diff --git a/src/animated_tile.cpp b/src/animated_tile.cpp index e200788ad5..86884d6ff9 100644 --- a/src/animated_tile.cpp +++ b/src/animated_tile.cpp @@ -24,7 +24,7 @@ std::vector _animated_tiles; */ void DeleteAnimatedTile(TileIndex tile) { - auto to_remove = std::find(_animated_tiles.begin(), _animated_tiles.end(), tile); + auto to_remove = std::ranges::find(_animated_tiles, tile); if (to_remove != _animated_tiles.end()) { /* The order of the remaining elements must stay the same, otherwise the animation loop may miss a tile. */ _animated_tiles.erase(to_remove); diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index 94ba5c6ae7..b2512edec0 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -167,7 +167,7 @@ class ReplaceVehicleWindow : public Window { if (side == 1) { /* ensure primary engine of variant group is in list */ for (const auto &variant : variants) { - if (std::find(list.begin(), list.end(), variant) == list.end()) { + if (std::ranges::find(list, variant, &GUIEngineListItem::engine_id) == list.end()) { const Engine *e = Engine::Get(variant); list.emplace_back(variant, e->info.variant_id, e->display_flags | EngineDisplayFlags::Shaded, 0); } diff --git a/src/core/container_func.hpp b/src/core/container_func.hpp index 5a713649aa..b0128229c0 100644 --- a/src/core/container_func.hpp +++ b/src/core/container_func.hpp @@ -23,7 +23,7 @@ template inline bool include(Container &container, typename Container::const_reference &item) { - const bool is_member = std::find(container.begin(), container.end(), item) != container.end(); + const bool is_member = std::ranges::find(container, item) != container.end(); if (!is_member) container.emplace_back(item); return is_member; } @@ -40,7 +40,7 @@ inline bool include(Container &container, typename Container::const_reference &i template int find_index(Container const &container, typename Container::const_reference item) { - auto const it = std::find(container.begin(), container.end(), item); + auto const it = std::ranges::find(container, item); if (it != container.end()) return std::distance(container.begin(), it); return -1; diff --git a/src/core/pool_func.cpp b/src/core/pool_func.cpp index e59a2de447..8bf7c91d79 100644 --- a/src/core/pool_func.cpp +++ b/src/core/pool_func.cpp @@ -19,7 +19,7 @@ /* virtual */ PoolBase::~PoolBase() { PoolVector *pools = PoolBase::GetPools(); - pools->erase(std::find(pools->begin(), pools->end(), this)); + pools->erase(std::ranges::find(*pools, this)); if (pools->empty()) delete pools; } diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp index 2d41f43255..476b92f8fe 100644 --- a/src/hotkeys.cpp +++ b/src/hotkeys.cpp @@ -267,7 +267,7 @@ HotkeyList::HotkeyList(const std::string &ini_group, const std::vector & HotkeyList::~HotkeyList() { - _hotkey_lists->erase(std::find(_hotkey_lists->begin(), _hotkey_lists->end(), this)); + _hotkey_lists->erase(std::ranges::find(*_hotkey_lists, this)); } /** diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp index 2c8dd8bf69..e3f7d197b2 100644 --- a/src/industry_cmd.cpp +++ b/src/industry_cmd.cpp @@ -424,10 +424,10 @@ static void AddAcceptedCargo_Industry(TileIndex tile, CargoArray &acceptance, Ca if (itspec->special_flags & INDTILE_SPECIAL_ACCEPTS_ALL_CARGO) { /* Copy all accepted cargoes from industry itself */ for (const auto &a : ind->accepted) { - auto pos = std::find(std::begin(accepts_cargo), std::end(accepts_cargo), a.cargo); + auto pos = std::ranges::find(accepts_cargo, a.cargo); if (pos == std::end(accepts_cargo)) { /* Not found, insert */ - pos = std::find(std::begin(accepts_cargo), std::end(accepts_cargo), INVALID_CARGO); + pos = std::ranges::find(accepts_cargo, INVALID_CARGO); if (pos == std::end(accepts_cargo)) continue; // nowhere to place, give up on this one *pos = a.cargo; } @@ -1879,7 +1879,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, continue; } /* Verify valid cargo */ - if (std::find(std::begin(indspec->accepts_cargo), std::end(indspec->accepts_cargo), cargo) == std::end(indspec->accepts_cargo)) { + if (std::ranges::find(indspec->accepts_cargo, cargo) == std::end(indspec->accepts_cargo)) { /* Cargo not in spec, error in NewGRF */ ErrorUnknownCallbackResult(indspec->grf_prop.grffile->grfid, CBID_INDUSTRY_INPUT_CARGO_TYPES, res); break; @@ -1915,7 +1915,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type, continue; } /* Verify valid cargo */ - if (std::find(std::begin(indspec->produced_cargo), std::end(indspec->produced_cargo), cargo) == std::end(indspec->produced_cargo)) { + if (std::ranges::find(indspec->produced_cargo, cargo) == std::end(indspec->produced_cargo)) { /* Cargo not in spec, error in NewGRF */ ErrorUnknownCallbackResult(indspec->grf_prop.grffile->grfid, CBID_INDUSTRY_OUTPUT_CARGO_TYPES, res); break; diff --git a/src/ini_load.cpp b/src/ini_load.cpp index b20d3ffa13..92a7f3284c 100644 --- a/src/ini_load.cpp +++ b/src/ini_load.cpp @@ -162,8 +162,8 @@ IniGroup &IniLoadFile::GetOrCreateGroup(std::string_view name) IniGroup &IniLoadFile::CreateGroup(std::string_view name) { IniGroupType type = IGT_VARIABLES; - if (std::find(this->list_group_names.begin(), this->list_group_names.end(), name) != this->list_group_names.end()) type = IGT_LIST; - if (std::find(this->seq_group_names.begin(), this->seq_group_names.end(), name) != this->seq_group_names.end()) type = IGT_SEQUENCE; + if (std::ranges::find(this->list_group_names, name) != this->list_group_names.end()) type = IGT_LIST; + if (std::ranges::find(this->seq_group_names, name) != this->seq_group_names.end()) type = IGT_SEQUENCE; return this->groups.emplace_back(name, type); } diff --git a/src/misc/binaryheap.hpp b/src/misc/binaryheap.hpp index 377d4d9548..b9a35d6bf1 100644 --- a/src/misc/binaryheap.hpp +++ b/src/misc/binaryheap.hpp @@ -262,7 +262,7 @@ public: */ inline size_t FindIndex(const T &item) const { - auto it = std::find(this->data.begin(), this->data.end(), &item); + auto it = std::ranges::find(this->data, &item); return it == this->data.end() ? 0 : std::distance(this->data.begin(), it); } diff --git a/src/network/network_command.cpp b/src/network/network_command.cpp index 3007852001..3c1f8e5e05 100644 --- a/src/network/network_command.cpp +++ b/src/network/network_command.cpp @@ -178,8 +178,8 @@ static CommandQueue _local_execution_queue; */ static size_t FindCallbackIndex(CommandCallback *callback) { - if (auto it = std::find(std::cbegin(_callback_table), std::cend(_callback_table), callback); it != std::cend(_callback_table)) { - return static_cast(std::distance(std::cbegin(_callback_table), it)); + if (auto it = std::ranges::find(_callback_table, callback); it != std::end(_callback_table)) { + return static_cast(std::distance(std::begin(_callback_table), it)); } return std::numeric_limits::max(); diff --git a/src/network/network_content.cpp b/src/network/network_content.cpp index 5bb5857027..560824e8b2 100644 --- a/src/network/network_content.cpp +++ b/src/network/network_content.cpp @@ -838,7 +838,7 @@ void ClientNetworkContentSocketHandler::SendReceive() void ClientNetworkContentSocketHandler::DownloadContentInfo(ContentID cid) { /* When we tried to download it already, don't try again */ - if (std::find(this->requested.begin(), this->requested.end(), cid) != this->requested.end()) return; + if (std::ranges::find(this->requested, cid) != this->requested.end()) return; this->requested.push_back(cid); this->RequestContentList(1, &cid); diff --git a/src/network/network_content.h b/src/network/network_content.h index edfa0783c6..1bb1898d09 100644 --- a/src/network/network_content.h +++ b/src/network/network_content.h @@ -146,7 +146,7 @@ public: /** Add a callback to this class */ void AddCallback(ContentCallback *cb) { include(this->callbacks, cb); } /** Remove a callback */ - void RemoveCallback(ContentCallback *cb) { this->callbacks.erase(std::find(this->callbacks.begin(), this->callbacks.end(), cb)); } + void RemoveCallback(ContentCallback *cb) { this->callbacks.erase(std::ranges::find(this->callbacks, cb)); } }; extern ClientNetworkContentSocketHandler _network_content_client; diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index 6a37ce0bcf..73713c9cce 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -45,7 +45,7 @@ const SpriteGroup *GetWagonOverrideSpriteSet(EngineID engine, CargoID cargo, Eng for (const WagonOverride &wo : e->overrides) { if (wo.cargo != cargo && wo.cargo != SpriteGroupCargo::SG_DEFAULT) continue; - if (std::find(wo.engines.begin(), wo.engines.end(), overriding_engine) != wo.engines.end()) return wo.group; + if (std::ranges::find(wo.engines, overriding_engine) != wo.engines.end()) return wo.group; } return nullptr; } diff --git a/src/pathfinder/water_regions.cpp b/src/pathfinder/water_regions.cpp index 4ed8cc02e1..ab02cfe129 100644 --- a/src/pathfinder/water_regions.cpp +++ b/src/pathfinder/water_regions.cpp @@ -373,7 +373,7 @@ static inline void VisitAdjacentWaterRegionPatchNeighbors(const WaterRegionPatch const TileIndex neighbor_edge_tile = GetEdgeTileCoordinate(nx, ny, opposite_side, x_or_y); const TWaterRegionPatchLabel neighbor_label = neighboring_region.GetLabel(neighbor_edge_tile); assert(neighbor_label != INVALID_WATER_REGION_PATCH); - if (std::find(unique_labels.begin(), unique_labels.end(), neighbor_label) == unique_labels.end()) unique_labels.push_back(neighbor_label); + if (std::ranges::find(unique_labels, neighbor_label) == unique_labels.end()) unique_labels.push_back(neighbor_label); } for (TWaterRegionPatchLabel unique_label : unique_labels) func(WaterRegionPatchDesc{ nx, ny, unique_label }); } diff --git a/src/pathfinder/yapf/yapf_ship.cpp b/src/pathfinder/yapf/yapf_ship.cpp index c2dde7eb55..8b0c04bffb 100644 --- a/src/pathfinder/yapf/yapf_ship.cpp +++ b/src/pathfinder/yapf/yapf_ship.cpp @@ -151,8 +151,7 @@ public: TrackFollower F(Yapf().GetVehicle()); if (F.Follow(old_node.key.tile, old_node.key.td)) { if (this->water_region_corridor.empty() - || std::find(this->water_region_corridor.begin(), this->water_region_corridor.end(), - GetWaterRegionInfo(F.new_tile)) != this->water_region_corridor.end()) { + || std::ranges::find(this->water_region_corridor, GetWaterRegionInfo(F.new_tile)) != this->water_region_corridor.end()) { Yapf().AddMultipleNodes(&old_node, F); } } @@ -255,7 +254,7 @@ public: while (node->parent) { const WaterRegionPatchDesc node_water_patch = GetWaterRegionPatchInfo(node->GetTile()); - const bool node_water_patch_on_high_level_path = std::find(high_level_path.begin(), high_level_path.end(), node_water_patch) != high_level_path.end(); + const bool node_water_patch_on_high_level_path = std::ranges::find(high_level_path, node_water_patch) != high_level_path.end(); const bool add_full_path = !is_intermediate_destination && node_water_patch != end_water_patch; /* The cached path must always lead to a region patch that's on the high level path. diff --git a/src/pathfinder/yapf/yapf_ship_regions.cpp b/src/pathfinder/yapf/yapf_ship_regions.cpp index d1674556b7..fa96143585 100644 --- a/src/pathfinder/yapf/yapf_ship_regions.cpp +++ b/src/pathfinder/yapf/yapf_ship_regions.cpp @@ -95,7 +95,7 @@ public: bool HasOrigin(const WaterRegionPatchDesc &water_region_patch) { - return std::find(this->origin_keys.begin(), this->origin_keys.end(), CYapfRegionPatchNodeKey{ water_region_patch }) != this->origin_keys.end(); + return std::ranges::find(this->origin_keys, CYapfRegionPatchNodeKey{ water_region_patch }) != this->origin_keys.end(); } void PfSetStartupNodes() diff --git a/src/picker_gui.cpp b/src/picker_gui.cpp index 4f56485952..c4f4049a45 100644 --- a/src/picker_gui.cpp +++ b/src/picker_gui.cpp @@ -49,7 +49,7 @@ PickerCallbacks::PickerCallbacks(const std::string &ini_group) : ini_group(ini_g PickerCallbacks::~PickerCallbacks() { auto &callbacks = GetPickerCallbacks(); - callbacks.erase(std::find(callbacks.begin(), callbacks.end(), this)); + callbacks.erase(std::ranges::find(callbacks, this)); } /** @@ -500,7 +500,7 @@ void PickerWindow::EnsureSelectedClassIsVisible() if (!this->has_class_picker) return; if (this->classes.empty()) return; - auto it = std::find(std::begin(this->classes), std::end(this->classes), this->callbacks.GetSelectedClass()); + auto it = std::ranges::find(this->classes, this->callbacks.GetSelectedClass()); if (it == std::end(this->classes)) return; int pos = static_cast(std::distance(std::begin(this->classes), it)); diff --git a/src/rail.cpp b/src/rail.cpp index 4419f852fe..55f55fb0f4 100644 --- a/src/rail.cpp +++ b/src/rail.cpp @@ -322,7 +322,7 @@ RailType GetRailTypeByLabel(RailTypeLabel label, bool allow_alternate_labels) /* Test if any rail type defines the label as an alternate. */ for (RailType r = RAILTYPE_BEGIN; r != RAILTYPE_END; r++) { const RailTypeInfo *rti = GetRailTypeInfo(r); - if (std::find(rti->alternate_labels.begin(), rti->alternate_labels.end(), label) != rti->alternate_labels.end()) return r; + if (std::ranges::find(rti->alternate_labels, label) != rti->alternate_labels.end()) return r; } } diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index d64b8b54f2..6ddc3e4a42 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -490,7 +490,7 @@ struct BuildRailToolbarWindow : Window { bool can_build = CanBuildVehicleInfrastructure(VEH_TRAIN); if (can_build) return false; - if (std::find(std::begin(can_build_widgets), std::end(can_build_widgets), widget) == std::end(can_build_widgets)) return false; + if (std::ranges::find(can_build_widgets, widget) == std::end(can_build_widgets)) return false; GuiShowTooltips(this, STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE, close_cond); return true; diff --git a/src/road.cpp b/src/road.cpp index f66bedfd65..0ac5556c93 100644 --- a/src/road.cpp +++ b/src/road.cpp @@ -265,7 +265,7 @@ RoadType GetRoadTypeByLabel(RoadTypeLabel label, bool allow_alternate_labels) /* Test if any road type defines the label as an alternate. */ for (RoadType r = ROADTYPE_BEGIN; r != ROADTYPE_END; r++) { const RoadTypeInfo *rti = GetRoadTypeInfo(r); - if (std::find(rti->alternate_labels.begin(), rti->alternate_labels.end(), label) != rti->alternate_labels.end()) return r; + if (std::ranges::find(rti->alternate_labels, label) != rti->alternate_labels.end()) return r; } } diff --git a/src/script/api/script_text.cpp b/src/script/api/script_text.cpp index 7c2a2c93ae..9ec7b09e6b 100644 --- a/src/script/api/script_text.cpp +++ b/src/script/api/script_text.cpp @@ -168,7 +168,7 @@ std::string ScriptText::GetEncodedText() void ScriptText::_FillParamList(ParamList ¶ms, ScriptTextList &seen_texts) { - if (std::find(seen_texts.begin(), seen_texts.end(), this) != seen_texts.end()) throw Script_FatalError(fmt::format("{}: Circular reference detected", GetGameStringName(this->string))); + if (std::ranges::find(seen_texts, this) != seen_texts.end()) throw Script_FatalError(fmt::format("{}: Circular reference detected", GetGameStringName(this->string))); seen_texts.push_back(this); for (int i = 0; i < this->paramc; i++) { diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 3ead59aa20..5d8ca16c54 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -86,7 +86,7 @@ static const void *ResolveObject(const GameSettings *settings_ptr, const IntSett */ static uint GetCurrentResolutionIndex() { - auto it = std::find(_resolutions.begin(), _resolutions.end(), Dimension(_screen.width, _screen.height)); + auto it = std::ranges::find(_resolutions, Dimension(_screen.width, _screen.height)); return std::distance(_resolutions.begin(), it); } diff --git a/src/settingsgen/settingsgen.cpp b/src/settingsgen/settingsgen.cpp index e0b05fcc06..5e20d2080b 100644 --- a/src/settingsgen/settingsgen.cpp +++ b/src/settingsgen/settingsgen.cpp @@ -301,7 +301,7 @@ static void DumpSections(const IniLoadFile &ifile) /* Output every group, using its name as template name. */ for (const IniGroup &grp : ifile.groups) { /* Exclude special group names. */ - if (std::find(std::begin(special_group_names), std::end(special_group_names), grp.name) != std::end(special_group_names)) continue; + if (std::ranges::find(special_group_names, grp.name) != std::end(special_group_names)) continue; const IniItem *template_item = templates_grp->GetItem(grp.name); // Find template value. if (template_item == nullptr || !template_item->value.has_value()) { diff --git a/src/station_gui.cpp b/src/station_gui.cpp index ad2fc18ad2..30238c319a 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -2218,7 +2218,7 @@ static bool AddNearbyStation(TileIndex tile, void *user_data) if (!T::IsValidID(sid)) return false; BaseStation *st = BaseStation::Get(sid); - if (st->owner != _local_company || std::find(_stations_nearby_list.begin(), _stations_nearby_list.end(), sid) != _stations_nearby_list.end()) return false; + if (st->owner != _local_company || std::ranges::find(_stations_nearby_list, sid) != _stations_nearby_list.end()) return false; if (st->rect.BeforeAddRect(ctx->tile, ctx->w, ctx->h, StationRect::ADD_TEST).Succeeded()) { _stations_nearby_list.push_back(sid); diff --git a/src/train_gui.cpp b/src/train_gui.cpp index 16328bf224..ba4daea0c6 100644 --- a/src/train_gui.cpp +++ b/src/train_gui.cpp @@ -287,7 +287,7 @@ static void GetCargoSummaryOfArticulatedVehicle(const Train *v, CargoSummary &su new_item.subtype = GetCargoSubtypeText(v); if (!IsValidCargoID(new_item.cargo) && new_item.subtype == STR_EMPTY) continue; - auto item = std::find(std::begin(summary), std::end(summary), new_item); + auto item = std::ranges::find(summary, new_item); if (item == std::end(summary)) { item = summary.emplace(std::end(summary)); item->cargo = new_item.cargo; diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index c44fa6a528..afccfd9faa 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -379,7 +379,7 @@ static std::tuple RefitVehicle(Vehicle /* Reset actual_subtype for every new vehicle */ if (!v->IsArticulatedPart()) actual_subtype = new_subtype; - if (v->type == VEH_TRAIN && std::find(vehicles_to_refit.begin(), vehicles_to_refit.end(), v->index) == vehicles_to_refit.end() && !only_this) continue; + if (v->type == VEH_TRAIN && std::ranges::find(vehicles_to_refit, v->index) == vehicles_to_refit.end() && !only_this) continue; const Engine *e = v->GetEngine(); if (!e->CanCarryCargo()) continue; diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 19da5a9855..4504321b8f 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -443,7 +443,7 @@ void BaseVehicleListWindow::FilterVehicleList() if (this->vehicles.empty()) { /* No vehicle passed through the filter, invalidate the previously selected vehicle */ this->vehicle_sel = INVALID_VEHICLE; - } else if (this->vehicle_sel != INVALID_VEHICLE && std::find(this->vehicles.begin(), this->vehicles.end(), Vehicle::Get(this->vehicle_sel)) == this->vehicles.end()) { // previously selected engine didn't pass the filter, remove selection + } else if (this->vehicle_sel != INVALID_VEHICLE && std::ranges::find(this->vehicles, Vehicle::Get(this->vehicle_sel)) == this->vehicles.end()) { // previously selected engine didn't pass the filter, remove selection this->vehicle_sel = INVALID_VEHICLE; } } @@ -636,7 +636,7 @@ uint8_t GetBestFittingSubType(Vehicle *v_from, Vehicle *v_for, CargoID dest_carg StringID subtype = GetCargoSubtypeText(v); if (subtype == STR_EMPTY) break; - if (std::find(subtypes.begin(), subtypes.end(), subtype) == subtypes.end()) continue; + if (std::ranges::find(subtypes, subtype) == subtypes.end()) continue; /* We found something matching. */ ret_refit_cyc = refit_cyc; @@ -787,7 +787,7 @@ struct RefitWindow : public Window { GetVehicleSet(vehicles_to_refit, Vehicle::Get(this->selected_vehicle), this->num_vehicles); do { - if (v->type == VEH_TRAIN && std::find(vehicles_to_refit.begin(), vehicles_to_refit.end(), v->index) == vehicles_to_refit.end()) continue; + if (v->type == VEH_TRAIN && std::ranges::find(vehicles_to_refit, v->index) == vehicles_to_refit.end()) continue; const Engine *e = v->GetEngine(); CargoTypes cmask = e->info.refit_mask; uint8_t callback_mask = e->info.callback_mask; @@ -1081,7 +1081,7 @@ struct RefitWindow : public Window { for (Train *u = Train::From(v); u != nullptr; u = u->Next()) { /* Start checking. */ - const bool contained = std::find(vehicles_to_refit.begin(), vehicles_to_refit.end(), u->index) != vehicles_to_refit.end(); + const bool contained = std::ranges::find(vehicles_to_refit, u->index) != vehicles_to_refit.end(); if (contained && left == INT32_MIN) { left = x - this->hscroll->GetPosition() + r.left + this->vehicle_margin; width = 0; diff --git a/src/video/allegro_v.cpp b/src/video/allegro_v.cpp index 6cf585813d..8b0406acee 100644 --- a/src/video/allegro_v.cpp +++ b/src/video/allegro_v.cpp @@ -152,7 +152,7 @@ static void GetVideoModes() uint w = modes[i].width; uint h = modes[i].height; if (w < 640 || h < 480) continue; - if (std::find(_resolutions.begin(), _resolutions.end(), Dimension(w, h)) != _resolutions.end()) continue; + if (std::ranges::find(_resolutions, Dimension(w, h)) != _resolutions.end()) continue; _resolutions.emplace_back(w, h); } @@ -167,7 +167,7 @@ static void GetAvailableVideoMode(uint *w, uint *h) if (_resolutions.empty()) return; /* is the wanted mode among the available modes? */ - if (std::find(_resolutions.begin(), _resolutions.end(), Dimension(*w, *h)) != _resolutions.end()) return; + if (std::ranges::find(_resolutions, Dimension(*w, *h)) != _resolutions.end()) return; /* use the closest possible resolution */ uint best = 0; diff --git a/src/video/sdl2_v.cpp b/src/video/sdl2_v.cpp index 6a287552c0..a546e136b0 100644 --- a/src/video/sdl2_v.cpp +++ b/src/video/sdl2_v.cpp @@ -65,7 +65,7 @@ static void FindResolutions() SDL_GetDisplayMode(display, i, &mode); if (mode.w < 640 || mode.h < 480) continue; - if (std::find(_resolutions.begin(), _resolutions.end(), Dimension(mode.w, mode.h)) != _resolutions.end()) continue; + if (std::ranges::find(_resolutions, Dimension(mode.w, mode.h)) != _resolutions.end()) continue; _resolutions.emplace_back(mode.w, mode.h); } } @@ -84,7 +84,7 @@ static void GetAvailableVideoMode(uint *w, uint *h) if (!_fullscreen || _resolutions.empty()) return; /* Is the wanted mode among the available modes? */ - if (std::find(_resolutions.begin(), _resolutions.end(), Dimension(*w, *h)) != _resolutions.end()) return; + if (std::ranges::find(_resolutions, Dimension(*w, *h)) != _resolutions.end()) return; /* Use the closest possible resolution */ uint best = 0; diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp index 17041ab064..dbff0cb186 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -192,7 +192,7 @@ static void GetVideoModes() uint w = modes[i]->w; uint h = modes[i]->h; if (w < 640 || h < 480) continue; // reject too small resolutions - if (std::find(_resolutions.begin(), _resolutions.end(), Dimension(w, h)) != _resolutions.end()) continue; + if (std::ranges::find(_resolutions, Dimension(w, h)) != _resolutions.end()) continue; _resolutions.emplace_back(w, h); } if (_resolutions.empty()) UserError("No usable screen resolutions found!\n"); @@ -206,7 +206,7 @@ static void GetAvailableVideoMode(uint *w, uint *h) if (_all_modes || _resolutions.empty()) return; /* Is the wanted mode among the available modes? */ - if (std::find(_resolutions.begin(), _resolutions.end(), Dimension(*w, *h)) != _resolutions.end()) return; + if (std::ranges::find(_resolutions, Dimension(*w, *h)) != _resolutions.end()) return; /* Use the closest possible resolution */ uint best = 0; diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index 8a32b21d0c..f6aa0994cf 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -800,7 +800,7 @@ static void FindResolutions(uint8_t bpp) DEVMODE dm; for (uint i = 0; EnumDisplaySettings(nullptr, i, &dm) != 0; i++) { if (dm.dmBitsPerPel != bpp || dm.dmPelsWidth < 640 || dm.dmPelsHeight < 480) continue; - if (std::find(_resolutions.begin(), _resolutions.end(), Dimension(dm.dmPelsWidth, dm.dmPelsHeight)) != _resolutions.end()) continue; + if (std::ranges::find(_resolutions, Dimension(dm.dmPelsWidth, dm.dmPelsHeight)) != _resolutions.end()) continue; _resolutions.emplace_back(dm.dmPelsWidth, dm.dmPelsHeight); } diff --git a/src/window.cpp b/src/window.cpp index 4f4fd66a44..e69c50977c 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -126,7 +126,7 @@ WindowDesc::WindowDesc(WindowPosition def_pos, const char *ini_key, int16_t def_ WindowDesc::~WindowDesc() { - _window_descs->erase(std::find(_window_descs->begin(), _window_descs->end(), this)); + _window_descs->erase(std::ranges::find(*_window_descs, this)); } /**