summaryrefslogtreecommitdiffstats
path: root/library/cpp
diff options
context:
space:
mode:
authorthegeorg <[email protected]>2025-07-16 15:34:29 +0300
committerthegeorg <[email protected]>2025-07-16 15:58:41 +0300
commitef045b77ff78b1860689616c25519d87081b6cbf (patch)
tree4f5c92d6db70c31434b1631636e36396fefbaa92 /library/cpp
parent535bd566280173b905d8ba4995475ebb805df490 (diff)
Add return lvalue test (and fix corresponding bugs)
commit_hash:f776eaac24e9bbe1abac58a171d9895556c43dd8
Diffstat (limited to 'library/cpp')
-rw-r--r--library/cpp/threading/future/core/coroutine_traits.h6
-rw-r--r--library/cpp/threading/future/ut_gtest/coroutine_traits_ut.cpp3
2 files changed, 7 insertions, 2 deletions
diff --git a/library/cpp/threading/future/core/coroutine_traits.h b/library/cpp/threading/future/core/coroutine_traits.h
index 502c5f8eb60..b36362db28a 100644
--- a/library/cpp/threading/future/core/coroutine_traits.h
+++ b/library/cpp/threading/future/core/coroutine_traits.h
@@ -3,6 +3,7 @@
#include <library/cpp/threading/future/future.h>
#include <coroutine>
+#include <utility>
template <typename... Args>
struct std::coroutine_traits<NThreading::TFuture<void>, Args...> {
@@ -75,11 +76,12 @@ struct std::coroutine_traits<NThreading::TFuture<T>, Args...> {
Y_ASSERT(success && "value already set");
}
- template <typename E> requires std::derived_from<E, std::exception>
+ template <typename E>
+ requires std::derived_from<std::remove_cvref_t<E>, std::exception>
void return_value(E&& err) {
// Allow co_return std::exception instances in order to avoid stack unwinding
bool success = State_->TrySetException(
- std::make_exception_ptr(std::move(err)),
+ std::make_exception_ptr(std::forward<E>(err)),
/* deferCallbacks */ true
);
Y_ASSERT(success && "value already set");
diff --git a/library/cpp/threading/future/ut_gtest/coroutine_traits_ut.cpp b/library/cpp/threading/future/ut_gtest/coroutine_traits_ut.cpp
index 75de1d1c7fe..a9b0176920e 100644
--- a/library/cpp/threading/future/ut_gtest/coroutine_traits_ut.cpp
+++ b/library/cpp/threading/future/ut_gtest/coroutine_traits_ut.cpp
@@ -147,6 +147,9 @@ TEST(TestFutureTraits, ErrorViaReturnException) {
auto coroutineReturnException = [&result]() -> NThreading::TFuture<size_t> {
result.push_back("coroutine_return_exception");
co_return std::runtime_error("exception_to_return");
+
+ static std::runtime_error another("another_exception_not_to_return");
+ co_return another;
};
auto coroutineReturnValueReturnException = [&]() -> NThreading::TFuture<size_t> {