Having similar piece of code to the following:
#include <iostream>
#include <vector>
int main()
{
std::vector<std::string> v1, v2;
for (const auto& s : v1) {
// do something with s
}
for (const auto& s : v2) {
// do something with s
}
}
I would like to iterate over all elements from v1
and v2
in one go (and since the logic is kind of difficult in those loops I cannot use functions inside them - for the sake of this question).
So the ideal solution would be something like:
for (const auto& s : magic(v1,v2)) {
// do something with s
}
obviously without allocating new container with all elements copied to it (since that solution is trivial.
Is there anything like it e.g. in boost
?