General Purpose library for Freestanding C++ and POSIX systems
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 

27 righe
500 B

#pragma once
#include "gp/algorithms/move.hpp"
namespace gp {
template<typename iterator>
iterator rotate(iterator first, iterator new_first, iterator last)
{
if(first == new_first) return last;
if(new_first == last) return first;
iterator in = new_first;
iterator out = first;
iterator mv = first;
while(in != last) {
if(out == mv) mv = in;
gp::swap((*out++), (*in++));
}
// rotate the remaining sequence into place
(rotate)(out, mv, last);
return out;
}
}