TouchCPLib  1.0.0
A touch-enabled GUI interface based on SDL and libTS. It provides a simple desktop-free UI for your embedded Raspberry projects.
Optional< T > Class Template Reference

A class that wraps a value that can be null. More...

#include <Optional.h>

Public Member Functions

 Optional ()
 Construct an empty Optional object. More...
 
 Optional (const T &value)
 Construct an Optional object initialized with the given value. More...
 
 Optional (T &&value)
 Construct an Optional object initialized with the given value. More...
 
bool hasValue () const
 Returns true if the optional object has a value. More...
 
T & get ()
 Gets the inner object. More...
 
const T & get () const
 Gets the inner object. More...
 
void set (const T &value)
 Replace the inner object. More...
 
void set (T &&value)
 Replace the inner object. More...
 
Optional< T > & operator= (const Optional< T > &value)
 Assignment operator with copy semantics. More...
 
void clear ()
 Removes the inner object, making the optional void. More...
 

Detailed Description

template<typename T>
class Optional< T >

A class that wraps a value that can be null.

Template Parameters
TThe type of the value to wrap

Constructor & Destructor Documentation

◆ Optional() [1/3]

template<typename T>
Optional< T >::Optional ( )
inline

Construct an empty Optional object.

◆ Optional() [2/3]

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

Construct an Optional object initialized with the given value.

Parameters
valueThe value that will be copied

◆ Optional() [3/3]

template<typename T>
Optional< T >::Optional ( T &&  value)
inline

Construct an Optional object initialized with the given value.

Parameters
valueThe value that will be moved

Member Function Documentation

◆ clear()

template<typename T>
void Optional< T >::clear ( )
inline

Removes the inner object, making the optional void.

◆ get() [1/2]

template<typename T>
T& Optional< T >::get ( )
inline

Gets the inner object.

Returns
T& The inner object
Exceptions
std::runtime_errorif the optional does not have an object

◆ get() [2/2]

template<typename T>
const T& Optional< T >::get ( ) const
inline

Gets the inner object.

Returns
T& The inner object
Exceptions
std::runtime_errorif the optional does not have an object

◆ hasValue()

template<typename T>
bool Optional< T >::hasValue ( ) const
inline

Returns true if the optional object has a value.

Returns
whether the optional has a value

◆ operator=()

template<typename T>
Optional<T>& Optional< T >::operator= ( const Optional< T > &  value)
inline

Assignment operator with copy semantics.

Parameters
valueThe value to assign
Returns
Optional<T>& This object

◆ set() [1/2]

template<typename T>
void Optional< T >::set ( const T &  value)
inline

Replace the inner object.

Parameters
valueThe object to be copied

◆ set() [2/2]

template<typename T>
void Optional< T >::set ( T &&  value)
inline

Replace the inner object.

Parameters
valueThe object to be moved

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