|
Boost : |
From: Daniel Frey (d.frey_at_[hidden])
Date: 2008-04-11 13:42:58
On Fri, 2008-04-11 at 19:11 +0300, Peter Dimov wrote:
> I'm still not 100% convinced that we need this functionality in shared_ptr.
How many % is it currently? ;)
> But if we do, it seems that the proper way to add it is to make shared_ptr
> issue an unqualified call to
>
> sp_accept_owner( this, p );
>
> which the user will now be free to add to the namespace of *p or one of its
> base classes. Your code, for example, would now have
>
> template<class T>
> void sp_accept_owner(
> shared_ptr<T> * p, shared_ptr_debugger * q );
>
> in the namespace of shared_ptr_debugger, and another overload in the
> namespace of C4 that would resolve the ambiguity.
That's a very good idea. And it's not very different from the current
code anyway. Moving code around a bit, I ended up with the attach patch
against HEAD. It also seems cleaner to me (compared with the HEAD
version), as enable_shared_from_this is no longer forward declared in
shared_ptr.hpp and the registration of the observer can be moved to
enable_shared_from_this.hpp.
I'll try to write an alternative enable_shared_from_this class with only
a single plain pointer overhead based on the attached patch. At least to
me enable_shared_from_this' efficiency/overhead is far more important
than additional features that I never needed so far. Having a choice
seems highly desirable.
Regards, Daniel
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk