Hacker News new | past | comments | ask | show | jobs | submit login

Anyone that uses char * instead of std::array for example.



std::array will instantiate function templates for all used array sizes, lengthen compilation time, and be hard to use across separately-compiled code without putting code into headers. It has its uses, but more often I'd prefer T[N] with bounds-checking, and, in another world, a builtin variably-sized, non-resizable array type; basically a sort of absl::FixedArray[1], but with the semantics of operator[] and at() reversed, so that bounds-checking is the default. Sadly, nothing like that is included in the standard, so won't be a lingua-franca.

[1]: <https://github.com/abseil/abseil-cpp/blob/master/absl/contai...>


On Visual Studio it is relatively easy to enable bounds checking for operator[]().

https://docs.microsoft.com/en-us/visualstudio/debugger/how-t...

That is the thing, the standard doesn't require bounds checking for operator()[], while it does require for at(), but it doesn't forbid it either, it is up to the implementations.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: