Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-10-22 10:01:11


Eric Niebler wrote:

>> What frequent use cases do you see where people will want to change
>> bits rather than work with characters?
>>
>
>
> utf8_string str;
> str.reserve(some_big_number);
>
> ifstream file("utf8.txt");
> istreambuf_iterator<char8_t> begin(file), end;
>
> std::copy( begin, end, back_inserter(str) );
>
>
> This can't throw if you want people to use your string class.

And what if the example is changed to be:

   ifstream file("local8bit.txt");
   istreambuf_iterator<char8_t> begin(file), end;
 
   std::copy( begin, end, back_inserter(str) );

? This use case is common, so you have to provide something like
"local8bit_back_inserter", and then to be explicit it's better to provide
"utf8_back_inserter".

- Volodya

 


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