CASM  1.1.0
A Clusters Approach to Statistical Mechanics
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 163 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 cloneable_ptr &other)
 Construct by cloning other. More...
 
template<typename U >
 cloneable_ptr (const cloneable_ptr< U > &other)
 Construct by cloning other. More...
 
 cloneable_ptr (cloneable_ptr &&other)
 Construct by moving 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_ptr ()
 
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...
 
template<typename U >
cloneable_ptr< Type > & operator= (cloneable_ptr< U > &&other)
 Assignment via move. More...
 
template<typename U >
cloneable_ptr< Type > & operator= (const std::unique_ptr< U > &other)
 Assignment via clone. More...
 
template<typename U >
cloneable_ptr< Type > & operator= (std::unique_ptr< U > &&other)
 Assignment via move. More...
 

Private Attributes

std::unique_ptr< Type > m_unique
 

Member Typedef Documentation

◆ element_type

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

Definition at line 165 of file cloneable_ptr.hh.

◆ pointer

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

Definition at line 166 of file cloneable_ptr.hh.

◆ reference

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

Definition at line 167 of file cloneable_ptr.hh.

Constructor & Destructor Documentation

◆ cloneable_ptr() [1/8]

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

Default constructor.

Definition at line 170 of file cloneable_ptr.hh.

◆ cloneable_ptr() [2/8]

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

Construct by taking ownership of ptr.

Definition at line 295 of file cloneable_ptr.hh.

◆ cloneable_ptr() [3/8]

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

Construct by cloning other.

Definition at line 299 of file cloneable_ptr.hh.

◆ cloneable_ptr() [4/8]

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

Construct by cloning other.

Definition at line 308 of file cloneable_ptr.hh.

◆ cloneable_ptr() [5/8]

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

Construct by moving other.

Definition at line 316 of file cloneable_ptr.hh.

◆ cloneable_ptr() [6/8]

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

Construct by moving other.

Definition at line 322 of file cloneable_ptr.hh.

◆ cloneable_ptr() [7/8]

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

Construct by cloning other.

Definition at line 328 of file cloneable_ptr.hh.

◆ cloneable_ptr() [8/8]

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

Construct by moving.

Definition at line 338 of file cloneable_ptr.hh.

◆ ~cloneable_ptr()

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

Definition at line 342 of file cloneable_ptr.hh.

Member Function Documentation

◆ operator bool()

template<typename Type >
notstd::cloneable_ptr< Type >::operator bool
explicit

Checks whether *this owns an object.

Definition at line 411 of file cloneable_ptr.hh.

◆ operator*()

template<typename Type >
cloneable_ptr< Type >::reference notstd::cloneable_ptr< Type >::operator*

Definition at line 382 of file cloneable_ptr.hh.

◆ operator->()

template<typename Type >
cloneable_ptr< Type >::pointer notstd::cloneable_ptr< Type >::operator->

Definition at line 387 of file cloneable_ptr.hh.

◆ operator=() [1/7]

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

Assignment via copy-swap.

Definition at line 346 of file cloneable_ptr.hh.

◆ operator=() [2/7]

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

Assignment via move.

◆ operator=() [3/7]

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

Assignment via move.

Definition at line 354 of file cloneable_ptr.hh.

◆ operator=() [4/7]

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

Assignment via clone.

◆ operator=() [5/7]

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

Assignment via clone.

Definition at line 362 of file cloneable_ptr.hh.

◆ operator=() [6/7]

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

Assignment via move.

◆ operator=() [7/7]

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

Assignment via move.

Definition at line 375 of file cloneable_ptr.hh.

◆ reset()

template<typename Type >
void notstd::cloneable_ptr< Type >::reset

Reset contained unique_ptr.

Definition at line 393 of file cloneable_ptr.hh.

◆ unique() [1/2]

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

Access contained unique_ptr.

Definition at line 399 of file cloneable_ptr.hh.

◆ unique() [2/2]

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

const Access contained unique_ptr

Definition at line 405 of file cloneable_ptr.hh.

Member Data Documentation

◆ m_unique

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

Definition at line 231 of file cloneable_ptr.hh.


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