Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/libs/preprocessor/test/repetition.cpp @ 47

Last change on this file since 47 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 2.0 KB
Line 
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
24int add(BOOST_PP_ENUM_PARAMS(MAX, int x)) {
25    return BOOST_PP_REPEAT(MAX, NTH, + x);
26}
27
28const 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
31const 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
38TEST(0)
39TEST(MAX)
40
41template<BOOST_PP_ENUM_PARAMS(MAX, class T)> struct no_rescan;
42
43# define F1(z, n, p) p n
44BEGIN 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
50template<BOOST_PP_FOR(1, PRED, OP, MACRO)> struct for_test;
Note: See TracBrowser for help on using the repository browser.