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 an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Struct template call_if_statement<false, Then, internal_type>

boost::contract::call_if_statement<false, Then, internal_type> — Template specialization to handle static predicates that are false.

Synopsis

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

template<typename Then> 
struct call_if_statement<false, Then, internal_type> {
  // construct/copy/destruct
  explicit call_if_statement(Then const &);

  // public member functions
  template<typename Else> result_of< Else()>::type else_(Else) const;
  template<bool ElseIfPred, typename ElseIfThen> 
    call_if_statement< ElseIfPred, ElseIfThen > else_if_c(ElseIfThen) const;
  template<typename ElseIfPred, typename ElseIfThen> 
    call_if_statement< ElseIfPred::value, ElseIfThen > 
    else_if(ElseIfThen) const;
};

Description

This template specialization handles all else-branch functor template calls (whether they return void or not). Usually this class template is instantiated only via the return value of boost::contract::call_if and boost::contract::call_if_c.

See Also:

Assertion Requirements

Template Parameters

  1. typename Then

    Type of functor template to call when the static predicate is true (never the case for this template specialization).

call_if_statement public construct/copy/destruct

  1. explicit call_if_statement(Then const & f);
    Construct this object with the then-branch functor template.

    Parameters:

    f

    Then-branch nullary functor template. The functor template call f() is never compiled and executed for this template specialization (because the if-statement static predicate is false). 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.

call_if_statement public member functions

  1. template<typename Else> result_of< Else()>::type else_(Else f) const;
    Specify the else-branch functor template.
    [Note] Note

    The result_of<Else()>::type expression should be evaluated only when the static predicate is already checked to be false (because Else() is required to compile only in that case). Thus, this result-of expression is evaluated lazily only in instantiations of this template specialization.

    Parameters:

    f

    Else-branch nullary functor template. The functor template call f() is actually compiled and executed for this template specialization (because the if-statement static predicate is false). 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.

    Returns:

    A copy of the value returned by the call to the else-branch functor template f().

  2. template<bool ElseIfPred, typename ElseIfThen> 
      call_if_statement< ElseIfPred, ElseIfThen > else_if_c(ElseIfThen f) const;
    Specify an else-if-branch functor template (using a static boolean predicate).

    Parameters:

    f

    Else-if-branch nullary functor template. The functor template call f() is actually compiled and executed if and only if ElseIfPred is true (because the if-statement static predicate is already false for this template specialization). 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.

    Template Parameters:

    ElseIfPred

    Static boolean predicate selecting which functor template call to compile and execute.

    Returns:

    A call-if statement so the else statement and additional else-if statements can be specified if needed. Eventually, this will be the return value of the functor template call being compiled and executed.

  3. template<typename ElseIfPred, typename ElseIfThen> 
      call_if_statement< ElseIfPred::value, ElseIfThen > 
      else_if(ElseIfThen f) const;
    Specify an else-if-branch functor template (using a nullary boolen meta-function).

    Parameters:

    f

    Else-if-branch nullary functor template. The functor template call f() is actually compiled and executed if and only if ElseIfPred::value is true (because the if-statement static predicate is already false for this template specialization). 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.

    Template Parameters:

    ElseIfPred

    Nullary boolean meta-function selecting which functor template call to compile and execute.

    Returns:

    A call-if statement so the else statement and additional else-if statements can be specified if needed. Eventually, this will be the return value of the functor template call being compiled and executed.


PrevUpHomeNext