1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-26 04:32:35 +01:00

vm_ptr.h: Do not allow dereferencing for void ptr

Do not create vm::ref from it as well.
This commit is contained in:
Eladash 2021-07-17 19:40:02 +03:00 committed by Megamouse
parent a981c65d2f
commit 9a392d2b5c

View File

@ -82,20 +82,21 @@ namespace vm
}
// Get vm reference to a struct member
template <typename MT, typename T2> requires PtrComparable<T, T2>
template <typename MT, typename T2> requires PtrComparable<T, T2> && (!std::is_void_v<T>)
_ref_base<MT, u32> ref(MT T2::*const mptr) const
{
return vm::cast(vm::cast(m_addr) + offset32(mptr));
}
// Get vm reference to a struct member with array subscription
template <typename MT, typename T2, typename ET = std::remove_extent_t<MT>> requires PtrComparable<T, T2>
template <typename MT, typename T2, typename ET = std::remove_extent_t<MT>> requires PtrComparable<T, T2> && (!std::is_void_v<T>)
_ref_base<ET, u32> ref(MT T2::*const mptr, u32 index) const
{
return vm::cast(vm::cast(m_addr) + offset32(mptr) + u32{sizeof(ET)} * index);
}
// Get vm reference
template <bool = false> requires (!std::is_void_v<T>)
_ref_base<T, u32> ref() const
{
return vm::cast(m_addr);
@ -106,6 +107,7 @@ namespace vm
return static_cast<T*>(vm::base(vm::cast(m_addr)));
}
template <bool = false> requires (!std::is_void_v<T>)
T* operator ->() const
{
return get_ptr();