Fix vector comparison and add unit test.

This commit is contained in:
King_DuckZ 2015-07-30 01:48:29 +02:00
commit 971cd54688
3 changed files with 39 additions and 14 deletions

View file

@ -199,35 +199,27 @@ namespace cloonel {
///--------------------------------------------------------------------------
template <typename T, typename U, uint32_t S>
inline bool operator< (const Vector<T, S>& parA, const Vector<U, S>& parB) {
bool retVal = false;
bool retVal = true;
for (uint32_t z = 0; z < S; ++z) {
retVal |= static_cast<bool>(parA[z] < parB[z]);
retVal &= static_cast<bool>(parA[z] < parB[z]);
}
return retVal;
}
template <typename T, typename U, uint32_t S>
inline bool operator> (const Vector<T, S>& parA, const Vector<U, S>& parB) {
bool retVal = false;
for (uint32_t z = 0; z < S; ++z) {
retVal |= static_cast<bool>(parA[z] > parB[z]);
}
return retVal;
return not (parA <= parB);
}
template <typename T, typename U, uint32_t S>
inline bool operator<= (const Vector<T, S>& parA, const Vector<U, S>& parB) {
bool retVal = false;
bool retVal = true;
for (uint32_t z = 0; z < S; ++z) {
retVal |= static_cast<bool>(parA[z] <= parB[z]);
retVal &= static_cast<bool>(parA[z] <= parB[z]);
}
return retVal;
}
template <typename T, typename U, uint32_t S>
inline bool operator>= (const Vector<T, S>& parA, const Vector<U, S>& parB) {
bool retVal = false;
for (uint32_t z = 0; z < S; ++z) {
retVal |= static_cast<bool>(parA[z] >= parB[z]);
}
return retVal;
return not (parA < parB);
}
template <typename T, typename U, uint32_t S>
inline bool operator== (const Vector<T, S>& parA, const Vector<U, S>& parB) {