boost::mpl::find_if

# find_if

### Synopsis

    template<
          typename Sequence
        , typename Pred
        >
    struct find_if
    {
        typedef unspecified type;
    };

### Description

Finds the first element in a `Sequence` that satisfies the predicate `Pred`.

### Definition

    #include "boost/mpl/find_if.hpp"

### Parameters

Parameter | Requirement | Description
--- | --- | ---
`Sequence` | A model of Forward Sequence | A sequence to search in.
`Pred` | A model of Predicate [Lambda Expression] | A search condition.

### Expression semantics

Expression | Expression type | Precondition | Semantics | Postcondition
--- | --- | --- | --- | ---
`typedef find_if<Sequence,Pred>::type i;` | A model of Forward Iterator |  | `i` is the first iterator in the range `[begin<Sequence>::type, end<Sequence>::type)` such that `apply< lambda<Pred>::type,i::type >::type::value == true`; `i` is identical to `end<Sequence>::type`, if no such iterator exists. |

### Complexity

Linear. At most `size<Sequence>::value` applications of `Pred`.

### Example

    typedef vector<char,int,unsigned,long,unsigned_long> types;
    typedef find_if<types, is_same<_1,unsigned> >::type iter;
    BOOST_STATIC_ASSERT(iter::pos::value == 2);

### See also

Algorithms, `find`, `contains`, `count`, `count_if`

Table of Contents
Last edited September 15, 2002 7:24 pm