Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/evo/simplifiedmns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CSimplifiedMNListEntry>& left, const std::unique_ptr<CSimplifiedMNListEntry>& right)
{
return *left == *right;
}
);
ranges::equal(mnList, rhs.mnList,
[](const std::unique_ptr<CSimplifiedMNListEntry>& left,
const std::unique_ptr<CSimplifiedMNListEntry>& right) { return *left == *right; });
}

CSimplifiedMNListDiff::CSimplifiedMNListDiff() = default;
Expand Down
4 changes: 2 additions & 2 deletions src/rpc/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <util/strencodings.h>
#include <util/string.h>
#include <util/system.h>
#include <util/ranges.h>

#include <boost/signals2/signal.hpp>

Expand Down Expand Up @@ -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(),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this broke rpc_platform_filter.py

[](const UniValue& left, const UniValue& right) {
return left.type() == right.type() && left.getValStr() == right.getValStr();
})) {
Expand Down
43 changes: 34 additions & 9 deletions src/util/ranges.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,48 @@
//namespace ranges = std::ranges;
//#else

#define MK_RANGE(FUN) \
template <typename X, typename Z> \
inline auto FUN(const X& ds, const Z& fn) { \
return std::FUN(cbegin(ds), cend(ds), fn); \
} \
template <typename X, typename Z> \
inline auto FUN(X& ds, const Z& fn) { \
return std::FUN(begin(ds), end(ds), fn); \
}
#define MK_RANGE(FUN) \
template <typename X, typename Z> \
inline auto FUN(const X& ds, const Z& fn) \
{ \
return std::FUN(std::cbegin(ds), std::cend(ds), fn); \
} \
template <typename X, typename Z> \
inline auto FUN(X& ds, const Z& fn) \
{ \
return std::FUN(std::begin(ds), std::end(ds), fn); \
}

#define MK_RANGE2(FUN) \
template <typename X, typename Y, typename Z> \
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 <typename X, typename Y, typename Z> \
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 <typename X, typename Y> \
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 <typename X, typename Y> \
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)
MK_RANGE(any_of)
MK_RANGE(count_if)
MK_RANGE(find_if)

MK_RANGE2(equal)

template <typename X, typename Z>
constexpr inline auto find_if_opt(const X& ds, const Z& fn) {
const auto it = ranges::find_if(ds, fn);
Expand Down