std::make_exception_ptr
來自 cppreference.com
定義於標頭檔案 <exception> |
||
template< class E > std::exception_ptr make_exception_ptr( E e ) noexcept; |
(C++11 起) (C++26 起為 constexpr) |
|
建立一個 std::exception_ptr,它持有 e 的副本的引用。這就像執行以下程式碼一樣完成:
try { throw e; } catch(...) { return std::current_exception(); }
目錄 |
[編輯] 引數
e | - | 要建立其副本引用的異常物件 |
[編輯] 返回值
一個 std::exception_ptr 例項,它持有 e 的副本的引用,或一個 std::bad_alloc 例項的引用,或一個 std::bad_exception 例項的引用(參閱 std::current_exception)。
[編輯] 注意
引數按值傳遞,並且會發生切片。
特性測試宏 | 值 | 標準 | 特性 |
---|---|---|---|
__cpp_lib_constexpr_exceptions |
202411L |
(C++26) | 異常型別的 constexpr |
[編輯] 示例
本節不完整 原因:無示例 |
[編輯] 另請參閱
(C++11) |
將當前異常捕獲到 std::exception_ptr 中 (函式) |