if_

Synopsis

template <class C, class T, class F>
struct if_
{
  // unspecified
};

Description

Evaluates the nullary metafunction C, and when it returns a true logical value, if_ returns the result of the nullary metafunction T, when C returns false, if_ returns the result of the nullary metafunction F.

#include <mpllibs/metamonad/if_.hpp>

Expression semantics

For any ct nullary metafunction evaluating to true, cf nullary metafunction evaluating to false and t, f nullary metafunctions the following are equivalent:

if_<ct, t, f>::type
t::type
if_<cf, t, f>::type
f::type

Example

MPLLIBS_METAFUNCTION(divide_if_not_zero, (A)(B))
((
  if_<
    boost::mpl::equal_to<boost::mpl::int_<0>, B>,
    A,
    boost::mpl::divides<A, B>
  >
));

[up]