From 707a648a4c3a90e81e8690dd556f3d9268a13b8f Mon Sep 17 00:00:00 2001 From: Eladash <18193363+elad335@users.noreply.github.com> Date: Sun, 24 Mar 2024 13:40:32 +0200 Subject: [PATCH] utils: Fix shared_ptr::store/exchange --- rpcs3/util/shared_ptr.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/rpcs3/util/shared_ptr.hpp b/rpcs3/util/shared_ptr.hpp index 109e28216a..138599d107 100644 --- a/rpcs3/util/shared_ptr.hpp +++ b/rpcs3/util/shared_ptr.hpp @@ -598,7 +598,7 @@ namespace stx constexpr atomic_ptr() noexcept = default; // Optimized value construct - template >> + template requires (!(sizeof...(Args) == 1 && (std::is_same_v, shared_type> || ...)) && std::is_constructible_v) explicit atomic_ptr(Args&&... args) noexcept { shared_type r = make_single(std::forward(args)...); @@ -805,7 +805,9 @@ namespace stx } } - template >> + // Create an object from variadic args + // If a type needs shared_type to be constructed, std::reference_wrapper can be used + template requires (!(sizeof...(Args) == 1 && (std::is_same_v, shared_type> || ...)) && std::is_constructible_v) void store(Args&&... args) noexcept { shared_type r = make_single(std::forward(args)...); @@ -827,7 +829,7 @@ namespace stx old.m_val.raw() = m_val.exchange(reinterpret_cast(std::exchange(value.m_ptr, nullptr)) << c_ref_size); } - template >> + template requires (!(sizeof...(Args) == 1 && (std::is_same_v, shared_type> || ...)) && std::is_constructible_v) [[nodiscard]] shared_type exchange(Args&&... args) noexcept { shared_type r = make_single(std::forward(args)...);