Namespaces
Variants
Views
Actions

std::weak_ptr::operator=

From cppreference.com
< cpp‎ | memory‎ | weak ptr
Revision as of 13:45, 2 November 2012 by P12bot (Talk | contribs)

 
 
 
 
 

Template:ddcl list begin <tr class="t-dcl ">

<td >
weak_ptr& operator=( const weak_ptr& r );
</td>

<td > (1) </td> <td > (since C++11) </td> </tr> <tr class="t-dcl ">

<td >
template< class Y >
weak_ptr& operator=( const weak_ptr<Y>& r );
</td>

<td > (2) </td> <td > (since C++11) </td> </tr> <tr class="t-dcl ">

<td >
template< class Y >
weak_ptr& operator=( const shared_ptr<Y>& r );
</td>

<td > (3) </td> <td > (since C++11) </td> </tr> Template:ddcl list end

Replaces the managed object with the one managed by r. The object is shared with r. If r manages no object, *this manages no object too. Equivalent to weak_ptr<T>(r).swap(*this).

Contents

Parameters

r - smart pointer to share an object with

Return value

*this

Exceptions

noexcept specification:  
noexcept
  

Notes

The implementation may meet the requirements without creating a temporary weak_ptr object.