std::unexpected

From cppreference.com
< cpp‎ | error
 
 
Utilities library
Type support (basic types, RTTI, type traits)
Dynamic memory management
Error handling
Program utilities
Variadic functions
Date and time
Function objects
(C++11)
Relational operators
Optional and any
(C++17)
(C++17)
Pairs and tuples
(C++11)
(C++17)
Swap, forward and move
(C++14)
(C++11)
(C++11)
Type operations
(C++11)
(C++17)
 
Error handling
Exception handling
(C++11)
(C++17)
Exception handling failures
(C++11)
unexpected
(deprecated)
(deprecated)
(C++11)(deprecated)
(deprecated)
 
Defined in header <exception>
void unexpected();
(until C++11)
[[noreturn]] void unexpected();
(since C++11)
(deprecated)

std::unexpected() is called by the C++ runtime when a dynamic exception specification is violated: an exception is thrown from a function whose exception specification forbids exceptions of this type.

std::unexpected() may also be called directly from the program.

In either case, std::unexpected calls the currently installed std::unexpected_handler. The default std::unexpected_handler calls std::terminate.

If a destructor reset the unexpected handler during stack unwinding and the unwinding later led to unexpected being called, the handler that was installed at the end of the throw expression is the one that will be called. (note: it was ambiguous whether re-throwing applied the new handlers)

(until C++11)

If a destructor reset the unexpected handler during stack unwinding, it is unspecified which handler is called if the unwinding later led to unexpected being called.

(since C++17)


Contents

[edit] Parameters

(none)

[edit] Return value

(none)

[edit] Exceptions

Throw any exception thrown by the currently installed std::unexpected_handler

[edit] See also

(deprecated since C++11)
the type of the function called by std::unexpected
(typedef)