
----Original Message---- From: Matt Calabrese [mailto:rivorus@gmail.com] Sent: 27 October 2005 06:44 To: boost@lists.boost.org Subject: Re: [boost] Is there any interest in a library that provides containers with virtual destructors?
On 10/27/05, Victor A. Wagner Jr. <vawjr@rudbek.com> wrote:
indeed, but there is no dynamic type vs static type in the example.
If you have a virtual_vector<person>* which points to an instance of people, and you call delete with that pointer as an operand, you have undefined behavior unless virtual_vector<person> has a virtual destructor since virtual_vector<person> is the static type and people is the dynamic type.
Nit: Actually the static type is virtual_vector<person>*, and the dynamic type is people*. (The standard talks about the static and dynamic types of the operand to delete, not the static and dynamic types of the object pointed to by the operand to delete.) (Given the mess I made of the last reference I made to the standard, I shall be interested to see what I have got wrong THIS time!) -- Martin Bonner Martin.Bonner@Pitechnology.com Pi Technology, Milton Hall, Ely Road, Milton, Cambridge, CB4 6WZ, ENGLAND Tel: +44 (0)1223 441434