[libcxx-commits] [libcxx] [libc++] <algorithm>: __is_callable checks whether the callable can be called with rvalue (PR #73451)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 11 07:30:07 PST 2023


================
@@ -0,0 +1,16 @@
+#include <algorithm>
+
+struct ConstUncallable {
+  void operator()(int, int) const& = delete;
+  void operator()(int, int) & { return; }
+};
+
+struct NonConstUncallable {
+  void operator()(int, int) const& { return; }
+  void operator()(int, int) & = delete;
+};
+
+void test() {
+  std::minmax({42, 0, -42}, ConstUncallable{});
+  //expected-error-re@*:* {{static_assert(__is_callable<_Compare const&, decltype(*__first), const _Tp&>::value, "The comparator has to be const-callable")}}
+}
----------------
ldionne wrote:

Missing newline at the end of the file.

https://github.com/llvm/llvm-project/pull/73451


More information about the libcxx-commits mailing list