3.9 KiB
[coro.generator.class]
25 Ranges library [ranges]
25.8 Range generators [coro.generator]
25.8.3 Class template generator [coro.generator.class]
namespace std {template<class Ref, class Val = void, class Allocator = void>class generator : public ranges::view_interface<generator<Ref, Val, Allocator>> {private:using value = conditional_t<is_void_v, remove_cvref_t, Val>; // exposition onlyusing reference = conditional_t<is_void_v, Ref&&, Ref>; // exposition only// [coro.generator.iterator], class generator::iteratorclass iterator; // exposition onlypublic:using yielded = conditional_t<is_reference_v<reference>, reference, const reference&>; // [coro.generator.promise], class generator::promise_typeclass promise_type;
generator(const generator&) = delete; generator(generator&& other) noexcept; ~generator();
generator& operator=(generator other) noexcept; iterator begin(); default_sentinel_t end() const noexcept; private: coroutine_handle<promise_type> coroutine_ = nullptr; // exposition only unique_ptr<stack<coroutine_handle<>>> active_; // exposition only};}
Mandates:
-
If Allocator is not void,allocator_traits::pointer is a pointer type.
-
value is a cv-unqualified object type.
-
reference is either a reference type, or a cv-unqualified object type that models copy_constructible.
-
Let RRef denote remove_reference_t<reference>&& if reference is a reference type, and reference otherwise. Each of:
common_reference_with<reference&&, value&>,
common_reference_with<reference&&, RRef&&>, and
common_reference_with<RRef&&, const value&>
is modeled. [Note 1: These requirements ensure the exposition-only iterator type can model indirectly_readable and thus input_iterator. â end note]
If Allocator is not void, it shall meet the Cpp17Allocator requirements.
Specializations of generator modelview and input_range.
The behavior of a program that adds a specialization for generator is undefined.