https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111052
Bug ID: 111052
Summary: std::format_to(std::back_inserter(str), "") should
write directly to the string
Product: gcc
Version: 13.1.1
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
fmt::format_to has a nice optimization where it recognizes a
back_insert_iterator<string> and extracts the contained string so that it can
format directly to the string, instead of writing one character at a time
through the output iterator.
We could get the string, move it into a _Seq_sink<string> to format into it,
then move assign (or swap) the populated string back to the original one that
the iterator referred to.