diff options
author | John Wiegley <johnw@newartisans.com> | 2007-08-03 21:21:57 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 03:39:09 -0400 |
commit | ca131ea6e8f2c86153f624f13281c3aed142ed98 (patch) | |
tree | 244f10ff67adbc2a06ca5230ad79c1c5236b938e | |
parent | 41039518a06ca01d9d5faf552bf90e54ef6fcc2b (diff) | |
download | fork-ledger-ca131ea6e8f2c86153f624f13281c3aed142ed98.tar.gz fork-ledger-ca131ea6e8f2c86153f624f13281c3aed142ed98.tar.bz2 fork-ledger-ca131ea6e8f2c86153f624f13281c3aed142ed98.zip |
Added polymorphic == and < operators.
-rw-r--r-- | src/numerics/value.h | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/numerics/value.h b/src/numerics/value.h index d0f5cb76..580b775d 100644 --- a/src/numerics/value.h +++ b/src/numerics/value.h @@ -36,8 +36,10 @@ * * @brief Abstract dynamic type representing various numeric types. * - * A value_t object can be one of many types, and can change its type - * dynamically based on how it is used. + * A value_t object can be one of many types, and changes its type + * dynamically based on how it is used. For example, if you assign + * the number 10 to a value object, it's internal type will be + * INTEGER. */ #ifndef _VALUE_H #define _VALUE_H @@ -346,13 +348,19 @@ public: } /** - * Comparison operators. + * Comparison operators. Values can be compared to other values */ bool operator==(const value_t& val) const; bool operator<(const value_t& val) const; -#if 0 - bool operator>(const value_t& val) const; -#endif + + template <typename T> + bool operator==(const T& amt) const { + return *this == value_t(amt); + } + template <typename T> + bool operator<(const T& amt) const { + return *this < value_t(amt); + } /** * Binary arithmetic operators. |