filter_view

| Home | Libraries | People | FAQ | More

### filter_view

##### Description

`filter_view` is a view into a subset of its underlying sequence's elements satisfying a given predicate (an MPL metafunction). The `filter_view` presents only those elements for which its predicate evaluates to `mpl::true_`.

##### Header

    #include <boost/fusion/view/filter_view.hpp>
    #include <boost/fusion/include/filter_view.hpp>

##### Synopsis

    template <typename Sequence, typename Pred>
    struct filter_view;

##### Template parameters

Parameter | Description | Default
--- | --- | ---
`Sequence` | A Forward Sequence |
`Pred` | Unary Metafunction returning an `mpl::bool_` |

##### Model of

- Forward Sequence
- Associative Sequence if `Sequence` implements the Associative Sequence model.

Notation

`F`

  A `filter_view` type

`f`, `f2`

  Instances of `filter_view`

`s`

  A Forward Sequence

##### Expression Semantics

Semantics of an expression is defined only where it differs from, or is not defined in the implemented models.

Expression | Semantics
--- | ---
`F(s)` | Creates a `filter_view` given a sequence, `s`.
`F(f)` | Copy constructs a `filter_view` from another `filter_view`, `f`.
`f = f2` | Assigns to a `filter_view`, `f`, from another `filter_view`, `f2`.

##### Example

    using boost::mpl::_;
    using boost::mpl::not_;
    using boost::is_class;

    typedef vector<std::string, char, long, bool, double> vector_type;

    vector_type v("a-string", '@', 987654, true, 6.6);
    filter_view<vector_type const, not_<is_class<_> > > view(v);
    std::cout << view << std::endl;