ADTF  3.18.2
Optional< T >

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

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 More...
 
Optionaloperator= (const Optional &)=default
 copy assignment operator More...
 
 ~Optional ()=default
 DTOR.
 
 Optional (const value_type &value)
 special copy CTOR More...
 
Optionaloperator= (const value_type &value)
 copy assignment operator More...
 
 Optional (value_type &&value)
 move CTOR More...
 
Optionaloperator= (value_type &&value)
 move assignment operator More...
 
 operator bool () const
 validation status of the optional More...
 
 operator value_type () const
 conversion to the value type More...
 
value_typeoperator* ()
 referenced access to the value More...
 
const value_type operator* () const
 dereferenced access of the value More...
 
void reset ()
 invalidates the value
 
value_type get () const
 return the value type as copy More...
 
bool operator== (const Optional &other) const
 equality operator. More...
 
bool operator!= (const Optional &other) const
 non equality operator. More...
 

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

Definition at line 28 of file dd_access_optional.h.

Constructor & Destructor Documentation

◆ Optional() [1/2]

Optional ( const value_type value)
inline

special copy CTOR

Parameters
valuethe value to copy

Definition at line 70 of file dd_access_optional.h.

◆ Optional() [2/2]

Optional ( value_type &&  value)
inline

move CTOR

Parameters
valuethe value to move

Definition at line 91 of file dd_access_optional.h.

Member Function Documentation

◆ get()

value_type get ( ) const
inline

return the value type as copy

Returns
value_type

Definition at line 162 of file dd_access_optional.h.

References Optional< T >::_value.

◆ operator bool()

operator bool ( ) const
inline

validation status of the optional

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

Definition at line 114 of file dd_access_optional.h.

References Optional< T >::_valid.

◆ operator value_type()

operator value_type ( ) const
inline

conversion to the value type

Returns
value_type

Definition at line 124 of file dd_access_optional.h.

References Optional< T >::_value.

◆ operator!=()

bool 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.

Definition at line 190 of file dd_access_optional.h.

References Optional< T >::operator==().

◆ operator*() [1/2]

value_type& operator* ( )
inline

referenced access to the value

Returns
value_type&

Definition at line 134 of file dd_access_optional.h.

References Optional< T >::_value.

◆ operator*() [2/2]

const value_type operator* ( ) const
inline

dereferenced access of the value

Returns
const value_type

Definition at line 144 of file dd_access_optional.h.

References Optional< T >::_value.

◆ operator=() [1/4]

Optional& operator= ( const Optional< T > &  )
default

copy assignment operator

Returns
Optional&

◆ operator=() [2/4]

Optional& operator= ( const value_type value)
inline

copy assignment operator

Parameters
valuethe value to copy
Returns
Optional&

Definition at line 79 of file dd_access_optional.h.

References Optional< T >::_valid, and Optional< T >::_value.

◆ operator=() [3/4]

Optional& operator= ( Optional< T > &&  )
default

move assignment operator

Returns
Optional&

◆ operator=() [4/4]

Optional& operator= ( value_type &&  value)
inline

move assignment operator

Parameters
valuethe value to move
Returns
Optional&

Definition at line 101 of file dd_access_optional.h.

References Optional< T >::_valid, and Optional< T >::_value.

◆ operator==()

bool 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.

Definition at line 173 of file dd_access_optional.h.

References Optional< T >::_valid, and Optional< T >::_value.

Referenced by Optional< T >::operator!=().