
22 Oct
2004
22 Oct
'04
3:01 p.m.
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