-
Notifications
You must be signed in to change notification settings - Fork 1
filter
Vlad Riscutia edited this page Nov 7, 2016
·
1 revision
Header pipe/algorithm.h
, in namespace pipe::algorithm
.
template <typename Predicate>
auto filter(Predicate pred);
filter
returns an object which can act as a rhs when applying operator|
to a lhs generator. When applied, it filters out elements yielded by the input generator that don't conform to the given Predicate
, yielding the remaining elements.
Example:
std::vector<int> out { };
count<int>() | take_n(6) | filter([](auto& item) { return item % 2 == 0; }) | collect(std::back_inserter(out));
// out contains { 0, 2, 4 }