1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
void f()
{
std::vector<int> a = {1,2,3,4,5};
std::vector<int> b = {6,7,8,9,0};
std::vector<std::pair<int&, int&>> target;
target.reserve(a.size());
std::transform(a.begin(), a.end(), b.begin(), std::back_inserter(target),
[](int& x, int& y) { return std::make_pair(x, y); });
for(auto& each : target) {
each.first--;
each.second++;
}
for(auto& eachA : a) {
std::cout << eachA << "\n";
}
for(auto& eachB : b) {
std::cout << eachB << "\n";
}
}
|