by throwaway968321 · 4y ago · 0 comments
for (std::size_t i {}; i < pipes.size(); ++i) {
C++ has had range based loops for years now, can use that instead here. for (auto& pipe : pipes)
I don't remember if the '&' is needed after the auto though.anyway you should just use Rust, Zig, or Go...
But the code is busted anyway. After it erases the pipe (which is always at index zero) it then skips the pipe that was at index 1, if there was one.
Correct would be to do the check and erase before entering the loop. Then the range-based loop would better.
'&' isn't necessary to use auto but you would use it here to avoid making an unnecessary copy of the pipe.