Smart Pointers

ref_count_policy Struct Reference

#include <smart_ptr.hpp>

List of all members.


Detailed Description

Use this policy to create a reference counting smart pointer. This policy is similar to reference counting logic used by boost::shared_ptr. In general, it is slower than the other two reference policies (ref_link_policy and ref_intrusive_policy). It is more generic than ref_intrusive_policy, since it does not require that the target type have intrusive functions. It takes less space than ref_link_policy, and it's easier to implement in synchronized code, than ref_link_policy. Use this policy when space is the primary factor, or when referencing the same object in multiple threads and you don't wish to use an intrusive_lock_policy.
Example Usage.

#include "../shape_test.h"

void example_ref_count_policy_usage()
{
        smart_ptr<Shape, copy_on_write_policy<ref_count_policy> >       pShape1 = new Square("Blue");

        smart_ptr<Shape, shared_ptr_policy<ref_count_policy> >          pShape2 = new Circle("Red");

        smart_ptr<Shape, copy_on_write_policy<ref_count_policy> >       pShape3 = pShape2; //exchangeable policies

        smart_ptr<Shape, shared_ptr_policy<ref_count_policy> >          pShape4 = pShape1; //exchangeable policies
}

See also:
smart_ptr, ref_link_policy, ref_intrusive_policy

Definition at line 523 of file smart_ptr.hpp.

Public Member Functions

 ref_count_policy ()
template<class T1>
 ref_count_policy (ref_count_policy &src, T1 &)
template<class T, class F, class LCK>
void release (T &type, F clone_fct, LCK &lck_policy)
template<class T1, class F1, class T2, class F2, class LCK>
void assign (T1 &type1, F1 &clone_fct1, T2 type2, const F2 clone_fct2, ref_count_policy &src_policy, LCK &lck_policy)

Protected Member Functions

template<class T>
bool is_referenced (T &) const


Member Function Documentation

void release T &  type,
clone_fct,
LCK &  lck_policy
[inline]
 

Todo:
Add assertion argument so function can call assertion policy

Definition at line 549 of file smart_ptr.hpp.


The documentation for this struct was generated from the following file:
Generated on Wed Mar 29 21:58:59 2006 for Smart Pointers by  doxygen 1.4.6.Axter [Axter-Extended-Version]