Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-10-22 12:30:54


David Abrahams wrote:
> "Peter Dimov" <pdimov_at_[hidden]> writes:
>
>> David Abrahams wrote:
>>> Is this going to be illegal for most fs, then?
>>> std::copy(
>>> std::istream_iterator<char>(f),
>>> std::istream_iterator<char>(),
>>> std::back_inserter(my_utf8_string));
>>> I think it pretty much has to work.
>>
>> my_utf8_string.append(
>> std::istream_iterator<char>(f), std::istream_iterator<char>() );
>>
>> is the proper spelling. Or, if you prefer,
>>
>> my_utf8_string.insert( my_utf8_string.end(),
>> std::istream_iterator<char>(f), std::istream_iterator<char>() );
>>
>> Character by character push_back loops just aren't cool.
>
> Okay, but should we make this well-known and understood idiom one
> that compiles and fails at runtime?

The well-known idiom is evil, but I see your point. A checking utf8_string
probably shouldn't have push_back( char ).

However, how did an utf8_string enter the discussion? Wasn't our unicode
string supposed to hold UTF-16 in a clever way that permitted random access,
and expose char32_t as its value_type?


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