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 70 of file ref_ptr.