E-MailRelay
Public Member Functions | List of all members
G::optional< T > Class Template Reference

A class template like a simplified c++17 std::optional. More...

#include <goptional.h>

Public Member Functions

 optional () noexcept(noexcept(T()))
 Default constructor for no value.
 
 optional (const T &)
 Constructor for a defined value. More...
 
 optional (bool has_value, const T &value)
 Constructor. Not in std::optional. More...
 
void clear ()
 Clears the value. Not in std::optional. More...
 
bool has_value () const noexcept
 Returns true if a defined value. More...
 
 operator bool () const noexcept
 Returns true if a defined value. More...
 
const T & value () const
 Returns the value. More...
 
value_or (const T &) const
 Returns the value or a default. More...
 
optional< T > & operator= (const T &)
 Assignment for a defined value. More...
 
 optional (const optional &)=default
 
 optional (optional &&) noexcept=default
 
optionaloperator= (const optional &)=default
 
optionaloperator= (optional &&) noexcept=default
 

Detailed Description

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

A class template like a simplified c++17 std::optional.

Definition at line 37 of file goptional.h.

Constructor & Destructor Documentation

◆ optional() [1/2]

template<typename T >
G::optional< T >::optional ( const T &  t)
explicit

Constructor for a defined value.

Definition at line 87 of file goptional.h.

◆ optional() [2/2]

template<typename T >
G::optional< T >::optional ( bool  has_value,
const T &  value 
)

Constructor. Not in std::optional.

Definition at line 94 of file goptional.h.

Member Function Documentation

◆ clear()

template<typename T >
void G::optional< T >::clear

Clears the value. Not in std::optional.

Definition at line 101 of file goptional.h.

◆ has_value()

template<typename T >
bool G::optional< T >::has_value
noexcept

Returns true if a defined value.

Definition at line 107 of file goptional.h.

◆ operator bool()

template<typename T >
G::optional< T >::operator bool
explicitnoexcept

Returns true if a defined value.

Definition at line 113 of file goptional.h.

◆ operator=()

template<typename T >
G::optional< T > & G::optional< T >::operator= ( const T &  t)

Assignment for a defined value.

Definition at line 138 of file goptional.h.

◆ value()

template<typename T >
const T & G::optional< T >::value

Returns the value.

Definition at line 119 of file goptional.h.

◆ value_or()

template<typename T >
T G::optional< T >::value_or ( const T &  default_) const

Returns the value or a default.

Definition at line 132 of file goptional.h.


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