Unit: replace unit_ability_list::push_back with an emplace_back impl
This commit is contained in:
parent
1749de1521
commit
c7b8694370
3 changed files with 8 additions and 6 deletions
|
@ -190,7 +190,7 @@ unit_ability_list unit::get_abilities(const std::string& tag_name,
|
|||
&& ability_affects_weapon(i, weapon, false)
|
||||
&& ability_affects_weapon(i, opp_weapon, true)
|
||||
) {
|
||||
res.push_back(unit_ability(&i, loc));
|
||||
res.emplace_back(&i, loc);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ unit_ability_list unit::get_abilities(const std::string& tag_name,
|
|||
&& ability_affects_adjacent(tag_name, j, i, loc, *it) && ability_affects_weapon(j, weapon, false)
|
||||
&& ability_affects_weapon(j, opp_weapon, true)
|
||||
) {
|
||||
res.push_back(unit_ability(&j, adjacent[i]));
|
||||
res.emplace_back(&j, adjacent[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -685,7 +685,7 @@ unit_ability_list attack_type::get_specials(const std::string& special) const
|
|||
|
||||
for(const config& i : specials_.child_range(special)) {
|
||||
if(special_active(i, AFFECT_SELF)) {
|
||||
res.push_back(unit_ability(&i, self_loc_));
|
||||
res.emplace_back(&i, self_loc_);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -695,7 +695,7 @@ unit_ability_list attack_type::get_specials(const std::string& special) const
|
|||
|
||||
for(const config& i : other_attack_->specials_.child_range(special)) {
|
||||
if(other_attack_->special_active(i, AFFECT_OTHER)) {
|
||||
res.push_back(unit_ability(&i, other_loc_));
|
||||
res.emplace_back(&i, other_loc_);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -855,7 +855,7 @@ int unit_type::resistance_against(const std::string& damage_name, bool attacker)
|
|||
continue;
|
||||
}
|
||||
|
||||
resistance_abilities.push_back(unit_ability(&cfg, map_location::null_location()));
|
||||
resistance_abilities.emplace_back(&cfg, map_location::null_location());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,9 @@ public:
|
|||
const unit_ability& back() const { return cfgs_.back(); }
|
||||
|
||||
iterator erase(const iterator& erase_it) { return cfgs_.erase(erase_it); }
|
||||
void push_back(const unit_ability& ability) { cfgs_.push_back(ability); }
|
||||
|
||||
template<typename... T>
|
||||
void emplace_back(T&&... args) { cfgs_.emplace_back(args...); }
|
||||
|
||||
const map_location& loc() const { return loc_; }
|
||||
private:
|
||||
|
|
Loading…
Add table
Reference in a new issue