Skip to content

chore: update ds::generator for better code quality in generator.hh. - #277

Merged
hzhangxyz merged 1 commit into
mainfrom
dev/generator-better
Mar 15, 2026
Merged

chore: update ds::generator for better code quality in generator.hh.#277
hzhangxyz merged 1 commit into
mainfrom
dev/generator-better

Conversation

@hzhangxyz

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings March 15, 2026 10:35
@hzhangxyz
hzhangxyz merged commit f0b5bfd into main Mar 15, 2026
88 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the internal ds::generator implementation in include/ds/generator.hh, restructuring it around nested promise_type / iterator_type to simplify the coroutine wiring and iteration API.

Changes:

  • Replaces the separate _generator_promise<T> type with a nested _generator<T>::promise_type.
  • Reworks iteration to use an explicit iterator_type end() sentinel instead of nullptr_t.
  • Removes the std::coroutine_traits specialization previously used to bind _generator to its promise type.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread include/ds/generator.hh
Comment on lines +8 to 13
struct _generator {
struct promise_type;
struct iterator_type;
using handle_type = std::coroutine_handle<promise_type>;
handle_type handle_;

Comment thread include/ds/generator.hh
Comment on lines +16 to 20
_generator(_generator&& other) : handle_(other.handle_) {
other.handle_ = nullptr;
}
_generator& operator=(_generator&& other) noexcept {
_generator& operator=(_generator&& other) {
if (this != &other) {
Comment thread include/ds/generator.hh
Comment on lines +61 to +63
std::suspend_always yield_value(T value) {
value_ = value;
return {};
Comment thread include/ds/generator.hh
Comment on lines +65 to +67
void unhandled_exception() {
throw;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants