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
filter
Description

For a given sequence, filter returns a new sequences containing only the elements of a specified type.

Synopsis
template<
    typename T,
    typename Sequence
    >
typename result_of::filter<Sequence const, T>::type filter(Sequence const& seq);

Table 1.66. Parameters

Parameter

Requirement

Description

seq

A model of Forward Sequence

Operation's argument

T

Any type

The type to retain


Expression Semantics
filter<T>(seq);

Return type:

Semantics: Returns a sequence containing all the elements of seq of type T. Equivalent to filter_if<boost::same_type<_, T> >(seq).

Complexity

Constant. Returns a view which is lazily evaluated.

Header
#include <boost/fusion/algorithm/transformation/filter.hpp>
#include <boost/fusion/include/filter.hpp>
Example
const vector<int,int,long,long> vec(1,2,3,4);
assert(filter<int>(vec) == make_vector(1,2));

PrevUpHomeNext