2016-02-24 49 views

回答

2

在範圍-V3,你會創建這樣一個範圍內view::generate

auto stream = ranges::view::generate([x=1245]() mutable { 
    auto old = x; 
    if(x % 2 == 0) 
     x /= 2; 
    else 
     x = 3 * x + 1; 
    return old; 
}); 

DEMO