https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111053
Bug ID: 111053
Summary: std::ranges::copy is missing important optimizations
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
Blocks: 111052
Target Milestone: ---
std::copy is overloaded for a few special cases, like deque iterators and
ostreambuf_iterators. std::ranges::copy is missing these optimizations.
__copy_or_move(_Iter __first, _Sent __last, _Out __result)
{
// TODO: implement more specializations to be at least on par with
// std::copy/std::move.
We should optimize copying a range to an ostreambuf_iterator, as we do for
std::copy.
We should optimize copying to/from a deque, by working on a whole page at a
time.
As mentioned in Bug 111052 comment 1 we could optimize copying a range to
back_insert_iterator<C> by calling C::insert to insert the whole range at once
(this might need ranges::to <https://wg21.link/P1206R7> support first, so it
isn't limited to Cpp17Iterators). Similarly for insert iterators.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111052
[Bug 111052] std::format_to(std::back_inserter(str), "") should write directly
to the string