Computes the generalized associative combinationof all elements using a non-tail recursive call.
- Parameters
-
| f | Associative binary callable function to apply |
| t | Product type of size 1 or more to operate on |
- Returns
- The value of
f(get<0>(t), f(... , f(get<N-2>(t), get<N-1>(t)))
Helper type
namespace kumi::result
{
template<
typename Function, product_type T>
struct fold_right;
template<typename Function, product_type T>
using fold_right_t = typename fold_right<Function,T>::type;
}
constexpr auto fold_right(Function f, T &&t, Value init)
Computes the generalized combination of all elements using a non-tail recursive call.
Definition fold.hpp:115
Computes the return type of a call to kumi::fold_right
Examples:
#include <kumi/kumi.hpp>
#include <iostream>
#include <vector>
int main()
{
auto output =
kumi::fold_right( [](
auto m,
auto a) { a.push_back(
sizeof(m));
return a; }
, t
, std::vector<std::size_t>{}
);
for(auto s : output) std::cout << s << " ";
std::cout << "\n";
{
std::cout << '(' << acc << ',' << e << ")\n";
return (e <acc) ? e : acc;
}
, u
)
<< "\n";
}
Fixed-size collection of heterogeneous values.
Definition tuple.hpp:32
#include <kumi/kumi.hpp>
#include <iostream>
#include <vector>
int main()
{
auto output =
kumi::fold_right( [](
auto m,
auto a) { a.push_back(
sizeof(m));
return a; }
, t
, std::vector<std::size_t>{}
);
for(auto s : output) std::cout << s << " ";
std::cout << "\n";
{
std::cout << '(' << acc << ',' << e << ")\n";
return (e <acc) ? e : acc;
}
, u
)
<< "\n";
}