Boost C++ Libraries

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

This is an old version of boost. Click here for the latest version's documentation home page.

[Home]and_

Synopsis

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

Description

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

Definition

#include "boost/mpl/and.hpp"

Parameters

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

Expression semantics

 Expression  Expression type  Precondition  Semantics  Postcondition 
and_<f1,f2,..,fn>A model of bool Integral Constantfalse_ 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.

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((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

See also

Metafunctions, or_, not_


Table of Contents
Last edited September 6, 2003 3:13 am