1.5.3.12 Permuting


bool next_permutation(b,b)
bool next_permutation
(b,b,bpred)

Change a range of values to the next lexicographic permutation of those values, and return true, or false if no next permuation exists.



bool prev_permutation (b,b)
bool prev_permutation
(b,b, bpred)

Change a range of values to the previous lexicographic permutation of those values, and return true, or return false if no previous permuation exists.



A example:
int a[] = {1,2,3}; 
do { 
    cout << a[0] <<  << a[1] <<  << a[2] << \n; 
} while ( std::next_permutation(a,a+3) ); 
1 2 3 // 1 3 2 //2 1 3 
2 3 1 //3 1 2  //3 2 1