Heidelberg Educational Numerics Library Version 0.24 (from 9 September 2011)
Public Member Functions

hdnum::CP< T, P > Class Template Reference

Pointer with a reference count in the pointed-to object. More...

#include <countingptr.hh>

List of all members.

Public Member Functions

 CP ()
 Construct a CP object which points to 0.
 CP (T *p_)
 Construct a CP object which points to p_ (which may be 0)
 CP (const CP< T > &cp)
 Copy constructor.
 ~CP ()
 Destructor.
CP< T > & operator= (T *p_)
 assignment from a C pointer
CP< T > & operator= (const CP< T > &cp)
 copy operator
T * operator-> () const
 target element access
T & operator* () const
 dereference operator
bool operator== (const CP< T > &cp) const
 check whether both point to same target
bool operator!= (const CP< T > &cp) const
 check whether target have different adress

Detailed Description

template<typename T, typename P = DeletingMemoryManagementPolicy>
class hdnum::CP< T, P >

Pointer with a reference count in the pointed-to object.

Template Parameters:
TThe type of the pointed-to object. Must be derived from Countable.
PWhat to do when the reference count reaches 0. Two predefined policy classes are available: NondeletingMemoryManagementPolicy and DeletingMemoryManagementPolicy (the default).

An object cp of class CP points to another object of a class derived from Countable, or to 0. If it does not point to 0, it will keep track of how many CP objects point to the same object. If cp stops pointing to the target object, it will decrement its reference count, and if the reference count reaches zero may or may not delete the target object, depending on what the memory managment policy dictates.

cp may be set via assingment from an apropriate C pointer or another CP of the same type. To access the pointed to object, the expressions *cp and cp->member may be used, where member is a member of the pointed to object. Finally, CP objects may be compared using == and != to find out whether they point to the same object.


The documentation for this class was generated from the following file: