std::views::filter lazily exposes only the elements for which a supplied predicate returns true. A predicate returns a Boolean: true retains an element, while false rejects it. section 4.4
Use it in a ranges pipeline to compose filtering with transformations. The resulting view can be traversed with begin() and end(), but std::accumulate still consumes iterator pairs rather than composing directly as a range operation. section 4.4
Filter transformed values
auto evens = vals | std::views::transform([](int x) { return abs(x); }) | std::views::filter([](int x) { return x % 2 == 0; }); auto sum = std::accumulate(evens.begin(), evens.end(), 0);
