19 Diagnostics library [diagnostics]

19.5 System error support [syserr]

19.5.3 Class error_condition [syserr.errcondition]

19.5.3.1 Class error_condition overview [syserr.errcondition.overview]

The class error_condition describes an object used to hold values identifying error conditions. [ Note: error_condition values are portable abstractions, while error_code values ([syserr.errcode]) are implementation specific.  — end note ]

namespace std {
  class error_condition {
  public:
    // [syserr.errcondition.constructors] constructors:
    error_condition() noexcept;
    error_condition(int val, const error_category& cat) noexcept;
    template <class ErrorConditionEnum>
      error_condition(ErrorConditionEnum e) noexcept;

    // [syserr.errcondition.modifiers] modifiers:
    void assign(int val, const error_category& cat) noexcept;
    template<class ErrorConditionEnum>
        error_condition& operator=(ErrorConditionEnum e) noexcept;
    void clear() noexcept;

    // [syserr.errcondition.observers] observers:
    int value() const noexcept;
    const error_category& category() const noexcept;
    string message() const;
    explicit operator bool() const noexcept;

  private:
    int val_;                   // exposition only
    const error_category* cat_; // exposition only
  };

  // [syserr.errcondition.nonmembers] non-member functions:
  bool operator<(const error_condition& lhs, const error_condition& rhs) noexcept;
} // namespace std

19.5.3.2 Class error_condition constructors [syserr.errcondition.constructors]

error_condition() noexcept;

Effects: Constructs an object of type error_condition.

Postconditions: val_ == 0 and cat_ == &generic_category().

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

Effects: Constructs an object of type error_condition.

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

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

Effects: Constructs an object of type error_condition.

Postcondition: *this == make_error_condition(e).

Remarks: This constructor shall not participate in overload resolution unless is_error_condition_enum<ErrorConditionEnum>::value is true.

19.5.3.3 Class error_condition 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;

Postcondition: *this == make_error_condition(e).

Returns: *this.

Remarks: This operator shall not participate in overload resolution unless is_error_condition_enum<ErrorConditionEnum>::value is true.

void clear() noexcept;

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

19.5.3.4 Class error_condition observers [syserr.errcondition.observers]

int value() const noexcept;

Returns: val_.

const error_category& category() const noexcept;

Returns: *cat_.

string message() const;

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

explicit operator bool() const noexcept;

Returns: value() != 0.

19.5.3.5 Class error_condition non-member functions [syserr.errcondition.nonmembers]

error_condition make_error_condition(errc e) noexcept;

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

bool operator<(const error_condition& lhs, const error_condition& rhs) noexcept;

Returns: lhs.category() < rhs.category() || lhs.category() == rhs.category() &&
lhs.value() < rhs.value()
.