
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wednesday 19 March 2008 08:39 am, Peter Dimov wrote:
After a brief consideration I think I agree with your approach, though. Nothing better comes to mind. But it would be nice if the deleter replacement happens only if shared_from_this has been called.
I think that could be done, but would probably require a mutex to protect against shared_from_this() getting called concurrently with ownership transfer. Of course, the lazy initialization in init_internal_shared_once() from the patch in trac probably needs a mutex too, or to use call_once from boost.thread.
To proceed, we need two new tests. One that tests currently valid code that will continue to work the same way
Maybe some of the existing test functions can be turned into templates where the template type parameter is the type owned by the shared_ptr? Then the test could be run on a type that does and doesn't inherit from enable_shared_from_this. I haven't looked at most of the tests, but something like that should work fine on get_deleter_test.cpp.
, and another that tests the new behavior.
I can add some stuff to shared_from_this_test.cpp that calls shared_from_this from constructors. Regarding the get_deleter breakage, I think I can modify sp_counted_impl_pd/sp_counted_impl_pda so their get_deleter methods try to unwrap the deleter D if it is of type detail::deleter_wrapper (a class I'm currently using as the deleter for the shared_from_this pointers ). Maybe I should svn copy a little branch somewhere like sandbox-branches/fmhess/enable_shared_from_this/ for the files I've modified, so you can see my code immediately instead of waiting for a patch posted on trac or wherever? - -- Frank -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFH4UIZ5vihyNWuA4URAiFMAJsFftsyPiBzUZw/9GKlr0ZZIvp63QCfaIww evgbnVd1CTMYXg4s9xBsfcY= =a/xZ -----END PGP SIGNATURE-----