blob: 474c0fbee5d96c38f56e84c2498a2556afe2eba6 [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_ARITHMETIC_ADD_HPP
15# define NDNBOOST_PREPROCESSOR_ARITHMETIC_ADD_HPP
Jeff Thompsonf7d49942013-08-01 16:47:40 -070016#
Jeff Thompson2277ce52013-08-01 17:34:11 -070017# include <ndnboost/preprocessor/arithmetic/dec.hpp>
18# include <ndnboost/preprocessor/arithmetic/inc.hpp>
19# include <ndnboost/preprocessor/config/config.hpp>
20# include <ndnboost/preprocessor/control/while.hpp>
21# include <ndnboost/preprocessor/tuple/elem.hpp>
Jeff Thompsonf7d49942013-08-01 16:47:40 -070022#
Jeff Thompson3d613fd2013-10-15 15:39:04 -070023# /* NDNBOOST_PP_ADD */
Jeff Thompsonf7d49942013-08-01 16:47:40 -070024#
Jeff Thompson3d613fd2013-10-15 15:39:04 -070025# if ~NDNBOOST_PP_CONFIG_FLAGS() & NDNBOOST_PP_CONFIG_EDG()
26# define NDNBOOST_PP_ADD(x, y) NDNBOOST_PP_TUPLE_ELEM(2, 0, NDNBOOST_PP_WHILE(NDNBOOST_PP_ADD_P, NDNBOOST_PP_ADD_O, (x, y)))
Jeff Thompsonf7d49942013-08-01 16:47:40 -070027# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -070028# define NDNBOOST_PP_ADD(x, y) NDNBOOST_PP_ADD_I(x, y)
29# define NDNBOOST_PP_ADD_I(x, y) NDNBOOST_PP_TUPLE_ELEM(2, 0, NDNBOOST_PP_WHILE(NDNBOOST_PP_ADD_P, NDNBOOST_PP_ADD_O, (x, y)))
Jeff Thompsonf7d49942013-08-01 16:47:40 -070030# endif
31#
Jeff Thompson3d613fd2013-10-15 15:39:04 -070032# define NDNBOOST_PP_ADD_P(d, xy) NDNBOOST_PP_TUPLE_ELEM(2, 1, xy)
Jeff Thompsonf7d49942013-08-01 16:47:40 -070033#
Jeff Thompson3d613fd2013-10-15 15:39:04 -070034# if ~NDNBOOST_PP_CONFIG_FLAGS() & NDNBOOST_PP_CONFIG_MWCC()
35# define NDNBOOST_PP_ADD_O(d, xy) NDNBOOST_PP_ADD_O_I xy
Jeff Thompsonf7d49942013-08-01 16:47:40 -070036# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -070037# define NDNBOOST_PP_ADD_O(d, xy) NDNBOOST_PP_ADD_O_I(NDNBOOST_PP_TUPLE_ELEM(2, 0, xy), NDNBOOST_PP_TUPLE_ELEM(2, 1, xy))
Jeff Thompsonf7d49942013-08-01 16:47:40 -070038# endif
39#
Jeff Thompson3d613fd2013-10-15 15:39:04 -070040# define NDNBOOST_PP_ADD_O_I(x, y) (NDNBOOST_PP_INC(x), NDNBOOST_PP_DEC(y))
Jeff Thompsonf7d49942013-08-01 16:47:40 -070041#
Jeff Thompson3d613fd2013-10-15 15:39:04 -070042# /* NDNBOOST_PP_ADD_D */
Jeff Thompsonf7d49942013-08-01 16:47:40 -070043#
Jeff Thompson3d613fd2013-10-15 15:39:04 -070044# if ~NDNBOOST_PP_CONFIG_FLAGS() & NDNBOOST_PP_CONFIG_EDG()
45# define NDNBOOST_PP_ADD_D(d, x, y) NDNBOOST_PP_TUPLE_ELEM(2, 0, NDNBOOST_PP_WHILE_ ## d(NDNBOOST_PP_ADD_P, NDNBOOST_PP_ADD_O, (x, y)))
Jeff Thompsonf7d49942013-08-01 16:47:40 -070046# else
Jeff Thompson3d613fd2013-10-15 15:39:04 -070047# define NDNBOOST_PP_ADD_D(d, x, y) NDNBOOST_PP_ADD_D_I(d, x, y)
48# define NDNBOOST_PP_ADD_D_I(d, x, y) NDNBOOST_PP_TUPLE_ELEM(2, 0, NDNBOOST_PP_WHILE_ ## d(NDNBOOST_PP_ADD_P, NDNBOOST_PP_ADD_O, (x, y)))
Jeff Thompsonf7d49942013-08-01 16:47:40 -070049# endif
50#
51# endif