Class xlifepp::SmartPtr#

template<typename T, template<class> class OwnershipPolicy, class ConversionPolicy, template<class> class CheckingPolicy, template<class> class StoragePolicy, template<class> class ConstnessPolicy>
class SmartPtr : public StoragePolicy<T>, public OwnershipPolicy<StoragePolicy<T>::InitPointerType>, public CheckingPolicy<StoragePolicy<T>::StoredType>, public ConversionPolicy#

Inheritence diagram for xlifepp::SmartPtr:

digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "4" [label="CheckingPolicy< StoragePolicy< T >::StoredType >" tooltip="CheckingPolicy< StoragePolicy< T >::StoredType >"] "5" [label="ConversionPolicy" tooltip="ConversionPolicy"] "3" [label="OwnershipPolicy< StoragePolicy< T >::InitPointerType >" tooltip="OwnershipPolicy< StoragePolicy< T >::InitPointerType >"] "13" [label="xlifepp::SmartPtr< MV >" tooltip="xlifepp::SmartPtr< MV >"] "16" [label="xlifepp::SmartPtr< const MV >" tooltip="xlifepp::SmartPtr< const MV >"] "22" [label="xlifepp::SmartPtr< const MulVec >" tooltip="xlifepp::SmartPtr< const MulVec >"] "12" [label="xlifepp::SmartPtr< const OP >" tooltip="xlifepp::SmartPtr< const OP >"] "17" [label="xlifepp::SmartPtr< const std::vector< typename xlifepp::NumTraits< ScalarType >::RealScalar > >" tooltip="xlifepp::SmartPtr< const std::vector< typename xlifepp::NumTraits< ScalarType >::RealScalar > >"] "18" [label="xlifepp::SmartPtr< const xlifepp::MatrixEigenDense< ScalarType > >" tooltip="xlifepp::SmartPtr< const xlifepp::MatrixEigenDense< ScalarType > >"] "6" [label="xlifepp::SmartPtr< std::ostream >" tooltip="xlifepp::SmartPtr< std::ostream >"] "15" [label="xlifepp::SmartPtr< xlifepp::BasicOutputManager< ScalarType > >" tooltip="xlifepp::SmartPtr< xlifepp::BasicOutputManager< ScalarType > >"] "7" [label="xlifepp::SmartPtr< xlifepp::EigenProblem< ScalarType, MV, OP > >" tooltip="xlifepp::SmartPtr< xlifepp::EigenProblem< ScalarType, MV, OP > >"] "11" [label="xlifepp::SmartPtr< xlifepp::MatOrthoManager< ScalarType, MV, OP > >" tooltip="xlifepp::SmartPtr< xlifepp::MatOrthoManager< ScalarType, MV, OP > >"] "14" [label="xlifepp::SmartPtr< xlifepp::MatrixEigenDense< ScalarType > >" tooltip="xlifepp::SmartPtr< xlifepp::MatrixEigenDense< ScalarType > >"] "20" [label="xlifepp::SmartPtr< xlifepp::OrthoManager< ScalarType, MV > >" tooltip="xlifepp::SmartPtr< xlifepp::OrthoManager< ScalarType, MV > >"] "9" [label="xlifepp::SmartPtr< xlifepp::OutputManager< ScalarType > >" tooltip="xlifepp::SmartPtr< xlifepp::OutputManager< ScalarType > >"] "21" [label="xlifepp::SmartPtr< xlifepp::SortManager< MagnitudeType > >" tooltip="xlifepp::SmartPtr< xlifepp::SortManager< MagnitudeType > >"] "8" [label="xlifepp::SmartPtr< xlifepp::SortManager< typename xlifepp::NumTraits< ScalarType >::RealScalar > >" tooltip="xlifepp::SmartPtr< xlifepp::SortManager< typename xlifepp::NumTraits< ScalarType >::RealScalar > >"] "19" [label="xlifepp::SmartPtr< xlifepp::SortManager< typename xlifepp::NumTraits< ScalarType >::magnitudeType > >" tooltip="xlifepp::SmartPtr< xlifepp::SortManager< typename xlifepp::NumTraits< ScalarType >::magnitudeType > >"] "10" [label="xlifepp::SmartPtr< xlifepp::StatusTest< ScalarType, MV, OP > >" tooltip="xlifepp::SmartPtr< xlifepp::StatusTest< ScalarType, MV, OP > >"] "2" [label="StoragePolicy< T >" tooltip="StoragePolicy< T >"] "1" [label="xlifepp::SmartPtr< T, OwnershipPolicy, ConversionPolicy, CheckingPolicy, StoragePolicy, ConstnessPolicy >" tooltip="xlifepp::SmartPtr< T, OwnershipPolicy, ConversionPolicy, CheckingPolicy, StoragePolicy, ConstnessPolicy >" fillcolor="#BFBFBF"] "13" -> "1" [dir=forward tooltip="template-instance"] "16" -> "1" [dir=forward tooltip="template-instance"] "22" -> "1" [dir=forward tooltip="template-instance"] "12" -> "1" [dir=forward tooltip="template-instance"] "17" -> "1" [dir=forward tooltip="template-instance"] "18" -> "1" [dir=forward tooltip="template-instance"] "6" -> "1" [dir=forward tooltip="template-instance"] "15" -> "1" [dir=forward tooltip="template-instance"] "7" -> "1" [dir=forward tooltip="template-instance"] "11" -> "1" [dir=forward tooltip="template-instance"] "14" -> "1" [dir=forward tooltip="template-instance"] "20" -> "1" [dir=forward tooltip="template-instance"] "9" -> "1" [dir=forward tooltip="template-instance"] "21" -> "1" [dir=forward tooltip="template-instance"] "8" -> "1" [dir=forward tooltip="template-instance"] "19" -> "1" [dir=forward tooltip="template-instance"] "10" -> "1" [dir=forward tooltip="template-instance"] "1" -> "2" [dir=forward tooltip="public-inheritance"] "1" -> "3" [dir=forward tooltip="public-inheritance"] "1" -> "4" [dir=forward tooltip="public-inheritance"] "1" -> "5" [dir=forward tooltip="public-inheritance"] }

Collaboration diagram for xlifepp::SmartPtr:

digraph { graph [bgcolor="#00000000"] node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2] edge [color="#1414CE"] "4" [label="CheckingPolicy< StoragePolicy< T >::StoredType >" tooltip="CheckingPolicy< StoragePolicy< T >::StoredType >"] "5" [label="ConversionPolicy" tooltip="ConversionPolicy"] "3" [label="OwnershipPolicy< StoragePolicy< T >::InitPointerType >" tooltip="OwnershipPolicy< StoragePolicy< T >::InitPointerType >"] "2" [label="StoragePolicy< T >" tooltip="StoragePolicy< T >"] "1" [label="xlifepp::SmartPtr< T, OwnershipPolicy, ConversionPolicy, CheckingPolicy, StoragePolicy, ConstnessPolicy >" tooltip="xlifepp::SmartPtr< T, OwnershipPolicy, ConversionPolicy, CheckingPolicy, StoragePolicy, ConstnessPolicy >" fillcolor="#BFBFBF"] "1" -> "2" [dir=forward tooltip="public-inheritance"] "1" -> "3" [dir=forward tooltip="public-inheritance"] "1" -> "4" [dir=forward tooltip="public-inheritance"] "1" -> "5" [dir=forward tooltip="public-inheritance"] }

Smart pointers are objects which store pointers to dynamically allocated (heap) objects.

They behave much like built-in C++ pointers except that they automatically delete the object pointed to at the appropriate time. Conceptually, smart pointers are seen as owning the object pointed to, and thus responsible for deletion of the object when it is no longer needed.

Note

The implementation is adapted from Modern C++ Design: Generic Programming and Design Patterns Applied

Public Functions

inline SmartPtr()#

default constructor

template<typename T1, template<class> class OP1, class CP1, template<class> class KP1, template<class> class SP1, template<class> class CNP1>
inline SmartPtr(const SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1> &rhs)#

copy constructor

inline SmartPtr(CopyArg &rhs)#

constructor frm copy argument

inline explicit SmartPtr(ExplicitArg p)#

constructor from explicit argument

inline SmartPtr(ImplicitArg p)#

basic constructor from implicit argument

inline SmartPtr(ImplicitArg p, bool isAllocated)#

constructor from implicit argument

inline SmartPtr(RefToValue<SmartPtr> rhs)#

constructor

inline SmartPtr(SmartPointerNullType smNull)#

constructor from null pointer

template<typename T1, template<class> class OP1, class CP1, template<class> class KP1, template<class> class SP1, template<class> class CNP1>
inline SmartPtr(SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1> &rhs)#

copy constructor (non const arg)

inline ~SmartPtr()#

destructor

inline SmartPtr &operator=(const SmartPointerNullType&)#

assignment operator from null pointer

template<typename T1, template<class> class OP1, class CP1, template<class> class KP1, template<class> class SP1, template<class> class CNP1>
inline SmartPtr &operator=(const SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1> &rhs)#

assignment operator

inline SmartPtr &operator=(CopyArg &rhs)#

assignment operator from copy argument

template<typename T1, template<class> class OP1, class CP1, template<class> class KP1, template<class> class SP1, template<class> class CNP1>
inline SmartPtr &operator=(SmartPtr<T1, OP1, CP1, KP1, SP1, CNP1> &rhs)#

assignment operator (non const arg)