diff --git a/rpcs3/Emu/Cell/PPUAnalyser.h b/rpcs3/Emu/Cell/PPUAnalyser.h index 0f2e94cd86..492e3c012b 100644 --- a/rpcs3/Emu/Cell/PPUAnalyser.h +++ b/rpcs3/Emu/Cell/PPUAnalyser.h @@ -143,7 +143,7 @@ struct ppu_module return get_ptr(addr, u32{size_element}); } - template requires requires (const U& obj) { +obj.size() * 0; } + template requires requires (const U& obj) { obj.get_ptr(); } to_be_t* get_ptr(U&& addr) const { constexpr usz size_element = std::is_void_v ? 0 : sizeof(std::conditional_t, char, T>); @@ -167,7 +167,7 @@ struct ppu_module return *std::add_pointer_t>{}; } - template requires requires (const U& obj) { +obj.size() * 0; } + template requires requires (const U& obj) { obj.get_ptr(); } to_be_t& get_ref(U&& addr, u32 index = 0, u32 line = __builtin_LINE(), u32 col = __builtin_COLUMN(), diff --git a/rpcs3/Emu/Memory/vm_ptr.h b/rpcs3/Emu/Memory/vm_ptr.h index 93b97852ab..eed53220ed 100644 --- a/rpcs3/Emu/Memory/vm_ptr.h +++ b/rpcs3/Emu/Memory/vm_ptr.h @@ -33,7 +33,7 @@ namespace vm _ptr_base() = default; - _ptr_base(vm::addr_t addr) + _ptr_base(vm::addr_t addr) noexcept : m_addr(addr) { } @@ -57,12 +57,12 @@ namespace vm // Enable only the conversions which are originally possible between pointer types template requires (std::is_convertible_v) - operator _ptr_base() const + operator _ptr_base() const noexcept { return vm::cast(m_addr); } - explicit operator bool() const + explicit operator bool() const noexcept { return m_addr != 0u; } @@ -96,8 +96,7 @@ namespace vm } // Get vm reference - template requires (!std::is_void_v) - _ref_base ref() const + _ref_base ref() const requires (!std::is_void_v) { return vm::cast(m_addr); } @@ -107,18 +106,17 @@ namespace vm return static_cast(vm::base(vm::cast(m_addr))); } - template requires (!std::is_void_v) - T* operator ->() const + T* operator ->() const requires (!std::is_void_v) { return get_ptr(); } - std::add_lvalue_reference_t operator *() const + std::add_lvalue_reference_t operator *() const requires (!std::is_void_v) { return *static_cast(vm::base(vm::cast(m_addr))); } - std::add_lvalue_reference_t operator [](u32 index) const + std::add_lvalue_reference_t operator [](u32 index) const requires (!std::is_void_v) { return *static_cast(vm::base(vm::cast(m_addr) + u32{sizeof(T)} * index)); } @@ -130,13 +128,13 @@ namespace vm } // Get type size - static constexpr u32 size() + static constexpr u32 size() noexcept requires (!std::is_void_v) { return sizeof(T); } // Get type alignment - static constexpr u32 align() + static constexpr u32 align() noexcept requires (!std::is_void_v) { return alignof(T); } @@ -146,17 +144,17 @@ namespace vm return vm::cast(m_addr); } - _ptr_base operator +(u32 count) const + _ptr_base operator +(u32 count) const requires (!std::is_void_v) { return vm::cast(vm::cast(m_addr) + count * size()); } - _ptr_base operator -(u32 count) const + _ptr_base operator -(u32 count) const requires (!std::is_void_v) { return vm::cast(vm::cast(m_addr) - count * size()); } - friend _ptr_base operator +(u32 count, const _ptr_base& ptr) + friend _ptr_base operator +(u32 count, const _ptr_base& ptr) requires (!std::is_void_v) { return vm::cast(vm::cast(ptr.m_addr) + count * size()); } @@ -168,60 +166,57 @@ namespace vm return static_cast(vm::cast(m_addr) - vm::cast(right.m_addr)) / size(); } - _ptr_base operator ++(int) + _ptr_base operator ++(int) requires (!std::is_void_v) { _ptr_base result = *this; m_addr = vm::cast(m_addr) + size(); return result; } - _ptr_base& operator ++() + _ptr_base& operator ++() requires (!std::is_void_v) { m_addr = vm::cast(m_addr) + size(); return *this; } - _ptr_base operator --(int) + _ptr_base operator --(int) requires (!std::is_void_v) { _ptr_base result = *this; m_addr = vm::cast(m_addr) - size(); return result; } - _ptr_base& operator --() + _ptr_base& operator --() requires (!std::is_void_v) { m_addr = vm::cast(m_addr) - size(); return *this; } - _ptr_base& operator +=(s32 count) + _ptr_base& operator +=(s32 count) requires (!std::is_void_v) { m_addr = vm::cast(m_addr) + count * size(); return *this; } - _ptr_base& operator -=(s32 count) + _ptr_base& operator -=(s32 count) requires (!std::is_void_v) { m_addr = vm::cast(m_addr) - count * size(); return *this; } - template requires (std::is_copy_constructible_v) - std::pair, char, std::remove_const_t>> try_read() const + std::pair, char, std::remove_const_t>> try_read() const requires (std::is_copy_constructible_v) { alignas(sizeof(T) >= 16 ? 16 : 8) char buf[sizeof(T)]{}; const bool ok = vm::try_access(vm::cast(m_addr), buf, sizeof(T), false); return { ok, std::bit_cast(buf) }; } - template requires (!std::is_void_v) - bool try_read(std::conditional_t, char, std::remove_const_t>& out) const + bool try_read(std::conditional_t, char, std::remove_const_t>& out) const requires (!std::is_void_v) { return vm::try_access(vm::cast(m_addr), std::addressof(out), sizeof(T), false); } - template requires (!std::is_void_v && !std::is_const_v) - bool try_write(const std::conditional_t, char, T>& _in) const + bool try_write(const std::conditional_t, char, T>& _in) const requires (!std::is_void_v) { return vm::try_access(vm::cast(m_addr), const_cast(std::addressof(_in)), sizeof(T), true); }