Dune::shared_ptr< T > Class Template Reference
[Common (foundation classes)]

A reference counting smart pointer. More...

#include <dune/common/shared_ptr.hh>

Inheritance diagram for Dune::shared_ptr< T >:
Inheritance graph

List of all members.

Classes

struct  DefaultDeleter
 A default deleter that just calls delete.
class  PointerRep
 The object we reference.
class  PointerRepImpl
 Adds call to deleter to PointerRep.

Public Types

typedef T element_type
 The data type we are a pointer for.

Public Member Functions

 shared_ptr ()
 Constructs a new smart pointer and allocates the referenced Object.
 shared_ptr (T *pointer)
 Constructs a new smart pointer from a preallocated Object.
template<class Deleter >
 shared_ptr (T *pointer, Deleter deleter)
 Constructs a new smart pointer from a preallocated Object.
 shared_ptr (const shared_ptr< T > &pointer)
 Copy constructor.
 ~shared_ptr ()
 Destructor.
shared_ptroperator= (const shared_ptr< T > &pointer)
 Assignment operator.
element_typeoperator* ()
 Dereference as object.
element_typeoperator-> ()
 Dereference as pointer.
const element_typeoperator* () const
 Dereference as const object.
const element_typeoperator-> () const
 Dereference as const pointer.
element_typeget () const
 Access to the raw pointer, if you really want it.
void swap (shared_ptr &other)
 Swap content of this shared_ptr and another.
void reset ()
 Decrease the reference count by one and free the memory if the reference count has reached 0.
void reset (T *pointer)
 Detach shared pointer and set it anew for the given pointer.
template<class Deleter >
void reset (T *pointer, Deleter deleter)
int use_count () const
 The number of shared_ptrs pointing to the object we point to.
 operator __unspecified_bool_type () const
 Implicit conversion to "bool".

Related Functions

(Note that these are not member functions.)



template<typename T >
shared_ptr< T > stackobject_to_shared_ptr (T &t)
 Convert a stack-allocated object to a shared_ptr:

Detailed Description

template<class T>
class Dune::shared_ptr< T >

A reference counting smart pointer.

It is designed such that it is usable within a std::vector. The contained object is destroyed only if there are no more references to it.


Member Typedef Documentation

template<class T>
typedef T Dune::shared_ptr< T >::element_type

The data type we are a pointer for.

This has to have a parameterless constructor.


Member Function Documentation

template<class T>
element_type* Dune::shared_ptr< T >::get (  )  const [inline]

Access to the raw pointer, if you really want it.

Referenced by Dune::Generic_MPI_Op< Type, BinaryFunction >::get(), and Dune::Generic_MPI_Datatype< T >::get().

template<class T>
Dune::shared_ptr< T >::operator __unspecified_bool_type (  )  const [inline]

Implicit conversion to "bool".


Friends And Related Function Documentation

template<typename T >
shared_ptr< T2 > stackobject_to_shared_ptr ( T &  t  )  [related]

Convert a stack-allocated object to a shared_ptr:

Convert a stack object to a shared_ptr of a base class.

            int i = 10;
            shared_ptr<int> pi = stackobject_to_shared_ptr(i);
            class A {};
            class B : public A {};

            ...
            
            B b;
            shared_ptr<A> pa = stackobject_to_shared_ptr<A>(b);

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

Generated on Fri Apr 29 2011 with Doxygen (ver 1.7.1) [doxygen-log,error-log].