diff --git a/rpcs3/Emu/IdManager.h b/rpcs3/Emu/IdManager.h index 363b555c13..36163b258d 100644 --- a/rpcs3/Emu/IdManager.h +++ b/rpcs3/Emu/IdManager.h @@ -48,10 +48,13 @@ namespace id_manager } template - concept IdmCompatible = requires () { T::id_base, T::id_step, T::id_count; }; + concept IdmCompatible = requires () { +T::id_base, +T::id_step, +T::id_count; }; template - concept IdmSavable = IdmCompatible && T::savestate_init_pos != 0 && (requires () { std::declval().save(std::declval>()); }); + concept IdmBaseCompatible = (std::is_final_v ? IdmCompatible : !!(requires () { +T::id_step, +T::id_count; })); + + template + concept IdmSavable = IdmBaseCompatible && T::savestate_init_pos != 0 && (requires () { std::declval().save(std::declval>()); }); // Last allocated ID for constructors extern thread_local u32 g_id; @@ -103,7 +106,7 @@ namespace id_manager template struct id_traits_load_func> { - static constexpr std::shared_ptr(*load)(utils::serial&) = &T::load; + static constexpr std::shared_ptr(*load)(utils::serial&) = [](utils::serial& ar) -> std::shared_ptr { return T::load(stx::exact_t(ar)); }; }; template @@ -172,7 +175,7 @@ namespace id_manager { typeinfo info{}; - using C = std::conditional_t, T, dummy_construct>; + using C = std::conditional_t && IdmSavable, T, dummy_construct>; using Type = std::conditional_t, T, dummy_construct>; if constexpr (std::is_same_v) @@ -248,6 +251,8 @@ namespace id_manager template struct id_map { + static_assert(IdmBaseCompatible, "Please specify IDM compatible type."); + std::vector>> vec{}, private_copy{}; shared_mutex mutex{}; // TODO: Use this instead of global mutex diff --git a/rpcs3/util/fixed_typemap.hpp b/rpcs3/util/fixed_typemap.hpp index 3c2ee8e7f2..d296777b35 100644 --- a/rpcs3/util/fixed_typemap.hpp +++ b/rpcs3/util/fixed_typemap.hpp @@ -117,13 +117,6 @@ namespace stx *std::launder(static_cast(ptr)) = state; } -#ifdef _MSC_VER - template - static void call_save(void*, utils::serial&) noexcept - { - } -#endif - template requires requires (T& a) { a.save(std::declval>()); } static void call_save(void* ptr, utils::serial& ar) noexcept { @@ -144,10 +137,7 @@ namespace stx r.stop = &call_stop; } - // TODO: Unconnement and remove call_save overload when MSVC implements it -#ifndef _MSC_VER if constexpr (!!(requires (T& a) { a.save(std::declval>()); })) -#endif { r.save = &call_save; }