In the case where you are going from N elements to N-1 elements, you
can still use next_permutation, just chop off the right-most element.
In the general case of N to M, M < N-1, chop off the last (N-M) elements,
then insert the resulting tuple into a set. There will be a lot of duplicates
that you can ignore.
If all you want to do is generate k(2) and not k(n), then I suggest just using two for loops. For example:
1 2 3 4 5 6
int my_set[ 24 ] - { /* values here */ };
for( int first = 0; first < 24; ++first )
for( int second = 0; second < 24; ++second )
if( first != second )
std::cout << '{' << my_set[ first ] << ',' << my_set[ second ] << '}' << std::endl;
Obviously if 2 is a runtime parameter as opposed to a constant, then you'd need a variable
number of nested for loops, which makes the problem a bit harder and requires more
coding.