From: Jeff Garland (jeff_at_[hidden])
Date: 2006-10-13 08:20:19
Martin Bonner wrote:
> ----Original Message----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]] On Behalf Of Caleb Epstein Sent:
> 12 October 2006 22:09 To: boost_at_[hidden]
> Subject: Re: [boost] Boost super_string
>> On 10/12/06, Arkadiy Vertleyb <vertleyb_at_[hidden]> wrote:
>>> More importantly, according
>>> to the standard, the basic_string class destructor is not virtual,
>>> and so basic_string is not intended for derivation.
>> Wouldn't this only matter if super_string added data members (it
>> doesn't AFAICT)
> Not relevent.
It is relevant. If you add data members you now want to ensure the subclass
destructor runs in the case below. Detailed completely in Effective C++ #14.
>> and was being deleted via pointers to
> THIS is the relevent point.
> string* pstr = new super_string;
> delete pstr;
> is undefined behaviour. In practise, you get away with it if
> super_string doesnt do anything in its destructor,
> and if all additional
> members don't do anything in their destructors. However, formally it is
> ALWAYS undefined behaviour.
> The real question is how often will people create a super_string on the
> heap, and delete it through pointer to string.
No. The intent is that the above new/delete is supported. If it isn't then
it's a really bad idea.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk