A slightly cleaner N3031 workaround

This commit is contained in:
Nikita Kniazev
2018-10-12 00:34:20 +03:00
parent 6208b083fb
commit 2160949150
3 changed files with 16 additions and 17 deletions

View File

@ -24,12 +24,10 @@ namespace boost { namespace fusion
struct value_at_key_impl<map_tag> struct value_at_key_impl<map_tag>
{ {
template <typename Sequence, typename Key> template <typename Sequence, typename Key>
struct apply struct apply : BOOST_FUSION_DECLTYPE_N3031((
{
typedef typename BOOST_FUSION_IDENTIFIED_TYPE((
boost::declval<Sequence>().get_val(mpl::identity<Key>()) boost::declval<Sequence>().get_val(mpl::identity<Key>())
)) type; ))
}; {};
}; };
} }
}} }}

View File

@ -47,12 +47,10 @@ namespace boost { namespace fusion
struct value_at_impl<vector_tag> struct value_at_impl<vector_tag>
{ {
template <typename Sequence, typename N> template <typename Sequence, typename N>
struct apply struct apply : BOOST_FUSION_DECLTYPE_N3031((
{
typedef typename BOOST_FUSION_IDENTIFIED_TYPE((
vector_detail::value_at_impl<N::value>(boost::declval<Sequence*>()) vector_detail::value_at_impl<N::value>(boost::declval<Sequence*>())
)) type; ))
}; {};
}; };
} }
}} }}

View File

@ -97,17 +97,20 @@ namespace std
#endif #endif
// Workaround for compiler which doesn't compile decltype(expr)::type. // Workaround for compilers not implementing N3031 (DR743 and DR950).
// It expects decltype(expr) deduced as mpl::identity<T>.
#if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1913)) || \ #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1913)) || \
BOOST_WORKAROUND(BOOST_GCC, < 40700) || \ BOOST_WORKAROUND(BOOST_GCC, < 40700) || \
defined(BOOST_CLANG) && (__clang_major__ == 3 && __clang_minor__ == 0) defined(BOOST_CLANG) && (__clang_major__ == 3 && __clang_minor__ == 0)
# include <boost/mpl/identity.hpp> namespace boost { namespace fusion { namespace detail
# define BOOST_FUSION_IDENTIFIED_TYPE(parenthesized_expr) \ {
boost::mpl::identity<decltype parenthesized_expr>::type::type template <typename T>
using type_alias_t = T;
}}}
# define BOOST_FUSION_DECLTYPE_N3031(parenthesized_expr) \
boost::fusion::detail::type_alias_t<decltype parenthesized_expr>
#else #else
# define BOOST_FUSION_IDENTIFIED_TYPE(parenthesized_expr) \ # define BOOST_FUSION_DECLTYPE_N3031(parenthesized_expr) \
decltype parenthesized_expr ::type decltype parenthesized_expr
#endif #endif