top | item 45178591

(no title)

miropalmu | 5 months ago

What do you mean no slice/span type?

https://en.cppreference.com/w/cpp/container/span.html

Or if you want multidimensional span:

https://en.cppreference.com/w/cpp/container/mdspan.html

discuss

order

sirwhinesalot|5 months ago

C, not C++. Also span had no bounds checking until the introduction of .at() in C++26, which was a very silly thing to do so late in an age where the white house was asking people to use memory safe languages.

TuxSH|5 months ago

> Also span had no bounds checking

While there was no reason not to have .at(), lack of bound checks by default isn't a bad thing, as inlined bound checks have the potential to highly pessimize code (esp. in loops); also standard library hardening is a thing.

IMO there's much more value to be had in migrating C code (and pre-C++11 code, too) to C++ (or Rust, depending on one's tastes); RAII - that is to say, the ability to automatically run destructors on scope exit - and in particular shared_ptr/unique_ptr/bespoke intrustive pointers drastically reduce the risks of use-after-free

miropalmu|5 months ago

Oh. Makes sense. My bad.