
17 Apr
2008
17 Apr
'08
5:42 a.m.
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 enable_shared_from_this<T>. Regards, Daniel