Evo C++ Library v0.5.1
|
#include <evo/ptr.h>
Shared smart pointer to single object.
SharedPtr<T[]> is specialized for arrays so the pointer is freed with delete[]. However an array SharedPtr<T[]> doesn't support unshare() (array size isn't known).
See Managed Pointers
C++11:
T | Type to use pointer to (not the raw pointer type) |
Output:
Public Types | |
typedef PtrBase< T, T * > | Base |
This pointer base type. More... | |
typedef void | EvoNullableType |
Identify as nullable type. More... | |
typedef T | Item |
Item type dereferenced to. More... | |
typedef SharedPtr< T, TSize > | This |
This pointer type. More... | |
Public Member Functions | |
SharedPtr () | |
Constructor to start with null pointer. More... | |
SharedPtr (T *ptr) | |
Constructor. More... | |
SharedPtr (const This &src) | |
Copy constructor. More... | |
SharedPtr (This &&src) | |
Move constructor (C++11). More... | |
~SharedPtr () | |
Destructor. More... | |
This & | clear () |
Release pointer and set as null. More... | |
bool | null () const |
Get whether pointer is null. More... | |
operator SafeBoolType () const | |
Safe (explicit) evaluation as bool type. More... | |
bool | operator! () const |
Negation operator checks if NULL. More... | |
bool | operator!= (const Base &ptr) const |
Inequality operator. More... | |
bool | operator!= (void *ptr) const |
Inequality operator. More... | |
const T & | operator* () const |
Dereference operator (const). More... | |
T & | operator* () |
Dereference operator (mutable). More... | |
const T * | operator-> () const |
Member access operator (const). More... | |
T * | operator-> () |
Member access operator (mutable). More... | |
bool | operator< (const Base &ptr) const |
Less-than operator. More... | |
bool | operator< (void *ptr) const |
Less-than operator. More... | |
bool | operator<= (const Base &ptr) const |
Less-than-or-equals operator. More... | |
bool | operator<= (void *ptr) const |
Less-than-or-equals operator. More... | |
This & | operator= (const This &src) |
Copy/Assignment operator. More... | |
This & | operator= (T *ptr) |
Assignment operator for new pointer. More... | |
This & | operator= (This &&src) |
Move assignment operator (C++11). More... | |
bool | operator== (const Base &ptr) const |
Equality operator. More... | |
bool | operator== (void *ptr) const |
Equality operator. More... | |
bool | operator> (const Base &ptr) const |
Greater-than operator. More... | |
bool | operator> (void *ptr) const |
Greater-than operator. More... | |
bool | operator>= (const Base &ptr) const |
Greater-than-or-equals operator. More... | |
bool | operator>= (void *ptr) const |
Greater-than-or-equals operator. More... | |
const T & | operator[] (ulong index) const |
Array access operator (const). More... | |
T & | operator[] (ulong index) |
Array access operator (mutable). More... | |
const T * | ptr () const |
Get current pointer (const). More... | |
T * | ptr () |
Get current pointer (mutable). More... | |
This & | set () |
Set as null – same as clear(). More... | |
bool | shared () const |
Get whether pointer is shared (reference count > 1). More... | |
This & | unshare () |
Unshare pointer by setting as a new copy, if shared. More... | |
bool | valid () const |
Get whether pointer is valid (not null). More... | |
Public Attributes | |
T * | ptr_ |
Pointer. More... | |
Protected Member Functions | |
void | free () |
Protected Attributes | |
TSize * | refs_ |
|
inherited |
Identify as nullable type.
typedef T Item |
Item type dereferenced to.
|
inline |
Constructor to start with null pointer.
|
inline |
Constructor.
ptr | Pointer to set, NULL for none |
Copy constructor.
src | Source pointer |
|
inline |
Destructor.
|
inline |
Release pointer and set as null.
|
inlineprotected |
|
inlineinherited |
Get whether pointer is null.
|
inlineinherited |
Safe (explicit) evaluation as bool type.
|
inlineinherited |
Negation operator checks if NULL.
Inequality operator.
ptr | Pointer to compare to |
|
inlineinherited |
Inequality operator.
ptr | Pointer to compare to |
|
inlineinherited |
Dereference operator (const).
|
inlineinherited |
Dereference operator (mutable).
|
inlineinherited |
Member access operator (const).
|
inlineinherited |
Member access operator (mutable).
|
inlineinherited |
Less-than operator.
ptr | Pointer to compare to |
|
inlineinherited |
Less-than operator.
ptr | Pointer to compare to |
|
inlineinherited |
Less-than-or-equals operator.
ptr | Pointer to compare to |
|
inlineinherited |
Less-than-or-equals operator.
ptr | Pointer to compare to |
Copy/Assignment operator.
src | Source pointer |
|
inline |
Assignment operator for new pointer.
ptr | Pointer to set |
Move assignment operator (C++11).
src | Source to move |
|
inlineinherited |
Equality operator.
ptr | Pointer to compare to |
|
inlineinherited |
Equality operator.
ptr | Pointer to compare to |
|
inlineinherited |
Greater-than operator.
ptr | Pointer to compare to |
|
inlineinherited |
Greater-than operator.
ptr | Pointer to compare to |
|
inlineinherited |
Greater-than-or-equals operator.
ptr | Pointer to compare to |
|
inlineinherited |
Greater-than-or-equals operator.
ptr | Pointer to compare to |
|
inlineinherited |
Array access operator (const).
|
inlineinherited |
Array access operator (mutable).
|
inlineinherited |
Get current pointer (const).
|
inlineinherited |
Get current pointer (mutable).
|
inline |
Get whether pointer is shared (reference count > 1).
|
inline |
Unshare pointer by setting as a new copy, if shared.
|
inlineinherited |
Get whether pointer is valid (not null).
|
inherited |
Pointer.
|
protected |