GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::experimental::optional::value(3) C++ Standard Libary std::experimental::optional::value(3)

std::experimental::optional::value - std::experimental::optional::value


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();


(none)


A reference to the contained value.


std::experimental::bad_optional_access if *this does not contain a value.


The dereference operator operator*() does not check if this optional contains a
value, which may be more efficient than value().

// Run this code


#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';
}
}


optional<T>::value: not engaged


returns the contained value if available, another value
value_or otherwise
(public member function)
operator-> accesses the contained value
operator* (public member function)
bad_optional_access exception indicating checked access to an optional that
(library fundamentals TS) doesn't contain a value
(class)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.