cpp/algorithm/inplace merge

Merges two consecutive sorted ranges and  into one sorted range.

A sequence is said to be sorted with respect to a comparator  if for any iterator  pointing to the sequence and any non-negative integer  such that  is a valid iterator pointing to an element of the sequence,  evaluates to.

This merge is stable, which means that for equivalent elements in the original two ranges, the elements from the first range (preserving their original order) precede the elements from the second range (preserving their original order).

@1@ Elements are compared using and the ranges must be sorted with respect to the same. @3@ Elements are compared using the given binary comparison function and the ranges must be sorted with respect to the same. @2,4@ Same as, but executed according to.

Return value
(none)

Complexity
Given , @1,3@ Exactly comparisons if enough additional memory is available. If the memory is insufficient, comparisons. @2,4@ comparisons.

Possible implementation
See the implementations in libstdc++ and libc++.