std::experimental::optional<T>::value
Min standard notice:
Returns the contained value.
# Declarations
constexpr T& value() &;
constexpr const T & value() const &;
(library fundamentals TS)
constexpr T&& value() &&;
constexpr const T&& value() const &&;
(library fundamentals TS)
# Return value
A reference to the contained value.
# Notes
The dereference operator operator*() does not check if this optional contains a value, which may be more efficient than value().
# Example
#include <experimental/optional>
#include <iostream>
int main()
{
std::experimental::optional<int> opt = {};
try
{
int n = opt.value();
}
catch (const std::logic_error& e)
{
std::cout << e.what() << '\n';
}
}