Skip to content

Commit aaeed33

Browse files
authored
fix(coro): fix an oopsie (#1219)
1 parent 19e24f3 commit aaeed33

File tree

1 file changed

+6
-26
lines changed

1 file changed

+6
-26
lines changed

include/dpp/coro/awaitable.h

+6-26
Original file line numberDiff line numberDiff line change
@@ -534,31 +534,19 @@ class basic_promise : public detail::promise::promise_base<T> {
534534
}
535535

536536
/**
537-
* @brief Construct the result by copy, and resume any awaiter.
538-
*
539-
* @tparam Notify Whether to resume any awaiter or not.
540-
* @throws dpp::logic_exception if the promise is not empty.
541-
*/
542-
template <bool Notify = true, typename U = T>
543-
requires (std::convertible_to<const U&, T>)
544-
void set_value(const U& v) {
545-
emplace_value<Notify>(v);
546-
}
547-
548-
/**
549-
* @brief Construct the result by move, and resume any awaiter.
537+
* @brief Construct the result by forwarding reference, and resume any awaiter.
550538
*
551539
* @tparam Notify Whether to resume any awaiter or not.
552540
* @throws dpp::logic_exception if the promise is not empty.
553541
*/
554542
template <bool Notify = true, typename U = T>
555543
requires (std::convertible_to<U&&, T>)
556544
void set_value(U&& v) {
557-
emplace_value<Notify>(std::move(v));
545+
emplace_value<Notify>(std::forward<U>(v));
558546
}
559547

560548
/**
561-
* @brief Construct the result by move, and resume any awaiter.
549+
* @brief Construct a void result, and resume any awaiter.
562550
*
563551
* @tparam Notify Whether to resume any awaiter or not.
564552
* @throws dpp::logic_exception if the promise is not empty.
@@ -605,19 +593,11 @@ class moveable_promise {
605593
}
606594

607595
/**
608-
* @copydoc basic_promise<T>::set_value(const T&)
609-
*/
610-
template <bool Notify = true, typename U = T>
611-
void set_value(const U& v) requires (std::convertible_to<const U&, T>) {
612-
shared_state->template set_value<Notify>(v);
613-
}
614-
615-
/**
616-
* @copydoc basic_promise<T>::set_value(T&&)
596+
* @copydoc basic_promise<T>::set_value(U&&)
617597
*/
618598
template <bool Notify = true, typename U = T>
619-
void set_value(U&& v) requires (std::convertible_to<const U&, T>) {
620-
shared_state->template set_value<Notify>(std::move(v));
599+
void set_value(U&& v) requires (std::convertible_to<U&&, T>) {
600+
shared_state->template set_value<Notify>(std::forward<U>(v));
621601
}
622602

623603
/**

0 commit comments

Comments
 (0)