testing some classifiers permutations

This commit is contained in:
Lorenzo Caminiti
2014-12-18 18:21:45 -08:00
parent 5cd9ec32a5
commit 33c0afdba3
10 changed files with 81 additions and 42 deletions

View File

@@ -8,12 +8,13 @@
// NOTE: All these levels of indirection (instead of doing the PP_CAT directly)
// are necessary to ensure proper macro expansion on MSVC which would otherwise
// get confused sometimes.
#define BOOST_CONTRACT_EXT_PP_KEYWORD_UTILITY_REMOVE_EXPAND1_(x) x
// get confused sometimes. Also, use its own implementation of EXPAND_ONCE to
// avoid reentrancy issues.
#define BOOST_CONTRACT_EXT_PP_KEYWORD_UTILITY_REMOVE_EXPAND_ONCE_(x) x
#define BOOST_CONTRACT_EXT_PP_KEYWORD_UTILITY_REMOVE_CAT_(a, b) \
BOOST_CONTRACT_EXT_PP_KEYWORD_UTILITY_REMOVE_EXPAND1_(BOOST_PP_CAT(a, b))
BOOST_CONTRACT_EXT_PP_KEYWORD_UTILITY_REMOVE_EXPAND_ONCE_( \
BOOST_PP_CAT(a, b))
/* PUBLIC */

View File

@@ -46,13 +46,13 @@
// NOTE: Using `BOOST_PP_TUPLE_ELEM(2, 0, sign_traits)` instead of this
// confuses MSVC macro expansion sometimes (OK on GCC, CLang, Wave, etc.).
#define BOOST_CONTRACT_EXT_PP_SIGN_TRAITS_FIRST(sign_traits) \
BOOST_CONTRACT_EXT_PP_EXPAND1( \
BOOST_CONTRACT_EXT_PP_EXPAND_ONCE( \
BOOST_CONTRACT_EXT_PP_SIGN_TRAITS_FIRST_ sign_traits)
// NOTE: Using `BOOST_PP_TUPLE_ELEM(2, 1, sign_traits)` instead of this
// confuses MSVC macro expansion sometimes (OK on GCC, CLang, Wave, etc.).
#define BOOST_CONTRACT_EXT_PP_SIGN_TRAITS_SECOND(sign_traits) \
BOOST_CONTRACT_EXT_PP_EXPAND1( \
BOOST_CONTRACT_EXT_PP_EXPAND_ONCE( \
BOOST_CONTRACT_EXT_PP_SIGN_TRAITS_SECOND_ sign_traits)
#endif // #include guard

View File

@@ -11,6 +11,7 @@
#include <boost/contract/ext_/preprocessor/keyword/friend.hpp>
#include <boost/contract/ext_/preprocessor/keyword/inline.hpp>
#include <boost/contract/ext_/preprocessor/utility/expand.hpp>
#include <boost/contract/ext_/preprocessor/utility/idem.hpp>
#include <boost/preprocessor/tuple/elem.hpp>
#include <boost/preprocessor/control/while.hpp>
#include <boost/preprocessor/control/iif.hpp>
@@ -32,7 +33,7 @@
#define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_CLASSIFIERS_OP_ARGS_(continue_, \
sign, inline_, static_, extern_, explicit_, virtual_, friend_) \
BOOST_CONTRACT_EXT_PP_EXPAND1( \
BOOST_CONTRACT_EXT_PP_EXPAND_ONCE( \
BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_CLASSIFIERS_SIGN_ \
BOOST_PP_IIF(BOOST_PP_BITAND(BOOST_PP_COMPL(inline_), \
BOOST_CONTRACT_EXT_PP_KEYWORD_IS_INLINE_FRONT(sign)), \
@@ -59,14 +60,14 @@
(1, BOOST_CONTRACT_EXT_PP_KEYWORD_FRIEND_REMOVE_FRONT, sign, \
inline_, static_, extern_, explicit_, virtual_, 1) \
, \
(0, BOOST_CONTRACT_EXT_PP_EXPAND1, sign, \
(0, BOOST_CONTRACT_EXT_PP_IDEM, sign, \
inline_, static_, extern_, explicit_, virtual_, friend_) \
)))))) \
)
#define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_CLASSIFIERS_OP_( \
d, continue_sign_inline_static_extern_explicit_virtual_friend) \
BOOST_CONTRACT_EXT_PP_EXPAND1( \
BOOST_CONTRACT_EXT_PP_EXPAND_ONCE( \
BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_CLASSIFIERS_OP_ARGS_ \
continue_sign_inline_static_extern_explicit_virtual_friend \
)

View File

@@ -39,10 +39,10 @@
#define BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_EXPORT_PARSE(sign_traits) \
( \
BOOST_CONTRACT_EXT_PP_EXPAND1( \
BOOST_CONTRACT_EXT_PP_EXPAND_ONCE( \
BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_EXPORT_SIGN_ sign_traits) \
, \
BOOST_CONTRACT_EXT_PP_EXPAND1( \
BOOST_CONTRACT_EXT_PP_EXPAND_ONCE( \
BOOST_CONTRACT_EXT_PP_FUNC_TRAITS_EXPORT_TRAIT_ sign_traits) \
)

View File

@@ -65,10 +65,10 @@
#define BOOST_CONTRACT_EXT_PP_TPARAM_TRAITS_KIND_PARSE(sign_traits) \
( \
BOOST_CONTRACT_EXT_PP_EXPAND1( \
BOOST_CONTRACT_EXT_PP_EXPAND_ONCE( \
BOOST_CONTRACT_EXT_PP_TPARAM_TRAITS_KIND_SIGN_ sign_traits) \
, \
BOOST_CONTRACT_EXT_PP_EXPAND1( \
BOOST_CONTRACT_EXT_PP_EXPAND_ONCE( \
BOOST_CONTRACT_EXT_PP_TPARAM_TRAITS_KIND_TRAIT_ sign_traits) \
)

View File

@@ -5,14 +5,19 @@
/* PUBLIC */
// Expand its argument once, `BOOST_PP_EXPAND` expands it twice instead:
// EXPAND1(x) --> x (x expanded once)
// EXPAND(x) --> EXPAND_(x) --> x (x expanded twice)
// NOTE: This macro is sometimes useful to enforce proper macro expansion on
// EXPAND_ONCE(x) --> x (x expanded once)
// EXPAND(x) --> EXPAND_(x) --> x (x expanded twice)
// This macro is sometimes useful to enforce proper macro expansion at least on
// MSVC (on better preprocessors like GCC, CLang, and Wave this macro is not
// necessary instead). For example, `EXPAND1(macro args) ...` where `args` is
// `(a, b EMPTY)` expands to `macro(a, b EMPTY) ...`. Otherwise, MSVC would
// necessary instead). For example, `EXPAND_ONCE(macro args) ...` where `args`
// is `(a, b EMPTY)` expands to `macro(a, b EMPTY) ...`. Otherwise, MSVC would
// sometimes confuse `...` as arguments for `EMPTY`, etc.
#define BOOST_CONTRACT_EXT_PP_EXPAND1(tokens) tokens
// NOTE:
// * In theory this macro is equivalent to `IDEM(tokens)` but these are
// logically different, plus not using both macros confuses MSVC sometimes.
// * In theory this macro is also equivalent to `BOOST_PP_REM(1) (tokens)`
// but again that confuses MSVC sometimes.
#define BOOST_CONTRACT_EXT_PP_EXPAND_ONCE(tokens) tokens
#endif // #include gaurd

View File

@@ -0,0 +1,16 @@
#ifndef BOOST_CONTRACT_EXT_PP_IDEM_HPP_
#define BOOST_CONTRACT_EXT_PP_IDEM_HPP_
/* PUBLIC */
// NOTE:
// * In theory this macro is equivalent to `EXPAND_ONCE(tokens)` but these
// are logically different plus not using both macros confuses MSVC
// sometimes.
// * In theory this macro is also equivalent to `BOOST_PP_REM(1) (tokens)`
// but again that confuses MSVC sometimes.
#define BOOST_CONTRACT_EXT_PP_IDEM(tokens) tokens
#endif // #include guard