4 ms·
Yeah I agree using vector::at is a common and fairly bad anti-pattern. So long as you make sure your program is correct you never need to worry about indices b
by chlorion 5y ago
Yeah I agree using vector::at is a common and fairly bad anti-pattern.
So long as you make sure your program is correct you never need to worry about indices being out of bounds. Requiring bounds checking is a sign you need to eliminate the errors in your software.
This makes me wonder, why are people writing software with errors in it in the first place? Even master programmers seem to be too lazy and careless to remove the errors from their software. What gives?
- imtringued 5y agoI think I'm falling for Poe's law. Here is a honest answer. The problem is frankly unsolvable thanks to the halting problem. It's impossible to determine in general whether a program is going to reach a certain state except by testing all potential inputs and even that is only going to give you an approximate answer. If it were possible we would have written a program that solves the problem through static analysis.
- benibela 5y agoUsing C++ is an anti-pattern That is why I write all my code in Pascal, where you can enable bound checking for [] Enable it for a debug build, and you an be sure there are no overflows of any kind, and when it runs the program has pretty much no errors at all. Disable it for the release build, and it runs as fast as if it was written in C