次の方法で共有


error_category クラス

エラー コードのカテゴリを表すオブジェクトの抽象的な共通基底を表します。

構文

class error_category;

constexpr error_category() noexcept;
virtual ~error_category();
error_category(const error_category&) = delete

解説

定義済みの 2 つのオブジェクト generic_category および system_category によって error_category が実装されます。

メンバー

Typedefs

名前 説明
value_type 格納されたエラー コード値を表す型。

関数

名前 説明
default_error_condition エラー条件オブジェクトのエラー コード値を格納します。
equivalent エラー オブジェクトが同等であるかどうかを示す値を返します。
generic_category
message 指定したエラー コードの名前を返します。
name カテゴリの名前を返します。
system_category

演算子

名前 説明
operator= 代入演算子。
operator== error_category オブジェクト間の同等性をテストします。
operator!= error_category オブジェクト間の不等性をテストします。
operator< error_category オブジェクトが比較のために渡される error_category オブジェクトより小さいかどうかをテストします。

default_error_condition

エラー条件オブジェクトのエラー コード値を格納します。

virtual error_condition default_error_condition(int _Errval) const;

パラメーター

_Errval
error_condition オブジェクトに格納するエラー コード値。

戻り値

error_condition(_Errval, *this) を返します。

解説

equivalent

エラー オブジェクトが同等であるかどうかを示す値を返します。

virtual bool equivalent(value_type _Errval,
    const error_condition& _Cond) const;

virtual bool equivalent(const error_code& _Code,
    value_type _Errval) const;

パラメーター

_Errval
比較するエラー コード値。

_Cond
比較する error_condition オブジェクト。

_Code
比較する error_code オブジェクト。

戻り値

カテゴリと値が等しい場合は true、それ以外の場合は false

解説

最初のメンバー関数は *this == _Cond.category() && _Cond.value() == _Errval を返します。

2 番目のメンバー関数は *this == _Code.category() && _Code.value() == _Errval を返します。

generic_category

const error_category& generic_category();

message

指定したエラー コードの名前を返します。

virtual string message(error_code::value_type val) const = 0;

パラメーター

val
記述するエラー コード値。

戻り値

カテゴリのエラー コード val のわかりやすい名前を返します。 エラー コードが認識できない場合、"unknown error" を返します。

解説

name

カテゴリの名前を返します。

virtual const char *name() const = 0;

戻り値

カテゴリの名前を、null 終端バイト文字列として返します。

operator=

error_category& operator=(const error_category&) = delete;

operator==

error_category オブジェクト間の同等性をテストします。

bool operator==(const error_category& right) const;

パラメーター

right
等しいかどうかをテストするオブジェクト。

戻り値

true オブジェクトが等しい場合。 false オブジェクトが等しくない場合は >

解説

このメンバー演算子は、this == &right を返します。

operator!=

error_category オブジェクト間の不等性をテストします。

bool operator!=(const error_category& right) const;

パラメーター

right
不等性をテストするオブジェクト。

戻り値

trueオブジェクトが右にerror_category渡されたオブジェクトと等error_categoryしくない場合は > それ以外の場合falseは >

解説

このメンバー演算子は、 (!*this == right)を返します。

operator<

error_category オブジェクトが比較のために渡される error_category オブジェクトより小さいかどうかをテストします。

bool operator<(const error_category& right) const;

パラメーター

right
比較される error_category オブジェクト。

戻り値

error_category オブジェクトが、比較対象として渡された error_category オブジェクトより小さい場合は true。それ以外の場合は false

解説

このメンバー演算子は、 this < &rightを返します。

system_category

const error_category& system_category();

value_type

格納されたエラー コード値を表す型。

typedef int value_type;

解説

この型定義は int のシノニムです。