[syserr.errcondition] (original) (raw)

19 Diagnostics library [diagnostics]

19.5 System error support [syserr]

19.5.5 Class error_condition [syserr.errcondition]

19.5.5.1 Overview [syserr.errcondition.overview]

The class error_condition describes an object used to hold values identifying error conditions.

[Note 1:

error_condition values are portable abstractions, while error_code values ([syserr.errcode]) are implementation specific.

— _end note_]

namespace std { class error_condition { public: error_condition() noexcept; error_condition(int val, const error_category& cat) noexcept;template<class ErrorConditionEnum> error_condition(ErrorConditionEnum e) noexcept;void assign(int val, const error_category& cat) noexcept;template<class ErrorConditionEnum> error_condition& operator=(ErrorConditionEnum e) noexcept;void clear() noexcept;int value() const noexcept;const error_category& category() const noexcept; string message() const;explicit operator bool() const noexcept;private: int val_; const error_category* cat_; };}

19.5.5.2 Constructors [syserr.errcondition.constructors]

error_condition() noexcept;

Effects: Initializes val_ with 0and cat_ with &generic_category().

error_condition(int val, const error_category& cat) noexcept;

Effects: Initializes val_ with valand cat_ with &cat.

template<class ErrorConditionEnum> error_condition(ErrorConditionEnum e) noexcept;

Constraints: is_error_condition_enum_v<ErrorConditionEnum> is true.

Effects: Equivalent to:error_condition ec = make_error_condition(e); assign(ec.value(), ec.category());

19.5.5.3 Modifiers [syserr.errcondition.modifiers]

void assign(int val, const error_category& cat) noexcept;

Postconditions: val_ == val and cat_ == &cat.

template<class ErrorConditionEnum> error_condition& operator=(ErrorConditionEnum e) noexcept;

Constraints: is_error_condition_enum_v<ErrorConditionEnum> is true.

Effects: Equivalent to:error_condition ec = make_error_condition(e); assign(ec.value(), ec.category());

Postconditions: value() == 0 and category() == generic_category().

19.5.5.4 Observers [syserr.errcondition.observers]

int value() const noexcept;

const error_category& category() const noexcept;

Returns: category().message(value()).

explicit operator bool() const noexcept;

19.5.5.5 Non-member functions [syserr.errcondition.nonmembers]

error_condition make_error_condition(errc e) noexcept;

Returns: error_condition(static_cast<int>(e), generic_category()).