A predicate for checking whether an error code indicates error.

Synopsis

Declared in header <boost/scope/error_code_checker.hpp>

template<typename ErrorCode>
class error_code_checker;

Types

Name

Description

result_type

Predicate result type

Member Functions

Name

Description

error_code_checker

Constructs the predicate.

operator()

Checks if the error code indicates error.

Description

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

  • std::error_code or boost::system::error_code,

  • std::expected, boost::outcome_v2::basic_outcome or boost::outcome_v2::basic_result,

  • int, where the value of 0 indicates no error,

  • bool, where the value of false indicates no error,

  • T*, where a null pointer indicates no error.