1# /* Copyright (C) 2001 2# * Housemarque Oy 3# * http://www.housemarque.com 4# * 5# * Distributed under the Boost Software License, Version 1.0. (See 6# * accompanying file LICENSE_1_0.txt or copy at 7# * http://www.boost.org/LICENSE_1_0.txt) 8# */ 9# 10# /* Revised by Paul Mensonides (2002) */ 11# 12# /* See http://www.boost.org for most recent version. */ 13# 14# ifndef MSGPACK_PREPROCESSOR_LIST_FILTER_HPP 15# define MSGPACK_PREPROCESSOR_LIST_FILTER_HPP 16# 17# include <msgpack/preprocessor/config/config.hpp> 18# include <msgpack/preprocessor/control/if.hpp> 19# include <msgpack/preprocessor/list/fold_right.hpp> 20# include <msgpack/preprocessor/tuple/elem.hpp> 21# include <msgpack/preprocessor/tuple/rem.hpp> 22# 23# /* MSGPACK_PP_LIST_FILTER */ 24# 25# if ~MSGPACK_PP_CONFIG_FLAGS() & MSGPACK_PP_CONFIG_EDG() 26# define MSGPACK_PP_LIST_FILTER(pred, data, list) MSGPACK_PP_TUPLE_ELEM(3, 2, MSGPACK_PP_LIST_FOLD_RIGHT(MSGPACK_PP_LIST_FILTER_O, (pred, data, MSGPACK_PP_NIL), list)) 27# else 28# define MSGPACK_PP_LIST_FILTER(pred, data, list) MSGPACK_PP_LIST_FILTER_I(pred, data, list) 29# define MSGPACK_PP_LIST_FILTER_I(pred, data, list) MSGPACK_PP_TUPLE_ELEM(3, 2, MSGPACK_PP_LIST_FOLD_RIGHT(MSGPACK_PP_LIST_FILTER_O, (pred, data, MSGPACK_PP_NIL), list)) 30# endif 31# 32# if ~MSGPACK_PP_CONFIG_FLAGS() & MSGPACK_PP_CONFIG_EDG() 33# define MSGPACK_PP_LIST_FILTER_O(d, pdr, elem) MSGPACK_PP_LIST_FILTER_O_D(d, MSGPACK_PP_TUPLE_ELEM(3, 0, pdr), MSGPACK_PP_TUPLE_ELEM(3, 1, pdr), MSGPACK_PP_TUPLE_ELEM(3, 2, pdr), elem) 34# else 35# define MSGPACK_PP_LIST_FILTER_O(d, pdr, elem) MSGPACK_PP_LIST_FILTER_O_I(d, MSGPACK_PP_TUPLE_REM_3 pdr, elem) 36# define MSGPACK_PP_LIST_FILTER_O_I(d, im, elem) MSGPACK_PP_LIST_FILTER_O_D(d, im, elem) 37# endif 38# 39# if ~MSGPACK_PP_CONFIG_FLAGS() & MSGPACK_PP_CONFIG_DMC() 40# define MSGPACK_PP_LIST_FILTER_O_D(d, pred, data, res, elem) (pred, data, MSGPACK_PP_IF(pred(d, data, elem), (elem, res), res)) 41# else 42# define MSGPACK_PP_LIST_FILTER_O_D(d, pred, data, res, elem) (pred, data, MSGPACK_PP_IF(pred##(d, data, elem), (elem, res), res)) 43# endif 44# 45# /* MSGPACK_PP_LIST_FILTER_D */ 46# 47# if ~MSGPACK_PP_CONFIG_FLAGS() & MSGPACK_PP_CONFIG_EDG() 48# define MSGPACK_PP_LIST_FILTER_D(d, pred, data, list) MSGPACK_PP_TUPLE_ELEM(3, 2, MSGPACK_PP_LIST_FOLD_RIGHT_ ## d(MSGPACK_PP_LIST_FILTER_O, (pred, data, MSGPACK_PP_NIL), list)) 49# else 50# define MSGPACK_PP_LIST_FILTER_D(d, pred, data, list) MSGPACK_PP_LIST_FILTER_D_I(d, pred, data, list) 51# define MSGPACK_PP_LIST_FILTER_D_I(d, pred, data, list) MSGPACK_PP_TUPLE_ELEM(3, 2, MSGPACK_PP_LIST_FOLD_RIGHT_ ## d(MSGPACK_PP_LIST_FILTER_O, (pred, data, MSGPACK_PP_NIL), list)) 52# endif 53# 54# endif 55