Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
Public Member Functions | Friends
ext::ptr_value< T > Class Template Reference

Class representing wrapper of dynamically allocated object behaving like rvalue reference. More...

#include <ptr_value.hpp>

Public Member Functions

 ptr_value (const T &value)
 Constructor of the ptr_value from dynaically allocated object. The class will take ownerhip of the pointer. More...
 
 ptr_value (T &&value)
 Constructor of the ptr_value from dynaically allocated object. The class will take ownerhip of the pointer. More...
 
template<class U >
 ptr_value (ptr_value< U > &&other)
 User conversion constructor from ptr_value for type U where T is its predecessor. More...
 
 ptr_value (const ptr_value &other)
 Copy construction will clone the pointer referenced value in source instance to create new one for the constructed object. More...
 
 ptr_value (ptr_value &&other) noexcept
 Move construction will transfer ownership of the pointer from source instance to newly created one. More...
 
ptr_valueoperator= (const ptr_value &other)
 Copy assignment will clone the pointer referenced value in source instance to create new one for the constructed object. More...
 
ptr_valueoperator= (ptr_value &&other) noexcept
 
 ~ptr_value () noexcept
 Destructor will free the owned instance. More...
 
T * operator-> () &&
 Arrow operator to chain dereference. More...
 
T * operator-> () &
 Arrow operator to chain dereference. More...
 
const T * operator-> () const &
 Arrow operator to chain dereference. More...
 
 operator T& () &
 Allow automatic cast to const reference. More...
 
 operator const T && () const &
 Allow automatic cast to const rvalue reference which can be itself binded to const reference. More...
 
 operator T&& () &&
 Allow automatic cast to rvalue reference which can be itself binded to const reference. More...
 
const T & get () const
 Getter of the holded value. More...
 

Friends

template<class U >
class ptr_value
 

Detailed Description

template<class T>
class ext::ptr_value< T >

Class representing wrapper of dynamically allocated object behaving like rvalue reference.

The class takes ownership of the dynamically allocated object

Template Parameters
thetype of value wrapped

Constructor & Destructor Documentation

◆ ptr_value() [1/5]

template<class T >
ext::ptr_value< T >::ptr_value ( const T &  value)
inlineexplicit

Constructor of the ptr_value from dynaically allocated object. The class will take ownerhip of the pointer.

◆ ptr_value() [2/5]

template<class T >
ext::ptr_value< T >::ptr_value ( T &&  value)
inlineexplicit

Constructor of the ptr_value from dynaically allocated object. The class will take ownerhip of the pointer.

◆ ptr_value() [3/5]

template<class T >
template<class U >
ext::ptr_value< T >::ptr_value ( ptr_value< U > &&  other)
inline

User conversion constructor from ptr_value for type U where T is its predecessor.

Template Parameters
Uthe subtype of T
Parameters
otherthe other instance

◆ ptr_value() [4/5]

template<class T >
ext::ptr_value< T >::ptr_value ( const ptr_value< T > &  other)
inline

Copy construction will clone the pointer referenced value in source instance to create new one for the constructed object.

Parameters
otherthe other instance

◆ ptr_value() [5/5]

template<class T >
ext::ptr_value< T >::ptr_value ( ptr_value< T > &&  other)
inlinenoexcept

Move construction will transfer ownership of the pointer from source instance to newly created one.

Parameters
otherthe other instance

◆ ~ptr_value()

template<class T >
ext::ptr_value< T >::~ptr_value ( )
inlinenoexcept

Destructor will free the owned instance.

Member Function Documentation

◆ get()

template<class T >
const T & ext::ptr_value< T >::get ( ) const
inline

Getter of the holded value.

Returns
constant reference to the holded value

◆ operator const T &&()

template<class T >
ext::ptr_value< T >::operator const T && ( ) const &
inline

Allow automatic cast to const rvalue reference which can be itself binded to const reference.

The expected cast type const T & causes ambuguity in cast resolution, therefore a hack like this was found.

Returns
the holded value

◆ operator T&()

template<class T >
ext::ptr_value< T >::operator T& ( ) &
inline

Allow automatic cast to const reference.

Returns
the holded value

◆ operator T&&()

template<class T >
ext::ptr_value< T >::operator T&& ( ) &&
inline

Allow automatic cast to rvalue reference which can be itself binded to const reference.

Returns
the holded value

◆ operator->() [1/3]

template<class T >
T * ext::ptr_value< T >::operator-> ( ) &
inline

Arrow operator to chain dereference.

Returns
the owned pointer

◆ operator->() [2/3]

template<class T >
T * ext::ptr_value< T >::operator-> ( ) &&
inline

Arrow operator to chain dereference.

Returns
the owned pointer

◆ operator->() [3/3]

template<class T >
const T * ext::ptr_value< T >::operator-> ( ) const &
inline

Arrow operator to chain dereference.

Returns
the owned pointer

◆ operator=() [1/2]

template<class T >
ptr_value & ext::ptr_value< T >::operator= ( const ptr_value< T > &  other)
inline

Copy assignment will clone the pointer referenced value in source instance to create new one for the constructed object.

Parameters
otherthe other instance
Here is the call graph for this function:

◆ operator=() [2/2]

template<class T >
ptr_value & ext::ptr_value< T >::operator= ( ptr_value< T > &&  other)
inlinenoexcept
Parameters
Moveassignment will swap holded pointers between the two instances.
otherthe other instance.
Here is the call graph for this function:

Friends And Related Function Documentation

◆ ptr_value

template<class T >
template<class U >
friend class ptr_value
friend

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