Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions include/stdexec/__detail/__any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,14 +916,14 @@ namespace STDEXEC::__any
return std::swap(__this_ptr, __that_ptr);

if (__this_ptr == nullptr)
return __value(__other).__move_to(__root_ptr_, __buff_);
return __other.__move_to_empty(*this);

if (__that_ptr == nullptr)
return __value(*this).__move_to(__other.__root_ptr_, __other.__buff_);
return (*this).__move_to_empty(__other);

auto temp = std::move(*this);
__value(__other).__move_to(__root_ptr_, __buff_);
__value(temp).__move_to(__other.__root_ptr_, __other.__buff_);
auto __temp = std::move(*this);
__other.__move_to_empty(*this);
__temp.__move_to_empty(__other);
}
}

Expand Down Expand Up @@ -1050,6 +1050,31 @@ namespace STDEXEC::__any
}
}

constexpr void __move_to_empty(__value_proxy_root &__other) noexcept
requires __movable
{
STDEXEC_IF_CONSTEVAL
{
__other.__root_ptr_ = std::exchange(__root_ptr_, nullptr);
}
else
{
STDEXEC_ASSERT(!__empty(*this));
STDEXEC_ASSERT(__empty(__other));
auto &__this_ptr = *__std::start_lifetime_as<__tagged_ptr>(__buff_);
auto &__that_ptr = *__std::start_lifetime_as<__tagged_ptr>(__other.__buff_);
if (__this_ptr.__is_tagged())
{
__that_ptr = std::exchange(__this_ptr, nullptr);
}
else
{
__value(*this).__move_to(__other.__root_ptr_, __other.__buff_);
__reset(*this);
}
}
}

STDEXEC_ATTRIBUTE(always_inline)
constexpr void __reset_() noexcept final
{
Expand Down
Loading
Loading