Re:C and C++ Prioritize Performance over Correctness
by memefrog on Saturday August 19, 2023 @12:07AM
(#37185403)
Bear in mind that my ultimate perspective is that you shouldn't use smart pointers (or C++) at all.
But even if you think they have some value, it isn't a flaw in a language if it's not immediately obvious how to write code in it for people that are new to it. If you're coming from Python or Java, then learn how to write C++. There are probably as many books on C++ as on any other language out there.
FWIW I consider shared_ptr a bit of a code-smell that you don't have your ownership model well understood, there are cases to use it but 90% of the time you can eliminate it with a more explicit design(and avoid chances of leaks + penalties from atomics).