namespace std {
const error_category& iostream_category(); // C++11
const error_category& iostream_category() noexcept; // C++14
}
概要
io_errc
のためのエラーカテゴリを取得する。
戻り値
error_category
クラスを継承したクラスオブジェクトへの参照を返す。
この関数を呼び出すことによって返されるオブジェクトは、同じオブジェクトを指す。
この関数によって返されるオブジェクトのクラスは以下の特徴を持つ:
name()
関数によって返される文字列は"iostream"
default_error_condition()
仮想関数およびequivalent()
仮想関数の挙動は、基底クラスであるerror_category
と同じである
例外
投げない
例
#include <iostream> // 自動的に<ios>もインクルードされる
#include <string>
int main()
{
const std::error_category& cat = std::iostream_category();
std::cout << cat.name() << std::endl;
std::cout << cat.message(static_cast<int>(std::io_errc::stream)) << std::endl;
}
11
#include <iostream> // 自動的に<ios>もインクルードされる
#include <string>
int main()
{
const std::error_category& cat = std::iostream_category();
std::cout << cat.name() << std::endl;
std::cout << cat.message(static_cast<int>(std::io_errc::stream)) << std::endl;
}
出力例
iostream
iostream stream error
バージョン
言語
- C++11
処理系
- Clang: ??
- GCC: ??
- ICC: ??
- Visual C++: 2010 ✅, 2012 ✅