23template <
typename T,
typename Allocator = HeapFrameAllocator>
33 [[nodiscard]]
static void*
operator new(std::size_t size) {
34 return Allocator::allocate(size);
37 static void operator delete(
void* ptr)
noexcept {
38 Allocator::deallocate(ptr, 0);
41 static void operator delete(
void* ptr, std::size_t size)
noexcept {
42 Allocator::deallocate(ptr, size);
47 return Generator(std::coroutine_handle<promise_type>::from_promise(*
this));
69#if defined(__cpp_exceptions) || defined(__EXCEPTIONS)
95 if (_handle.promise().exception) {
96#if defined(__cpp_exceptions) || defined(__EXCEPTIONS)
97 std::rethrow_exception(_handle.promise().exception);
111 return *_handle.promise().currentValue;
116 return _handle.promise().currentValue;
121 return !_handle || _handle.done();
126 return !(*
this == s);
130 std::coroutine_handle<promise_type> _handle{
nullptr};
150 : _handle(std::exchange(other._handle,
nullptr))
155 if (
this != &other) {
159 _handle = std::exchange(other._handle,
nullptr);
168 if (_handle.promise().exception) {
169#if defined(__cpp_exceptions) || defined(__EXCEPTIONS)
170 std::rethrow_exception(_handle.promise().exception);
183 std::coroutine_handle<promise_type> _handle{
nullptr};
187template <
typename T, std::
size_t MaxFrames = 16, std::
size_t FrameSize = 256>
Zero-heap static coroutine frame pool and frame allocator policies.
Definition Generator.hpp:77
Iterator & operator++()
Definition Generator.hpp:91
T value_type
Definition Generator.hpp:81
void operator++(int)
Definition Generator.hpp:104
bool operator!=(Sentinel s) const noexcept
Definition Generator.hpp:124
constexpr Iterator() noexcept=default
std::ptrdiff_t difference_type
Definition Generator.hpp:80
const T * pointer
Definition Generator.hpp:83
reference operator*() const noexcept
Definition Generator.hpp:109
pointer operator->() const noexcept
Definition Generator.hpp:114
std::input_iterator_tag iterator_category
Definition Generator.hpp:79
const T & reference
Definition Generator.hpp:82
bool operator==(Sentinel) const noexcept
Definition Generator.hpp:119
Definition Generator.hpp:75
Zero-heap C++20 pull-based lazy generator sequence with configurable frame allocator....
Definition Generator.hpp:24
~Generator()
Definition Generator.hpp:139
Generator & operator=(const Generator &)=delete
Generator(Generator &&other) noexcept
Definition Generator.hpp:149
constexpr Sentinel end() noexcept
Definition Generator.hpp:177
T ValueType
Definition Generator.hpp:26
Allocator AllocatorType
Definition Generator.hpp:27
Iterator begin()
Definition Generator.hpp:164
Generator(const Generator &)=delete
Generator & operator=(Generator &&other) noexcept
Definition Generator.hpp:153
constexpr Generator() noexcept=default
Definition AsyncEvent.hpp:14
Definition Generator.hpp:29
void return_void() noexcept
Definition Generator.hpp:65
std::suspend_always final_suspend() noexcept
Definition Generator.hpp:51
void unhandled_exception() noexcept
Definition Generator.hpp:67
std::suspend_always initial_suspend() noexcept
Definition Generator.hpp:50
std::exception_ptr exception
Definition Generator.hpp:31
const T * currentValue
Definition Generator.hpp:30
std::suspend_always yield_value(const T &val) noexcept
Definition Generator.hpp:53
Generator get_return_object() noexcept
Definition Generator.hpp:45
std::suspend_always yield_value(T &&val) noexcept
Definition Generator.hpp:59