Boost logo

Boost :

Subject: Re: [boost] [General] Always treat std::strings as UTF-8
From: Dave Abrahams (dave_at_[hidden])
Date: 2011-01-21 12:01:48


At Fri, 21 Jan 2011 09:01:10 -0500,
Stewart, Robert wrote:
>
> Alexander Lamaison wrote:
> >
> > Rule 35 of C++ Coding Standard by Sutter and Alexandrescu:
> > "Avoid inheriting from classes that were not designed to be
> > classes"
> ^
> base
>
> > "Using a standalone class as a base is a serious design error"
> >
> > The reasons given include undefined behaviour when deleting a
> > std::string* pointing to an instance of the subclass, slicing
> > if extra data is added and pointlessness as the subclass
> > doesn't get any more access to the superclass's implementation
> > that it would have had if it just kept std::string as a
> > member.
>
> If there are no additional members, then slicing and failure to
> invoke the derivate's destructor cause no problems

None other than undefined behavior. :-)

The fact that most compilers and platforms will let you get away with
it notwithstanding, I'd like to avoid that.

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk