// заменяет в последовательности [whole_start, whole_end) вхождения [old_start, old_end) на
// [new_start, new_end), копируя результат в output
template <class IterWhole, class IterOld, class IterNew,class OuputIter>
OuputIter Replace(
IterWhole whole_start, IterWhole whole_end,
IterOld old_start, IterOld old_end,
IterNew new_start, IterNew new_end,
OuputIter output)
{
typename std::iterator_traits<IterOld>::difference_type const old_len = std::distance(old_start, old_end);
if (old_len == 0)
return std::copy(whole_start, whole_end, output);
for (;;)
{
IterWhole found = std::search(whole_start, whole_end, old_start, old_end);
output = std::copy(whole_start, found, output);
if (found == whole_end)
return output;
output = std::copy(new_start, new_end, output);
std::advance(found, old_len);
whole_start = found;
}
}
Всё ли хорошо тут написано?