...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Finds the first element within a sequence with a type for which a given
MPL
Lambda Expression evaluates to boost::mpl::true_
.
template< typename F, typename Sequence > typenameresult_of::find_if
<Sequence const, F>::type find_if(Sequence const& seq); template< typename F, typename Sequence > typenameresult_of::find_if
<Sequence, F>::type find_if(Sequence& seq);
Table 1.56. Parameters
Parameter |
Requirement |
Description |
---|---|---|
|
A model of Forward Sequence |
The sequence to search |
|
A unary MPL Lambda Expression |
The search predicate |
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
if there is no such element.
end
(seq)
Linear. At most
comparisons.
result_of::size
<Sequence>::value
#include <boost/fusion/algorithm/query/find_if.hpp> #include <boost/fusion/include/find_if.hpp>
constvector
<double,int> vec(1.0,2); assert(*find_if
<is_integral<mpl::_> >(vec) == 2); assert(find_if
<is_class<mpl::_> >(vec) ==end
(vec));