Dev Essential
Loading...
Searching...
No Matches
ddl::dd::utility::Optional< T > Struct Template Reference

An optional template as long as the std::optional is not available here. More...

#include <access_optional.h>

Public Types

typedef T value_type
 defintion of the value type of this optional
 

Public Member Functions

 Optional ()
 default CTOR
 
 Optional (Optional &&)=default
 move CTOR
 
 Optional (const Optional &)=default
 copy CTOR
 
Optionaloperator= (Optional &&)=default
 move assignment operator
 
Optionaloperator= (const Optional &)=default
 copy assignment operator
 
 ~Optional ()=default
 DTOR.
 
 Optional (const value_type &value)
 special copy CTOR
 
Optionaloperator= (const value_type &value)
 copy assignment operator
 
 Optional (value_type &&value)
 move CTOR
 
Optionaloperator= (value_type &&value)
 move assignment operator
 
 operator bool () const
 validation status of the optional
 
 operator value_type () const
 conversion to the value type
 
value_typeoperator* () &
 referenced access to the value
 
value_type && operator* () &&
 referenced access to the value
 
const value_typeoperator* () const &
 referenced access of the value
 
const value_type && operator* () const &&
 referenced access of the value
 
void reset ()
 invalidates the value
 
value_type get () &
 return the value type as copy
 
value_type && get () &&
 steal value type
 
value_type get () const &
 return the value type as copy
 
value_type get () const &&
 steal value type
 
bool operator== (const Optional &other) const
 equality operator.
 
bool operator!= (const Optional &other) const
 non equality operator.
 

Public Attributes

bool _valid = false
 is valid or not
 
value_type _value = {}
 the value if it is valid
 

Detailed Description

template<typename T>
struct ddl::dd::utility::Optional< T >

An optional template as long as the std::optional is not available here.

Template Parameters
Tthe value type

Constructor & Destructor Documentation

◆ Optional() [1/2]

template<typename T>
ddl::dd::utility::Optional< T >::Optional ( const value_type & value)
inline

special copy CTOR

Parameters
valuethe value to copy

◆ Optional() [2/2]

template<typename T>
ddl::dd::utility::Optional< T >::Optional ( value_type && value)
inline

move CTOR

Parameters
valuethe value to move

Member Function Documentation

◆ get() [1/4]

template<typename T>
value_type ddl::dd::utility::Optional< T >::get ( ) &
inline

return the value type as copy

Returns
value_type

◆ get() [2/4]

template<typename T>
value_type && ddl::dd::utility::Optional< T >::get ( ) &&
inline

steal value type

Returns
value_type&&

◆ get() [3/4]

template<typename T>
value_type ddl::dd::utility::Optional< T >::get ( ) const &
inline

return the value type as copy

Returns
value_type

◆ get() [4/4]

template<typename T>
value_type ddl::dd::utility::Optional< T >::get ( ) const &&
inline

steal value type

Returns
value_type

◆ operator bool()

template<typename T>
ddl::dd::utility::Optional< T >::operator bool ( ) const
inline

validation status of the optional

Returns
true the value is valid
false the value is not valid

◆ operator value_type()

template<typename T>
ddl::dd::utility::Optional< T >::operator value_type ( ) const
inline

conversion to the value type

Returns
value_type

◆ operator!=()

template<typename T>
bool ddl::dd::utility::Optional< T >::operator!= ( const Optional< T > & other) const
inline

non equality operator.

Parameters
otherthe other Optional to compare this Optional to.
Returns
false the Optionals are equal (value and validity)
true the Optionals are not equal.

◆ operator*() [1/4]

template<typename T>
value_type & ddl::dd::utility::Optional< T >::operator* ( ) &
inline

referenced access to the value

Returns
value_type&

◆ operator*() [2/4]

template<typename T>
value_type && ddl::dd::utility::Optional< T >::operator* ( ) &&
inline

referenced access to the value

Returns
value_type&&

◆ operator*() [3/4]

template<typename T>
const value_type & ddl::dd::utility::Optional< T >::operator* ( ) const &
inline

referenced access of the value

Returns
const value_type&

◆ operator*() [4/4]

template<typename T>
const value_type && ddl::dd::utility::Optional< T >::operator* ( ) const &&
inline

referenced access of the value

Returns
const value_type&&

◆ operator=() [1/4]

template<typename T>
Optional & ddl::dd::utility::Optional< T >::operator= ( const Optional< T > & )
default

copy assignment operator

Returns
Optional&

◆ operator=() [2/4]

template<typename T>
Optional & ddl::dd::utility::Optional< T >::operator= ( const value_type & value)
inline

copy assignment operator

Parameters
valuethe value to copy
Returns
Optional&

◆ operator=() [3/4]

template<typename T>
Optional & ddl::dd::utility::Optional< T >::operator= ( Optional< T > && )
default

move assignment operator

Returns
Optional&

◆ operator=() [4/4]

template<typename T>
Optional & ddl::dd::utility::Optional< T >::operator= ( value_type && value)
inline

move assignment operator

Parameters
valuethe value to move
Returns
Optional&

◆ operator==()

template<typename T>
bool ddl::dd::utility::Optional< T >::operator== ( const Optional< T > & other) const
inline

equality operator.

Parameters
otherthe other Optional to compare this Optional to.
Returns
true the Optionals are equal (value and validity)
false the Optionals are not equal.

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