KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to wrap my head around the new idioms for C++11. It seems that with shared_ptr at least, there is a substantive difference between using new T() and make_shared<T>() . But what of resetting a shared pointer to point to a new instance of something. Previously, I would typically use reset(new T()) member. However, doesn't this suffer from the same problem as not using make_shared() in the first place? (i.e. it doesn't allow make_shared to allocate the object, therefore it is forced to place the ref count in a separate allocation instead of in the same allocation as the T itself?) Is it simply better going forward to use: mysharedptr = make_shared<T>(args...); Or is there a better way? And shouldn't reset offer variadic forwarding of arguments as make_shared does, so that one could write mysharedptr.reset(args...); ?
Tags (comma-separated)
Save Edits
Cancel