## Class template error_code_checker

boost::scope::error_code_checker — A predicate for checking whether an error code indicates error.

## Synopsis

    // In header: <boost/scope/error_code_checker.hpp>

    template<typename ErrorCode>
    class error_code_checker {
    public:
      // types
      typedef bool result_type;  // Predicate result type.

      // public member functions
      explicit error_code_checker(ErrorCode &) noexcept;
      result_type operator()() const noexcept;
    };

## 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.

### Template Parameters

1.     typename ErrorCode

   Error code type.

### `error_code_checker` public member functions

1.     explicit error_code_checker(ErrorCode & ec) noexcept;

   Constructs the predicate.

   Upon construction, the predicate saves a reference to the external error code object. The referenced object must remain valid for the whole lifetime duration of the predicate.

   Throws: Nothing.

2.     result_type operator()() const noexcept;

   Checks if the error code indicates error.

   Throws: Nothing.

   Returns: | As if `!!ec`, where `ec` is the error code object passed to the predicate constructor.