:relfileprefix: ../../
[#C5A605739122EDE5A1903963331AAFE725729503]

= Class error_code_checker

pass:v,q[A predicate for checking whether an error code indicates error.]


== Synopsis

Declared in header `<https://github.com/Lastique/scope/blob/develop/include/boost/scope/error_code_checker.hpp#L51[boost/scope/error_code_checker.hpp,window=blank_]>`

[source,cpp,subs="verbatim,macros,-callouts"]
----
template<typename ErrorCode>
class error_code_checker;
----

==  Types
[,cols=2]
|===
|Name |Description
|xref:boost/scope/error_code_checker/result_type.adoc[`pass:v[result_type]`] |
pass:v,q[Predicate result type]

|===
==  Member Functions
[,cols=2]
|===
|Name |Description
|xref:boost/scope/error_code_checker/2constructor.adoc[`pass:v[error_code_checker]`] |
pass:v,q[Constructs the predicate.]

|xref:boost/scope/error_code_checker/operator_call.adoc[`pass:v[operator()]`] |
pass:v,q[Checks if the error code indicates error.]

|===

== Description

pass:v,q[The predicate captures a reference to an external error code object, which it]
pass:v,q[tests for an error indication when called. The error code object must remain]
pass:v,q[valid for the whole lifetime duration of the predicate.]
pass:v,q[For an error code object `ec`, an expression `!ec` must be valid, never throw exceptions,]
pass:v,q[and return a value contextually convertible to `bool`. If the returned value converts]
pass:v,q[to `false`, then this is taken as an error indication, and the predicate returns `true`.]
pass:v,q[Otherwise, the predicate returns `false`.]
pass:v,q[A few examples of error code types:]

* pass:v,q[`std::error_code` or `boost::system::error_code`,]

* pass:v,q[`std::expected`, `boost::outcome_v2::basic_outcome` or `boost::outcome_v2::basic_result`,]

* pass:v,q[`int`, where the value of 0 indicates no error,]

* pass:v,q[`bool`, where the value of `false` indicates no error,]

* pass:v,q[`T*`, where a null pointer indicates no error.]



