File indexing completed on 2025-01-18 09:37:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_HANA_DETAIL_VARIADIC_TAKE_HPP
0011 #define BOOST_HANA_DETAIL_VARIADIC_TAKE_HPP
0012
0013 #include <boost/hana/config.hpp>
0014 #include <boost/hana/detail/variadic/split_at.hpp>
0015 #include <boost/hana/functional/always.hpp>
0016 #include <boost/hana/functional/reverse_partial.hpp>
0017
0018 #include <cstddef>
0019
0020
0021 namespace boost { namespace hana { namespace detail { namespace variadic {
0022 struct take_impl2 {
0023 template <typename F, typename ...Xs>
0024 constexpr decltype(auto) operator()(F&& f, Xs&& ...xs) const {
0025 return static_cast<F&&>(f)(static_cast<Xs&&>(xs)...);
0026 }
0027 };
0028
0029 struct take_impl1 {
0030 template <typename ...Xs>
0031 constexpr auto operator()(Xs&& ...xs) const {
0032 return hana::always(
0033 reverse_partial(take_impl2{},
0034 static_cast<Xs&&>(xs)...)
0035 );
0036 }
0037 };
0038
0039 template <std::size_t n>
0040 struct take_t {
0041 template <typename ...Xs>
0042 constexpr decltype(auto) operator()(Xs&& ...xs) const {
0043 return variadic::split_at<n>(static_cast<Xs&&>(xs)...)(take_impl1{});
0044 }
0045 };
0046
0047 template <std::size_t n>
0048 BOOST_HANA_INLINE_VARIABLE constexpr take_t<n> take{};
0049 }} }}
0050
0051 #endif