Boost logo

Boost :

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

On Thu, 2008-04-17 at 00:22 +0300, Peter Dimov wrote:
> Daniel Frey:
> ...
> > template< typename U >
> > shared_ptr<U> shared_from_this( U* u );
> This would even allow you to drop the template parameter of esft_light.
> Interesting.

That would only be possible if I drop shared_from_this(), which would
break the interface for every use case. OTOH, if you consider a breaking
change to the interface, it's easier for the user as he simply passes
the this-pointer in all cases (except where he wants to pass a different
pointer) and doesn't need to make a decision. The possibility of passing
something else than "this"

> Getting back to your proposed changes, I unfortunately can't think of a
> mutually satisfactory way to integrate them. I don't like
> shared_ptr( shared_count & pn, Y* px );
> because it moves from the lvalue pn, auto_ptr style. The proper interface
> wouldn't do that; it would copy from lvalues and move from rvalues by
> default, while still providing an explicit way to move from lvalues.

In fact my copy of the trunk already contains const shared_count& and a
shared_count&& overload, since I also felt that taking and modifying a
reference is too "dirty". I think I wouldn't mind the additional
overhead in case of C++03, as I think that some other cases are
optimized anyway, so it might not be that bad. If you like, I could post
a patch and an analysis of all cases where it optimizes or pessimizes
something. Adding yet another overload for the auto_ptr-style might not
be worth it.

Regards, Daniel

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