Library of Assembled Shared Sources
lass::util::IntrusiveCounter< T, CounterType, referenceCounter > Class Template Reference

implementation of CounterPolicy concept, using a counter in the managed object itself. More...

#include <smart_ptr_policies.h>

Inheritance diagram for lass::util::IntrusiveCounter< T, CounterType, referenceCounter >:

Detailed Description

template<typename T, typename CounterType, CounterType T::* referenceCounter>
class lass::util::IntrusiveCounter< T, CounterType, referenceCounter >

implementation of CounterPolicy concept, using a counter in the managed object itself.

Author
Bram de Greve [Bramz]

This comes from "C++ Templates, The Complete Guide" by David Vandevoorde and Nicolai M. Josuttis. See their MemberReferenceCount policy.

The DefaultCounter policy puts the reference counter outside the managed object. That's great in most cases, because that way, the managed type doesn't have to be designed to be used with our SharedPtr. However, in some cases it is more interesting to put the reference counter inside the managed object. You can use the IntrusiveCounter policy to use such a reference counter with our SharedPtr.

struct Foo
{
std::string blablabla;
int referenceCount;
};
typedef lass::util::SharedPtr
<
Foo,
<
Foo, // the managed type (containing the counter)
int, // type of the counter
&Foo::referenceCount // pointer to the counter
>
>
TFooPtr;
TFooPtr foo(new Foo);
implementation of CounterPolicy concept, using a counter in the managed object itself.
Default storage policy for single objects, implementation of StoragePolicy concept.

Definition at line 456 of file smart_ptr_policies.h.


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