4 ms·
For std::string and std::vector yes, but not for std::span (until C++26) for reasons I cannot understand.
by sirwhinesalot 2mo ago
For std::string and std::vector yes, but not for std::span (until C++26) for reasons I cannot understand.
- pjmlp 2mo agoThat is standardese, you get them all bounds checked by using specific compiler flags. Here is for VC++ https://github.com/microsoft/STL/blob/2a62bf7b4079f0a3e33ec80d7daf9ea968805b12/stl/inc/span https://github.com/microsoft/STL/blob/2a62bf7b4079f0a3e33ec8... You just have to define the proper iterator level for enabling bounds checking. Other compilers have similar approaches. I chose VC++ on purpose, because it is what I know better, and is famously trailing behind C++26 features. Then there are the Tclass, Cclass, Qclass, from all those C++ frameworks pre C++98. However plenty devs seem allergic to learn about how to use their compilers.
- sirwhinesalot 2mo agoI wasn't aware of that VC++ feature, TIL, thanks!