4 ms·
> Now you aren't even supposed to do `new`, but rather std::shared_ptr<...> or std::unique_ptr<...> (as appropriate). Apples and oranges. Smart pointers are wr
by geezerjay 7y ago
> Now you aren't even supposed to do `new`, but rather std::shared_ptr<...> or std::unique_ptr<...> (as appropriate).
Apples and oranges. Smart pointers are wrappers over raw pointers. They extend functionality, but are not the same.
> Except that you generally create them with std::make_shared() and std::make_unique()
Again, apples and oranges. You're confusing factory functions that wrap memory allocation for convenience with actual memory allocation.
At most you could only complain that those factory methods duplicate the role of constructors, which would be silly.
> And then you have the fun of passing those to a function. Do you pass by value (shared_ptr) or by reference (I believe you do not) or pass a naked pointer (when you need to pass a unique_ptr to a function that uses, but does not modify or cache the pointer, if I remember correctly).
There is no duplication in your examples. You are just unaware of how those functionalities are used.