• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 //  (C) Copyright Edward Diener 2011-2015,2019
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/vmd/is_empty.hpp>
8 #include <boost/preprocessor/tuple/elem.hpp>
9 #include <boost/preprocessor/variadic/elem.hpp>
10 #include <boost/preprocessor/variadic/has_opt.hpp>
11 #include <boost/detail/lightweight_test.hpp>
12 
main()13 int main()
14   {
15 
16 #if BOOST_PP_VARIADICS
17 
18  #define USE_VA_OPT BOOST_PP_VARIADIC_HAS_OPT()
19 
20  #define SMACRO() someoutput
21  #define EMACRO(x) otheroutput x
22 
23  BOOST_TEST(!BOOST_VMD_IS_EMPTY(SMACRO()));
24  BOOST_TEST(!BOOST_VMD_IS_EMPTY(EMACRO(somedata)));
25  BOOST_TEST(!BOOST_VMD_IS_EMPTY(EMACRO()));
26 
27  #define MMACRO(x,y,z) x y z
28 
29  BOOST_TEST(!BOOST_VMD_IS_EMPTY(MMACRO(1,,2)));
30 
31  #define VMACRO(x,...) x __VA_ARGS__
32 
33  BOOST_TEST(!BOOST_VMD_IS_EMPTY(VMACRO(somedata,)));
34  BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_VARIADIC_ELEM(1,VMACRO(somedata,vdata1,,vdata3))));
35 
36  #define TMACRO(x,atuple) x atuple
37 
38 #if !BOOST_VMD_MSVC_V8
39 
40  BOOST_TEST(!BOOST_VMD_IS_EMPTY(TMACRO(somedata,())));
41 
42 #endif
43 
44  BOOST_TEST(!BOOST_VMD_IS_EMPTY(TMACRO(somedata,(telem1,,telem2,teleem3))));
45 
46  #define RMACRO(x,y,z)
47 
48  BOOST_TEST(BOOST_VMD_IS_EMPTY(RMACRO(data1,data2,data3)));
49 
50 #if !BOOST_VMD_MSVC_V8
51 
52  #define TRETMACRO(x,y,z) ()
53 
54  BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(0,TRETMACRO(1,2,3))));
55 
56 #endif
57 
58  #define TRETMACRO1(x,y,z) (x,,y,,z)
59 
60  BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_TUPLE_ELEM(3,TRETMACRO1(1,2,3))));
61 
62  #define VRETMACRO(x,y,z) x,,y,,z
63 
64  BOOST_TEST(BOOST_VMD_IS_EMPTY(BOOST_PP_VARIADIC_ELEM(3,VRETMACRO(1,2,3))));
65 
66  #define FMACRO(x,y) any_output
67 
68  BOOST_TEST(!BOOST_VMD_IS_EMPTY(FMACRO(arg1,arg2)));
69  BOOST_TEST(!BOOST_VMD_IS_EMPTY(someinput FMACRO(arg1,arg2)));
70 
71 #if BOOST_VMD_MSVC
72 
73  BOOST_TEST(!BOOST_VMD_IS_EMPTY(FMACRO(1)));
74 
75 #endif
76 
77 #if BOOST_VMD_MSVC
78 
79  #define FMACRO1(parameter) FMACRO3 parameter()
80  #define FMACRO2() ()
81  #define FMACRO3() 1
82 
83  int MSVC_number_one = FMACRO1(FMACRO2);
84 
85 #endif
86 
87  #define FMACRO4() ( any_number_of_tuple_elements )
88  #define FMACRO5(param) ( any_number_of_tuple_elements )
89 
90 #if USE_VA_OPT
91 
92  #define FMACRO6(param1,param2) ( any_number_of_tuple_elements )
93 
94  BOOST_TEST(!BOOST_VMD_IS_EMPTY(FMACRO4));
95  BOOST_TEST(!BOOST_VMD_IS_EMPTY(FMACRO5));
96  BOOST_TEST(!BOOST_VMD_IS_EMPTY(FMACRO6));
97 
98 #elif BOOST_VMD_MSVC
99 
100  #define FMACRO6(param1,param2) ( any_number_of_tuple_elements )
101 
102  BOOST_TEST(BOOST_VMD_IS_EMPTY(FMACRO4));
103  BOOST_TEST(BOOST_VMD_IS_EMPTY(FMACRO5));
104  BOOST_TEST(BOOST_VMD_IS_EMPTY(FMACRO6));
105 
106 #else
107 
108  BOOST_TEST(!BOOST_VMD_IS_EMPTY(FMACRO4));
109  BOOST_TEST(!BOOST_VMD_IS_EMPTY(FMACRO5));
110 
111 #endif
112 
113 #else
114 
115 BOOST_ERROR("No variadic macro support");
116 
117 #endif
118 
119   return boost::report_errors();
120 
121   }
122