]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*! |
2 | @file | |
3 | Defines `boost::hana::detail::variadic::at`. | |
4 | ||
5 | @copyright Louis Dionne 2013-2016 | |
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 | BOOST_HANA_NAMESPACE_BEGIN 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 | constexpr at_type<n> at{}; | |
38 | }} BOOST_HANA_NAMESPACE_END | |
39 | ||
40 | #endif // !BOOST_HANA_DETAIL_VARIADIC_AT_HPP |