summaryrefslogtreecommitdiffstats
path: root/core/object/ref_counted.h
diff options
context:
space:
mode:
authorA Thousand Ships <96648715+AThousandShips@users.noreply.github.com>2024-08-29 17:33:29 +0200
committerA Thousand Ships <96648715+AThousandShips@users.noreply.github.com>2024-09-12 11:26:49 +0200
commitdf29cc696f22e6b91b09284ee9ce0779ed77a3d9 (patch)
tree056816fd978887e545b73ff766cc3207d9e17052 /core/object/ref_counted.h
parent83d54ab2ad476ae265b323c2b88f4623b922f4c6 (diff)
downloadredot-engine-df29cc696f22e6b91b09284ee9ce0779ed77a3d9.tar.gz
[Core] Optionally delete `Ref` `nullptr` comparisons
Adds an optional (default false) compile option to enable comparing `Ref` to `nullptr` to ensure correct use, as well as future expandsion for more general dev checks (enabled with `dev_mode`)
Diffstat (limited to 'core/object/ref_counted.h')
-rw-r--r--core/object/ref_counted.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/core/object/ref_counted.h b/core/object/ref_counted.h
index 5b358135c4..f0706b4d08 100644
--- a/core/object/ref_counted.h
+++ b/core/object/ref_counted.h
@@ -86,6 +86,11 @@ public:
_FORCE_INLINE_ bool operator!=(const T *p_ptr) const {
return reference != p_ptr;
}
+#ifdef STRICT_CHECKS
+ // Delete these to prevent raw comparisons with `nullptr`.
+ bool operator==(std::nullptr_t) const = delete;
+ bool operator!=(std::nullptr_t) const = delete;
+#endif // STRICT_CHECKS
_FORCE_INLINE_ bool operator<(const Ref<T> &p_r) const {
return reference < p_r.reference;