C++ class for finding lexicographic permutations