39 std::exception_ptr exception;
41 void*
operator new(std::size_t size) {
42 return ::operator
new(size);
45 void operator delete(
void* ptr, std::size_t size) {
46#if __cpp_sized_deallocation >= 201309L
47 ::operator
delete(ptr, size);
49 ::operator
delete(ptr);
57 [[nodiscard]]
static std::suspend_always initial_suspend()
noexcept {
61 [[nodiscard]]
static std::suspend_always final_suspend()
noexcept {
65 void unhandled_exception()
noexcept {
66 exception = std::current_exception();
69 std::suspend_always yield_value(
const T& from)
noexcept {
70 value = std::addressof(from);
75 static void return_void()
noexcept {}
77 void rethrow_if_exception()
const {
79 std::rethrow_exception(exception);
86 using iterator_category = std::input_iterator_tag;
87 using difference_type = std::ptrdiff_t;
89 using reference =
const T&;
90 using pointer =
const T*;
94 explicit iterator(std::coroutine_handle<promise_type> handle) noexcept : handle_{handle} {}
100 std::exchange(handle_, {}).promise().rethrow_if_exception();
106 void operator++(
int) {
107 static_cast<void>(operator++());
110 bool operator==(
const iterator& right)
const noexcept {
111 return handle_ == right.handle_;
114 bool operator!=(
const iterator& right)
const noexcept {
115 return !(*
this == right);
118 reference operator*()
const noexcept {
119 return *handle_.promise().value;
122 pointer operator->()
const noexcept {
123 return handle_.promise()._Value;
127 std::coroutine_handle<promise_type> handle_;