Skip to content

Commit

Permalink
libdeng2: Added equality operators for integer vectors
Browse files Browse the repository at this point in the history
Unlike floating point vectors, integer vectors have unambiguously
defined equality.
  • Loading branch information
skyjake committed Jan 20, 2013
1 parent 80dec67 commit a43d7e7
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions doomsday/libdeng2/include/de/vector.h
Expand Up @@ -407,6 +407,37 @@ QTextStream &operator << (QTextStream &os, Vector4<Type> const &vec4)
return os;
}

// Equality operators for integer types.
inline bool operator == (Vector2<dint> const &a, Vector2<dint> const &b)
{
return a.x == b.x && a.y == b.y;
}

inline bool operator == (Vector3<dint> const &a, Vector3<dint> const &b)
{
return a.x == b.x && a.y == b.y && a.z == b.z;
}

inline bool operator == (Vector4<dint> const &a, Vector4<dint> const &b)
{
return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
}

inline bool operator == (Vector2<duint> const &a, Vector2<duint> const &b)
{
return a.x == b.x && a.y == b.y;
}

inline bool operator == (Vector3<duint> const &a, Vector3<duint> const &b)
{
return a.x == b.x && a.y == b.y && a.z == b.z;
}

inline bool operator == (Vector4<duint> const &a, Vector4<duint> const &b)
{
return a.x == b.x && a.y == b.y && a.z == b.z && a.w == b.w;
}

//@{
/// @ingroup types
typedef Vector2<dint> Vector2i; ///< 2-component vector of integer values.
Expand Down

0 comments on commit a43d7e7

Please sign in to comment.