|
| Ref_ptr () noexcept |
| Default constructor creates a pointer with no managed object.
|
|
| Ref_ptr (Wp const &o) noexcept |
| Create a shared pointer from a weak pointer.
|
|
| Ref_ptr (decltype(nullptr) n) noexcept |
| allow creation from nullptr
|
|
template<typename X > |
| Ref_ptr (X *o) noexcept |
| Create a shared pointer from a raw pointer.
|
|
| Ref_ptr (T *o, bool d) noexcept |
| Create a shared pointer from a raw pointer without creating a new reference.
|
|
T * | get () const noexcept) |
| Return a raw pointer to the object this shared pointer points to.
|
|
T * | ptr () const noexcept) |
| Return a raw pointer to the object this shared pointer points to.
|
|
T * | release () noexcept |
| Release the shared pointer without removing the reference.
|
|
template<typename T = void, template< typename X > class CNT = Default_ref_counter>
class cxx::Ref_ptr< T, CNT >
A reference-counting pointer with automatic cleanup.
- Template Parameters
-
T | Type of object the pointer points to. |
CNT | Type of management class that manages the life time of the object. |
This pointer is similar to the standard C++-11 shared_ptr but it does the reference counting directly in the object being pointed to, so that no additional management structures need to be allocated from the heap.
Classes that use this pointer type must implement two functions:
int remove_ref()
is called when a reference is removed and must return 0 when there are no further references to the object.
void add_ref()
is called when another ref_ptr to the object is created.
Ref_obj provides a simple implementation of this interface from which classes may inherit.
- Examples
- tmpfs/lib/src/fs.cc.
Definition at line 81 of file ref_ptr.