Clarifying functionality
Many conversions of loops to STL forms are near to net-zero in terms of complexity changes: From for (int i = 0: i != r.size(); ++i) vec.emplace_back(r[i]); to for (auto iter = r.begin(): iter != r.end(); ++iter) vec.emplace_back(*iter); to std::for_each (r.begin(), r.end(), [&vec](const auto& inVal) { vec.emplace_back(inVal); }); to std::copy(r.begin(), r.end(), std::back_inserter(vec)); to std::ranges::copy(r, std::back_inserter(vec)); gives us five versions of the same operation in the same ballpark as far as figuring out what is going on, with only the last really giving us a noticeably shorter form because of the simpler form of the range algorithms. (The last version is also almost certainly more efficient than the first version.) The biggest difference is that one can basically read the last one from left to right as "copy the contents of r onto the back of a vector vec". Some changes, though, can do a great deal to clarify ...