Subject: Re: [boost] [General] Always treat std::strings as UTF-8
From: Alexander Lamaison (awl03_at_[hidden])
Date: 2011-01-21 08:52:42
On Fri, 21 Jan 2011 01:43:08 -0800, Patrick Horgan wrote:
> On 01/20/2011 03:46 PM, Chad Nelson wrote:
>> ... elision by patrick
>> For interaction with functions that require std::string, and presumably
>> don't care about the encoding, it's convenient. Without it, using the
>> UTF classes with such a function requires calling the std::string
>> constructor with the element iterators. That's going to be a major need
>> for the foreseeable future.
> But if utf8_string, like std::string derives from basic_string, wouldn't
> that just work?
Rule 35 of C++ Coding Standard by Sutter and Alexandrescu:
"Avoid inheriting from classes that were not designed to be classes"
"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.
-- Easy SFTP for Windows Explorer (http://www.swish-sftp.org)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk