mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
Added move constructor for BonusList
This commit is contained in:
parent
55e27a6334
commit
d42947f109
@ -97,6 +97,13 @@ BonusList::BonusList(const BonusList &bonusList)
|
|||||||
belongsToTree = false;
|
belongsToTree = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BonusList::BonusList(BonusList&& other):
|
||||||
|
belongsToTree(false)
|
||||||
|
{
|
||||||
|
std::swap(belongsToTree, other.belongsToTree);
|
||||||
|
std::swap(bonuses, other.bonuses);
|
||||||
|
}
|
||||||
|
|
||||||
BonusList& BonusList::operator=(const BonusList &bonusList)
|
BonusList& BonusList::operator=(const BonusList &bonusList)
|
||||||
{
|
{
|
||||||
bonuses.resize(bonusList.size());
|
bonuses.resize(bonusList.size());
|
||||||
@ -705,23 +712,16 @@ CBonusSystemNode::CBonusSystemNode() : bonuses(true), exportedBonuses(true), nod
|
|||||||
}
|
}
|
||||||
|
|
||||||
CBonusSystemNode::CBonusSystemNode(CBonusSystemNode && other):
|
CBonusSystemNode::CBonusSystemNode(CBonusSystemNode && other):
|
||||||
bonuses(other.bonuses),
|
bonuses(std::move(other.bonuses)),
|
||||||
exportedBonuses(other.exportedBonuses),
|
exportedBonuses(std::move(other.exportedBonuses)),
|
||||||
nodeType(other.nodeType),
|
nodeType(other.nodeType),
|
||||||
description(other.description),
|
description(other.description),
|
||||||
cachedLast(0)
|
cachedLast(0)
|
||||||
{
|
{
|
||||||
//todo: move constructor for bonuslist
|
|
||||||
other.bonuses.clear();
|
|
||||||
other.exportedBonuses.clear();
|
|
||||||
|
|
||||||
bonuses.belongsToTree = true;
|
|
||||||
exportedBonuses.belongsToTree = true;
|
|
||||||
|
|
||||||
std::swap(parents, other.parents);
|
std::swap(parents, other.parents);
|
||||||
std::swap(children, other.children);
|
std::swap(children, other.children);
|
||||||
|
|
||||||
//TODO: move cache
|
//cache ignored
|
||||||
|
|
||||||
//cachedBonuses
|
//cachedBonuses
|
||||||
//cachedRequests
|
//cachedRequests
|
||||||
|
@ -423,6 +423,7 @@ public:
|
|||||||
|
|
||||||
BonusList(bool BelongsToTree = false);
|
BonusList(bool BelongsToTree = false);
|
||||||
BonusList(const BonusList &bonusList);
|
BonusList(const BonusList &bonusList);
|
||||||
|
BonusList(BonusList && other);
|
||||||
BonusList& operator=(const BonusList &bonusList);
|
BonusList& operator=(const BonusList &bonusList);
|
||||||
|
|
||||||
// wrapper functions of the STL vector container
|
// wrapper functions of the STL vector container
|
||||||
@ -494,8 +495,6 @@ public:
|
|||||||
{
|
{
|
||||||
return bonuses.end();
|
return bonuses.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
friend class CBonusSystemNode;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extensions for BOOST_FOREACH to enable iterating of BonusList objects
|
// Extensions for BOOST_FOREACH to enable iterating of BonusList objects
|
||||||
|
Loading…
x
Reference in New Issue
Block a user