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 to view this page for the latest version.
PrevUpHomeNext

Function template condition_if

boost::contract::condition_if — Select compilation and execution of a boolean functor template condition using a nullary boolean meta-function.

Synopsis

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


template<typename Pred, typename Then> 
  bool condition_if(Then f, bool else_ = true);

Description

This is equivalent to boost::contract::condition_if_c<Pred::value>(f, else_). Compile and execute the nullary boolean functor template call f() if and only if the specified nullary boolean meta-function Pred is true, otherwise trivially return else_ (true by default) at run-time.

See Also:

Assertion Requirements

Parameters:

else_

Boolean value to return when Pred::value is false (instead of compiling and executing the functor template call f()).

f

Nullary boolean functor template. The functor template call f() is compiled and executed if and only if Pred::value is true.

Template Parameters:

Pred

Nullary boolean meta-function selecting when the functor template call f() should be compiled and executed.

Returns:

Boolean value returned by f() if the static predicate Pred is true. Otherwise, trivially return else_.


PrevUpHomeNext