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/config.hpp b/include/boost/fusion/support/config.hpp index 5a0f572e..d27266ed 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,2018 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) @@ -108,4 +108,12 @@ namespace std decltype parenthesized_expr ::type #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/detail/and.hpp b/include/boost/fusion/support/detail/and.hpp index 1b310dda..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,6 +17,8 @@ #endif namespace boost { namespace fusion { namespace detail { +#if defined(BOOST_NO_CXX17_FOLD_EXPRESSIONS) \ + || BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1913)) template struct and_impl : false_type {}; @@ -34,6 +38,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 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_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/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/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 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; } }} 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 <> diff --git a/include/boost/fusion/support/unused.hpp b/include/boost/fusion/support/unused.hpp index 964839ab..c376d07f 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_FUSION_NOEXCEPT_ON_DEFAULTED, { - } + }) + + BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED + BOOST_DEFAULTED_FUNCTION( + unused_type(unused_type const&) BOOST_FUSION_NOEXCEPT_ON_DEFAULTED, + { + }) 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(); diff --git a/test/Jamfile b/test/Jamfile index 9492e83f..9289033c 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -267,6 +267,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))); +}