| Technical Specification | ||||
| Filesystem library(filesystem TS) | ||||
| Library fundamentals(library fundamentals TS) | ||||
| Library fundamentals 2(library fundamentals TS v2) | ||||
| Library fundamentals 3(library fundamentals TS v3) | ||||
| Extensions for parallelism(parallelism TS) | ||||
| Extensions for parallelism 2(parallelism TS v2) | ||||
| Extensions for concurrency(concurrency TS) | ||||
| Extensions for concurrency 2(concurrency TS v2) | ||||
| Concepts(concepts TS) | ||||
| Ranges(ranges TS) | ||||
| Reflection(reflection TS) | ||||
| Mathematical special functions(special functions TR) | ||||
| Experimental Non-TS | ||||
| Pattern Matching | ||||
| Linear Algebra | ||||
| std::execution | ||||
| Contracts | ||||
| 2D Graphics |
| Member functions | ||||
| Observers | ||||
optional::value | ||||
| Modifiers | ||||
| Non-member functions | ||||
| Helper classes | ||||
| Helper objects | ||||
constexpr T& value()&; constexprconst T& value()const&; | (1) | (library fundamentals TS) |
constexpr T&& value()&&; constexprconst T&& value()const&&; | (2) | (library fundamentals TS) |
Returns the contained value.
Contents |
(none)
A reference to the contained value.
std::experimental::bad_optional_access if*this does not contain a value.
The dereference operatoroperator*() does not check if this optional contains a value, which may be more efficient thanvalue().
#include <experimental/optional>#include <iostream> int main(){std::experimental::optional<int> opt={}; try{int n= opt.value();}catch(conststd::logic_error& e){std::cout<< e.what()<<'\n';}}
Possible output:
optional<T>::value: not engaged
| returns the contained value if available, another value otherwise (public member function)[edit] | |
| accesses the contained value (public member function)[edit] | |
(library fundamentals TS) | exception indicating checked access to an optional that doesn't contain a value (class)[edit] |