|
| 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. More...
|
|
| 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. More...
|
|
| Ref_ptr (T *o, bool d) noexcept |
| Create a shared pointer from a raw pointer without creating a new reference. More...
|
|
T * | get () const noexcept |
| Return a raw pointer to the object this shared pointer points to. More...
|
|
T * | ptr () const noexcept |
| Return a raw pointer to the object this shared pointer points to. More...
|
|
T * | release () noexcept |
| Release the shared pointer without removing the reference. More...
|
|
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.
template<typename T = void, template< typename X > class CNT = Default_ref_counter>
template<typename X >
Create a shared pointer from a raw pointer.
In contrast to C++11 shared_ptr it is safe to use this constructor multiple times and have the same reference counter.
Definition at line 111 of file ref_ptr.
template<typename T = void, template< typename X > class CNT = Default_ref_counter>
Return a raw pointer to the object this shared pointer points to.
This does not release the pointer or decrease the reference count.
Definition at line 131 of file ref_ptr.
template<typename T = void, template< typename X > class CNT = Default_ref_counter>
Return a raw pointer to the object this shared pointer points to.
This does not release the pointer or decrease the reference count.
Definition at line 137 of file ref_ptr.