diff --git a/include/proxy/v5/detail/core.h b/include/proxy/v5/detail/core.h index 8829e84..910dae4 100644 --- a/include/proxy/v5/detail/core.h +++ b/include/proxy/v5/detail/core.h @@ -360,16 +360,17 @@ R invoke_dispatch(Args&&... args) { #pragma warning(pop) #endif // defined(_MSC_VER) && !defined(__clang__) -template -struct destroying_guard { - explicit destroying_guard(P* p) noexcept : p_(p) {} - ~destroying_guard() noexcept(std::is_nothrow_destructible_v

) { p_->~P(); } - -private: - P* p_; +struct construction_dispatch { + template + PRO5D_STATIC_CALL(void, T&& self, void* rhs) noexcept( + nothrow_constructible, T>) { + std::construct_at(static_cast*>(rhs), + std::forward(self)); + } +}; +struct destruction_dispatch { + PRO5D_STATIC_CALL(void, auto&&) noexcept {} }; - -struct relocate_dispatch; template using erased_ptr_t = std::conditional_t ptr, Args... args) noexcept(NE) -> R { auto* self = std::launder( static_cast>*>(ptr)); - if constexpr (std::is_same_v) { - [self](void* rhs) { - if constexpr (is_bitwise_trivially_relocatable_v

) { - if constexpr (!std::is_empty_v

) { - std::uninitialized_copy_n(reinterpret_cast(self), - sizeof(P), static_cast(rhs)); - } - } else { - destroying_guard

guard{self}; - std::construct_at(static_cast(rhs), std::move(*self)); - } - }(args...); + if constexpr (std::is_same_v && + Q == qualifier_type::rv && + is_bitwise_trivially_relocatable_v

) { + if constexpr (!std::is_empty_v

) { + std::uninitialized_copy_n(reinterpret_cast(self), + sizeof(P), static_cast(args)...); + } } else if constexpr (Q == qualifier_type::rv) { - destroying_guard

guard{self}; + struct destroying_guard { + ~destroying_guard() noexcept(std::is_nothrow_destructible_v

) { + p->~P(); + } + P* p; + } guard{self}; return invoke_dispatch(get_operand(self), std::forward(args)...); } else { @@ -560,16 +561,6 @@ consteval bool is_metadata_well_formed() { } return false; } -struct copy_dispatch { - template - PRO5D_STATIC_CALL(void, const T& self, - void* rhs) noexcept(nothrow_constructible) { - std::construct_at(static_cast(rhs), self); - } -}; -struct destroy_dispatch { - PRO5D_STATIC_CALL(void, auto&&) noexcept {} -}; template struct lifetime_meta_traits : std::type_identity {}; template @@ -1031,12 +1022,12 @@ struct proxy_traits proxy_meta_base_t, composite_t< typename proxy_traits::super_meta, - lifetime_meta_t, - lifetime_meta_t, - lifetime_meta_t, + lifetime_meta_t, typename proxy_traits::self_op_meta, typename proxy_traits::refl_meta>>; @@ -1500,7 +1491,7 @@ class proxy : public detail::proxy_traits::direct_accessor, static_cast(detail::proxy_helper::get_ptr(rhs)), F2::max_size, ptr_); } else { - invoke(rhs, ptr_); } @@ -1520,7 +1511,7 @@ class proxy : public detail::proxy_traits::direct_accessor, F2::max_size, ptr_); } else { detail::proxy_helper::get_meta>(rhs) .function(rhs_ptr, ptr_); @@ -1547,7 +1538,7 @@ class proxy : public detail::proxy_traits::direct_accessor, { if constexpr (F::destructibility != lifetime_requirement::trivial) { if (meta_) { - invoke( std::move(*this));