Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P2502R2 <generator>: Synchronous Coroutine Generator For Ranges #2936

Closed
4 tasks done
StephanTLavavej opened this issue Jul 25, 2022 · 2 comments · Fixed by #4953
Closed
4 tasks done

P2502R2 <generator>: Synchronous Coroutine Generator For Ranges #2936

StephanTLavavej opened this issue Jul 25, 2022 · 2 comments · Fixed by #4953
Labels
cxx23 C++23 feature fixed Something works now, yay! generator C++23 generator

Comments

@StephanTLavavej
Copy link
Member

StephanTLavavej commented Jul 25, 2022

WG21-P2502R2 <generator>: Synchronous Coroutine Generator For Ranges
WG21-P2787R1 pmr::generator
LWG-3762 generator::iterator::operator== should pass by reference
LWG-3826 Redundant specification [for overload of yield_value]
LWG-3894 generator::promise_type::yield_value(ranges::elements_of<Rng, Alloc>) should not be noexcept

Feature-test macro:

#define __cpp_lib_generator 202207L

The IDE already knows about this extensionless header.

Todo

According to @CaseyCarter in #4342 (comment) and as observed by @frederick-vs-ja in #4342 (comment) , the feature/generator branch needs:

  • More thorough testing
  • A quick audit to ensure it meets all the requirements
  • A review of the allocator handling
  • Thought put into what to do when __cpp_lib_byte is unavailable
@StephanTLavavej StephanTLavavej added the cxx23 C++23 feature label Jul 25, 2022
@StephanTLavavej
Copy link
Member Author

I believe that @CaseyCarter is working on his feature.

@CaseyCarter
Copy link
Member

I haven't had time for STL work, and this has sat idle for so long that it's embarrassing. If someone wants to pick this up, feel free to do so. My prototype implementation is in a single commit at a5f4f74, which I just rebased on current main. It should provide a good starting point - if nothing else, it illustrates how the "stack of coroutine handles" the specification describes should actually be implemented via links in promises and awaiters and not a concrete std::stack requiring external memory allocation. The test is currently more of a demonstration than a true test, as fits a reference implementation for a WG21 proposal, it needs completion.

I'd also recommend auditing to ensure the implementation meets all of the requirements in the Standard wording. I think I implemented changes as they were made to the proposal, but suspect I did something hack-ish storing non-trivially-copyable allocator types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cxx23 C++23 feature fixed Something works now, yay! generator C++23 generator
Projects
Development

Successfully merging a pull request may close this issue.

2 participants