From 65116a7e91d474ae0f95784e3edd90fb7fec28c4 Mon Sep 17 00:00:00 2001 From: derammo <817160+derammo@users.noreply.github.com> Date: Tue, 23 Aug 2022 11:34:26 -0400 Subject: [PATCH] change Ref to allow non const access to ptr allows non-const T* to be taken from const Ref directly instead of using hacky workarounds such as copying it to another Ref this fixes methods with const Ref& arguments not being able to access non-const methods on contained T --- core/object/ref_counted.h | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/core/object/ref_counted.h b/core/object/ref_counted.h index bd06a84bd8d..8deef007d8c 100644 --- a/core/object/ref_counted.h +++ b/core/object/ref_counted.h @@ -97,26 +97,15 @@ public: return reference != p_r.reference; } - _FORCE_INLINE_ T *operator->() { + _FORCE_INLINE_ T *operator*() const { return reference; } - _FORCE_INLINE_ T *operator*() { + _FORCE_INLINE_ T *operator->() const { return reference; } - _FORCE_INLINE_ const T *operator->() const { - return reference; - } - - _FORCE_INLINE_ const T *ptr() const { - return reference; - } - _FORCE_INLINE_ T *ptr() { - return reference; - } - - _FORCE_INLINE_ const T *operator*() const { + _FORCE_INLINE_ T *ptr() const { return reference; }