From 141d62fbf9f292156b27dea0ed3d7c5ecf705e59 Mon Sep 17 00:00:00 2001 From: Eladash Date: Sat, 11 Apr 2020 21:34:31 +0300 Subject: [PATCH] Implement ::as_rvalue --- Utilities/types.h | 18 ++++++++++++++++++ rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp | 2 +- rpcs3/Emu/Cell/lv2/sys_usbd.cpp | 2 +- rpcs3/Emu/IdManager.h | 6 +++--- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Utilities/types.h b/Utilities/types.h index 855791bcf1..94fe3c0290 100644 --- a/Utilities/types.h +++ b/Utilities/types.h @@ -167,6 +167,24 @@ using get_uint_t = typename get_int_impl::utype; template using get_sint_t = typename get_int_impl::stype; +template +T as_rvalue(T&& obj) +{ + return obj; +} + +template +T as_rvalue(const T& obj) +{ + return obj; +} + +template +T as_rvalue(const volatile T& obj) +{ + return obj; +} + // Formatting helper, type-specific preprocessing for improving safety and functionality template struct fmt_unveil; diff --git a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp index 8e9c838fb4..8fc23f2fd0 100644 --- a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp +++ b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp @@ -846,7 +846,7 @@ spu_function_t spu_recompiler::compile(spu_program&& _func) c->jmp(imm_ptr(spu_runtime::tr_dispatch)); } - for (auto&& work : decltype(after)(std::move(after))) + for (auto&& work : ::as_rvalue(std::move(after))) { work(); } diff --git a/rpcs3/Emu/Cell/lv2/sys_usbd.cpp b/rpcs3/Emu/Cell/lv2/sys_usbd.cpp index be1520a506..5842e83f50 100644 --- a/rpcs3/Emu/Cell/lv2/sys_usbd.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_usbd.cpp @@ -476,7 +476,7 @@ error_code sys_usbd_finalize(ppu_thread& ppu, u32 handle) usbh->is_init = false; // Forcefully awake all waiters - for (auto& cpu : decltype(usbh->sq)(std::move(usbh->sq))) + for (auto& cpu : ::as_rvalue(std::move(usbh->sq))) { // Special ternimation signal value cpu->gpr[4] = 4; diff --git a/rpcs3/Emu/IdManager.h b/rpcs3/Emu/IdManager.h index 764ea8eb3b..ebf36eb263 100644 --- a/rpcs3/Emu/IdManager.h +++ b/rpcs3/Emu/IdManager.h @@ -574,7 +574,7 @@ public: if (const auto found = find_id(id)) { - ptr = std::static_pointer_cast(std::move(found->second)); + ptr = std::static_pointer_cast(::as_rvalue(std::move(found->second))); } } @@ -594,7 +594,7 @@ public: if constexpr (std::is_void_v) { func(*_ptr); - return std::static_pointer_cast(std::move(found->second)); + return std::static_pointer_cast(::as_rvalue(std::move(found->second))); } else { @@ -606,7 +606,7 @@ public: return {{found->second, _ptr}, std::move(ret)}; } - return {std::static_pointer_cast(std::move(found->second)), std::move(ret)}; + return {std::static_pointer_cast(::as_rvalue(std::move(found->second))), std::move(ret)}; } }