`Description`

`Description`

```
```*Next_permutation* transforms the range of elements *[first, last) *into the lexicographically next greater permutation of the elements. There is a finite number of distinct permutations (at most *N!* [1], where *N* is *last – first*), so, if the permutations are ordered by *lexicographical_compare*, there is an unambiguous definition of which permutation is lexicographically next. If such a permutation exists, *next_permutation* transforms *[first, last)* into that permutation and returns *true*. Otherwise it transforms *[first, last)* into the lexicographically smallest permutation [2] and returns *false*.

The postcondition is that the new permutation of elements is lexicographically greater than the old (as determined by *lexicographical_compare*) if and only if the return value is *true*.

The two versions of *next_permutation* differ in how they define whether one element is less than another. The first version compares objects using *operator<*, and the second compares objects using a function object *comp*.