From 73e2abd1b2e2bacbd353999a7b3edd95a04112c4 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 23 Aug 2004 18:23:31 -0400 Subject: a little cleanup; reversed the meaning of -z and -p (to be more mnemonic) --- amount.cc | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'amount.cc') diff --git a/amount.cc b/amount.cc index 6fc7dd59..cb1b3376 100644 --- a/amount.cc +++ b/amount.cc @@ -585,15 +585,17 @@ amount_t amount_t::round(unsigned int prec) const } } -std::ostream& operator<<(std::ostream& out, const amount_t& amt) +std::ostream& operator<<(std::ostream& _out, const amount_t& amt) { + if (! amt.quantity) + return _out; + + std::ostringstream out; + mpz_t quotient; mpz_t rquotient; mpz_t remainder; - if (! amt.quantity) - return out; - mpz_init(quotient); mpz_init(rquotient); mpz_init(remainder); @@ -710,14 +712,9 @@ std::ostream& operator<<(std::ostream& out, const amount_t& amt) mpz_clear(rquotient); mpz_clear(remainder); - return out; -} + _out << out.str(); -amount_t::operator std::string() const -{ - std::ostringstream s; - s << *this; - return s.str(); + return _out; } void parse_quantity(std::istream& in, std::string& value) -- cgit v1.2.3