blob: 52d564e5eb0b90ad4ba69f5930b5dcf8c406bc26 [file] [log] [blame]
Jeff Thompsonf7d49942013-08-01 16:47:40 -07001# /* 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#
Jeff Thompson3d613fd2013-10-15 15:39:04 -070014# ifndef NDNBOOST_PREPROCESSOR_LIST_TRANSFORM_HPP
15# define NDNBOOST_PREPROCESSOR_LIST_TRANSFORM_HPP
Jeff Thompsonf7d49942013-08-01 16:47:40 -070016#
Jeff Thompson2277ce52013-08-01 17:34:11 -070017# include <ndnboost/preprocessor/config/config.hpp>
18# include <ndnboost/preprocessor/list/fold_right.hpp>
19# include <ndnboost/preprocessor/tuple/elem.hpp>
20# include <ndnboost/preprocessor/tuple/rem.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070021#
Jeff Thompson3d613fd2013-10-15 15:39:04 -070022# /* NDNBOOST_PP_LIST_TRANSFORM */
Jeff Thompsonf7d49942013-08-01 16:47:40 -070023#
Jeff Thompson3d613fd2013-10-15 15:39:04 -070024# if ~NDNBOOST_PP_CONFIG_FLAGS() & NDNBOOST_PP_CONFIG_EDG()
25# define NDNBOOST_PP_LIST_TRANSFORM(op, data, list) NDNBOOST_PP_TUPLE_ELEM(3, 2, NDNBOOST_PP_LIST_FOLD_RIGHT(NDNBOOST_PP_LIST_TRANSFORM_O, (op, data, NDNBOOST_PP_NIL), list))
Jeff Thompsonf7d49942013-08-01 16:47:40 -070026# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -070027# define NDNBOOST_PP_LIST_TRANSFORM(op, data, list) NDNBOOST_PP_LIST_TRANSFORM_I(op, data, list)
28# define NDNBOOST_PP_LIST_TRANSFORM_I(op, data, list) NDNBOOST_PP_TUPLE_ELEM(3, 2, NDNBOOST_PP_LIST_FOLD_RIGHT(NDNBOOST_PP_LIST_TRANSFORM_O, (op, data, NDNBOOST_PP_NIL), list))
Jeff Thompsonf7d49942013-08-01 16:47:40 -070029# endif
30#
Jeff Thompson3d613fd2013-10-15 15:39:04 -070031# if ~NDNBOOST_PP_CONFIG_FLAGS() & NDNBOOST_PP_CONFIG_EDG()
32# define NDNBOOST_PP_LIST_TRANSFORM_O(d, odr, elem) NDNBOOST_PP_LIST_TRANSFORM_O_D(d, NDNBOOST_PP_TUPLE_ELEM(3, 0, odr), NDNBOOST_PP_TUPLE_ELEM(3, 1, odr), NDNBOOST_PP_TUPLE_ELEM(3, 2, odr), elem)
Jeff Thompsonf7d49942013-08-01 16:47:40 -070033# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -070034# define NDNBOOST_PP_LIST_TRANSFORM_O(d, odr, elem) NDNBOOST_PP_LIST_TRANSFORM_O_I(d, NDNBOOST_PP_TUPLE_REM_3 odr, elem)
35# define NDNBOOST_PP_LIST_TRANSFORM_O_I(d, im, elem) NDNBOOST_PP_LIST_TRANSFORM_O_D(d, im, elem)
Jeff Thompsonf7d49942013-08-01 16:47:40 -070036# endif
37#
Jeff Thompson3d613fd2013-10-15 15:39:04 -070038# define NDNBOOST_PP_LIST_TRANSFORM_O_D(d, op, data, res, elem) (op, data, (op(d, data, elem), res))
Jeff Thompsonf7d49942013-08-01 16:47:40 -070039#
Jeff Thompson3d613fd2013-10-15 15:39:04 -070040# /* NDNBOOST_PP_LIST_TRANSFORM_D */
Jeff Thompsonf7d49942013-08-01 16:47:40 -070041#
Jeff Thompson3d613fd2013-10-15 15:39:04 -070042# if ~NDNBOOST_PP_CONFIG_FLAGS() & NDNBOOST_PP_CONFIG_EDG()
43# define NDNBOOST_PP_LIST_TRANSFORM_D(d, op, data, list) NDNBOOST_PP_TUPLE_ELEM(3, 2, NDNBOOST_PP_LIST_FOLD_RIGHT_ ## d(NDNBOOST_PP_LIST_TRANSFORM_O, (op, data, NDNBOOST_PP_NIL), list))
Jeff Thompsonf7d49942013-08-01 16:47:40 -070044# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -070045# define NDNBOOST_PP_LIST_TRANSFORM_D(d, op, data, list) NDNBOOST_PP_LIST_TRANSFORM_D_I(d, op, data, list)
46# define NDNBOOST_PP_LIST_TRANSFORM_D_I(d, op, data, list) NDNBOOST_PP_TUPLE_ELEM(3, 2, NDNBOOST_PP_LIST_FOLD_RIGHT_ ## d(NDNBOOST_PP_LIST_TRANSFORM_O, (op, data, NDNBOOST_PP_NIL), list))
Jeff Thompsonf7d49942013-08-01 16:47:40 -070047# endif
48#
49# endif