summaryrefslogtreecommitdiff
path: root/boost/hana/detail/variadic
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:38:45 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:39:52 +0900
commit5cde13f21d36c7224b0e13d11c4b49379ae5210d (patch)
treee8269ac85a4b0f7d416e2565fa4f451b5cb41351 /boost/hana/detail/variadic
parentd9ec475d945d3035377a0d89ed42e382d8988891 (diff)
downloadboost-5cde13f21d36c7224b0e13d11c4b49379ae5210d.tar.gz
boost-5cde13f21d36c7224b0e13d11c4b49379ae5210d.tar.bz2
boost-5cde13f21d36c7224b0e13d11c4b49379ae5210d.zip
Imported Upstream version 1.61.0
Change-Id: I96a1f878d1e6164f01e9aadd5147f38fca448d90 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/hana/detail/variadic')
-rw-r--r--boost/hana/detail/variadic/at.hpp40
-rw-r--r--boost/hana/detail/variadic/drop_into.hpp47
-rw-r--r--boost/hana/detail/variadic/foldl1.hpp212
-rw-r--r--boost/hana/detail/variadic/foldr1.hpp208
-rw-r--r--boost/hana/detail/variadic/reverse_apply.hpp27
-rw-r--r--boost/hana/detail/variadic/reverse_apply/flat.hpp41
-rw-r--r--boost/hana/detail/variadic/reverse_apply/unrolled.hpp87
-rw-r--r--boost/hana/detail/variadic/split_at.hpp153
-rw-r--r--boost/hana/detail/variadic/take.hpp51
9 files changed, 866 insertions, 0 deletions
diff --git a/boost/hana/detail/variadic/at.hpp b/boost/hana/detail/variadic/at.hpp
new file mode 100644
index 0000000000..705d0e2ccc
--- /dev/null
+++ b/boost/hana/detail/variadic/at.hpp
@@ -0,0 +1,40 @@
+/*!
+@file
+Defines `boost::hana::detail::variadic::at`.
+
+@copyright Louis Dionne 2013-2016
+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_VARIADIC_AT_HPP
+#define BOOST_HANA_DETAIL_VARIADIC_AT_HPP
+
+#include <boost/hana/config.hpp>
+
+#include <cstddef>
+#include <utility>
+
+
+BOOST_HANA_NAMESPACE_BEGIN namespace detail { namespace variadic {
+ template <std::size_t n, typename = std::make_index_sequence<n>>
+ struct at_type;
+
+ template <std::size_t n, std::size_t ...ignore>
+ struct at_type<n, std::index_sequence<ignore...>> {
+ private:
+ template <typename Nth>
+ static constexpr auto go(decltype(ignore, (void*)0)..., Nth nth, ...)
+ { return nth; }
+
+ public:
+ template <typename ...Xs>
+ constexpr auto operator()(Xs ...xs) const
+ { return *go(&xs...); }
+ };
+
+ template <std::size_t n>
+ constexpr at_type<n> at{};
+}} BOOST_HANA_NAMESPACE_END
+
+#endif // !BOOST_HANA_DETAIL_VARIADIC_AT_HPP
diff --git a/boost/hana/detail/variadic/drop_into.hpp b/boost/hana/detail/variadic/drop_into.hpp
new file mode 100644
index 0000000000..9e5a80f5dd
--- /dev/null
+++ b/boost/hana/detail/variadic/drop_into.hpp
@@ -0,0 +1,47 @@
+/*!
+@file
+Defines `boost::hana::detail::variadic::drop_into`.
+
+@copyright Louis Dionne 2013-2016
+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_VARIADIC_DROP_INTO_HPP
+#define BOOST_HANA_DETAIL_VARIADIC_DROP_INTO_HPP
+
+#include <boost/hana/config.hpp>
+
+#include <cstddef>
+#include <utility>
+
+
+BOOST_HANA_NAMESPACE_BEGIN namespace detail { namespace variadic {
+ template <std::size_t n, typename F, typename = std::make_index_sequence<n>>
+ struct dropper;
+
+ template <std::size_t n, typename F, std::size_t ...ignore>
+ struct dropper<n, F, std::index_sequence<ignore...>> {
+ F f;
+
+ template <typename ...Rest>
+ constexpr auto go(decltype(ignore, (void*)0)..., Rest ...rest) const
+ { return f(*rest...); }
+
+ template <typename ...Xs>
+ constexpr auto operator()(Xs ...xs) const
+ { return go(&xs...); }
+ };
+
+ template <std::size_t n>
+ struct make_dropper {
+ template <typename F>
+ constexpr auto operator()(F f) const
+ { return dropper<n, decltype(f)>{f}; }
+ };
+
+ template <std::size_t n>
+ constexpr make_dropper<n> drop_into{};
+}} BOOST_HANA_NAMESPACE_END
+
+#endif // !BOOST_HANA_DETAIL_VARIADIC_DROP_INTO_HPP
diff --git a/boost/hana/detail/variadic/foldl1.hpp b/boost/hana/detail/variadic/foldl1.hpp
new file mode 100644
index 0000000000..ad2946b05f
--- /dev/null
+++ b/boost/hana/detail/variadic/foldl1.hpp
@@ -0,0 +1,212 @@
+/*!
+@file
+Defines `boost::hana::detail::variadic::foldl1`.
+
+@copyright Louis Dionne 2013-2016
+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_VARIADIC_FOLDL1_HPP
+#define BOOST_HANA_DETAIL_VARIADIC_FOLDL1_HPP
+
+#include <boost/hana/config.hpp>
+#include <boost/hana/core/when.hpp>
+
+
+BOOST_HANA_NAMESPACE_BEGIN namespace detail { namespace variadic {
+ template <unsigned int n, typename = when<true>>
+ struct foldl1_impl;
+
+ template <>
+ struct foldl1_impl<1> {
+ template <typename F, typename X1>
+ static constexpr X1 apply(F&&, X1&& x1)
+ { return static_cast<X1&&>(x1); }
+ };
+
+ template <>
+ struct foldl1_impl<2> {
+ template <typename F, typename X1, typename X2>
+ static constexpr decltype(auto) apply(F&& f, X1&& x1, X2&& x2) {
+ return static_cast<F&&>(f)(static_cast<X1&&>(x1),
+ static_cast<X2&&>(x2));
+ }
+ };
+
+ template <>
+ struct foldl1_impl<3> {
+ template <typename F, typename X1, typename X2, typename X3>
+ static constexpr decltype(auto) apply(F&& f, X1&& x1, X2&& x2, X3&& x3) {
+ return f(f(static_cast<X1&&>(x1),
+ static_cast<X2&&>(x2)),
+ static_cast<X3&&>(x3));
+ }
+ };
+
+ template <>
+ struct foldl1_impl<4> {
+ template <typename F, typename X1, typename X2, typename X3, typename X4>
+ static constexpr decltype(auto) apply(F&& f, X1&& x1, X2&& x2, X3&& x3, X4&& x4) {
+ return f(f(f(static_cast<X1&&>(x1),
+ static_cast<X2&&>(x2)),
+ static_cast<X3&&>(x3)),
+ static_cast<X4&&>(x4));
+ }
+ };
+
+ template <>
+ struct foldl1_impl<5> {
+ template <typename F, typename X1, typename X2, typename X3, typename X4, typename X5>
+ static constexpr decltype(auto) apply(F&& f, X1&& x1, X2&& x2, X3&& x3, X4&& x4, X5&& x5) {
+ return f(f(f(f(static_cast<X1&&>(x1),
+ static_cast<X2&&>(x2)),
+ static_cast<X3&&>(x3)),
+ static_cast<X4&&>(x4)),
+ static_cast<X5&&>(x5));
+ }
+ };
+
+ template <>
+ struct foldl1_impl<6> {
+ template <typename F, typename X1, typename X2, typename X3, typename X4, typename X5, typename X6>
+ static constexpr decltype(auto) apply(F&& f, X1&& x1, X2&& x2, X3&& x3, X4&& x4, X5&& x5, X6&& x6) {
+ return f(f(f(f(f(static_cast<X1&&>(x1),
+ static_cast<X2&&>(x2)),
+ static_cast<X3&&>(x3)),
+ static_cast<X4&&>(x4)),
+ static_cast<X5&&>(x5)),
+ static_cast<X6&&>(x6));
+ }
+ };
+
+ template <unsigned int n>
+ struct foldl1_impl<n, when<(n >= 7) && (n < 14)>> {
+ template <typename F, typename X1, typename X2, typename X3, typename X4, typename X5, typename X6, typename X7, typename ...Xn>
+ static constexpr decltype(auto)
+ apply(F&& f
+ , X1&& x1, X2&& x2, X3&& x3, X4&& x4, X5&& x5, X6&& x6, X7&& x7
+ , Xn&& ...xn)
+ {
+ return foldl1_impl<sizeof...(xn) + 1>::apply(
+ f,
+ f(f(f(f(f(f(static_cast<X1&&>(x1),
+ static_cast<X2&&>(x2)),
+ static_cast<X3&&>(x3)),
+ static_cast<X4&&>(x4)),
+ static_cast<X5&&>(x5)),
+ static_cast<X6&&>(x6)),
+ static_cast<X7&&>(x7)),
+ static_cast<Xn&&>(xn)...
+ );
+ }
+ };
+
+ template <unsigned int n>
+ struct foldl1_impl<n, when<(n >= 14) && (n < 28)>> {
+ template <
+ typename F
+ , typename X1, typename X2, typename X3, typename X4, typename X5, typename X6, typename X7
+ , typename X8, typename X9, typename X10, typename X11, typename X12, typename X13, typename X14
+ , typename ...Xn
+ >
+ static constexpr decltype(auto)
+ apply(F&& f
+ , X1&& x1, X2&& x2, X3&& x3, X4&& x4, X5&& x5, X6&& x6, X7&& x7
+ , X8&& x8, X9&& x9, X10&& x10, X11&& x11, X12&& x12, X13&& x13, X14&& x14
+ , Xn&& ...xn)
+ {
+ return foldl1_impl<sizeof...(xn) + 1>::apply(
+ f,
+ f(f(f(f(f(f(f(f(f(f(f(f(f(
+ static_cast<X1&&>(x1), static_cast<X2&&>(x2)), static_cast<X3&&>(x3)), static_cast<X4&&>(x4)), static_cast<X5&&>(x5)), static_cast<X6&&>(x6)), static_cast<X7&&>(x7)),
+ static_cast<X8&&>(x8)), static_cast<X9&&>(x9)), static_cast<X10&&>(x10)), static_cast<X11&&>(x11)), static_cast<X12&&>(x12)), static_cast<X13&&>(x13)), static_cast<X14&&>(x14))
+ , static_cast<Xn&&>(xn)...);
+
+ }
+ };
+
+ template <unsigned int n>
+ struct foldl1_impl<n, when<(n >= 28) && (n < 56)>> {
+ template <
+ typename F
+ , typename X1, typename X2, typename X3, typename X4, typename X5, typename X6, typename X7
+ , typename X8, typename X9, typename X10, typename X11, typename X12, typename X13, typename X14
+ , typename X15, typename X16, typename X17, typename X18, typename X19, typename X20, typename X21
+ , typename X22, typename X23, typename X24, typename X25, typename X26, typename X27, typename X28
+ , typename ...Xn
+ >
+ static constexpr decltype(auto)
+ apply(F&& f
+ , X1&& x1, X2&& x2, X3&& x3, X4&& x4, X5&& x5, X6&& x6, X7&& x7
+ , X8&& x8, X9&& x9, X10&& x10, X11&& x11, X12&& x12, X13&& x13, X14&& x14
+ , X15&& x15, X16&& x16, X17&& x17, X18&& x18, X19&& x19, X20&& x20, X21&& x21
+ , X22&& x22, X23&& x23, X24&& x24, X25&& x25, X26&& x26, X27&& x27, X28&& x28
+ , Xn&& ...xn)
+ {
+ return foldl1_impl<sizeof...(xn) + 1>::apply(
+ f,
+ f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(
+ static_cast<X1&&>(x1), static_cast<X2&&>(x2)), static_cast<X3&&>(x3)), static_cast<X4&&>(x4)), static_cast<X5&&>(x5)), static_cast<X6&&>(x6)), static_cast<X7&&>(x7)),
+ static_cast<X8&&>(x8)), static_cast<X9&&>(x9)), static_cast<X10&&>(x10)), static_cast<X11&&>(x11)), static_cast<X12&&>(x12)), static_cast<X13&&>(x13)), static_cast<X14&&>(x14)),
+ static_cast<X15&&>(x15)), static_cast<X16&&>(x16)), static_cast<X17&&>(x17)), static_cast<X18&&>(x18)), static_cast<X19&&>(x19)), static_cast<X20&&>(x20)), static_cast<X21&&>(x21)),
+ static_cast<X22&&>(x22)), static_cast<X23&&>(x23)), static_cast<X24&&>(x24)), static_cast<X25&&>(x25)), static_cast<X26&&>(x26)), static_cast<X27&&>(x27)), static_cast<X28&&>(x28))
+ , static_cast<Xn&&>(xn)...);
+ }
+ };
+
+ template <unsigned int n>
+ struct foldl1_impl<n, when<(n >= 56)>> {
+ template <
+ typename F
+ , typename X1, typename X2, typename X3, typename X4, typename X5, typename X6, typename X7
+ , typename X8, typename X9, typename X10, typename X11, typename X12, typename X13, typename X14
+ , typename X15, typename X16, typename X17, typename X18, typename X19, typename X20, typename X21
+ , typename X22, typename X23, typename X24, typename X25, typename X26, typename X27, typename X28
+ , typename X29, typename X30, typename X31, typename X32, typename X33, typename X34, typename X35
+ , typename X36, typename X37, typename X38, typename X39, typename X40, typename X41, typename X42
+ , typename X43, typename X44, typename X45, typename X46, typename X47, typename X48, typename X49
+ , typename X50, typename X51, typename X52, typename X53, typename X54, typename X55, typename X56
+ , typename ...Xn
+ >
+ static constexpr decltype(auto)
+ apply(F&& f
+ , X1&& x1, X2&& x2, X3&& x3, X4&& x4, X5&& x5, X6&& x6, X7&& x7
+ , X8&& x8, X9&& x9, X10&& x10, X11&& x11, X12&& x12, X13&& x13, X14&& x14
+ , X15&& x15, X16&& x16, X17&& x17, X18&& x18, X19&& x19, X20&& x20, X21&& x21
+ , X22&& x22, X23&& x23, X24&& x24, X25&& x25, X26&& x26, X27&& x27, X28&& x28
+ , X29&& x29, X30&& x30, X31&& x31, X32&& x32, X33&& x33, X34&& x34, X35&& x35
+ , X36&& x36, X37&& x37, X38&& x38, X39&& x39, X40&& x40, X41&& x41, X42&& x42
+ , X43&& x43, X44&& x44, X45&& x45, X46&& x46, X47&& x47, X48&& x48, X49&& x49
+ , X50&& x50, X51&& x51, X52&& x52, X53&& x53, X54&& x54, X55&& x55, X56&& x56
+ , Xn&& ...xn)
+ {
+ return foldl1_impl<sizeof...(xn) + 1>::apply(
+ f,
+ f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(f(
+ static_cast<X1&&>(x1), static_cast<X2&&>(x2)), static_cast<X3&&>(x3)), static_cast<X4&&>(x4)), static_cast<X5&&>(x5)), static_cast<X6&&>(x6)), static_cast<X7&&>(x7)),
+ static_cast<X8&&>(x8)), static_cast<X9&&>(x9)), static_cast<X10&&>(x10)), static_cast<X11&&>(x11)), static_cast<X12&&>(x12)), static_cast<X13&&>(x13)), static_cast<X14&&>(x14)),
+ static_cast<X15&&>(x15)), static_cast<X16&&>(x16)), static_cast<X17&&>(x17)), static_cast<X18&&>(x18)), static_cast<X19&&>(x19)), static_cast<X20&&>(x20)), static_cast<X21&&>(x21)),
+ static_cast<X22&&>(x22)), static_cast<X23&&>(x23)), static_cast<X24&&>(x24)), static_cast<X25&&>(x25)), static_cast<X26&&>(x26)), static_cast<X27&&>(x27)), static_cast<X28&&>(x28)),
+ static_cast<X29&&>(x29)), static_cast<X30&&>(x30)), static_cast<X31&&>(x31)), static_cast<X32&&>(x32)), static_cast<X33&&>(x33)), static_cast<X34&&>(x34)), static_cast<X35&&>(x35)),
+ static_cast<X36&&>(x36)), static_cast<X37&&>(x37)), static_cast<X38&&>(x38)), static_cast<X39&&>(x39)), static_cast<X40&&>(x40)), static_cast<X41&&>(x41)), static_cast<X42&&>(x42)),
+ static_cast<X43&&>(x43)), static_cast<X44&&>(x44)), static_cast<X45&&>(x45)), static_cast<X46&&>(x46)), static_cast<X47&&>(x47)), static_cast<X48&&>(x48)), static_cast<X49&&>(x49)),
+ static_cast<X50&&>(x50)), static_cast<X51&&>(x51)), static_cast<X52&&>(x52)), static_cast<X53&&>(x53)), static_cast<X54&&>(x54)), static_cast<X55&&>(x55)), static_cast<X56&&>(x56))
+ , static_cast<Xn&&>(xn)...);
+ }
+ };
+
+ struct foldl1_t {
+ template <typename F, typename X1, typename ...Xn>
+ constexpr decltype(auto) operator()(F&& f, X1&& x1, Xn&& ...xn) const {
+ return foldl1_impl<sizeof...(xn) + 1>::apply(
+ static_cast<F&&>(f), static_cast<X1&&>(x1), static_cast<Xn&&>(xn)...
+ );
+ }
+ };
+
+ constexpr foldl1_t foldl1{};
+ constexpr auto foldl = foldl1;
+}} BOOST_HANA_NAMESPACE_END
+
+#endif // !BOOST_HANA_DETAIL_VARIADIC_FOLDL1_HPP
diff --git a/boost/hana/detail/variadic/foldr1.hpp b/boost/hana/detail/variadic/foldr1.hpp
new file mode 100644
index 0000000000..88b5c95305
--- /dev/null
+++ b/boost/hana/detail/variadic/foldr1.hpp
@@ -0,0 +1,208 @@
+/*!
+@file
+Defines `boost::hana::detail::variadic::foldr1`.
+
+@copyright Louis Dionne 2013-2016
+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_VARIADIC_FOLDR1_HPP
+#define BOOST_HANA_DETAIL_VARIADIC_FOLDR1_HPP
+
+#include <boost/hana/config.hpp>
+#include <boost/hana/core/when.hpp>
+
+
+BOOST_HANA_NAMESPACE_BEGIN namespace detail { namespace variadic {
+ template <unsigned int n, typename = when<true>>
+ struct foldr1_impl;
+
+ template <>
+ struct foldr1_impl<1> {
+ template <typename F, typename X1>
+ static constexpr X1 apply(F&&, X1&& x1)
+ { return static_cast<X1&&>(x1); }
+ };
+
+ template <>
+ struct foldr1_impl<2> {
+ template <typename F, typename X1, typename X2>
+ static constexpr decltype(auto) apply(F&& f, X1&& x1, X2&& x2) {
+ return static_cast<F&&>(f)(static_cast<X1&&>(x1),
+ static_cast<X2&&>(x2));
+ }
+ };
+
+ template <>
+ struct foldr1_impl<3> {
+ template <typename F, typename X1, typename X2, typename X3>
+ static constexpr decltype(auto) apply(F&& f, X1&& x1, X2&& x2, X3&& x3) {
+ return f(static_cast<X1&&>(x1),
+ f(static_cast<X2&&>(x2),
+ static_cast<X3&&>(x3)));
+ }
+ };
+
+ template <>
+ struct foldr1_impl<4> {
+ template <typename F, typename X1, typename X2, typename X3, typename X4>
+ static constexpr decltype(auto) apply(F&& f, X1&& x1, X2&& x2, X3&& x3, X4&& x4) {
+ return f(static_cast<X1&&>(x1),
+ f(static_cast<X2&&>(x2),
+ f(static_cast<X3&&>(x3),
+ static_cast<X4&&>(x4))));
+ }
+ };
+
+ template <>
+ struct foldr1_impl<5> {
+ template <typename F, typename X1, typename X2, typename X3, typename X4, typename X5>
+ static constexpr decltype(auto) apply(F&& f, X1&& x1, X2&& x2, X3&& x3, X4&& x4, X5&& x5) {
+ return f(static_cast<X1&&>(x1),
+ f(static_cast<X2&&>(x2),
+ f(static_cast<X3&&>(x3),
+ f(static_cast<X4&&>(x4),
+ static_cast<X5&&>(x5)))));
+ }
+ };
+
+ template <>
+ struct foldr1_impl<6> {
+ template <typename F, typename X1, typename X2, typename X3, typename X4, typename X5, typename X6>
+ static constexpr decltype(auto) apply(F&& f, X1&& x1, X2&& x2, X3&& x3, X4&& x4, X5&& x5, X6&& x6) {
+ return f(static_cast<X1&&>(x1),
+ f(static_cast<X2&&>(x2),
+ f(static_cast<X3&&>(x3),
+ f(static_cast<X4&&>(x4),
+ f(static_cast<X5&&>(x5),
+ static_cast<X6&&>(x6))))));
+ }
+ };
+
+ template <unsigned int n>
+ struct foldr1_impl<n, when<(n >= 7) && (n < 14)>> {
+ template <typename F, typename X1, typename X2, typename X3, typename X4, typename X5, typename X6, typename X7, typename ...Xn>
+ static constexpr decltype(auto)
+ apply(F&& f
+ , X1&& x1, X2&& x2, X3&& x3, X4&& x4, X5&& x5, X6&& x6, X7&& x7
+ , Xn&& ...xn)
+ {
+ return f(static_cast<X1&&>(x1),
+ f(static_cast<X2&&>(x2),
+ f(static_cast<X3&&>(x3),
+ f(static_cast<X4&&>(x4),
+ f(static_cast<X5&&>(x5),
+ f(static_cast<X6&&>(x6),
+ foldr1_impl<sizeof...(xn) + 1>::apply(f, static_cast<X7&&>(x7), static_cast<Xn&&>(xn)...)))))));
+ }
+ };
+
+ template <unsigned int n>
+ struct foldr1_impl<n, when<(n >= 14) && (n < 28)>> {
+ template <
+ typename F
+ , typename X1, typename X2, typename X3, typename X4, typename X5, typename X6, typename X7
+ , typename X8, typename X9, typename X10, typename X11, typename X12, typename X13, typename X14
+ , typename ...Xn
+ >
+ static constexpr decltype(auto)
+ apply(F&& f
+ , X1&& x1, X2&& x2, X3&& x3, X4&& x4, X5&& x5, X6&& x6, X7&& x7
+ , X8&& x8, X9&& x9, X10&& x10, X11&& x11, X12&& x12, X13&& x13, X14&& x14
+ , Xn&& ...xn)
+ {
+ return f(static_cast<X1&&>(x1), f(static_cast<X2&&>(x2), f(static_cast<X3&&>(x3), f(static_cast<X4&&>(x4), f(static_cast<X5&&>(x5), f(static_cast<X6&&>(x6), f(static_cast<X7&&>(x7),
+ f(static_cast<X8&&>(x8), f(static_cast<X9&&>(x9), f(static_cast<X10&&>(x10), f(static_cast<X11&&>(x11), f(static_cast<X12&&>(x12), f(static_cast<X13&&>(x13),
+ foldr1_impl<sizeof...(xn) + 1>::apply(f, static_cast<X14&&>(x14), static_cast<Xn&&>(xn)...))))))))))))));
+ }
+ };
+
+ template <unsigned int n>
+ struct foldr1_impl<n, when<(n >= 28) && (n < 56)>> {
+ template <
+ typename F
+ , typename X1, typename X2, typename X3, typename X4, typename X5, typename X6, typename X7
+ , typename X8, typename X9, typename X10, typename X11, typename X12, typename X13, typename X14
+ , typename X15, typename X16, typename X17, typename X18, typename X19, typename X20, typename X21
+ , typename X22, typename X23, typename X24, typename X25, typename X26, typename X27, typename X28
+ , typename ...Xn
+ >
+ static constexpr decltype(auto)
+ apply(F&& f
+ , X1&& x1, X2&& x2, X3&& x3, X4&& x4, X5&& x5, X6&& x6, X7&& x7
+ , X8&& x8, X9&& x9, X10&& x10, X11&& x11, X12&& x12, X13&& x13, X14&& x14
+ , X15&& x15, X16&& x16, X17&& x17, X18&& x18, X19&& x19, X20&& x20, X21&& x21
+ , X22&& x22, X23&& x23, X24&& x24, X25&& x25, X26&& x26, X27&& x27, X28&& x28
+ , Xn&& ...xn)
+ {
+ return f(static_cast<X1&&>(x1), f(static_cast<X2&&>(x2), f(static_cast<X3&&>(x3), f(static_cast<X4&&>(x4), f(static_cast<X5&&>(x5), f(static_cast<X6&&>(x6), f(static_cast<X7&&>(x7),
+ f(static_cast<X8&&>(x8), f(static_cast<X9&&>(x9), f(static_cast<X10&&>(x10), f(static_cast<X11&&>(x11), f(static_cast<X12&&>(x12), f(static_cast<X13&&>(x13), f(static_cast<X14&&>(x14),
+ f(static_cast<X15&&>(x15), f(static_cast<X16&&>(x16), f(static_cast<X17&&>(x17), f(static_cast<X18&&>(x18), f(static_cast<X19&&>(x19), f(static_cast<X20&&>(x20), f(static_cast<X21&&>(x21),
+ f(static_cast<X22&&>(x22), f(static_cast<X23&&>(x23), f(static_cast<X24&&>(x24), f(static_cast<X25&&>(x25), f(static_cast<X26&&>(x26), f(static_cast<X27&&>(x27),
+ foldr1_impl<sizeof...(xn) + 1>::apply(f, static_cast<X28&&>(x28), static_cast<Xn&&>(xn)...))))))))))))))))))))))))))));
+ }
+ };
+
+ template <unsigned int n>
+ struct foldr1_impl<n, when<(n >= 56)>> {
+ template <
+ typename F
+ , typename X1, typename X2, typename X3, typename X4, typename X5, typename X6, typename X7
+ , typename X8, typename X9, typename X10, typename X11, typename X12, typename X13, typename X14
+ , typename X15, typename X16, typename X17, typename X18, typename X19, typename X20, typename X21
+ , typename X22, typename X23, typename X24, typename X25, typename X26, typename X27, typename X28
+ , typename X29, typename X30, typename X31, typename X32, typename X33, typename X34, typename X35
+ , typename X36, typename X37, typename X38, typename X39, typename X40, typename X41, typename X42
+ , typename X43, typename X44, typename X45, typename X46, typename X47, typename X48, typename X49
+ , typename X50, typename X51, typename X52, typename X53, typename X54, typename X55, typename X56
+ , typename ...Xn
+ >
+ static constexpr decltype(auto)
+ apply(F&& f
+ , X1&& x1, X2&& x2, X3&& x3, X4&& x4, X5&& x5, X6&& x6, X7&& x7
+ , X8&& x8, X9&& x9, X10&& x10, X11&& x11, X12&& x12, X13&& x13, X14&& x14
+ , X15&& x15, X16&& x16, X17&& x17, X18&& x18, X19&& x19, X20&& x20, X21&& x21
+ , X22&& x22, X23&& x23, X24&& x24, X25&& x25, X26&& x26, X27&& x27, X28&& x28
+ , X29&& x29, X30&& x30, X31&& x31, X32&& x32, X33&& x33, X34&& x34, X35&& x35
+ , X36&& x36, X37&& x37, X38&& x38, X39&& x39, X40&& x40, X41&& x41, X42&& x42
+ , X43&& x43, X44&& x44, X45&& x45, X46&& x46, X47&& x47, X48&& x48, X49&& x49
+ , X50&& x50, X51&& x51, X52&& x52, X53&& x53, X54&& x54, X55&& x55, X56&& x56
+ , Xn&& ...xn)
+ {
+ return f(static_cast<X1&&>(x1), f(static_cast<X2&&>(x2), f(static_cast<X3&&>(x3), f(static_cast<X4&&>(x4), f(static_cast<X5&&>(x5), f(static_cast<X6&&>(x6), f(static_cast<X7&&>(x7),
+ f(static_cast<X8&&>(x8), f(static_cast<X9&&>(x9), f(static_cast<X10&&>(x10), f(static_cast<X11&&>(x11), f(static_cast<X12&&>(x12), f(static_cast<X13&&>(x13), f(static_cast<X14&&>(x14),
+ f(static_cast<X15&&>(x15), f(static_cast<X16&&>(x16), f(static_cast<X17&&>(x17), f(static_cast<X18&&>(x18), f(static_cast<X19&&>(x19), f(static_cast<X20&&>(x20), f(static_cast<X21&&>(x21),
+ f(static_cast<X22&&>(x22), f(static_cast<X23&&>(x23), f(static_cast<X24&&>(x24), f(static_cast<X25&&>(x25), f(static_cast<X26&&>(x26), f(static_cast<X27&&>(x27), f(static_cast<X28&&>(x28),
+ f(static_cast<X29&&>(x29), f(static_cast<X30&&>(x30), f(static_cast<X31&&>(x31), f(static_cast<X32&&>(x32), f(static_cast<X33&&>(x33), f(static_cast<X34&&>(x34), f(static_cast<X35&&>(x35),
+ f(static_cast<X36&&>(x36), f(static_cast<X37&&>(x37), f(static_cast<X38&&>(x38), f(static_cast<X39&&>(x39), f(static_cast<X40&&>(x40), f(static_cast<X41&&>(x41), f(static_cast<X42&&>(x42),
+ f(static_cast<X43&&>(x43), f(static_cast<X44&&>(x44), f(static_cast<X45&&>(x45), f(static_cast<X46&&>(x46), f(static_cast<X47&&>(x47), f(static_cast<X48&&>(x48), f(static_cast<X49&&>(x49),
+ f(static_cast<X50&&>(x50), f(static_cast<X51&&>(x51), f(static_cast<X52&&>(x52), f(static_cast<X53&&>(x53), f(static_cast<X54&&>(x54), f(static_cast<X55&&>(x55),
+ foldr1_impl<sizeof...(xn) + 1>::apply(f, static_cast<X56&&>(x56), static_cast<Xn&&>(xn)...))))))))))))))))))))))))))))))))))))))))))))))))))))))));
+ }
+ };
+
+ struct foldr1_t {
+ template <typename F, typename X1, typename ...Xn>
+ constexpr decltype(auto) operator()(F&& f, X1&& x1, Xn&& ...xn) const {
+ return foldr1_impl<sizeof...(xn) + 1>::apply(
+ static_cast<F&&>(f), static_cast<X1&&>(x1), static_cast<Xn&&>(xn)...
+ );
+ }
+ };
+
+ constexpr foldr1_t foldr1{};
+
+ struct foldr_t {
+ template <typename F, typename State, typename ...Xn>
+ constexpr decltype(auto) operator()(F&& f, State&& state, Xn&& ...xn) const {
+ return foldr1_impl<sizeof...(xn) + 1>::apply(
+ static_cast<F&&>(f), static_cast<Xn&&>(xn)..., static_cast<State&&>(state)
+ );
+ }
+ };
+
+ constexpr foldr_t foldr{};
+}} BOOST_HANA_NAMESPACE_END
+
+#endif // !BOOST_HANA_DETAIL_VARIADIC_FOLDR1_HPP
diff --git a/boost/hana/detail/variadic/reverse_apply.hpp b/boost/hana/detail/variadic/reverse_apply.hpp
new file mode 100644
index 0000000000..08444a1035
--- /dev/null
+++ b/boost/hana/detail/variadic/reverse_apply.hpp
@@ -0,0 +1,27 @@
+/*!
+@file
+Defines `boost::hana::detail::variadic::reverse_apply`.
+
+@copyright Louis Dionne 2013-2016
+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_VARIADIC_REVERSE_APPLY_HPP
+#define BOOST_HANA_DETAIL_VARIADIC_REVERSE_APPLY_HPP
+
+#include <boost/hana/config.hpp>
+#include <boost/hana/detail/variadic/reverse_apply/unrolled.hpp>
+
+
+BOOST_HANA_NAMESPACE_BEGIN namespace detail { namespace variadic {
+ BOOST_HANA_CONSTEXPR_LAMBDA auto reverse_apply =
+ [](auto&& f, auto&& ...x) -> decltype(auto) {
+ return detail::variadic::reverse_apply_unrolled(
+ static_cast<decltype(f)&&>(f),
+ static_cast<decltype(x)&&>(x)...
+ );
+ };
+}} BOOST_HANA_NAMESPACE_END
+
+#endif // !BOOST_HANA_DETAIL_VARIADIC_REVERSE_APPLY_HPP
diff --git a/boost/hana/detail/variadic/reverse_apply/flat.hpp b/boost/hana/detail/variadic/reverse_apply/flat.hpp
new file mode 100644
index 0000000000..6cd7bed53a
--- /dev/null
+++ b/boost/hana/detail/variadic/reverse_apply/flat.hpp
@@ -0,0 +1,41 @@
+/*!
+@file
+Defines `boost::hana::detail::variadic::reverse_apply_flat`.
+
+@copyright Louis Dionne 2013-2016
+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_VARIADIC_REVERSE_APPLY_FLAT_HPP
+#define BOOST_HANA_DETAIL_VARIADIC_REVERSE_APPLY_FLAT_HPP
+
+#include <boost/hana/config.hpp>
+#include <boost/hana/detail/variadic/at.hpp>
+
+#include <utility>
+
+
+BOOST_HANA_NAMESPACE_BEGIN namespace detail { namespace variadic {
+ template <int ...i, typename F, typename ...X>
+ constexpr decltype(auto)
+ reverse_apply_flat_helper(std::integer_sequence<int, i...>, F&& f, X&& ...x)
+ {
+ return static_cast<F&&>(f)(
+ detail::variadic::at<sizeof...(x) - i - 1>(
+ static_cast<X&&>(x)...
+ )...
+ );
+ }
+
+ template <typename F, typename ...X>
+ constexpr decltype(auto) reverse_apply_flat(F&& f, X&& ...x) {
+ return reverse_apply_flat_helper(
+ std::make_integer_sequence<int, sizeof...(x)>{},
+ static_cast<F&&>(f),
+ static_cast<X&&>(x)...
+ );
+ }
+}} BOOST_HANA_NAMESPACE_END
+
+#endif // !BOOST_HANA_DETAIL_VARIADIC_REVERSE_APPLY_FLAT_HPP
diff --git a/boost/hana/detail/variadic/reverse_apply/unrolled.hpp b/boost/hana/detail/variadic/reverse_apply/unrolled.hpp
new file mode 100644
index 0000000000..5cddf3c2c1
--- /dev/null
+++ b/boost/hana/detail/variadic/reverse_apply/unrolled.hpp
@@ -0,0 +1,87 @@
+/*!
+@file
+Defines `boost::hana::detail::variadic::reverse_apply_unrolled`.
+
+@copyright Louis Dionne 2013-2016
+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_VARIADIC_REVERSE_APPLY_UNROLLED_HPP
+#define BOOST_HANA_DETAIL_VARIADIC_REVERSE_APPLY_UNROLLED_HPP
+
+#include <boost/hana/config.hpp>
+#include <boost/hana/functional/reverse_partial.hpp>
+
+
+BOOST_HANA_NAMESPACE_BEGIN namespace detail { namespace variadic {
+ struct reverse_apply_unrolled_impl {
+ template <typename F>
+ constexpr decltype(auto) operator()(F&& f) const {
+ return static_cast<F&&>(f)();
+ }
+
+ template <typename F, typename X1>
+ constexpr decltype(auto) operator()(F&& f, X1&& x1) const {
+ return static_cast<F&&>(f)(
+ static_cast<X1&&>(x1)
+ );
+ }
+
+ template <typename F, typename X1, typename X2>
+ constexpr decltype(auto) operator()(F&& f, X1&& x1, X2&& x2) const {
+ return static_cast<F&&>(f)(
+ static_cast<X2&&>(x2),
+ static_cast<X1&&>(x1)
+ );
+ }
+
+ template <typename F, typename X1, typename X2, typename X3>
+ constexpr decltype(auto) operator()(F&& f, X1&& x1, X2&& x2, X3&& x3) const {
+ return static_cast<F&&>(f)(
+ static_cast<X3&&>(x3),
+ static_cast<X2&&>(x2),
+ static_cast<X1&&>(x1)
+ );
+ }
+
+ template <typename F, typename X1, typename X2, typename X3, typename X4>
+ constexpr decltype(auto) operator()(F&& f, X1&& x1, X2&& x2, X3&& x3, X4&& x4) const {
+ return static_cast<F&&>(f)(
+ static_cast<X4&&>(x4),
+ static_cast<X3&&>(x3),
+ static_cast<X2&&>(x2),
+ static_cast<X1&&>(x1)
+ );
+ }
+
+ template <typename F, typename X1, typename X2, typename X3, typename X4, typename X5>
+ constexpr decltype(auto) operator()(F&& f, X1&& x1, X2&& x2, X3&& x3, X4&& x4, X5&& x5) const {
+ return static_cast<F&&>(f)(
+ static_cast<X5&&>(x5),
+ static_cast<X4&&>(x4),
+ static_cast<X3&&>(x3),
+ static_cast<X2&&>(x2),
+ static_cast<X1&&>(x1)
+ );
+ }
+
+ template <typename F, typename X1, typename X2, typename X3, typename X4, typename X5, typename X6, typename ...Xn>
+ constexpr decltype(auto) operator()(F&& f, X1&& x1, X2&& x2, X3&& x3, X4&& x4, X5&& x5, X6&& x6, Xn&& ...xn) const {
+ return (*this)(hana::reverse_partial(
+ static_cast<F&&>(f)
+ , static_cast<X6&&>(x6)
+ , static_cast<X5&&>(x5)
+ , static_cast<X4&&>(x4)
+ , static_cast<X3&&>(x3)
+ , static_cast<X2&&>(x2)
+ , static_cast<X1&&>(x1)
+ ), static_cast<Xn&&>(xn)...);
+ }
+ };
+
+ constexpr reverse_apply_unrolled_impl reverse_apply_unrolled{};
+
+}} BOOST_HANA_NAMESPACE_END
+
+#endif // !BOOST_HANA_DETAIL_VARIADIC_REVERSE_APPLY_UNROLLED_HPP
diff --git a/boost/hana/detail/variadic/split_at.hpp b/boost/hana/detail/variadic/split_at.hpp
new file mode 100644
index 0000000000..07e75088a6
--- /dev/null
+++ b/boost/hana/detail/variadic/split_at.hpp
@@ -0,0 +1,153 @@
+/*!
+@file
+Defines `boost::hana::detail::variadic::split_at`.
+
+@copyright Louis Dionne 2013-2016
+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_VARIADIC_SPLIT_AT_HPP
+#define BOOST_HANA_DETAIL_VARIADIC_SPLIT_AT_HPP
+
+#include <boost/hana/config.hpp>
+#include <boost/hana/functional/partial.hpp>
+#include <boost/hana/functional/reverse_partial.hpp>
+
+#include <cstddef>
+
+
+BOOST_HANA_NAMESPACE_BEGIN namespace detail { namespace variadic {
+ template <std::size_t n>
+ struct split_at_t {
+ template <typename F, typename X1, typename X2, typename X3, typename X4, typename X5, typename X6, typename X7, typename X8, typename ...Xs>
+ 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 {
+ return split_at_t<n - 8>{}(
+ hana::partial(static_cast<F&&>(f),
+ static_cast<X1&&>(x1),
+ static_cast<X2&&>(x2),
+ static_cast<X3&&>(x3),
+ static_cast<X4&&>(x4),
+ static_cast<X5&&>(x5),
+ static_cast<X6&&>(x6),
+ static_cast<X7&&>(x7),
+ static_cast<X8&&>(x8)
+ ),
+ static_cast<Xs&&>(xs)...
+ );
+ }
+ };
+
+ template <>
+ struct split_at_t<0> {
+ template <typename F, typename ...Xs>
+ constexpr decltype(auto) operator()(F&& f, Xs&& ...xs) const {
+ return static_cast<F&&>(f)()(static_cast<Xs&&>(xs)...);
+ }
+ };
+
+ template <>
+ struct split_at_t<1> {
+ template <typename F, typename X1, typename ...Xs>
+ constexpr decltype(auto) operator()(F&& f, X1&& x1, Xs&& ...xs) const {
+ return static_cast<F&&>(f)(
+ static_cast<X1&&>(x1)
+ )(static_cast<Xs&&>(xs)...);
+ }
+ };
+
+ template <>
+ struct split_at_t<2> {
+ template <typename F, typename X1, typename X2, typename ...Xs>
+ constexpr decltype(auto) operator()(F&& f, X1&& x1, X2&& x2, Xs&& ...xs) const {
+ return static_cast<F&&>(f)(
+ static_cast<X1&&>(x1),
+ static_cast<X2&&>(x2)
+ )(static_cast<Xs&&>(xs)...);
+ }
+ };
+
+ template <>
+ struct split_at_t<3> {
+ template <typename F, typename X1, typename X2, typename X3, typename ...Xs>
+ constexpr decltype(auto) operator()(F&& f, X1&& x1, X2&& x2, X3&& x3, Xs&& ...xs) const {
+ return static_cast<F&&>(f)(
+ static_cast<X1&&>(x1),
+ static_cast<X2&&>(x2),
+ static_cast<X3&&>(x3)
+ )(static_cast<Xs&&>(xs)...);
+ }
+ };
+
+ template <>
+ struct split_at_t<4> {
+ template <typename F, typename X1, typename X2, typename X3, typename X4, typename ...Xs>
+ constexpr decltype(auto) operator()(F&& f, X1&& x1, X2&& x2, X3&& x3, X4&& x4, Xs&& ...xs) const {
+ return static_cast<F&&>(f)(
+ static_cast<X1&&>(x1),
+ static_cast<X2&&>(x2),
+ static_cast<X3&&>(x3),
+ static_cast<X4&&>(x4)
+ )(static_cast<Xs&&>(xs)...);
+ }
+ };
+
+ template <>
+ struct split_at_t<5> {
+ template <typename F, typename X1, typename X2, typename X3, typename X4, typename X5, typename ...Xs>
+ constexpr decltype(auto) operator()(F&& f, X1&& x1, X2&& x2, X3&& x3, X4&& x4, X5&& x5, Xs&& ...xs) const {
+ return static_cast<F&&>(f)(
+ static_cast<X1&&>(x1),
+ static_cast<X2&&>(x2),
+ static_cast<X3&&>(x3),
+ static_cast<X4&&>(x4),
+ static_cast<X5&&>(x5)
+ )(static_cast<Xs&&>(xs)...);
+ }
+ };
+
+ template <>
+ struct split_at_t<6> {
+ template <typename F, typename X1, typename X2, typename X3, typename X4, typename X5, typename X6, typename ...Xs>
+ constexpr decltype(auto) operator()(F&& f, X1&& x1, X2&& x2, X3&& x3, X4&& x4, X5&& x5, X6&& x6, Xs&& ...xs) const {
+ return static_cast<F&&>(f)(
+ static_cast<X1&&>(x1),
+ static_cast<X2&&>(x2),
+ static_cast<X3&&>(x3),
+ static_cast<X4&&>(x4),
+ static_cast<X5&&>(x5),
+ static_cast<X6&&>(x6)
+ )(static_cast<Xs&&>(xs)...);
+ }
+ };
+
+ template <>
+ struct split_at_t<7> {
+ template <typename F, typename X1, typename X2, typename X3, typename X4, typename X5, typename X6, typename X7, typename ...Xs>
+ constexpr decltype(auto) operator()(F&& f, X1&& x1, X2&& x2, X3&& x3, X4&& x4, X5&& x5, X6&& x6, X7&& x7, Xs&& ...xs) const {
+ return static_cast<F&&>(f)(
+ static_cast<X1&&>(x1),
+ static_cast<X2&&>(x2),
+ static_cast<X3&&>(x3),
+ static_cast<X4&&>(x4),
+ static_cast<X5&&>(x5),
+ static_cast<X6&&>(x6),
+ static_cast<X7&&>(x7)
+ )(static_cast<Xs&&>(xs)...);
+ }
+ };
+
+ template <std::size_t n>
+ struct _makesplit_at_t {
+ template <typename ...Xs>
+ constexpr decltype(auto) operator()(Xs&& ...xs) const {
+ return hana::reverse_partial(split_at_t<n>{},
+ static_cast<Xs&&>(xs)...);
+ }
+ };
+
+ template <std::size_t n>
+ constexpr _makesplit_at_t<n> split_at{};
+}} BOOST_HANA_NAMESPACE_END
+
+#endif // !BOOST_HANA_DETAIL_VARIADIC_SPLIT_AT_HPP
diff --git a/boost/hana/detail/variadic/take.hpp b/boost/hana/detail/variadic/take.hpp
new file mode 100644
index 0000000000..01da4b5b29
--- /dev/null
+++ b/boost/hana/detail/variadic/take.hpp
@@ -0,0 +1,51 @@
+/*!
+@file
+Defines `boost::hana::detail::variadic::take`.
+
+@copyright Louis Dionne 2013-2016
+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_VARIADIC_TAKE_HPP
+#define BOOST_HANA_DETAIL_VARIADIC_TAKE_HPP
+
+#include <boost/hana/config.hpp>
+#include <boost/hana/detail/variadic/split_at.hpp>
+#include <boost/hana/functional/always.hpp>
+#include <boost/hana/functional/reverse_partial.hpp>
+
+#include <cstddef>
+
+
+BOOST_HANA_NAMESPACE_BEGIN namespace detail { namespace variadic {
+ struct take_impl2 {
+ template <typename F, typename ...Xs>
+ constexpr decltype(auto) operator()(F&& f, Xs&& ...xs) const {
+ return static_cast<F&&>(f)(static_cast<Xs&&>(xs)...);
+ }
+ };
+
+ struct take_impl1 {
+ template <typename ...Xs>
+ constexpr auto operator()(Xs&& ...xs) const {
+ return hana::always(
+ reverse_partial(take_impl2{},
+ static_cast<Xs&&>(xs)...)
+ );
+ }
+ };
+
+ template <std::size_t n>
+ struct take_t {
+ template <typename ...Xs>
+ constexpr decltype(auto) operator()(Xs&& ...xs) const {
+ return variadic::split_at<n>(static_cast<Xs&&>(xs)...)(take_impl1{});
+ }
+ };
+
+ template <std::size_t n>
+ constexpr take_t<n> take{};
+}} BOOST_HANA_NAMESPACE_END
+
+#endif // !BOOST_HANA_DETAIL_VARIADIC_TAKE_HPP