Ugh, my suggestion was not good enought, you can actually move values out of that local nodes_stats
:
0 for (auto&& node_stats : nodes_stats) {
1 const CNodeCombinedStats stats{std::get<0>(std::move(node_stats)),
2 std::get<2>(std::move(node_stats)),
3 std::get<1>(std::move(node_stats))};
(note loop variable is no longer cost reference!)
Or even with an algorithm (also moves, at least it does on local test), if one would care about “No raw loops” mantra :)
0 std::transform(nodes_stats.begin(), nodes_stats.end(), std::back_inserter(new_peers_data), [](auto&& i) {
1 return CNodeCombinedStats{std::get<0>(std::move(i)), std::get<2>(std::move(i)), std::get<1>(std::move(i))};
2 });
Though moving std::transform
seems fishy, not sure if it’s “legal” to move source… But gcc 10.2.1 does that.