Boost logo

Boost Users :

Subject: Re: [Boost-users] [smart_ptr] Problem with circular reference detection
From: Jim Barry (jim_at_[hidden])
Date: 2008-09-17 07:01:45


peter_foelsche_at_[hidden] 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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net