FastJet  3.3.0
Public Member Functions | List of all members
fastjet::SharedPtr< T > Class Template Reference

an implementation of C++0x shared pointers (or boost's) More...

#include <fastjet/SharedPtr.hh>

Inheritance diagram for fastjet::SharedPtr< T >:
Inheritance graph
[legend]

Public Member Functions

 SharedPtr ()
 default ctor
 
template<class Y >
 SharedPtr (Y *ptr)
 initialise with the main data More...
 
 SharedPtr (SharedPtr const &share)
 overload the copy ctor so that it updates count More...
 
 ~SharedPtr ()
 default dtor
 
void reset ()
 reset the pointer to default value (NULL)
 
template<class Y >
void reset (Y *ptr)
 reset from a pointer
 
template<class Y >
void reset (SharedPtr< Y > const &share)
 do a smart copy More...
 
SharedPtroperator= (SharedPtr const &share)
 overload the = operator so that it updates count More...
 
template<class Y >
SharedPtroperator= (SharedPtr< Y > const &share)
 overload the = operator so that it updates count More...
 
T * operator() () const
 return the pointer we're pointing to More...
 
T & operator* () const
 indirection, get a reference to the stored pointer More...
 
T * operator-> () const
 indirection, get the stored pointer More...
 
T * get () const
 get the stored pointer
 
bool unique () const
 check if the instance is unique
 
long use_count () const
 return the number of counts
 
 operator bool () const
 conversion to bool This will allow you to use the indirection nicely
 
void swap (SharedPtr &share)
 exchange the content of the two pointers
 
void set_count (const long &count)
 force the count to be set to a specified value More...
 

Detailed Description

template<class T>
class fastjet::SharedPtr< T >

an implementation of C++0x shared pointers (or boost's)

this class implements a smart pointer, based on the shared+ptr proposal. A description of shared_ptr can be found in Section 2.2.3 of the first C++ Technical Report (TR1) http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1745.pdf or, alternatively, on the Boost C++ library website at http://www.boost.org/doc/libs/1_42_0/libs/smart_ptr/shared_ptr.htm

Our implementation is compatible with both of these apart from a series of members and functions that have not been implemented:

We also add the possibility to force an update of the count.

The class has been tested against the existing boost (v1.42) implementation (for the parts that we have implemented).

Definition at line 121 of file SharedPtr.hh.

Constructor & Destructor Documentation

◆ SharedPtr() [1/2]

template<class T>
template<class Y >
fastjet::SharedPtr< T >::SharedPtr ( Y *  ptr)
inlineexplicit

initialise with the main data

Parameters
t: the object we want a smart pointer to

Definition at line 131 of file SharedPtr.hh.

◆ SharedPtr() [2/2]

template<class T>
fastjet::SharedPtr< T >::SharedPtr ( SharedPtr< T > const &  share)
inline

overload the copy ctor so that it updates count

Parameters
share: the object we want to copy

Definition at line 137 of file SharedPtr.hh.

Member Function Documentation

◆ reset()

template<class T>
template<class Y >
void fastjet::SharedPtr< T >::reset ( SharedPtr< Y > const &  share)
inline

do a smart copy

Parameters
share: the object we want to copy Q? Do we need a non-template<Y> version as for the ctor and the assignment?

Definition at line 182 of file SharedPtr.hh.

◆ operator=() [1/2]

template<class T>
SharedPtr& fastjet::SharedPtr< T >::operator= ( SharedPtr< T > const &  share)
inline

overload the = operator so that it updates count

Parameters
share: the object we want to copy

Definition at line 206 of file SharedPtr.hh.

◆ operator=() [2/2]

template<class T>
template<class Y >
SharedPtr& fastjet::SharedPtr< T >::operator= ( SharedPtr< Y > const &  share)
inline

overload the = operator so that it updates count

Parameters
share: the object we want to copy

Definition at line 213 of file SharedPtr.hh.

◆ operator()()

template<class T>
T* fastjet::SharedPtr< T >::operator() ( ) const
inline

return the pointer we're pointing to

Since FastJet 3.2.0, this is depracated since it is no longer part of std::shared_ptr<T>. Use SharedPtr<T>::get() instead

Definition at line 223 of file SharedPtr.hh.

◆ operator*()

template<class T>
T& fastjet::SharedPtr< T >::operator* ( ) const
inline

indirection, get a reference to the stored pointer

!!! WATCH OUT It fails to check the requirement that the stored pointer must not be NULL!! So you need explicitly to check the validity in your code

Definition at line 234 of file SharedPtr.hh.

◆ operator->()

template<class T>
T* fastjet::SharedPtr< T >::operator-> ( ) const
inline

indirection, get the stored pointer

!!! WATCH OUT It fails to check the requirement that the stored pointer must not be NULL!! So you need explicitly to check the validity in your code

Definition at line 244 of file SharedPtr.hh.

◆ set_count()

template<class T>
void fastjet::SharedPtr< T >::set_count ( const long &  count)
inline

force the count to be set to a specified value

Parameters
countthe value that we need to reset to

Definition at line 284 of file SharedPtr.hh.


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