Richard Linden 2013-08-27 18:08:52 -07:00
commit 1f58bcc59c
2 changed files with 48 additions and 6 deletions

View File

@ -169,11 +169,13 @@ struct LLUnit
{
return mValue <= convert(other).value();
}
template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>
LL_FORCE_INLINE bool operator > (LLUnit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const
{
return mValue > convert(other).value();
}
template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>
LL_FORCE_INLINE bool operator >= (LLUnit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const
{
@ -283,7 +285,12 @@ struct LLUnitImplicit : public LLUnit<STORAGE_TYPE, UNITS>
base_t::mValue -= convert(other).value();
}
using base_t::operator ==;
template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>
LL_FORCE_INLINE bool operator == (LLUnit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const
{
return mValue == convert(other).value();
}
template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>
LL_FORCE_INLINE bool operator == (LLUnitImplicit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const
{
@ -296,7 +303,12 @@ struct LLUnitImplicit : public LLUnit<STORAGE_TYPE, UNITS>
return base_t::mValue == other;
}
using base_t::operator !=;
template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>
LL_FORCE_INLINE bool operator != (LLUnit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const
{
return mValue != convert(other).value();
}
template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>
LL_FORCE_INLINE bool operator != (LLUnitImplicit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const
{
@ -309,7 +321,12 @@ struct LLUnitImplicit : public LLUnit<STORAGE_TYPE, UNITS>
return base_t::mValue != other;
}
using base_t::operator <;
template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>
LL_FORCE_INLINE bool operator < (LLUnit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const
{
return mValue < convert(other).value();
}
template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>
LL_FORCE_INLINE bool operator < (LLUnitImplicit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const
{
@ -322,7 +339,12 @@ struct LLUnitImplicit : public LLUnit<STORAGE_TYPE, UNITS>
return base_t::mValue < other;
}
using base_t::operator <=;
template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>
LL_FORCE_INLINE bool operator <= (LLUnit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const
{
return mValue <= convert(other).value();
}
template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>
LL_FORCE_INLINE bool operator <= (LLUnitImplicit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const
{
@ -335,7 +357,12 @@ struct LLUnitImplicit : public LLUnit<STORAGE_TYPE, UNITS>
return base_t::mValue <= other;
}
using base_t::operator >;
template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>
LL_FORCE_INLINE bool operator > (LLUnit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const
{
return mValue > convert(other).value();
}
template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>
LL_FORCE_INLINE bool operator > (LLUnitImplicit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const
{
@ -348,7 +375,12 @@ struct LLUnitImplicit : public LLUnit<STORAGE_TYPE, UNITS>
return base_t::mValue > other;
}
using base_t::operator >=;
template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>
LL_FORCE_INLINE bool operator >= (LLUnit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const
{
return mValue >= convert(other).value();
}
template<typename OTHER_STORAGE_TYPE, typename OTHER_UNITS>
LL_FORCE_INLINE bool operator >= (LLUnitImplicit<OTHER_STORAGE_TYPE, OTHER_UNITS> other) const
{

View File

@ -274,6 +274,16 @@ namespace tut
quatloos_implicit -= F32Quatloos(10);
ensure("can subtract-assign explicit units", quatloos_implicit == 16);
// comparisons
ensure("can compare greater than implicit unit", quatloos_implicit > F32QuatloosImplicit(0.f));
ensure("can compare greater than non-implicit unit", quatloos_implicit > F32Quatloos(0.f));
ensure("can compare greater than or equal to implicit unit", quatloos_implicit >= F32QuatloosImplicit(0.f));
ensure("can compare greater than or equal to non-implicit unit", quatloos_implicit >= F32Quatloos(0.f));
ensure("can compare less than implicit unit", quatloos_implicit < F32QuatloosImplicit(0.f));
ensure("can compare less than non-implicit unit", quatloos_implicit < F32Quatloos(0.f));
ensure("can compare less than or equal to implicit unit", quatloos_implicit <= F32QuatloosImplicit(0.f));
ensure("can compare less than or equal to non-implicit unit", quatloos_implicit <= F32Quatloos(0.f));
}
// precision tests