summaryrefslogtreecommitdiff
path: root/src/balance.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-27 02:15:27 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-27 02:15:27 -0400
commitfbb0d2583173073e11976c7cd7e570d4829f0621 (patch)
tree7c83465d30bd45f89f82757d5f3041a9e3903f1f /src/balance.h
parentecb1ca71c12f7772d345f19b6df821da123d3b57 (diff)
downloadfork-ledger-fbb0d2583173073e11976c7cd7e570d4829f0621.tar.gz
fork-ledger-fbb0d2583173073e11976c7cd7e570d4829f0621.tar.bz2
fork-ledger-fbb0d2583173073e11976c7cd7e570d4829f0621.zip
Gave round/unround/truncate all in_place_ variants
Diffstat (limited to 'src/balance.h')
-rw-r--r--src/balance.h21
1 files changed, 18 insertions, 3 deletions
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 {