Stefan Scholz / ETL
Embed: (wiki syntax)

« Back to documentation index

optional< T > Class Template Reference

optional< T > Class Template Reference

An optional type. More...

#include <optional.h>

Public Member Functions

 optional ()
 Constructor.
 optional (etl::nullopt_t)
 Constructor with nullopt.
 optional (const optional &other)
 Copy constructor.
 optional (const T &value_)
 Constructor from value type.
 ~optional ()
 Destructor.
optionaloperator= (etl::nullopt_t)
 Assignment operator from nullopt.
optionaloperator= (const optional &other)
 Assignment operator from optional.
optionaloperator= (const T &value_)
 Assignment operator from value type.
T * operator-> ()
 Pointer operator.
const T * operator-> () const
 Pointer operator.
T & operator* ()
 Dereference operator.
const T & operator* () const
 Dereference operator.
 operator bool () const
 Bool conversion operator.
T & value ()
 Get a reference to the value.
const T & value () const
 Get a const reference to the value.
value_or (T default_value) const
 Gets the value or a default if no valid.
void swap (optional &other)
 Swaps this value with another.

Detailed Description

template<typename T>
class etl::optional< T >

An optional type.

If the optional type is not initialised then a type is not constructed.

Template Parameters:
Thetype to store.

Definition at line 104 of file optional.h.


Constructor & Destructor Documentation

optional (  )

Constructor.

Definition at line 111 of file optional.h.

Constructor with nullopt.

Definition at line 119 of file optional.h.

optional ( const optional< T > &  other )

Copy constructor.

Definition at line 127 of file optional.h.

optional ( const T &  value_ )

Constructor from value type.

Definition at line 139 of file optional.h.

~optional (  )

Destructor.

Definition at line 148 of file optional.h.


Member Function Documentation

operator bool (  ) const [explicit]

Bool conversion operator.

Definition at line 268 of file optional.h.

T& operator* (  )

Dereference operator.

Definition at line 244 of file optional.h.

const T& operator* (  ) const

Dereference operator.

Definition at line 256 of file optional.h.

const T* operator-> (  ) const

Pointer operator.

Definition at line 232 of file optional.h.

T* operator-> (  )

Pointer operator.

Definition at line 220 of file optional.h.

optional& operator= ( const optional< T > &  other )

Assignment operator from optional.

Definition at line 173 of file optional.h.

optional& operator= ( etl::nullopt_t   )

Assignment operator from nullopt.

Definition at line 159 of file optional.h.

optional& operator= ( const T &  value_ )

Assignment operator from value type.

Definition at line 202 of file optional.h.

void swap ( optional< T > &  other )

Swaps this value with another.

Definition at line 308 of file optional.h.

const T& value (  ) const

Get a const reference to the value.

Definition at line 288 of file optional.h.

T& value (  )

Get a reference to the value.

Definition at line 276 of file optional.h.

T value_or ( default_value ) const

Gets the value or a default if no valid.

Definition at line 300 of file optional.h.