...
At this point, the sorting algorithm assumes that pivot_element
and *mid_point
have equivalent value representations and will compare equal. However, for std::auto_ptr
, this is not the case because *mid_point
has been mutated, and results unexpected behavior.
GenerallyBefore C++11, a copy operation that mutates mutated the source operand is a safe operation to perform only was the only way to provide move-like semantics. However, the language did not provide a way to enforce that this operation only occurred when the source operand is was at the end of its lifetime, because the value representation of the source operand is not important. Such which led to fragile APIs like std::auto_ptr
. In C++11 and later, such a situation is a good candidate for a move operation instead of a copy operation.
...