## inplace_merge
## Prototype
template <class BidirectionalIterator> inline void inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last); template <class BidirectionalIterator, class StrictWeakOrdering> inline void inplace_merge(BidirectionalIterator first, BidirectionalIterator middle, BidirectionalIterator last, StrictWeakOrdering comp); ## Description
The two versions of ## DefinitionDefined in algo.h. ## Requirements on typesFor the first version: -
`BidirectionalIterator` is a model of BidirectionalIterator. -
`BidirectionalIterator` is mutable. -
`BidirectionalIterator` 's value type is a model of LessThanComparable. -
The ordering on objects of
`BidirectionalIterator` 's value type is a*strict weak ordering*, as defined in the LessThanComparable requirements.
For the second version: -
`BidirectionalIterator` is a model of BidirectionalIterator. -
`BidirectionalIterator` is mutable. -
`StrictWeakOrdering` is a model of StrictWeakOrdering. -
`BidirectionalIterator` 's value type is convertible to`StrictWeakOrdering` 's argument type.
## PreconditionsFor the first version: -
`[first, middle)` is a valid range. -
`[middle, last)` is a valid range. -
`[first, middle)` is in ascending order. That is, for every pair of iterators`i` and`j` in`[first, middle)` such that`i` precedes`j` ,`*j < *i` is`false` . -
`[middle, last)` is in ascending order. That is, for every pair of iterators`i` and`j` in`[middle, last)` such that`i` precedes`j` ,`*j < *i` is`false` .
For the second version: -
`[first, middle)` is a valid range. -
`[middle, last)` is a valid range. -
`[first, middle)` is in ascending order. That is, for every pair of iterators`i` and`j` in`[first, middle)` such that`i` precedes`j` ,`comp(*j, *i)` is`false` . -
`[middle, last)` is in ascending order. That is, for every pair of iterators`i` and`j` in`[middle, last)` such that`i` precedes`j` ,`comp(*j, *i)` is`false` .
## Complexity
## Exampleint main() { int A[] = { 1, 3, 5, 7, 2, 4, 6, 8 }; inplace_merge(A, A + 4, A + 8); copy(A, A + 8, ostream_iterator<int>(cout, " ")); // The output is "1 2 3 4 5 6 7 8". } ## Notes[1] Note that you may use an ordering that is a strict weak ordering but not a total ordering; that is, there might be values ## See also |