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<true, Then, ThenResult>

boost::contract::call_if_statement<true, Then, ThenResult> — Template specialization to handle static predicates that are true for then-branch functor template calls that do not return void.

Synopsis

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

template<typename Then, typename ThenResult> 
struct call_if_statement<true, Then, ThenResult> {
  // construct/copy/destruct
  explicit call_if_statement(Then);

  // public member functions
  operator ThenResult() const;
  template<typename Else> ThenResult else_(Else const &) const;
  template<bool ElseIfPred, typename ElseIfThen> 
    call_if_statement< true, Then, ThenResult > 
    else_if_c(ElseIfThen const &) const;
  template<typename ElseIfPred, typename ElseIfThen> 
    call_if_statement< true, Then, ThenResult > 
    else_if(ElseIfThen const &) const;
};

Description

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 (as it is for this template specialization).

  2. typename ThenResult

    Non-void return type of the then-branch functor template call.

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 actually compiled and executed 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 ThenResult type.

call_if_statement public member functions

  1. operator ThenResult() const;
    This implicit type conversion returns a copy of the value returned by the call to the then-branch functor template.
  2. template<typename Else> ThenResult else_(Else const & f) const;
    Specify the else-branch functor template.

    Parameters:

    f

    Else-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 true). The return type of f() must be the same as (or implicitly convertible to) the ThenResult type.

    Returns:

    A copy of the value returned by the call to the then-branch functor template (because the else-branch functor template call is not executed).

  3. template<bool ElseIfPred, typename ElseIfThen> 
      call_if_statement< true, Then, ThenResult > 
      else_if_c(ElseIfThen const & 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 never compiled and executed 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 ThenResult type.

    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, it will be the return value of the then-branch functor template call for this template specialization (because the if-statement static predicate is true).

  4. template<typename ElseIfPred, typename ElseIfThen> 
      call_if_statement< true, Then, ThenResult > 
      else_if(ElseIfThen const & f) const;
    Specify an else-if-branch functor template (using a nullary boolean meta-function).

    Parameters:

    f

    Else-if-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 true). The return type of f() must be the same as (or implicitly convertible to) the ThenResult type.

    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, it will be the return value of the then-branch functor template call for this template specialization (because the if-statement static predicate is true).


PrevUpHomeNext