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/vmd/is_identifier.hpp> 8 #include <boost/vmd/to_list.hpp> 9 #include <boost/vmd/equal.hpp> 10 #include <boost/detail/lightweight_test.hpp> 11 #include <boost/preprocessor/list/at.hpp> 12 #include <boost/preprocessor/list/size.hpp> 13 #include <boost/preprocessor/seq/elem.hpp> 14 #include <boost/preprocessor/tuple/elem.hpp> 15 main()16 int main() 17 { 18 19 #if BOOST_PP_VARIADICS 20 21 #define BOOST_VMD_REGISTER_ggh (ggh) 22 #define BOOST_VMD_DETECT_ggh_ggh 23 #define BOOST_VMD_REGISTER_dvd (dvd) 24 #define BOOST_VMD_DETECT_dvd_dvd 25 26 #define ANIDENTIFIER ggh 27 #define ANIDENTIFIER2 dvd 28 #define ANUMBER 249 29 #define ANUMBER2 17 30 #define ASEQ (25)(26)(27) 31 #define ATUPLE (0,1,2,3,((a,b))((c,d))((e))((f,g,h))) 32 #define ALIST (0,(1,(2,(3,BOOST_PP_NIL)))) 33 #define ANARRAY (3,(a,b,38)) 34 #define ASEQUENCE ANUMBER ALIST ATUPLE ANIDENTIFIER ANARRAY ASEQ 35 #define ASEQUENCE2 ANIDENTIFIER2 ASEQ ALIST ANUMBER ATUPLE 36 #define ASEQUENCE3 ASEQ ANUMBER2 ATUPLE 37 #define ASEQUENCE4 38 39 /* TO_LIST */ 40 41 BOOST_TEST_EQ(BOOST_PP_SEQ_ELEM(0,BOOST_PP_TUPLE_ELEM(1,BOOST_PP_LIST_AT(BOOST_VMD_TO_LIST(ASEQUENCE,BOOST_VMD_RETURN_TYPE),5))),25); 42 BOOST_TEST_EQ(BOOST_PP_TUPLE_ELEM(1,BOOST_PP_LIST_AT(BOOST_VMD_TO_LIST(ASEQUENCE2,BOOST_VMD_RETURN_TYPE),3)),249); 43 BOOST_TEST(BOOST_VMD_EQUAL(BOOST_PP_TUPLE_ELEM(0,BOOST_PP_LIST_AT(BOOST_VMD_TO_LIST(ASEQUENCE3,BOOST_VMD_RETURN_TYPE),2)),BOOST_VMD_TYPE_TUPLE,BOOST_VMD_TYPE_TYPE)); 44 BOOST_TEST_EQ(BOOST_PP_LIST_SIZE(BOOST_VMD_TO_LIST(ASEQUENCE4,BOOST_VMD_RETURN_TYPE)),0); 45 46 /* TO_LIST_DATA */ 47 48 BOOST_TEST_EQ(BOOST_PP_TUPLE_ELEM(3,BOOST_PP_LIST_AT(BOOST_VMD_TO_LIST(ASEQUENCE),2)),3); 49 BOOST_TEST(BOOST_VMD_IS_IDENTIFIER(BOOST_PP_LIST_AT(BOOST_VMD_TO_LIST(ASEQUENCE2),0),(aaa,bbb,dvd))); 50 BOOST_TEST_EQ(BOOST_PP_TUPLE_ELEM(0,BOOST_PP_LIST_AT(BOOST_VMD_TO_LIST(ASEQUENCE3),2)),0); 51 BOOST_TEST_EQ(BOOST_PP_LIST_SIZE(BOOST_VMD_TO_LIST(ASEQUENCE4)),0); 52 53 #else 54 55 BOOST_ERROR("No variadic macro support"); 56 57 #endif 58 59 return boost::report_errors(); 60 61 } 62