------- Comment #5 from chris at bubblescope dot net 2009-09-14 17:00 ------- You cannot assume the elements you are sorting have a default constructor. You can however certainly use a separate array of indices, and then swap at the end, so I withdraw that comment. However, this also only complicates the problem, as it suggests we should also fix stable_partition.
A long time ago I tried improving the standard library to use whichever of swap or copy was more efficent, and ended up effectively reinventing rvalue references using template wrappers. Given any patches would only be in a new version of gcc, as this is not a regression, as we haw never done it "properly", would you be happy instead using the c++0x support in those new compiler? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41351