FEI
Version of the Day
|
#include <fei_SharedPtr.hpp>
Public Types | |
typedef T | element_type |
Public Member Functions | |
SharedPtr (T *p) | |
~SharedPtr () | |
template<typename Y > | |
SharedPtr (const SharedPtr< Y > &x) | |
template<typename Y > | |
SharedPtr & | operator= (const SharedPtr< Y > &x) |
SharedPtr (const SharedPtr &x) | |
SharedPtr & | operator= (const SharedPtr &x) |
void | reset (T *p=0) |
T & | operator* () const |
T * | operator-> () const |
T * | get () const |
long | use_count () const |
bool | unique () const |
void | share (T *xpointer, long *xcount) |
void | dispose () |
A smart pointer with reference counted copy semantics. This class is a close copy of boost::shared_ptr. See www.boost.org, and www.boost.org/libs/smart_ptr/smart_ptr.htm. For logistical reasons it was deemed easier to make a copy of the boost::shared_ptr rather than having FEI be dependent on boost. According to TR1 (C++ Technical Report 1), referenced on the boost web site, shared_ptr will be migrating into the C++ standard.
fei::SharedPtr usage notes:
Construction:
Assignment:
Comparison:
The object pointed to is deleted when the last SharedPtr pointing to it is destroyed or reset.
Definition at line 65 of file fei_SharedPtr.hpp.
typedef T fei::SharedPtr< T >::element_type |
The type of the stored pointer.
Definition at line 72 of file fei_SharedPtr.hpp.
|
inlineexplicit |
Constructs a SharedPtr, storing a copy of p, which must have been allocated via a C++ new expression or be 0. On exit, use_count() is 1 (even if p==0; see the destructor).
The only exception which may be thrown by this constructor is std::bad_alloc. If an exception is thrown, delete p is called.
p | the pointer value recently allocated |
Definition at line 84 of file fei_SharedPtr.hpp.
|
inline |
Destructor. If use_count() == 1, deletes the object pointed to by the stored pointer. Otherwise, use_count() for any remaining copies is decremented by 1. Note that in C++ delete on a pointer with a value of 0 is harmless.
Never throws an exception.
Definition at line 109 of file fei_SharedPtr.hpp.
|
inline |
Constructs a SharedPtr, as if by storing a copy of the pointer stored in x. Afterwards, use_count() for all copies is 1 more than the initial x.use_count().
Never throws an exception.
x | a shared pointer to another type |
Definition at line 122 of file fei_SharedPtr.hpp.
|
inline |
Constructs a SharedPtr, as if by storing a copy of the pointer stored in x. Afterwards, use_count() for all copies is 1 more than the initial x.use_count().
Never throws an exception.
x | the shared pointer to copy |
Definition at line 160 of file fei_SharedPtr.hpp.
|
inline |
Assignment to a shared pointer of another type.
First, if use_count() == 1, deletes the object pointed to by the stored pointer. Otherwise, use_count() for any remaining copies is decremented by 1. Note that in C++ delete on a pointer with a value of 0 is harmless.
Then replaces the contents of this, as if by storing a copy of the pointer stored in x. Afterwards, use_count() for all copies is 1 more than the initial x.use_count().
Never throws an exception.
x | a shared pointer to another type |
Definition at line 145 of file fei_SharedPtr.hpp.
|
inline |
Assignment to another shared pointer. First, if use_count() == 1, deletes the object pointed to by the stored pointer. Otherwise, use_count() for any remaining copies is decremented by 1. Note that in C++ delete on a pointer with a value of 0 is harmless.
Then replaces the contents of this, as if by storing a copy of the pointer stored in x. Afterwards, use_count() for all copies is 1 more than the initial x.use_count().
Does not throw any exception.
x | the shared pointer to copy |
Definition at line 181 of file fei_SharedPtr.hpp.
|
inline |
Reset the pointer value of this shared pointer. First, if use_count() == 1, deletes the object pointed to by the stored pointer. Otherwise, use_count() for any remaining copies is decremented by 1. Then replaces the contents of this, as if by storing a copy of p, which must have been allocated via a C++ new expression or be 0. Afterwards, use_count() is 1 (even if p==0; see ~SharedPtr).
Note that in C++ delete on a pointer with a value of 0 is harmless.
The only exception which may be thrown is std::bad_alloc. If an exception is thrown, delete p is called.
p | a pointer value, or 0 if not present |
Definition at line 203 of file fei_SharedPtr.hpp.
|
inline |
Returns a reference to the object pointed to by the stored pointer.
Never throws an exception.
Definition at line 228 of file fei_SharedPtr.hpp.
|
inline |
Return the stored pointer.
Never throws an exception.
Definition at line 235 of file fei_SharedPtr.hpp.
|
inline |
Return the stored pointer. T is not required to be a complete type.
Never throws an exception.
Definition at line 242 of file fei_SharedPtr.hpp.
|
inline |
Returns the number of SharedPtr's sharing ownership of the stored pointer. T is not required to be a complete type.
Never throws an exception.
Definition at line 250 of file fei_SharedPtr.hpp.
|
inline |
Returns use_count() == 1. T is not required to be a complete type.
Never throws an exception.
Definition at line 258 of file fei_SharedPtr.hpp.
|
inline |
power users only
Definition at line 261 of file fei_SharedPtr.hpp.
|
inline |
power users only
Definition at line 271 of file fei_SharedPtr.hpp.