summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-09-25 04:21:28 -0400
committerJohn Wiegley <johnw@newartisans.com>2004-09-25 04:21:28 -0400
commita4d96f79bfd0d3f1faffcd46c223f63c12a00eb4 (patch)
tree56ca9d1dba815af628cc8862e662892d91cf7afa
parentd4657c66f454003bc88ed1ce25e7bfabdace6306 (diff)
downloadfork-ledger-a4d96f79bfd0d3f1faffcd46c223f63c12a00eb4.tar.gz
fork-ledger-a4d96f79bfd0d3f1faffcd46c223f63c12a00eb4.tar.bz2
fork-ledger-a4d96f79bfd0d3f1faffcd46c223f63c12a00eb4.zip
corrected a small problem with conversion of numeric types to amount_t's
-rw-r--r--amount.h31
1 files changed, 14 insertions, 17 deletions
diff --git a/amount.h b/amount.h
index ed1c9bb5..0761c068 100644
--- a/amount.h
+++ b/amount.h
@@ -184,28 +184,25 @@ class amount_t
template <typename T>
void parse_num(T num) {
- std::string str;
- { std::ostringstream strstr(str);
- strstr << num;
- }
- { std::istringstream strstr(str);
- parse(strstr);
- }
+ std::ostringstream temp;
+ temp << num;
+ std::istringstream in(temp.str());
+ parse(in);
}
int sign() const;
// POD comparisons
-#define AMOUNT_CMP_INT(OP) \
- template <typename T> \
- bool operator OP (T num) const { \
- if (num == 0) { \
- return sign() OP 0; \
- } else { \
- amount_t amt; \
- amt.parse_num(num); \
- return *this OP amt; \
- } \
+#define AMOUNT_CMP_INT(OP) \
+ template <typename T> \
+ bool operator OP (T num) const { \
+ if (num == 0) { \
+ return sign() OP 0; \
+ } else { \
+ amount_t amt; \
+ amt.parse_num(num); \
+ return *this OP amt; \
+ } \
}
AMOUNT_CMP_INT(<)