| Home | Libraries | People | FAQ | More

##### filter_if

###### Description

For a given sequence, `filter_if` returns a new sequences containing only the elements with types for which a given MPL Lambda Expression evaluates to `boost::mpl::true_`.

###### Synopsis

    template<
        typename Pred,
        typename Sequence
        >
    typename result_of::filter_if<Sequence const, Pred>::type filter_if(Sequence const& seq);

Table 1.58. Parameters

Parameter | Requirement | Description
--- | --- | ---
`seq` | A model of Forward Sequence | Operation's argument
`Pred` | A unary MPL Lambda Expression | The predicate to filter by

###### Expression Semantics

    filter_if<Pred>(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` with types for which `Pred` evaluates to `boost::mpl::true_`. The order of the retained elements is the same as in the original sequence.

###### Complexity

Constant. Returns a view which is lazily evaluated.

###### Header

    #include <boost/fusion/algorithm/transformation/filter_if.hpp>
    #include <boost/fusion/include/filter_if.hpp>

###### Example

    const vector<int,int,double,double> vec(1,2,3.0,4.0);
    assert(filter_if<is_integral<mpl::_> >(vec) == make_vector(1,2));