Boost logo

Boost :

From: Daniel Frey (d.frey_at_[hidden])
Date: 2008-04-17 01:42:07

On Wed, 2008-04-16 at 17:16 -0400, Frank Mori Hess wrote:
> > Daniel Frey:
> > template< typename U >
> > shared_ptr<U> shared_from_this( U* u );
> >
> > template< typename U >
> > shared_ptr<U const> shared_from_this( U const* u );
> >

> Wouldn't it be safer to make it a non-template? The aliasing constructor can
> be easily misused. If the user really wants to use the aliasing constructor,
> they could always pass the return value from shared_from_this() to the
> aliasing constructor.

In which case it is useless, as it cannot accept "this" and therefore
doesn't solve any problem at all. Passing this allows you to pass the
type of "this", which is the derived type T, not the type of

Regards, Daniel

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