Implement ::as_rvalue

This commit is contained in:
Eladash 2020-04-11 21:34:31 +03:00 committed by Ivan
parent e407018bb5
commit 141d62fbf9
4 changed files with 23 additions and 5 deletions

View File

@ -167,6 +167,24 @@ using get_uint_t = typename get_int_impl<N>::utype;
template <std::size_t N>
using get_sint_t = typename get_int_impl<N>::stype;
template <typename T>
T as_rvalue(T&& obj)
{
return obj;
}
template <typename T>
T as_rvalue(const T& obj)
{
return obj;
}
template <typename T>
T as_rvalue(const volatile T& obj)
{
return obj;
}
// Formatting helper, type-specific preprocessing for improving safety and functionality
template <typename T, typename = void>
struct fmt_unveil;

View File

@ -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();
}

View File

@ -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;

View File

@ -574,7 +574,7 @@ public:
if (const auto found = find_id<T, Get>(id))
{
ptr = std::static_pointer_cast<Get>(std::move(found->second));
ptr = std::static_pointer_cast<Get>(::as_rvalue(std::move(found->second)));
}
}
@ -594,7 +594,7 @@ public:
if constexpr (std::is_void_v<FRT>)
{
func(*_ptr);
return std::static_pointer_cast<Get>(std::move(found->second));
return std::static_pointer_cast<Get>(::as_rvalue(std::move(found->second)));
}
else
{
@ -606,7 +606,7 @@ public:
return {{found->second, _ptr}, std::move(ret)};
}
return {std::static_pointer_cast<Get>(std::move(found->second)), std::move(ret)};
return {std::static_pointer_cast<Get>(::as_rvalue(std::move(found->second))), std::move(ret)};
}
}