[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 Nov 27 07:31:38 PST 2023


================
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
----------------
ldionne wrote:

This should be a `.verify.cpp` test. Please look at other `.verify.cpp` tests for inspiration, they're really not that hard to write.

To trigger the `static_assert`, you'll have to create a comparator that can't be called as a `F const&` and one that can't be called as a `F&`. You can do

```
struct ConstUncallable {
  void operator()(...) const& = delete;
  void operator()(...) & { implementation }
};

struct NonConstUncallable {
  void operator()(...) const&  { implementation }
  void operator()(...) & = delete;
};
```

With the proper signature as expected by each algorithm, of course.


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


More information about the libcxx-commits mailing list