3 ms·
I was just talking about ownership and smart pointers. C++'s non-owning "view" classes are a different matter, and the issue there isn't ownership but lifetime
by HarHarVeryFunny 10mo ago
I was just talking about ownership and smart pointers.
C++'s non-owning "view" classes are a different matter, and the issue there isn't ownership but lifetime of the view vs the underlying data the view is referencing (which in case of string_view could be literally anywhere - a local array of char, a malloc'd block of memory, etc!!).
I'm not a fan of a lot of the (relatively) more recent additions to C++. I think C++14 was about the peak! Given that C++ is meant to be usable as a systems programming language, not just for applications, and given that many new features being added to C++ are really library additions, not language ones, then it's important for the language to include unsafe lower level facilities than can be used for things like that, but actually encouraging application developers to use classes like this that are error-prone by design seems questionable!
- aw1621107 10mo ago> I was just talking about ownership and smart pointers. Sure, I was just clarifying that "references" in the bit I quoted covers specific things and not everything with reference-like behavior.
- HarHarVeryFunny 10mo agoSure, I should have been clearer that smart pointers only guarantee not to release things until there are no more SMART POINTER references to them. As soon as you start mix 'n' matching smart pointers and raw pointers into what they are pointing to, then all bets are off!