virtual const char* name() const noexcept = 0;
概要
カテゴリの名前を取得する
戻り値
エラーの分類を示す文字列を返す
- C++11 : 文字列のエンコーディングは未規定(実際には、各実装とも文字列リテラルで定義しており、通常の文字列リテラルのエンコーディングだった)
- C++29 : 文字列は、通常の文字列リテラルのエンコーディングであると規定された
例外
投げない
例
#include <iostream>
#include <system_error>
int main()
{
const std::error_category& generic_cat = std::generic_category();
std::cout << generic_cat.name() << std::endl;
const std::error_category& system_cat = std::system_category();
std::cout << system_cat.name() << std::endl;
}
出力
generic
system
バージョン
言語
- C++11
処理系
- Clang: ??
- GCC: 4.6.1 ✅
- Visual C++: 2010 ✅
参照
- P3395R6 Fix encoding issues and add a
formatterforstd::error_code- C++29で、返される文字列のエンコーディングが規定された
- LWG Issue 4156.
error_categorymessages have unspecified encoding- エンコーディングが未規定であることを指摘したissue。P3395R6で解決された