FastJet 3.0.2
|
an implementation of C++0x shared pointers (or boost's) More...
#include <fastjet/SharedPtr.hh>
Public Member Functions | |
SharedPtr () | |
default ctor | |
template<class Y > | |
SharedPtr (Y *ptr) | |
initialise with the main data | |
SharedPtr (SharedPtr const &share) | |
overload the copy ctor so that it updates count | |
~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 | |
SharedPtr & | operator= (SharedPtr const &share) |
overload the = operator so that it updates count | |
template<class Y > | |
SharedPtr & | operator= (SharedPtr< Y > const &share) |
overload the = operator so that it updates count | |
T * | operator() () const |
return the pointer we're pointing to | |
T & | operator* () const |
indirection, get a reference to the stored pointer | |
T * | operator-> () const |
indirection, get the stored pointer | |
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 |
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 114 of file SharedPtr.hh.
fastjet::SharedPtr< T >::SharedPtr | ( | Y * | ptr | ) | [inline, explicit] |
initialise with the main data
t | : the object we want a smart pointer to |
Definition at line 124 of file SharedPtr.hh.
fastjet::SharedPtr< T >::SharedPtr | ( | SharedPtr< T > const & | share | ) | [inline] |
overload the copy ctor so that it updates count
share | : the object we want to copy |
Definition at line 130 of file SharedPtr.hh.
void fastjet::SharedPtr< T >::reset | ( | SharedPtr< Y > const & | share | ) | [inline] |
do a smart copy
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 175 of file SharedPtr.hh.
SharedPtr& fastjet::SharedPtr< T >::operator= | ( | SharedPtr< T > const & | share | ) | [inline] |
overload the = operator so that it updates count
share | : the object we want to copy |
Definition at line 199 of file SharedPtr.hh.
SharedPtr& fastjet::SharedPtr< T >::operator= | ( | SharedPtr< Y > const & | share | ) | [inline] |
overload the = operator so that it updates count
share | : the object we want to copy |
Definition at line 206 of file SharedPtr.hh.
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 223 of file SharedPtr.hh.
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 233 of file SharedPtr.hh.
void fastjet::SharedPtr< T >::set_count | ( | const long & | count | ) | [inline] |
force the count to be set to a specified value
count | the value that we need to reset to |
Definition at line 270 of file SharedPtr.hh.