Nugget
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
eastl::weak_ptr< T > Class Template Reference

#include <shared_ptr.h>

Collaboration diagram for eastl::weak_ptr< T >:
Collaboration graph
[legend]

Public Types

typedef weak_ptr< T > this_type
 
typedef T element_type
 

Public Member Functions

 weak_ptr () EA_NOEXCEPT
 weak_ptr
 
 weak_ptr (const this_type &weakPtr) EA_NOEXCEPT
 
 weak_ptr (this_type &&weakPtr) EA_NOEXCEPT
 
template<typename U >
 weak_ptr (const weak_ptr< U > &weakPtr, typename eastl::enable_if< eastl::is_convertible< U *, element_type * >::value >::type *=0) EA_NOEXCEPT
 
template<typename U >
 weak_ptr (weak_ptr< U > &&weakPtr, typename eastl::enable_if< eastl::is_convertible< U *, element_type * >::value >::type *=0) EA_NOEXCEPT
 
template<typename U >
 weak_ptr (const shared_ptr< U > &sharedPtr, typename eastl::enable_if< eastl::is_convertible< U *, element_type * >::value >::type *=0) EA_NOEXCEPT
 
 ~weak_ptr ()
 ~weak_ptr
 
this_typeoperator= (const this_type &weakPtr) EA_NOEXCEPT
 
this_typeoperator= (this_type &&weakPtr) EA_NOEXCEPT
 
template<typename U >
eastl::enable_if< eastl::is_convertible< U *, element_type * >::value, this_type & >::type operator= (const weak_ptr< U > &weakPtr) EA_NOEXCEPT
 operator=(weak_ptr)
 
template<typename U >
eastl::enable_if< eastl::is_convertible< U *, element_type * >::value, this_type & >::type operator= (weak_ptr< U > &&weakPtr) EA_NOEXCEPT
 
template<typename U >
eastl::enable_if< eastl::is_convertible< U *, element_type * >::value, this_type & >::type operator= (const shared_ptr< U > &sharedPtr) EA_NOEXCEPT
 
shared_ptr< T > lock () const EA_NOEXCEPT
 
int use_count () const EA_NOEXCEPT
 
bool expired () const EA_NOEXCEPT
 
void reset ()
 
void swap (this_type &weakPtr)
 
template<typename U >
void assign (const weak_ptr< U > &weakPtr, typename eastl::enable_if< eastl::is_convertible< U *, element_type * >::value >::type *=0) EA_NOEXCEPT
 
template<typename U >
bool owner_before (const weak_ptr< U > &weakPtr) const EA_NOEXCEPT
 
template<typename U >
bool owner_before (const shared_ptr< U > &sharedPtr) const EA_NOEXCEPT
 owner_before
 
template<typename U >
bool less_than (const weak_ptr< U > &weakPtr) const EA_NOEXCEPT
 
void assign (element_type *pValue, ref_count_sp *pRefCount)
 

Protected Attributes

element_type * mpValue
 
ref_count_spmpRefCount
 The (weakly) owned pointer.
 

Friends

template<typename U >
class shared_ptr
 Reference count for owned pointer.
 

Detailed Description

template<typename T>
class eastl::weak_ptr< T >

weak_ptr

The weak_ptr class template stores a "weak reference" to an object that's already managed by a shared_ptr. To access the object, a weak_ptr can be converted to a shared_ptr using the shared_ptr constructor or the lock() member function. When the last shared_ptr to the object goes away and the object is deleted, the attempt to obtain a shared_ptr from the weak_ptr instances that refer to the deleted object will fail via lock() returning an empty shared_ptr.

The Allocator template argument manages the memory of the shared reference count and not the stored object. weak_ptr will not delete the stored object but instead can only delete the reference count on that object.

Constructor & Destructor Documentation

◆ weak_ptr() [1/5]

template<typename T >
eastl::weak_ptr< T >::weak_ptr ( const this_type weakPtr)
inline

weak_ptr Construction with self type.

◆ weak_ptr() [2/5]

template<typename T >
eastl::weak_ptr< T >::weak_ptr ( this_type &&  weakPtr)
inline

weak_ptr Move construction with self type.

◆ weak_ptr() [3/5]

template<typename T >
template<typename U >
eastl::weak_ptr< T >::weak_ptr ( const weak_ptr< U > &  weakPtr,
typename eastl::enable_if< eastl::is_convertible< U *, element_type * >::value >::type *  = 0 
)
inline

weak_ptr Constructs a weak_ptr from another weak_ptr.

◆ weak_ptr() [4/5]

template<typename T >
template<typename U >
eastl::weak_ptr< T >::weak_ptr ( weak_ptr< U > &&  weakPtr,
typename eastl::enable_if< eastl::is_convertible< U *, element_type * >::value >::type *  = 0 
)
inline

weak_ptr Move constructs a weak_ptr from another weak_ptr.

◆ weak_ptr() [5/5]

template<typename T >
template<typename U >
eastl::weak_ptr< T >::weak_ptr ( const shared_ptr< U > &  sharedPtr,
typename eastl::enable_if< eastl::is_convertible< U *, element_type * >::value >::type *  = 0 
)
inline

weak_ptr Constructs a weak_ptr from a shared_ptr.

Member Function Documentation

◆ assign() [1/2]

template<typename T >
template<typename U >
void eastl::weak_ptr< T >::assign ( const weak_ptr< U > &  weakPtr,
typename eastl::enable_if< eastl::is_convertible< U *, element_type * >::value >::type *  = 0 
)
inline

assign

Assignment via another weak_ptr.

◆ assign() [2/2]

template<typename T >
void eastl::weak_ptr< T >::assign ( element_type *  pValue,
ref_count_sp pRefCount 
)
inline

assign

Assignment through a T/ref_count_sp pair. This is used by external utility functions.

◆ less_than()

template<typename T >
template<typename U >
bool eastl::weak_ptr< T >::less_than ( const weak_ptr< U > &  weakPtr) const
inline

less_than For compatibility with pre-C++11 weak_ptr. Use owner_before instead.

◆ operator=() [1/2]

template<typename T >
template<typename U >
eastl::enable_if<eastl::is_convertible<U*, element_type*>::value, this_type&>::type eastl::weak_ptr< T >::operator= ( const shared_ptr< U > &  sharedPtr)
inline

operator=(shared_ptr) Assigns to a weak_ptr from a shared_ptr.

◆ operator=() [2/2]

template<typename T >
this_type& eastl::weak_ptr< T >::operator= ( const this_type weakPtr)
inline

operator=(weak_ptr) assignment to self type.

◆ owner_before()

template<typename T >
template<typename U >
bool eastl::weak_ptr< T >::owner_before ( const weak_ptr< U > &  weakPtr) const
inline

owner_before C++11 function for ordering.


The documentation for this class was generated from the following file: