From 21609491500d03e980885b3c3d49084e9637ce08 Mon Sep 17 00:00:00 2001 From: Nikita Kniazev Date: Fri, 12 Oct 2018 00:34:20 +0300 Subject: [PATCH] A slightly cleaner N3031 workaround --- .../container/map/detail/value_at_key_impl.hpp | 8 +++----- .../container/vector/detail/value_at_impl.hpp | 8 +++----- include/boost/fusion/support/config.hpp | 17 ++++++++++------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/include/boost/fusion/container/map/detail/value_at_key_impl.hpp b/include/boost/fusion/container/map/detail/value_at_key_impl.hpp index da6259e6..d53a8f02 100644 --- a/include/boost/fusion/container/map/detail/value_at_key_impl.hpp +++ b/include/boost/fusion/container/map/detail/value_at_key_impl.hpp @@ -24,12 +24,10 @@ namespace boost { namespace fusion struct value_at_key_impl { template - struct apply - { - typedef typename BOOST_FUSION_IDENTIFIED_TYPE(( + struct apply : BOOST_FUSION_DECLTYPE_N3031(( boost::declval().get_val(mpl::identity()) - )) type; - }; + )) + {}; }; } }} diff --git a/include/boost/fusion/container/vector/detail/value_at_impl.hpp b/include/boost/fusion/container/vector/detail/value_at_impl.hpp index a2dd5fcd..f29c0e14 100644 --- a/include/boost/fusion/container/vector/detail/value_at_impl.hpp +++ b/include/boost/fusion/container/vector/detail/value_at_impl.hpp @@ -47,12 +47,10 @@ namespace boost { namespace fusion struct value_at_impl { template - struct apply - { - typedef typename BOOST_FUSION_IDENTIFIED_TYPE(( + struct apply : BOOST_FUSION_DECLTYPE_N3031(( vector_detail::value_at_impl(boost::declval()) - )) type; - }; + )) + {}; }; } }} diff --git a/include/boost/fusion/support/config.hpp b/include/boost/fusion/support/config.hpp index 21630f3d..ca3ce126 100644 --- a/include/boost/fusion/support/config.hpp +++ b/include/boost/fusion/support/config.hpp @@ -97,17 +97,20 @@ namespace std #endif -// Workaround for compiler which doesn't compile decltype(expr)::type. -// It expects decltype(expr) deduced as mpl::identity. +// Workaround for compilers not implementing N3031 (DR743 and DR950). #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1913)) || \ BOOST_WORKAROUND(BOOST_GCC, < 40700) || \ defined(BOOST_CLANG) && (__clang_major__ == 3 && __clang_minor__ == 0) -# include -# define BOOST_FUSION_IDENTIFIED_TYPE(parenthesized_expr) \ - boost::mpl::identity::type::type +namespace boost { namespace fusion { namespace detail +{ + template + using type_alias_t = T; +}}} +# define BOOST_FUSION_DECLTYPE_N3031(parenthesized_expr) \ + boost::fusion::detail::type_alias_t #else -# define BOOST_FUSION_IDENTIFIED_TYPE(parenthesized_expr) \ - decltype parenthesized_expr ::type +# define BOOST_FUSION_DECLTYPE_N3031(parenthesized_expr) \ + decltype parenthesized_expr #endif