find_if
template<
typename Sequence
, typename Pred
>
struct find_if
{
typedef unspecified type;
};
Finds the first element in a Sequence that satisfies the predicate Pred.
#include "boost/mpl/find_if.hpp"
| 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 | 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. |
Linear. At most size<Sequence>::value applications of Pred.
typedef vector<char,int,unsigned,long,unsigned_long> types; typedef find_if<types, is_same<_1,unsigned> >::type iter; BOOST_STATIC_ASSERT(iter::position == 2);
Algorithms, find, contains, count, count_if