You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I have this coroutine, which generates a sequence of numbers and store the generator in a variable to reuse it later, but when I do reuse it, it skips over first value:
cppcoro::generator<int> numbers(int start) {
while (true) {
co_yield start++;
}
}
intmain() {
auto generator = numbers(0);
for (constint& i : generator | std::views::take(5)) {
std::cout << i << ''; //Prints "0 1 2 3 4", which is correct
}
for (constint& i : generator | std::views::take(5)) {
std::cout << i << ''; //Prints "6 7 8 9 10", which is incorrect as it has skipped over 5 for some reason
}
}
So I have this coroutine, which generates a sequence of numbers and store the generator in a variable to reuse it later, but when I do reuse it, it skips over first value:
Here's a godbolt link to see it in action
The text was updated successfully, but these errors were encountered: