Finished deploying std::map::emplace (cont. e1a579da51
)
Apparently, the last time I did this I only grepped for `insert(std::pair` not `insert(std::make_pair`. Oversight, much?
This commit is contained in:
parent
a9e499bb64
commit
0c3260dc05
20 changed files with 97 additions and 97 deletions
|
@ -1063,46 +1063,46 @@ synced_command_result_ptr actions::execute_synced_command_action( side_number si
|
|||
const std::string& actions::get_error_name(int error_code)
|
||||
{
|
||||
if (error_names_.empty()){
|
||||
error_names_.insert(std::make_pair(action_result::AI_ACTION_SUCCESS,"action_result::AI_ACTION_SUCCESS"));
|
||||
error_names_.insert(std::make_pair(action_result::AI_ACTION_STARTED,"action_result::AI_ACTION_STARTED"));
|
||||
error_names_.insert(std::make_pair(action_result::AI_ACTION_FAILURE,"action_result::AI_ACTION_FAILURE"));
|
||||
error_names_.emplace(action_result::AI_ACTION_SUCCESS, "action_result::AI_ACTION_SUCCESS");
|
||||
error_names_.emplace(action_result::AI_ACTION_STARTED, "action_result::AI_ACTION_STARTED");
|
||||
error_names_.emplace(action_result::AI_ACTION_FAILURE, "action_result::AI_ACTION_FAILURE");
|
||||
|
||||
error_names_.insert(std::make_pair(attack_result::E_EMPTY_ATTACKER,"attack_result::E_EMPTY_ATTACKER"));
|
||||
error_names_.insert(std::make_pair(attack_result::E_EMPTY_DEFENDER,"attack_result::E_EMPTY_DEFENDER"));
|
||||
error_names_.insert(std::make_pair(attack_result::E_INCAPACITATED_ATTACKER,"attack_result::E_INCAPACITATED_ATTACKER"));
|
||||
error_names_.insert(std::make_pair(attack_result::E_INCAPACITATED_DEFENDER,"attack_result::E_INCAPACITATED_DEFENDER"));
|
||||
error_names_.insert(std::make_pair(attack_result::E_NOT_OWN_ATTACKER,"attack_result::E_NOT_OWN_ATTACKER"));
|
||||
error_names_.insert(std::make_pair(attack_result::E_NOT_ENEMY_DEFENDER,"attack_result::E_NOT_ENEMY_DEFENDER"));
|
||||
error_names_.insert(std::make_pair(attack_result::E_NO_ATTACKS_LEFT,"attack_result::E_NO_ATTACKS_LEFT"));
|
||||
error_names_.insert(std::make_pair(attack_result::E_WRONG_ATTACKER_WEAPON,"attack_result::E_WRONG_ATTACKER_WEAPON"));
|
||||
error_names_.insert(std::make_pair(attack_result::E_UNABLE_TO_CHOOSE_ATTACKER_WEAPON,"attack_result::E_UNABLE_TO_CHOOSE_ATTACKER_WEAPON"));
|
||||
error_names_.insert(std::make_pair(attack_result::E_ATTACKER_AND_DEFENDER_NOT_ADJACENT,"attack_result::E_ATTACKER_AND_DEFENDER_NOT_ADJACENT"));
|
||||
error_names_.emplace(attack_result::E_EMPTY_ATTACKER, "attack_result::E_EMPTY_ATTACKER");
|
||||
error_names_.emplace(attack_result::E_EMPTY_DEFENDER, "attack_result::E_EMPTY_DEFENDER");
|
||||
error_names_.emplace(attack_result::E_INCAPACITATED_ATTACKER, "attack_result::E_INCAPACITATED_ATTACKER");
|
||||
error_names_.emplace(attack_result::E_INCAPACITATED_DEFENDER, "attack_result::E_INCAPACITATED_DEFENDER");
|
||||
error_names_.emplace(attack_result::E_NOT_OWN_ATTACKER, "attack_result::E_NOT_OWN_ATTACKER");
|
||||
error_names_.emplace(attack_result::E_NOT_ENEMY_DEFENDER, "attack_result::E_NOT_ENEMY_DEFENDER");
|
||||
error_names_.emplace(attack_result::E_NO_ATTACKS_LEFT, "attack_result::E_NO_ATTACKS_LEFT");
|
||||
error_names_.emplace(attack_result::E_WRONG_ATTACKER_WEAPON, "attack_result::E_WRONG_ATTACKER_WEAPON");
|
||||
error_names_.emplace(attack_result::E_UNABLE_TO_CHOOSE_ATTACKER_WEAPON, "attack_result::E_UNABLE_TO_CHOOSE_ATTACKER_WEAPON");
|
||||
error_names_.emplace(attack_result::E_ATTACKER_AND_DEFENDER_NOT_ADJACENT," attack_result::E_ATTACKER_AND_DEFENDER_NOT_ADJACENT");
|
||||
|
||||
error_names_.insert(std::make_pair(move_result::E_EMPTY_MOVE,"move_result::E_EMPTY_MOVE"));
|
||||
error_names_.insert(std::make_pair(move_result::E_NO_UNIT,"move_result::E_NO_UNIT"));
|
||||
error_names_.insert(std::make_pair(move_result::E_NOT_OWN_UNIT,"move_result::E_NOT_OWN_UNIT"));
|
||||
error_names_.insert(std::make_pair(move_result::E_INCAPACITATED_UNIT,"move_result::E_INCAPACITATED_UNIT"));
|
||||
error_names_.insert(std::make_pair(move_result::E_AMBUSHED,"move_result::E_AMBUSHED"));
|
||||
error_names_.insert(std::make_pair(move_result::E_FAILED_TELEPORT,"move_result::E_FAILED_TELEPORT"));
|
||||
error_names_.insert(std::make_pair(move_result::E_NOT_REACHED_DESTINATION,"move_result::E_NOT_REACHED_DESTINATION"));
|
||||
error_names_.insert(std::make_pair(move_result::E_NO_ROUTE,"move_result::E_NO_ROUTE"));
|
||||
error_names_.emplace(move_result::E_EMPTY_MOVE, "move_result::E_EMPTY_MOVE");
|
||||
error_names_.emplace(move_result::E_NO_UNIT, "move_result::E_NO_UNIT");
|
||||
error_names_.emplace(move_result::E_NOT_OWN_UNIT, "move_result::E_NOT_OWN_UNIT");
|
||||
error_names_.emplace(move_result::E_INCAPACITATED_UNIT, "move_result::E_INCAPACITATED_UNIT");
|
||||
error_names_.emplace(move_result::E_AMBUSHED, "move_result::E_AMBUSHED");
|
||||
error_names_.emplace(move_result::E_FAILED_TELEPORT, "move_result::E_FAILED_TELEPORT");
|
||||
error_names_.emplace(move_result::E_NOT_REACHED_DESTINATION, "move_result::E_NOT_REACHED_DESTINATION");
|
||||
error_names_.emplace(move_result::E_NO_ROUTE, "move_result::E_NO_ROUTE");
|
||||
|
||||
error_names_.insert(std::make_pair(recall_result::E_NOT_AVAILABLE_FOR_RECALLING,"recall_result::E_NOT_AVAILABLE_FOR_RECALLING"));
|
||||
error_names_.insert(std::make_pair(recall_result::E_NO_GOLD,"recall_result::E_NO_GOLD"));
|
||||
error_names_.insert(std::make_pair(recall_result::E_NO_LEADER,"recall_result::E_NO_LEADER"));
|
||||
error_names_.insert(std::make_pair(recall_result::E_LEADER_NOT_ON_KEEP,"recall_result::E_LEADER_NOT_ON_KEEP"));
|
||||
error_names_.insert(std::make_pair(recall_result::E_BAD_RECALL_LOCATION,"recall_result::E_BAD_RECALL_LOCATION"));
|
||||
error_names_.emplace(recall_result::E_NOT_AVAILABLE_FOR_RECALLING, "recall_result::E_NOT_AVAILABLE_FOR_RECALLING");
|
||||
error_names_.emplace(recall_result::E_NO_GOLD, "recall_result::E_NO_GOLD");
|
||||
error_names_.emplace(recall_result::E_NO_LEADER," recall_result::E_NO_LEADER");
|
||||
error_names_.emplace(recall_result::E_LEADER_NOT_ON_KEEP, "recall_result::E_LEADER_NOT_ON_KEEP");
|
||||
error_names_.emplace(recall_result::E_BAD_RECALL_LOCATION, "recall_result::E_BAD_RECALL_LOCATION");
|
||||
|
||||
error_names_.insert(std::make_pair(recruit_result::E_NOT_AVAILABLE_FOR_RECRUITING,"recruit_result::E_NOT_AVAILABLE_FOR_RECRUITING"));
|
||||
error_names_.insert(std::make_pair(recruit_result::E_UNKNOWN_OR_DUMMY_UNIT_TYPE,"recruit_result::E_UNKNOWN_OR_DUMMY_UNIT_TYPE"));
|
||||
error_names_.insert(std::make_pair(recruit_result::E_NO_GOLD,"recruit_result::E_NO_GOLD"));
|
||||
error_names_.insert(std::make_pair(recruit_result::E_NO_LEADER,"recruit_result::E_NO_LEADER"));
|
||||
error_names_.insert(std::make_pair(recruit_result::E_LEADER_NOT_ON_KEEP,"recruit_result::E_LEADER_NOT_ON_KEEP"));
|
||||
error_names_.insert(std::make_pair(recruit_result::E_BAD_RECRUIT_LOCATION,"recruit_result::E_BAD_RECRUIT_LOCATION"));
|
||||
error_names_.emplace(recruit_result::E_NOT_AVAILABLE_FOR_RECRUITING, "recruit_result::E_NOT_AVAILABLE_FOR_RECRUITING");
|
||||
error_names_.emplace(recruit_result::E_UNKNOWN_OR_DUMMY_UNIT_TYPE, "recruit_result::E_UNKNOWN_OR_DUMMY_UNIT_TYPE");
|
||||
error_names_.emplace(recruit_result::E_NO_GOLD, "recruit_result::E_NO_GOLD");
|
||||
error_names_.emplace(recruit_result::E_NO_LEADER, "recruit_result::E_NO_LEADER");
|
||||
error_names_.emplace(recruit_result::E_LEADER_NOT_ON_KEEP, "recruit_result::E_LEADER_NOT_ON_KEEP");
|
||||
error_names_.emplace(recruit_result::E_BAD_RECRUIT_LOCATION, "recruit_result::E_BAD_RECRUIT_LOCATION");
|
||||
|
||||
error_names_.insert(std::make_pair(stopunit_result::E_NO_UNIT,"stopunit_result::E_NO_UNIT"));
|
||||
error_names_.insert(std::make_pair(stopunit_result::E_NOT_OWN_UNIT,"stopunit_result::E_NOT_OWN_UNIT"));
|
||||
error_names_.insert(std::make_pair(stopunit_result::E_INCAPACITATED_UNIT,"stopunit_result::E_INCAPACITATED_UNIT"));
|
||||
error_names_.emplace(stopunit_result::E_NO_UNIT, "stopunit_result::E_NO_UNIT");
|
||||
error_names_.emplace(stopunit_result::E_NOT_OWN_UNIT, "stopunit_result::E_NOT_OWN_UNIT");
|
||||
error_names_.emplace(stopunit_result::E_INCAPACITATED_UNIT, "stopunit_result::E_INCAPACITATED_UNIT");
|
||||
}
|
||||
std::map<int,std::string>::iterator i = error_names_.find(error_code);
|
||||
if (i==error_names_.end()){
|
||||
|
|
|
@ -70,7 +70,7 @@ void configuration::init(const config &game_config)
|
|||
desc.text = ai_configuration["description"].t_str();
|
||||
desc.cfg=ai_configuration;
|
||||
|
||||
ai_configurations_.insert(std::make_pair(id,desc));
|
||||
ai_configurations_.emplace(id, desc);
|
||||
LOG_AI_CONFIGURATION << "loaded AI config: " << ai_configuration["description"] << std::endl;
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ void extract_ai_configurations(std::map<std::string, description> &storage, cons
|
|||
desc.text = ai_configuration["description"].t_str();
|
||||
desc.cfg=ai_configuration;
|
||||
|
||||
storage.insert(std::make_pair(id,desc));
|
||||
storage.emplace(id, desc);
|
||||
LOG_AI_CONFIGURATION << "loaded AI config: " << ai_configuration["description"] << std::endl;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -474,14 +474,14 @@ double move_leader_to_keep_phase::evaluate()
|
|||
return BAD_SCORE;
|
||||
}
|
||||
//define the next hop to have the lowest cost (0)
|
||||
moves_toward_keep.insert(std::make_pair(0, next_hop));
|
||||
moves_toward_keep.emplace(0, next_hop);
|
||||
|
||||
for (const pathfind::paths::step &dest : leader_paths.destinations) {
|
||||
if (!units_.find(dest.curr).valid()) {
|
||||
route = pathfind::a_star_search(dest.curr, next_hop, 10000.0, calc,
|
||||
resources::gameboard->map().w(), resources::gameboard->map().h(), &allowed_teleports);
|
||||
if (route.move_cost < next_hop_cost) {
|
||||
moves_toward_keep.insert(std::make_pair(route.move_cost, dest.curr));
|
||||
moves_toward_keep.emplace(route.move_cost, dest.curr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -613,7 +613,7 @@ void get_villages_phase::get_villages(
|
|||
continue;
|
||||
}
|
||||
if(u_itor->side() == get_side() && u_itor->movement_left()) {
|
||||
reachmap.insert(std::make_pair(u_itor->get_location(), std::vector<map_location>()));
|
||||
reachmap.emplace(u_itor->get_location(), std::vector<map_location>());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -990,7 +990,7 @@ void get_villages_phase::dispatch_complex(
|
|||
for(size_t u = 0; u < unit_count; ++u, ++itor) {
|
||||
units[u] = itor->first;
|
||||
villages_per_unit[u] = itor->second.size();
|
||||
unit_lookup.insert(std::make_pair(villages_per_unit[u], u));
|
||||
unit_lookup.emplace(villages_per_unit[u], u);
|
||||
|
||||
assert(itor->second.size() >= 2);
|
||||
|
||||
|
|
|
@ -792,7 +792,7 @@ std::stack<holder>& manager::get_or_create_ai_stack_for_side( side_number side )
|
|||
if (iter!=ai_map_.end()){
|
||||
return iter->second;
|
||||
}
|
||||
return ai_map_.insert(std::make_pair(side, std::stack<holder>())).first->second;
|
||||
return ai_map_.emplace(side, std::stack<holder>()).first->second;
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
|
|
@ -177,8 +177,8 @@ void server::load_config()
|
|||
load_blacklist();
|
||||
|
||||
// Load any configured hooks.
|
||||
hooks_.insert(std::make_pair(std::string("hook_post_upload"), cfg_["hook_post_upload"]));
|
||||
hooks_.insert(std::make_pair(std::string("hook_post_erase"), cfg_["hook_post_erase"]));
|
||||
hooks_.emplace(std::string("hook_post_upload"), cfg_["hook_post_upload"]);
|
||||
hooks_.emplace(std::string("hook_post_erase"), cfg_["hook_post_erase"]);
|
||||
|
||||
#ifndef _WIN32
|
||||
// Open the control socket if enabled.
|
||||
|
|
|
@ -95,7 +95,7 @@ void terrain_palette::setup(const config& cfg)
|
|||
|
||||
std::map<std::string, item_group*> id_to_group;
|
||||
for (item_group& group : groups_) {
|
||||
id_to_group.insert(std::make_pair(group.id, &group));
|
||||
id_to_group.emplace(group.id, &group);
|
||||
}
|
||||
|
||||
// add the groups for all terrains to the map
|
||||
|
|
|
@ -65,24 +65,24 @@ void editor_toolkit::init_sidebar(const config& game_config)
|
|||
|
||||
void editor_toolkit::init_mouse_actions(context_manager& cmanager)
|
||||
{
|
||||
mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_PAINT,
|
||||
std::make_shared<mouse_action_paint>(&brush_, key_, *palette_manager_->terrain_palette_.get())));
|
||||
mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_FILL,
|
||||
std::make_shared<mouse_action_fill>(key_, *palette_manager_->terrain_palette_.get())));
|
||||
mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_SELECT,
|
||||
std::make_shared<mouse_action_select>(&brush_, key_, *palette_manager_->empty_palette_.get())));
|
||||
mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_STARTING_POSITION,
|
||||
std::make_shared<mouse_action_starting_position>(key_, *palette_manager_->location_palette_.get())));
|
||||
mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_LABEL,
|
||||
std::make_shared<mouse_action_map_label>(key_, *palette_manager_->empty_palette_.get())));
|
||||
mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_UNIT,
|
||||
std::make_shared<mouse_action_unit>(key_, *palette_manager_->unit_palette_.get())));
|
||||
mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_VILLAGE,
|
||||
std::make_shared<mouse_action_village>(key_, *palette_manager_->empty_palette_.get())));
|
||||
mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_CLIPBOARD_PASTE,
|
||||
std::make_shared<mouse_action_paste>(cmanager.get_clipboard(), key_, *palette_manager_->empty_palette_.get())));
|
||||
mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_ITEM,
|
||||
std::make_shared<mouse_action_item>(key_, *palette_manager_->item_palette_.get())));
|
||||
mouse_actions_.emplace(hotkey::HOTKEY_EDITOR_TOOL_PAINT,
|
||||
std::make_shared<mouse_action_paint>(&brush_, key_, *palette_manager_->terrain_palette_.get()));
|
||||
mouse_actions_.emplace(hotkey::HOTKEY_EDITOR_TOOL_FILL,
|
||||
std::make_shared<mouse_action_fill>(key_, *palette_manager_->terrain_palette_.get()));
|
||||
mouse_actions_.emplace(hotkey::HOTKEY_EDITOR_TOOL_SELECT,
|
||||
std::make_shared<mouse_action_select>(&brush_, key_, *palette_manager_->empty_palette_.get()));
|
||||
mouse_actions_.emplace(hotkey::HOTKEY_EDITOR_TOOL_STARTING_POSITION,
|
||||
std::make_shared<mouse_action_starting_position>(key_, *palette_manager_->location_palette_.get()));
|
||||
mouse_actions_.emplace(hotkey::HOTKEY_EDITOR_TOOL_LABEL,
|
||||
std::make_shared<mouse_action_map_label>(key_, *palette_manager_->empty_palette_.get()));
|
||||
mouse_actions_.emplace(hotkey::HOTKEY_EDITOR_TOOL_UNIT,
|
||||
std::make_shared<mouse_action_unit>(key_, *palette_manager_->unit_palette_.get()));
|
||||
mouse_actions_.emplace(hotkey::HOTKEY_EDITOR_TOOL_VILLAGE,
|
||||
std::make_shared<mouse_action_village>(key_, *palette_manager_->empty_palette_.get()));
|
||||
mouse_actions_.emplace(hotkey::HOTKEY_EDITOR_CLIPBOARD_PASTE,
|
||||
std::make_shared<mouse_action_paste>(cmanager.get_clipboard(), key_, *palette_manager_->empty_palette_.get()));
|
||||
mouse_actions_.emplace(hotkey::HOTKEY_EDITOR_TOOL_ITEM,
|
||||
std::make_shared<mouse_action_item>(key_, *palette_manager_->item_palette_.get()));
|
||||
|
||||
for (const theme::menu& menu : gui_.get_theme().menus()) {
|
||||
if (menu.items().size() == 1) {
|
||||
|
|
|
@ -94,7 +94,7 @@ struct char_block_map
|
|||
return;
|
||||
}
|
||||
}
|
||||
cbmap.insert(std::make_pair(first, block_t(last, id)));
|
||||
cbmap.emplace(first, block_t(last, id));
|
||||
}
|
||||
/**
|
||||
* Compresses map by merging consecutive ranges with the same font, even
|
||||
|
@ -154,7 +154,7 @@ static TTF_Font* open_font(const std::string& fname, int size)
|
|||
}
|
||||
|
||||
TTF_Font* result = open_font_impl(fname, size);
|
||||
open_fonts.insert(std::make_pair(key, result));
|
||||
open_fonts.emplace(key, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -226,7 +226,7 @@ TTF_Font* sdl_ttf::get_font(font_id id)
|
|||
if ((id.style & TTF_STYLE_ITALIC) && italic_names[id.subset].size()) {
|
||||
if (TTF_Font* font = open_font(italic_names[id.subset], id.size)) {
|
||||
ttf_record rec = {font, TTF_STYLE_ITALIC};
|
||||
font_table.insert(std::make_pair(id, rec));
|
||||
font_table.emplace(id, rec);
|
||||
return sdl_ttf::get_font(id);
|
||||
}
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ TTF_Font* sdl_ttf::get_font(font_id id)
|
|||
if ((id.style & TTF_STYLE_BOLD) && bold_names[id.subset].size()) {
|
||||
if (TTF_Font* font = open_font(bold_names[id.subset], id.size)) {
|
||||
ttf_record rec = {font, TTF_STYLE_BOLD};
|
||||
font_table.insert(std::make_pair(id, rec));
|
||||
font_table.emplace(id, rec);
|
||||
return sdl_ttf::get_font(id);
|
||||
}
|
||||
}
|
||||
|
@ -244,14 +244,14 @@ TTF_Font* sdl_ttf::get_font(font_id id)
|
|||
if (font_names[id.subset].size()) {
|
||||
if(TTF_Font* font = open_font(font_names[id.subset], id.size)) {
|
||||
ttf_record rec = {font, TTF_STYLE_NORMAL};
|
||||
font_table.insert(std::make_pair(id, rec));
|
||||
font_table.emplace(id, rec);
|
||||
return sdl_ttf::get_font(id);
|
||||
}
|
||||
}
|
||||
|
||||
// Failed to find a font.
|
||||
ttf_record rec = {nullptr, TTF_STYLE_NORMAL};
|
||||
font_table.insert(std::make_pair(id, rec));
|
||||
font_table.emplace(id, rec);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -409,7 +409,7 @@ std::vector<topic> generate_weapon_special_topics(const bool sort_generated)
|
|||
std::vector<std::pair<t_string, t_string> > specials = atk.special_tooltips();
|
||||
for ( size_t i = 0; i != specials.size(); ++i )
|
||||
{
|
||||
special_description.insert(std::make_pair(specials[i].first, specials[i].second));
|
||||
special_description.emplace(specials[i].first, specials[i].second);
|
||||
|
||||
if (!type.hide_help()) {
|
||||
//add a link in the list of units having this special
|
||||
|
@ -430,7 +430,7 @@ std::vector<topic> generate_weapon_special_topics(const bool sort_generated)
|
|||
if(effect["apply_to"] == "new_attack" && effect.has_child("specials")) {
|
||||
for(config::any_child spec : effect.child("specials").all_children_range()) {
|
||||
if(!spec.cfg["name"].empty()) {
|
||||
special_description.insert(std::make_pair(spec.cfg["name"].t_str(), spec.cfg["description"].t_str()));
|
||||
special_description.emplace(spec.cfg["name"].t_str(), spec.cfg["description"].t_str());
|
||||
if(!type.hide_help()) {
|
||||
//add a link in the list of units having this special
|
||||
std::string type_name = type.type_name();
|
||||
|
@ -447,7 +447,7 @@ std::vector<topic> generate_weapon_special_topics(const bool sort_generated)
|
|||
} else if(effect["apply_to"] == "attack" && effect.has_child("set_specials")) {
|
||||
for(config::any_child spec : effect.child("set_specials").all_children_range()) {
|
||||
if(!spec.cfg["name"].empty()) {
|
||||
special_description.insert(std::make_pair(spec.cfg["name"].t_str(), spec.cfg["description"].t_str()));
|
||||
special_description.emplace(spec.cfg["name"].t_str(), spec.cfg["description"].t_str());
|
||||
if(!type.hide_help()) {
|
||||
//add a link in the list of units having this special
|
||||
std::string type_name = type.type_name();
|
||||
|
@ -517,7 +517,7 @@ std::vector<topic> generate_ability_topics(const bool sort_generated)
|
|||
const std::string abil_desc =
|
||||
j >= desc_vec.size() ? "" : desc_vec[j].str();
|
||||
|
||||
ability_description.insert(std::make_pair(abil_name, abil_desc));
|
||||
ability_description.emplace(abil_name, abil_desc);
|
||||
|
||||
if (!type.hide_help()) {
|
||||
//add a link in the list of units with this ability
|
||||
|
@ -671,7 +671,7 @@ std::vector<topic> generate_trait_topics(const bool sort_generated)
|
|||
|
||||
for (const config & trait : unit_types.traits()) {
|
||||
const std::string trait_id = trait["id"];
|
||||
trait_list.insert(std::make_pair(trait_id, trait));
|
||||
trait_list.emplace(trait_id, trait);
|
||||
}
|
||||
|
||||
|
||||
|
@ -682,13 +682,13 @@ std::vector<topic> generate_trait_topics(const bool sort_generated)
|
|||
if (config::const_child_itors traits = type.possible_traits()) {
|
||||
for (const config & trait : traits) {
|
||||
const std::string trait_id = trait["id"];
|
||||
trait_list.insert(std::make_pair(trait_id, trait));
|
||||
trait_list.emplace(trait_id, trait);
|
||||
}
|
||||
}
|
||||
if (const unit_race *r = unit_types.find_race(type.race_id())) {
|
||||
for (const config & trait : r->additional_traits()) {
|
||||
const std::string trait_id = trait["id"];
|
||||
trait_list.insert(std::make_pair(trait_id, trait));
|
||||
trait_list.emplace(trait_id, trait);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -243,7 +243,7 @@ void locator::init_index()
|
|||
|
||||
if ( i == locator_finder.end() ) {
|
||||
index_ = last_index_++;
|
||||
locator_finder.insert(std::make_pair(val_, index_));
|
||||
locator_finder.emplace(val_, index_);
|
||||
} else {
|
||||
index_ = i->second;
|
||||
}
|
||||
|
@ -1083,7 +1083,7 @@ bool exists(const image::locator& i_locator)
|
|||
|
||||
// The insertion will fail if there is already an element in the cache
|
||||
std::pair< std::map< std::string, bool >::iterator, bool >
|
||||
it = image_existence_map.insert(std::make_pair(i_locator.get_filename(), false));
|
||||
it = image_existence_map.emplace(i_locator.get_filename(), false);
|
||||
bool &cache = it.first->second;
|
||||
if (it.second)
|
||||
cache = !filesystem::get_binary_file_location("images", i_locator.get_filename()).empty();
|
||||
|
|
|
@ -377,7 +377,7 @@ int movetype::terrain_info::data::value(
|
|||
{
|
||||
// Check the cache.
|
||||
std::pair<cache_t::iterator, bool> cache_it =
|
||||
cache_.insert(std::make_pair(terrain, -127)); // Bogus value that should never be seen.
|
||||
cache_.emplace(terrain, -127); // Bogus value that should never be seen.
|
||||
if ( cache_it.second )
|
||||
// The cache did not have an entry for this terrain, so calculate the value.
|
||||
cache_it.first->second = calc_value(terrain, fallback, recurse_count);
|
||||
|
|
|
@ -97,7 +97,7 @@ mp_game_settings::mp_game_settings(const config& cfg)
|
|||
{
|
||||
for (const config & a : cfg.child_range("addon")) {
|
||||
if (!a["id"].empty()) {
|
||||
addons.insert(std::make_pair(a["id"].str(), addon_version_info(a)));
|
||||
addons.emplace(a["id"].str(), addon_version_info(a));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -195,6 +195,6 @@ void mp_game_settings::update_addon_requirements(const config & cfg) {
|
|||
}
|
||||
} else {
|
||||
// Didn't find this addon-id in the map, so make a new entry.
|
||||
addons.insert(std::make_pair(cfg["id"].str(), new_data));
|
||||
addons.emplace(cfg["id"].str(), new_data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -220,13 +220,13 @@ teleport_map::teleport_map(
|
|||
if(teleport_map_.count(*source_it) == 0) {
|
||||
std::set<std::string> id_set;
|
||||
id_set.insert(teleport_id);
|
||||
teleport_map_.insert(std::make_pair(*source_it, id_set));
|
||||
teleport_map_.emplace(*source_it, id_set);
|
||||
} else {
|
||||
(teleport_map_.find(*source_it)->second).insert(teleport_id);
|
||||
}
|
||||
}
|
||||
sources_.insert(std::make_pair(teleport_id, locations.first));
|
||||
targets_.insert(std::make_pair(teleport_id, locations.second));
|
||||
sources_.emplace(teleport_id, locations.first);
|
||||
targets_.emplace(teleport_id, locations.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3214,7 +3214,7 @@ namespace { // Types
|
|||
loc_(loc),
|
||||
too_many_recursions_(false)
|
||||
{
|
||||
counter::iterator inserted = counter_.insert(std::make_pair(loc_, 0)).first;
|
||||
counter::iterator inserted = counter_.emplace(loc_, 0).first;
|
||||
++inserted->second;
|
||||
too_many_recursions_ = inserted->second >= max_recursion;
|
||||
}
|
||||
|
|
|
@ -40,12 +40,12 @@ void plugins_context::initialize(const std::vector<Reg>& callbacks, const std::v
|
|||
{
|
||||
for (const Reg& l : callbacks) { /* fill the table with given functions */
|
||||
if (l.name != nullptr) {
|
||||
callbacks_.insert(std::make_pair(l.name, l.func));
|
||||
callbacks_.emplace(l.name, l.func);
|
||||
}
|
||||
}
|
||||
for (const aReg& r : accessors) { /* fill the table with given functions */
|
||||
if (r.name != nullptr) {
|
||||
accessors_.insert(std::make_pair(r.name, r.func));
|
||||
accessors_.emplace(r.name, r.func);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -321,7 +321,7 @@ void create_terrain_maps(const config::const_child_itors &cfgs,
|
|||
<< terrain.id() << " " << terrain.name() << " : " << terrain.editor_group() << "\n";
|
||||
|
||||
std::pair<std::map<t_translation::terrain_code, terrain_type>::iterator, bool> res;
|
||||
res = letter_to_terrain.insert(std::make_pair(terrain.number(), terrain));
|
||||
res = letter_to_terrain.emplace(terrain.number(), terrain);
|
||||
if (!res.second) {
|
||||
terrain_type& curr = res.first->second;
|
||||
if(terrain == curr) {
|
||||
|
|
|
@ -189,7 +189,7 @@ int add_tooltip(const SDL_Rect& rect, const std::string& message, const std::str
|
|||
|
||||
int id = tooltip_id++;
|
||||
|
||||
tips.insert(std::make_pair(id, tooltip(rect, message, action, use_markup, foreground) ));
|
||||
tips.emplace(id, tooltip(rect, message, action, use_markup, foreground));
|
||||
|
||||
current_tooltip = tips.end();
|
||||
return id;
|
||||
|
|
|
@ -96,12 +96,12 @@ std::pair<unit_map::unit_iterator, bool> unit_map::move(const map_location &src,
|
|||
|
||||
lmap_.erase(i);
|
||||
|
||||
std::pair<lmap::iterator,bool> res = lmap_.insert(std::make_pair(dst, uit));
|
||||
std::pair<lmap::iterator,bool> res = lmap_.emplace(dst, uit);
|
||||
|
||||
//Fail and don't move if the destination is already occupied
|
||||
if(res.second == false) {
|
||||
p->set_location(src);
|
||||
lmap_.insert(std::make_pair(src, uit));
|
||||
lmap_.emplace(src, uit);
|
||||
return std::make_pair(make_unit_iterator(uit), false);
|
||||
}
|
||||
|
||||
|
@ -142,7 +142,7 @@ std::pair<unit_map::unit_iterator, bool> unit_map::insert(unit_ptr p) {
|
|||
DBG_NG << "Adding unit " << p->underlying_id() << " - " << p->id()
|
||||
<< " to location: (" << loc << ")\n";
|
||||
|
||||
std::pair<umap::iterator, bool> uinsert = umap_.insert(std::make_pair(unit_id, upod ));
|
||||
std::pair<umap::iterator, bool> uinsert = umap_.emplace(unit_id, upod);
|
||||
|
||||
if (! uinsert.second) {
|
||||
//If the pod is empty reinsert the unit in the same list element
|
||||
|
@ -164,7 +164,7 @@ std::pair<unit_map::unit_iterator, bool> unit_map::insert(unit_ptr p) {
|
|||
<< p->underlying_id()
|
||||
<< " to prevent duplicate id conflicts.\n";
|
||||
|
||||
uinsert = umap_.insert(std::make_pair(p->underlying_id(), upod ));
|
||||
uinsert = umap_.emplace(p->underlying_id(), upod);
|
||||
int guard(0);
|
||||
while (!uinsert.second && (++guard < 1e6) ) {
|
||||
if(guard % 10 == 9){
|
||||
|
@ -176,13 +176,13 @@ std::pair<unit_map::unit_iterator, bool> unit_map::insert(unit_ptr p) {
|
|||
"\nThank you for your help in fixing this bug.\n";
|
||||
}
|
||||
p->clone(false);
|
||||
uinsert = umap_.insert(std::make_pair(p->underlying_id(), upod )); }
|
||||
uinsert = umap_.emplace(p->underlying_id(), upod); }
|
||||
if (!uinsert.second) {
|
||||
throw game::error("One million collisions in unit_map"); }
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<lmap::iterator,bool> linsert = lmap_.insert(std::make_pair(loc, uinsert.first ));
|
||||
std::pair<lmap::iterator,bool> linsert = lmap_.emplace(loc, uinsert.first);
|
||||
|
||||
//Fail if the location is occupied
|
||||
if(! linsert.second) {
|
||||
|
|
|
@ -1017,7 +1017,7 @@ void unit_type_data::set_config(config &cfg)
|
|||
|
||||
for (const config &mt : cfg.child_range("movetype"))
|
||||
{
|
||||
movement_types_.insert(std::make_pair(mt["name"].str(), movetype(mt)));
|
||||
movement_types_.emplace(mt["name"].str(), movetype(mt));
|
||||
gui2::dialogs::loading_screen::progress();
|
||||
}
|
||||
|
||||
|
|
|
@ -255,7 +255,7 @@ static void handle_preprocess_command(const commandline_options& cmdline_opts)
|
|||
}
|
||||
|
||||
LOG_PREPROC << "adding define: " << define << '\n';
|
||||
defines_map.insert(std::make_pair(define, preproc_define(define)));
|
||||
defines_map.emplace(define, preproc_define(define));
|
||||
|
||||
if (define == "SKIP_CORE")
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue