1 | # /* ************************************************************************** |
---|
2 | # * * |
---|
3 | # * (C) Copyright Paul Mensonides 2002. |
---|
4 | # * Distributed under the Boost Software License, Version 1.0. (See |
---|
5 | # * accompanying file LICENSE_1_0.txt or copy at |
---|
6 | # * http://www.boost.org/LICENSE_1_0.txt) |
---|
7 | # * * |
---|
8 | # ************************************************************************** */ |
---|
9 | # |
---|
10 | # /* See http://www.boost.org for most recent version. */ |
---|
11 | # |
---|
12 | # ifndef BOOST_PREPROCESSOR_SEQ_FILTER_HPP |
---|
13 | # define BOOST_PREPROCESSOR_SEQ_FILTER_HPP |
---|
14 | # |
---|
15 | # include <boost/preprocessor/config/config.hpp> |
---|
16 | # include <boost/preprocessor/control/expr_if.hpp> |
---|
17 | # include <boost/preprocessor/facilities/empty.hpp> |
---|
18 | # include <boost/preprocessor/seq/fold_left.hpp> |
---|
19 | # include <boost/preprocessor/seq/seq.hpp> |
---|
20 | # include <boost/preprocessor/tuple/elem.hpp> |
---|
21 | # include <boost/preprocessor/tuple/rem.hpp> |
---|
22 | # |
---|
23 | # /* BOOST_PP_SEQ_FILTER */ |
---|
24 | # |
---|
25 | # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() |
---|
26 | # define BOOST_PP_SEQ_FILTER(pred, data, seq) BOOST_PP_SEQ_TAIL(BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_SEQ_FOLD_LEFT(BOOST_PP_SEQ_FILTER_O, (pred, data, (nil)), seq))) |
---|
27 | # else |
---|
28 | # define BOOST_PP_SEQ_FILTER(pred, data, seq) BOOST_PP_SEQ_FILTER_I(pred, data, seq) |
---|
29 | # define BOOST_PP_SEQ_FILTER_I(pred, data, seq) BOOST_PP_SEQ_TAIL(BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_SEQ_FOLD_LEFT(BOOST_PP_SEQ_FILTER_O, (pred, data, (nil)), seq))) |
---|
30 | # endif |
---|
31 | # |
---|
32 | # if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT() |
---|
33 | # define BOOST_PP_SEQ_FILTER_O(s, st, elem) BOOST_PP_SEQ_FILTER_O_IM(s, BOOST_PP_TUPLE_REM_3 st, elem) |
---|
34 | # define BOOST_PP_SEQ_FILTER_O_IM(s, im, elem) BOOST_PP_SEQ_FILTER_O_I(s, im, elem) |
---|
35 | # else |
---|
36 | # define BOOST_PP_SEQ_FILTER_O(s, st, elem) BOOST_PP_SEQ_FILTER_O_I(s, BOOST_PP_TUPLE_ELEM(3, 0, st), BOOST_PP_TUPLE_ELEM(3, 1, st), BOOST_PP_TUPLE_ELEM(3, 2, st), elem) |
---|
37 | # endif |
---|
38 | # |
---|
39 | # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_DMC() |
---|
40 | # define BOOST_PP_SEQ_FILTER_O_I(s, pred, data, res, elem) (pred, data, res BOOST_PP_EXPR_IF(pred(s, data, elem), (elem))) |
---|
41 | # else |
---|
42 | # define BOOST_PP_SEQ_FILTER_O_I(s, pred, data, res, elem) (pred, data, res BOOST_PP_EXPR_IF(pred##(s, data, elem), (elem))) |
---|
43 | # endif |
---|
44 | # |
---|
45 | # /* BOOST_PP_SEQ_FILTER_S */ |
---|
46 | # |
---|
47 | # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() |
---|
48 | # define BOOST_PP_SEQ_FILTER_S(s, pred, data, seq) BOOST_PP_SEQ_TAIL(BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_SEQ_FOLD_LEFT_ ## s(BOOST_PP_SEQ_FILTER_O, (pred, data, (nil)), seq))) |
---|
49 | # else |
---|
50 | # define BOOST_PP_SEQ_FILTER_S(s, pred, data, seq) BOOST_PP_SEQ_FILTER_S_I(s, pred, data, seq) |
---|
51 | # define BOOST_PP_SEQ_FILTER_S_I(s, pred, data, seq) BOOST_PP_SEQ_TAIL(BOOST_PP_TUPLE_ELEM(3, 2, BOOST_PP_SEQ_FOLD_LEFT_ ## s(BOOST_PP_SEQ_FILTER_O, (pred, data, (nil)), seq))) |
---|
52 | # endif |
---|
53 | # |
---|
54 | # endif |
---|