3 ms·
C and C++ could both easily add this feature: https://www.digitalmars.com/articles/C-biggest-mistake.html https://www.digitalmars.com/articles/C-biggest-mistak
by WalterBright 3y ago
C and C++ could both easily add this feature:
https://www.digitalmars.com/articles/C-biggest-mistake.html https://www.digitalmars.com/articles/C-biggest-mistake.html
which is adding slices to the native language. This will eliminate buffer overflow errors (if the user uses that feature). D has had this from the beginning, and while it doesn't cover everything, that feature alone has resulted in an enormous reduction in memory safety errors.
BTW, D also has a prototype ownership/borrowing system.
- pptr 3y agoC++20 added std::span, which is essentially that.
- pjmlp 3y agoWithout bounds checking.
- vlovich123 3y agoHey. Be reasonable. That's coming in c++26 using the `.at` interface that no one actually uses because `[]` is more natural, shorter (2.5x shorter), and convenient.
- pjmlp 3y agoYeah, that is exactly the problem. :)