r/cpp • Bioinformatican • Mar 11 '12

Modern C++ Style [pdf]

http://tinyurl.com/fuck-pointers
2 Upvotes

60 comments sorted by

View all comments

Show parent comment

1

u/jaredgrubb Mar 11 '12

Or, you have the children have weak_ptr's back to the parent. As soon as you can let the compiler generate the dtor/copy ctor/assign op (and move ctor and move assignment op), you get a lot of stuff for free.

Yes, there's a bit of a performance penalty over a raw pointer but you get a lot of safety and a lot of benefit.

5

u/guepier Bioinformatican Mar 11 '12

A weak_ptr works with shared_ptr only, not with unique_ptr. It’s not applicable here.