diff --git a/src/MeoAssistant/AsstConf.h b/src/MeoAssistant/AsstConf.h index 94f041e492..dabcae4c00 100644 --- a/src/MeoAssistant/AsstConf.h +++ b/src/MeoAssistant/AsstConf.h @@ -1,6 +1,6 @@ #pragma once -#if !defined(ASST_USE_RANGES_STL) && !defined(ASST_USE_RANGES_RANGE_V3) +#if !defined(ASST_USE_RANGES_STL) && !defined(ASST_USE_RANGES_RANGE_V3) && !defined(ASST_USE_RANGES_BOOST) #ifdef __clang__ #define ASST_USE_RANGES_RANGE_V3 #else diff --git a/src/MeoAssistant/AsstRanges.hpp b/src/MeoAssistant/AsstRanges.hpp index 2d4557f566..6f3fe7f7eb 100644 --- a/src/MeoAssistant/AsstRanges.hpp +++ b/src/MeoAssistant/AsstRanges.hpp @@ -8,7 +8,31 @@ namespace asst { - namespace ranges = ::ranges; + namespace ranges + { + using namespace ::ranges; + + // return type of ::ranges::remove_if is different from which of std::remove_if + struct remove_if_fn + { + template S, typename C, typename P = identity> + constexpr subrange + operator()(I first, S last, C pred, P proj = P{}) const + { + return { ::ranges::remove_if(std::move(first), last, std::move(pred), std::move(proj)), last }; + } + + template + constexpr borrowed_subrange_t operator()(Rng&& rng, C pred, P proj = P{}) const + { + return (*this)(begin(rng), end(rng), std::move(pred), std::move(proj)); + } + }; + + // this one will be found before ::ranges::remove_if + inline constexpr remove_if_fn remove_if{}; + } + namespace views = ::ranges::views; } @@ -22,8 +46,20 @@ namespace asst namespace views = std::views; } +#elif defined(ASST_USE_RANGES_BOOST) + +#error "Not implemented" + +#include +#include + +namespace asst { + namespace ranges = boost::range; + namespace views = boost::adaptors; +} + #else #error -#endif \ No newline at end of file +#endif diff --git a/src/MeoAssistant/InfrastProductionTask.cpp b/src/MeoAssistant/InfrastProductionTask.cpp index ebdd3edee0..ba6ddc08a8 100644 --- a/src/MeoAssistant/InfrastProductionTask.cpp +++ b/src/MeoAssistant/InfrastProductionTask.cpp @@ -496,14 +496,8 @@ bool asst::InfrastProductionTask::opers_choose() auto remove_iter = ranges::remove_if(cur_all_opers, [&](const infrast::Oper& rhs) -> bool { return rhs.mood_ratio < m_mood_threshold; - }); -#ifdef ASST_USE_RANGES_STL - cur_all_opers.erase(remove_iter.begin(), cur_all_opers.end()); -#elif defined(ASST_USE_RANGES_RANGE_V3) + }).begin(); cur_all_opers.erase(remove_iter, cur_all_opers.end()); -#else -#error -#endif Log.trace("after mood filter, opers size:", cur_all_opers.size()); for (auto opt_iter = m_optimal_combs.begin(); opt_iter != m_optimal_combs.end();) { Log.trace("to find", opt_iter->skills.begin()->names.front());