Boost C++ Libraries Home Libraries People FAQ More

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);

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: A model of Forward Sequence.

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>
Example
const vector<int,int,long,long> vec(1,2,3,4);
assert(filter<int>(vec) == make_vector(1,2));
Copyright © 2001-2005 Joel de Guzman, Dan Marsden

PrevUpHomeNext