Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:37:41

0001 /*!
0002 @file
0003 Defines `boost::hana::detail::variadic::split_at`.
0004 
0005 Copyright Louis Dionne 2013-2022
0006 Distributed under the Boost Software License, Version 1.0.
0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
0008  */
0009 
0010 #ifndef BOOST_HANA_DETAIL_VARIADIC_SPLIT_AT_HPP
0011 #define BOOST_HANA_DETAIL_VARIADIC_SPLIT_AT_HPP
0012 
0013 #include <boost/hana/config.hpp>
0014 #include <boost/hana/functional/partial.hpp>
0015 #include <boost/hana/functional/reverse_partial.hpp>
0016 
0017 #include <cstddef>
0018 
0019 
0020 namespace boost { namespace hana { namespace detail { namespace variadic {
0021     template <std::size_t n>
0022     struct split_at_t {
0023         template <typename F, typename X1, typename X2, typename X3, typename X4, typename X5, typename X6, typename X7, typename X8, typename ...Xs>
0024         constexpr decltype(auto) operator()(F&& f, X1&& x1, X2&& x2, X3&& x3, X4&& x4, X5&& x5, X6&& x6, X7&& x7, X8&& x8, Xs&& ...xs) const {
0025             return split_at_t<n - 8>{}(
0026                 hana::partial(static_cast<F&&>(f),
0027                     static_cast<X1&&>(x1),
0028                     static_cast<X2&&>(x2),
0029                     static_cast<X3&&>(x3),
0030                     static_cast<X4&&>(x4),
0031                     static_cast<X5&&>(x5),
0032                     static_cast<X6&&>(x6),
0033                     static_cast<X7&&>(x7),
0034                     static_cast<X8&&>(x8)
0035                 ),
0036                 static_cast<Xs&&>(xs)...
0037             );
0038         }
0039     };
0040 
0041     template <>
0042     struct split_at_t<0> {
0043         template <typename F, typename ...Xs>
0044         constexpr decltype(auto) operator()(F&& f, Xs&& ...xs) const {
0045             return static_cast<F&&>(f)()(static_cast<Xs&&>(xs)...);
0046         }
0047     };
0048 
0049     template <>
0050     struct split_at_t<1> {
0051         template <typename F, typename X1, typename ...Xs>
0052         constexpr decltype(auto) operator()(F&& f, X1&& x1, Xs&& ...xs) const {
0053             return static_cast<F&&>(f)(
0054                 static_cast<X1&&>(x1)
0055             )(static_cast<Xs&&>(xs)...);
0056         }
0057     };
0058 
0059     template <>
0060     struct split_at_t<2> {
0061         template <typename F, typename X1, typename X2, typename ...Xs>
0062         constexpr decltype(auto) operator()(F&& f, X1&& x1, X2&& x2, Xs&& ...xs) const {
0063             return static_cast<F&&>(f)(
0064                 static_cast<X1&&>(x1),
0065                 static_cast<X2&&>(x2)
0066             )(static_cast<Xs&&>(xs)...);
0067         }
0068     };
0069 
0070     template <>
0071     struct split_at_t<3> {
0072         template <typename F, typename X1, typename X2, typename X3, typename ...Xs>
0073         constexpr decltype(auto) operator()(F&& f, X1&& x1, X2&& x2, X3&& x3, Xs&& ...xs) const {
0074             return static_cast<F&&>(f)(
0075                 static_cast<X1&&>(x1),
0076                 static_cast<X2&&>(x2),
0077                 static_cast<X3&&>(x3)
0078             )(static_cast<Xs&&>(xs)...);
0079         }
0080     };
0081 
0082     template <>
0083     struct split_at_t<4> {
0084         template <typename F, typename X1, typename X2, typename X3, typename X4, typename ...Xs>
0085         constexpr decltype(auto) operator()(F&& f, X1&& x1, X2&& x2, X3&& x3, X4&& x4, Xs&& ...xs) const {
0086             return static_cast<F&&>(f)(
0087                 static_cast<X1&&>(x1),
0088                 static_cast<X2&&>(x2),
0089                 static_cast<X3&&>(x3),
0090                 static_cast<X4&&>(x4)
0091             )(static_cast<Xs&&>(xs)...);
0092         }
0093     };
0094 
0095     template <>
0096     struct split_at_t<5> {
0097         template <typename F, typename X1, typename X2, typename X3, typename X4, typename X5, typename ...Xs>
0098         constexpr decltype(auto) operator()(F&& f, X1&& x1, X2&& x2, X3&& x3, X4&& x4, X5&& x5, Xs&& ...xs) const {
0099             return static_cast<F&&>(f)(
0100                 static_cast<X1&&>(x1),
0101                 static_cast<X2&&>(x2),
0102                 static_cast<X3&&>(x3),
0103                 static_cast<X4&&>(x4),
0104                 static_cast<X5&&>(x5)
0105             )(static_cast<Xs&&>(xs)...);
0106         }
0107     };
0108 
0109     template <>
0110     struct split_at_t<6> {
0111         template <typename F, typename X1, typename X2, typename X3, typename X4, typename X5, typename X6, typename ...Xs>
0112         constexpr decltype(auto) operator()(F&& f, X1&& x1, X2&& x2, X3&& x3, X4&& x4, X5&& x5, X6&& x6, Xs&& ...xs) const {
0113             return static_cast<F&&>(f)(
0114                 static_cast<X1&&>(x1),
0115                 static_cast<X2&&>(x2),
0116                 static_cast<X3&&>(x3),
0117                 static_cast<X4&&>(x4),
0118                 static_cast<X5&&>(x5),
0119                 static_cast<X6&&>(x6)
0120             )(static_cast<Xs&&>(xs)...);
0121         }
0122     };
0123 
0124     template <>
0125     struct split_at_t<7> {
0126         template <typename F, typename X1, typename X2, typename X3, typename X4, typename X5, typename X6, typename X7, typename ...Xs>
0127         constexpr decltype(auto) operator()(F&& f, X1&& x1, X2&& x2, X3&& x3, X4&& x4, X5&& x5, X6&& x6, X7&& x7, Xs&& ...xs) const {
0128             return static_cast<F&&>(f)(
0129                 static_cast<X1&&>(x1),
0130                 static_cast<X2&&>(x2),
0131                 static_cast<X3&&>(x3),
0132                 static_cast<X4&&>(x4),
0133                 static_cast<X5&&>(x5),
0134                 static_cast<X6&&>(x6),
0135                 static_cast<X7&&>(x7)
0136             )(static_cast<Xs&&>(xs)...);
0137         }
0138     };
0139 
0140     template <std::size_t n>
0141     struct _makesplit_at_t {
0142         template <typename ...Xs>
0143         constexpr decltype(auto) operator()(Xs&& ...xs) const {
0144             return hana::reverse_partial(split_at_t<n>{},
0145                                          static_cast<Xs&&>(xs)...);
0146         }
0147     };
0148 
0149     template <std::size_t n>
0150     BOOST_HANA_INLINE_VARIABLE constexpr _makesplit_at_t<n> split_at{};
0151 }} }} // end namespace boost::hana
0152 
0153 #endif // !BOOST_HANA_DETAIL_VARIADIC_SPLIT_AT_HPP