forked from boostorg/mp11
Use __type_pack_element in mp_at(_c)
This commit is contained in:
@@ -264,20 +264,29 @@ template<class N> using mp_iota = detail::mp_from_sequence<make_integer_sequence
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
template<class L, class I> struct mp_at_impl
|
template<class L, std::size_t I> struct mp_at_c_impl;
|
||||||
|
|
||||||
|
#if defined(BOOST_MP11_HAS_TYPE_PACK_ELEMENT)
|
||||||
|
|
||||||
|
template<template<class...> class L, class... T, std::size_t I> struct mp_at_c_impl<L<T...>, I>
|
||||||
{
|
{
|
||||||
static_assert( I::value >= 0, "mp_at<L, I>: I must not be negative" );
|
using type = __type_pack_element<I, T...>;
|
||||||
|
|
||||||
using _map = mp_transform<mp_list, mp_iota<mp_size<L>>, L>;
|
|
||||||
|
|
||||||
using type = mp_second<mp_map_find<_map, mp_size_t<I::value>>>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
template<class L, std::size_t I> struct mp_at_c_impl
|
||||||
|
{
|
||||||
|
using _map = mp_transform<mp_list, mp_iota<mp_size<L>>, L>;
|
||||||
|
using type = mp_second<mp_map_find<_map, mp_size_t<I>>>;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
template<class L, std::size_t I> using mp_at_c = typename detail::mp_at_impl<L, mp_size_t<I>>::type;
|
template<class L, std::size_t I> using mp_at_c = typename detail::mp_at_c_impl<L, I>::type;
|
||||||
|
template<class L, class I> using mp_at = typename detail::mp_at_c_impl<L, std::size_t{ I::value }>::type;
|
||||||
template<class L, class I> using mp_at = typename detail::mp_at_impl<L, I>::type;
|
|
||||||
|
|
||||||
// mp_take(_c)<L, N>
|
// mp_take(_c)<L, N>
|
||||||
namespace detail
|
namespace detail
|
||||||
|
@@ -29,4 +29,12 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__has_builtin)
|
||||||
|
# if __has_builtin(__type_pack_element)
|
||||||
|
|
||||||
|
# define BOOST_MP11_HAS_TYPE_PACK_ELEMENT
|
||||||
|
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // #ifndef BOOST_MP11_DETAIL_CONFIG_HPP_INCLUDED
|
#endif // #ifndef BOOST_MP11_DETAIL_CONFIG_HPP_INCLUDED
|
||||||
|
Reference in New Issue
Block a user