Boost logo

Boost :

Subject: Re: [boost] [smart_ptr] enable_shared_from_this and multiple inheritance solution
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2010-11-30 09:14:40

Hash: SHA1

On Monday 29 November 2010, Ansel Sermersheim wrote:
> After mulling this over for some time, I _think_ I have come up with a
> solution that mitigates all these problems.
> I have a new patch up, at the same URL. In order to make this
> mechanism work, I had to add a new constructor to
> boost::shared_ptr<T>, which I am loath to do. Given that downside the
> patch appears to work properly. It also adds a free function
> boost::shared_from<T>(T*) which returns a boost::shared_ptr<T>.
> The only cast that occurs in this code is a static_cast that downcasts
> from enable_shared_from_polymorphic<T> to T. I have read the relevant
> portions of the standard several times and I beleive this is valid,
> but I would definitely be curious if wiser heads agree with my reading.

If you use a free function only (see enable_shared_from_raw.hpp in trunk),
the enabling base class doesn't have to use the CRTP. Why did you need
another shared_ptr constructor (sorry, I don't have time to actually read
the code)? It's hard to imagine, given the presence of the shared_ptr
aliasing constructor.

Version: GnuPG v1.4.9 (GNU/Linux)


Boost list run by bdawes at, gregod at, cpdaniel at, john at