summaryrefslogtreecommitdiff
path: root/amount.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2006-03-19 23:16:31 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 05:48:45 -0400
commitf60717d3f4bd3f3c04e08edbe459495d00936d0c (patch)
treeb573b4e23dbcec06d7f4b79835127a2d64db5db7 /amount.h
parent7adb262823377bc40085ba5b66a6448a3d58db0b (diff)
downloadfork-ledger-f60717d3f4bd3f3c04e08edbe459495d00936d0c.tar.gz
fork-ledger-f60717d3f4bd3f3c04e08edbe459495d00936d0c.tar.bz2
fork-ledger-f60717d3f4bd3f3c04e08edbe459495d00936d0c.zip
*** no comment ***
Diffstat (limited to 'amount.h')
-rw-r--r--amount.h24
1 files changed, 15 insertions, 9 deletions
diff --git a/amount.h b/amount.h
index d64c3c2d..284353a7 100644
--- a/amount.h
+++ b/amount.h
@@ -181,16 +181,22 @@ class amount_t
operator double() const;
// comparisons between amounts
- bool operator<(const amount_t& amt) const;
- bool operator<=(const amount_t& amt) const;
- bool operator>(const amount_t& amt) const;
- bool operator>=(const amount_t& amt) const;
- bool operator==(const amount_t& amt) const;
- bool operator!=(const amount_t& amt) const {
- if (commodity_ != amt.commodity_)
- return true;
- return ! (*this == amt);
+ int compare(const amount_t& amt) const;
+
+ bool operator<(const amount_t& amt) const {
+ return compare(amt) < 0;
+ }
+ bool operator<=(const amount_t& amt) const {
+ return compare(amt) <= 0;
}
+ bool operator>(const amount_t& amt) const {
+ return compare(amt) > 0;
+ }
+ bool operator>=(const amount_t& amt) const {
+ return compare(amt) >= 0;
+ }
+ bool operator==(const amount_t& amt) const;
+ bool operator!=(const amount_t& amt) const;
template <typename T>
void parse_num(T num) {