playrho::OptionalValue< T > Class Template Reference

Optional value template class. More...

#include <OptionalValue.hpp>

Public Types

using value_type = T
 Value type. More...
 

Public Member Functions

PLAYRHO_CONSTEXPR OptionalValue ()=default
 
PLAYRHO_CONSTEXPR OptionalValue (const OptionalValue &other)=default
 Copy constructor. More...
 
PLAYRHO_CONSTEXPR OptionalValue (OptionalValue &&other) noexcept
 Move constructor. More...
 
PLAYRHO_CONSTEXPR OptionalValue (T v)
 Initializing constructor. More...
 
 ~OptionalValue ()=default
 
const PLAYRHO_CONSTEXPR T & operator* () const
 Indirection operator. More...
 
PLAYRHO_CONSTEXPR T & operator* ()
 Indirection operator. More...
 
const PLAYRHO_CONSTEXPR T * operator-> () const
 Member of pointer operator. More...
 
PLAYRHO_CONSTEXPR T * operator-> ()
 Member of pointer operator. More...
 
PLAYRHO_CONSTEXPR operator bool () const noexcept
 Boolean operator. More...
 
PLAYRHO_CONSTEXPR bool has_value () const noexcept
 Whether this optional value has a value. More...
 
OptionalValueoperator= (const OptionalValue &other)=default
 Assignment operator. More...
 
OptionalValueoperator= (OptionalValue &&other) noexcept
 Move assignment operator. More...
 
OptionalValueoperator= (T v)
 Assignment operator. More...
 
PLAYRHO_CONSTEXPR T & value ()
 Accesses the value. More...
 
const PLAYRHO_CONSTEXPR T & value () const
 Accesses the value. More...
 
PLAYRHO_CONSTEXPRvalue_or (const T &alt) const
 Gets the value or provides the alternate given value instead. More...
 
void reset () noexcept
 Resets the optional value back to its default constructed state. More...
 

Detailed Description

template<typename T>
class playrho::OptionalValue< T >

Optional value template class.

An implementation of the optional value type idea.

Note
This is meant to be compatible with std::optional from C++ 17.
Use of this type directly is discouraged. Use the Optional type alias instead.

Definition at line 35 of file OptionalValue.hpp.

Member Typedef Documentation

◆ value_type

template<typename T >
using playrho::OptionalValue< T >::value_type = T

Value type.

Definition at line 40 of file OptionalValue.hpp.

Constructor & Destructor Documentation

◆ OptionalValue() [1/4]

template<typename T >
PLAYRHO_CONSTEXPR playrho::OptionalValue< T >::OptionalValue ( )
inlinedefault

◆ OptionalValue() [2/4]

template<typename T >
PLAYRHO_CONSTEXPR playrho::OptionalValue< T >::OptionalValue ( const OptionalValue< T > &  other)
inlinedefault

Copy constructor.

◆ OptionalValue() [3/4]

template<typename T >
PLAYRHO_CONSTEXPR playrho::OptionalValue< T >::OptionalValue ( OptionalValue< T > &&  other)
inlinenoexcept

Move constructor.

Definition at line 48 of file OptionalValue.hpp.

◆ OptionalValue() [4/4]

template<typename T >
PLAYRHO_CONSTEXPR playrho::OptionalValue< T >::OptionalValue ( v)
inlineexplicit

Initializing constructor.

Definition at line 117 of file OptionalValue.hpp.

◆ ~OptionalValue()

template<typename T >
playrho::OptionalValue< T >::~OptionalValue ( )
default

Member Function Documentation

◆ operator*() [1/2]

template<typename T >
PLAYRHO_CONSTEXPR T & playrho::OptionalValue< T >::operator*
inline

Indirection operator.

Definition at line 154 of file OptionalValue.hpp.

◆ operator*() [2/2]

template<typename T >
PLAYRHO_CONSTEXPR T& playrho::OptionalValue< T >::operator* ( )
inline

Indirection operator.

◆ operator->() [1/2]

template<typename T >
PLAYRHO_CONSTEXPR T * playrho::OptionalValue< T >::operator->
inline

Member of pointer operator.

Definition at line 140 of file OptionalValue.hpp.

◆ operator->() [2/2]

template<typename T >
PLAYRHO_CONSTEXPR T* playrho::OptionalValue< T >::operator-> ( )
inline

Member of pointer operator.

◆ operator bool()

template<typename T >
PLAYRHO_CONSTEXPR playrho::OptionalValue< T >::operator bool
inlineexplicitnoexcept

Boolean operator.

Definition at line 126 of file OptionalValue.hpp.

◆ has_value()

template<typename T >
PLAYRHO_CONSTEXPR bool playrho::OptionalValue< T >::has_value
inlinenoexcept

Whether this optional value has a value.

Definition at line 120 of file OptionalValue.hpp.

◆ operator=() [1/3]

template<typename T >
OptionalValue& playrho::OptionalValue< T >::operator= ( const OptionalValue< T > &  other)
default

Assignment operator.

◆ operator=() [2/3]

template<typename T >
OptionalValue& playrho::OptionalValue< T >::operator= ( OptionalValue< T > &&  other)
inlinenoexcept

Move assignment operator.

Definition at line 83 of file OptionalValue.hpp.

◆ operator=() [3/3]

template<typename T >
OptionalValue< T > & playrho::OptionalValue< T >::operator= ( v)

Assignment operator.

Definition at line 132 of file OptionalValue.hpp.

◆ value() [1/2]

template<typename T >
const PLAYRHO_CONSTEXPR T & playrho::OptionalValue< T >::value
inline

Accesses the value.

Definition at line 168 of file OptionalValue.hpp.

◆ value() [2/2]

template<typename T >
const PLAYRHO_CONSTEXPR T& playrho::OptionalValue< T >::value ( ) const

Accesses the value.

◆ value_or()

template<typename T >
PLAYRHO_CONSTEXPR T playrho::OptionalValue< T >::value_or ( const T &  alt) const
inline

Gets the value or provides the alternate given value instead.

Definition at line 180 of file OptionalValue.hpp.

◆ reset()

template<typename T >
void playrho::OptionalValue< T >::reset ( )
inlinenoexcept

Resets the optional value back to its default constructed state.

Definition at line 105 of file OptionalValue.hpp.


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