Created
October 17, 2019 18:03
-
-
Save vinniefalco/23e29719f4d0a54f01f8929c2b86f72d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void | |
value:: | |
swap(value& other) | |
{ | |
if(*get_storage() != *other.get_storage()) | |
{ | |
value temp1( | |
std::move(*this), | |
other.get_storage()); | |
value temp2( | |
std::move(other), | |
this->get_storage()); | |
other.~value(); | |
::new(&other) value(pilfer(temp1)); | |
this->~value(); | |
::new(this) value(pilfer(temp2)); | |
} | |
else | |
{ | |
value tmp(pilfer(*this)); | |
this->~value(); | |
::new(this) value(pilfer(other)); | |
other.~value(); | |
::new(&other) value(pilfer(tmp)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment