Boost C++ Libraries

...one 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 to view this page for the latest version.
PrevUpHomeNext
find
Description

Finds the first element of a given type within a sequence.

Synopsis
template<
    typename T,
    typename Sequence
    >
unspecified find(Sequence const& seq);

template<
    typename T,
    typename Sequence
    >
unspecified find(Sequence& seq);

Table 1.53. Parameters

Parameter

Requirement

Description

seq

A model of Forward Sequence

The sequence to search

T

Any type

The type to search for


Expression Semantics
find<T>(seq)

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

Semantics: Returns an iterator to the first element of seq of type T, or end(seq) if there is no such element. Equivalent to find_if<boost::is_same<_, T> >(seq)

Complexity

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

Header
#include <boost/fusion/algorithm/query/find.hpp>
#include <boost/fusion/include/find.hpp>
Example
const vector<char,int> vec('a','0');
assert(*find<int>(vec) == '0');
assert(find<double>(vec) == end(vec));

PrevUpHomeNext