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

fix(coro): fix an oopsie #1219

Merged
merged 2 commits into from
Aug 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 6 additions & 26 deletions include/dpp/coro/awaitable.h
Original file line number Diff line number Diff line change
Expand Up @@ -534,31 +534,19 @@ class basic_promise : public detail::promise::promise_base<T> {
}

/**
* @brief Construct the result by copy, and resume any awaiter.
*
* @tparam Notify Whether to resume any awaiter or not.
* @throws dpp::logic_exception if the promise is not empty.
*/
template <bool Notify = true, typename U = T>
requires (std::convertible_to<const U&, T>)
void set_value(const U& v) {
emplace_value<Notify>(v);
}

/**
* @brief Construct the result by move, and resume any awaiter.
* @brief Construct the result by forwarding reference, and resume any awaiter.
*
* @tparam Notify Whether to resume any awaiter or not.
* @throws dpp::logic_exception if the promise is not empty.
*/
template <bool Notify = true, typename U = T>
requires (std::convertible_to<U&&, T>)
void set_value(U&& v) {
emplace_value<Notify>(std::move(v));
emplace_value<Notify>(std::forward<U>(v));
}

/**
* @brief Construct the result by move, and resume any awaiter.
* @brief Construct a void result, and resume any awaiter.
*
* @tparam Notify Whether to resume any awaiter or not.
* @throws dpp::logic_exception if the promise is not empty.
Expand Down Expand Up @@ -605,19 +593,11 @@ class moveable_promise {
}

/**
* @copydoc basic_promise<T>::set_value(const T&)
*/
template <bool Notify = true, typename U = T>
void set_value(const U& v) requires (std::convertible_to<const U&, T>) {
shared_state->template set_value<Notify>(v);
}

/**
* @copydoc basic_promise<T>::set_value(T&&)
* @copydoc basic_promise<T>::set_value(U&&)
*/
template <bool Notify = true, typename U = T>
void set_value(U&& v) requires (std::convertible_to<const U&, T>) {
shared_state->template set_value<Notify>(std::move(v));
void set_value(U&& v) requires (std::convertible_to<U&&, T>) {
shared_state->template set_value<Notify>(std::forward<U>(v));
}

/**
Expand Down
Loading