summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-08-21 21:28:29 +0200
committerGitHub <noreply@github.com>2018-08-21 21:28:29 +0200
commit65c8a491221efdb4fd26ff230f22b541a2511483 (patch)
tree5d0d0fc60a96ffb0d4139f66b32074380747d9b3
parent404ee1a56b138ac6280c0cba9dbd9ea92b9e9a24 (diff)
parenta1d2fbdeb29dbc0f7fa2940f9f66c161cf723180 (diff)
Merge pull request #21250 from dragmz/ref-ptr-n(eq)-op
== and != operators for Ref<T> / T*
-rw-r--r--core/reference.h7
-rw-r--r--scene/resources/material.cpp2
2 files changed, 8 insertions, 1 deletions
diff --git a/core/reference.h b/core/reference.h
index 0d6b1ced6e..25e02180fa 100644
--- a/core/reference.h
+++ b/core/reference.h
@@ -87,6 +87,13 @@ class Ref {
//virtual Reference * get_reference() const { return reference; }
public:
+ _FORCE_INLINE_ bool operator==(const T *p_ptr) const {
+ return reference == p_ptr;
+ }
+ _FORCE_INLINE_ bool operator!=(const T *p_ptr) const {
+ return reference != p_ptr;
+ }
+
_FORCE_INLINE_ bool operator<(const Ref<T> &p_r) const {
return reference < p_r.reference;
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index d6c22d5664..143a1438ea 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -34,7 +34,7 @@
void Material::set_next_pass(const Ref<Material> &p_pass) {
- ERR_FAIL_COND(p_pass.ptr() == this);
+ ERR_FAIL_COND(p_pass == this);
if (next_pass == p_pass)
return;