From d8b1c3118a8346c16adf899e76f5ecd96604bcd2 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Mon, 15 Jun 2015 19:02:16 +0300 Subject: [PATCH] vm::ref assignment operators fixed --- rpcs3/Emu/Memory/vm_ref.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) 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; }