Namespaces
Variants
Actions

std::unexpected

From cppreference.com
< cpp‎ | utility‎ | expected
 
 
Utilities library
General utilities
Relational operators (deprecated in C++20)
 
 
Defined in header <expected>
template< class E >
class unexpected;
(since C++23)

The class template std::unexpected represents an unexpected value stored in std::expected. In particular, std::expected has constructors with std::unexpected as a single argument, which creates an expected object that contains an unexpected value.

A program is ill-formed if it instantiates an unexpected with a non-object type, an array type, a specialization of std::unexpected, or a cv-qualified type.

Contents

[edit] Template parameters

E - the type of the unexpected value. The type must not be an array type, a non-object type, a specialization of std::unexpected, or a cv-qualified type.

[edit] Member functions

constructs the unexpected object
(public member function)
(destructor)
(implicitly declared)
destroys the unexpected object, along with the stored value
(public member function)
operator=
(implicitly declared)
assigns the stored value
(public member function)
accesses the stored value
(public member function)
swaps the stored value
(public member function)

[edit] Non-member functions

compares the stored value
(function template)
specializes the