
----Original Message---- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Caleb Epstein Sent: 12 October 2006 22:09 To: boost@lists.boost.org Subject: Re: [boost] Boost super_string
On 10/12/06, Arkadiy Vertleyb <vertleyb@hotmail.com> 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.
and was being deleted via pointers to std::basic_string?
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. -- Martin Bonner Martin.Bonner@Pitechnology.com Pi Technology, Milton Hall, Ely Road, Milton, Cambridge, CB24 6WZ, ENGLAND Tel: +44 (0)1223 203894