DAVID4 SDK  1.8.7
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
david::Optional< T > Class Template Reference

The class template david::Optional manages an optional contained value, i.e. More...

#include <Common.h>

Public Member Functions

 Optional ()
 Standard constructor. More...
 
 Optional (const T &value)
 Constructor that initializes the value. More...
 
const T & value () const
 Get value. More...
 
 operator bool () const
 Checks whether *this is in engaged state, i.e. More...
 

Detailed Description

template<class T>
class david::Optional< T >

The class template david::Optional manages an optional contained value, i.e.

a value that semantically may not be present.

The value inside an optional object may be in either an initialized or uninitialized state. An optional object with a value in initialized state is called engaged, whereas if the value is in uninitialized state, the object is called disengaged.

Interface is similar to std::optional defined in C++14: http://en.cppreference.com/w/cpp/utility/optional

Definition at line 84 of file Common.h.

Constructor & Destructor Documentation

template<class T>
david::Optional< T >::Optional ( )
inline

Standard constructor.

Value is not initialized.

Definition at line 89 of file Common.h.

template<class T>
david::Optional< T >::Optional ( const T &  value)
inline

Constructor that initializes the value.

Parameters
[in]valueValue to assign to the contained value.

Definition at line 93 of file Common.h.

Member Function Documentation

template<class T>
david::Optional< T >::operator bool ( ) const
inline

Checks whether *this is in engaged state, i.e.

whether the contained value is initialized.

Returns
true if *this is in engaged state, false otherwise.

Definition at line 106 of file Common.h.

template<class T>
const T& david::Optional< T >::value ( ) const
inline

Get value.

Returns
Current value. Might be anything, if not initialized.
Exceptions
david::Error_MissingObject(david::Exception) Value is not initialized.

Definition at line 98 of file Common.h.


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