std::weak_ptr<T>::operator=
提供: cppreference.com
<tbody>
</tbody>
weak_ptr& operator=( const weak_ptr& r ) noexcept; |
(1) | (C++11以上) |
template< class Y > weak_ptr& operator=( const weak_ptr<Y>& r ) noexcept; |
(2) | (C++11以上) |
template< class Y > weak_ptr& operator=( const shared_ptr<Y>& r ) noexcept; |
(3) | (C++11以上) |
weak_ptr& operator=( weak_ptr&& r ) noexcept; |
(4) | (C++14以上) |
template< class Y > weak_ptr& operator=( weak_ptr<Y>&& r ) noexcept; |
(5) | (C++14以上) |
管理対象オブジェクトを r によって管理されているオブジェクトで置き換えます。 オブジェクトは r と共有されます。 r がオブジェクトを管理していなければ、 *this もオブジェクトを管理しません。
1-3)
std::weak_ptr<T>(r).swap(*this) と同等です。4,5)
std::weak_ptr<T>(std::move(r)).swap(*this) と同等です。引数
| r | - | オブジェクトを共有するスマートポインタ |
戻り値
*this。
ノート
処理系は一時的な weak_ptr オブジェクトを作成することなく要求を満たすかもしれません。
関連項目
新しい weak_ptr を作成します (パブリックメンバ関数) | |
| 管理対象オブジェクトを入れ替えます (パブリックメンバ関数) |