名前空間
変種
操作

std::make_exception_ptr

From cppreference.com
< cpp‎ | error
 
 
 
ヘッダー <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 - コピー元の例外オブジェクト

[編集] 戻り値

e のコピーへの参照を保持する std::exception_ptr のインスタンス。または、std::bad_alloc のインスタンス、あるいは std::bad_exception のインスタンス(std::current_exception を参照)。

[編集] 注記

パラメータは値渡しされ、スライシングの対象となります。

機能テストマクロ 規格 機能
__cpp_lib_constexpr_exceptions 202411L (C++26) constexpr for exception types

[編集]

[編集] 関連項目

現在の例外を std::exception_ptr にキャプチャする
(関数) [編集]
English 日本語 中文(简体) 中文(繁體)