C++ Standard Library next_permutation() Sample

Description

next_permutation() computes the next permutation of a sequence of elements, rearranging the elements in place. For N elements, there are N! permutations. false is returned when the permutations are exhausted.

Declaration

	template <class Bi>
	    bool next_permutation(Bi, Bi);
	template <class Bi, class Cmp>
	    bool next_permutation(Bi, Bi, Cmp);

Concept

The example sets up a three-long C-style string, and then prints all permutations of it. The output is:

	abc
	acb
	bac
	bca
	cab
	cba

Supported
Supported
Supported