次の方法で共有


error_code クラス

実装固有の低レベルなシステム エラーを表します。

構文

class error_code;

解説

error_code クラス型のオブジェクトは、エラー コード値を格納するほか、レポートされた低レベルのシステム エラーを説明するエラー コードのカテゴリを表すオブジェクトを指すポインターも格納します。

メンバー

コンストラクター

名前 説明
error_code error_code 型のオブジェクトを構築します。

Typedefs

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

関数

名前 説明
assign エラー コードにエラー コード値とカテゴリを割り当てます。
category エラー カテゴリを返します。
clear エラー コード値とカテゴリをクリアします。
default_error_condition 既定のエラー条件を返します。
message エラー コードの名前を返します。

演算子

名前 説明
operator== error_code オブジェクト間の同等性をテストします。
operator!= error_code オブジェクト間の不等性をテストします。
operator< error_code オブジェクトが比較のために渡される error_code オブジェクトより小さいかどうかをテストします。
operator= error_code オブジェクトに新しい列挙値を代入します。
operator bool error_code 型の変数をキャストします。

割り当て

エラー コードにエラー コード値とカテゴリを割り当てます。

void assign(value_type val, const error_category& _Cat);

パラメーター

val
error_code に格納するエラー コード値。

_Cat
error_code に格納するエラー カテゴリ。

解説

このメンバー関数は、エラー コード値としての val_Cat を指すポインターを格納します。

category

エラー カテゴリを返します。

const error_category& category() const;

解説

clear

エラー コード値とカテゴリをクリアします。

clear();

解説

このメンバー関数はゼロ エラー コード値と generic_category を指すポインターを格納します。

default_error_condition

既定のエラー条件を返します。

error_condition default_error_condition() const;

戻り値

default_error_condition で指定された error_condition

解説

このメンバー関数は category().default_error_condition(value()) を返します。

error_code

error_code 型のオブジェクトを構築します。

error_code();

error_code(value_type val, const error_category& _Cat);

template <class _Enum>
error_code(_Enum _Errcode,
    typename enable_if<is_error_code_enum<_Enum>::value,
    error_code>::type* = 0);

パラメーター

val
error_code に格納するエラー コード値。

_Cat
error_code に格納するエラー カテゴリ。

_Errcode
error_code に格納する列挙値。

解説

最初のコンストラクターはゼロ エラー コード値と generic_category を指すポインターを格納します。

2 番目のコンストラクターは、エラー コード値としての valerror_category を指すポインターを格納します。

3 番目のコンストラクターは、エラー コード値としての (value_type)_Errcodegeneric_category を指すポインターを格納します。

message

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

string message() const;

戻り値

エラー コードの名前を表す string

解説

このメンバー関数は category().message(value()) を返します。

operator==

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

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

パラメーター

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

戻り値

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

解説

このメンバー演算子は、 category() == right.category() && value == right.value()を返します。

operator!=

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

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

パラメーター

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

戻り値

error_code オブジェクトが、right に渡される error_code オブジェクトに等しくない場合は true。それ以外の場合は false

解説

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

operator<

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

bool operator<(const error_code& right) const;

パラメーター

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

戻り値

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

解説

このメンバー演算子は、 category() < right.category() || category() == right.category() && value < right.value()を返します。

operator=

error_code オブジェクトに新しい列挙値を代入します。

template <class _Enum>
typename enable_if<is_error_code_enum<_Enum>::value, error_code>::type&
    operator=(_Enum _Errcode);

パラメーター

_Errcode
error_code オブジェクトに代入する列挙値。

戻り値

メンバー関数によって新しい列挙値が代入される error_code オブジェクトへの参照。

解説

このメンバー演算子は、エラー コード値としての (value_type)_Errcodegeneric_category を指すポインターを格納します。 *this を返します。

operator bool

error_code 型の変数をキャストします。

explicit operator bool() const;

戻り値

error_code オブジェクトのブール値。

解説

この演算子は、が 0 と等しくない場合に限り、true に変換できる値が返されます。 戻り値の型は、void * またはその他の既知のスカラー型ではなく、bool 型にのみ変換可能です。

value

格納されたエラー コード値を返します。

value_type value() const;

戻り値

value_type 型の格納されたエラー コード値。

value_type

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

typedef int value_type;

解説

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