[Home]logical_or

Synopsis

template< 
      typename F1
    , typename F2
    , typename F3 = false_c
    ...
    , typename Fn = false_c
    >
struct logical_or
{
    typedef unspecified type;
};

Description

Returns the result of short-circuit logical or (||) operation on its arguments.

Definition

#include "boost/mpl/logical/or.hpp"

Parameters

 Parameter  Requirement  Description  
F1, F2, .., FnA model of nullary Metafunction

Expression semantics

 Expression  Expression type  Precondition  Semantics  Postcondition 
typedef logical_or<f1,f2,..,fn>::type c;A model of bool Integral ConstantReturns true_c if either of f1::type::value, f2::type::value, .., fn::type::value expressions evaluates to true, and false_c otherwise; guarantees left-to-right evaluation; moreover, the operands subsequent to the first fi metafunction that evaluates to true are not evaluated.

Example

// will generate compile-time error if invoked with T == any fundamental type
template< typename T > struct fail
{
   typedef typename T::nonexistent type;
};

BOOST_STATIC_ASSERT((logical_or< false_c,true_c >::type::value == true)); BOOST_STATIC_ASSERT((logical_or< true_c,fail<int> >::type::value == true)); // ok, fail<int> is never invoked BOOST_STATIC_ASSERT((logical_or< false_c,true_c,fail<int> >::type::value == true)); // ok too

See also

Metafunctions, logical_and, logical_not


Table of Content | Reference
Last edited July 17, 2002 4:12 am