diff --git a/include/boost/contract/ext_/preprocessor/traits/assertion/namespace/name.hpp b/include/boost/contract/ext_/preprocessor/traits/assertion/namespace/name.hpp index 66700ca..f4c171b 100644 --- a/include/boost/contract/ext_/preprocessor/traits/assertion/namespace/name.hpp +++ b/include/boost/contract/ext_/preprocessor/traits/assertion/namespace/name.hpp @@ -5,6 +5,7 @@ #include #include #include +#include /* PUBLIC */ @@ -17,8 +18,10 @@ #define BOOST_CONTRACT_EXT_PP_NAMESPACE_ASSERTION_TRAITS_NAME_PARSE( \ decl_traits) \ - BOOST_CONTRACT_EXT_PP_NAMESPACE_ASSERTION_TRAITS_NAME_PARSE_ARGS_ \ - decl_traits + BOOST_PP_EXPAND( \ + BOOST_CONTRACT_EXT_PP_NAMESPACE_ASSERTION_TRAITS_NAME_PARSE_ARGS_ \ + decl_traits \ + ) /* PRIVATE */ diff --git a/include/boost/contract/ext_/preprocessor/traits/assertion/using/namespace.hpp b/include/boost/contract/ext_/preprocessor/traits/assertion/using/namespace.hpp index f41c551..8a96428 100644 --- a/include/boost/contract/ext_/preprocessor/traits/assertion/using/namespace.hpp +++ b/include/boost/contract/ext_/preprocessor/traits/assertion/using/namespace.hpp @@ -17,17 +17,6 @@ traits \ )() -// TODO: The EXPAND below seem to be needed at least on MSVC (and at least most -// of the times...). Apply EXPAND everywhere based on following rule: The -// general rule could be to use EXPAND whenever the macro invocation does not -// explicitly read the parameter list's parenthesis, for example: -// F(x) // explicit paren => no expand -// IF(c, F, G)(x, y) // explicit paren (after the IF) => no expand -// EXPAND(M IF(c, (x, y), (a, b))) // no explicit paren (they are "hidden" -// // inside IF(...)) => use expand -// M args // no explicit paren (they are "hidden" inside args = (x, y)) => -// // use expand - #define BOOST_CONTRACT_EXT_PP_USING_ASSERTION_TRAITS_NAMESPACE_PARSE( \ decl_traits) \ BOOST_PP_EXPAND( \ diff --git a/include/boost/contract/ext_/preprocessor/traits/base/classifiers.hpp b/include/boost/contract/ext_/preprocessor/traits/base/classifiers.hpp index d1860ce..1c0dd5b 100644 --- a/include/boost/contract/ext_/preprocessor/traits/base/classifiers.hpp +++ b/include/boost/contract/ext_/preprocessor/traits/base/classifiers.hpp @@ -25,7 +25,7 @@ BOOST_CONTRACT_EXT_PP_TRAITS_ELEM( \ BOOST_CONTRACT_EXT_PP_BASE_TRAITS_AUX_VIRTUAL_INDEX, traits)() -// Implementation: Do NOT use EXPAND here for proper macro expansion (on MSVC). +// Implementation: Do NOT use EXPAND for proper expansion (on MSVC). #define BOOST_CONTRACT_EXT_PP_BASE_TRAITS_CLASSIFIERS_PARSE(decl_traits) \ BOOST_CONTRACT_EXT_PP_BASE_TRAITS_VIRTUAL_1ST_CHECK_ decl_traits diff --git a/include/boost/contract/ext_/preprocessor/traits/base/type.hpp b/include/boost/contract/ext_/preprocessor/traits/base/type.hpp index c8bf476..aedfdd8 100644 --- a/include/boost/contract/ext_/preprocessor/traits/base/type.hpp +++ b/include/boost/contract/ext_/preprocessor/traits/base/type.hpp @@ -7,6 +7,7 @@ #include #include #include +#include /* PUBLIC */ @@ -23,7 +24,8 @@ /* PRIVATE */ #define BOOST_CONTRACT_EXT_PP_BASE_TRAITS_TYPE_PARSE_EXPAND_(decl_traits) \ - BOOST_CONTRACT_EXT_PP_BASE_TRAITS_TYPE_PARSE_ARGS_ decl_traits + BOOST_PP_EXPAND(BOOST_CONTRACT_EXT_PP_BASE_TRAITS_TYPE_PARSE_ARGS_ \ + decl_traits) #define BOOST_CONTRACT_EXT_PP_BASE_TRAITS_TYPE_PARSE_ARGS_(decl, traits) \ ( \ diff --git a/include/boost/contract/ext_/preprocessor/traits/func/except.hpp b/include/boost/contract/ext_/preprocessor/traits/func/except.hpp index 848bf4a..1db188e 100644 --- a/include/boost/contract/ext_/preprocessor/traits/func/except.hpp +++ b/include/boost/contract/ext_/preprocessor/traits/func/except.hpp @@ -19,7 +19,8 @@ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_EXCEPT_INDEX, traits)() #define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_EXCEPT_PARSE(decl_traits) \ - BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_EXCEPT_PARSE_ARGS_ decl_traits + BOOST_PP_EXPAND(BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_EXCEPT_PARSE_ARGS_ \ + decl_traits) /* PRIVATE */ diff --git a/include/boost/contract/ext_/preprocessor/traits/utility/type.hpp b/include/boost/contract/ext_/preprocessor/traits/utility/type.hpp index e3a0201..16583f1 100644 --- a/include/boost/contract/ext_/preprocessor/traits/utility/type.hpp +++ b/include/boost/contract/ext_/preprocessor/traits/utility/type.hpp @@ -82,7 +82,8 @@ // Extra level of indirection needed for proper macro expansion (on MSVC). #define BOOST_CONTRACT_EXT_PP_TYPE_TRAITS_SEQ_RETURN_(decl_type) \ - BOOST_CONTRACT_EXT_PP_TYPE_TRAITS_SEQ_RETURN_ARGS_ decl_type + BOOST_PP_EXPAND(BOOST_CONTRACT_EXT_PP_TYPE_TRAITS_SEQ_RETURN_ARGS_ \ + decl_type) // Remove an extra set of parenthesis around sequence (originally added to // handle commas by algorithms in common with spaced type traits). diff --git a/test/aux_/pp_1tuple_rem.hpp b/test/aux_/pp_1tuple_rem.hpp index 71ff602..799513f 100644 --- a/test/aux_/pp_1tuple_rem.hpp +++ b/test/aux_/pp_1tuple_rem.hpp @@ -12,8 +12,6 @@ /* PUBLIC */ -// TODO: Use this macro in all tests that need to remove type's parenthesis. - // Expand `(x)` to x, but `x` (no parenthesis) to `x` and `(x, ...)` (tuple // size > `) to `(x, ...)`. #define BOOST_CONTRACT_TEST_AUX_PP_1TUPLE_REM(tuple) \ diff --git a/test/pp_func_traits/params.cpp b/test/pp_func_traits/params.cpp index 8964655..73fdfe6 100644 --- a/test/pp_func_traits/params.cpp +++ b/test/pp_func_traits/params.cpp @@ -7,6 +7,7 @@ #define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_INDEX_TEST \ BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_AUX_PARAMS_INDEX #include "../aux_/pp_traits.hpp" +#include "../aux_/pp_1tuple_rem.hpp" #include #include #include @@ -18,20 +19,9 @@ #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. - -// Just for these tests, assumes all 1-tuples were specified without paren. -#define BOOST_CONTRACT_TEST_PAREN_REM_(trait) \ - BOOST_PP_EXPR_IIF(BOOST_PP_EQUAL(BOOST_PP_TUPLE_SIZE(trait), 1), \ - BOOST_PP_TUPLE_REM(0) \ - ) \ - trait - #define BOOST_CONTRACT_TEST_PARAM_(r, unused, i, param) \ BOOST_PP_COMMA_IF(i) \ - BOOST_CONTRACT_TEST_PAREN_REM_( \ + BOOST_CONTRACT_TEST_AUX_PP_1TUPLE_REM( \ BOOST_CONTRACT_EXT_PP_PARAM_TRAITS_TYPE(param)) \ BOOST_CONTRACT_EXT_PP_PARAM_TRAITS_NAME(param) \ BOOST_PP_IIF(BOOST_CONTRACT_EXT_PP_IS_EMPTY( \ @@ -41,7 +31,7 @@ BOOST_PP_TUPLE_REM(2) \ )( \ BOOST_PP_EMPTY(), \ - default BOOST_CONTRACT_TEST_PAREN_REM_( \ + default BOOST_CONTRACT_TEST_AUX_PP_1TUPLE_REM( \ BOOST_CONTRACT_EXT_PP_PARAM_TRAITS_DEFAULT(param)) \ )