stl solution for next permutation