Merge pull request #201 from Kojoley/a-slightly-cleaner-n3031-workaround

A slightly cleaner N3031 workaround
This commit is contained in:
Kohei Takahashi
2018-10-18 08:17:24 +09:00
committed by GitHub
3 changed files with 21 additions and 16 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,26 @@ 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)
# if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
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
# include <boost/mpl/identity.hpp>
# define BOOST_FUSION_IDENTIFIED_TYPE(parenthesized_expr) \
boost::mpl::identity<decltype parenthesized_expr>::type::type
# define BOOST_FUSION_DECLTYPE_N3031(parenthesized_expr) \
boost::mpl::identity<decltype parenthesized_expr>::type
# endif
#else
# define BOOST_FUSION_IDENTIFIED_TYPE(parenthesized_expr) \
decltype parenthesized_expr ::type
# define BOOST_FUSION_DECLTYPE_N3031(parenthesized_expr) \
decltype parenthesized_expr
#endif