Minetest  5.4.0
Optional< T > Class Template Reference

An implementation of optional for C++11, which aims to be compatible with a subset of std::optional features. More...

#include <Optional.h>

+ Collaboration diagram for Optional< T >:

Public Member Functions

 Optional () noexcept
 
 Optional (nullopt_t) noexcept
 
 Optional (const T &value) noexcept
 
 Optional (const Optional< T > &other) noexcept
 
void operator= (nullopt_t) noexcept
 
void operator= (const Optional< T > &other) noexcept
 
T & value ()
 
const T & value () const
 
const T & value_or (const T &def) const
 
bool has_value () const noexcept
 
 operator bool () const
 

Private Attributes

bool m_has_value = false
 
m_value
 

Detailed Description

template<typename T>
class Optional< T >

An implementation of optional for C++11, which aims to be compatible with a subset of std::optional features.

Unfortunately, Minetest doesn't use C++17 yet.

Template Parameters
TThe type to be stored

Constructor & Destructor Documentation

◆ Optional() [1/4]

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

◆ Optional() [2/4]

template<typename T >
Optional< T >::Optional ( nullopt_t  )
inlinenoexcept

◆ Optional() [3/4]

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

◆ Optional() [4/4]

template<typename T >
Optional< T >::Optional ( const Optional< T > &  other)
inlinenoexcept

Member Function Documentation

◆ has_value()

template<typename T >
bool Optional< T >::has_value ( ) const
inlinenoexcept

◆ operator bool()

template<typename T >
Optional< T >::operator bool ( ) const
inlineexplicit

◆ operator=() [1/2]

template<typename T >
void Optional< T >::operator= ( const Optional< T > &  other)
inlinenoexcept

◆ operator=() [2/2]

template<typename T >
void Optional< T >::operator= ( nullopt_t  )
inlinenoexcept

◆ value() [1/2]

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

References FATAL_ERROR_IF, Optional< T >::m_has_value, and Optional< T >::m_value.

Referenced by Nametag::getBgColor(), ObjectRef::l_get_nametag_attributes(), push_object_properties(), and ObjectProperties::serialize().

+ Here is the caller graph for this function:

◆ value() [2/2]

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

◆ value_or()

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

Member Data Documentation

◆ m_has_value

◆ m_value

template<typename T >
T Optional< T >::m_value
private

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