corrected a small problem with conversion of numeric types to amount_t's
This commit is contained in:
parent
d4657c66f4
commit
a4d96f79bf
1 changed files with 14 additions and 17 deletions
31
amount.h
31
amount.h
|
|
@ -184,28 +184,25 @@ class amount_t
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void parse_num(T num) {
|
void parse_num(T num) {
|
||||||
std::string str;
|
std::ostringstream temp;
|
||||||
{ std::ostringstream strstr(str);
|
temp << num;
|
||||||
strstr << num;
|
std::istringstream in(temp.str());
|
||||||
}
|
parse(in);
|
||||||
{ std::istringstream strstr(str);
|
|
||||||
parse(strstr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int sign() const;
|
int sign() const;
|
||||||
|
|
||||||
// POD comparisons
|
// POD comparisons
|
||||||
#define AMOUNT_CMP_INT(OP) \
|
#define AMOUNT_CMP_INT(OP) \
|
||||||
template <typename T> \
|
template <typename T> \
|
||||||
bool operator OP (T num) const { \
|
bool operator OP (T num) const { \
|
||||||
if (num == 0) { \
|
if (num == 0) { \
|
||||||
return sign() OP 0; \
|
return sign() OP 0; \
|
||||||
} else { \
|
} else { \
|
||||||
amount_t amt; \
|
amount_t amt; \
|
||||||
amt.parse_num(num); \
|
amt.parse_num(num); \
|
||||||
return *this OP amt; \
|
return *this OP amt; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
AMOUNT_CMP_INT(<)
|
AMOUNT_CMP_INT(<)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue