Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for a snapshot of the master branch, built from commit c0bc0d89c9.
PrevUpHomeNext

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 >
{
  // construct/copy/destruct
  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] 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 construct/copy/destruct

  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.


PrevUpHomeNext