summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorRichard Linden <none@none>2013-08-27 18:08:32 -0700
committerRichard Linden <none@none>2013-08-27 18:08:32 -0700
commit25e2fbe419655b2f8ce22dbafa1de6bc655b1567 (patch)
tree8a9c63ec9f1172fac06d8b0e21c4ea3692099ff4 /indra
parent00bd492b30f0dcb49d354be74e6e9a312a84863f (diff)
got comparisons between implicit and explicit units working right
Diffstat (limited to 'indra')
-rw-r--r--indra/llcommon/llunittype.h44
-rw-r--r--indra/llcommon/tests/llunits_test.cpp10
2 files changed, 48 insertions, 6 deletions
diff --git a/indra/llcommon/llunittype.h b/indra/llcommon/llunittype.h
index 50037ccade..663641d6b1 100644
--- a/indra/llcommon/llunittype.h
+++ b/indra/llcommon/llunittype.h
@@ -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 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 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 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 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 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
{
diff --git a/indra/llcommon/tests/llunits_test.cpp b/indra/llcommon/tests/llunits_test.cpp
index 59876ce3b4..d5b7c08672 100644
--- a/indra/llcommon/tests/llunits_test.cpp
+++ b/indra/llcommon/tests/llunits_test.cpp
@@ -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