Is an achievable / negative change in an adapter with a reinforced filter possible, e.g.
std::vector<int> v = {1, 2, 3, 4, 5};
for(auto i : v | !filtered(is_even))
std::cout << i << std::endl;
instead of doing negation inside a lambda expression?
Motivation: I work a lot with filtered and lambda functions, however, when I use a filter more than once, I usually reorganize it into a custom filter, for example.
for(auto i : v | even)
std::cout << i << std::endl;
Now that I need negation, I create a custom filter for them, for example.
for(auto i : v | not_even)
std::cout << i << std::endl;
but I would be best off hiding a negative filter like
for(auto i : v | !even)
std::cout << i << std::endl;
source
share