General Purpose library for Freestanding C++ and POSIX systems
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 

26 行
498 B

#pragma once
#include "gp/algorithm/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;
}
}