| default (1) | template <class BidirectionalIterator> bool next_permutation (BidirectionalIterator first, BidirectionalIterator last); |
|---|---|
| custom (2) | template <class BidirectionalIterator, class Compare> bool next_permutation (BidirectionalIterator first, BidirectionalIterator last, Compare comp); |
[first,last) into the nextlexicographically greater permutation.N! possible arrangements the elements can take (whereN is the number of elements in the range). Different permutations can be ordered according to how they comparelexicographicaly to each other; The first such-sorted possible permutation (the one that would comparelexicographically smaller to all other permutations) is the one which has all its elements sorted in ascending order, and the largest has all its elements sorted in descending order.operator< for the first version, orcomp for the second.true. If that was not possible (because it is already at the largest possible permutation), it rearranges the elements according to the first permutation (sorted in ascending order) and returnsfalse.[first,last), which contains all the elements betweenfirst andlast, including the element pointed byfirst but not the element pointed bylast.bool. The value returned indicates whether the first argument is considered to go before the second in the specificstrict weak ordering it defines.true if the function could rearrange the object as a lexicographicaly greater permutation.false to indicate that the arrangement is not greater than the previous, but the lowest possible (sorted in ascending order). | |
The 3! possible permutations with 3 elements:1 2 31 3 22 1 32 3 13 1 23 2 1After loop: 1 2 3 |
[first,last) are modified.