C++ algorithms: next_permutation