...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
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 |
---|---|---|---|---|
and_<f1,f2,..,fn> | A model of bool Integral Constant | 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_ >::value == false)); BOOST_STATIC_ASSERT((and_< false_,fail<int> >::value == false)); // OK, fail<int> is never invoked BOOST_STATIC_ASSERT((and_< true_,false_,fail<int> >::value == false)); // OK too