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... | |
OptionalValue & | operator= (const OptionalValue &other)=default |
Assignment operator. More... | |
OptionalValue & | operator= (OptionalValue &&other) noexcept |
Move assignment operator. More... | |
OptionalValue & | operator= (T v) |
Assignment operator. More... | |
PLAYRHO_CONSTEXPR T & | value () |
Accesses the value. More... | |
const PLAYRHO_CONSTEXPR T & | value () const |
Accesses the value. More... | |
PLAYRHO_CONSTEXPR T | value_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
using playrho::OptionalValue< T >::value_type = T |
Value type.
Definition at line 40 of file OptionalValue.hpp.
Constructor & Destructor Documentation
◆ OptionalValue() [1/4]
|
inlinedefault |
◆ OptionalValue() [2/4]
|
inlinedefault |
Copy constructor.
◆ OptionalValue() [3/4]
|
inlinenoexcept |
Move constructor.
Definition at line 48 of file OptionalValue.hpp.
◆ OptionalValue() [4/4]
|
inlineexplicit |
Initializing constructor.
Definition at line 117 of file OptionalValue.hpp.
◆ ~OptionalValue()
|
default |
Member Function Documentation
◆ operator*() [1/2]
|
inline |
Indirection operator.
Definition at line 154 of file OptionalValue.hpp.
◆ operator*() [2/2]
|
inline |
Indirection operator.
◆ operator->() [1/2]
|
inline |
Member of pointer operator.
Definition at line 140 of file OptionalValue.hpp.
◆ operator->() [2/2]
|
inline |
Member of pointer operator.
◆ operator bool()
|
inlineexplicitnoexcept |
Boolean operator.
Definition at line 126 of file OptionalValue.hpp.
◆ has_value()
|
inlinenoexcept |
Whether this optional value has a value.
Definition at line 120 of file OptionalValue.hpp.
◆ operator=() [1/3]
|
default |
Assignment operator.
◆ operator=() [2/3]
|
inlinenoexcept |
Move assignment operator.
Definition at line 83 of file OptionalValue.hpp.
◆ operator=() [3/3]
OptionalValue< T > & playrho::OptionalValue< T >::operator= | ( | T | v | ) |
Assignment operator.
Definition at line 132 of file OptionalValue.hpp.
◆ value() [1/2]
|
inline |
Accesses the value.
Definition at line 168 of file OptionalValue.hpp.
◆ value() [2/2]
const PLAYRHO_CONSTEXPR T& playrho::OptionalValue< T >::value | ( | ) | const |
Accesses the value.
◆ value_or()
|
inline |
Gets the value or provides the alternate given value instead.
Definition at line 180 of file OptionalValue.hpp.
◆ 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:
- Common/OptionalValue.hpp