This class template manages an optional contained value, i.e. More...
#include <optional.hpp>
Public Types | |
using | type = T |
Public Member Functions | |
optional ()=default | |
Default constructor. | |
optional (const T &val) noexcept | |
Copy constructor from an instance of the templated class. | |
optional (T &&val) noexcept | |
Move constructor from an instance of the templated class. | |
optional (const optional< T > &val) noexcept | |
Copy constructor. | |
optional (optional< T > &&val) noexcept | |
Move constructor. | |
~optional ()=default | |
Destructor. | |
template<class ... Args> | |
void | emplace (Args &&... _args) |
Constructs the contained value in-place. | |
void | reset (bool initial_engaged=false) |
Reset the state of the optional. | |
T & | value () & |
Returns the contained value. | |
const T & | value () const & |
Returns the contained value. | |
T && | value () && |
Returns the contained value. | |
const T && | value () const && |
Returns the contained value. | |
bool | has_value () const |
Checks whether the optional contains a value. | |
optional & | operator= (const optional &opt) |
Assigns content from an optional. | |
optional & | operator= (optional &&opt) |
Assigns content from an optional. | |
optional & | operator= (const T &val) |
Assigns content from an instance of the templated class. | |
optional & | operator= (T &&val) |
Assigns content from an instance of the templated class. | |
optional & | operator= (nullopt_t) noexcept |
Uninitialized the optional. | |
bool | operator== (const optional &opt_val) const |
Compares optional values. | |
bool | operator!= (const optional &opt_val) const |
Compares optional values. | |
T & | operator* () &noexcept |
Accesses the contained value. | |
const T & | operator* () const &noexcept |
Accesses the contained value. | |
T && | operator* () &&noexcept |
Accesses the contained value. | |
const T && | operator* () const &&noexcept |
Accesses the contained value. | |
T * | operator-> () noexcept |
Accesses the contained value. | |
const T * | operator-> () const noexcept |
Accesses the contained value. | |
operator bool () const noexcept | |
Checks whether the optional contains a value. | |
This class template manages an optional contained value, i.e.
a value that may or may not be present.
using type = T |
|
default |
Default constructor.
|
inlinenoexcept |
Copy constructor from an instance of the templated class.
|
inlinenoexcept |
Move constructor from an instance of the templated class.
|
default |
Destructor.
|
inline |
Constructs the contained value in-place.
[in] | _args | The arguments to pass to the constructor. |
|
inline |
Checks whether the optional contains a value.
|
inlineexplicitnoexcept |
Checks whether the optional contains a value.
|
inline |
Compares optional values.
|
inlinenoexcept |
Accesses the contained value.
The behavior is undefined if *this does not contain a value.
|
inlinenoexcept |
Accesses the contained value.
The behavior is undefined if *this does not contain a value.
|
inlinenoexcept |
Accesses the contained value.
The behavior is undefined if *this does not contain a value.
|
inlinenoexcept |
Accesses the contained value.
The behavior is undefined if *this does not contain a value.
|
inlinenoexcept |
Accesses the contained value.
The behavior is undefined if *this does not contain a value.
|
inlinenoexcept |
Accesses the contained value.
The behavior is undefined if *this does not contain a value.
Assigns content from an optional.
|
inline |
Assigns content from an instance of the templated class.
Assigns content from an optional.
|
inline |
Assigns content from an instance of the templated class.
|
inline |
Compares optional values.
|
inline |
Reset the state of the optional.
[in] | initial_engaged | True value initializes the state with a default instance of the templated class. False value leaves the optional in a uninitialized state. |
|
inline |
Returns the contained value.
exception::BadOptionalAccessException | This exception is thrown when the optional is uninitialized. |
|
inline |
Returns the contained value.
exception::BadOptionalAccessException | This exception is thrown when the optional is uninitialized. |
|
inline |
Returns the contained value.
exception::BadOptionalAccessException | This exception is thrown when the optional is uninitialized. |
|
inline |
Returns the contained value.
exception::BadOptionalAccessException | This exception is thrown when the optional is uninitialized. |