|
| OFshared_ptr (T *const pt=OFnullptr) |
| Constructs a shared_ptr with pt as the managed object.
|
|
| OFshared_ptr (const OFshared_ptr &other) |
| Constructs a shared_ptr which shares ownership of the object managed by other.
|
|
OFshared_ptr & | operator= (const OFshared_ptr &other) |
| Replaces the managed object with the one managed by other.
|
|
| ~OFshared_ptr () |
| If *this owns an object and it is the last shared_ptr owning it, the object is destroyed.
|
|
| operator OFBool () const |
| Checks if *this manages an object, i.e.
|
|
OFBool | operator! () const |
| Checks if *this does not manage an object, i.e.
|
|
T & | operator* () const |
| Dereferences pointer to the managed object.
|
|
T * | operator-> () const |
| Dereferences pointer to the managed object.
|
|
T * | get () const |
| Returns a pointer to the managed object.
|
|
void | reset (T *const pt=OFnullptr) |
| Replaces the managed object with an object pointed to by pt.
|
|
template<typename T>
class OFshared_ptr< T >
OFshared_ptr is a smart pointer that retains shared ownership of an object through a pointer.
Several OFshared_ptr objects may own the same object; the object is destroyed when the last remaining OFshared_ptr referring to it is destroyed or reset.
An OFshared_ptr may also own no objects, in which case it is called empty.
OFshared_ptr meets the requirements of CopyConstructible and CopyAssignable.
- Template Parameters
-
T | the type of the managed object, e.g. int for an OFshared_ptr behaving like an int*. |
- Note
- this implementation is meant to be a subset of the c++11's std::shared_ptr that lacks the following features: swap support, support for weak references, atomic access to the managed object, custom deleters and some functions like comparing OFshared_ptrs or read access to the reference counter. see http://en.cppreference.com/w/cpp/memory/shared_ptr to compare OFshared_ptr against std::shared_ptr.