|
Boost : |
From: Martin Bonner (martin.bonner_at_[hidden])
Date: 2005-10-27 03:06:36
----Original Message----
From: Matt Calabrese [mailto:rivorus_at_[hidden]]
Sent: 27 October 2005 06:44
To: boost_at_[hidden]
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_at_[hidden]> 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_at_[hidden] Pi Technology, Milton Hall, Ely Road, Milton, Cambridge, CB4 6WZ, ENGLAND Tel: +44 (0)1223 441434
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk