The standard library currently contains optimized versions of std::move and std::move_backward for std::deque iterators, which move everything block per block. However those overloads only work when both the input and output iterators are std::deque iterators, and not when the types of iterators differ. I noticed that lately when checking the performance of merge algorithms on std::deque algorithms: I expected memmove to be called when calling std::move to move the contents of a std::deque to a temporary buffer (represented by a simple pointer) and when moving the elements back from the buffer to the std::deque, but while memmove was called as expected when using libc++, it wasn't when using libstdc++. I looked at the standard library code and that's when I realized that the libstdc++ overloads for deque iterators didn't accept mixed iterators. Would it be possible to add std::[_backward] overloads to take this case into account? If I'm not mistaken it should improve std::inplace_merge and std::stable_sort out of the box for std::deque<T> iterators when T is trivially copyable.
Patch awaiting on mailing list: https://gcc.gnu.org/ml/libstdc++/2019-06/msg00097.html
The different patches have been applied.