The BOOST_PP_SEQ_FILTER macro filters a seq according to a supplied criterion.

Usage

BOOST_PP_SEQ_FILTER(pred, data, seq)

Arguments

pred
A ternary predicate of the form pred(s, data, elem).  This predicate is expanded by BOOST_PP_SEQ_FILTER for each element in seq with the next available BOOST_PP_SEQ_FOLD_LEFT fold step, the auxiliary data, and the current element in seq.  This macro must return a integral value in the range of 0 to BOOST_PP_LIMIT_MAG.  If this predicate expands to non-zero for a certain element, that element is included in the resulting seq.
data
Auxiliary data passed to pred.
seq
The seq to be filtered.

Remarks

This macro expands pred for each element in seq.  It builds a new seq out of each element for which pred returns non-zero.
For maximum efficiency, use BOOST_PP_SEQ_FILTER_S.

See Also

Requirements

Header:  <boost/preprocessor/seq/filter.hpp>

Sample Code

#include <boost/preprocessor/comparison/less_equal.hpp>
#include <boost/preprocessor/seq/filter.hpp>

#define SEQ (1)(3)(2)(5)

#define PRED(s, data, elem) BOOST_PP_LESS_EQUAL(elem, data)

BOOST_PP_SEQ_FILTER(PRED, 3, SEQ)
   // expands to (1)(3)(2)

© Copyright Housemarque Oy 2002
© Copyright Paul Mensonides 2002

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt)