microsoft / cppwinrt

C++/WinRT
MIT License
1.64k stars 238 forks source link

Add synchronous generator support for IIterable<T> #1323

Closed Fulgen301 closed 1 year ago

Fulgen301 commented 1 year ago

This implements #1278.

IIterable::First() throws E_CHANGED_STATE if it is called more than one time since the coroutine has already been resumed at that point; however, I am unsure whether this violates the API contract:

If changes are made to the collection, such as adding, modifying, or deleting elements, the iterator is permitted to raise an exception for all future operations.

Fulgen301 commented 1 year ago

@microsoft-github-policy-service agree

kennykerr commented 1 year ago

Unfortunately, a project maintainer is not currently available to review this pull request. Please see the contributing guide for more information. Feel free to keep the conversation going on the related issue.

kennykerr commented 1 year ago

The https://github.com/microsoft/wil library is where we've been collecting implementation helpers such as this. You might want to open an issue on that repo for consideration.

jonwis commented 1 year ago

The https://github.com/microsoft/wil library is where we've been collecting implementation helpers such as this. You might want to open an issue on that repo for consideration.

Yes - this looks much more appropriate for wil or https://github.com/microsoft/cpp-async as it doesn't really require cppwinrt on its own. Looking forward to the PR on either of those places!

sylveon commented 1 year ago

Feels weird to have to IAsyncOperation support be built-in but not IIterable. Perhaps both should be moved to wil?

kennykerr commented 1 year ago

Async coroutine support is fundamental to C++/WinRT for both consumption and production. Generator support for iteration, while cool, has very narrowly defined application.