cpp/algorithm/ranges/next permutation

@1@ Transforms the range into the next, where the set of all permutations is ordered lexicographically with respect to binary comparison function object  and projection function object. Returns if such a "next permutation" exists; otherwise transforms the range into the lexicographically first permutation as if by, and returns.

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

Return value
@1@ if the new permutation is lexicographically greater than the old one. if the last permutation was reached and the range was reset to the first 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.