mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 18:20:39 +08:00
feat: improve compatibility of range-v3 replacement
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 <permutable I, sentinel_for<I> S, typename C, typename P = identity>
|
||||
constexpr subrange<I>
|
||||
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 <forward_range Rng, typename C, typename P = identity>
|
||||
constexpr borrowed_subrange_t<Rng> 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 <boost/range/algorithm.hpp>
|
||||
#include <boost/range/adaptors.hpp>
|
||||
|
||||
namespace asst {
|
||||
namespace ranges = boost::range;
|
||||
namespace views = boost::adaptors;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#error
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user