| 1 | /*! |
| 2 | @file |
| 3 | Defines `boost::hana::detail::variadic::reverse_apply_flat`. |
| 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_REVERSE_APPLY_FLAT_HPP |
| 11 | #define BOOST_HANA_DETAIL_VARIADIC_REVERSE_APPLY_FLAT_HPP |
| 12 | |
| 13 | #include <boost/hana/config.hpp> |
| 14 | #include <boost/hana/detail/variadic/at.hpp> |
| 15 | |
| 16 | #include <utility> |
| 17 | |
| 18 | |
| 19 | namespace boost { namespace hana { namespace detail { namespace variadic { |
| 20 | template <int ...i, typename F, typename ...X> |
| 21 | constexpr decltype(auto) |
| 22 | reverse_apply_flat_helper(std::integer_sequence<int, i...>, F&& f, X&& ...x) |
| 23 | { |
| 24 | return static_cast<F&&>(f)( |
| 25 | detail::variadic::at<sizeof...(x) - i - 1>( |
| 26 | static_cast<X&&>(x)... |
| 27 | )... |
| 28 | ); |
| 29 | } |
| 30 | |
| 31 | template <typename F, typename ...X> |
| 32 | constexpr decltype(auto) reverse_apply_flat(F&& f, X&& ...x) { |
| 33 | return reverse_apply_flat_helper( |
| 34 | std::make_integer_sequence<int, sizeof...(x)>{}, |
| 35 | static_cast<F&&>(f), |
| 36 | static_cast<X&&>(x)... |
| 37 | ); |
| 38 | } |
| 39 | }} }} // end namespace boost::hana |
| 40 | |
| 41 | #endif // !BOOST_HANA_DETAIL_VARIADIC_REVERSE_APPLY_FLAT_HPP |
| 42 | |