
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday, March 18, 2011, Ted Byers wrote:
Or is it the case that extra intelligence has been adde to boost::shared_ptr, et al, so that if you create a boost::shared_ptr
, and pass it a pointer to derived type, it remembers the type of the original pointer (and maintains that memory across copy/assignment), and does the right thing when the object is to be freed?
Yes.
But I'd be curious as to why and how that would have been added, and when, when virtual functions acomplish the same thing with no extra effort or pain.
Not all base classes need have any virtual functions at all. See enable_shared_from_this for example. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEARECAAYFAk2DgukACgkQ5vihyNWuA4XOtQCg43GLABPUtHZR6tsjw/a4nwCw D24AnAn/BHprFMk9Wo8cLObX3JxV6GLp =BYwl -----END PGP SIGNATURE-----