core/coroutine: add a specialization for std::expected<void, Err> #2971
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As recorded in https://www.scylladb.com/2024/05/14/better-goodput-performance-through-c-exception-handling/ under
Approach 1: Avoid The Exceptions
there are places where we would like to avoid exceptions. One approach we do is useboost::result
, but now that we're on C++23 have instead favored usingstd::expected
as it's a bit simpler and "modern" (for what that is worth).However, for side effecting functions we've started to represent that with
std::expected<void, Err>
, which is fine, but very cumbersome to fully type out. We'd like to specialize coroutine_traits to make this case less verbose, but can't do it in our application due to it being in aninternal
namespace and compatibility not being ensured.So we propose a specialization for
std::expected
that allows the syntaxco_return {};
. This is really a small quality of life improvement for us we'd like to understand if there is an appetite for having upstream.