std::experimental::optional<T>::value (3) - Linux Manuals
std::experimental::optional<T>::value: std::experimental::optional<T>::value
NAME
std::experimental::optional<T>::value - std::experimental::optional<T>::value
Synopsis
constexpr T& value() &; (1) (library fundamentals TS)
constexpr const T & value() const &;
constexpr T&& value() &&; (2) (library fundamentals TS)
constexpr const T&& value() const &&;
Returns the contained value.
1) Equivalent to return bool(*this) ? *val : throw bad_optional_access();
2) Equivalent to return bool(*this) ? std::move(*val) : throw bad_optional_access();
Parameters
(none)
Return value
A reference to the contained value.
Exceptions
std::experimental::bad_optional_access if *this does not contain a value.
Notes
The dereference operator operator*() does not check if this optional contains a value, which may be more efficient than value().
Example
// Run this code
Possible output:
See also
value_or (public member function)
operator-> (public member function)
operator*
bad_optional_access exception indicating checked access to an optional that doesn't contain a value
(library fundamentals TS)