filter

| Home | Libraries | People | FAQ | More

##### 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.57. 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.
- A model of Associative Sequence if `seq` implements the Associative Sequence model.

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