Boost logo

Boost Users :

From: Russell Hind (rh_gmane_at_[hidden])
Date: 2006-10-18 04:16:57


I thought each time you inherit from enable_shared_from_this<T> you get
a new reference count, so with the code below, won't you end up with 2
separate reference counts to the same instance? I thought this was a
limitation of shared_from_this.

Russell

Johan Nilsson wrote:
>
> Do you mean something like this?
>
> ---------
>
> #include <boost/enable_shared_from_this.hpp>
>
> struct A
> : boost::enable_shared_from_this<A>
> {};
>
> struct B
> : A
> , boost::enable_shared_from_this<B>
> {
> boost::shared_ptr<B> FooB()
> {
> return boost::enable_shared_from_this<B>::shared_from_this();
> }
>
> boost::shared_ptr<A> FooA()
> {
> return boost::enable_shared_from_this<A>::shared_from_this();
> }
> };
>
> ------------
>
> HTH // Johan


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