Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 09:53:01

0001 /*!
0002 @file
0003 Defines `boost::hana::detail::type_at`.
0004 
0005 Copyright Louis Dionne 2013-2022
0006 Distributed under the Boost Software License, Version 1.0.
0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
0008  */
0009 
0010 #ifndef BOOST_HANA_DETAIL_TYPE_AT_HPP
0011 #define BOOST_HANA_DETAIL_TYPE_AT_HPP
0012 
0013 #include <boost/hana/config.hpp>
0014 
0015 #include <cstddef>
0016 #include <utility>
0017 
0018 
0019 // If possible, use an intrinsic provided by Clang
0020 #if defined(__has_builtin)
0021 #   if __has_builtin(__type_pack_element)
0022 #       define BOOST_HANA_USE_TYPE_PACK_ELEMENT_INTRINSIC
0023 #   endif
0024 #endif
0025 
0026 namespace boost { namespace hana { namespace detail {
0027     namespace td {
0028         template <std::size_t I, typename T>
0029         struct elt { using type = T; };
0030 
0031         template <typename Indices, typename ...T>
0032         struct indexer;
0033 
0034         template <std::size_t ...I, typename ...T>
0035         struct indexer<std::index_sequence<I...>, T...>
0036             : elt<I, T>...
0037         { };
0038 
0039         template <std::size_t I, typename T>
0040         elt<I, T> get_elt(elt<I, T> const&);
0041     }
0042 
0043     //! @ingroup group-details
0044     //! Classic MPL-style metafunction returning the nth element of a type
0045     //! parameter pack.
0046     template <std::size_t n, typename ...T>
0047     struct type_at {
0048 #if defined(BOOST_HANA_USE_TYPE_PACK_ELEMENT_INTRINSIC)
0049         using type = __type_pack_element<n, T...>;
0050 #else
0051         using Indexer = td::indexer<std::make_index_sequence<sizeof...(T)>, T...>;
0052         using type = typename decltype(td::get_elt<n>(Indexer{}))::type;
0053 #endif
0054     };
0055 } }} // end namespace boost::hana
0056 
0057 #endif // !BOOST_HANA_DETAIL_TYPE_AT_HPP