summaryrefslogtreecommitdiff
path: root/amount.h
diff options
context:
space:
mode:
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) {