Hard
Returning a filter view from a function taking const vector&
Compiled as C++20, what happens when this program runs?
main.cpp
#include <iostream>
#include <ranges>
#include <vector>
auto evens(const std::vector<int>& v) {
return v | std::views::filter([](int n) { return n % 2 == 0; });
}
int main() {
auto view = evens({2, 4, 6, 7, 8}); // temporary vector bound to const&
for (int n : view) std::cout << n << " ";
}56 of 117 in C++