43 using pointer = std::add_pointer_t<reference>;
64 value = std::addressof(v);
77 std::coroutine_handle<promise_type>
handle_;
79 explicit iterator(std::coroutine_handle<promise_type> h) noexcept : handle_(h) {}
89 handle_ = std::exchange(other.handle_, {});
95 assert(!handle_.done() &&
"Can't increment generator end iterator");
106 assert(!handle_.done() &&
"Can't dereference generator end iterator");
107 return *handle_.promise().value;
111 return std::addressof(
operator*());
114 [[nodiscard]]
bool operator==(std::default_sentinel_t)
const noexcept {
122 static_assert(std::input_iterator<iterator>);
129 assert(promise_ &&
"Can't call begin on moved-from generator");
130 auto handle = std::coroutine_handle<promise_type>::from_promise(*promise_);
134 [[nodiscard]] std::default_sentinel_t
end() const noexcept {
136 return std::default_sentinel;
147inline constexpr bool std::ranges::enable_view<mp_coro::generator<T>> =
true;
iterator(iterator &&other) noexcept
iterator(std::coroutine_handle< promise_type > h) noexcept
iterator & operator=(iterator &&other) noexcept
reference operator*() const noexcept
generator::value_type value_type
pointer operator->() const noexcept
std::ptrdiff_t difference_type
bool operator==(std::default_sentinel_t) const noexcept
std::coroutine_handle< promise_type > handle_
promise_ptr< promise_type > promise_
std::remove_reference_t< T > value_type
std::conditional_t< std::is_reference_v< T >, T, const value_type & > reference
generator(promise_type *promise)
std::add_pointer_t< reference > pointer
std::default_sentinel_t end() const noexcept
std::unique_ptr< T, coro_deleter > promise_ptr
RAII wrapper that destroys promise object's associated coroutine.
Base class with deleted copy constructor and copy assignment operator.
generator get_return_object() noexcept
void await_transform()=delete
static void return_void() noexcept
std::suspend_always yield_value(reference v) noexcept
static std::suspend_always final_suspend() noexcept
static std::suspend_always initial_suspend() noexcept
void unhandled_exception()