diff options
| author | thegeorg <[email protected]> | 2025-11-06 17:13:27 +0300 |
|---|---|---|
| committer | thegeorg <[email protected]> | 2025-11-06 17:43:28 +0300 |
| commit | b64824d81555d01eeb83574daaaef7bb670461f4 (patch) | |
| tree | d7aa8a77a0a076599f98529072936b511ef84fe0 /library/cpp/threading/future/core | |
| parent | 92f0fb706123c524bda1e50de2ac060cdeb7f6c8 (diff) | |
Try to prevent slicing in `co_return ex;`
commit_hash:348f2fb14a4a93cfa3c8504419d021c1f41e4b8f
Diffstat (limited to 'library/cpp/threading/future/core')
| -rw-r--r-- | library/cpp/threading/future/core/coroutine_traits.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/library/cpp/threading/future/core/coroutine_traits.h b/library/cpp/threading/future/core/coroutine_traits.h index b36362db28a..9ad791e58d0 100644 --- a/library/cpp/threading/future/core/coroutine_traits.h +++ b/library/cpp/threading/future/core/coroutine_traits.h @@ -87,6 +87,11 @@ struct std::coroutine_traits<NThreading::TFuture<T>, Args...> { Y_ASSERT(success && "value already set"); } + // Allow only rvalues to be returned to prevent slicing + template <typename E> + requires std::derived_from<std::remove_cvref_t<E>, std::exception> + void return_value(E& err) = delete; + void return_value(auto&& val) { bool success = State_->TrySetValue(std::forward<decltype(val)>(val), /* deferCallbacks */ true); Y_ASSERT(success && "value already set"); |
