| Home | Libraries | People | FAQ | More

## Struct template call_if_statement<true, Then, internal_type>

boost::contract::call_if_statement<true, Then, internal_type> — Template specialization to dispatch between then-branch functor template calls that return void and the ones that return non-void (not needed on C++17 compilers, use `if constexpr` instead).

## Synopsis

    // In header: <boost/contract/call_if.hpp>

    template<typename Then>
    struct call_if_statement<true, Then, internal_type> : public boost::contract::call_if_statement< true, Then, result_of< Then()>::type >
    {

      // public member functions
      explicit call_if_statement(Then);
    };

## Description

The base class is a call-if statement so the else and else-if statements can be specified if needed. Usually this class template is instantiated only via the return value of `boost::contract::call_if` and `boost::contract::call_if_c`.

| Note
The `result_of<Then()>::type` expression needs be evaluated only when the static predicate is already checked to be `true` (because `Then()` is required to compile only in that case). Thus, this template specialization introduces an extra level of indirection necessary for proper lazy evaluation of this result-of expression.

See Also: Assertion Requirements

### Template Parameters

1.     typename Then

   Type of functor template to call when the static predicate is `true` (as it is for this template specialization).

### `call_if_statement` public member functions

1.     explicit call_if_statement(Then f);

   Construct this object with the then-branch functor template.

   Parameters: |
   `f` | Then-branch nullary functor template. The functor template call `f()` is compiled and called for this template specialization (because the if-statement static predicate is `true`). The return type of `f()` must be the same as (or implicitly convertible to) the return type of all other functor template calls specified for this call-if object.