diff --git a/src/evo/simplifiedmns.cpp b/src/evo/simplifiedmns.cpp index 41c3138c6652..c0e059a358c1 100644 --- a/src/evo/simplifiedmns.cpp +++ b/src/evo/simplifiedmns.cpp @@ -132,12 +132,9 @@ uint256 CSimplifiedMNList::CalcMerkleRoot(bool* pmutated) const bool CSimplifiedMNList::operator==(const CSimplifiedMNList& rhs) const { return mnList.size() == rhs.mnList.size() && - std::equal(mnList.begin(), mnList.end(), rhs.mnList.begin(), - [](const std::unique_ptr& left, const std::unique_ptr& right) - { - return *left == *right; - } - ); + ranges::equal(mnList, rhs.mnList, + [](const std::unique_ptr& left, + const std::unique_ptr& right) { return *left == *right; }); } CSimplifiedMNListDiff::CSimplifiedMNListDiff() = default; diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 7af6478c0f72..ebf5a7c13e83 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -595,8 +596,7 @@ static bool ExecuteCommand(const CRPCCommand& command, const JSONRPCRequest& req continue; } - if (std::equal(vecAllowedParam.begin(), vecAllowedParam.end(), - request.params.getValues().begin(), + if (ranges::equal(vecAllowedParam, request.params.getValues(), [](const UniValue& left, const UniValue& right) { return left.type() == right.type() && left.getValStr() == right.getValStr(); })) { diff --git a/src/util/ranges.h b/src/util/ranges.h index dca6866eea31..19dd502b969a 100644 --- a/src/util/ranges.h +++ b/src/util/ranges.h @@ -12,16 +12,39 @@ //namespace ranges = std::ranges; //#else -#define MK_RANGE(FUN) \ -template \ -inline auto FUN(const X& ds, const Z& fn) { \ - return std::FUN(cbegin(ds), cend(ds), fn); \ -} \ -template \ -inline auto FUN(X& ds, const Z& fn) { \ - return std::FUN(begin(ds), end(ds), fn); \ -} +#define MK_RANGE(FUN) \ + template \ + inline auto FUN(const X& ds, const Z& fn) \ + { \ + return std::FUN(std::cbegin(ds), std::cend(ds), fn); \ + } \ + template \ + inline auto FUN(X& ds, const Z& fn) \ + { \ + return std::FUN(std::begin(ds), std::end(ds), fn); \ + } +#define MK_RANGE2(FUN) \ + template \ + inline auto FUN(const X& first, const Y& second, const Z& fn) \ + { \ + return std::FUN(std::cbegin(first), std::cend(first), std::cbegin(second), std::cend(second), fn); \ + } \ + template \ + inline auto FUN(X& first, Y& second, const Z& fn) \ + { \ + return std::FUN(std::begin(first), std::end(first), std::begin(second), std::end(second), fn); \ + } \ + template \ + inline auto FUN(const X& first, const Y& second) \ + { \ + return std::FUN(std::cbegin(first), std::cend(first), std::cbegin(second), std::cend(second)); \ + } \ + template \ + inline auto FUN(X& first, Y& second) \ + { \ + return std::FUN(std::begin(first), std::end(first), std::begin(second), std::end(second)); \ + } namespace ranges { MK_RANGE(all_of) @@ -29,6 +52,8 @@ namespace ranges { MK_RANGE(count_if) MK_RANGE(find_if) + MK_RANGE2(equal) + template constexpr inline auto find_if_opt(const X& ds, const Z& fn) { const auto it = ranges::find_if(ds, fn);