added usual operator

This commit is contained in:
John Wiegley 2004-08-25 21:51:11 -04:00
parent ac000a67c4
commit 69bd31b4d0
4 changed files with 27 additions and 19 deletions

View file

@ -276,11 +276,12 @@ amount_t& amount_t::operator=(const char * value)
// assignment operator
amount_t& amount_t::operator=(const amount_t& amt)
{
if (amt.quantity)
_copy(amt);
else if (quantity)
_clear();
if (this != &amt) {
if (amt.quantity)
_copy(amt);
else if (quantity)
_clear();
}
return *this;
}

View file

@ -70,11 +70,13 @@ class balance_t
// assignment operator
balance_t& operator=(const balance_t& bal) {
amounts.clear();
for (amounts_map::const_iterator i = bal.amounts.begin();
i != bal.amounts.end();
i++)
*this += (*i).second;
if (this != &bal) {
amounts.clear();
for (amounts_map::const_iterator i = bal.amounts.begin();
i != bal.amounts.end();
i++)
*this += (*i).second;
}
return *this;
}
balance_t& operator=(const amount_t& amt) {
@ -452,15 +454,16 @@ class balance_pair_t
// assignment operator
balance_pair_t& operator=(const balance_pair_t& bal_pair) {
if (cost) {
delete cost;
cost = NULL;
if (this != &bal_pair) {
if (cost) {
delete cost;
cost = NULL;
}
quantity = bal_pair.quantity;
if (bal_pair.cost)
cost = new balance_t(*bal_pair.cost);
}
quantity = bal_pair.quantity;
if (bal_pair.cost)
cost = new balance_t(*bal_pair.cost);
return *this;
}
balance_pair_t& operator=(const balance_t& bal) {

View file

@ -22,6 +22,9 @@ void value_t::destroy()
value_t& value_t::operator=(const value_t& value)
{
if (this == &value)
return *this;
destroy();
switch (value.type) {
case BOOLEAN:

3
walk.h
View file

@ -53,8 +53,9 @@ class compare_items {
assert(right);
value_t left_result;
sort_order->compute(left_result, details_t(left));
value_t right_result;
sort_order->compute(left_result, details_t(left));
sort_order->compute(right_result, details_t(right));
return left_result < right_result;