]>
Commit | Line | Data |
---|---|---|
1 | /*! | |
2 | @file | |
3 | Defines `boost::hana::detail::variadic::drop_into`. | |
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_DROP_INTO_HPP | |
11 | #define BOOST_HANA_DETAIL_VARIADIC_DROP_INTO_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 F, typename = std::make_index_sequence<n>> | |
21 | struct dropper; | |
22 | ||
23 | template <std::size_t n, typename F, std::size_t ...ignore> | |
24 | struct dropper<n, F, std::index_sequence<ignore...>> { | |
25 | F f; | |
26 | ||
27 | template <typename ...Rest> | |
28 | constexpr auto go(decltype(ignore, (void*)0)..., Rest ...rest) const | |
29 | { return f(*rest...); } | |
30 | ||
31 | template <typename ...Xs> | |
32 | constexpr auto operator()(Xs ...xs) const | |
33 | { return go(&xs...); } | |
34 | }; | |
35 | ||
36 | template <std::size_t n> | |
37 | struct make_dropper { | |
38 | template <typename F> | |
39 | constexpr auto operator()(F f) const | |
40 | { return dropper<n, decltype(f)>{f}; } | |
41 | }; | |
42 | ||
43 | template <std::size_t n> | |
44 | constexpr make_dropper<n> drop_into{}; | |
45 | }} BOOST_HANA_NAMESPACE_END | |
46 | ||
47 | #endif // !BOOST_HANA_DETAIL_VARIADIC_DROP_INTO_HPP |