8000 Fix coro::when_all not compiling when passing the output of std::views by ripose-jp · Pull Request #209 · jbaldwin/libcoro · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix coro::when_all not compiling when passing the output of std::views #209

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

Merged
merged 1 commit into from
Nov 19, 2023

Conversation

ripose-jp
Copy link
Contributor

Fixes a bug that prevents coro::when_all from compiling when passing the result of a std::ranges::views of awaitables. The for-each loop in coro::when_all defines an auto& a when looping through awaitables, when it should use auto&& a since it's moving them into a vector.

Here is a minimal example that should compile, but currently doesn't.

#include <iostream>
#include <ranges>

#include <coro/coro.hpp>

static coro::task<void> foo(int i)
{
    std::cout << i << '\n';
    co_return;
}

int main(void)
{
    coro::sync_wait(coro::when_all(
        std::views::iota(0, 6)
        | std::views::transform(::foo)
    ));
    return 0;
}

Also there's a bug in your .githooks that changes all & in the code portions of your README to ${EXAMPLE_CORO_TASK_CPP}. I haven't fixed that, but you I thought you should know.

Change the for-each loop in coro::when_all for range_types from an
lvalue reference to an rvalue reference. This fixes a bug that prevents
passing the output of a std::views operation directly to coro::when_all.
@jbaldwin jbaldwin force-pushed the fix_when_all_ranges branch from 58df152 to 5124fd9 Compare November 19, 2023 19:35
@jbaldwin
Copy link
Owner

Thanks for making a PR to fix this issue. LGTM 👍

@jbaldwin jbaldwin merged commit 138fc76 into jbaldwin:main Nov 19, 2023
@ripose-jp ripose-jp deleted the fix_when_all_ranges branch November 22, 2023 03:51
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
0