I want to concatenate multiple ranges (e.q.vectors) in to a single range without copying them to a new container, so that the performance is better.
It is for iterating over the whole range later.
#include <iostream>
#include <vector>
#include <boost/range/adaptors.hpp>
#include <boost/range.hpp>
const std::vector<int> vec1 = { 0, 1, 2, 3 };
const std::vector<int> vec2 = { 10, 11, 12, 13 };
const std::vector<int> vec3 = { 20, 21, 22, 23 };
const std::vector<int> vec4 = { 30, 31, 32, 33 };
std::vector< std::vector<int>> all{vec1, vec2, vec3, vec4};
int main() {
auto range = boost::adaptors::transform( all, [&](auto &v) {
return boost::make_iterator_range( v );
} );
for( const auto &i:range) {
std::cout << i << ", ";
}
}
The above prints this;
0123, 10111213, 20212223, 30313233,
But what I actually want is this;
0, 1, 2, 3, 10, 11, 12, 13, 20, 21, 22, 23, 30, 31, 32, 33,