名前空間
変種
操作

std::exception_ptr

提供: cppreference.com
< cpp‎ | error

 
 
ユーティリティライブラリ
支援を入力します (basic types, RTTI, type traits)
動的なメモリ管理
エラー処理
プログラムユーティリティ
可変個引数関数
日付と時刻
関数オブジェクト
initializer_list(C++11)
bitset
hash(C++11)
関係演算子
Original:
Relational operators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rel_ops::operator!=
rel_ops::operator>
rel_ops::operator<=
rel_ops::operator>=
ペアとタプル
Original:
Pairs and tuples
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
pair
tuple(C++11)
piecewise_construct_t(C++11)
piecewise_construct(C++11)
フォワード、スワップ、および移動
Original:
Swap, forward and move
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
swap
forward(C++11)
move(C++11)
move_if_noexcept(C++11)
declval(C++11)
 
エラー処理
例外処理
Original:
Exception handling
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
exception
uncaught_exception
exception_ptr(C++11)
make_exception_ptr(C++11)
current_exception(C++11)
rethrow_exception(C++11)
nested_exception(C++11)
throw_with_nested(C++11)
rethrow_if_nested(C++11)
例外処理の失敗
Original:
Exception handling failures
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
terminate
terminate_handler
get_terminate(C++11)
set_terminate
unexpected(廃止予定)
bad_exception
unexpected_handler(廃止予定)
get_unexpected(C++11)(廃止予定)
set_unexpected(廃止予定)
例外カテゴリ
Original:
Exception categories
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
logic_error
invalid_argument
domain_error
length_error
out_of_range
runtime_error
range_error
overflow_error
underflow_error
エラーコード
Original:
Error codes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
エラーコード
errno
アサーション
Original:
Assertions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
assert
SYSTEM_ERROR施設
Original:
system_error facility
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
error_category(C++11)
generic_category(C++11)
system_category(C++11)
error_condition(C++11)
errc(C++11)
error_code(C++11)
system_error(C++11)
 
Defined in header <exception>
typedef /*unspecified*/ exception_ptr;
(C++11およびそれ以降)
std::exception_ptrスローとstd::current_exceptionで捕捉された例外オブジェクトを管理Null許容ポインタのようなタイプです。例外が再スローとcatch節で処理されるかもしれないところstd::exception_ptrのインスタンスは、おそらく別のスレッドで、別の関数に渡すことができます.
Original:
std::exception_ptr is a nullable pointer-like type that manages an exception object which has been thrown and captured with std::current_exception. An instance of std::exception_ptr may be passed to another function, possibly on another thread, where the exception may be rethrown and handled with a catch clause.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
std::exception_ptrnullポインタであるデフォルト·構築、それは例外オブジェクトを指していない.
Original:
Default-constructed std::exception_ptr is a null pointer, it does not point to an exception object.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
std::exception_ptrの2つのインスタンスは、それらが同じ例外オブジェクトでnullまたは両方のポイントの両方である場合にのみ等しいと比較.
Original:
Two instances of std::exception_ptr compare equal only if they are both null or both point at the same exception object.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
std::exception_ptr任意の算術、列挙体、またはポインタ型に暗黙的に変換できません。それはboolへ転換です.
Original:
std::exception_ptr is not implicitly convertible to any arithmetic, enumeration, or pointer type. It is convertible to bool.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
std::exception_ptrによって参照される例外オブジェクトは、それを参照している少なくとも1std::exception_ptrが残っている限り有効なままです。std::exception_ptrは、共有所有のスマートポインタです.
Original:
The exception object referenced by an std::exception_ptr remains valid as long as there remains at least one std::exception_ptr that is referencing it: std::exception_ptr is a shared-ownership smart pointer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集]

[edit]
#include <iostream>
#include <string>
#include <exception>
#include <stdexcept>
 
void handle_eptr(std::exception_ptr eptr) // passing by value is ok
{
    try {
        if (eptr != std::exception_ptr()) {
            std::rethrow_exception(eptr);
        }
    } catch(const std::exception& e) {
        std::cout << "Caught exception \"" << e.what() << "\"\n";
    }
}
 
int main()
{
    std::exception_ptr eptr;
    try {
        std::string().at(1); // this generates an std::out_of_range
    } catch(...) {
        eptr = std::current_exception(); // capture
    }
    handle_eptr(eptr);
} // destructor for std::out_of_range called here, when the eptr is destructed

Output:

Caught exception "basic_string::at"

[編集] も参照してください

例外オブジェクトからstd::exception_ptrを作成します
Original:
creates an std::exception_ptr from an exception object
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数テンプレート) [edit]
captures the current exception in a std::exception_ptr
(関数) [edit]
std::exception_ptrから例外がスローされます
Original:
throws the exception from an std::exception_ptr
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(関数) [edit]