Boost logo

Boost :

From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2008-04-10 09:27:59

Hash: SHA1

On Thursday 10 April 2008 06:40 am, Daniel Frey wrote:
> On Wed, 2008-04-09 at 20:13 -0400, Frank Mori Hess wrote:
> I attached a minimalistic patch against the trunk which enhances the
> current code into that direction.

The static_cast in your patch is going to have problems with virtual base
classes. I think you could just use the Y* available in
sp_enable_shared_from_this and call _internal_accept_owner from that.

Also, on further thought, I don't think enable_shared_from_this_base needs to
be a template class at all.

> The name (enable_shared_from_this_base) is probably not a good name. I
> think that from shared_ptr's point of view, it doesn't need to know what
> the callback is used for. It might be better to call it
> notify_on_ownership or something in that direction. And the callback
> function should probably also be renamed. Suggestions?

I agree. notify_on_ownership seems ok. Some other possibilities are
ownership_observer or shared_ptr_observer. The callback might be
accept_shared_ptr_owner() or update_shared_ptr_owner()

Also, I don't think enable_shared_from_this should actually use this base
class in the end, whatever it is called (although it is a good test). If it
does, the user will have to take special care to avoid problems when deriving
from both enable_shared_from_this and this base class. This might happen if
the user is deriving from the base class for purposes other than
re-implementing enable_shared_from_this.

- --
Version: GnuPG v1.4.6 (GNU/Linux)


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