This commit is contained in:
2025-10-25 03:02:53 +03:00
commit 043225d523
3416 changed files with 681196 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
[coroutine.generator.overview]
# 25 Ranges library [[ranges]](./#ranges)
## 25.8 Range generators [[coro.generator]](coro.generator#coroutine.generator.overview)
### 25.8.1 Overview [coroutine.generator.overview]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L18041)
Class template generator presents
a view of the elements yielded by the evaluation of a coroutine[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/ranges.tex#L18045)
A generator generates a sequence of elements by
repeatedly resuming the coroutine from which it was returned[.](#2.sentence-1)
Elements of the sequence are produced by the coroutine
each time a co_yield statement is evaluated[.](#2.sentence-2)
When the co_yield statement is of the formco_yield elements_of(r),
each element of the range r is successively produced as an element of the sequence[.](#2.sentence-3)
[*Example [1](#example-1)*: generator<int> ints(int start = 0) {while (true)co_yield start++;}void f() {for (auto i : ints() | views::take(3)) cout << i << ' '; // prints 0 1 2} — *end example*]