std::make_error_condition(std::io_errc)
From cppreference.com
| ヘッダ <ios>で定義 |
||
| std::error_condition make_error_condition( std::io_errc e ) noexcept; |
(C++11以降) | |
std::error_condition オブジェクトを std::io_errc 型の値から、return std::error_condition(static_cast<int>(e), std::iostream_category()) のように構築します。
目次 |
[編集] パラメータ
| e | - | エラーコード番号 |
[編集] 戻り値
std::error_condition 型の値。これは、エラーカテゴリ "iostream" に関連付けられた e からのエラーコード番号を保持します。
[編集] 例
このコードを実行
#include <iostream> #include <system_error> int main() { std::error_condition ec = std::make_error_condition(std::io_errc::stream); std::cout << "error condition for io_errc::stream has value " << ec.value() << "\nand message \"" << ec.message() << "\"\n"; }
出力
error condition for io_errc::stream has value 1 and message "unspecified iostream_category error"
[編集] 不具合報告
以下の動作変更を伴う欠陥報告が、以前に公開されたC++標準に遡って適用されました。
| DR | 適用対象 | 公開された動作 | 正しい動作 |
|---|---|---|---|
| LWG 2087 | C++11 | make_error_condition(io_errc) は noexcept として宣言されていませんでした。 |
noexcept として宣言された |
[編集] 関連項目
| (C++11) |
ポータブルなエラーコードを保持する (クラス) |
| (C++11) |
IOストリームのエラーコード (enum) |