Boost logo

Boost :

Subject: Re: [boost] [UTF String] UTF String library 1.5 ready for perusal
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2011-02-10 09:18:27

On 10/02/2011 14:40, Chad Nelson wrote:
> On Thu, 10 Feb 2011 14:22:56 +0100
> Mathias Gaunard<mathias.gaunard_at_[hidden]> wrote:
>> On 09/02/2011 15:50, Chad Nelson wrote:
>>> This version is substantially better than the original. The design
>>> has been somewhat simplified, removing extraneous features like
>>> null-string emulation. Each of the classes now contain as many of
>>> the std::string functions as I could efficiently add (essentially
>>> all of them in utf32_t), including I/O stream functions
>> Bad design, IMHO.
> Not very constructive. *Why* do you think it's a bad design?

It's generally agreed on that std::string is a bad design.
See GotW #84 for example. That must be a good ten years old...

>>> and also features code-point iterators.
>> That code point iterator uses pointers and indexes instead of
>> iterators, which means it cannot work as an arbitrary iterator adaptor
>> even though it could with virtually no change, especially since it
>> only requires a forward iterator.
> Sorry, I don't understand the reasoning behind that assertion. Please
> enlighten me.

There is no need for any reasoning: look at the code of your code point
iterator. It uses a pointer and indexes, and is therefore not a generic
iterator adaptor.
Iterating through code points is fully generic and should work for any
forward iterator or bidirectional iterator, not just a pointer.

Making your iterator random access when it obviously isn't is also a
terrible idea. The special case thing has nothing to do there either, it
should be a different iterator.
I'm not a fan of returning a reference in operator* as well.

I also don't understand what mIndex and mEndIndex are for (nor why you
compute the size in code points of the string before constructing
iterators), since you seem to check data is valid beforehand.
And if data is invalid, you have lots of potential for unsafety in your
iterators anyway (in _value for example).

Boost list run by bdawes at, gregod at, cpdaniel at, john at