std::swap(std::unique_ptr) - cppreference.com (original) (raw)
Specializes the std::swap algorithm for std::unique_ptr. Swaps the contents of lhs and rhs. Calls lhs.swap(rhs).
| This function does not participate in overload resolution unless std::is_swappable_v<D> is true. | (since C++17) |
|---|
[edit] Parameters
| lhs, rhs | - | smart pointers whose contents to swap |
|---|
[edit] Return value
(none)
[edit] Complexity
Constant.
[edit] Example
Output:
Foo... Foo... p1=100 p2=200 p1=200 p2=100 ~Foo... p1=nullptr p2=100 p1=100 p2=nullptr ~Foo...
[edit] See also
| | swaps the values of two objects (function template) [edit] | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | | swaps the contents (public member function) [edit] |