Skip to content

Commit

Permalink
ResultVariant is not default constructible
Browse files Browse the repository at this point in the history
  • Loading branch information
maikel committed Jan 20, 2025
1 parent b97725a commit 961776b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions source/sio/sequence/last.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ namespace sio {

template <class Receiver>
void visit_result(Receiver&& rcvr) noexcept {
ResultVariant result_on_stack;
{
ResultVariant result_on_stack = [&]() {
std::scoped_lock lock{mutex_};
result_on_stack = static_cast<ResultVariant&&>(result_.__get());
}
ResultVariant result = static_cast<ResultVariant&&>(result_.__get());
return result;
}();
result_.__destroy();

std::visit(
[&]<class Tuple>(Tuple&& tuple) noexcept {
Expand Down Expand Up @@ -75,6 +76,11 @@ namespace sio {

template <class Receiver>
void visit_result(Receiver&& rcvr) noexcept {
ResultVariant result_on_stack = [&]() {
ResultVariant result = static_cast<ResultVariant&&>(result_.__get());
return result;
}();
result_.__destroy();
std::visit(
[&]<class Tuple>(Tuple&& tuple) noexcept {
if constexpr (__not_decays_to<Tuple, std::monostate>) {
Expand All @@ -88,7 +94,7 @@ namespace sio {
stdexec::set_stopped(static_cast<Receiver&&>(rcvr));
}
},
static_cast<ResultVariant&&>(result_.__get()));
static_cast<ResultVariant&&>(result_on_stack));
}
};

Expand Down

0 comments on commit 961776b

Please sign in to comment.