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 for the latest Boost documentation.

[Home]filter_view

Synopsis

template<
      typename Sequence
    , typename Pred
    >
struct filter_view
{
    // unspecified
};

Description

filter_view is a sequence wrapper that allows one to operate on the filtered sequence without actually creating one.

Definition

#include "boost/mpl/filter_view.hpp"

Parameters

 Parameter  Requirement  Description  
SequenceA model of SequenceA sequence to wrap.
PredA model of unary Predicate [Lambda Expression]A filtering predicate.

Expression semantics

 Expression  Expression type  Precondition  Semantics  Postcondition 
typedef filter_view<Sequence,Pred> s;A model of Sequences prodives iterators to all the elements in the range [begin<Sequence>::type,end<Sequence>::type) that satisfy the predicate Pred.size<s>::type::value == count_if< Sequence,Pred >::type::value.

Complexity

Amortized constant time.

Example

Finds the largest floating type in a sequence.

typedef list<int,float,long,float,char[50],long double,char> types;
typedef max_element<
      transform_view< filter_view< types,boost::is_float<_> >, size_of<_> >
    >::type iter;

BOOST_STATIC_ASSERT((is_same<iter::base::type,long double>::value));

See also

Sequences, transform_view, joint_view, zip_view, max_element


Table of Contents
Last edited March 10, 2003 4:42 am