Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Click here to view the latest version of this page.
Front Page / Metafunctions / Logical Operations / and_



      typename F1
    , typename F2
    , typename Fn = unspecified
struct and_
    typedef unspecified type;


Returns the result of short-circuit logical and (&&) operation on its arguments.


#include <boost/mpl/and.hpp>
#include <boost/mpl/logical.hpp>


Parameter Requirement Description
F1, F2,... Fn Nullary Metafunction Operation's arguments.

Expression semantics

For arbitrary nullary Metafunctions f1, f2,... fn:

typedef and_<f1,f2,...,fn>::type r;
Return type:Integral Constant.
Semantics:r is 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; the operands subsequent to the first fi metafunction that evaluates to false are not evaluated.
typedef and_<f1,f2,...,fn> r;
Return type:

Integral Constant.


Equivalent to

struct r : and_<f1,f2,...,fn>::type {};


struct unknown;

BOOST_MPL_ASSERT(( and_< true_,true_ > ));
BOOST_MPL_ASSERT_NOT(( and_< false_,true_ > ));
BOOST_MPL_ASSERT_NOT(( and_< true_,false_ > ));
BOOST_MPL_ASSERT_NOT(( and_< false_,false_ > ));
BOOST_MPL_ASSERT_NOT(( and_< false_,unknown > )); // OK
BOOST_MPL_ASSERT_NOT(( and_< false_,unknown,unknown > )); // OK too

See also

Metafunctions, Logical Operations, or_, not_