| Home | Libraries | People | FAQ | More

## Function template call_if_c

boost::contract::call_if_c — Select compilation and execution of functor template calls using a static boolean predicate (not needed on C++17 compilers, use `if constexpr` instead).

## Synopsis

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

    template<bool Pred, typename Then>
      call_if_statement< Pred, Then > call_if_c(Then f);

## Description

Create a call-if object with the specified then-branch functor template:

    boost::contract::call_if_c<Pred1>(
        then_functor_template1
    ).template else_if_c<Pred2>(            // Optional.
        then_functor_template2
    )                                       // Optionally, other `else_if_c` or
    ...                                     // `else_if`.
    .else_(                                 // Optional for `void` functors,
        else_functor_template               // but required for non `void`.
    )

Optional functor templates for else-if-branches and the else-branch can be specified as needed (the else-branch function template is required if `f` returns non-void).

See Also:

Assertion Requirements

Parameters: |
`f` | Then-branch nullary functor template. The functor template call `f()` is compiled and executed if and only if `Pred` is `true`. The return type of other functor template calls specified for this call-if statement (else-branch, else-if-branches, etc.) must be the same as (or implicitly convertible to) the return type of then-branch functor call `f()`.
Template Parameters: |
`Pred` | Static boolean predicate selecting which functor template call to compile and execute.
Returns: | A call-if statement so else and else-if statements can be specified if needed. Eventually, this will be the return value of the one functor template call being compiled and executed (which could also be `void`).