1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-07 07:10:04 +02:00

Reduce boost includes further

This commit is contained in:
Ivan Savenko 2025-03-18 15:43:12 +00:00
parent 7a3e1409d0
commit c73116a010
4 changed files with 30 additions and 12 deletions

View File

@ -162,15 +162,34 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
#include <boost/algorithm/string.hpp>
#include <boost/container/small_vector.hpp>
#include <boost/container/static_vector.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
// C++ 20 -> std::source_location::function_name
#include <boost/current_function.hpp>
// C++ 17 -> std::filesystem
#include <boost/filesystem/directory.hpp>
#include <boost/filesystem/exception.hpp>
#include <boost/filesystem/file_status.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/format.hpp>
#include <boost/logic/tribool.hpp>
#include <boost/multi_array.hpp>
// C++ 20 -> std::range
#include <boost/range/adaptor/filtered.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm/copy.hpp>
#include <boost/range/algorithm/count.hpp>
#include <boost/range/algorithm/count_if.hpp>
#include <boost/range/algorithm/fill.hpp>
#include <boost/range/algorithm/find.hpp>
#include <boost/range/algorithm/find_if.hpp>
#include <boost/range/algorithm/max_element.hpp>
#include <boost/range/algorithm/min_element.hpp>
#include <boost/range/algorithm/remove.hpp>
#include <boost/range/algorithm/remove_if.hpp>
#include <boost/range/algorithm/replace.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/algorithm/unique.hpp>
#include <boost/range/algorithm/upper_bound.hpp>
#ifndef M_PI
# define M_PI 3.14159265358979323846
@ -180,7 +199,6 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
/* Usings */
/* ---------------------------------------------------------------------------- */
using namespace std::placeholders;
namespace range = boost::range;
/* ---------------------------------------------------------------------------- */
/* Typedefs */
@ -319,7 +337,7 @@ namespace vstd
template <typename Container, typename Func>
int find_pos_if(const Container & c, const Func &f)
{
auto ret = boost::range::find_if(c, f);
auto ret = std::find_if(c.begin(), c.end(), f);
if(ret != std::end(c))
return std::distance(std::begin(c), ret);
@ -470,13 +488,13 @@ namespace vstd
template <typename Container, typename Item>
void erase(Container &c, const Item &item)
{
c.erase(boost::remove(c, item), c.end());
c.erase(std::remove(c.begin(), c.end(), item), c.end());
}
template<typename Range, typename Predicate>
void erase_if(Range &vec, Predicate pred)
{
vec.erase(boost::remove_if(vec, pred),vec.end());
vec.erase(std::remove_if(vec.begin(), vec.end(), pred), vec.end());
}
template<typename Elem, typename Predicate>
@ -563,7 +581,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 boost::min_element(rng, [&] (decltype(*std::begin(rng)) lhs, decltype(*std::begin(rng)) rhs) -> bool
return std::min_element(rng.begin(), rng.end(), [&] (decltype(*std::begin(rng)) lhs, decltype(*std::begin(rng)) rhs) -> bool
{
return vf(lhs) < vf(rhs);
});
@ -578,7 +596,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 boost::max_element(rng, [&] (decltype(*std::begin(rng)) lhs, decltype(*std::begin(rng)) rhs) -> bool
return std::max_element(rng.begin(), rng.end(), [&] (decltype(*std::begin(rng)) lhs, decltype(*std::begin(rng)) rhs) -> bool
{
return vf(lhs) < vf(rhs);
});

View File

@ -308,7 +308,7 @@ void AdventureMapShortcuts::endTurn()
void AdventureMapShortcuts::showThievesGuild()
{
//find first town with tavern
auto itr = range::find_if(GAME->interface()->localState->getOwnedTowns(), [](const CGTownInstance * town)
auto itr = boost::range::find_if(GAME->interface()->localState->getOwnedTowns(), [](const CGTownInstance * town)
{
return town->hasBuilt(BuildingID::TAVERN);
});

View File

@ -132,7 +132,7 @@ bool StartBatchCopyDataProgram(
(boost::format("start \"\" /D %1% %2%") % currentPath % (to / exeName)); // Start game in 'currentPath"
const bfs::path bathFilename = to / "_temp.bat";
bfs::ofstream bathFile(bathFilename, bfs::ofstream::trunc | bfs::ofstream::out);
std::ofstream bathFile(bathFilename.c_str(), std::ofstream::trunc | std::ofstream::out);
if (!bathFile.is_open())
return false;
bathFile << (boost::format(base) % exeName % from % (from / "*.*") % to % startGameString.str()).str();

View File

@ -372,7 +372,7 @@ const JsonNode & CampaignState::getHeroByType(HeroTypeID heroID) const
void CampaignState::setCurrentMapAsConquered(std::vector<CGHeroInstance *> heroes)
{
range::sort(heroes, [](const CGHeroInstance * a, const CGHeroInstance * b)
boost::range::sort(heroes, [](const CGHeroInstance * a, const CGHeroInstance * b)
{
return a->getValueForCampaign() > b->getValueForCampaign();
});