News for hackers. Stuff that matters.
Re:Smart pointers and move semantics in modern C++ by shermanyo on Tuesday September 27, 2016 @09:06PM (#12594677)
Herb Sutter gave a really great talk on this:

https://www.youtube.com/watch?v=JfmTagWcqoE

He has 3 guidelines:

1. Prefer scoped lifetimes by default (local members)

2. Else prefer unique_ptr and containers

3. Else consider shared_ptr

His whole talk gives examples that show the flexibility of unique_ptr and how modern C++ can express ownership.

See slide 5 here:

https://github.com/CppCon/CppCon2016/blob/master/Presentatio...

There are no comments on this comment yet.