181 lines
6.1 KiB
Markdown
181 lines
6.1 KiB
Markdown
[syserr.errcondition]
|
||
|
||
# 19 Diagnostics library [[diagnostics]](./#diagnostics)
|
||
|
||
## 19.5 System error support [[syserr]](syserr#errcondition)
|
||
|
||
### 19.5.5 Class error_condition [syserr.errcondition]
|
||
|
||
#### [19.5.5.1](#overview) Overview [[syserr.errcondition.overview]](syserr.errcondition.overview)
|
||
|
||
[1](#overview-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1238)
|
||
|
||
The class error_condition describes an object used to hold values identifying
|
||
error conditions[.](#overview-1.sentence-1)
|
||
|
||
[*Note [1](#overview-note-1)*:
|
||
|
||
error_condition values are portable abstractions,
|
||
while error_code values ([[syserr.errcode]](syserr.errcode "19.5.4 Class error_code")) are implementation specific[.](#overview-1.sentence-2)
|
||
|
||
â *end note*]
|
||
|
||
[ð](#lib:error_condition)
|
||
|
||
namespace std {class error_condition {public:// [[syserr.errcondition.constructors]](#constructors "19.5.5.2 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 "19.5.5.3 Modifiers"), modifiersvoid assign(int val, const error_category& cat) noexcept; template<class ErrorConditionEnum> error_condition& operator=(ErrorConditionEnum e) noexcept; void clear() noexcept; // [[syserr.errcondition.observers]](#observers "19.5.5.4 Observers"), observersint 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*};}
|
||
|
||
#### [19.5.5.2](#constructors) Constructors [[syserr.errcondition.constructors]](syserr.errcondition.constructors)
|
||
|
||
[ð](#lib:error_condition,constructor)
|
||
|
||
`error_condition() noexcept;
|
||
`
|
||
|
||
[1](#constructors-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1284)
|
||
|
||
*Effects*: Initializes *val_* with 0 and *cat_* with &generic_category()[.](#constructors-1.sentence-1)
|
||
|
||
[ð](#lib:error_condition,constructor_)
|
||
|
||
`error_condition(int val, const error_category& cat) noexcept;
|
||
`
|
||
|
||
[2](#constructors-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1296)
|
||
|
||
*Effects*: Initializes *val_* with val and *cat_* with &cat[.](#constructors-2.sentence-1)
|
||
|
||
[ð](#lib:error_condition,constructor__)
|
||
|
||
`template<class ErrorConditionEnum>
|
||
error_condition(ErrorConditionEnum e) noexcept;
|
||
`
|
||
|
||
[3](#constructors-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1309)
|
||
|
||
*Constraints*: is_error_condition_enum_v<ErrorConditionEnum> is true[.](#constructors-3.sentence-1)
|
||
|
||
[4](#constructors-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1313)
|
||
|
||
*Effects*: Equivalent to:error_condition ec = make_error_condition(e);
|
||
assign(ec.value(), ec.category());
|
||
|
||
#### [19.5.5.3](#modifiers) Modifiers [[syserr.errcondition.modifiers]](syserr.errcondition.modifiers)
|
||
|
||
[ð](#lib:assign,error_condition)
|
||
|
||
`void assign(int val, const error_category& cat) noexcept;
|
||
`
|
||
|
||
[1](#modifiers-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1331)
|
||
|
||
*Postconditions*: *val_* == val and *cat_* == &cat[.](#modifiers-1.sentence-1)
|
||
|
||
[ð](#lib:operator=,error_condition)
|
||
|
||
`template<class ErrorConditionEnum>
|
||
error_condition& operator=(ErrorConditionEnum e) noexcept;
|
||
`
|
||
|
||
[2](#modifiers-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1343)
|
||
|
||
*Constraints*: is_error_condition_enum_v<ErrorConditionEnum> is true[.](#modifiers-2.sentence-1)
|
||
|
||
[3](#modifiers-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1347)
|
||
|
||
*Effects*: Equivalent to:error_condition ec = make_error_condition(e);
|
||
assign(ec.value(), ec.category());
|
||
|
||
[4](#modifiers-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1355)
|
||
|
||
*Returns*: *this[.](#modifiers-4.sentence-1)
|
||
|
||
[ð](#lib:clear,error_condition)
|
||
|
||
`void clear() noexcept;
|
||
`
|
||
|
||
[5](#modifiers-5)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1366)
|
||
|
||
*Postconditions*: value() == 0 and category() == generic_category()[.](#modifiers-5.sentence-1)
|
||
|
||
#### [19.5.5.4](#observers) Observers [[syserr.errcondition.observers]](syserr.errcondition.observers)
|
||
|
||
[ð](#lib:value,error_condition)
|
||
|
||
`int value() const noexcept;
|
||
`
|
||
|
||
[1](#observers-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1379)
|
||
|
||
*Returns*: *val_*[.](#observers-1.sentence-1)
|
||
|
||
[ð](#lib:category,error_condition)
|
||
|
||
`const error_category& category() const noexcept;
|
||
`
|
||
|
||
[2](#observers-2)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1390)
|
||
|
||
*Returns*: **cat_*[.](#observers-2.sentence-1)
|
||
|
||
[ð](#lib:message,error_condition)
|
||
|
||
`string message() const;
|
||
`
|
||
|
||
[3](#observers-3)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1401)
|
||
|
||
*Returns*: category().message(value())[.](#observers-3.sentence-1)
|
||
|
||
[ð](#lib:operator_bool,error_condition)
|
||
|
||
`explicit operator bool() const noexcept;
|
||
`
|
||
|
||
[4](#observers-4)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1412)
|
||
|
||
*Returns*: value() != 0[.](#observers-4.sentence-1)
|
||
|
||
#### [19.5.5.5](#nonmembers) Non-member functions [[syserr.errcondition.nonmembers]](syserr.errcondition.nonmembers)
|
||
|
||
[ð](#lib:make_error_condition,errc)
|
||
|
||
`error_condition make_error_condition(errc e) noexcept;
|
||
`
|
||
|
||
[1](#nonmembers-1)
|
||
|
||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1425)
|
||
|
||
*Returns*: error_condition(static_cast<int>(e), generic_category())[.](#nonmembers-1.sentence-1)
|