mn::basic_optional< T > Class Template Reference

#include <mn_optional.hpp>

Public Types

using value_type = T
 
using const_value_type = const T
 
using reference = T &
 
using const_reference = const T &
 
using move_type = T &&
 
using const_move_type = const T &&
 
using pointer = T *
 
using const_pointer = const T *
 
using self_type = basic_optional< T >
 

Public Member Functions

constexpr basic_optional () noexcept
 
 basic_optional (const self_type &other)
 
 basic_optional (const self_type &&other) noexcept
 
template<typename... Args>
constexpr basic_optional (Args &&... args)
 
template<typename U = value_type>
constexpr basic_optional (U &&value)
 
 ~basic_optional ()
 
void reset () noexcept
 Resets the basic_optional. More...
 
void clear ()
 Clears the basic_optional. More...
 
self_typeassign (const_value_type &value)
 Assigns a value to the basic_otional. More...
 
self_typeassign (move_type value)
 Moves a value into the basic_otional. More...
 
self_typeassign (const self_type &other)
 Assigns another basic_otional. More...
 
void swap (self_type &other)
 Swap this basic_optional with a other. More...
 
constexpr bool has_value () const noexcept
 Have this basic_optional a value? More...
 
reference value ()
 Returns the basic_optional's value. More...
 
const_reference value () const
 Returns the basic_optional's value. More...
 
constexpr value_type value_or (const value_type value) const
 Returns the basic_optional's value, or the given default value when this basic_optional no value have. More...
 
template<typename U >
constexpr value_type value_or (const U &value) const
 Returns the basic_optional's value, or the given default value when this basic_optional no value have. More...
 
self_typeoperator= (const self_type &other) noexcept
 Assigns another basic_otional. More...
 
self_typeoperator= (self_type &&other) noexcept
 Assigns another basic_otional. More...
 
constexpr const_pointer operator-> () const
 Get the given value as pointer. More...
 
pointer operator-> ()
 
constexpr const_reference operator* () const
 
reference operator* ()
 
 operator bool () const noexcept
 Convert this basic_optional to boolean. More...
 

Private Attributes

bool m_bHasValue
 Flag whether or not has this basic_optianel a value. More...
 
value_type m_tValue
 A saved / cached copy of the value. More...
 

Member Typedef Documentation

◆ const_move_type

template<typename T >
using mn::basic_optional< T >::const_move_type = const T&&

◆ const_pointer

template<typename T >
using mn::basic_optional< T >::const_pointer = const T*

◆ const_reference

template<typename T >
using mn::basic_optional< T >::const_reference = const T&

◆ const_value_type

template<typename T >
using mn::basic_optional< T >::const_value_type = const T

◆ move_type

template<typename T >
using mn::basic_optional< T >::move_type = T&&

◆ pointer

template<typename T >
using mn::basic_optional< T >::pointer = T*

◆ reference

template<typename T >
using mn::basic_optional< T >::reference = T&

◆ self_type

template<typename T >
using mn::basic_optional< T >::self_type = basic_optional<T>

◆ value_type

template<typename T >
using mn::basic_optional< T >::value_type = T

Constructor & Destructor Documentation

◆ basic_optional() [1/5]

template<typename T >
constexpr mn::basic_optional< T >::basic_optional ( )
inlineconstexprnoexcept

◆ basic_optional() [2/5]

template<typename T >
mn::basic_optional< T >::basic_optional ( const self_type other)
inline

◆ basic_optional() [3/5]

template<typename T >
mn::basic_optional< T >::basic_optional ( const self_type &&  other)
inlinenoexcept

◆ basic_optional() [4/5]

template<typename T >
template<typename... Args>
constexpr mn::basic_optional< T >::basic_optional ( Args &&...  args)
inlineexplicitconstexpr

◆ basic_optional() [5/5]

template<typename T >
template<typename U = value_type>
constexpr mn::basic_optional< T >::basic_optional ( U &&  value)
inlineexplicitconstexpr

◆ ~basic_optional()

template<typename T >
mn::basic_optional< T >::~basic_optional ( )
inline

Member Function Documentation

◆ assign() [1/3]

template<typename T >
self_type& mn::basic_optional< T >::assign ( const self_type other)
inline

Assigns another basic_otional.

◆ assign() [2/3]

template<typename T >
self_type& mn::basic_optional< T >::assign ( const_value_type value)
inline

Assigns a value to the basic_otional.

◆ assign() [3/3]

template<typename T >
self_type& mn::basic_optional< T >::assign ( move_type  value)
inline

Moves a value into the basic_otional.

◆ clear()

template<typename T >
void mn::basic_optional< T >::clear ( )
inline

Clears the basic_optional.

◆ has_value()

template<typename T >
constexpr bool mn::basic_optional< T >::has_value ( ) const
inlineconstexprnoexcept

Have this basic_optional a value?

Returns
True when this basic_optional hald any vaule and false when not.

◆ operator bool()

template<typename T >
mn::basic_optional< T >::operator bool ( ) const
inlineexplicitnoexcept

Convert this basic_optional to boolean.

Returns
True when this basic_optional hald any vaule and false when not.

◆ operator*() [1/2]

template<typename T >
reference mn::basic_optional< T >::operator* ( void  )
inline

◆ operator*() [2/2]

template<typename T >
constexpr const_reference mn::basic_optional< T >::operator* ( void  ) const
inlineconstexpr

◆ operator->() [1/2]

template<typename T >
pointer mn::basic_optional< T >::operator-> ( )
inline

◆ operator->() [2/2]

template<typename T >
constexpr const_pointer mn::basic_optional< T >::operator-> ( ) const
inlineconstexpr

Get the given value as pointer.

◆ operator=() [1/2]

template<typename T >
self_type& mn::basic_optional< T >::operator= ( const self_type other)
inlinenoexcept

Assigns another basic_otional.

◆ operator=() [2/2]

template<typename T >
self_type& mn::basic_optional< T >::operator= ( self_type &&  other)
inlinenoexcept

Assigns another basic_otional.

◆ reset()

template<typename T >
void mn::basic_optional< T >::reset ( )
inlinenoexcept

Resets the basic_optional.

◆ swap()

template<typename T >
void mn::basic_optional< T >::swap ( self_type other)
inline

Swap this basic_optional with a other.

◆ value() [1/2]

template<typename T >
reference mn::basic_optional< T >::value ( )
inline

Returns the basic_optional's value.

◆ value() [2/2]

template<typename T >
const_reference mn::basic_optional< T >::value ( ) const
inline

Returns the basic_optional's value.

◆ value_or() [1/2]

template<typename T >
template<typename U >
constexpr value_type mn::basic_optional< T >::value_or ( const U &  value) const
inlineconstexpr

Returns the basic_optional's value, or the given default value when this basic_optional no value have.

◆ value_or() [2/2]

template<typename T >
constexpr value_type mn::basic_optional< T >::value_or ( const value_type  value) const
inlineconstexpr

Returns the basic_optional's value, or the given default value when this basic_optional no value have.

Member Data Documentation

◆ m_bHasValue

template<typename T >
bool mn::basic_optional< T >::m_bHasValue
private

Flag whether or not has this basic_optianel a value.

◆ m_tValue

template<typename T >
value_type mn::basic_optional< T >::m_tValue
private

A saved / cached copy of the value.


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