From 6b4b3b41cd56c3547217a44b225be2e785c75bd0 Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Mon, 28 Jul 2025 15:36:25 -0700 Subject: [PATCH] Fix build failure with std::ranges on Debian 11 --- src/util.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/util.cc b/src/util.cc index 8059976da6..02e17c74f8 100644 --- a/src/util.cc +++ b/src/util.cc @@ -1538,7 +1538,14 @@ TEST_CASE("util strstrip") { std::string strstrip(std::string s) { auto notspace = [](unsigned char c) { return ! std::isspace(c); }; s.erase(s.begin(), std::ranges::find_if(s, notspace)); - s.erase(std::ranges::find_if(std::ranges::reverse_view(s), notspace).base(), s.end()); + + // We require `std::reverse_iterator::base` here which in e.g., gcc-10.2.1 + // is not implemented for the range equivalent of the code + // (`borrowed_iterator_t` over a `reverse_view`). Stick to the non-ranges + // version for now. + // NOLINTNEXTLINE(modernize-use-ranges) + s.erase(std::find_if(s.rbegin(), s.rend(), notspace).base(), s.end()); + return s; }