Implementation of == != < <= > >= operators.

This commit is contained in:
King_DuckZ 2014-03-07 12:30:07 +01:00
parent ccc831e34d
commit a561242395
2 changed files with 64 additions and 0 deletions

View file

@ -92,6 +92,19 @@ namespace cloonel {
template <typename T, typename U, uint32_t S> template <typename T, typename U, uint32_t S>
Vector<typename std::common_type<T, U>::type, S> operator/ ( const Vector<T, S>& parA, U parB ) __attribute__((pure)); Vector<typename std::common_type<T, U>::type, S> operator/ ( const Vector<T, S>& parA, U parB ) __attribute__((pure));
template <typename T, typename U, uint32_t S>
bool operator< ( const Vector<T, S>& parA, const Vector<U, S>& parB ) __attribute__((pure));
template <typename T, typename U, uint32_t S>
bool operator> ( const Vector<T, S>& parA, const Vector<U, S>& parB ) __attribute__((pure));
template <typename T, typename U, uint32_t S>
bool operator<= ( const Vector<T, S>& parA, const Vector<U, S>& parB ) __attribute__((pure));
template <typename T, typename U, uint32_t S>
bool operator>= ( const Vector<T, S>& parA, const Vector<U, S>& parB ) __attribute__((pure));
template <typename T, typename U, uint32_t S>
bool operator== ( const Vector<T, S>& parA, const Vector<U, S>& parB ) __attribute__((pure));
template <typename T, typename U, uint32_t S>
bool operator!= ( const Vector<T, S>& parA, const Vector<U, S>& parB ) __attribute__((pure));
typedef Vector<float, 2> float2; typedef Vector<float, 2> float2;
typedef Vector<uint16_t, 2> ushort2; typedef Vector<uint16_t, 2> ushort2;
typedef Vector<int32_t, 2> int2; typedef Vector<int32_t, 2> int2;

View file

@ -187,4 +187,55 @@ namespace cloonel {
} }
return retVal; 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 = true;
for (uint32_t z = 0; z < S; ++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 = true;
for (uint32_t z = 0; z < S; ++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 = true;
for (uint32_t z = 0; z < S; ++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 = true;
for (uint32_t z = 0; z < S; ++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 = true;
for (uint32_t z = 0; z < S; ++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 = true;
for (uint32_t z = 0; z < S; ++z) {
retVal &= static_cast<bool>(parA[z] != parB[z]);
}
return retVal;
}
} //namespace cloonel } //namespace cloonel