From 6bd644d43d5c40d41e7844ec34a9f38557498fab Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sat, 29 Oct 2016 14:40:47 +0900 Subject: [PATCH 1/4] Don't use iterator for copy/move assign op. --- .../adapted/struct/detail/define_struct.hpp | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/include/boost/fusion/adapted/struct/detail/define_struct.hpp b/include/boost/fusion/adapted/struct/detail/define_struct.hpp index 1b968e38..3217926d 100644 --- a/include/boost/fusion/adapted/struct/detail/define_struct.hpp +++ b/include/boost/fusion/adapted/struct/detail/define_struct.hpp @@ -61,8 +61,26 @@ {} // Use templated version instead. +#define BOOST_FUSION_DEFINE_STRUCT_COPY_ASSIGN_FILLER_I( \ + R, ATTRIBUTE_TUPLE_SIZE, I_, ATTRIBUTE) \ + \ + BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)= \ + other.BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE); + #define BOOST_FUSION_DEFINE_STRUCT_COPY_ASSIGN_OP( \ - ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) + ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \ + \ + BOOST_FUSION_GPU_ENABLED \ + self_type& operator=(self_type const& other) \ + { \ + BOOST_PP_SEQ_FOR_EACH_I_R( \ + 1, \ + BOOST_FUSION_DEFINE_STRUCT_COPY_ASSIGN_FILLER_I, \ + ATTRIBUTE_TUPLE_SIZE, \ + ATTRIBUTES_SEQ) \ + \ + return *this; \ + } #else // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS @@ -148,34 +166,18 @@ #define BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_FILLER_I( \ R, ATTRIBUTE_TUPLE_SIZE, I_, ATTRIBUTE) \ \ - BOOST_PP_EXPR_IF( \ - I_, \ - typedef typename \ - boost::fusion::result_of::next< \ - BOOST_PP_CAT(I,BOOST_PP_DEC(I_)) \ - >::type \ - BOOST_PP_CAT(I,I_); \ - BOOST_PP_CAT(I,I_) BOOST_PP_CAT(i,I_)= \ - boost::fusion::next(BOOST_PP_CAT(i,BOOST_PP_DEC(I_))); \ - ) \ - \ BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)=std::move( \ - boost::fusion::deref(BOOST_PP_CAT(i,I_))); + other.BOOST_PP_TUPLE_ELEM(ATTRIBUTE_TUPLE_SIZE,1,ATTRIBUTE)); #define BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_OP( \ ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \ \ BOOST_FUSION_GPU_ENABLED \ - self_type& operator=(self_type&& seq) \ + self_type& operator=(self_type&& other) \ { \ - typedef \ - boost::fusion::result_of::begin::type \ - I0; \ - I0 i0=boost::fusion::begin(seq); \ - \ BOOST_PP_SEQ_FOR_EACH_I_R( \ 1, \ - BOOST_FUSION_DEFINE_STRUCT_ASSIGN_FILLER_I, \ + BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_FILLER_I, \ ATTRIBUTE_TUPLE_SIZE, \ ATTRIBUTES_SEQ) \ \ From 490baac6e2dc1dc5ee70edcf16aa48a1fd3e76d0 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sat, 29 Oct 2016 15:34:49 +0900 Subject: [PATCH 2/4] Added workaround for older gcc. --- .../adapted/struct/detail/define_struct.hpp | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/include/boost/fusion/adapted/struct/detail/define_struct.hpp b/include/boost/fusion/adapted/struct/detail/define_struct.hpp index 3217926d..015cc23c 100644 --- a/include/boost/fusion/adapted/struct/detail/define_struct.hpp +++ b/include/boost/fusion/adapted/struct/detail/define_struct.hpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -142,7 +143,8 @@ #else // BOOST_NO_CXX11_RVALUE_REFERENCES -#ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS +#if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) \ + || BOOST_WORKAROUND(BOOST_GCC, < 40500) #define BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR_FILLER_I( \ R, ATTRIBUTE_TUPLE_SIZE, I, ATTRIBUTE) \ @@ -163,6 +165,18 @@ ATTRIBUTES_SEQ) \ {} +#else // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS + +#define BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR( \ + NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \ + \ + BOOST_FUSION_GPU_ENABLED NAME(self_type&&) = default; + +#endif // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS + +#if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) \ + || BOOST_WORKAROUND(BOOST_GCC, < 40600) + #define BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_FILLER_I( \ R, ATTRIBUTE_TUPLE_SIZE, I_, ATTRIBUTE) \ \ @@ -186,11 +200,6 @@ #else // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS -#define BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR( \ - NAME, ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \ - \ - BOOST_FUSION_GPU_ENABLED NAME(self_type&&) = default; - #define BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_OP( \ ATTRIBUTES_SEQ, ATTRIBUTE_TUPLE_SIZE) \ \ From 5135b5109bb703557b99a0341d7cc65908f2a9a0 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sat, 29 Oct 2016 20:57:06 +0900 Subject: [PATCH 3/4] Likewise. --- .../boost/fusion/adapted/struct/detail/define_struct.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/boost/fusion/adapted/struct/detail/define_struct.hpp b/include/boost/fusion/adapted/struct/detail/define_struct.hpp index 015cc23c..cb52ddff 100644 --- a/include/boost/fusion/adapted/struct/detail/define_struct.hpp +++ b/include/boost/fusion/adapted/struct/detail/define_struct.hpp @@ -144,7 +144,8 @@ #else // BOOST_NO_CXX11_RVALUE_REFERENCES #if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) \ - || BOOST_WORKAROUND(BOOST_GCC, < 40500) + || BOOST_WORKAROUND(BOOST_GCC, < 40500) \ + || BOOST_WORKAROUND(BOOST_MSVC, == 1800) #define BOOST_FUSION_DEFINE_STRUCT_MOVE_CTOR_FILLER_I( \ R, ATTRIBUTE_TUPLE_SIZE, I, ATTRIBUTE) \ @@ -175,7 +176,8 @@ #endif // BOOST_NO_CXX11_DEFAULTED_FUNCTIONS #if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) \ - || BOOST_WORKAROUND(BOOST_GCC, < 40600) + || BOOST_WORKAROUND(BOOST_GCC, < 40600) \ + || BOOST_WORKAROUND(BOOST_MSVC, == 1800) #define BOOST_FUSION_DEFINE_STRUCT_MOVE_ASSIGN_FILLER_I( \ R, ATTRIBUTE_TUPLE_SIZE, I_, ATTRIBUTE) \ From c158886591246a431282fa1f2d4ca98fffd8b61a Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Sat, 29 Oct 2016 21:29:26 +0900 Subject: [PATCH 4/4] Workaround for MSVC 12 variadics bug. --- include/boost/fusion/support/detail/and.hpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/boost/fusion/support/detail/and.hpp b/include/boost/fusion/support/detail/and.hpp index 8560f344..1b310dda 100644 --- a/include/boost/fusion/support/detail/and.hpp +++ b/include/boost/fusion/support/detail/and.hpp @@ -20,7 +20,11 @@ namespace boost { namespace fusion { namespace detail { template struct and_impl...> : true_type {}; - + + // This specialization is necessary to avoid MSVC-12 variadics bug. + template + struct and_impl1 : and_impl...> {}; + /* fusion::detail::and_ differs from mpl::and_ in the following ways: - The empty set is valid and returns true - A single element set is valid and returns the identity @@ -29,7 +33,7 @@ namespace boost { namespace fusion { namespace detail { reduces instantations when returning true; the implementation is not recursive. */ template - struct and_ : and_impl...> {}; + struct and_ : and_impl1 {}; }}} #endif // FUSION_AND_07152016_1625