CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
notstd::cloneable_ptr< Type > Class Template Reference

#include <cloneable_ptr.hh>

Detailed Description

template<typename Type>
class notstd::cloneable_ptr< Type >

A 'cloneable_ptr' can be used in place of 'unique_ptr'.

If you are creating a class 'MyNewClass' that will have 'std::unique_ptr<Type> m_data' as a class member, you have to explicitly write a copy constructor.

If Type has method 'virtual std::unique_ptr<Type> clone() const' you can use 'notstd::cloneable_ptr<Type> m_data' in place of 'std::unique_ptr<Type> m_data' as a class member and not have to explicity write copy constructors.

Definition at line 28 of file cloneable_ptr.hh.

Public Types

typedef Type element_type
 
typedef Type * pointer
 
typedef Type & reference
 

Public Member Functions

 cloneable_ptr ()
 Default constructor. More...
 
 cloneable_ptr (pointer ptr)
 Construct by taking ownership of ptr. More...
 
 cloneable_ptr (const Type &obj)
 Construct by cloning obj. More...
 
 cloneable_ptr (const cloneable_ptr &other)
 Construct by cloning other. More...
 
template<typename U >
 cloneable_ptr (const cloneable_ptr< U > &other)
 Construct by cloning other. More...
 
template<typename U >
 cloneable_ptr (cloneable_ptr< U > &&other)
 Construct by moving other. More...
 
template<typename U >
 cloneable_ptr (const std::unique_ptr< U > &other)
 Construct by cloning other. More...
 
template<typename U >
 cloneable_ptr (std::unique_ptr< U > &&other)
 Construct by moving. More...
 
cloneable_ptroperator= (cloneable_ptr other)
 Assignment via copy-swap. More...
 
template<typename U >
cloneable_ptroperator= (cloneable_ptr< U > &&other)
 Assignment via move. More...
 
template<typename U >
cloneable_ptroperator= (const std::unique_ptr< U > &other)
 Assignment via clone. More...
 
template<typename U >
cloneable_ptroperator= (std::unique_ptr< U > &&other)
 Assignment via move. More...
 
reference operator* () const
 
pointer operator-> () const
 
void reset ()
 Reset contained unique_ptr. More...
 
std::unique_ptr< Type > & unique ()
 Access contained unique_ptr. More...
 
const std::unique_ptr< Type > & unique () const
 const Access contained unique_ptr More...
 
 operator bool () const
 Checks whether *this owns an object. More...
 

Private Attributes

std::unique_ptr< Type > m_unique
 

Member Typedef Documentation

template<typename Type>
typedef Type notstd::cloneable_ptr< Type >::element_type

Definition at line 70 of file cloneable_ptr.hh.

template<typename Type>
typedef Type* notstd::cloneable_ptr< Type >::pointer

Definition at line 71 of file cloneable_ptr.hh.

template<typename Type>
typedef Type& notstd::cloneable_ptr< Type >::reference

Definition at line 72 of file cloneable_ptr.hh.

Constructor & Destructor Documentation

template<typename Type>
notstd::cloneable_ptr< Type >::cloneable_ptr ( )
inline

Default constructor.

Definition at line 75 of file cloneable_ptr.hh.

template<typename Type>
notstd::cloneable_ptr< Type >::cloneable_ptr ( pointer  ptr)
inlineexplicit

Construct by taking ownership of ptr.

Definition at line 78 of file cloneable_ptr.hh.

template<typename Type>
notstd::cloneable_ptr< Type >::cloneable_ptr ( const Type &  obj)
inlineexplicit

Construct by cloning obj.

Definition at line 82 of file cloneable_ptr.hh.

template<typename Type>
notstd::cloneable_ptr< Type >::cloneable_ptr ( const cloneable_ptr< Type > &  other)
inline

Construct by cloning other.

Definition at line 87 of file cloneable_ptr.hh.

template<typename Type>
template<typename U >
notstd::cloneable_ptr< Type >::cloneable_ptr ( const cloneable_ptr< U > &  other)
inline

Construct by cloning other.

Definition at line 96 of file cloneable_ptr.hh.

template<typename Type>
template<typename U >
notstd::cloneable_ptr< Type >::cloneable_ptr ( cloneable_ptr< U > &&  other)
inline

Construct by moving other.

Definition at line 105 of file cloneable_ptr.hh.

template<typename Type>
template<typename U >
notstd::cloneable_ptr< Type >::cloneable_ptr ( const std::unique_ptr< U > &  other)
inline

Construct by cloning other.

Definition at line 111 of file cloneable_ptr.hh.

template<typename Type>
template<typename U >
notstd::cloneable_ptr< Type >::cloneable_ptr ( std::unique_ptr< U > &&  other)
inline

Construct by moving.

Definition at line 120 of file cloneable_ptr.hh.

Member Function Documentation

template<typename Type>
notstd::cloneable_ptr< Type >::operator bool ( ) const
inlineexplicit

Checks whether *this owns an object.

Definition at line 182 of file cloneable_ptr.hh.

template<typename Type>
reference notstd::cloneable_ptr< Type >::operator* ( ) const
inline

Definition at line 158 of file cloneable_ptr.hh.

template<typename Type>
pointer notstd::cloneable_ptr< Type >::operator-> ( ) const
inline

Definition at line 162 of file cloneable_ptr.hh.

template<typename Type>
cloneable_ptr& notstd::cloneable_ptr< Type >::operator= ( cloneable_ptr< Type >  other)
inline

Assignment via copy-swap.

Definition at line 125 of file cloneable_ptr.hh.

template<typename Type>
template<typename U >
cloneable_ptr& notstd::cloneable_ptr< Type >::operator= ( cloneable_ptr< U > &&  other)
inline

Assignment via move.

Definition at line 132 of file cloneable_ptr.hh.

template<typename Type>
template<typename U >
cloneable_ptr& notstd::cloneable_ptr< Type >::operator= ( const std::unique_ptr< U > &  other)
inline

Assignment via clone.

Definition at line 140 of file cloneable_ptr.hh.

template<typename Type>
template<typename U >
cloneable_ptr& notstd::cloneable_ptr< Type >::operator= ( std::unique_ptr< U > &&  other)
inline

Assignment via move.

Definition at line 152 of file cloneable_ptr.hh.

template<typename Type>
void notstd::cloneable_ptr< Type >::reset ( )
inline

Reset contained unique_ptr.

Definition at line 167 of file cloneable_ptr.hh.

template<typename Type>
std::unique_ptr<Type>& notstd::cloneable_ptr< Type >::unique ( )
inline

Access contained unique_ptr.

Definition at line 172 of file cloneable_ptr.hh.

template<typename Type>
const std::unique_ptr<Type>& notstd::cloneable_ptr< Type >::unique ( ) const
inline

const Access contained unique_ptr

Definition at line 177 of file cloneable_ptr.hh.

Member Data Documentation

template<typename Type>
std::unique_ptr<Type> notstd::cloneable_ptr< Type >::m_unique
private

Definition at line 188 of file cloneable_ptr.hh.


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