See this example code:
#include <ranges>
int main() {
for(auto i : std::ranges::iota_view(1) | std::views::reverse)
break;
}
It compiles on gcc (I cannot check on clang/msvc - since they do not support ranges). Of course -- it runs "forever" and does nothing.
I also checked that doing std::ranges::rbegin(inf)
or std::ranges::rend(inf)
on infinite range is not allowed (it does not compile).
I am not sure if this is correct c++ code? And I am curious about std::ranges::reverse implementation - looks like rbegin/rend is not used to implement this view -- so how this implementation works?