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>
{
template <typename Sequence, typename Key>
struct apply
{
typedef typename BOOST_FUSION_IDENTIFIED_TYPE((
struct apply : BOOST_FUSION_DECLTYPE_N3031((
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>
{
template <typename Sequence, typename N>
struct apply
{
typedef typename BOOST_FUSION_IDENTIFIED_TYPE((
struct apply : BOOST_FUSION_DECLTYPE_N3031((
vector_detail::value_at_impl<N::value>(boost::declval<Sequence*>())
)) type;
};
))
{};
};
}
}}

View File

@ -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<T>.
// 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 <boost/mpl/identity.hpp>
# define BOOST_FUSION_IDENTIFIED_TYPE(parenthesized_expr) \
boost::mpl::identity<decltype parenthesized_expr>::type::type
namespace boost { namespace fusion { namespace detail
{
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
# define BOOST_FUSION_IDENTIFIED_TYPE(parenthesized_expr) \
decltype parenthesized_expr ::type
# define BOOST_FUSION_DECLTYPE_N3031(parenthesized_expr) \
decltype parenthesized_expr
#endif