blob: 304eb52568c20069f5903859c8bbd7985d47cad7 [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001# /* **************************************************************************
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#
Jeff Thompson3d613fd2013-10-15 15:39:04 -070012# ifndef NDNBOOST_PREPROCESSOR_SEQ_TRANSFORM_HPP
13# define NDNBOOST_PREPROCESSOR_SEQ_TRANSFORM_HPP
Jeff Thompsona28eed82013-08-22 16:21:10 -070014#
15# include <ndnboost/preprocessor/config/config.hpp>
16# include <ndnboost/preprocessor/seq/fold_left.hpp>
17# include <ndnboost/preprocessor/seq/seq.hpp>
18# include <ndnboost/preprocessor/tuple/elem.hpp>
19# include <ndnboost/preprocessor/tuple/rem.hpp>
20#
Jeff Thompson3d613fd2013-10-15 15:39:04 -070021# /* NDNBOOST_PP_SEQ_TRANSFORM */
Jeff Thompsona28eed82013-08-22 16:21:10 -070022#
Jeff Thompson3d613fd2013-10-15 15:39:04 -070023# if ~NDNBOOST_PP_CONFIG_FLAGS() & NDNBOOST_PP_CONFIG_EDG()
24# define NDNBOOST_PP_SEQ_TRANSFORM(op, data, seq) NDNBOOST_PP_SEQ_TAIL(NDNBOOST_PP_TUPLE_ELEM(3, 2, NDNBOOST_PP_SEQ_FOLD_LEFT(NDNBOOST_PP_SEQ_TRANSFORM_O, (op, data, (nil)), seq)))
Jeff Thompsona28eed82013-08-22 16:21:10 -070025# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -070026# define NDNBOOST_PP_SEQ_TRANSFORM(op, data, seq) NDNBOOST_PP_SEQ_TRANSFORM_I(op, data, seq)
27# define NDNBOOST_PP_SEQ_TRANSFORM_I(op, data, seq) NDNBOOST_PP_SEQ_TAIL(NDNBOOST_PP_TUPLE_ELEM(3, 2, NDNBOOST_PP_SEQ_FOLD_LEFT(NDNBOOST_PP_SEQ_TRANSFORM_O, (op, data, (nil)), seq)))
Jeff Thompsona28eed82013-08-22 16:21:10 -070028# endif
29#
Jeff Thompson3d613fd2013-10-15 15:39:04 -070030# if NDNBOOST_PP_CONFIG_FLAGS() & NDNBOOST_PP_CONFIG_STRICT()
31# define NDNBOOST_PP_SEQ_TRANSFORM_O(s, state, elem) NDNBOOST_PP_SEQ_TRANSFORM_O_IM(s, NDNBOOST_PP_TUPLE_REM_3 state, elem)
32# define NDNBOOST_PP_SEQ_TRANSFORM_O_IM(s, im, elem) NDNBOOST_PP_SEQ_TRANSFORM_O_I(s, im, elem)
Jeff Thompsona28eed82013-08-22 16:21:10 -070033# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -070034# define NDNBOOST_PP_SEQ_TRANSFORM_O(s, state, elem) NDNBOOST_PP_SEQ_TRANSFORM_O_I(s, NDNBOOST_PP_TUPLE_ELEM(3, 0, state), NDNBOOST_PP_TUPLE_ELEM(3, 1, state), NDNBOOST_PP_TUPLE_ELEM(3, 2, state), elem)
Jeff Thompsona28eed82013-08-22 16:21:10 -070035# endif
36#
Jeff Thompson3d613fd2013-10-15 15:39:04 -070037# define NDNBOOST_PP_SEQ_TRANSFORM_O_I(s, op, data, res, elem) (op, data, res (op(s, data, elem)))
Jeff Thompsona28eed82013-08-22 16:21:10 -070038#
Jeff Thompson3d613fd2013-10-15 15:39:04 -070039# /* NDNBOOST_PP_SEQ_TRANSFORM_S */
Jeff Thompsona28eed82013-08-22 16:21:10 -070040#
Jeff Thompson3d613fd2013-10-15 15:39:04 -070041# if ~NDNBOOST_PP_CONFIG_FLAGS() & NDNBOOST_PP_CONFIG_EDG()
42# define NDNBOOST_PP_SEQ_TRANSFORM_S(s, op, data, seq) NDNBOOST_PP_SEQ_TAIL(NDNBOOST_PP_TUPLE_ELEM(3, 2, NDNBOOST_PP_SEQ_FOLD_LEFT_ ## s(NDNBOOST_PP_SEQ_TRANSFORM_O, (op, data, (nil)), seq)))
Jeff Thompsona28eed82013-08-22 16:21:10 -070043# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -070044# define NDNBOOST_PP_SEQ_TRANSFORM_S(s, op, data, seq) NDNBOOST_PP_SEQ_TRANSFORM_S_I(s, op, data, seq)
45# define NDNBOOST_PP_SEQ_TRANSFORM_S_I(s, op, data, seq) NDNBOOST_PP_SEQ_TAIL(NDNBOOST_PP_TUPLE_ELEM(3, 2, NDNBOOST_PP_SEQ_FOLD_LEFT_ ## s(NDNBOOST_PP_SEQ_TRANSFORM_O, (op, data, (nil)), seq)))
Jeff Thompsona28eed82013-08-22 16:21:10 -070046# endif
47#
48# endif