From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2008-04-09 14:16:10
-----BEGIN PGP SIGNED MESSAGE-----
On Wednesday 09 April 2008 14:07 pm, Daniel Frey wrote:
> On Wed, 2008-04-09 at 13:47 -0400, Frank Mori Hess wrote:
> > On Wednesday 09 April 2008 11:13 am, Daniel Frey wrote:
> > > I have use cases which would be a lot easier to implement if
> > > shared_from_this() never throws. And - at least with the "old"
> > > implementation - I don't see any reason why this guarantee should not
> > > hold. Of course it's not a defect, but to me it seems desirable.
> > It is technically possible to make it throw without violating the
> > functions documented requirements, if there are multiple owners. For
> > example, if pass the raw pointer to multiple shared_ptrs with null
> > deleters.
> Could you provide a small but complete code example, please? I fail to
> see how that case should be legal.
Here you go, this throws against the old library. It doesn't against the
trunk, due to a slight change in behavior, but could easily be modified to do
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
-----END PGP SIGNATURE-----
Content-Type: text/x-c++src; charset="iso-8859-1";
void null_deleter(const void*)
class myclass: public boost::enable_shared_from_this<myclass>
myclass *myobj = new myclass;
boost::shared_ptr<myclass> ptr2(myobj, &null_deleter);
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk