diff --git a/rpcs3/Emu/Memory/vm_ref.h b/rpcs3/Emu/Memory/vm_ref.h index 6a42afa5f7..acd62e58f1 100644 --- a/rpcs3/Emu/Memory/vm_ref.h +++ b/rpcs3/Emu/Memory/vm_ref.h @@ -48,18 +48,21 @@ namespace vm return get_ref(); } - // copy assignment operator - auto operator =(const _ref_base& right) -> decltype(std::declval() = std::declval()) + // copy assignment operator: + // returns T& by default, this may be wrong if called assignment operator has different return type + T& operator =(const _ref_base& right) + { + static_assert(!std::is_const::value, "vm::_ref_base<> error: operator= is not available for const reference"); + + return get_ref() = right.get_ref(); + } + + template auto operator =(const _ref_base& right) const -> decltype(std::declval() = std::declval()) { return get_ref() = right.get_ref(); } - template auto operator =(const _ref_base& right) -> decltype(std::declval() = std::declval()) const - { - return get_ref() = right.get_ref(); - } - - template auto operator =(const CT& right) -> decltype(std::declval() = std::declval()) const + template auto operator =(const CT& right) const -> decltype(std::declval() = std::declval()) { return get_ref() = right; }