From fbb0d2583173073e11976c7cd7e570d4829f0621 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 27 Feb 2009 02:15:27 -0400 Subject: Gave round/unround/truncate all in_place_ variants --- src/balance.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/balance.h') diff --git a/src/balance.h b/src/balance.h index f8e4f25c..71fc41be 100644 --- a/src/balance.h +++ b/src/balance.h @@ -312,24 +312,39 @@ public: } balance_t rounded() const { + balance_t temp(*this); + temp.in_place_round(); + return temp; + } + void in_place_round() { balance_t temp; foreach (const amounts_map::value_type& pair, amounts) temp += pair.second.rounded(); - return temp; + *this = temp; } balance_t truncated() const { + balance_t temp(*this); + temp.in_place_truncate(); + return temp; + } + void in_place_truncate() { balance_t temp; foreach (const amounts_map::value_type& pair, amounts) temp += pair.second.truncated(); - return temp; + *this = temp; } balance_t unrounded() const { + balance_t temp(*this); + temp.in_place_unround(); + return temp; + } + void in_place_unround() { balance_t temp; foreach (const amounts_map::value_type& pair, amounts) temp += pair.second.unrounded(); - return temp; + *this = temp; } balance_t reduced() const { -- cgit v1.2.3