std::shared_ptr::operator=
来自cppreference.com
< cpp | memory | shared ptr
|
|
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
| shared_ptr& operator=( const shared_ptr& r ); |
(1) | |
| template< class Y > shared_ptr& operator=( const shared_ptr<Y>& r ); |
(1) | |
| shared_ptr& operator=( shared_ptr&& r ); |
(2) | |
| template< class Y > shared_ptr& operator=( shared_ptr<Y>&& r ); |
(2) | |
| template< class Y > shared_ptr& operator=( std::auto_ptr<Y>&& r ); |
(3) | |
| template< class Y, class Deleter > shared_ptr& operator=( std::unique_ptr<Y,Deleter>&& r ); |
(4) | |
替换与被管理对象的管理
1) r.原文:
Replaces the managed object with the one managed by
r.r股份标的物所有权的管理。如果r管理对象,*this管理也没有对象。模板超载不参与重载决议,如果Y*是隐式转换为T*。相当于shared_ptr<T> p(r).swap(*this).原文:
Shares ownership of the object managed by
r. If r manages no object, *this manages no object too. The templated overload doesn't participate in the overload resolution if Y* is not implicitly convertible to T*. Equivalent to shared_ptr<T> p(r).swap(*this).移动分配一个
3) shared_ptrr。在分配之后,*this包含以前的状态r的副本,r是空的。模板超载不参与重载决议,如果Y*是隐式转换为T*。相当于shared_ptr<T> p(std::move(r)).swap(*this).原文:
Move-assigns a
shared_ptr from r. After the assignment, *this contains a copy of the previous state of r, r is empty. The templated overload doesn't participate in the overload resolution if Y* is not implicitly convertible to T*. Equivalent to shared_ptr<T> p(std::move(r)).swap(*this).| 本章尚未完成 |
r到*this管理的对象的所有权转移。存储未来的管理对象删除的删除相关的r。 r管理后没有对象的调用。相当于shared_ptr<T> p(std::move(r)).swap(*this).原文:
Transfers the ownership of the object managed by
r to *this. The deleter associated to r is stored for future deletion of the managed object. r manages no object after the call. Equivalent to shared_ptr<T> p(std::move(r)).swap(*this).目录 |
[编辑] 参数
| r | - | 另一个智能指针共享所有权或收购的所有权
原文: another smart pointer to share the ownership to or acquire the ownership from |
[编辑] 返回值
*this
[编辑] 注释
实现可满足要求,而无需创建一个临时
shared_ptr对象.原文:
The implementation may meet the requirements without creating a temporary
shared_ptr object.[编辑] 例外
1-2) 3)(无)
4-5)
[编辑] 示例
| 本章尚未完成 原因:暂无示例 |
[编辑] 另请参阅
| 取代管理的对象 (公共成员函数) | |