C++ API Reference
MSharedPtr< T > Class Template Reference

A reference counting pointer. More...

#include <MSharedPtr.h>

+ Inheritance diagram for MSharedPtr< T >:

Public Member Functions

T * get () const
 
T * operator-> () const
 dereferences the stored pointer. More...
 
decltype(auto) operator* () const
 dereferences the stored pointer. More...
 
 operator bool () const
 checks if the stored pointer is not null More...
 
constexpr MSharedPtr () noexcept
 construct an MSharedPtr with no managed object
 
constexpr MSharedPtr (std::nullptr_t _ptr) noexcept
 construct an MSharedPtr with no managed object More...
 
template<class U , typename std::enable_if< std::is_convertible< U *, T * >::value, int >::type = 0>
 MSharedPtr (U *_ptr)
 Constructs an MSharedPtr with _ptr as the managed object. More...
 
template<class U , class Deleter , typename std::enable_if< std::is_convertible< U *, T * >::value, int >::type = 0>
 MSharedPtr (U *_ptr, Deleter _d)
 Constructs an MShared with _ptr as the managed object. More...
 
template<class Deleter >
 MSharedPtr (std::nullptr_t _ptr, Deleter _d)
 Constructs an MSharedPtr with no managed object. More...
 
template<class U >
 MSharedPtr (const MSharedPtr< U > &_rhs, element_type *_ptr) noexcept
 Constructs an MShared with the same management as _rhs, but which stores _ptr. More...
 
 MSharedPtr (const MSharedPtr &_rhs) noexcept
 Constructs an MSharedPtr which shares ownership with _rhs. More...
 
template<class U , typename std::enable_if< std::is_convertible< U *, T * >::value, int >::type = 0>
 MSharedPtr (const MSharedPtr< U > &_rhs) noexcept
 Constructs an MSharedPtr which shares ownership with _rhs. More...
 
 MSharedPtr (MSharedPtr &&_rhs) noexcept
 Move-constructs an MSharedPtr from _rhs. More...
 
template<class U , typename std::enable_if< std::is_convertible< U *, T * >::value, int >::type = 0>
 MSharedPtr (MSharedPtr< U > &&_rhs) noexcept
 Move-constructs an MSharedPtr from _rhs. More...
 
MSharedPtroperator= (const MSharedPtr &_rhs) noexcept
 Replaces the managed object with the object managed by _rhs. More...
 
template<class U , typename std::enable_if< std::is_convertible< U *, T * >::value, int >::type = 0>
MSharedPtroperator= (const MSharedPtr< U > &_rhs) noexcept
 Replaces the managed object with the object managed by _rhs. More...
 
MSharedPtroperator= (MSharedPtr &&_rhs) noexcept
 Transfers ownership of the managed object in _rhs to this. More...
 
template<class U , typename std::enable_if< std::is_convertible< U *, T * >::value, int >::type = 0>
MSharedPtroperator= (MSharedPtr< U > &&_rhs) noexcept
 Transfers ownership of the managed object in _rhs to this. More...
 
template<class U >
bool operator== (const MSharedPtr< U > &_rhs) const noexcept
 
template<class U >
bool operator!= (const MSharedPtr< U > &_rhs) const noexcept
 
template<class U >
bool operator< (const MSharedPtr< U > &_rhs) const noexcept
 
template<class U >
bool operator> (const MSharedPtr< U > &_rhs) const noexcept
 
template<class U >
bool operator<= (const MSharedPtr< U > &_rhs) const noexcept
 
template<class U >
bool operator>= (const MSharedPtr< U > &_rhs) const noexcept
 
void reset () noexcept
 Release ownership of the managed object. More...
 
template<class U , typename std::enable_if< std::is_convertible< U *, T * >::value, int >::type = 0>
void reset (U *_ptr)
 Replace the managed object with _ptr. More...
 
template<class U , class Deleter , typename std::enable_if< std::is_convertible< U *, T * >::value, int >::type = 0>
void reset (U *_ptr, Deleter _d)
 Replace the managed object with _ptr and use Deleter _d as the deleter. More...
 

Static Public Member Functions

template<class U >
static MSharedPtr< T > static_pointer_cast (const MSharedPtr< U > &_rhs) noexcept
 
template<class U >
static MSharedPtr< T > static_pointer_cast (MSharedPtr< U > &&_rhs) noexcept
 
template<class U >
static MSharedPtr< T > dynamic_pointer_cast (const MSharedPtr< U > &_rhs) noexcept
 
template<class U >
static MSharedPtr< T > dynamic_pointer_cast (MSharedPtr< U > &&_rhs) noexcept
 
template<class U >
static MSharedPtr< T > const_pointer_cast (const MSharedPtr< U > &_rhs) noexcept
 
template<class U >
static MSharedPtr< T > const_pointer_cast (MSharedPtr< U > &&_rhs) noexcept
 
template<class U >
static MSharedPtr< T > reinterpret_pointer_cast (const MSharedPtr< U > &_rhs) noexcept
 
template<class U >
static MSharedPtr< T > reinterpret_pointer_cast (MSharedPtr< U > &&_rhs) noexcept
 
template<class... Args>
static MSharedPtr< T > make (Args &&..._args)
 Constructs an object of type T using args as the paramter list of the constructor of T and wraps the resulting object in an MSharedPtr. More...
 

Detailed Description

template<class T>
class MSharedPtr< T >

A reference counting pointer.

MSharedPtr is a smart pointer that retains ownership of an object through a pointer. Several MSharedPtr objects may own the same object. The object is destroyed and its memory deallocated when no MSharedPtr's exist which own the object.

Examples:
apiMeshShape/apiMeshGeometryOverride.cpp, apiMeshShape/apiMeshSubSceneOverride.cpp, exampleFalloff/smoothFalloffNode.cpp, and gpuCache/gpuCacheSubSceneOverride.cpp.

Constructor & Destructor Documentation

constexpr MSharedPtr ( std::nullptr_t  _ptr)
inlinenoexcept

construct an MSharedPtr with no managed object

Parameters
[in]_ptra nullptr
MSharedPtr ( U *  _ptr)
inlineexplicit

Constructs an MSharedPtr with _ptr as the managed object.

U* must be a type which is convertible to T*.

Parameters
[in]_ptrA pointer to an object to manage.
MSharedPtr ( U *  _ptr,
Deleter  _d 
)
inline

Constructs an MShared with _ptr as the managed object.

Constructs an MSharedPtr with _ptr as the managed object. Deleter _d is used to delete the object. The expression _d(_ptr) must be well-formed, have well-defined behavior and not throw exceptions.

U* must be a type which is convertible to T*.

Parameters
[in]_ptrA pointer to an object to manage.
[in]_dA deleter object for _ptr.
MSharedPtr ( std::nullptr_t  _ptr,
Deleter  _d 
)
inline

Constructs an MSharedPtr with no managed object.

Parameters
[in]_ptrA pointer to an object to manage.
[in]_dA deleter object for _ptr.
MSharedPtr ( const MSharedPtr< U > &  _rhs,
element_type *  _ptr 
)
inlinenoexcept

Constructs an MShared with the same management as _rhs, but which stores _ptr.

Create an MSharedPtr which shared ownership information with _rhs, but holds an unrelated, unmanaged pointer _ptr. It is the responsibility of the programmer to ensure that _ptr remains valid as long as this shared_ptr exists.

Parameters
[in]_rhsAn MSharedPtr to share ownership with.
[in]_ptrA pointer to an object.
MSharedPtr ( const MSharedPtr< T > &  _rhs)
inlinenoexcept

Constructs an MSharedPtr which shares ownership with _rhs.

Parameters
[in]_rhsAn MSharedPtr to share ownership with.
MSharedPtr ( const MSharedPtr< U > &  _rhs)
inlinenoexcept

Constructs an MSharedPtr which shares ownership with _rhs.

U* must be a type which is convertible to T*.

Parameters
[in]_rhsAn MSharedPtr to share ownership with, whose held type U* is convertible to T*.
MSharedPtr ( MSharedPtr< T > &&  _rhs)
inlinenoexcept

Move-constructs an MSharedPtr from _rhs.

After construction *this contains the original state of _rhs, and _rhs is empty and stores a nullptr.

Parameters
[in]_rhsAn MSharedPtr whose state should move into *this.
MSharedPtr ( MSharedPtr< U > &&  _rhs)
inlinenoexcept

Move-constructs an MSharedPtr from _rhs.

After construction *this contains the original state of _rhs, and _rhs is empty and stores a nullptr. U* must be a type which is convertible to T*.

Parameters
[in]_rhsAn MSharedPtr to whose state should move into this, and whose held type U* is convertible to T*.

Member Function Documentation

T* get ( ) const
inline
Returns
the stored pointer.
T* operator-> ( ) const
inline

dereferences the stored pointer.

Returns
the stored pointer.
decltype(auto) operator* ( ) const
inline

dereferences the stored pointer.

MSharedPtr<void>::operator*() is unspecified and the behavior is undefined.

Returns
T& of the stored pointer.
operator bool ( ) const
inlineexplicit

checks if the stored pointer is not null

Returns
true true if the stored pointer is not null
MSharedPtr& operator= ( const MSharedPtr< T > &  _rhs)
inlinenoexcept

Replaces the managed object with the object managed by _rhs.

Shares ownership with _rhs.

Parameters
[in]_rhsAn MSharedPtr to share ownership with.
MSharedPtr& operator= ( const MSharedPtr< U > &  _rhs)
inlinenoexcept

Replaces the managed object with the object managed by _rhs.

Shares ownership with _rhs.

U* must be a type which is convertible to T*.

Parameters
[in]_rhsAn MSharedPtr to share ownership with, whose held type U* is convertible to T*.
MSharedPtr& operator= ( MSharedPtr< T > &&  _rhs)
inlinenoexcept

Transfers ownership of the managed object in _rhs to this.

After assignment *this contains the original state of _rhs, and _rhs is empty and stores a nullptr.

Parameters
[in]_rhsAn MSharedPtr whose state should move into *this.
MSharedPtr& operator= ( MSharedPtr< U > &&  _rhs)
inlinenoexcept

Transfers ownership of the managed object in _rhs to this.

After assignment *this contains the original state of _rhs, and _rhs is empty and stores a nullptr. U* must be a type which is convertible to T*.

Parameters
[in]_rhsAn MSharedPtr whose state should move into *this.
bool operator== ( const MSharedPtr< U > &  _rhs) const
inlinenoexcept
Returns
get() == _rhs.get()
bool operator!= ( const MSharedPtr< U > &  _rhs) const
inlinenoexcept
Returns
!(*this == _rhs)
bool operator< ( const MSharedPtr< U > &  _rhs) const
inlinenoexcept
Returns
get() < _rhs.get()
bool operator> ( const MSharedPtr< U > &  _rhs) const
inlinenoexcept
Returns
_rhs < *this
bool operator<= ( const MSharedPtr< U > &  _rhs) const
inlinenoexcept
Returns
!(_rhs < *this)
bool operator>= ( const MSharedPtr< U > &  _rhs) const
inlinenoexcept
Returns
!(*this < _rhs)
static MSharedPtr<T> static_pointer_cast ( const MSharedPtr< U > &  _rhs)
inlinestaticnoexcept
Returns
static_cast<T*>(_rhs.get())
static MSharedPtr<T> static_pointer_cast ( MSharedPtr< U > &&  _rhs)
inlinestaticnoexcept
Returns
static_cast<T*>(_rhs.get())
static MSharedPtr<T> dynamic_pointer_cast ( const MSharedPtr< U > &  _rhs)
inlinestaticnoexcept
Returns
dynamic_cast<T*>(_rhs.get())
Examples:
gpuCache/gpuCacheSubSceneOverride.cpp.
static MSharedPtr<T> dynamic_pointer_cast ( MSharedPtr< U > &&  _rhs)
inlinestaticnoexcept
Returns
dynamic_cast<T*>(_rhs.get())
static MSharedPtr<T> const_pointer_cast ( const MSharedPtr< U > &  _rhs)
inlinestaticnoexcept
Returns
const_cast<T*>(_rhs.get())
static MSharedPtr<T> const_pointer_cast ( MSharedPtr< U > &&  _rhs)
inlinestaticnoexcept
Returns
const_cast<T*>(_rhs.get())
static MSharedPtr<T> reinterpret_pointer_cast ( const MSharedPtr< U > &  _rhs)
inlinestaticnoexcept
Returns
reinterpret_cast<T*>(_rhs.get())
static MSharedPtr<T> reinterpret_pointer_cast ( MSharedPtr< U > &&  _rhs)
inlinestaticnoexcept
Returns
reinterpret_cast<T*>(_rhs.get())
void reset ( )
inlinenoexcept

Release ownership of the managed object.

After the call, *this manages no object.

void reset ( U *  _ptr)
inline

Replace the managed object with _ptr.

U* must be a type which is convertible to T*.

Parameters
[in]_ptrA pointer to an object to manage.
void reset ( U *  _ptr,
Deleter  _d 
)
inline

Replace the managed object with _ptr and use Deleter _d as the deleter.

Deleter _d is used to delete the object. The expression _d(_ptr) must be well-formed, have well-defined behavior and not throw exceptions.

U* must be a type which is convertible to T*.

Parameters
[in]_ptrA pointer to an object to manage.
[in]_dA deleter object for _ptr.
static MSharedPtr<T> make ( Args &&...  _args)
inlinestatic

Constructs an object of type T using args as the paramter list of the constructor of T and wraps the resulting object in an MSharedPtr.

The memory for the constructed object and the MSharedPtr are allocated together in a single heap allocation, improving performance.

Parameters
[in]argsparameter list used for the constructor of held object.
Returns
MSharedPtr which manages the lifetime of constructed object.
Examples:
apiMeshShape/apiMeshSubSceneOverride.cpp, footPrintNode_AnimatedMaterial/footPrintNode_GeometryOverride_AnimatedMaterial.cpp, and hwPhongShader/hwPhongShader.cpp.

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