cpp/algorithm/ranges/nth element

Reorders the elements in such that:
 * The element pointed at by is changed to whatever element would occur in that position if  were sorted with respect to  and.
 * All of the elements before this new element are less than or equal to the elements after the new  element. That is, for every iterator i, j in the ranges,  respectively, the expression  evaluates to.
 * If then the function has no effect.

@1@ Elements are compared using the given binary comparison function object and projection object.

@2@ Same as, but uses as the range, as if using  as  and  as.

Return value
@1@ An iterator equal to. @2@ Same as if  is an lvalue or of a  type. Otherwise returns std.

Complexity
Linear in on average.

Possible implementation
See also the implementation in msvc stl, libstdc++, and libc++: (1) / (2).