123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- /*!
- @file
- Defines `boost::hana::detail::type_foldr1`.
- @copyright Louis Dionne 2013-2017
- Distributed under the Boost Software License, Version 1.0.
- (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
- */
- #ifndef BOOST_HANA_DETAIL_TYPE_FOLDR1_HPP
- #define BOOST_HANA_DETAIL_TYPE_FOLDR1_HPP
- #include <boost/hana/config.hpp>
- BOOST_HANA_NAMESPACE_BEGIN namespace detail {
- template <unsigned n>
- struct type_foldr1_t;
- template <>
- struct type_foldr1_t<0> {
- template <
- template <typename ...> class f,
- typename state
- >
- using result = state;
- };
- template <>
- struct type_foldr1_t<1> {
- template <
- template <typename ...> class f,
- typename x1,
- typename state
- >
- using result = typename f<x1, state>::type;
- };
- template <>
- struct type_foldr1_t<2> {
- template <
- template <typename ...> class f,
- typename x1, typename x2,
- typename state
- >
- using result = typename f<x1, typename f<x2, state>::type>::type;
- };
- template <>
- struct type_foldr1_t<3> {
- template <
- template <typename ...> class f,
- typename x1, typename x2, typename x3,
- typename state
- >
- using result = typename f<
- x1,
- typename f<
- x2,
- typename f<
- x3,
- state
- >::type
- >::type
- >::type;
- };
- template <>
- struct type_foldr1_t<4> {
- template <
- template <typename ...> class f,
- typename x1, typename x2, typename x3, typename x4,
- typename state
- >
- using result = typename f<
- x1,
- typename f<
- x2,
- typename f<
- x3,
- typename f<
- x4,
- state
- >::type
- >::type
- >::type
- >::type;
- };
- template <>
- struct type_foldr1_t<5> {
- template <
- template <typename ...> class f,
- typename x1, typename x2, typename x3, typename x4, typename x5,
- typename state
- >
- using result = typename f<
- x1,
- typename f<
- x2,
- typename f<
- x3,
- typename f<
- x4,
- typename f<
- x5,
- state
- >::type
- >::type
- >::type
- >::type
- >::type;
- };
- template <>
- struct type_foldr1_t<6> {
- template <
- template <typename ...> class f,
- typename x1, typename x2, typename x3, typename x4, typename x5, typename x6,
- typename ...xs
- >
- using result =
- typename f<
- x1,
- typename f<
- x2,
- typename f<
- x3,
- typename f<
- x4,
- typename f<
- x5,
- typename type_foldr1_t<(sizeof...(xs) > 6 ? 6 : sizeof...(xs))>::
- template result<f, x6, xs...>
- >::type
- >::type
- >::type
- >::type
- >::type;
- };
- template <template <typename ...> class f, typename x1, typename ...xn>
- struct type_foldr1 {
- using type = typename type_foldr1_t<(sizeof...(xn) > 6 ? 6 : sizeof...(xn))>
- ::template result<f, x1, xn...>;
- };
- } BOOST_HANA_NAMESPACE_END
- #endif // !BOOST_HANA_DETAIL_TYPE_FOLDR1_HPP
|