diff --git a/src/util/ranges.h b/src/util/ranges.h index dca6866eea..aec61de960 100644 --- a/src/util/ranges.h +++ b/src/util/ranges.h @@ -5,40 +5,20 @@ #ifndef BITCOIN_UTIL_RANGES_H #define BITCOIN_UTIL_RANGES_H -#include +#include #include -//#if __cplusplus > 201703L // C++20 compiler -//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); \ -} - - namespace ranges { - MK_RANGE(all_of) - MK_RANGE(any_of) - MK_RANGE(count_if) - MK_RANGE(find_if) +using namespace std::ranges; - template - constexpr inline auto find_if_opt(const X& ds, const Z& fn) { - const auto it = ranges::find_if(ds, fn); - if (it != end(ds)) { - return std::make_optional(*it); - } - return std::optional>{}; +template +constexpr inline auto find_if_opt(const X& ds, const Z& fn) { + const auto it = std::ranges::find_if(ds, fn); + if (it != std::end(ds)) { + return std::make_optional(*it); } - + return std::optional>{}; +} } -//#endif // C++20 compiler #endif // BITCOIN_UTIL_RANGES_H