```
class Solution {
public:
void nextPermutation(vector<int> &num) {
if (!next_permutation(num.begin(), num.end()))
sort(num.begin(), num.end());
}
};
```

You can get more details about the function *next_permutation* at http://www.cplusplus.com/reference/algorithm/next_permutation/