I\'m using a circular buffer to push data onto either end of a list. After I\'m done I want to align the buffer so the first element in the list is at position zero and can be u
This algorithm taken from the std::rotate
implementation on cplusplus.com is quite nice:
template
void rotate (ForwardIterator first, ForwardIterator middle,
ForwardIterator last)
{
ForwardIterator next = middle;
while (first!=next)
{
swap (*first++,*next++);
if (next==last) next=middle;
else if (first==middle) middle=next;
}
}
http://www.cplusplus.com/reference/algorithm/rotate/