std::swap(std::weak_ptr)

来自cppreference.com
 
 
内存管理库
分配器
内存资源
未初始化存储 (C++20 前*)
垃圾收集器支持 (C++23 前)
 
 
在标头 <memory> 定义
template< class T >
void swap( std::weak_ptr<T>& lhs, std::weak_ptr<T>& rhs ) noexcept;
(C++11 起)
(C++26 起为 constexpr)

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

参数

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

复杂度

常数。

示例

cpp/memory/weak ptr/swap2/example

参阅

交换两个对象的值
(函数模板) [编辑]
交换内容
(公开成员函数) [编辑]
Morty Proxy This is a proxified and sanitized view of the page, visit original site.