Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 09:53:01

0001 /*!
0002 @file
0003 Defines `boost::hana::detail::type_foldl1`.
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_TYPE_FOLDL1_HPP
0011 #define BOOST_HANA_DETAIL_TYPE_FOLDL1_HPP
0012 
0013 #include <boost/hana/config.hpp>
0014 
0015 
0016 namespace boost { namespace hana { namespace detail {
0017     template <unsigned n>
0018     struct type_foldl1_t;
0019 
0020     template <>
0021     struct type_foldl1_t<0> {
0022         template <
0023             template <typename ...> class f,
0024             typename state
0025         >
0026         using result = state;
0027     };
0028 
0029     template <>
0030     struct type_foldl1_t<1> {
0031         template <
0032             template <typename ...> class f,
0033             typename state,
0034             typename x1
0035         >
0036         using result = typename f<state, x1>::type;
0037     };
0038 
0039     template <>
0040     struct type_foldl1_t<2> {
0041         template <
0042             template <typename ...> class f,
0043             typename state,
0044             typename x1, typename x2
0045         >
0046         using result = typename f<typename f<state, x1>::type, x2>::type;
0047     };
0048 
0049     template <>
0050     struct type_foldl1_t<3> {
0051         template <
0052             template <typename ...> class f,
0053             typename state,
0054             typename x1, typename x2, typename x3
0055         >
0056         using result = typename f<
0057             typename f<
0058                 typename f<state, x1>::type,
0059                 x2
0060             >::type,
0061             x3
0062         >::type;
0063     };
0064 
0065     template <>
0066     struct type_foldl1_t<4> {
0067         template <
0068             template <typename ...> class f,
0069             typename state,
0070             typename x1, typename x2, typename x3, typename x4
0071         >
0072         using result = typename f<
0073             typename f<
0074                 typename f<
0075                     typename f<state, x1>::type,
0076                     x2
0077                 >::type,
0078                 x3
0079             >::type,
0080             x4
0081         >::type;
0082     };
0083 
0084     template <>
0085     struct type_foldl1_t<5> {
0086         template <
0087             template <typename ...> class f,
0088             typename state,
0089             typename x1, typename x2, typename x3, typename x4, typename x5
0090         >
0091         using result = typename f<
0092             typename f<
0093                 typename f<
0094                     typename f<
0095                         typename f<state, x1>::type,
0096                         x2
0097                     >::type,
0098                     x3
0099                 >::type,
0100                 x4
0101             >::type,
0102             x5
0103         >::type;
0104     };
0105 
0106     template <>
0107     struct type_foldl1_t<6> {
0108         template <
0109             template <typename ...> class f,
0110             typename state,
0111             typename x1, typename x2, typename x3, typename x4, typename x5, typename x6,
0112             typename ...xs
0113         >
0114         using result =
0115             typename type_foldl1_t<(sizeof...(xs) > 6 ? 6 : sizeof...(xs))>::
0116             template result<
0117                 f,
0118                 typename f<
0119                     typename f<
0120                         typename f<
0121                             typename f<
0122                                 typename f<
0123                                     typename f<state, x1>::type,
0124                                     x2
0125                                 >::type,
0126                                 x3
0127                             >::type,
0128                             x4
0129                         >::type,
0130                         x5
0131                     >::type,
0132                     x6
0133                 >::type,
0134                 xs...
0135             >;
0136     };
0137 
0138     template <template <typename ...> class f, typename x1, typename ...xn>
0139     struct type_foldl1 {
0140         using type = typename type_foldl1_t<(sizeof...(xn) > 6 ? 6 : sizeof...(xn))>
0141                      ::template result<f, x1, xn...>;
0142     };
0143 } }} // end namespace boost::hana
0144 
0145 #endif // !BOOST_HANA_DETAIL_TYPE_FOLDL1_HPP