diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-10-13 14:06:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-13 14:06:29 +0200 |
commit | 7969913ee302ec4a19c38c529b99ce12edddb5b7 (patch) | |
tree | 05c7a5b229aaddf8524ce93a59db3d92ea77cb54 /vespalib | |
parent | 7b380ed31ec056ad2ca1e627025bccdccde316f1 (diff) | |
parent | 7e4b77ee4e02b70e92908ba3bd4af5e0a85a48f5 (diff) |
Merge pull request #24423 from vespa-engine/havardpe/better-return-value-handling
unify return value handling using universal references
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/vespa/vespalib/coro/lazy.h | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/vespalib/src/vespa/vespalib/coro/lazy.h b/vespalib/src/vespa/vespalib/coro/lazy.h index 38a57108f04..5a10c05bc24 100644 --- a/vespalib/src/vespa/vespalib/coro/lazy.h +++ b/vespalib/src/vespa/vespalib/coro/lazy.h @@ -38,11 +38,10 @@ public: }; return awaiter(); } - void return_value(const T &ret_value) noexcept(std::is_nothrow_move_constructible_v<T>) requires(std::copy_constructible<T>) { - value = ret_value; - } - void return_value(T &&ret_value) noexcept(std::is_nothrow_move_constructible_v<T>) { - value = std::move(ret_value); + template <typename RET> + requires std::is_convertible_v<RET&&,T> + void return_value(RET &&ret_value) noexcept(std::is_nothrow_constructible_v<T,RET&&>) { + value = std::forward<RET>(ret_value); } void unhandled_exception() noexcept { exception = std::current_exception(); @@ -52,7 +51,7 @@ public: std::coroutine_handle<> waiter; promise_type(promise_type &&) = delete; promise_type(const promise_type &) = delete; - promise_type() : value(std::nullopt), exception(), waiter(std::noop_coroutine()) {} + promise_type() noexcept : value(std::nullopt), exception(), waiter(std::noop_coroutine()) {} T &result() & { if (exception) { std::rethrow_exception(exception); |