std:: make_exception_ptr
From cppreference.net
|
定义于头文件
<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(...) { return std::current_exception(); }
目录 |
参数
| e | - | 用于创建副本引用的异常对象 |
返回值
一个持有 e 副本引用的 std::exception_ptr 实例,或持有 std::bad_alloc 实例,或持有 std::bad_exception 实例(参见 std::current_exception )。
注释
参数通过值传递,且会发生切片现象。
| 功能测试 宏 | 值 | 标准 | 功能 |
|---|---|---|---|
__cpp_lib_constexpr_exceptions
|
202411L
|
(C++26) | constexpr for exception types |
示例
|
本节内容不完整
原因:缺少示例 |
参见
|
(C++11)
|
捕获当前异常到
std::exception_ptr
中
(函数) |