'Does range-v3's "sliding" view not work with lazy ranges?

I don't understand why the following code does not compile while the commented out version does work.

#include <range/v3/all.hpp>
#include <iostream>

namespace rv = ranges::views;

int main() {

    //std::vector<int> fives = {5,5,5,5,5,5,5,5,5,5};
    //auto rng = fives | rv::sliding(2);

    auto lazy_fives = rv::generate( [](){ return 5;});
    auto rng = lazy_fives  | rv::sliding(2);

    for (auto pair : rng | rv::take(10)) {
        for (auto val : pair) {
            std::cout << val << " ";
        }
        std::cout << "\n";
    }
}

On godbolt here.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source