added usual operator
This commit is contained in:
parent
ac000a67c4
commit
69bd31b4d0
4 changed files with 27 additions and 19 deletions
11
amount.cc
11
amount.cc
|
|
@ -276,11 +276,12 @@ amount_t& amount_t::operator=(const char * value)
|
||||||
// assignment operator
|
// assignment operator
|
||||||
amount_t& amount_t::operator=(const amount_t& amt)
|
amount_t& amount_t::operator=(const amount_t& amt)
|
||||||
{
|
{
|
||||||
if (amt.quantity)
|
if (this != &amt) {
|
||||||
_copy(amt);
|
if (amt.quantity)
|
||||||
else if (quantity)
|
_copy(amt);
|
||||||
_clear();
|
else if (quantity)
|
||||||
|
_clear();
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
29
balance.h
29
balance.h
|
|
@ -70,11 +70,13 @@ class balance_t
|
||||||
|
|
||||||
// assignment operator
|
// assignment operator
|
||||||
balance_t& operator=(const balance_t& bal) {
|
balance_t& operator=(const balance_t& bal) {
|
||||||
amounts.clear();
|
if (this != &bal) {
|
||||||
for (amounts_map::const_iterator i = bal.amounts.begin();
|
amounts.clear();
|
||||||
i != bal.amounts.end();
|
for (amounts_map::const_iterator i = bal.amounts.begin();
|
||||||
i++)
|
i != bal.amounts.end();
|
||||||
*this += (*i).second;
|
i++)
|
||||||
|
*this += (*i).second;
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
balance_t& operator=(const amount_t& amt) {
|
balance_t& operator=(const amount_t& amt) {
|
||||||
|
|
@ -452,15 +454,16 @@ class balance_pair_t
|
||||||
|
|
||||||
// assignment operator
|
// assignment operator
|
||||||
balance_pair_t& operator=(const balance_pair_t& bal_pair) {
|
balance_pair_t& operator=(const balance_pair_t& bal_pair) {
|
||||||
if (cost) {
|
if (this != &bal_pair) {
|
||||||
delete cost;
|
if (cost) {
|
||||||
cost = NULL;
|
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;
|
return *this;
|
||||||
}
|
}
|
||||||
balance_pair_t& operator=(const balance_t& bal) {
|
balance_pair_t& operator=(const balance_t& bal) {
|
||||||
|
|
|
||||||
3
value.cc
3
value.cc
|
|
@ -22,6 +22,9 @@ void value_t::destroy()
|
||||||
|
|
||||||
value_t& value_t::operator=(const value_t& value)
|
value_t& value_t::operator=(const value_t& value)
|
||||||
{
|
{
|
||||||
|
if (this == &value)
|
||||||
|
return *this;
|
||||||
|
|
||||||
destroy();
|
destroy();
|
||||||
switch (value.type) {
|
switch (value.type) {
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
|
|
|
||||||
3
walk.h
3
walk.h
|
|
@ -53,8 +53,9 @@ class compare_items {
|
||||||
assert(right);
|
assert(right);
|
||||||
|
|
||||||
value_t left_result;
|
value_t left_result;
|
||||||
sort_order->compute(left_result, details_t(left));
|
|
||||||
value_t right_result;
|
value_t right_result;
|
||||||
|
|
||||||
|
sort_order->compute(left_result, details_t(left));
|
||||||
sort_order->compute(right_result, details_t(right));
|
sort_order->compute(right_result, details_t(right));
|
||||||
|
|
||||||
return left_result < right_result;
|
return left_result < right_result;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue