Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext
find_if

Finds the first element within a sequence with a type for which a given MPL Lambda Expression evaluates to boost::mpl::true_.

Description
Synopsis
template<
    typename Sequence,
    typename F
    >
unspecified find_if(Sequence const& seq);

template<
    typename Sequence,
    typename F
    >
unspecified find_if(Sequence& seq);

Parameters

Parameter Requirement Description
seq A model of Forward Sequence The sequence to search
F A unary MPL Lambda Expression The search predicate
Expression Semantics
find_if<F>(seq)

Return type: An iterator of the same iterator category as the iterators of seq.

Semantics: Returns the first element of seq for which MPL Lambda Expression F evaluates to boost::mpl::true_, or end(seq) if there is no such element.

Complexity

Linear. At most result_of::size<Sequence>::value comparisons.

Header
#include <boost/fusion/algorithm/query/find_if.hpp>
Example
const vector<double,int> vec(1.0,2);
assert(*find_if<is_integral<mpl::_> >(vec) == 2);
assert(find_if<is_class<mpl::_> >(vec) == end(vec));
Copyright © 2001-2005 Joel de Guzman, Dan Marsden

PrevUpHomeNext