std::swap(std::shared_ptr)

< cpp‎ | memory‎ | shared ptr

定义于头文件 <memory>
template< class T >
void swap( std::shared_ptr<T>& lhs, std::shared_ptr<T>& rhs ) noexcept;
(C++11 起)

std::shared_ptr 特化 std::swap 算法。交换 lhsrhs 的内容。调用 lhs.swap(rhs)


参数

lhs, rhs - 要交换内容的智能指针

返回值

(无)

复杂度

常数

参阅

交换两个对象的值
(函数模板)
交换内容
(公开成员函数)