#include #if !BOOST_PP_VARIADICS # error "this compiler does not support variadic macros" #else #include #define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_INDEX_TEST \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_TEMPLATE_INDEX #include "../aux_/pp_traits.hpp" #include #include #include #include #include #include #include #include #include #include #include // NOTE: Some extra test macros are necessary here to regenerate the decl back // from the parsed trait to check if the parsing was correct. But, at the end // these are valuable tests also because they use the PARAM_TRAITS macros. // Assume all 1-tuple types were specified without parenthesis. This is usually // NOT true, but it is true in these tests. This is relevant only in these // tests where generated code must match original declaration and its // parenthesis (the extra parenthesis of the original declaration do not need // to be reproduced when generating C++ code so this assumption is not // necessary). #define BOOST_CONTRACT_TEST_TEMPLATE_PARAM_REM_YES_(type) \ BOOST_PP_EXPR_IIF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_SIZE(type), 1), \ BOOST_PP_TUPLE_REM(0) \ ) \ type #define BOOST_CONTRACT_TEST_TEMPLATE_PARAM_REM_(type) \ BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_HAS_PAREN(type), \ BOOST_CONTRACT_TEST_TEMPLATE_PARAM_REM_YES_ \ , \ BOOST_PP_TUPLE_REM(1) \ )(type) #define BOOST_CONTRACT_TEST_TEMPLATE_PARAM_(r, unused, i, template_param) \ BOOST_PP_COMMA_IF(i) \ BOOST_CONTRACT_TEST_TEMPLATE_PARAM_REM_( \ BOOST_CONTRACT_EXT_PP_PARAM_TRAITS_TYPE(template_param)) \ BOOST_CONTRACT_EXT_PP_PARAM_TRAITS_NAME(template_param) \ BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_IS_EMPTY( \ BOOST_CONTRACT_EXT_PP_PARAM_TRAITS_DEFAULT(template_param)), \ BOOST_PP_TUPLE_EAT(2) \ , \ BOOST_PP_TUPLE_REM(2) \ )( \ BOOST_PP_EMPTY(), \ default BOOST_CONTRACT_EXT_PP_PARAM_TRAITS_DEFAULT(template_param) \ ) #define BOOST_CONTRACT_TEST_TEMPLATE_PARAMS_(func_traits) \ ( \ BOOST_PP_LIST_FOR_EACH_I(BOOST_CONTRACT_TEST_TEMPLATE_PARAM_, ~, \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_TEMPLATE_PARAMS(func_traits))\ ) #define BOOST_CONTRACT_TEST_TEMPLATE_(func_traits) \ BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_IS_EMPTY( \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_TEMPLATE(func_traits)), \ BOOST_PP_TUPLE_EAT(1) \ , \ template BOOST_CONTRACT_TEST_TEMPLATE_PARAMS_ \ )(func_traits) #define BOOST_CONTRACT_TEST_(template_params) \ BOOST_CONTRACT_TEST_AUX_PP_TRAITS( \ BOOST_CONTRACT_TEST_TEMPLATE_, \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS, \ BOOST_PP_EMPTY(), \ template_params, \ (std::map&) (f) ( int x, (std::map&) y ), \ template_params \ ) int main ( ) { // Test no template. BOOST_CONTRACT_TEST_( BOOST_PP_EMPTY() ) // Test template with no parameter. BOOST_CONTRACT_TEST_( template( ) ) // Test named typename. BOOST_CONTRACT_TEST_( template( typename T ) ) // Test named typename with default. BOOST_CONTRACT_TEST_( template( typename T, default (std::map) ) ) // Test named variadic typename. BOOST_CONTRACT_TEST_( template( typename... T) ) // Test unnamed typename. BOOST_CONTRACT_TEST_( template( typename ) ) // Test unnamed typename with default. BOOST_CONTRACT_TEST_( template( typename, default (std::map) ) ) // Test unnamed variadic typename. BOOST_CONTRACT_TEST_( template( typename... ) ) // Test named class. BOOST_CONTRACT_TEST_( template( class T ) ) // Test named class with default. BOOST_CONTRACT_TEST_( template( class T, default (std::map) ) ) // Test named variadic class. BOOST_CONTRACT_TEST_( template( class... T) ) // Test unnamed class. BOOST_CONTRACT_TEST_( template( class ) ) // Test unnamed class with default. BOOST_CONTRACT_TEST_( template( class, default (std::map) ) ) // Test unnamed variadic class. BOOST_CONTRACT_TEST_( template( class... ) ) // Test named value. BOOST_CONTRACT_TEST_( template( int I ) ) // Test named value with default. BOOST_CONTRACT_TEST_( template( int I, default 123 ) ) // Test unnamed value. BOOST_CONTRACT_TEST_( template( int ) ) // Test unnamed value with default. BOOST_CONTRACT_TEST_( template( int, default 123 ) ) // Test named value (of parenthesized type). BOOST_CONTRACT_TEST_( template( (std::map::key_type) I ) ) // Test named value (of parenthesized type) with default. BOOST_CONTRACT_TEST_( template( (std::map::key_type) I, default 123 ) ) // Test unnamed value (of parenthesized type). BOOST_CONTRACT_TEST_( template( (std::map::key_type) ) ) // Test unnamed value (of parenthesized type) with default. BOOST_CONTRACT_TEST_( template( (std::map::key_type), default 123 ) ) // Test template-template parameter with no parameters. BOOST_CONTRACT_TEST_( template( template( ) class P ) ) // Test template-template parameter with parameters. BOOST_CONTRACT_TEST_( template( template( typename T, class C, std::map::key_type I, typename... V ) class P ) ) // Test template-template parameter with defaults. BOOST_CONTRACT_TEST_( template( template( typename T = std::map::key_type, class C = std::map::key_type, std::map::key_type I = 123, typename... V ) class P, default (::n::c::template t) ) ) // Test template-template parameter with unnamed parameters. BOOST_CONTRACT_TEST_( template( template( typename, class, std::map::key_type, typename... ) class ) ) // Test template-template parameter with unnamed and defaults. BOOST_CONTRACT_TEST_( template( template( typename = std::map::key_type, class = std::map::key_type, std::map::key_type = 123, typename... ) class, default (::n::c::template t) ) ) return BOOST_CONTRACT_TEST_AUX_PP_TRAITS_REPORT_ERRORS; } #endif // variadics