3 ms·
> The default [] API can be replaced with C++ classes that do bounds checks Which means you subtly break the performance guarantees of code which makes migrati
by vlovich123 3y ago
> The default [] API can be replaced with C++ classes that do bounds checks
Which means you subtly break the performance guarantees of code which makes migration to a new version more annoying.
> C++ 20 provides the std::array class to do precisely that
What? https://en.cppreference.com/w/cpp/container/array/operator_at https://en.cppreference.com/w/cpp/container/array/operator_a...
> Returns a reference to the element at specified location pos. No bounds checking is performed
> option to disable native arrays in C++ code
Yeah, no that's not the only place where bounds checking shows up. Lots of places use pointers as iterators because the language lets you. So even if you shut off those avenues, code that uses pointers as iterators would remain exploitable. Of course it's a step improvement, but there's just no way to close the barn door for C++ unless you sacrifice performance to such a degree that the obvious question becomes "why restricted C/C++" which still has a bunch of footguns, is slow, and which has a really inconsistent API and language surface?