From 6704b09dcf66ae7d52e04ab5b9c66cc157f27c8c Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Thu, 24 Sep 2020 06:07:26 -0400 Subject: [PATCH] =?UTF-8?q?It=20normally=20should=20not=20be=20necessary?= =?UTF-8?q?=20to=20use=20the=20=5FZ=20form=20of=20the=20BOOST=5FP=E2=80=A6?= =?UTF-8?q?=20(#52)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * It normally should not be necessary to use the _Z form of the BOOST_PP_ENUM macro, although it is perfectly legal and helpful to do so, but in this case it is necessary as a workaround for a bug in the new VC++ standard conforming preprocessor. The bug manifests itself when testing the TTI library, which internally uses the Boost MPL code. The bug in the new VC++ standard conforming compiler is fixed in the VS2019 preview product, so that fix is sure to find its way to the official VS2019 product sometime soon. In the meantime this "fix" shortens the macro expansion somewhat and, while it should not be necessary, is still helpful. * Fix for appveyor.yml file * Added VS2019 tests, also with new preprocessor. Further MPL Fixes for new preprocessor bug, which are also useful and will speed up preprocessing. * Can't seem to test msvc-10.0 or msvc-11.0 any more with Appveyor * Update description --- appveyor.yml | 22 +++++++++++++++---- include/boost/mpl/aux_/preprocessor/enum.hpp | 12 ++++++++++ .../boost/mpl/aux_/preprocessor/params.hpp | 12 ++++++++++ include/boost/mpl/has_xxx.hpp | 4 ++-- include/boost/mpl/string.hpp | 12 +++++----- test/apply_wrap.cpp | 22 +++++++++---------- test/aux_/increased_arity.cpp | 6 ++--- 7 files changed, 64 insertions(+), 26 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 434186f..6ce28df 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -45,6 +45,19 @@ environment: B2_VARIANT: variant=release,debug matrix: + - FLAVOR: Visual Studio 2019 All Modes + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + TOOLSET: msvc-14.2 + B2_ADDRESS_MODEL: address-model=64,32 + CXXSTD: 14,17,latest + + - FLAVOR: Visual Studio 2019 New Preprocessor + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + TOOLSET: msvc-14.2 + B2_ADDRESS_MODEL: address-model=64,32 + CXXFLAGS: cxxflags="/Zc:preprocessor" + CXXSTD: 14,17,latest + - FLAVOR: Visual Studio 2017 C++2a Strict APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 TOOLSET: msvc-14.1 @@ -68,9 +81,10 @@ environment: TOOLSET: msvc-14.0 B2_ADDRESS_MODEL: address-model=64,32 - - FLAVOR: Visual Studio 2010, 2012, 2013 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2013 - TOOLSET: msvc-10.0,msvc-11.0,msvc-12.0 + - FLAVOR: Visual Studio 2012 + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + TOOLSET: msvc-12.0 + B2_ADDRESS_MODEL: address-model=64,32 - FLAVOR: cygwin (32-bit) APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 @@ -104,7 +118,7 @@ environment: ARCH: x86_64 B2_ADDRESS_MODEL: address-model=64 CXXSTD: 11,17 - DEFINES: define=__USE_ISOC99 + B2_DEFINES: define=__USE_ISOC99 SCRIPT: ci\appveyor\mingw.bat install: diff --git a/include/boost/mpl/aux_/preprocessor/enum.hpp b/include/boost/mpl/aux_/preprocessor/enum.hpp index 64c5e6a..92c5031 100644 --- a/include/boost/mpl/aux_/preprocessor/enum.hpp +++ b/include/boost/mpl/aux_/preprocessor/enum.hpp @@ -29,6 +29,10 @@ BOOST_PP_CAT(BOOST_MPL_PP_ENUM_,n)(param) \ /**/ +# define BOOST_MPL_PP_ENUM_Z(z_ignored, n, param) \ + BOOST_PP_CAT(BOOST_MPL_PP_ENUM_,n)(param) \ + /**/ + # define BOOST_MPL_PP_ENUM_0(p) # define BOOST_MPL_PP_ENUM_1(p) p # define BOOST_MPL_PP_ENUM_2(p) p,p @@ -57,6 +61,14 @@ ) \ /**/ +# define BOOST_MPL_PP_ENUM_Z(z, n, param) \ + BOOST_PP_REPEAT_ ## z( \ + n \ + , BOOST_MPL_PP_AUX_ENUM_FUNC \ + , param \ + ) \ + /**/ + #endif #endif // BOOST_MPL_AUX_PREPROCESSOR_ENUM_HPP_INCLUDED diff --git a/include/boost/mpl/aux_/preprocessor/params.hpp b/include/boost/mpl/aux_/preprocessor/params.hpp index acad321..c3ee6c1 100644 --- a/include/boost/mpl/aux_/preprocessor/params.hpp +++ b/include/boost/mpl/aux_/preprocessor/params.hpp @@ -29,6 +29,10 @@ BOOST_PP_CAT(BOOST_MPL_PP_PARAMS_,n)(p) \ /**/ +# define BOOST_MPL_PP_PARAMS_Z(z_ignored,n,p) \ + BOOST_PP_CAT(BOOST_MPL_PP_PARAMS_,n)(p) \ + /**/ + # define BOOST_MPL_PP_PARAMS_0(p) # define BOOST_MPL_PP_PARAMS_1(p) p##1 # define BOOST_MPL_PP_PARAMS_2(p) p##1,p##2 @@ -60,6 +64,14 @@ ) \ /**/ +# define BOOST_MPL_PP_PARAMS_Z(z, n, param) \ + BOOST_PP_REPEAT_ ## z( \ + n \ + , BOOST_MPL_PP_AUX_PARAM_FUNC \ + , param \ + ) \ + /**/ + #endif #endif // BOOST_MPL_AUX_PREPROCESSOR_PARAMS_HPP_INCLUDED diff --git a/include/boost/mpl/has_xxx.hpp b/include/boost/mpl/has_xxx.hpp index 8a65c1f..a59c35d 100644 --- a/include/boost/mpl/has_xxx.hpp +++ b/include/boost/mpl/has_xxx.hpp @@ -334,7 +334,7 @@ struct trait \ // correct name but different number of arguments. # define BOOST_MPL_HAS_MEMBER_MULTI_SUBSTITUTE(z, n, args) \ template< \ - template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n), typename V) > class V \ + template< BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_INC(n), typename V) > class V \ > \ struct BOOST_MPL_HAS_MEMBER_INTROSPECTION_SUBSTITUTE_NAME(args, n) { \ }; \ @@ -503,7 +503,7 @@ struct trait \ z, n, args \ ) \ template< \ - template< BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(n), typename U) > class U \ + template< BOOST_PP_ENUM_PARAMS_Z(z, BOOST_PP_INC(n), typename U) > class U \ > \ struct BOOST_MPL_HAS_MEMBER_INTROSPECTION_SUBSTITUTE_NAME_WITH_TEMPLATE_SFINAE( \ args, n \ diff --git a/include/boost/mpl/string.hpp b/include/boost/mpl/string.hpp index e789856..fd3100c 100644 --- a/include/boost/mpl/string.hpp +++ b/include/boost/mpl/string.hpp @@ -500,11 +500,11 @@ namespace boost { namespace mpl }; #define M0(z, n, data) \ - template \ - struct string_iterator, n, J> \ + template \ + struct string_iterator, n, J> \ { \ enum { eomc_ = (BOOST_MPL_MULTICHAR_LENGTH(BOOST_PP_CAT(C, n)) == J + 1) }; \ - typedef mpl::string string; \ + typedef mpl::string string; \ typedef std::bidirectional_iterator_tag category; \ typedef \ mpl::string_iterator \ @@ -514,11 +514,11 @@ namespace boost { namespace mpl prior; \ typedef mpl::char_ type; \ }; \ - template \ - struct string_iterator, n, 0> \ + template \ + struct string_iterator, n, 0> \ { \ enum { eomc_ = (BOOST_MPL_MULTICHAR_LENGTH(BOOST_PP_CAT(C, n)) == 1) }; \ - typedef mpl::string string; \ + typedef mpl::string string; \ typedef std::bidirectional_iterator_tag category; \ typedef \ mpl::string_iterator \ diff --git a/test/apply_wrap.cpp b/test/apply_wrap.cpp index 9c45f2e..851a817 100644 --- a/test/apply_wrap.cpp +++ b/test/apply_wrap.cpp @@ -24,14 +24,14 @@ #include #if !defined(BOOST_MPL_CFG_NO_DEFAULT_PARAMETERS_IN_NESTED_TEMPLATES) -# define APPLY_0_FUNC_DEF(i) \ +# define APPLY_0_FUNC_DEF(z_ignored,i) \ struct f0 \ { \ template< typename T = int > struct apply { typedef char type; }; \ }; \ /**/ #else -# define APPLY_0_FUNC_DEF(i) \ +# define APPLY_0_FUNC_DEF(z_ignored,i) \ struct f0 \ { \ template< typename T > struct apply { typedef char type; }; \ @@ -39,16 +39,16 @@ /**/ #endif -#define APPLY_N_FUNC_DEF(i) \ +#define APPLY_N_FUNC_DEF(z,i) \ struct first##i \ { \ - template< BOOST_MPL_PP_PARAMS(i, typename U) > \ + template< BOOST_MPL_PP_PARAMS_Z(z, i, typename U) > \ struct apply { typedef U1 type; }; \ }; \ \ struct last##i \ { \ - template< BOOST_MPL_PP_PARAMS(i, typename U) > \ + template< BOOST_MPL_PP_PARAMS_Z(z, i, typename U) > \ struct apply { typedef BOOST_PP_CAT(U,i) type; }; \ }; \ /**/ @@ -58,7 +58,7 @@ i \ , APPLY_N_FUNC_DEF \ , APPLY_0_FUNC_DEF \ - )(i) \ + )(z,i) \ /**/ namespace { namespace test { @@ -73,22 +73,22 @@ struct g0 { struct apply { typedef char type; }; }; }} -#define APPLY_0_TEST(i, apply_) \ +#define APPLY_0_TEST(z_ignored, i, apply_) \ typedef apply_::type t; \ { MPL_ASSERT(( boost::is_same )); } \ /**/ -#define APPLY_N_TEST(i, apply_) \ +#define APPLY_N_TEST(z, i, apply_) \ typedef apply_< \ test::first##i \ , char \ BOOST_PP_COMMA_IF(BOOST_PP_DEC(i)) \ - BOOST_MPL_PP_ENUM(BOOST_PP_DEC(i), int) \ + BOOST_MPL_PP_ENUM_Z(z, BOOST_PP_DEC(i), int) \ >::type t1##i; \ \ typedef apply_< \ test::last##i \ - , BOOST_MPL_PP_ENUM(BOOST_PP_DEC(i), int) \ + , BOOST_MPL_PP_ENUM_Z(z, BOOST_PP_DEC(i), int) \ BOOST_PP_COMMA_IF(BOOST_PP_DEC(i)) char \ >::type t2##i; \ { MPL_ASSERT(( boost::is_same )); } \ @@ -100,7 +100,7 @@ struct g0 { struct apply { typedef char type; }; }; i \ , APPLY_N_TEST \ , APPLY_0_TEST \ - )(i, BOOST_PP_CAT(apply_wrap,i)) \ + )(z, i, BOOST_PP_CAT(apply_wrap,i)) \ /**/ diff --git a/test/aux_/increased_arity.cpp b/test/aux_/increased_arity.cpp index 47a433d..1bfe192 100644 --- a/test/aux_/increased_arity.cpp +++ b/test/aux_/increased_arity.cpp @@ -25,11 +25,11 @@ #include #include -#define TEST_N_ARY(unused1, N, unused2) \ +#define TEST_N_ARY(z, N, unused2) \ static_assert_< \ apply< \ - and_, \ - BOOST_PP_ENUM_PARAMS(N, true_ BOOST_PP_INTERCEPT) \ + and_, \ + BOOST_PP_ENUM_PARAMS_Z(z, N, true_ BOOST_PP_INTERCEPT) \ > \ >(); \ /**/