tmp/tmp9itjl69w/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Class template `generator` <a id="coro.generator.class">[[coro.generator.class]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
namespace std {
|
| 5 |
+
template<class Ref, class V = void, class Allocator = void>
|
| 6 |
+
class generator : public ranges::view_interface<generator<Ref, V, Allocator>> {
|
| 7 |
+
private:
|
| 8 |
+
using value = conditional_t<is_void_v<V>, remove_cvref_t<Ref>, V>; // exposition only
|
| 9 |
+
using reference = conditional_t<is_void_v<V>, Ref&&, Ref>; // exposition only
|
| 10 |
+
|
| 11 |
+
// [coro.generator.iterator], class generator::iterator
|
| 12 |
+
class iterator; // exposition only
|
| 13 |
+
|
| 14 |
+
public:
|
| 15 |
+
using yielded =
|
| 16 |
+
conditional_t<is_reference_v<reference>, reference, const reference&>;
|
| 17 |
+
|
| 18 |
+
// [coro.generator.promise], class generator::promise_type
|
| 19 |
+
class promise_type;
|
| 20 |
+
|
| 21 |
+
generator(const generator&) = delete;
|
| 22 |
+
generator(generator&& other) noexcept;
|
| 23 |
+
|
| 24 |
+
~generator();
|
| 25 |
+
|
| 26 |
+
generator& operator=(generator other) noexcept;
|
| 27 |
+
|
| 28 |
+
iterator begin();
|
| 29 |
+
default_sentinel_t end() const noexcept;
|
| 30 |
+
|
| 31 |
+
private:
|
| 32 |
+
coroutine_handle<promise_type> coroutine_ = nullptr; // exposition only
|
| 33 |
+
unique_ptr<stack<coroutine_handle<>>> active_; // exposition only
|
| 34 |
+
};
|
| 35 |
+
}
|
| 36 |
+
```
|
| 37 |
+
|
| 38 |
+
*Mandates:*
|
| 39 |
+
|
| 40 |
+
- If `Allocator` is not `void`, `allocator_traits<Allocator>::pointer`
|
| 41 |
+
is a pointer type.
|
| 42 |
+
- *`value`* is a cv-unqualified object type.
|
| 43 |
+
- *`reference`* is either a reference type, or a cv-unqualified object
|
| 44 |
+
type that models `copy_constructible`.
|
| 45 |
+
- Let `RRef` denote `remove_reference_t<reference>&&` if *`reference`*
|
| 46 |
+
is a reference type, and *`reference`* otherwise. Each of:
|
| 47 |
+
- `common_reference_with<reference&&, value&>`,
|
| 48 |
+
- `common_reference_with<reference&&, RRef&&>`, and
|
| 49 |
+
- `\texttt{common_reference_with}<RRef&&, const \exposid{value}&>`
|
| 50 |
+
|
| 51 |
+
is modeled.
|
| 52 |
+
\[*Note 1*: These requirements ensure the exposition-only *`iterator`*
|
| 53 |
+
type can model `indirectly_readable` and thus
|
| 54 |
+
`input_iterator`. — *end note*]
|
| 55 |
+
|
| 56 |
+
If `Allocator` is not `void`, it shall meet the *Cpp17Allocator*
|
| 57 |
+
requirements.
|
| 58 |
+
|
| 59 |
+
Specializations of `generator` model `view` and `input_range`.
|
| 60 |
+
|
| 61 |
+
The behavior of a program that adds a specialization for `generator` is
|
| 62 |
+
undefined.
|
| 63 |
+
|