feat update
All checks were successful
linux-x64-gcc / linux-gcc (Release) (push) Successful in 1m40s
linux-x64-gcc / linux-gcc (Debug) (push) Successful in 53s

This commit is contained in:
tqcq 2024-03-26 08:51:17 +08:00
parent a10703176c
commit d8c5807af6
3 changed files with 11 additions and 8 deletions

View File

@ -25,15 +25,15 @@ struct JustSender {
template<typename R> template<typename R>
JustOperation<T, R> Connect(R receiver) JustOperation<T, R> Connect(R receiver)
{ {
return {value, receiver}; return {std::forward<T>(value), receiver};
} }
}; };
template<typename T> template<typename T>
JustSender<T> JustSender<T>
Just(T value) Just(T &&value)
{ {
return {value}; return {std::forward<T>(value)};
} }
}// namespace detail }// namespace detail

View File

@ -13,12 +13,12 @@ struct ThenReceiver {
F func; F func;
bool stopped = false; bool stopped = false;
template<typename U> template<typename U, typename Ret = invoke_result_t<F, U>>
void SetValue(U &&val) void SetValue(U &&val)
{ {
if (stopped) { return; } if (stopped) { return; }
try { try {
receiver.SetValue(func(std::forward<U>(val))); receiver.SetValue(std::forward<Ret>(func(std::forward<U>(val))));
} catch (...) { } catch (...) {
SetError(std::current_exception()); SetError(std::current_exception());
} }
@ -49,7 +49,7 @@ struct ThenOperation {
template<typename S, typename F> template<typename S, typename F>
struct ThenSender { struct ThenSender {
using result_t = invoke_result_t<F, typename S::result_t>; using result_t = invoke_result_t<F, typename decay_t<S>::result_t>;
S sender; S sender;
F func; F func;
@ -62,9 +62,9 @@ struct ThenSender {
template<typename S, typename F> template<typename S, typename F>
ThenSender<S, F> ThenSender<S, F>
Then(S sender, F &&func) Then(S &&sender, F &&func)
{ {
return {sender, std::forward<F>(func)}; return {std::forward<S>(sender), std::forward<F>(func)};
} }
}// namespace detail }// namespace detail

View File

@ -18,6 +18,9 @@ using ConnectResultT = typename ConnectResult<S, R>::type;
template<typename F, typename... Args> template<typename F, typename... Args>
using invoke_result_t = eggs::invoke_result_t<F, Args...>; using invoke_result_t = eggs::invoke_result_t<F, Args...>;
template<typename T>
using decay_t = typename std::decay<T>::type;
}// namespace detail }// namespace detail
}// namespace sled }// namespace sled
#endif// SLED_FUTURES_DETAIL_TRAITS_H #endif// SLED_FUTURES_DETAIL_TRAITS_H