This is my solution. I have found out it is similar to @SaltedFish code but rotating the elements inline, without swapping, and moving to the temp variable only the first element of each cycle.

class Solution {
public:
unsigned GCD(unsigned u, unsigned v) {
while (v != 0) {
unsigned r = u % v;
u = v;
v = r;
}
return u;
}
void rotate(vector<int>& nums, int k) {
int n = nums.size();
k = n - (k % n); // Transforming the problem to the equivalent rotation to the left
// to simplify indexes progression
int gcd = GCD(n, k);
for (int i = 0; i < gcd; i++) {
int tmp = nums[i];
int curr = i;
for (int next = (i + k) % n; next != i; next = (next + k) % n) {
nums[curr] = nums[next];
curr = next;
}
nums[curr] = tmp;
}
}
};