Boost logo

Boost :

Subject: Re: [boost] [string] proposal
From: Artyom (artyomtnk_at_[hidden])
Date: 2011-01-27 03:57:39


>
> So you do not consider the fact the following code compiles (and runs!)
> cleanly as a painful problem?
>
> std::string s = get_utf8_string();
> s[42] = '?';
>

It is fine code. Why? Because if you assign s[42] you probably
know why you are do it and you most likely know that there is
a some ASCII character there.

Like for example

    s=get_some_utf8_text_code();
    
    for(size_t i=0;i<s.size();i++) {
        switch(s[i]) {
        case: '\r':
           case: '\n':
            case: '\t':
                s[i]=' ';
       }
     }

Something very common and useful for text parsing.
Is this code wrong? No!

If fast there is lots of code that works fine with this.
removing operator[] does not solve **any** problem.

> I consider that std::string is cool as an internal for a Boost.Locale
> implementor, not as a standard API for encoded strings that should be
> used by all C++ developpers.
>

Seems to me you hadn't seen Boost.Locale code and what does it
does.

Artyom

      


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