cpp/algorithm/ranges/prev permutation

@1@ Transforms the range into the previous, where the set of all permutations is ordered  with respect to binary comparison function object  and projection function object. @@ Returns:
 * if "previous" permutation exists. Otherwise,
 * , and transforms the range into the (lexicographically) last permutation, as if by

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

Return value
@1@ if the new permutation is lexicographically less than the old one. if the first permutation was reached and the range was reset to the last permutation.

@2@ same as except that the return type is.

Exceptions
Any exceptions thrown from iterator operations or the element swap.

Complexity
At most swaps, where  is  in case  or  in case. Averaged over the entire sequence of permutations, typical implementations use about 3 comparisons and 1.5 swaps per call.