[ Web Proxy ]
URL:
Viewing: https://en.cppreference.com/cpp/error/exception_ptr_cast [Back]  [Original]

std::exception_ptr_cast - cppreference.com
cppreference.com
Namespaces
Variants

std::exception_ptr_cast

From cppreference.com
 
 
 
Defined in header <exception>
template< class E >
constexpr std::optional<const E&>
    exception_ptr_cast( const std::exception_ptr& ptr ) noexcept;
(since C++26)

Attempts to match the exception object referred to by ptr with const E&, and returns a reference to the matched exception object.

Parameters

ptr - the target std::exception_ptr object

Return value

If ptr is not null and a handler of type const E& is a match for the exception object referred to by ptr, returns an std::optional<const E&> object containing a reference to the exception object. Otherwise returns std::nullopt.

Notes

Feature-test macro Value Std Feature
__cpp_lib_exception_ptr_cast 202603L (C++26) std::exception_ptr_cast

Example

See also

creates an std::exception_ptr from an exception object
(function template) [edit]
captures the current exception in an std::exception_ptr
(function) [edit]

Web Proxy Viewer  |  New URL  |  Original Page