Skip to content

Commit

Permalink
change Ref<T> to allow non const access to ptr
Browse files Browse the repository at this point in the history
allows non-const T* to be taken from const Ref<T> directly
instead of using hacky workarounds such as copying it to
another Ref

this fixes methods with const Ref<T>& arguments not being
able to access non-const methods on contained T
  • Loading branch information
derammo committed Aug 23, 2022
1 parent ba0421f commit 65116a7
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions core/object/ref_counted.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,26 +97,15 @@ class Ref {
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;
}

Expand Down

0 comments on commit 65116a7

Please sign in to comment.