Is there a way to swap two sections of an array without needed to create a new one? Like cutting a deck of cards? I was able to do this by allocating a new array and then inserting the top sector first then the lower sector elements after.
I have made attempts to do it without the extra array and have two temporary variables to hold the elements while the algorithm does the swapping between the sections. The thing is that my attempt would work for specific cases.
For example:
original array: 0 1 2| 3 4 5 6 7
cut at index two
swapped array:
3 4 5 6 7| 0 1 2

std::reverse()calls.