• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 //  (C) Copyright Edward Diener 2011-2015
3 //  Use, modification and distribution are subject to the Boost Software License,
4 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 //  http://www.boost.org/LICENSE_1_0.txt).
6 
7 #include <boost/detail/lightweight_test.hpp>
8 #include <boost/preprocessor/cat.hpp>
9 #include <boost/preprocessor/control/if.hpp>
10 #include <boost/preprocessor/tuple/elem.hpp>
11 
main()12 int main()
13   {
14 
15 #if BOOST_PP_VARIADICS
16 
17 #define TN_GEN_ONE(p) (1)
18 #define TN_GEN_ZERO(p) (0)
19 
20 #define TN_TEST_ONE_MORE(parameter,ens) \
21         BOOST_PP_IF \
22             ( \
23             BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(1,0,ens),0), \
24             TN_GEN_ONE, \
25             TN_GEN_ZERO \
26             ) \
27         (parameter) \
28 /**/
29 
30 #define TN_TEST_ONE(parameter,ens) \
31     BOOST_PP_TUPLE_ELEM \
32         ( \
33         1, \
34         0, \
35         TN_TEST_ONE_MORE(parameter,ens) \
36         ) \
37 /**/
38 
39    BOOST_TEST_EQ(TN_TEST_ONE(A,(1)),1);
40    BOOST_TEST_EQ(TN_TEST_ONE(A,()),0);
41 
42 #else
43 
44 BOOST_ERROR("No variadic macro support");
45 
46 #endif /* BOOST_PP_VARIADICS */
47 
48   return boost::report_errors();
49 
50   }
51