std::next_permutation
The function std::next_permutation is a part of the C++ Standard Library, specifically included in the algorithm header. It rearranges the elements in a given range into the next lexicographical permutation. If the current arrangement is the last permutation, it transforms the range into the first permutation, which is the sorted order of the elements.
To use std::next_permutation, you provide it with two iterators that define the range of elements to be permuted. The function returns a boolean value: true if the permutation was successful and false if the input was already the last permutation. This makes it useful for generating all possible arrangements of a sequence.