#include <ShoreApp.h> int Ref<T>::operator==(const Ref<T> &ref) const; int Ref<T>::operator!=(const Ref<T> &ref) const; // For use with p == 0 only: int Ref<T>::operator==(const T *p) const; int Ref<T>::operator!=(const T *p) const; Ref<T>::operator int() const;
These operators implement equality comparisons among refs. The first two forms indicate whether two Ref<T>s point to the same object. The second two forms indicate whether the ref points to the same object as the given virtual memory pointer. The final form returns 0 if the ref is nil, 1 otherwise.
Ref<Part> p1, p2; if(p1 == p2) ... if(p1 != 0) ... if(p1) ...The first if-statement succeeds if p1 and p2 point to the same part object. The second and third if-statements are equivalent, and they succeed if p1 is not a nil ref.
The forms of the equality operator that take a virtual memory pointer are only intended for use with a parameter of 0.
In the current release of Shore, it is safe to compare refs whose targets have been destroyed. But in general, this practice is discouraged, as it may not be supported in future Shore releases.