https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110945
--- Comment #14 from Jonathan Wakely <redi at gcc dot gnu.org> --- Ah, and the patch will pessimize cases like str.assign(str2.begin(), str2.end()) where str.capacity() >= str2.capacity(). The current implementation in terms of replace(begin(), end(), first, last) handles that, because replace is overloaded for string iterators and pointers. Also solvable, but it's getting more complicated.