[libcxx-commits] [PATCH] D135016: [libc++] Implement P1169R4 (static operator())
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Oct 6 08:41:56 PDT 2022
ldionne accepted this revision.
ldionne added a comment.
This LGTM with my comments.
================
Comment at: libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/ctad.static.compile.pass.cpp:18
+
+#if defined(__cpp_static_call_operator) && __cpp_static_call_operator >= 202207L
+
----------------
Let's mark this as `UNSUPPORTED: clang-14, clang-15, gcc-12` instead.
================
Comment at: libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/ctad.static.compile.pass.cpp:20
+
+struct Except {
+ static int operator()(int*, long*) { return 0; }
----------------
Please add a few more cases: 0 arguments, 1 argument, variadic arguments, default argument (why not?).
Also, let's run these tests (not compile only), unless you sign up to address the more general issue of testing the integration of `static operator()` in `std::function` (and probably other places). If you don't sign up for that, then let's run these tests cause that's going to be better than nothing.
================
Comment at: libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/ctad.static.compile.pass.cpp:10
+// UNSUPPORTED: c++03, c++11, c++14
+// UNSUPPORTED: (c++17 || c++20) && !stdlib=libc++
+// ADDITIONAL_COMPILE_FLAGS: -Wno-c++2b-extensions
----------------
philnik wrote:
> ldionne wrote:
> > Why do we support this pre-C++23?
> Because my plan is to use `static operator()` for the implementation of the ranges algorithms, since it improves code gen.
Range algorithms can't be passed to `std::function` if we follow the letter of the standard. I don't think we should attempt to support this before C++23. If we do, then we are almost certainly missing similar things elsewhere in the library, which would make our support for that spotty anyway.
Let's just implement this in C++23, as specified, and we can make our ranges algorithms' `operator()` `static`, which shouldn't be detectable. While people can technically detect it by looking at the type of e.g. `std::ranges::copy::operator()`, they are not allowed to do that in the first place, which makes this undetectable.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D135016/new/
https://reviews.llvm.org/D135016
More information about the libcxx-commits
mailing list