https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87106
--- Comment #9 from Marc Glisse <glisse at gcc dot gnu.org> --- I was looking into using relocation in std::swap. For a type like deque (if we ignore the swap overload), using memcpy is really worth it. For a more simple type like int, using memcpy loses type information, which can hurt other optimizations, so I'd rather stick to the typed assignments for swap<int>. It isn't obvious what the right compromise is. Maybe types that are trivially relocatable but not trivially movable and destructible? Or just non-trivial? That might work if libstdc++ wasn't stuck with a legacy, non-trivial pair<int,int>. For the array swap, I could use a large intermediate buffer on the side (memcpy really shines on large regions), possibly as large as the full array, but I would need to cap it to some safe size (hard to define). By the way, when swapping ranges of a type that does not specialize/overload swap, it seems wasteful to call swap on each element, because it creates a new temporary object for each element instead of reusing the same one. It may be possible to detect if swap would call an overload in a different namespace, but it seems harder to detect if std::swap was specialized).