Template Class optional
Defined in File optional.hpp
Class Documentation
-
template<class T>
class optional This class template manages an optional contained value, i.e. a value that may or may not be present.
Public Functions
-
optional() = default
Default constructor.
-
~optional() = default
Destructor.
-
template<class ...Args>
inline void emplace(Args&&... _args) Constructs the contained value in-place.
- Parameters:
_args – [in] The arguments to pass to the constructor.
-
inline void reset(bool initial_engaged = false)
Reset the state of the optional.
- Parameters:
initial_engaged – [in] True value initializes the state with a default instance of the templated class. False value leaves the optional in a uninitialized state.
-
inline T &value() &
Returns the contained value.
- Throws:
exception::BadOptionalAccessException – This exception is thrown when the optional is uninitialized.
- Returns:
The contained value.
-
inline const T &value() const &
Returns the contained value.
- Throws:
exception::BadOptionalAccessException – This exception is thrown when the optional is uninitialized.
- Returns:
The contained value.
-
inline T &&value() &&
Returns the contained value.
- Throws:
exception::BadOptionalAccessException – This exception is thrown when the optional is uninitialized.
- Returns:
The contained value.
-
inline const T &&value() const &&
Returns the contained value.
- Throws:
exception::BadOptionalAccessException – This exception is thrown when the optional is uninitialized.
- Returns:
The contained value.
-
inline bool has_value() const
Checks whether the optional contains a value.
- Returns:
Whether the optional contains a value.
-
inline T &operator*() & noexcept
Accesses the contained value.
The behavior is undefined if *this does not contain a value.
- Returns:
The contained value.
-
inline const T &operator*() const & noexcept
Accesses the contained value.
The behavior is undefined if *this does not contain a value.
- Returns:
The contained value.
-
inline T &&operator*() && noexcept
Accesses the contained value.
The behavior is undefined if *this does not contain a value.
- Returns:
The contained value.
-
inline const T &&operator*() const && noexcept
Accesses the contained value.
The behavior is undefined if *this does not contain a value.
- Returns:
The contained value.
-
inline T *operator->() noexcept
Accesses the contained value.
The behavior is undefined if *this does not contain a value.
- Returns:
The contained value.
-
inline const T *operator->() const noexcept
Accesses the contained value.
The behavior is undefined if *this does not contain a value.
- Returns:
The contained value.
-
inline explicit operator bool() const noexcept
Checks whether the optional contains a value.
-
optional() = default