[libc++] Check correctly ref-qualified __is_callable in algorithms (#101553)
We were only checking that the comparator was rvalue callable,
when in reality the algorithms always call comparators as lvalues.
This patch also refactors the tests for callable requirements and
expands it to a few missing algorithms.
This is take 2 of #73451, which was reverted because it broke some
CI bots. The issue was that we checked __is_callable with arguments
in the wrong order inside std::upper_bound. This has now been fixed
and a test was added.
Fixes #69554
diff --git a/libcxx/src/regex.cpp b/libcxx/src/regex.cpp
index 9dc0c69..6d9f06e 100644
--- a/libcxx/src/regex.cpp
+++ b/libcxx/src/regex.cpp
@@ -323,8 +323,8 @@
{"xdigit", ctype_base::xdigit}};
struct use_strcmp {
- bool operator()(const collationnames& x, const char* y) { return strcmp(x.elem_, y) < 0; }
- bool operator()(const classnames& x, const char* y) { return strcmp(x.elem_, y) < 0; }
+ bool operator()(const collationnames& x, const char* y) const { return strcmp(x.elem_, y) < 0; }
+ bool operator()(const classnames& x, const char* y) const { return strcmp(x.elem_, y) < 0; }
};
} // namespace