2002-09-16 19:25:33 +00:00
<!doctype html public "-//ietf//dtd html//en">
2003-03-12 13:29:12 +00:00
< html >< head >< title > boost::mpl::find_if</ title >
2002-09-16 19:25:33 +00:00
< link rel = "stylesheet" href = "../mpl_wiki.css" >
</ head >< body bgcolor = "white" >
2003-03-12 13:29:12 +00:00
< h1 >< a href = "../Table_of_Contents.html" >< img src = "../mpl_logo.jpg" alt = "[Home]" border = 0 align = "right" ></ a > find_if</ h1 >< h3 > Synopsis</ h3 >
2002-09-16 19:25:33 +00:00
< p >
< pre >
template<
typename Sequence
, typename Pred
>
struct find_if
{
typedef < em > unspecified</ em > type;
};
</ pre >
< p >
< h3 > Description</ h3 >
< p >
Finds the first element in a < code > Sequence</ code > that satisfies the predicate < code > Pred</ code > .
< p >
< h3 > Definition</ h3 >
< p >
< pre >
2003-03-12 13:29:12 +00:00
#include "< a href = "../../../../../boost/mpl/find_if.hpp" > boost/mpl/find_if.hpp</ a > "
2002-09-16 19:25:33 +00:00
</ pre >
< p >
< h3 > Parameters</ h3 >
< table border = "1" >
< tr >< th > Parameter </ th >< th > Requirement </ th >< th > Description </ th ></ tr >
< tr >< td >< code > Sequence</ code ></ td >< td > A model of < a href = "../Forward_Sequence.html" > Forward Sequence</ a ></ td >< td > A sequence to search in. </ td ></ tr >
< tr >< td >< code > Pred</ code ></ td >< td > A model of Predicate [Lambda Expression]</ td >< td > A search condition. </ td ></ tr >
</ table >
< p >
< h3 > Expression semantics</ h3 >
< p >
< table border = "1" >
< tr >< th > Expression </ th >< th > Expression type </ th >< th > Precondition </ th >< th > Semantics </ th >< th > Postcondition </ th ></ tr >
< tr >< td >< code > typedef find_if< Sequence,Pred> ::type i;</ code ></ td >< td > A model of < a href = "../Forward_Iterator.html" > Forward Iterator</ a ></ td >< td ></ td >< td >< code > i</ code > is the first iterator in the range < code > [begin< Sequence> ::type, end< Sequence> ::type)</ code > such that < code > apply< lambda< Pred> ::type,i::type > ::type::value == true</ code > ; < code > i</ code > is identical to < code > end< Sequence> ::type</ code > , if no such iterator exists.</ td >< td ></ td ></ tr >
</ table >
< p >
< h3 > Complexity</ h3 >
< p >
Linear. At most < code > size< Sequence> ::value</ code > applications of < code > Pred</ code > .
< p >
< h3 > Example</ h3 >
< p >
< pre >
typedef < a href = "../Reference/vector.html" > vector</ a > < char,int,unsigned,long,unsigned_long> types;
typedef find_if< types, is_same< _1,unsigned> > ::type iter;
2003-03-12 13:29:12 +00:00
BOOST_STATIC_ASSERT(iter::pos::value == 2);
2002-09-16 19:25:33 +00:00
</ pre >
< p >
< h3 > See also</ h3 >
< p >
< a href = "../Algorithms.html" > Algorithms</ a > , < code >< a href = "../Reference/find.html" > find</ a ></ code > , < code >< a href = "../Reference/contains.html" > contains</ a ></ code > , < code >< a href = "../Reference/count.html" > count</ a ></ code > , < code >< a href = "../Reference/count_if.html" > count_if</ a ></ code >
< p >< hr >
2003-03-12 13:29:12 +00:00
< a href = "../Table_of_Contents.html" > Table of Contents</ a >< br > Last edited September 15, 2002 7:24 pm</ body ></ html >