Explorar o código

Revert "min_element and max_element from std"

This reverts commit ba2d8dc2768b59e07c862d4eada2b9d5c974b060.
Laserlicht hai 7 meses
pai
achega
0182bcd74a

+ 1 - 1
AI/Nullkiller/Analyzers/ArmyManager.cpp

@@ -128,7 +128,7 @@ std::vector<SlotInfo>::iterator ArmyManager::getBestUnitForScout(std::vector<Slo
 
 	const auto & movementPointsLimits = cb->getSettings().getVector(EGameSettings::HEROES_MOVEMENT_POINTS_LAND);
 
-	auto fastest = std::min_element(army.begin(), army.end(), [&](const SlotInfo & left, const SlotInfo & right) -> bool
+	auto fastest = boost::min_element(army, [&](const SlotInfo & left, const SlotInfo & right) -> bool
 	{
 		uint64_t leftUnitPower = left.power / left.count;
 		uint64_t rightUnitPower = left.power / left.count;

+ 1 - 1
AI/VCAI/ArmyManager.cpp

@@ -58,7 +58,7 @@ std::vector<SlotInfo> ArmyManager::getSortedSlots(const CCreatureSet * target, c
 
 std::vector<SlotInfo>::iterator ArmyManager::getWeakestCreature(std::vector<SlotInfo> & army) const
 {
-	auto weakest = std::min_element(army.begin(), army.end(), [](const SlotInfo & left, const SlotInfo & right) -> bool
+	auto weakest = boost::min_element(army, [](const SlotInfo & left, const SlotInfo & right) -> bool
 	{
 		if(left.creature->getLevel() != right.creature->getLevel())
 			return left.creature->getLevel() < right.creature->getLevel();

+ 1 - 1
AI/VCAI/FuzzyHelper.cpp

@@ -54,7 +54,7 @@ Goals::TSubgoal FuzzyHelper::chooseSolution(Goals::TGoalVec vec)
 		logAi->trace("FuzzyHelper evaluated goal %s, priority=%.4f", goal->name(), goal->priority);
 	}
 
-	Goals::TSubgoal result = *std::max_element(vec.begin(), vec.end(), compareGoals);
+	Goals::TSubgoal result = *boost::max_element(vec, compareGoals);
 
 	logAi->debug("FuzzyHelper returned goal %s, priority=%.4f", result->name(), result->priority);
 

+ 1 - 1
AI/VCAI/ResourceManager.cpp

@@ -128,7 +128,7 @@ Goals::TSubgoal ResourceManager::collectResourcesForOurGoal(ResourceObjective &o
 			return lhs.second < rhs.second;
 		};
 
-		resourceType = std::max_element(daysToEarn.begin(), daysToEarn.end(), incomeComparer)->first;
+		resourceType = boost::max_element(daysToEarn, incomeComparer)->first;
 		amountToCollect = missingResources[resourceType];
 	}
 

+ 5 - 5
AI/VCAI/VCAI.cpp

@@ -1438,12 +1438,12 @@ void VCAI::wander(HeroPtr h)
 			}
 			if(townsReachable.size()) //travel to town with largest garrison, or empty - better than nothing
 			{
-				dests.push_back(*std::max_element(townsReachable.begin(), townsReachable.end(), compareReinforcements));
+				dests.push_back(*boost::max_element(townsReachable, compareReinforcements));
 			}
 			else if(townsNotReachable.size())
 			{
 				//TODO pick the truly best
-				const CGTownInstance * t = *std::max_element(townsNotReachable.begin(), townsNotReachable.end(), compareReinforcements);
+				const CGTownInstance * t = *boost::max_element(townsNotReachable, compareReinforcements);
 				logAi->debug("%s can't reach any town, we'll try to make our way to %s at %s", h->getNameTranslated(), t->getNameTranslated(), t->visitablePos().toString());
 				int3 posBefore = h->visitablePos();
 				striveToGoal(sptr(Goals::ClearWayTo(t->visitablePos()).sethero(h))); //TODO: drop "strive", add to mainLoop
@@ -1470,7 +1470,7 @@ void VCAI::wander(HeroPtr h)
 				});
 				if (towns.size())
 				{
-					recruitHero(*std::max_element(towns.begin(), towns.end(), compareArmyStrength));
+					recruitHero(*boost::max_element(towns, compareArmyStrength));
 				}
 				break;
 			}
@@ -2214,7 +2214,7 @@ void VCAI::tryRealize(Goals::BuyArmy & g)
 			throw cannotFulfillGoalException("Can't buy any more creatures!");
 
 		creInfo ci =
-			*std::max_element(creaturesInDwellings.begin(), creaturesInDwellings.end(), [](const creInfo & lhs, const creInfo & rhs)
+			*boost::max_element(creaturesInDwellings, [](const creInfo & lhs, const creInfo & rhs)
 		{
 			//max value of creatures we can buy with our res
 			int value1 = lhs.cre->getAIValue() * lhs.count;
@@ -2293,7 +2293,7 @@ HeroPtr VCAI::primaryHero() const
 	if (hs.empty())
 		return nullptr;
 	else
-		return *std::max_element(hs.begin(), hs.end(), compareHeroStrength);
+		return *boost::max_element(hs, compareHeroStrength);
 }
 
 void VCAI::endTurn()

+ 2 - 2
Global.h

@@ -582,7 +582,7 @@ namespace vstd
 		 * Current bugfix is to don't use a typedef for decltype(*std::begin(rng)) and to use decltype
 		 * directly for both function parameters.
 		 */
-		return std::min_element(rng.begin(), rng.end(), [&] (decltype(*std::begin(rng)) lhs, decltype(*std::begin(rng)) rhs) -> bool
+		return boost::min_element(rng, [&] (decltype(*std::begin(rng)) lhs, decltype(*std::begin(rng)) rhs) -> bool
 		{
 			return vf(lhs) < vf(rhs);
 		});
@@ -597,7 +597,7 @@ namespace vstd
 		 * Current bugfix is to don't use a typedef for decltype(*std::begin(rng)) and to use decltype
 		 * directly for both function parameters.
 		 */
-		return std::max_element(rng.begin(), rng.end(), [&] (decltype(*std::begin(rng)) lhs, decltype(*std::begin(rng)) rhs) -> bool
+		return boost::max_element(rng, [&] (decltype(*std::begin(rng)) lhs, decltype(*std::begin(rng)) rhs) -> bool
 		{
 			return vf(lhs) < vf(rhs);
 		});

+ 1 - 1
client/windows/CCastleInterface.cpp

@@ -702,7 +702,7 @@ void CCastleBuildings::recreate()
 	{
 		const CBuilding * build = town->getTown()->buildings.at(entry.first);
 
-		const CStructure * toAdd = *std::max_element(entry.second.begin(), entry.second.end(), [=](const CStructure * a, const CStructure * b)
+		const CStructure * toAdd = *boost::max_element(entry.second, [=](const CStructure * a, const CStructure * b)
 		{
 			return build->getDistance(a->building->bid) < build->getDistance(b->building->bid);
 		});

+ 1 - 1
lib/battle/CBattleInfoCallback.cpp

@@ -1186,7 +1186,7 @@ std::pair<const battle::Unit *, BattleHex> CBattleInfoCallback::getNearestStack(
 	if(!stackPairs.empty())
 	{
 		auto comparator = [](DistStack lhs, DistStack rhs) { return lhs.distanceToPred < rhs.distanceToPred; };
-		auto minimal = std::min_element(stackPairs.begin(), stackPairs.end(), comparator);
+		auto minimal = boost::min_element(stackPairs, comparator);
 		return std::make_pair(minimal->stack, minimal->destination);
 	}
 	else

+ 1 - 1
lib/mapObjectConstructors/AObjectTypeHandler.cpp

@@ -224,7 +224,7 @@ std::vector<std::shared_ptr<const ObjectTemplate>>AObjectTypeHandler::getMostSpe
 	if (!templates.empty())
 	{
 		//Get terrain-specific template if possible
-		int leastTerrains = (*std::min_element(templates.begin(), templates.end(), [](const std::shared_ptr<const ObjectTemplate> & tmp1, const std::shared_ptr<const ObjectTemplate> & tmp2)
+		int leastTerrains = (*boost::min_element(templates, [](const std::shared_ptr<const ObjectTemplate> & tmp1, const std::shared_ptr<const ObjectTemplate> & tmp2)
 		{
 			return tmp1->getAllowedTerrains().size() < tmp2->getAllowedTerrains().size();
 		}))->getAllowedTerrains().size();

+ 3 - 3
lib/rmg/CZonePlacer.cpp

@@ -918,7 +918,7 @@ void CZonePlacer::assignZones(vstd::RNG * rand)
 				{
 					distances.emplace_back(zone.second, static_cast<float>(pos.dist2dSQ(zone.second->getPos())));
 				}
-				std::min_element(distances.begin(), distances.end(), compareByDistance)->first->area()->add(pos); //closest tile belongs to zone
+				boost::min_element(distances, compareByDistance)->first->area()->add(pos); //closest tile belongs to zone
 			}
 		}
 	}
@@ -951,7 +951,7 @@ void CZonePlacer::assignZones(vstd::RNG * rand)
 			{
 				distances.emplace_back(zone.second, zone.second->getCenter().dist2dSQ(float3(vertex.x(), vertex.y(), level)));
 			}
-			auto closestZone = std::min_element(distances.begin(), distances.end(), compareByDistance)->first;
+			auto closestZone = boost::min_element(distances, compareByDistance)->first;
 
 			vertexMapping[closestZone].insert(int3(vertex.x() * width, vertex.y() * height, level)); //Closest vertex belongs to zone
 		}
@@ -973,7 +973,7 @@ void CZonePlacer::assignZones(vstd::RNG * rand)
 				}
 
 				//Tile closest to vertex belongs to zone
-				auto closestZone = std::min_element(distances.begin(), distances.end(), simpleCompareByDistance)->first;
+				auto closestZone = boost::min_element(distances, simpleCompareByDistance)->first;
 				closestZone->area()->add(pos);
 				map.setZoneID(pos, closestZone->getId());
 			}