# logical_and

### Synopsis

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

### Description

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

### Definition

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

### Parameters

Parameter | Requirement | Description
--- | --- | ---
`F1, F2, .., Fn` | A model of nullary Metafunction |

### Expression semantics

Expression | Precondition | Semantics | Postcondition
--- | --- | --- | ---
`typedef logical_and<f1,f2,..,fn>::type c;` |  | Returns `false_c` if either of `f1::type::value, f2::type::value, .., fn::type::value` expressions evaluates to `false`, and `true_c` 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((logical_and< true_c,false_c >::type::value == false));
    BOOST_STATIC_ASSERT((logical_and< false_c,fail<int> >::type::value == false)); // ok, fail<int> is never invoked
    BOOST_STATIC_ASSERT((logical_and< true_c,false_c,fail<int> >::type::value == false)); // ok too

### See also

Metafunctions, `logical_or`, `logical_not`

Table of Content | Reference
Last edited July 17, 2002 1:06 am