diff --git a/include/boost/mp11/algorithm.hpp b/include/boost/mp11/algorithm.hpp index 309255c..cda0eb7 100644 --- a/include/boost/mp11/algorithm.hpp +++ b/include/boost/mp11/algorithm.hpp @@ -264,20 +264,29 @@ template using mp_iota = detail::mp_from_sequence struct mp_at_impl +template struct mp_at_c_impl; + +#if defined(BOOST_MP11_HAS_TYPE_PACK_ELEMENT) + +template class L, class... T, std::size_t I> struct mp_at_c_impl, I> { - static_assert( I::value >= 0, "mp_at: I must not be negative" ); - - using _map = mp_transform>, L>; - - using type = mp_second>>; + using type = __type_pack_element; }; +#else + +template struct mp_at_c_impl +{ + using _map = mp_transform>, L>; + using type = mp_second>>; +}; + +#endif + } // namespace detail -template using mp_at_c = typename detail::mp_at_impl>::type; - -template using mp_at = typename detail::mp_at_impl::type; +template using mp_at_c = typename detail::mp_at_c_impl::type; +template using mp_at = typename detail::mp_at_c_impl::type; // mp_take(_c) namespace detail diff --git a/include/boost/mp11/detail/config.hpp b/include/boost/mp11/detail/config.hpp index 3992cdc..75c5caa 100644 --- a/include/boost/mp11/detail/config.hpp +++ b/include/boost/mp11/detail/config.hpp @@ -29,4 +29,12 @@ # 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