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

This is the documentation for an old version of boost. Click here for the latest Boost documentation.



      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  
SequenceA model of Forward SequenceA sequence to search in.
PredA 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 Iteratori 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::pos::value == 2);

See also

Algorithms, find, contains, count, count_if

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