how can I efficiently modify the elements of these two lists using stl algorithms:
std::list<std::pair<double, string> > listPair(10);
std::list<double> listA(10);
And in such a way that the first pair-element gets the corresponding double value from listA?
Here I assume
listPairis already filled, because there’s no way to get that string otherwise.You could loop through the collections directly.
or use the “binary” version of
std::transform, but this will involve copying the string: