17 Sep
2008
17 Sep
'08
11:01 a.m.
peter_foelsche@agilent.com wrote:
What kind of design needs circular smart pointers?
I don't want any circular references - that's the point!
I cannot think of anything I would design this way. I usually use normal pointers somewhere to break circular references.
That's what weak_ptr is for. It's superior to a raw pointer because it knows when the pointee has gone away.
Also I would try to avoid using smart_ptr, since it must allocate another object (to store the reference count) using operator new. Use the intrusive smart pointer instead.
I use shared_ptr because I also need weak_ptr. I can live with the overhead. - Jim