Skip to content

Commit

Permalink
co_await must be used on rvalue
Browse files Browse the repository at this point in the history
  • Loading branch information
microcai committed Oct 13, 2024
1 parent 5174e2d commit c973b78
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion include/ucoro/awaitable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ namespace ucoro
requires(detail::is_awaiter_v<std::decay_t<A>>)
auto await_transform(A&& awaiter) const
{
return std::move(awaiter);
static_assert(std::is_rvalue_reference_v<decltype(awaiter)>, "co_await must be used on rvalue");
return std::forward<A>(awaiter);
}

template <typename A>
Expand Down
2 changes: 1 addition & 1 deletion tests/test1/test1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ucoro::awaitable<void> coro_compute_exec(int value)

auto comput_promise = coro_compute_int(value);

auto ret = co_await comput_promise;
auto ret = co_await std::move(comput_promise);
std::cout << "return: " << ret << std::endl;
co_return;
}
Expand Down

0 comments on commit c973b78

Please sign in to comment.