4 ms·
Yes, but they've made the convenient lightweight syntax not bounds check. Defaults matter in languages. Other languages make you use an esoteric function e.g at
by grumpyprole 2y ago
Yes, but they've made the convenient lightweight syntax not bounds check. Defaults matter in languages. Other languages make you use an esoteric function e.g at_unsafe to skip bounds checking.
- riku_iki 2y agoits probably because per contract std::array has to behave exactly like C array for legacy ops. Also this is not zero cost abstraction, so programmer has a choice: ultimate performance or extra safety.
- pjmlp 2y agoWhile a bummer, most C++ compilers do have a build flag to enable bounds check in operator[](). Which most sane compilers will do for you in debug builds.
- retrac 2y ago* = [] and friends can be overloaded in C++. So just about any kind of data structure can masquerade as items[3] or *value. Opinions differ on whether this is the great strength or fatal flaw in C++.