From 2aea153be0d56781866052a7948cc1979e1563a4 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Wed, 14 Mar 2018 14:53:07 +0900 Subject: [PATCH 1/8] Use fold expression to improbe compile speed --- include/boost/fusion/support/detail/and.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/boost/fusion/support/detail/and.hpp b/include/boost/fusion/support/detail/and.hpp index 1b310dda..b45fb0e3 100644 --- a/include/boost/fusion/support/detail/and.hpp +++ b/include/boost/fusion/support/detail/and.hpp @@ -15,6 +15,7 @@ #endif namespace boost { namespace fusion { namespace detail { +#if defined(BOOST_NO_CXX17_FOLD_EXPRESSIONS) template struct and_impl : false_type {}; @@ -34,6 +35,10 @@ namespace boost { namespace fusion { namespace detail { recursive. */ template struct and_ : and_impl1 {}; +#else + template + struct and_ : integral_constant {}; +#endif }}} #endif // FUSION_AND_07152016_1625 From d8f608c8f1c2797ff26cacf0aaae437845b638ae Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Wed, 14 Mar 2018 14:53:30 +0900 Subject: [PATCH 2/8] Move is_native_fusion_sequence to detail in order to reuse it in is_mpl_sequence --- .../fusion/support/detail/is_mpl_sequence.hpp | 6 ++--- .../detail/is_native_fusion_sequence.hpp | 27 +++++++++++++++++++ include/boost/fusion/support/is_sequence.hpp | 13 ++------- 3 files changed, 31 insertions(+), 15 deletions(-) create mode 100644 include/boost/fusion/support/detail/is_native_fusion_sequence.hpp diff --git a/include/boost/fusion/support/detail/is_mpl_sequence.hpp b/include/boost/fusion/support/detail/is_mpl_sequence.hpp index 24b86624..16b6db12 100644 --- a/include/boost/fusion/support/detail/is_mpl_sequence.hpp +++ b/include/boost/fusion/support/detail/is_mpl_sequence.hpp @@ -9,19 +9,17 @@ #define FUSION_DETAIL_IS_MPL_SEQUENCE_29122006_1105 #include -#include +#include #include #include #include -#include -#include namespace boost { namespace fusion { namespace detail { template struct is_mpl_sequence : mpl::and_< - mpl::not_, is_convertible > > + mpl::not_ > , mpl::is_sequence > {}; }}} diff --git a/include/boost/fusion/support/detail/is_native_fusion_sequence.hpp b/include/boost/fusion/support/detail/is_native_fusion_sequence.hpp new file mode 100644 index 00000000..189c784d --- /dev/null +++ b/include/boost/fusion/support/detail/is_native_fusion_sequence.hpp @@ -0,0 +1,27 @@ +/*============================================================================= + Copyright (c) 2018 Kohei Takahashi + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#ifndef BOOST_FUSION_IS_NATIVE_FUSION_SEQUENCE +#define BOOST_FUSION_IS_NATIVE_FUSION_SEQUENCE + +#include +#include +#include +#include +#include + +namespace boost { namespace fusion { namespace detail +{ + template + struct is_native_fusion_sequence + : mpl::and_< + is_complete + , is_convertible + > + {}; +}}} + +#endif diff --git a/include/boost/fusion/support/is_sequence.hpp b/include/boost/fusion/support/is_sequence.hpp index af7c84e1..95a9423f 100644 --- a/include/boost/fusion/support/is_sequence.hpp +++ b/include/boost/fusion/support/is_sequence.hpp @@ -10,13 +10,10 @@ #include #include #include -#include +#include #include #include -#include -#include #include -#include namespace boost { namespace fusion { @@ -69,13 +66,7 @@ namespace boost { namespace fusion > {}; - template - struct is_native_fusion_sequence - : mpl::and_< - is_complete, - is_convertible - > - {}; + using detail::is_native_fusion_sequence; } }} From 11a3f250b82e9aa4525c5e6923531028d58b1950 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Thu, 15 Mar 2018 19:56:07 +0900 Subject: [PATCH 3/8] Remove unused header --- .../boost/fusion/support/detail/unknown_key.hpp | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 include/boost/fusion/support/detail/unknown_key.hpp diff --git a/include/boost/fusion/support/detail/unknown_key.hpp b/include/boost/fusion/support/detail/unknown_key.hpp deleted file mode 100644 index 9466b9c0..00000000 --- a/include/boost/fusion/support/detail/unknown_key.hpp +++ /dev/null @@ -1,16 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2011 Joel de Guzman - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(FUSION_UNKNOWN_KEY_09242005_1219) -#define FUSION_UNKNOWN_KEY_09242005_1219 - -namespace boost { namespace fusion { namespace detail -{ - template - struct unknown_key {}; -}}} - -#endif From e3b053f9695a7e85021c04920b3afaa07f2b1225 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Thu, 15 Mar 2018 20:49:38 +0900 Subject: [PATCH 4/8] Remove detail metafunctions to simplify template --- include/boost/fusion/support/category_of.hpp | 6 ++++-- .../fusion/support/detail/category_of.hpp | 19 ------------------- .../boost/fusion/support/detail/is_view.hpp | 19 ------------------- include/boost/fusion/support/is_view.hpp | 6 +++--- 4 files changed, 7 insertions(+), 43 deletions(-) delete mode 100644 include/boost/fusion/support/detail/category_of.hpp delete mode 100644 include/boost/fusion/support/detail/is_view.hpp diff --git a/include/boost/fusion/support/category_of.hpp b/include/boost/fusion/support/category_of.hpp index 92b0ea1b..7397c45a 100644 --- a/include/boost/fusion/support/category_of.hpp +++ b/include/boost/fusion/support/category_of.hpp @@ -8,7 +8,6 @@ #define FUSION_CATEGORY_OF_07202005_0308 #include -#include #include #include @@ -44,7 +43,10 @@ namespace boost { namespace fusion struct category_of_impl { template - struct apply : detail::fusion_category_of {}; + struct apply + { + typedef typename T::category type; + }; }; template <> diff --git a/include/boost/fusion/support/detail/category_of.hpp b/include/boost/fusion/support/detail/category_of.hpp deleted file mode 100644 index e7ac44e5..00000000 --- a/include/boost/fusion/support/detail/category_of.hpp +++ /dev/null @@ -1,19 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2011 Joel de Guzman - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(FUSION_CATEGORY_OF_07212005_1025) -#define FUSION_CATEGORY_OF_07212005_1025 - -namespace boost { namespace fusion { namespace detail -{ - template - struct fusion_category_of - { - typedef typename T::category type; - }; -}}} - -#endif diff --git a/include/boost/fusion/support/detail/is_view.hpp b/include/boost/fusion/support/detail/is_view.hpp deleted file mode 100644 index c518dfc4..00000000 --- a/include/boost/fusion/support/detail/is_view.hpp +++ /dev/null @@ -1,19 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2011 Joel de Guzman - - Distributed under the Boost Software License, Version 1.0. (See accompanying - file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -==============================================================================*/ -#if !defined(FUSION_IS_VIEW_03202006_0018) -#define FUSION_IS_VIEW_03202006_0018 - -namespace boost { namespace fusion { namespace detail -{ - template - struct fusion_is_view - { - typedef typename T::is_view type; - }; -}}} - -#endif diff --git a/include/boost/fusion/support/is_view.hpp b/include/boost/fusion/support/is_view.hpp index c54e60e1..a6ca7259 100644 --- a/include/boost/fusion/support/is_view.hpp +++ b/include/boost/fusion/support/is_view.hpp @@ -9,7 +9,6 @@ #include #include -#include #include namespace boost { namespace fusion @@ -28,8 +27,9 @@ namespace boost { namespace fusion { template struct apply - : detail::fusion_is_view - {}; + { + typedef typename T::is_view type; + }; }; template <> From 38aa3705d036c8841b6790dfe60ece4310efaf6f Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Fri, 27 Apr 2018 12:37:00 +0900 Subject: [PATCH 5/8] Added test for unused_type --- test/Jamfile | 1 + test/support/unused.cpp | 95 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 test/support/unused.cpp diff --git a/test/Jamfile b/test/Jamfile index a61239d0..3a358045 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -266,6 +266,7 @@ project [ compile support/and.cpp : [ requires cxx11_variadic_templates ] ] [ compile support/tag_of.cpp ] + [ compile support/unused.cpp ] # [ compile-fail xxx.cpp ] diff --git a/test/support/unused.cpp b/test/support/unused.cpp new file mode 100644 index 00000000..28d2ffda --- /dev/null +++ b/test/support/unused.cpp @@ -0,0 +1,95 @@ +/*============================================================================= + Copyright (c) 2018 Kohei Takahashi + + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ + +#include +#include +#include +#include +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES +#include +#endif + +struct T { }; + +void unused_construction() +{ + boost::fusion::unused_type dephault; + + boost::fusion::unused_type BOOST_ATTRIBUTE_UNUSED parenthesis(); +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + boost::fusion::unused_type BOOST_ATTRIBUTE_UNUSED brace{}; + boost::fusion::unused_type BOOST_ATTRIBUTE_UNUSED list_copy = {}; +#endif + + boost::fusion::unused_type copy_copy BOOST_ATTRIBUTE_UNUSED = dephault; + boost::fusion::unused_type copy_direct BOOST_ATTRIBUTE_UNUSED (dephault); +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + boost::fusion::unused_type copy_copy_brace_direct BOOST_ATTRIBUTE_UNUSED = {dephault}; + boost::fusion::unused_type copy_direct_brace BOOST_ATTRIBUTE_UNUSED {dephault}; +#endif + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + boost::fusion::unused_type move_copy BOOST_ATTRIBUTE_UNUSED = std::move(dephault); + boost::fusion::unused_type move_direct BOOST_ATTRIBUTE_UNUSED (std::move(dephault)); +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + boost::fusion::unused_type move_copy_brace_direct BOOST_ATTRIBUTE_UNUSED = {std::move(dephault)}; + boost::fusion::unused_type move_direct_brace BOOST_ATTRIBUTE_UNUSED {std::move(dephault)}; +#endif +#endif + + + T value; + + boost::fusion::unused_type T_copy_copy BOOST_ATTRIBUTE_UNUSED = value; + boost::fusion::unused_type T_copy_direct BOOST_ATTRIBUTE_UNUSED (value); +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + boost::fusion::unused_type T_copy_copy_brace_direct BOOST_ATTRIBUTE_UNUSED = {value}; + boost::fusion::unused_type T_copy_direct_brace BOOST_ATTRIBUTE_UNUSED {value}; +#endif + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + boost::fusion::unused_type T_move_copy BOOST_ATTRIBUTE_UNUSED = std::move(value); + boost::fusion::unused_type T_move_direct BOOST_ATTRIBUTE_UNUSED (std::move(value)); +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + boost::fusion::unused_type T_move_copy_brace_direct BOOST_ATTRIBUTE_UNUSED = {std::move(value)}; + boost::fusion::unused_type T_move_direct_brace BOOST_ATTRIBUTE_UNUSED {std::move(value)}; +#endif +#endif +} + +void unused_assignment() +{ + boost::fusion::unused_type val1, val2; + + val1 = val2; +#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX + val1 = {}; +#endif +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + val1 = std::move(val2); +#endif + + + T value; + + val1 = value; +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + val1 = std::move(value); +#endif +} + +boost::type_traits::yes_type test_unused(boost::fusion::detail::unused_only const&); +boost::type_traits::no_type test_unused(...); + +void only_unused() +{ + BOOST_STATIC_ASSERT((sizeof(test_unused(boost::fusion::unused)) == sizeof(boost::type_traits::yes_type))); + BOOST_STATIC_ASSERT((sizeof(test_unused(0)) == sizeof(boost::type_traits::no_type))); + + boost::fusion::unused_type my_unused; + BOOST_STATIC_ASSERT((sizeof(test_unused(my_unused)) == sizeof(boost::type_traits::yes_type))); +} From 0e900bba3fed9a0f98daad55f08d5647f51b80f1 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Fri, 27 Apr 2018 12:37:37 +0900 Subject: [PATCH 6/8] Specify defaulted and remove unnecessary functions from unused_type --- include/boost/fusion/support/unused.hpp | 36 +++++++------------------ 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/include/boost/fusion/support/unused.hpp b/include/boost/fusion/support/unused.hpp index 964839ab..1f65015e 100644 --- a/include/boost/fusion/support/unused.hpp +++ b/include/boost/fusion/support/unused.hpp @@ -1,5 +1,6 @@ /*============================================================================= Copyright (c) 2001-2011 Joel de Guzman + Copyright (c) 2018 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -10,7 +11,6 @@ #include #include -#include #if defined(BOOST_MSVC) # pragma warning(push) # pragma warning(disable: 4522) // multiple assignment operators specified warning @@ -23,9 +23,16 @@ namespace boost { namespace fusion struct unused_type { BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED - unused_type() BOOST_NOEXCEPT + BOOST_DEFAULTED_FUNCTION( + unused_type() BOOST_NOEXCEPT, { - } + }) + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + BOOST_DEFAULTED_FUNCTION( + unused_type(unused_type const&) BOOST_NOEXCEPT, + { + }) template BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED @@ -33,35 +40,12 @@ namespace boost { namespace fusion { } - template - BOOST_FUSION_CONSTEXPR_THIS BOOST_FUSION_GPU_ENABLED - unused_type const& - operator=(T const&) const BOOST_NOEXCEPT - { - return *this; - } - - template - BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED - unused_type& - operator=(T const&) BOOST_NOEXCEPT - { - return *this; - } - BOOST_FUSION_CONSTEXPR_THIS BOOST_FUSION_GPU_ENABLED unused_type const& operator=(unused_type const&) const BOOST_NOEXCEPT { return *this; } - - BOOST_CXX14_CONSTEXPR BOOST_FUSION_GPU_ENABLED - unused_type& - operator=(unused_type const&) BOOST_NOEXCEPT - { - return *this; - } }; BOOST_CONSTEXPR_OR_CONST unused_type unused = unused_type(); From 5221bbbc766e664a21727e591bae2c1f98b8ebd2 Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Fri, 27 Apr 2018 14:56:23 +0900 Subject: [PATCH 7/8] Added workaround for defaulted and noexcept --- include/boost/fusion/support/config.hpp | 10 +++++++++- include/boost/fusion/support/unused.hpp | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/boost/fusion/support/config.hpp b/include/boost/fusion/support/config.hpp index 23554531..16cd8f7f 100644 --- a/include/boost/fusion/support/config.hpp +++ b/include/boost/fusion/support/config.hpp @@ -1,6 +1,6 @@ /*============================================================================= Copyright (c) 2014 Eric Niebler - Copyright (c) 2014 Kohei Takahashi + Copyright (c) 2014,2015,2018 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -96,4 +96,12 @@ namespace std #define BOOST_FUSION_CONSTEXPR_THIS BOOST_CONSTEXPR #endif + +// Workaround for GCC 4.6 that rejects defaulted function with noexcept. +#if BOOST_WORKAROUND(BOOST_GCC, / 100 == 406) +# define BOOST_FUSION_NOEXCEPT_ON_DEFAULTED +#else +# define BOOST_FUSION_NOEXCEPT_ON_DEFAULTED BOOST_NOEXCEPT +#endif + #endif diff --git a/include/boost/fusion/support/unused.hpp b/include/boost/fusion/support/unused.hpp index 1f65015e..c376d07f 100644 --- a/include/boost/fusion/support/unused.hpp +++ b/include/boost/fusion/support/unused.hpp @@ -24,13 +24,13 @@ namespace boost { namespace fusion { BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_DEFAULTED_FUNCTION( - unused_type() BOOST_NOEXCEPT, + unused_type() BOOST_FUSION_NOEXCEPT_ON_DEFAULTED, { }) BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED BOOST_DEFAULTED_FUNCTION( - unused_type(unused_type const&) BOOST_NOEXCEPT, + unused_type(unused_type const&) BOOST_FUSION_NOEXCEPT_ON_DEFAULTED, { }) From 6f8de8d774c5d74f7ddaa032e408891448e25a2b Mon Sep 17 00:00:00 2001 From: Kohei Takahashi Date: Fri, 27 Apr 2018 20:29:06 +0900 Subject: [PATCH 8/8] Added workaround for fold expr and dependent name --- include/boost/fusion/support/detail/and.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/boost/fusion/support/detail/and.hpp b/include/boost/fusion/support/detail/and.hpp index b45fb0e3..42926cb1 100644 --- a/include/boost/fusion/support/detail/and.hpp +++ b/include/boost/fusion/support/detail/and.hpp @@ -1,5 +1,6 @@ /*============================================================================= Copyright (c) 2016 Lee Clagett + Copyright (c) 2018 Kohei Takahashi Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -8,6 +9,7 @@ #define FUSION_AND_07152016_1625 #include +#include #include #if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) @@ -15,7 +17,8 @@ #endif namespace boost { namespace fusion { namespace detail { -#if defined(BOOST_NO_CXX17_FOLD_EXPRESSIONS) +#if defined(BOOST_NO_CXX17_FOLD_EXPRESSIONS) \ + || BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1913)) template struct and_impl : false_type {};