5 ms·
C++ devs need to understand the difference between: Vec1[0]; Vec1.at(0); Even the at method isn’t statically checked. If you want static checking, you p
by criddell 2y ago
C++ devs need to understand the difference between:
Vec1[0];
Vec1.at(0);
Even the at method isn’t statically checked. If you want static checking, you probably need to use std::array.
- pjmlp 2y agoMany also need to learn that there are configuration settings on their compilers that make those two cases the same, enabling bounds checking on operator[]().
- criddell 2y agoSure, but at() is guaranteed to throw an exception and operator[] can throw an exception when you go out of bounds. C++26 is tweaking this, but it's still going to differ implementation to implementation. At least that's my understanding of the situation. Happy to be corrected though.