summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
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 5cf41343fc..fbb8eb2431 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 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
{
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