Skip to content

Commit

Permalink
try making co_return strict
Browse files Browse the repository at this point in the history
  • Loading branch information
bashtanov committed Jan 3, 2025
1 parent f194d34 commit 54e7a37
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/seastar/core/coroutine.hh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public:

template<typename... U>
void return_value(U&&... value) {
_promise.set_value(std::forward<U>(value)...);
_promise.set_value(non_explicit_tag{}, std::forward<U>(value)...);
}

void return_value(coroutine::exception ce) noexcept {
Expand Down
11 changes: 11 additions & 0 deletions include/seastar/core/future.hh
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,9 @@ struct get0_return_type {
template<typename T>
using maybe_wrap_ref = std::conditional_t<std::is_reference_v<T>, std::reference_wrapper<std::remove_reference_t<T>>, T>;

struct non_explicit_tag{};


/// \brief Wrapper for keeping uninitialized values of non default constructible types.
///
/// This is similar to a std::optional<T>, but it doesn't know if it is holding a value or not, so the user is
Expand All @@ -302,8 +305,16 @@ struct uninitialized_wrapper_base<T, false> {
maybe_wrap_ref<T> value;
} _v;

template<typename U>
static T make_implicitly(U&& v) {
return std::forward<U>(v);
}
public:
uninitialized_wrapper_base() noexcept = default;
template<typename U>
void uninitialized_set(non_explicit_tag, U&& v) {
new (&_v.value) maybe_wrap_ref<T>(make_implicitly(std::forward<U>(v)));
}
template<typename... U>
std::enable_if_t<!std::is_same_v<std::tuple<std::remove_cv_t<U>...>, std::tuple<tuple_type>>, void>
uninitialized_set(U&&... vs) {
Expand Down

0 comments on commit 54e7a37

Please sign in to comment.