Regina Calculation Engine
|
A reference counted smart pointer that supports alternate models of ownership. More...
#include <utilities/safeptr.h>
Public Types | |
typedef T | element_type |
The pointee type. More... | |
Public Member Functions | |
SafePtr (T *object) | |
Constructs a new safe pointer that points to the given object. More... | |
template<class Y > | |
SafePtr (const SafePtr< Y > &other) | |
Copy constructor. More... | |
T * | get () const |
Returns a raw pointer to the pointee, or null if the pointee has already been destroyed. More... | |
A reference counted smart pointer that supports alternate models of ownership.
Specifically, there are two models of ownership for the pointee (of type T):
The pointee can indicate at runtime which model of ownership is in effect, through the return value of the function T::hasOwner().
The requirements for the pointee type T are as follows:
SafePointeeBase<T>
.bool hasOwner()
, which returns true
if and only if some other C++ object (which is not a SafePtr) owns the pointee.Destruction works as follows:
null
.false
.Under the hood, SafePtr uses SafeRemnant to achieve this.
typedef T regina::SafePtr< T >::element_type |
The pointee type.
This typedef is used by the boost infrastructure.
|
inline |
Constructs a new safe pointer that points to the given object.
object | the pointee. This may be null . |
|
inline |
|
inline |
Returns a raw pointer to the pointee, or null
if the pointee has already been destroyed.