1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Fixed incorrect usage of const std::shared_ptr. Resolves 0003142.

Replaced const TBonusListPtr with TConstBonusListPtr where necessary
Replaced const std::shared_ptr<T> with std::shared_ptr<const T> where necessary.
Removed superfluous use of const.
Replaced const std::shared_ptr<T> with const std::shared_ptr<T> & in function parameters and ranged for-loops.
This commit is contained in:
John Bolton
2020-09-30 22:55:41 -07:00
parent a54626459d
commit 6d8f1e4530
26 changed files with 88 additions and 87 deletions

View File

@@ -97,11 +97,11 @@ SlotID StackWithBonuses::unitSlot() const
return slot;
}
const TBonusListPtr StackWithBonuses::getAllBonuses(const CSelector & selector, const CSelector & limit,
TConstBonusListPtr StackWithBonuses::getAllBonuses(const CSelector & selector, const CSelector & limit,
const CBonusSystemNode * root, const std::string & cachingStr) const
{
TBonusListPtr ret = std::make_shared<BonusList>();
const TBonusListPtr originalList = origBearer->getAllBonuses(selector, limit, root, cachingStr);
TConstBonusListPtr originalList = origBearer->getAllBonuses(selector, limit, root, cachingStr);
vstd::copy_if(*originalList, std::back_inserter(*ret), [this](const std::shared_ptr<Bonus> & b)
{
@@ -177,7 +177,7 @@ void StackWithBonuses::removeUnitBonus(const std::vector<Bonus> & bonus)
void StackWithBonuses::removeUnitBonus(const CSelector & selector)
{
TBonusListPtr toRemove = origBearer->getBonuses(selector);
TConstBonusListPtr toRemove = origBearer->getBonuses(selector);
for(auto b : *toRemove)
bonusesToRemove.insert(b);

View File

@@ -42,7 +42,7 @@ public:
SlotID unitSlot() const override;
///IBonusBearer
const TBonusListPtr getAllBonuses(const CSelector & selector, const CSelector & limit,
TConstBonusListPtr getAllBonuses(const CSelector & selector, const CSelector & limit,
const CBonusSystemNode * root = nullptr, const std::string & cachingStr = "") const override;
int64_t getTreeVersion() const override;