...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
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_.
template< typename Pred, typename Sequence > typename result_of::filter_if<Sequence const, Pred>::type filter_if(Sequence const& seq);
Table 1.54. Parameters
Parameter |
Requirement |
Description |
---|---|---|
seq |
A model of Forward Sequence |
Operation's argument |
Pred |
A unary MPL Lambda Expression |
The predicate to filter by |
filter_if<Pred>(seq);
Return type: A model of Forward Sequence.
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.
Constant. Returns a view which is lazily evaluated.
#include <boost/fusion/algorithm/transformation/filter_if.hpp> #include <boost/fusion/include/filter_if.hpp>
const vector<int,int,double,double> vec(1,2,3.0,4.0); assert(filter_if<is_integral<mpl::_> >(vec) == make_vector(1,2));