mirror of
https://github.com/boostorg/hana.git
synced 2026-02-19 14:32:11 +00:00
Use simpler recursion.
This commit is contained in:
@@ -29,7 +29,7 @@ namespace boost { namespace hana { namespace detail {
|
||||
},
|
||||
[](auto xs, auto ys) {
|
||||
return equal(head(xs), head(ys)) &&
|
||||
equal(tail(xs), tail(ys));
|
||||
equal_impl(tail(xs), tail(ys));
|
||||
}
|
||||
)(xs, ys);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace boost { namespace hana { namespace detail {
|
||||
static constexpr auto foldl_impl(F f, State s, Iterable xs) {
|
||||
return if_(is_empty(xs),
|
||||
always(s),
|
||||
[=](auto xs) { return foldl(f, f(s, head(xs)), tail(xs)); }
|
||||
[=](auto xs) { return foldl_impl(f, f(s, head(xs)), tail(xs)); }
|
||||
)(xs);
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace boost { namespace hana { namespace detail {
|
||||
static constexpr auto foldr1_impl(F f, Iterable xs) {
|
||||
return if_(is_empty(tail(xs)),
|
||||
head,
|
||||
[=](auto xs) { return f(head(xs), foldr1(f, tail(xs))); }
|
||||
[=](auto xs) { return f(head(xs), foldr1_impl(f, tail(xs))); }
|
||||
)(xs);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace boost { namespace hana { namespace detail {
|
||||
static constexpr auto foldr_impl(F f, State s, Iterable xs) {
|
||||
return if_(is_empty(xs),
|
||||
always(s),
|
||||
[=](auto xs) { return f(head(xs), foldr(f, s, tail(xs))); }
|
||||
[=](auto xs) { return f(head(xs), foldr_impl(f, s, tail(xs))); }
|
||||
)(xs);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace boost { namespace hana {
|
||||
static constexpr auto at_impl(Index n, Iterable_ iterable) {
|
||||
return if_(n == size_t<0>,
|
||||
[](auto n, auto it) { return head(it); },
|
||||
[](auto n, auto it) { return at(n - size_t<1>, tail(it)); }
|
||||
[](auto n, auto it) { return at_impl(n - size_t<1>, tail(it)); }
|
||||
)(n, iterable);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace boost { namespace hana {
|
||||
static constexpr auto last_impl(Iterable_ iterable) {
|
||||
return if_(is_empty(tail(iterable)),
|
||||
head,
|
||||
compose(last, tail)
|
||||
[](auto it) { return last_impl(tail(it)); }
|
||||
)(iterable);
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace boost { namespace hana {
|
||||
static constexpr auto length_impl(Iterable_ iterable) {
|
||||
return if_(is_empty(iterable),
|
||||
always(size_t<0>),
|
||||
[](auto it) { return size_t<1> + length(tail(it)); }
|
||||
[](auto it) { return size_t<1> + length_impl(tail(it)); }
|
||||
)(iterable);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace boost { namespace hana {
|
||||
static constexpr auto drop_impl(N n, Iterable_ iterable) {
|
||||
return if_(n == size_t<0> || is_empty(iterable),
|
||||
always(iterable),
|
||||
[](auto n, auto it) { return drop(n - size_t<1>, tail(it)); }
|
||||
[](auto n, auto it) { return drop_impl(n - size_t<1>, tail(it)); }
|
||||
)(n, iterable);
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace boost { namespace hana {
|
||||
return if_(is_empty(iterable),
|
||||
always(false_),
|
||||
[](auto pred, auto it) {
|
||||
return pred(head(it)) || any(pred, tail(it));
|
||||
return pred(head(it)) || any_impl(pred, tail(it));
|
||||
}
|
||||
)(pred, iterable);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <boost/hana/integral.hpp>
|
||||
#include <boost/hana/iterable.hpp>
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user