In this simple test case, how do I flatten it from vector<vector<T>>
to vector<T>
?
#include <iostream>
#include <vector>
#include <ranges>
int main() {
std::vector v{1, 2, 3, 4, 5};
for (const auto &v : v | std::views::transform([](int i) { return std::vector{i, i * 2}; }))
std::cout << v << std::endl;
return 0;
}
appending | std::views::join
at, behind, or in front of, the transform
results in the following error:
error: class template argument deduction failed: 2700 | return join_view{std::forward(__r)};
So, how am I supposed to do this?