#include <stlsoft/smartptr/ref_ptr.hpp>
Its notable feature is that it supports forward declaration of the leaf interface so long as the base counting interface is visible in the scope of the template parameterisation.
| T | The counted type (i.e. a concrete class) | |
| I | The interface type | |
| U | The upcast intermediate type | 
by_library/com_utility/creation_functions/creation_functions.cpp, by_library/com_utility/rot_functions/rot_functions.cpp, by_library/conversion/interface_cast/interface_cast.cpp, and by_project/comstl/comstl.cpp.
| Public Types | |
| Types | |
| typedef bool_t | bool_type | 
| The Boolean type. | |
| typedef I | interface_type | 
| The interface type: the type of the RCI (Reference-Counted Interface). | |
| typedef T | counted_type | 
| The counted type: the concrete type of the objects whose instances will be managed. | |
| typedef U | upcast_type | 
| The up-cast type: the type used to disambiguate upcasts between T and I. | |
| typedef ref_ptr< T, I, U > | class_type | 
| The current instantiation of the type. | |
| typedef I | element_type | 
| This to be member-type-compatible with std::auto_ptr. | |
| typedef counted_type * | resource_type | 
| This is to be compatible with the get_invoker component. | |
| typedef counted_type const * | const_resource_type | 
| Public Member Functions | |
| Construction | |
| ref_ptr () | |
| Default constructor. | |
| ref_ptr (counted_type *c, bool_type bAddRef) | |
| Construct from a raw pointer to the counted type, and a boolean that indicates whether a reference should be taken on the instance. | |
| ref_ptr (class_type const &rhs) | |
| Creates a copy of the given ref_ptr instance, and increments the reference count on its referent object, if any. | |
| template<typename T2, typename I2, typename U2> | |
| ref_ptr (ref_ptr< T2, I2, U2 > &rhs) | |
| Copy constructs from an instance with different interface and/or counted type. | |
| ~ref_ptr () throw () | |
| Destructor. | |
| class_type & | operator= (class_type const &rhs) | 
| Copy assignment from a ref_ptr instance of the same type. | |
| template<typename T2, typename U2> | |
| class_type & | operator= (ref_ptr< T2, I, U2 > &rhs) | 
| Copy assignment from an instance of ref_ptr with a different counted_type (but the same interface type). | |
| Operations | |
| void | swap (class_type &rhs) | 
| Swaps the managed instance of thiswithrhs. | |
| void | set (counted_type *c, bool_type bAddRef) | 
| Assigns a reference-counted type to the smart pointer. | |
| void | close () | 
| Closes the instance, releasing the managed pointer. | |
| counted_type * | detach () | 
| Detaches the managed instance, and returns it to the caller, which takes responsibility for ensuring that the resource is not leaked. | |
| Equality Comparison | |
| bool_type | equal (class_type const &rhs) const | 
| Evaluates whether two instances are equal. | |
| Accessors | |
| bool_type | empty () const | 
| Determines whether the instance is empty. | |
| bool_type | operator! () const | 
| Determines whether the instance is empty. | |
| counted_type * | get () const | 
| Provides raw-pointer access to the instance. | |
| counted_type * | operator-> () | 
| Returns the interface pointer. | |
| counted_type const * | operator-> () const | 
| Returns the interface pointer. | |
| counted_type & | operator* () | 
| Returns a reference to the managed instance. | |
| counted_type const & | operator* () const | 
| Returns a reference to the managed instance. | |
| typedef I interface_type | 
The interface type: the type of the RCI (Reference-Counted Interface).
| typedef T counted_type | 
The counted type: the concrete type of the objects whose instances will be managed.
| typedef U upcast_type | 
The up-cast type: the type used to disambiguate upcasts between T and I.
| typedef ref_ptr<T, I, U> class_type | 
| typedef I element_type | 
This to be member-type-compatible with std::auto_ptr.
| typedef counted_type* resource_type | 
This is to be compatible with the get_invoker component.
| ref_ptr | ( | ) |  [inline] | 
Default constructor.
Constructs and empty instance
| ref_ptr | ( | counted_type * | c, | |
| bool_type | bAddRef | |||
| ) |  [inline] | 
Construct from a raw pointer to the counted type, and a boolean that indicates whether a reference should be taken on the instance.
| c | Pointer to a counted_type. May be NULL | |
| bAddRef | parameter that determines whether reference will be consumed ( false) or borrowed (true). | 
false should be specified as the second parameter. If, however, a reference is being "borrowed", then true should be specified. | ref_ptr | ( | class_type const & | rhs | ) |  [inline] | 
Creates a copy of the given ref_ptr instance, and increments the reference count on its referent object, if any.
| rhs | The instance to copy | 
Copy constructs from an instance with different interface and/or counted type.
| ~ref_ptr | ( | ) | throw ()  [inline] | 
Destructor.
If the ref_ptr instance is still holding a pointer to a managed instance, it will be released.
| class_type& operator= | ( | class_type const & | rhs | ) |  [inline] | 
Copy assignment from a ref_ptr instance of the same type.
add_reference() and release_reference() control shims - do not throw (which they must not). | class_type& operator= | ( | ref_ptr< T2, I, U2 > & | rhs | ) |  [inline] | 
Copy assignment from an instance of ref_ptr with a different counted_type (but the same interface type).
It is strongly exception-safe, as long as the implementations of the add-ref and release functions - as utilised in the add_reference() and release_reference() control shims - do not throw (which they must not). 
| void swap | ( | class_type & | rhs | ) |  [inline] | 
Swaps the managed instance of this with rhs. 
Referenced by ref_ptr< T >::operator=(), and ref_ptr< T >::set().
| void set | ( | counted_type * | c, | |
| bool_type | bAddRef | |||
| ) |  [inline] | 
Assigns a reference-counted type to the smart pointer.
| c | Pointer to a counted_type. May be NULL | |
| bAddRef | parameter that determines whether reference will be consumed ( false) or borrowed (true). | 
| void close | ( | ) |  [inline] | 
Closes the instance, releasing the managed pointer.
| counted_type* detach | ( | ) |  [inline] | 
Detaches the managed instance, and returns it to the caller, which takes responsibility for ensuring that the resource is not leaked.
Reimplemented in interface_ptr.
| bool_type equal | ( | class_type const & | rhs | ) | const  [inline] | 
Evaluates whether two instances are equal.
| bool_type empty | ( | ) | const  [inline] | 
| bool_type operator! | ( | ) | const  [inline] | 
Determines whether the instance is empty.
| counted_type* get | ( | ) | const  [inline] | 
Provides raw-pointer access to the instance.
Referenced by stlsoft::get_ptr(), and stlsoft::is_empty().
| counted_type* operator-> | ( | ) |  [inline] | 
Returns the interface pointer.
| counted_type const* operator-> | ( | ) | const  [inline] | 
Returns the interface pointer.
| counted_type& operator* | ( | ) |  [inline] | 
Returns a reference to the managed instance.
| counted_type const& operator* | ( | ) | const  [inline] | 
Returns a reference to the managed instance.
 1.5.6
 1.5.6