| 1 | /*! |
| 2 | @file |
| 3 | Defines `boost::hana::detail::variadic::at`. |
| 4 | |
| 5 | Copyright Louis Dionne 2013-2022 |
| 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) |
| 8 | */ |
| 9 | |
| 10 | #ifndef BOOST_HANA_DETAIL_VARIADIC_AT_HPP |
| 11 | #define BOOST_HANA_DETAIL_VARIADIC_AT_HPP |
| 12 | |
| 13 | #include <boost/hana/config.hpp> |
| 14 | |
| 15 | #include <cstddef> |
| 16 | #include <utility> |
| 17 | |
| 18 | |
| 19 | namespace boost { namespace hana { namespace detail { namespace variadic { |
| 20 | template <std::size_t n, typename = std::make_index_sequence<n>> |
| 21 | struct at_type; |
| 22 | |
| 23 | template <std::size_t n, std::size_t ...ignore> |
| 24 | struct at_type<n, std::index_sequence<ignore...>> { |
| 25 | private: |
| 26 | template <typename Nth> |
| 27 | static constexpr auto go(decltype(ignore, (void*)0)..., Nth nth, ...) |
| 28 | { return nth; } |
| 29 | |
| 30 | public: |
| 31 | template <typename ...Xs> |
| 32 | constexpr auto operator()(Xs ...xs) const |
| 33 | { return *go(&xs...); } |
| 34 | }; |
| 35 | |
| 36 | template <std::size_t n> |
| 37 | BOOST_HANA_INLINE_VARIABLE constexpr at_type<n> at{}; |
| 38 | }} }} // end namespace boost::hana |
| 39 | |
| 40 | #endif // !BOOST_HANA_DETAIL_VARIADIC_AT_HPP |
| 41 | |