This looks like a libstdc++ problem, which we can see by running a test using both libstdc++ and libc++ , and we can see that it only fails when we use libstdc++ .
Using replicators of online compilers makes the quick test quite simple, lib ++ live version does not create errors. While the version of libstdc ++ live generates the following error:
error: variable has an incomplete type 'void'
If we look at the cppreference entry for std :: rotate , we can see that the pre C ++ 11 version really returned void :
template< class ForwardIt > void rotate( ForwardIt first, ForwardIt n_first, ForwardIt last ) (until C++11) template< class ForwardIt > ForwardIt rotate( ForwardIt first, ForwardIt n_first, ForwardIt last ); (since C++11)
As stated in the comments above, this is apparently a known bug :
25.3 | Mutating sequence operations | Partial rotate | returns void.
In addition, it may be worth noting Visual Studio without problems with this code.
source share