-
Notifications
You must be signed in to change notification settings - Fork 1
fold
Vlad Riscutia edited this page Nov 7, 2016
·
1 revision
Header pipe/algorithm.h
, in namespace pipe::algorithm
.
template <typename BinaryOperation>
auto fold(BinaryOperation op);
fold
returns an object which can act as a rhs when applying operator|
to a lhs generator. When applied, it combines all elements yielded by the input generator using the given BinaryOperation
, returns the generator's value type default value if no elements are generated.
Example:
auto out = count() | take_n(5) | fold(std::plus<> {});
// out contains 10 (0 + 1 + 2 + 3 + 4)