
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday 29 November 2010, Ansel Sermersheim wrote:
After mulling this over for some time, I _think_ I have come up with a solution that mitigates all these problems.
I have a new patch up, at the same URL. In order to make this mechanism work, I had to add a new constructor to boost::shared_ptr<T>, which I am loath to do. Given that downside the patch appears to work properly. It also adds a free function boost::shared_from<T>(T*) which returns a boost::shared_ptr<T>.
The only cast that occurs in this code is a static_cast that downcasts from enable_shared_from_polymorphic<T> to T. I have read the relevant portions of the standard several times and I beleive this is valid, but I would definitely be curious if wiser heads agree with my reading.
If you use a free function only (see enable_shared_from_raw.hpp in trunk), the enabling base class doesn't have to use the CRTP. Why did you need another shared_ptr constructor (sorry, I don't have time to actually read the code)? It's hard to imagine, given the presence of the shared_ptr aliasing constructor. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkz1BtAACgkQ5vihyNWuA4Uz3gCbBSoU+V0ifaE19k6bX9IzxD4l WRcAmwXXO3eFlzKN8i/85Js3ho15TH6y =zZIO -----END PGP SIGNATURE-----