It's been quite a while since I wrote any significant C++ code, but this statement seems wrong. Is this really "state of the art" for C++?
It's been quite a while since I wrote any significant C++ code, but this statement seems wrong. Is this really "state of the art" for C++?
Seeing new and delete has very heavy code smell and can be avoided 99% of the time.
unique_ptr is gaining traction, of course.
Though while new and delete are best avoided where possible, it's hardly the end of the world if you do use them. And my experience has always been that you're better off just using them, if the alternative is heavy use of smart pointers.
As member variables, smart pointers are tolerable, if copied to an ordinary pointer before heavy use; as locals or parameters, they're almost always best avoided. Over the years I've have had far more annoyance from painful single stepping, spitefully poor unoptimised performance and inconvenient watch window behaviour than I have ever had from just picking out all the memory leaks after the fact. (Which, if the code is written relatively tastefully, is usually pretty straightforward. And unless your colleagues are actively being dicks, I've always found there aren't too many to get rid of anyway.)
Like 99.99999999% of the time you can use those. Like the only situation where I think they might be not enough is for some weird uses of placement new.