3 Defines `boost::hana::detail::type_at`.
5 @copyright Louis Dionne 2013-2017
6 Distributed under the Boost Software License, Version 1.0.
7 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
10 #ifndef BOOST_HANA_DETAIL_TYPE_AT_HPP
11 #define BOOST_HANA_DETAIL_TYPE_AT_HPP
13 #include <boost/hana/config.hpp>
19 // If possible, use an intrinsic provided by Clang
20 #if defined(__has_builtin)
21 # if __has_builtin(__type_pack_element)
22 # define BOOST_HANA_USE_TYPE_PACK_ELEMENT_INTRINSIC
26 namespace boost { namespace hana { namespace detail {
28 template <std::size_t I, typename T>
29 struct elt { using type = T; };
31 template <typename Indices, typename ...T>
34 template <std::size_t ...I, typename ...T>
35 struct indexer<std::index_sequence<I...>, T...>
39 template <std::size_t I, typename T>
40 elt<I, T> get_elt(elt<I, T> const&);
43 //! @ingroup group-details
44 //! Classic MPL-style metafunction returning the nth element of a type
46 template <std::size_t n, typename ...T>
48 #if defined(BOOST_HANA_USE_TYPE_PACK_ELEMENT_INTRINSIC)
49 using type = __type_pack_element<n, T...>;
51 using Indexer = td::indexer<std::make_index_sequence<sizeof...(T)>, T...>;
52 using type = typename decltype(td::get_elt<n>(Indexer{}))::type;
55 } }} // end namespace boost::hana
57 #endif // !BOOST_HANA_DETAIL_TYPE_AT_HPP