find_if

| Home | Libraries | People | FAQ | More

##### find_if

###### Prototype

    template<class SinglePassRange, class UnaryPredicate>
    typename range_iterator<SinglePassRange>::type
    find_if(SinglePassRange& rng, UnaryPredicate pred);

    template<
        range_return_value re,
        class SinglePassRange,
        class UnaryPredicate
        >
    typename range_return<SinglePassRange, re>::type
    find_if(SinglePassRange& rng, UnaryPredicate pred);

###### Description

The versions of `find_if` that return an iterator, returns the first iterator in the range `rng` such that `pred(*i)` is `true`. `end(rng)` is returned if no such iterator exists.

The versions of `find_if` that return a `range_return`, defines found in the same manner as the returned iterator described above.

###### Definition

Defined in the header file `boost/range/algorithm/find_if.hpp`

###### Requirements

- `SinglePassRange` is a model of the Single Pass Range Concept.
- `UnaryPredicate` is a model of the `PredicateConcept`.
- The value type of `SinglePassRange` is convertible to the argument type of `UnaryPredicate`.

###### Precondition:

For each iterator `i` in `rng`, `*i` is in the domain of `UnaryPredicate`.

###### Complexity

Linear. At most `distance(rng)` invocations of `pred`.