Replaced std::make_pair with just std::pair

This commit is contained in:
Charles Dang 2021-01-19 18:47:39 +11:00
parent 5cc08cb34a
commit 9de9c2195b
26 changed files with 48 additions and 48 deletions

View File

@ -183,7 +183,7 @@ bool check_case_insensitive_duplicates_internal(const config& dir, const std::st
const config::attribute_value &filename = path["name"];
const std::string lowercase = boost::algorithm::to_lower_copy(filename.str(), std::locale::classic());
const std::string with_prefix = prefix + filename.str();
std::tie(std::ignore, inserted) = filenames.emplace(lowercase, std::make_pair(false, with_prefix));
std::tie(std::ignore, inserted) = filenames.emplace(lowercase, std::pair(false, with_prefix));
if (!inserted){
if(badlist){
std::tie(printed, original) = filenames[lowercase];
@ -201,7 +201,7 @@ bool check_case_insensitive_duplicates_internal(const config& dir, const std::st
const config::attribute_value &filename = path["name"];
const std::string lowercase = boost::algorithm::to_lower_copy(filename.str(), std::locale::classic());
const std::string with_prefix = prefix + filename.str();
std::tie(std::ignore, inserted) = filenames.emplace(lowercase, std::make_pair(false, with_prefix));
std::tie(std::ignore, inserted) = filenames.emplace(lowercase, std::pair(false, with_prefix));
if (!inserted) {
if(badlist){
std::tie(printed, original) = filenames[lowercase];

View File

@ -125,7 +125,7 @@ void attack_analysis::analyze(const gamemap& map, unit_map& units,
// This cache is only about 99% correct, but speeds up evaluation by about 1000 times.
// We recalculate when we actually attack.
const readonly_context::unit_stats_cache_t::key_type cache_key = std::make_pair(target, &up->type());
const readonly_context::unit_stats_cache_t::key_type cache_key = std::pair(target, &up->type());
const readonly_context::unit_stats_cache_t::iterator usc = ai_obj.unit_stats_cache().find(cache_key);
// Just check this attack is valid for this attacking unit (may be modified)
if (usc != ai_obj.unit_stats_cache().end() &&
@ -146,7 +146,7 @@ void attack_analysis::analyze(const gamemap& map, unit_map& units,
old_bc.reset(nullptr);
if ( !from_cache ) {
ai_obj.unit_stats_cache().emplace(cache_key, std::make_pair(
ai_obj.unit_stats_cache().emplace(cache_key, std::pair(
bc->get_attacker_stats(),
bc->get_defender_stats()
));

View File

@ -270,7 +270,7 @@ std::pair<map_location,map_location> move_to_targets_phase::choose_move(std::vec
if (!(u->side() != get_side() || (u->can_recruit() && !is_keep_ignoring_leader(u->id())) || u->movement_left() <= 0 || u->incapacitated())) {
if (u->get_state("guardian")) {
LOG_AI << u->type_id() << " is guardian, staying still\n";
return std::make_pair(u->get_location(), u->get_location());
return std::pair(u->get_location(), u->get_location());
}
}
}
@ -363,7 +363,7 @@ std::pair<map_location,map_location> move_to_targets_phase::choose_move(std::vec
if(best_rated_target == rated_targets.end()) {
LOG_AI << "no eligible targets found for unit at " << u->get_location() << std::endl;
return std::make_pair(u->get_location(), u->get_location());
return std::pair(u->get_location(), u->get_location());
}
assert(best_rating >= 0);
@ -446,7 +446,7 @@ std::pair<map_location,map_location> move_to_targets_phase::choose_move(std::vec
}
LOG_AI << "returning support...\n";
return std::make_pair(best->get_location(), best_loc);
return std::pair(best->get_location(), best_loc);
}
}
@ -503,7 +503,7 @@ std::pair<map_location,map_location> move_to_targets_phase::choose_move(std::vec
LOG_AI << "group didn't move " << group.size() << "\n";
//the group didn't move, so end the first unit in the group's turn, to prevent an infinite loop
return std::make_pair(best->get_location(), best->get_location());
return std::pair(best->get_location(), best->get_location());
}
} else {
@ -604,7 +604,7 @@ std::pair<map_location,map_location> move_to_targets_phase::choose_move(std::vec
//create this as a target, attempting to rally units around
targets.emplace_back(best->get_location(), best_target->value);
best_target = targets.end() - 1;
return std::make_pair(best->get_location(), best->get_location());
return std::pair(best->get_location(), best->get_location());
}
LOG_AI << "Could not find anywhere to move!\n";

View File

@ -1040,7 +1040,7 @@ namespace {
}
}
return std::make_pair(highest_melee_damage, highest_ranged_damage);
return std::pair(highest_melee_damage, highest_ranged_damage);
}
}

View File

@ -569,7 +569,7 @@ void commandline_options::parse_resolution_ ( const std::string& resolution_stri
throw bad_commandline_resolution(resolution_string);
}
resolution = std::make_pair(xres, yres);
resolution = std::pair(xres, yres);
}
std::vector<std::pair<unsigned int,std::string>> commandline_options::parse_to_uint_string_tuples_(const std::vector<std::string> &strings, char separator)

View File

@ -123,7 +123,7 @@ void editor_controller::init_tods(const game_config_view& game_config)
tods_map::iterator times = tods_.find(schedule_id);
if (times == tods_.end()) {
std::pair<tods_map::iterator, bool> new_times =
tods_.emplace(schedule_id, std::make_pair(schedule_name, std::vector<time_of_day>()));
tods_.emplace(schedule_id, std::pair(schedule_name, std::vector<time_of_day>()));
times = new_times.first;
} else {

View File

@ -116,11 +116,11 @@ typedef std::pair<int64_t, std::ios_base::seekdir> offset_dir;
static offset_dir translate_seekdir(int64_t offset, int whence) {
switch(whence){
case RW_SEEK_SET:
return std::make_pair(std::max<int64_t>(0, offset), std::ios_base::beg);
return std::pair(std::max<int64_t>(0, offset), std::ios_base::beg);
case RW_SEEK_CUR:
return std::make_pair(offset, std::ios_base::cur);
return std::pair(offset, std::ios_base::cur);
case RW_SEEK_END:
return std::make_pair(std::min<int64_t>(0, offset), std::ios_base::end);
return std::pair(std::min<int64_t>(0, offset), std::ios_base::end);
default:
assert(false);
throw "assertion ignored";

View File

@ -30,7 +30,7 @@ namespace implementation
placer_horizontal_list::placer_horizontal_list(const unsigned maximum_rows)
: maximum_rows_(maximum_rows)
, rows_(maximum_rows, 0)
, columns_(1, std::make_pair(0, 0))
, columns_(1, std::pair(0, 0))
, row_(0)
, column_(0)
{

View File

@ -29,7 +29,7 @@ namespace implementation
placer_vertical_list::placer_vertical_list(const unsigned maximum_columns)
: maximum_columns_(maximum_columns)
, rows_(1, std::make_pair(0, 0))
, rows_(1, std::pair(0, 0))
, columns_(maximum_columns, 0)
, row_(0)
, column_(0)

View File

@ -277,7 +277,7 @@ public:
LOG_CHAT_LOG << "First " << first << ", last " << last << '\n';
return std::make_pair(first, last);
return std::pair(first, last);
}
void update_view_from_model(bool select_last_page = false)

View File

@ -385,7 +385,7 @@ void addon_list::finalize_setup()
list.register_sorting_option(3, [this](const int i) { return addon_vector_[i]->downloads; });
list.register_translatable_sorting_option(4, [this](const int i) { return addon_vector_[i]->display_type(); });
auto order = std::make_pair(0, preferences::SORT_ORDER::ASCENDING);
auto order = std::pair(0, preferences::SORT_ORDER::ASCENDING);
list.set_active_sorting_option(order);
}

View File

@ -666,11 +666,11 @@ const listbox::order_pair listbox::get_active_sorting_option()
selectable_item* w = orders_[column].first;
if(w && w->get_value() != SORT_ORDER::NONE) {
return std::make_pair(column, static_cast<SORT_ORDER::type>(w->get_value()));
return std::pair(column, static_cast<SORT_ORDER::type>(w->get_value()));
}
}
return std::make_pair(-1, SORT_ORDER::NONE);
return std::pair(-1, SORT_ORDER::NONE);
}
void listbox::mark_as_unsorted()

View File

@ -82,7 +82,7 @@ std::pair<tree_view_node::ptr_t, int> tree_view::remove_node(tree_view_node* nod
resize_content(0, -node_size.y);
}
return std::make_pair(std::move(old_node), position);
return std::pair(std::move(old_node), position);
}
void tree_view::clear()

View File

@ -370,7 +370,7 @@ void gamemap::set_special_location(const std::string& id, const map_location& lo
}
}
else {
starting_positions_.left.insert(it_left, std::make_pair(id, loc));
starting_positions_.left.insert(it_left, std::pair(id, loc));
}
}

View File

@ -882,7 +882,7 @@ full_cost_map::full_cost_map(const unit& u, bool force_ignore_zoc,
viewing_team_(viewing_team), see_all_(see_all), ignore_units_(ignore_units)
{
const gamemap& map = resources::gameboard->map();
cost_map = std::vector<std::pair<int, int>>(map.w() * map.h(), std::make_pair(-1, 0));
cost_map = std::vector<std::pair<int, int>>(map.w() * map.h(), std::pair(-1, 0));
add_unit(u);
}
@ -897,7 +897,7 @@ full_cost_map::full_cost_map(bool force_ignore_zoc,
viewing_team_(viewing_team), see_all_(see_all), ignore_units_(ignore_units)
{
const gamemap& map = resources::gameboard->map();
cost_map = std::vector<std::pair<int, int>>(map.w() * map.h(), std::make_pair(-1, 0));
cost_map = std::vector<std::pair<int, int>>(map.w() * map.h(), std::pair(-1, 0));
}
/**
@ -962,7 +962,7 @@ std::pair<int, int> full_cost_map::get_pair_at(map_location loc) const
assert(cost_map.size() == static_cast<unsigned>(map.w() * map.h()));
if (!map.on_board(loc)) {
return std::make_pair(-1, 0); // invalid
return std::pair(-1, 0); // invalid
}
return cost_map[loc.x + (loc.y * map.w())];

View File

@ -231,7 +231,7 @@ std::pair<preferences::acquaintance*, bool> add_acquaintance(
const std::string& nick, const std::string& mode, const std::string& notes)
{
if(!utils::isvalid_wildcard(nick)) {
return std::make_pair(nullptr, false);
return std::pair(nullptr, false);
}
preferences::acquaintance new_entry(nick, mode, notes);
@ -243,7 +243,7 @@ std::pair<preferences::acquaintance*, bool> add_acquaintance(
save_acquaintances();
return std::make_pair(&iter->second, success);
return std::pair(&iter->second, success);
}
bool remove_acquaintance(const std::string& nick)

View File

@ -174,7 +174,7 @@ void mapgen_gamemap::set_special_location(const std::string& id, const map_locat
}
}
else {
starting_positions_.left.insert(it_left, std::make_pair(id, loc));
starting_positions_.left.insert(it_left, std::pair(id, loc));
}
}

View File

@ -815,9 +815,9 @@ std::pair<int, int> parse_range(const std::string& str)
std::pair<int,int> res {0,0};
try {
if (b == "infinity") {
res = std::make_pair(std::stoi(a), std::numeric_limits<int>::max());
res = std::pair(std::stoi(a), std::numeric_limits<int>::max());
} else {
res = std::make_pair(std::stoi(a), std::stoi(b));
res = std::pair(std::stoi(a), std::stoi(b));
}
if (res.second < res.first) {

View File

@ -33,7 +33,7 @@ namespace ucs4
iterator_base(const string_type& str)
: current_char(0)
, string_end(str.end())
, current_substr(std::make_pair(str.begin(), str.begin()))
, current_substr(std::pair(str.begin(), str.begin()))
{
update();
}
@ -41,7 +41,7 @@ namespace ucs4
iterator_base(typename string_type::const_iterator const& begin, typename string_type::const_iterator const& end)
: current_char(0)
, string_end(end)
, current_substr(std::make_pair(begin, begin))
, current_substr(std::pair(begin, begin))
{
update();
}

View File

@ -130,7 +130,7 @@ static void write_str_int_map(config_writer &out, const stats::str_int_map& m)
m.begin(), m.end(),
std::inserter(rev, rev.begin()),
[](const stats::str_int_map::value_type p) {
return std::make_pair(p.second, p.first);
return std::pair(p.second, p.first);
}
);
reverse_map::const_iterator i = rev.begin(), j;

View File

@ -330,7 +330,7 @@ void user_choice_manager::update_local_choice()
"waiting for $desc from side $sides",
"waiting for $desc from sides $sides",
sides_str.size(),
{std::make_pair("desc", uch_.description()), std::make_pair("sides", utils::format_conjunct_list("", sides_str))}
{std::pair("desc", uch_.description()), std::pair("sides", utils::format_conjunct_list("", sides_str))}
);
if(local_choice_prev != local_choice_) {
changed_event_.notify_observers();

View File

@ -99,5 +99,5 @@ struct tracer
*/
#define TRACER_COUNT(marker) \
do { \
++tracer.counters[std::make_pair(__LINE__, marker)]; \
++tracer.counters[std::pair(__LINE__, marker)]; \
} while(false)

View File

@ -550,7 +550,7 @@ template<typename TComp>
std::pair<int,map_location> unit_ability_list::get_extremum(const std::string& key, int def, const TComp& comp) const
{
if ( cfgs_.empty() ) {
return std::make_pair(def, map_location());
return std::pair(def, map_location());
}
// The returned location is the best non-cumulative one, if any,
// the best absolute cumulative one otherwise.
@ -578,7 +578,7 @@ std::pair<int,map_location> unit_ability_list::get_extremum(const std::string& k
best_loc = p.teacher_loc;
}
}
return std::make_pair(flat + stack, best_loc);
return std::pair(flat + stack, best_loc);
}
template std::pair<int, map_location> unit_ability_list::get_extremum<std::less<int>>(const std::string& key, int def, const std::less<int>& comp) const;

View File

@ -97,19 +97,19 @@ unit_map::umap_retval_pair_t unit_map::move(const map_location& src, const map_l
// Find the unit at the src location
lmap::iterator i = lmap_.find(src);
if(i == lmap_.end()) {
return std::make_pair(make_unit_iterator(i), false);
return std::pair(make_unit_iterator(i), false);
}
umap::iterator uit(i->second);
if(src == dst) {
return std::make_pair(make_unit_iterator(uit), true);
return std::pair(make_unit_iterator(uit), true);
}
// Fail if there is no unit to move.
unit_ptr p = uit->second.unit;
if(!p) {
return std::make_pair(make_unit_iterator(uit), false);
return std::pair(make_unit_iterator(uit), false);
}
p->set_location(dst);
@ -122,12 +122,12 @@ unit_map::umap_retval_pair_t unit_map::move(const map_location& src, const map_l
if(res.second == false) {
p->set_location(src);
lmap_.emplace(src, uit);
return std::make_pair(make_unit_iterator(uit), false);
return std::pair(make_unit_iterator(uit), false);
}
self_check();
return std::make_pair(make_unit_iterator(uit), true);
return std::pair(make_unit_iterator(uit), true);
}
unit_map::umap_retval_pair_t unit_map::insert(unit_ptr p)
@ -144,7 +144,7 @@ unit_map::umap_retval_pair_t unit_map::insert(unit_ptr p)
if(!loc.valid()) {
ERR_NG << "Trying to add " << p->name() << " - " << p->id() << " at an invalid location; Discarding.\n";
return std::make_pair(make_unit_iterator(umap_.end()), false);
return std::pair(make_unit_iterator(umap_.end()), false);
}
unit_pod upod;
@ -213,11 +213,11 @@ unit_map::umap_retval_pair_t unit_map::insert(unit_ptr p)
<< (linsert.first->second->second).unit->name() << " - " << linsert.first->second->second.unit->id()
<< "\n";
return std::make_pair(make_unit_iterator(umap_.end()), false);
return std::pair(make_unit_iterator(umap_.end()), false);
}
self_check();
return std::make_pair(make_unit_iterator(uinsert.first), true);
return std::pair(make_unit_iterator(uinsert.first), true);
}
unit_map::umap_retval_pair_t unit_map::replace(const map_location& l, unit_ptr p)

View File

@ -139,7 +139,7 @@ int path_cost(const std::vector<map_location>& path, const unit& u)
int result = 0;
const gamemap& map = resources::gameboard->map();
for(const map_location& loc : std::make_pair(path.begin()+1,path.end())) {
for(const map_location& loc : std::pair(path.begin()+1,path.end())) {
result += u.movement_cost(map[loc]);
}
return result;

View File

@ -109,7 +109,7 @@ static std::pair<int, int> parse_fraction(const std::string& s)
parts.resize(2);
int num = lexical_cast_default<int>(parts[0], 0);
int denom = lexical_cast_default<int>(parts[1], 0);
return std::make_pair(num, denom);
return std::pair(num, denom);
}
static int xp_to_advance(const std::string& s) {