Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * swap
- */
- void swap(Expected& that) noexcept(
- expected_detail::StrictAllOf<IsNothrowSwappable, Value, Error>::value) {
- if (this->uninitializedByException() || that.uninitializedByException())
- throw BadExpectedAccess();
- using std::swap;
- if (*this) {
- if (that) {
- swap(this->value_, that.value_);
- } else {
- Error e(std::move(that.error_));
- that.assignValue(std::move(this->value_));
- this->assignError(std::move(e));
- }
- } else {
- if (!that) {
- swap(this->error_, that.error_);
- } else {
- Error e(std::move(this->error_));
- this->assignValue(std::move(that.value_));
- that.assignError(std::move(e));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement