std::make_exception_ptr

来自cppreference.com
< cpp‎ | error
在标头 <exception> 定义
template<class E >
std::exception_ptr make_exception_ptr( E e )noexcept;
(C++11 起)
(C++26 起为 constexpr)

创建一个保有到 e 副本的引用的 std::exception_ptr。这如同执行下列代码:

try{throw e;}catch(...){returnstd::current_exception();}

目录

[编辑]参数

e - 要创建对其副本的引用的异常对象

[编辑]返回值

std::exception_ptr 实例,它保有到 e 副本,或到 std::bad_alloc 实例,或到 std::bad_exception 实例的引用(参阅 std::current_exception)。

[编辑]注解

参数按值传递,并受切片影响。

功能特性测试标准功能特性
__cpp_lib_constexpr_exceptions202411L(C++26)constexpr 的异常类型

[编辑]示例

[编辑]参阅

捕获当前异常到 std::exception_ptr 之中
(函数)[编辑]
close