diff --git a/src/actions/create.cpp b/src/actions/create.cpp index d030adfa4ca8..353f4523c851 100644 --- a/src/actions/create.cpp +++ b/src/actions/create.cpp @@ -630,11 +630,8 @@ place_recruit_result place_recruit(unit_ptr u, const map_location &recruit_locat find_recruit_leader(u->side(), recruit_location, recruited_from); u->set_location(recruit_location); - unit_map::unit_iterator new_unit_itor; - bool success = false; - // Add the unit to the board. - std::tie(new_unit_itor, success) = resources::gameboard->units().insert(u); + auto [new_unit_itor, success] = resources::gameboard->units().insert(u); assert(success); map_location current_loc = recruit_location; diff --git a/src/actions/move.cpp b/src/actions/move.cpp index 7bc0452ec14d..51a15e045250 100644 --- a/src/actions/move.cpp +++ b/src/actions/move.cpp @@ -514,10 +514,7 @@ namespace { // Private helpers for move_unit() move_it_->anim_comp().invalidate(disp); // Attempt actually moving. Fails if *step_to is occupied. - unit_map::unit_iterator unit_it; - bool success = false; - - std::tie(unit_it, success) = resources::gameboard->units().move(*move_loc_, *step_to); + auto [unit_it, success] = resources::gameboard->units().move(*move_loc_, *step_to); if(success) { // Update the moving unit. @@ -891,11 +888,7 @@ namespace { // Private helpers for move_unit() // Make sure this hex is drawn correctly. disp.invalidate(hex); // Fire sighted events. - - bool wml_undo_blocked = false; - bool wml_move_aborted = false; - - std::tie(wml_undo_blocked, wml_move_aborted) = actor_sighted(*ambusher, &sight_cache); + auto [wml_undo_blocked, wml_move_aborted] = actor_sighted(*ambusher, &sight_cache); // TODO: should we call post_wml ? wml_move_aborted_ |= wml_move_aborted; wml_undo_disabled_ |= wml_undo_blocked; @@ -1000,11 +993,7 @@ namespace { // Private helpers for move_unit() // Finish animating. animator.finish(move_it_.get_shared_ptr()); // Check for the moving unit being seen. - - bool wml_undo_blocked = false; - bool wml_move_aborted = false; - - std::tie(wml_undo_blocked, wml_move_aborted) = actor_sighted(*move_it_, ¬_seeing); + auto [wml_undo_blocked, wml_move_aborted] = actor_sighted(*move_it_, ¬_seeing); // TODO: should we call post_wml ? wml_move_aborted_ |= wml_move_aborted; wml_undo_disabled_ |= wml_undo_blocked; diff --git a/src/ai/simulated_actions.cpp b/src/ai/simulated_actions.cpp index 2fe5ad7ecd81..0ea1f3dc719c 100644 --- a/src/ai/simulated_actions.cpp +++ b/src/ai/simulated_actions.cpp @@ -98,11 +98,8 @@ bool simulated_move(int side, const map_location& from, const map_location& to, { LOG_AI_SIM_ACTIONS << "Simulated move" << std::endl; - unit_map::unit_iterator move_unit; - bool success = false; - // In simulation, AI should not know if there is a enemy's ambusher. - std::tie(move_unit, success) = resources::gameboard->units().move(from, to); + auto [move_unit, success] = resources::gameboard->units().move(from, to); if(!success) { // This happened because in some CAs like get_village_phase and move_leader_to_keep phase, @@ -221,10 +218,7 @@ void helper_place_unit(const unit& u, const map_location& loc){ new_unit->heal_fully(); new_unit->set_location(loc); - unit_map::unit_iterator new_unit_itor; - bool success = false; - - std::tie(new_unit_itor, success) = resources::gameboard->units().insert(new_unit); + auto [new_unit_itor, success] = resources::gameboard->units().insert(new_unit); assert(success); if(resources::gameboard->map().is_village(loc)){ diff --git a/src/attack_prediction.cpp b/src/attack_prediction.cpp index 0a67e9aaa9b4..63693c9aabcd 100644 --- a/src/attack_prediction.cpp +++ b/src/attack_prediction.cpp @@ -875,8 +875,7 @@ void prob_matrix::clear() continue; } - decltype(used_rows_[p].begin()) first_row, last_row; - std::tie(first_row, last_row) = std::minmax_element(used_rows_[p].begin(), used_rows_[p].end()); + auto [first_row, last_row] = std::minmax_element(used_rows_[p].begin(), used_rows_[p].end()); for(unsigned int r = *first_row; r <= *last_row; ++r) { for(unsigned int c = 0u; c < cols_; ++c) { plane_[p][r * cols_ + c] = 0.0; diff --git a/src/formula/formula.cpp b/src/formula/formula.cpp index 99fd3eb28f29..7823fc2899ec 100644 --- a/src/formula/formula.cpp +++ b/src/formula/formula.cpp @@ -175,10 +175,7 @@ formula::formula(const std::string& text, function_symbol_table* symbols) std::string str = std::string(tokens.back().begin, tokens.back().end); files.emplace_back(str , 1); - std::set::iterator pos; - bool success; - - std::tie(pos, success) = filenames.insert(str); + auto [pos, success] = filenames.insert(str); if(success) { filenames_it = pos; diff --git a/src/game_events/wmi_manager.cpp b/src/game_events/wmi_manager.cpp index a547197b23f6..1beb3a8ea721 100644 --- a/src/game_events/wmi_manager.cpp +++ b/src/game_events/wmi_manager.cpp @@ -204,11 +204,8 @@ void wmi_manager::to_config(config& cfg) const */ void wmi_manager::set_item(const std::string& id, const vconfig& menu_item) { - auto iter = wml_menu_items_.begin(); - bool success; - // First, try to insert a brand new menu item. - std::tie(iter, success) = wml_menu_items_.emplace(id, std::make_shared(id, menu_item)); + auto [iter, success] = wml_menu_items_.emplace(id, std::make_shared(id, menu_item)); // If an entry already exists, reset it. if(!success) { diff --git a/src/gui/dialogs/attack_predictions.cpp b/src/gui/dialogs/attack_predictions.cpp index 6c06f1911a0c..8ca2c9acb988 100644 --- a/src/gui/dialogs/attack_predictions.cpp +++ b/src/gui/dialogs/attack_predictions.cpp @@ -298,8 +298,7 @@ void attack_predictions::draw_hp_graph(drawing& hp_graph, const combatant_data& for(const auto& probability : get_hitpoint_probabilities(attacker.combatant_.hp_dist)) { // Get the HP and probability. - int hp; double prob; - std::tie(hp, prob) = probability; + auto [hp, prob] = probability; color_t row_color; diff --git a/src/gui/dialogs/preferences_dialog.cpp b/src/gui/dialogs/preferences_dialog.cpp index c9bce89d5210..aaaf1e4a7738 100644 --- a/src/gui/dialogs/preferences_dialog.cpp +++ b/src/gui/dialogs/preferences_dialog.cpp @@ -242,10 +242,7 @@ void preferences_dialog::add_friend_list_entry(const bool is_friend, text_box& t username = username.substr(0, pos); } - acquaintance* entry = nullptr; - bool added_new; - - std::tie(entry, added_new) = add_acquaintance(username, (is_friend ? "friend": "ignore"), reason); + auto [entry, added_new] = add_acquaintance(username, (is_friend ? "friend": "ignore"), reason); if(!entry) { gui2::show_transient_message(_("Error"), _("Invalid username"), "", false, false, true); diff --git a/src/gui/widgets/settings.cpp b/src/gui/widgets/settings.cpp index 04969d7c6b55..400ce8aab485 100644 --- a/src/gui/widgets/settings.cpp +++ b/src/gui/widgets/settings.cpp @@ -56,8 +56,7 @@ void update_screen_size_variables() screen_width = rect.w; screen_height = rect.h; - float scalew, scaleh; - std::tie(scalew, scaleh) = vid.get_dpi_scale_factor(); + auto [scalew, scaleh] = vid.get_dpi_scale_factor(); float avgscale = (scalew + scaleh)/2; screen_pitch_microns = MICRONS_PER_INCH / (avgscale * MAGIC_DPI_MATCH_VIDEO); diff --git a/src/picture.cpp b/src/picture.cpp index 32ad96398422..78a842e6c18e 100644 --- a/src/picture.cpp +++ b/src/picture.cpp @@ -1018,10 +1018,7 @@ bool exists(const image::locator& i_locator) // The insertion will fail if there is already an element in the cache // and this will point to the existing element. - auto iter = image_existence_map.begin(); - bool success; - - std::tie(iter, success) = image_existence_map.emplace(i_locator.get_filename(), false); + auto [iter, success] = image_existence_map.emplace(i_locator.get_filename(), false); bool& cache = iter->second; if(success) { diff --git a/src/preferences/game.cpp b/src/preferences/game.cpp index 9ed886f24112..c9413089eb42 100644 --- a/src/preferences/game.cpp +++ b/src/preferences/game.cpp @@ -235,11 +235,7 @@ std::pair add_acquaintance( } preferences::acquaintance new_entry(nick, mode, notes); - - acquaintances_map::iterator iter; - bool success; - - std::tie(iter, success) = acquaintances.emplace(nick, new_entry); + auto [iter, success] = acquaintances.emplace(nick, new_entry); if(!success) { iter->second = new_entry; diff --git a/src/scripting/lua_unit.cpp b/src/scripting/lua_unit.cpp index f37c1cdb9d26..30cd84ecf21d 100644 --- a/src/scripting/lua_unit.cpp +++ b/src/scripting/lua_unit.cpp @@ -74,10 +74,7 @@ unit_ptr lua_unit::get_shared() const bool lua_unit::put_map(const map_location &loc) { if (ptr) { - unit_map::unit_iterator unit_it; - bool success = false; - - std::tie(unit_it, success) = resources::gameboard->units().replace(loc, ptr); + auto [unit_it, success] = resources::gameboard->units().replace(loc, ptr); if(success) { ptr.reset(); @@ -530,10 +527,7 @@ static int impl_unit_set(lua_State *L) return luaL_argerror(L, 2, err_msg.c_str()); } - unit_map::iterator unit_iterator = gb->units().end(); - bool success = false; - - std::tie(unit_iterator, success) = gb->units().move(src, dst); + auto [unit_iterator, success] = gb->units().move(src, dst); if(success) { unit_iterator->anim_comp().set_standing(); diff --git a/src/tests/test_formula_timespan.cpp b/src/tests/test_formula_timespan.cpp index 1d294276a1a8..9b3bf9222c07 100644 --- a/src/tests/test_formula_timespan.cpp +++ b/src/tests/test_formula_timespan.cpp @@ -52,16 +52,14 @@ typedef std::tuple< inline time_t gen_as_time_t(const time_detailed& params) { - time_t sec, min, hr, day, wk, mo, yr; - std::tie(sec, min, hr, day, wk, mo, yr) = params; + auto [sec, min, hr, day, wk, mo, yr] = params; return YEAR*yr + MONTH*mo + WEEK*wk + DAY*day + HOUR*hr + MIN*min + SEC*sec; } inline std::string gen_as_str(const time_detailed& params) { - time_t sec, min, hr, day, wk, mo, yr; - std::tie(sec, min, hr, day, wk, mo, yr) = params; + auto [sec, min, hr, day, wk, mo, yr] = params; std::vector bits; std::string res; diff --git a/src/video.cpp b/src/video.cpp index c631ff05a38f..6aaa07e3dc90 100644 --- a/src/video.cpp +++ b/src/video.cpp @@ -299,8 +299,7 @@ SDL_Rect CVideo::screen_area(bool as_pixels) const // Then convert the dimensions into screen coordinates, if applicable. if(!as_pixels) { - float scale_x, scale_y; - std::tie(scale_x, scale_y) = get_dpi_scale_factor(); + auto [scale_x, scale_y] = get_dpi_scale_factor(); size.x /= scale_x; size.y /= scale_y; @@ -464,8 +463,7 @@ std::vector CVideo::get_available_resolutions(const bool include_current) #if 0 // DPI scale factor. - float scale_h, scale_v; - std::tie(scale_h, scale_v) = get_dpi_scale_factor(); + auto [scale_h, scale_v] = get_dpi_scale_factor(); #endif // The maximum size to which this window can be set. For some reason this won't