|
libyuni
|
Smart Pointer. More...
#include <smartptr.h>


Classes | |
| struct | AutomaticConversion |
Empty class to allow if (mySmartPtr) ... More... | |
| struct | DynamicCastArg |
| class | Promote |
| Class Helper to determine the most suitable smart pointer for a class according the current threading policy. More... | |
Public Types | |
| typedef Static::If< ConversionPolicy::allow, const StoredType &, NeverMatched >::ResultType | ImplicitStoredType |
| Implicit - Conversions are allowed. | |
| typedef Static::If<!ConversionPolicy::allow, const StoredType &, NeverMatched >::ResultType | ExplicitStoredType |
| Explicit - Conversions are not allowed. | |
Type alias | |
| typedef T | Type |
| Original type. | |
| typedef StorP< T > | StoragePolicy |
| The Storage policy. | |
| typedef OwspP< typename StorP< T >::PointerType > | OwnershipPolicy |
| The Ownership policy. | |
| typedef ConvP | ConversionPolicy |
| The conversion policy. | |
| typedef ChckP< typename StorP< T >::StoredType > | CheckingPolicy |
| The checking policy. | |
| typedef ConsP< T > | ConstnessPolicy |
| The Constness policy. | |
| typedef StoragePolicy::PointerType | PointerType |
| the Pointer type | |
| typedef StoragePolicy::StoredType | StoredType |
| The Stored type. | |
| typedef StoragePolicy::ReferenceType | ReferenceType |
| The Reference type. | |
| typedef ConstnessPolicy::Type * | ConstPointerType |
| The Pointer type (const) | |
| typedef ConstnessPolicy::Type & | ConstReferenceType |
| The Reference type (const) | |
| typedef SmartPtr< T, OwspP, ChckP, ConvP, StorP, ConsP > | SmartPtrType |
| Alias to itself. | |
| typedef SmartPtr< T, OwspP, ChckP, ConvP, StorP, Policy::Constness::PropagateConst > | ConstSmartPtrType |
| A smart pointer with a const pointer. | |
| typedef SmartPtr< T, OwspP, ChckP, ConvP, StorP, Policy::Constness::DontPropagateConst > | NonConstSmartPtrType |
| A smart pointer with a non-const pointer. | |
| typedef Static::If< OwnershipPolicy::destructiveCopy, SmartPtrType, const SmartPtrType >::ResultType | CopyType |
| The Type to use for the copy constructor. | |
| typedef std::vector< SmartPtrType > | Vector |
| Vector. | |
| typedef std::list< SmartPtrType > | List |
| List. | |
Public Member Functions | |
| template<typename T1 , template< class > class OwspP1, template< class > class ChckP1, class ConvP1 , template< class > class StorP1, template< class > class ConsP1> | |
| SmartPtr (const SmartPtr< T1, OwspP1, ChckP1, ConvP1, StorP1, ConsP1 > &rhs, const DynamicCastArg &) | |
| Copy constructor with Dynamic casting. | |
| template<typename T1 , template< class > class OwspP1, template< class > class ChckP1, class ConvP1 , template< class > class StorP1, template< class > class ConsP1> | |
| SmartPtr (SmartPtr< T1, OwspP1, ChckP1, ConvP1, StorP1, ConsP1 > &rhs, const DynamicCastArg &) | |
| Copy constructor with Dynamic casting. | |
| template<typename T , template< class > class OwspP, template< class > class ChckP, class ConvP , template< class > class StorP, template< class > class ConsP> | |
| SmartPtr (typename SmartPtr< T, OwspP, ChckP, ConvP, StorP, ConsP >::ExplicitStoredType ptr) | |
| template<typename T , template< class > class OwspP, template< class > class ChckP, class ConvP , template< class > class StorP, template< class > class ConsP> | |
| SmartPtr (typename SmartPtr< T, OwspP, ChckP, ConvP, StorP, ConsP >::CopyType &rhs) | |
| template<typename T1 , template< class > class OwspP1, template< class > class ChckP1, class ConvP1 , template< class > class StorP1, template< class > class ConsP1> | |
| SmartPtr (SmartPtr< T1, OwspP1, ChckP1, ConvP1, StorP1, ConsP1 > &rhs, const typename SmartPtr< T, OwspP, ChckP, ConvP, StorP, ConsP >::DynamicCastArg &) | |
| template<typename T , template< class > class OwspP, template< class > class ChckP, class ConvP , template< class > class StorP, template< class > class ConsP> | |
| SmartPtr< T, OwspP, ChckP, ConvP, StorP, ConsP > & | operator= (typename SmartPtr< T, OwspP, ChckP, ConvP, StorP, ConsP >::CopyType &rhs) |
| template<typename T1 , template< class > class OwspP1, template< class > class ChckP1, class ConvP1 , template< class > class StorP1, template< class > class ConsP1> | |
| SmartPtr< T, OwspP, ChckP, ConvP, StorP, ConsP > & | operator= (const SmartPtr< T1, OwspP1, ChckP1, ConvP1, StorP1, ConsP1 > &rhs) |
| template<typename T1 , template< class > class OwspP1, template< class > class ChckP1, class ConvP1 , template< class > class StorP1, template< class > class ConsP1> | |
| SmartPtr< T, OwspP, ChckP, ConvP, StorP, ConsP > & | operator= (SmartPtr< T1, OwspP1, ChckP1, ConvP1, StorP1, ConsP1 > &rhs) |
Constructors & Destructor | |
| SmartPtr () | |
| Default constructor. | |
| SmartPtr (ExplicitStoredType ptr) | |
| Constructor with a given pointer, when implicit types are not allowed. | |
| SmartPtr (ImplicitStoredType ptr) | |
| Constructor with a given pointer, when implicit types are allowed. | |
| SmartPtr (const NullPtr &) | |
| Constructor with a null pointer. | |
| SmartPtr (CopyType &rhs) | |
| Copy constructor. | |
| template<typename T1 , template< class > class OwspP1, template< class > class ChckP1, class ConvP1 , template< class > class StorP1, template< class > class ConsP1> | |
| SmartPtr (const SmartPtr< T1, OwspP1, ChckP1, ConvP1, StorP1, ConsP1 > &rhs) | |
| Copy constructor. | |
| template<typename T1 , template< class > class OwspP1, template< class > class ChckP1, class ConvP1 , template< class > class StorP1, template< class > class ConsP1> | |
| SmartPtr (SmartPtr< T1, OwspP1, ChckP1, ConvP1, StorP1, ConsP1 > &rhs) | |
| Copy constructor. | |
| SmartPtr (Static::MoveConstructor< SmartPtrType > rhs) | |
| Move Constructor. | |
| ~SmartPtr () | |
| Destructor. | |
Swap | |
| void | swap (SmartPtr &rhs) |
| Swap from another smartptr. | |
Pointer | |
| PointerType | pointer () |
| Get a pointer to the object, like operator -> would do. | |
| ConstPointerType | pointer () const |
| Get a pointer to the object, like operator -> would do. | |
Operator * / -> | |
| PointerType | operator-> () |
| ConstPointerType | operator-> () const |
| ReferenceType | operator* () |
| ConstReferenceType | operator* () const |
Operator = | |
| SmartPtr & | operator= (CopyType &rhs) |
| Copy. | |
| SmartPtr & | operator= (const NullPtr &) |
| Reset. | |
| template<typename T1 , template< class > class OwspP1, template< class > class ChckP1, class ConvP1 , template< class > class StorP1, template< class > class ConsP1> | |
| SmartPtr & | operator= (const SmartPtr< T1, OwspP1, ChckP1, ConvP1, StorP1, ConsP1 > &rhs) |
| Copy from another smartptr. | |
| template<typename T1 , template< class > class OwspP1, template< class > class ChckP1, class ConvP1 , template< class > class StorP1, template< class > class ConsP1> | |
| SmartPtr & | operator= (SmartPtr< T1, OwspP1, ChckP1, ConvP1, StorP1, ConsP1 > &rhs) |
| Copy from another smartptr. | |
Comparisons | |
| bool | operator! () const |
Operator ! (to enable if (!mysmartptr) ...) | |
| bool | operator== (const NullPtr &) const |
operator == | |
| bool | operator!= (const NullPtr &) const |
operator != | |
| template<typename T1 , template< class > class OwspP1, template< class > class ChckP1, class ConvP1 , template< class > class StorP1, template< class > class ConsP1> | |
| bool | operator== (const SmartPtr< T1, OwspP1, ChckP1, ConvP1, StorP1, ConsP1 > &rhs) const |
operator == | |
| bool | operator== (const T *rhs) const |
operator == | |
| template<typename T1 , template< class > class OwspP1, template< class > class ChckP1, class ConvP1 , template< class > class StorP1, template< class > class ConsP1> | |
| bool | operator!= (const SmartPtr< T1, OwspP1, ChckP1, ConvP1, StorP1, ConsP1 > &rhs) const |
Operator != | |
| bool | operator!= (const T *rhs) const |
Operator != | |
| template<typename T1 , template< class > class OwspP1, template< class > class ChckP1, class ConvP1 , template< class > class StorP1, template< class > class ConsP1> | |
| bool | operator< (const SmartPtr< T1, OwspP1, ChckP1, ConvP1, StorP1, ConsP1 > &rhs) const |
Operator < | |
| template<typename T1 , template< class > class OwspP1, template< class > class ChckP1, class ConvP1 , template< class > class StorP1, template< class > class ConsP1> | |
| bool | operator> (const SmartPtr< T1, OwspP1, ChckP1, ConvP1, StorP1, ConsP1 > &rhs) const |
Operator > | |
| template<typename T1 , template< class > class OwspP1, template< class > class ChckP1, class ConvP1 , template< class > class StorP1, template< class > class ConsP1> | |
| bool | operator<= (const SmartPtr< T1, OwspP1, ChckP1, ConvP1, StorP1, ConsP1 > &rhs) const |
Operator <= | |
| template<typename T1 , template< class > class OwspP1, template< class > class ChckP1, class ConvP1 , template< class > class StorP1, template< class > class ConsP1> | |
| bool | operator>= (const SmartPtr< T1, OwspP1, ChckP1, ConvP1, StorP1, ConsP1 > &rhs) const |
Operator >= | |
Cast-Operator | |
| operator Static::MoveConstructor< SmartPtr > () | |
| Cast-Operator. | |
| operator AutomaticConversion * () const | |
Cast-Operator for if (mySmartPtr) ... | |
Static Public Member Functions | |
| static const T * | WeakPointer (const SmartPtr &ptr) |
| Get the internal stored pointer (weak pointer) by the smart pointer (const) More... | |
| static T * | WeakPointer (SmartPtr &ptr) |
| Get the internal stored pointer (weak pointer) by the smart pointer. More... | |
| static const T * | WeakPointer (const T *wptr) |
| Get the internal stored pointer (weak pointer) by the smart pointer (identity) (const) More... | |
| static T * | WeakPointer (T *wptr) |
| Get the internal stored pointer (weak pointer) by the smart pointer (identity) More... | |
| template<class S1 > | |
| static S1 | DynamicCast (SmartPtr p) |
| Perform a dynamic_cast on a smartptr. More... | |
Smart Pointer.
Smart pointers are abstract data type classes to simplify the memory management, especially in a multithreaded context. They simulate a pointer. They behave much like built-in C++ pointers except that they automatically delete the object pointed to at the appropriate time (automatic garbage collection), and can provide additional bounds checking.
here is a simple example :
Here is a more complex example, dealing with inheritance :
| T | The type |
| OwspP | The ownership policy |
| ChckP | The Checking policy |
| ConvP | The Conversion policy |
| StorP | The Storage policy |
| ConsP | The Constness policy |
|
inlinestatic |
Perform a dynamic_cast on a smartptr.
Assuming the class B is a descendant of the class A
|
inlinestatic |
Get the internal stored pointer (weak pointer) by the smart pointer (const)
| ptr | The smart pointer |
|
inlinestatic |
Get the internal stored pointer (weak pointer) by the smart pointer.
| ptr | The smart pointer |
|
inlinestatic |
Get the internal stored pointer (weak pointer) by the smart pointer (identity) (const)
| wptr | The pointer |
|
inlinestatic |
Get the internal stored pointer (weak pointer) by the smart pointer (identity)
| wptr | The pointer |
1.8.13