• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 # include <boost/preprocessor/arithmetic/inc.hpp>
13 # include <boost/preprocessor/cat.hpp>
14 # include <boost/preprocessor/comparison/equal.hpp>
15 # include <boost/preprocessor/comparison/not_equal.hpp>
16 # include <boost/preprocessor/facilities/intercept.hpp>
17 # include <boost/preprocessor/repetition.hpp>
18 # include <libs/preprocessor/test/test.h>
19 
20 # define MAX 10
21 
22 # define NTH(z, n, data) data ## n
23 
add(BOOST_PP_ENUM_PARAMS (MAX,int x))24 int add(BOOST_PP_ENUM_PARAMS(MAX, int x)) {
25     return BOOST_PP_REPEAT(MAX, NTH, + x);
26 }
27 
28 const int r = add(BOOST_PP_ENUM_PARAMS(MAX, 1 BOOST_PP_INTERCEPT));
29 
30 # define CONSTANT(z, n, text) BOOST_PP_CAT(text, n) = n
31 const int BOOST_PP_ENUM(MAX, CONSTANT, default_param_);
32 
33 # define TEST(n) \
34     void BOOST_PP_CAT(test_enum_params, n)(BOOST_PP_ENUM_PARAMS(n, int x)); \
35     void BOOST_PP_CAT(test_enum_params_with_a_default, n)(BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(n, int x, 0)); \
36     void BOOST_PP_CAT(test_enum_params_with_defaults, n)(BOOST_PP_ENUM_PARAMS_WITH_DEFAULTS(n, int x, default_param_));
37 
38 TEST(0)
39 TEST(MAX)
40 
41 template<BOOST_PP_ENUM_PARAMS(MAX, class T)> struct no_rescan;
42 
43 # define F1(z, n, p) p n
44 BEGIN 1 + (4+5+6) BOOST_PP_REPEAT_FROM_TO(4, 7, F1, -) END
45 
46 # define PRED(r, state) BOOST_PP_NOT_EQUAL(state, BOOST_PP_INC(MAX))
47 # define OP(r, state) BOOST_PP_INC(state)
48 # define MACRO(r, state) BOOST_PP_COMMA_IF(BOOST_PP_NOT_EQUAL(state, 1)) BOOST_PP_CAT(class T, state)
49 
50 template<BOOST_PP_FOR(1, PRED, OP, MACRO)> struct for_test;
51