template< typename F1 , typename F2 , typename F3 = true_ ... , typename Fn = true_ > struct and_ { typedef unspecified type; };
Returns the result of short-circuit logical and (&&
) operation on its arguments.
#include "boost/mpl/and.hpp"
Parameter | Requirement | Description |
---|---|---|
F1, F2, .., Fn | A model of nullary Metafunction |
Expression | Expression type | Precondition | Semantics | Postcondition |
---|---|---|---|---|
typedef and_<f1,f2,..,fn>::type c; | A model of bool Integral Constant | Returns false_ if either of f1::type::value, f2::type::value, .., fn::type::value expressions evaluates to false , and true_ otherwise; guarantees left-to-right evaluation; moreover, the operands subsequent to the first fi metafunction that evaluates to false are not evaluated. |
// 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((and_< true_,false_ >::type::value == false)); BOOST_STATIC_ASSERT((and_< false_,fail<int> >::type::value == false)); // OK, fail<int> is never invoked BOOST_STATIC_ASSERT((and_< true_,false_,fail<int> >::type::value == false)); // OK too