I just figured out that in Visual Studio C++ 2010, basic_string::append (iter, iter)
is, obviously, not implemented by making use of std::copy
.
First question:
Now suppose I implement my own iterator type, together with an optimized overloading of std::copy
for my iterator type in order to provide more efficient block-wise copying. Is there any way to get basic_string::append
to make use of this optimization, apart from overloading append
as well?
Is there any chance that basic_string::append (iter, iter)
does not do character-wise copying?
Second question (as a starting point for my own implementation):
Is the following guaranteed to be valid?
std::string t ("JohnB");
std::string s;
s.reserve (10);
std::copy (t.begin (), t.end (), s.begin ());
s.push_back ('\0');
or should I better use a back_inserter
? If I use a back_inserter
-- how can I avoid character-wise copying?