C++ API Reference
|
A reference counting pointer. More...
#include <MSharedPtr.h>
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... | |
MSharedPtr & | operator= (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> | |
MSharedPtr & | operator= (const MSharedPtr< U > &_rhs) noexcept |
Replaces the managed object with the object managed by _rhs. More... | |
MSharedPtr & | operator= (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> | |
MSharedPtr & | operator= (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... | |
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.
|
inlinenoexcept |
construct an MSharedPtr with no managed object
[in] | _ptr | a nullptr |
|
inlineexplicit |
Constructs an MSharedPtr with _ptr as the managed object.
U* must be a type which is convertible to T*.
[in] | _ptr | A pointer to an object to manage. |
|
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*.
[in] | _ptr | A pointer to an object to manage. |
[in] | _d | A deleter object for _ptr. |
|
inline |
Constructs an MSharedPtr with no managed object.
[in] | _ptr | A pointer to an object to manage. |
[in] | _d | A deleter object for _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.
[in] | _rhs | An MSharedPtr to share ownership with. |
[in] | _ptr | A pointer to an object. |
|
inlinenoexcept |
Constructs an MSharedPtr which shares ownership with _rhs.
[in] | _rhs | An MSharedPtr to share ownership with. |
|
inlinenoexcept |
Constructs an MSharedPtr which shares ownership with _rhs.
U* must be a type which is convertible to T*.
[in] | _rhs | An MSharedPtr to share ownership with, whose held type U* is convertible to T*. |
|
inlinenoexcept |
Move-constructs an MSharedPtr from _rhs.
After construction *this contains the original state of _rhs, and _rhs is empty and stores a nullptr.
[in] | _rhs | An MSharedPtr whose state should move into *this. |
|
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*.
[in] | _rhs | An MSharedPtr to whose state should move into this, and whose held type U* is convertible to T*. |
|
inline |
|
inline |
dereferences the stored pointer.
|
inline |
dereferences the stored pointer.
MSharedPtr<void>::operator*() is unspecified and the behavior is undefined.
|
inlineexplicit |
checks if the stored pointer is not null
|
inlinenoexcept |
Replaces the managed object with the object managed by _rhs.
Shares ownership with _rhs.
[in] | _rhs | An MSharedPtr to share ownership with. |
|
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*.
[in] | _rhs | An MSharedPtr to share ownership with, whose held type U* is convertible to T*. |
|
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.
[in] | _rhs | An MSharedPtr whose state should move into *this. |
|
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*.
[in] | _rhs | An MSharedPtr whose state should move into *this. |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinestaticnoexcept |
|
inlinestaticnoexcept |
|
inlinestaticnoexcept |
|
inlinestaticnoexcept |
|
inlinestaticnoexcept |
|
inlinestaticnoexcept |
|
inlinestaticnoexcept |
|
inlinestaticnoexcept |
|
inlinenoexcept |
Release ownership of the managed object.
After the call, *this manages no object.
|
inline |
Replace the managed object with _ptr.
U* must be a type which is convertible to T*.
[in] | _ptr | A pointer to an object to manage. |
|
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*.
[in] | _ptr | A pointer to an object to manage. |
[in] | _d | A deleter object for _ptr. |
|
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.
[in] | args | parameter list used for the constructor of held object. |