Skip to content

Commit

Permalink
Add IsInstanceEq IsPointerEq for when types are know more accurately
Browse files Browse the repository at this point in the history
  • Loading branch information
hughsando committed May 15, 2020
1 parent bb0223b commit 72e7007
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions include/hx/LessThanEq.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,13 @@ struct CompareTraits< T * >
};


template<typename T1>
hx::Object *GetExistingObject(const T1 &v1)
{
typedef CompareTraits<T1> traits1;
return traits1::toObject(v1);
}


template<typename T1>
bool IsNull(const T1 &v1)
Expand Down Expand Up @@ -420,6 +427,46 @@ template<typename T1, typename T2>
bool IsGreaterEq(const T1 &v1, const T2 &v2) { return TestLessEq<true,true,T2,T1>(v2,v1); }



template<typename T1, typename T2>
bool IsPointerEq(const T1 &v1, const T2 &v2)
{
return GetExistingObject(v1) == GetExistingObject(v2);
}

template<typename T1, typename T2>
bool IsPointerNotEq(const T1 &v1, const T2 &v2)
{
return GetExistingObject(v1) != GetExistingObject(v2);
}


template<typename T1, typename T2>
bool IsInstanceEq(const T1 &v1, const T2 &v2)
{
hx::Object *p1 = GetExistingObject(v1);
hx::Object *p2 = GetExistingObject(v2);
if (p1==p2)
return true;
if (!p1 || !p2)
return false;
return !p1->__Compare(p2);
}

template<typename T1, typename T2>
bool IsInstanceNotEq(const T1 &v1, const T2 &v2)
{
hx::Object *p1 = GetExistingObject(v1);
hx::Object *p2 = GetExistingObject(v2);
if (p1==p2)
return false;
if (!p1 || !p2)
return true;
return p1->__Compare(p2);
}



}


Expand Down

0 comments on commit 72e7007

Please sign in to comment.