#include <boost/iterator/counting_iterator.hpp>
#include <boost/range/join.hpp>
#include <boost/coroutines/all.hpp>
using namespace boost::coroutines;
template<typename Container>
auto wrap_counting(Container& c) {
return boost::make_iterator_range(
boost::counting_iterator<int>(0),
boost::make_reverse_iterator(boost::make_iterator_range(c.rbegin(), c.rend())));
}
auto filter(context& ctx, const std::vector<int>& v) {
for (int i : v) {
if (i % 2 == 0) ctx.yield(i);
}
}
int main() {
std::vector<int> v = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
auto r = filter(call_cooperative(), v);
for (int i : r) {
std::cout << i << " ";
}
std::cout << "\n";
}