SHARE
TWEET

Untitled

a guest Mar 13th, 2017 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   /**
  2.    * swap
  3.    */
  4.   void swap(Expected& that) noexcept(
  5.       expected_detail::StrictAllOf<IsNothrowSwappable, Value, Error>::value) {
  6.     if (this->uninitializedByException() || that.uninitializedByException())
  7.       throw BadExpectedAccess();
  8.     using std::swap;
  9.     if (*this) {
  10.       if (that) {
  11.         swap(this->value_, that.value_);
  12.       } else {
  13.         Error e(std::move(that.error_));
  14.         that.assignValue(std::move(this->value_));
  15.         this->assignError(std::move(e));
  16.       }
  17.     } else {
  18.       if (!that) {
  19.         swap(this->error_, that.error_);
  20.       } else {
  21.         Error e(std::move(this->error_));
  22.         this->assignValue(std::move(that.value_));
  23.         that.assignError(std::move(e));
  24.       }
  25.     }
  26.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top