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 MSGPACK_PREPROCESSOR_SEQ_FILTER_HPP 13# define MSGPACK_PREPROCESSOR_SEQ_FILTER_HPP 14# 15# include <msgpack/preprocessor/config/config.hpp> 16# include <msgpack/preprocessor/control/expr_if.hpp> 17# include <msgpack/preprocessor/facilities/empty.hpp> 18# include <msgpack/preprocessor/seq/fold_left.hpp> 19# include <msgpack/preprocessor/seq/seq.hpp> 20# include <msgpack/preprocessor/tuple/elem.hpp> 21# include <msgpack/preprocessor/tuple/rem.hpp> 22# 23# /* MSGPACK_PP_SEQ_FILTER */ 24# 25# if ~MSGPACK_PP_CONFIG_FLAGS() & MSGPACK_PP_CONFIG_EDG() 26# define MSGPACK_PP_SEQ_FILTER(pred, data, seq) MSGPACK_PP_SEQ_TAIL(MSGPACK_PP_TUPLE_ELEM(3, 2, MSGPACK_PP_SEQ_FOLD_LEFT(MSGPACK_PP_SEQ_FILTER_O, (pred, data, (nil)), seq))) 27# else 28# define MSGPACK_PP_SEQ_FILTER(pred, data, seq) MSGPACK_PP_SEQ_FILTER_I(pred, data, seq) 29# define MSGPACK_PP_SEQ_FILTER_I(pred, data, seq) MSGPACK_PP_SEQ_TAIL(MSGPACK_PP_TUPLE_ELEM(3, 2, MSGPACK_PP_SEQ_FOLD_LEFT(MSGPACK_PP_SEQ_FILTER_O, (pred, data, (nil)), seq))) 30# endif 31# 32# if MSGPACK_PP_CONFIG_FLAGS() & MSGPACK_PP_CONFIG_STRICT() 33# define MSGPACK_PP_SEQ_FILTER_O(s, st, elem) MSGPACK_PP_SEQ_FILTER_O_IM(s, MSGPACK_PP_TUPLE_REM_3 st, elem) 34# define MSGPACK_PP_SEQ_FILTER_O_IM(s, im, elem) MSGPACK_PP_SEQ_FILTER_O_I(s, im, elem) 35# else 36# define MSGPACK_PP_SEQ_FILTER_O(s, st, elem) MSGPACK_PP_SEQ_FILTER_O_I(s, MSGPACK_PP_TUPLE_ELEM(3, 0, st), MSGPACK_PP_TUPLE_ELEM(3, 1, st), MSGPACK_PP_TUPLE_ELEM(3, 2, st), elem) 37# endif 38# 39# if ~MSGPACK_PP_CONFIG_FLAGS() & MSGPACK_PP_CONFIG_DMC() 40# define MSGPACK_PP_SEQ_FILTER_O_I(s, pred, data, res, elem) (pred, data, res MSGPACK_PP_EXPR_IF(pred(s, data, elem), (elem))) 41# else 42# define MSGPACK_PP_SEQ_FILTER_O_I(s, pred, data, res, elem) (pred, data, res MSGPACK_PP_EXPR_IF(pred##(s, data, elem), (elem))) 43# endif 44# 45# /* MSGPACK_PP_SEQ_FILTER_S */ 46# 47# if ~MSGPACK_PP_CONFIG_FLAGS() & MSGPACK_PP_CONFIG_EDG() 48# define MSGPACK_PP_SEQ_FILTER_S(s, pred, data, seq) MSGPACK_PP_SEQ_TAIL(MSGPACK_PP_TUPLE_ELEM(3, 2, MSGPACK_PP_SEQ_FOLD_LEFT_ ## s(MSGPACK_PP_SEQ_FILTER_O, (pred, data, (nil)), seq))) 49# else 50# define MSGPACK_PP_SEQ_FILTER_S(s, pred, data, seq) MSGPACK_PP_SEQ_FILTER_S_I(s, pred, data, seq) 51# define MSGPACK_PP_SEQ_FILTER_S_I(s, pred, data, seq) MSGPACK_PP_SEQ_TAIL(MSGPACK_PP_TUPLE_ELEM(3, 2, MSGPACK_PP_SEQ_FOLD_LEFT_ ## s(MSGPACK_PP_SEQ_FILTER_O, (pred, data, (nil)), seq))) 52# endif 53# 54# endif 55