Merge pull request #21250 from dragmz/ref-ptr-n(eq)-op

== and != operators for Ref<T> / T*
This commit is contained in:
Rémi Verschelde 2018-08-21 21:28:29 +02:00 committed by GitHub
commit 65c8a49122
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -87,6 +87,13 @@ class Ref {
//virtual Reference * get_reference() const { return reference; } //virtual Reference * get_reference() const { return reference; }
public: 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 { _FORCE_INLINE_ bool operator<(const Ref<T> &p_r) const {
return reference < p_r.reference; return reference < p_r.reference;

View file

@ -34,7 +34,7 @@
void Material::set_next_pass(const Ref<Material> &p_pass) { 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) if (next_pass == p_pass)
return; return;