partitionedはstd::partitionのlazy版です。
以下の場合は、{1,2,3,4,5,6}という範囲を偶数と奇数に分けています。
(lazyなことがわかる例ではないですが・・・。)
#include <iostream> #include <vector> #include <pstade/oven/initial_values.hpp> #include <pstade/oven/partitioned.hpp> #include <pstade/oven/io.hpp> using namespace pstade::oven; bool is_even(int x) { return x % 2 == 0; } template <class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '(' << p.first << ' ' << p.second << ')'; } int main() { std::vector<int> v = initial_values(1, 2, 3, 4, 5, 6); std::cout << (v|partitioned(&is_even)) << std::endl; }
({2,4,6} {1,3,5})
【参照】
pstade::oven::partitioned