[libcxx-commits] [PATCH] D135016: [libc++] Implement P1169R4 (static operator())

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Oct 1 12:27:23 PDT 2022


philnik created this revision.
philnik added reviewers: ldionne, Mordante, var-const, huixie90.
Herald added a project: All.
philnik requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135016

Files:
  libcxx/docs/ReleaseNotes.rst
  libcxx/docs/Status/Cxx2bPapers.csv
  libcxx/include/__functional/function.h
  libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/ctad.static.compile.pass.cpp


Index: libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/ctad.static.compile.pass.cpp
===================================================================
--- /dev/null
+++ libcxx/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/ctad.static.compile.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14
+// UNSUPPORTED: (c++17 || c++20) && !stdlib=libc++
+// ADDITIONAL_COMPILE_FLAGS: -Wno-c++2b-extensions
+
+// checks that CTAD for std::function works properly with static operator() overloads
+
+#include <functional>
+#include <type_traits>
+
+#if defined(__cpp_static_call_operator) && __cpp_static_call_operator >= 202207L
+
+struct Except {
+  static int operator()(int*, long*) { return 0; }
+};
+static_assert(std::is_same_v<decltype(std::function{Except{}}), std::function<int(int*, long*)>>);
+
+struct Noexcept {
+  static int operator()(int*, long*) noexcept { return 0; }
+};
+static_assert(std::is_same_v<decltype(std::function{Noexcept{}}), std::function<int(int*, long*)>>);
+
+#endif
Index: libcxx/include/__functional/function.h
===================================================================
--- libcxx/include/__functional/function.h
+++ libcxx/include/__functional/function.h
@@ -1069,6 +1069,20 @@
 template<class _Fp>
 struct __strip_signature;
 
+#  if defined(__cpp_static_call_operator) && __cpp_static_call_operator >= 202207L
+
+template <class _Rp, class... _Args>
+struct __strip_signature<_Rp(*)(_Args...)> {
+  using type = _Rp(_Args...);
+};
+
+template <class _Rp, class... _Args>
+struct __strip_signature<_Rp(*)(_Args...) noexcept> {
+  using type = _Rp(_Args...);
+};
+
+#  endif // defined(__cpp_static_call_operator) && __cpp_static_call_operator >= 202207L
+
 template<class _Rp, class _Gp, class ..._Ap>
 struct __strip_signature<_Rp (_Gp::*) (_Ap...)> { using type = _Rp(_Ap...); };
 template<class _Rp, class _Gp, class ..._Ap>
Index: libcxx/docs/Status/Cxx2bPapers.csv
===================================================================
--- libcxx/docs/Status/Cxx2bPapers.csv
+++ libcxx/docs/Status/Cxx2bPapers.csv
@@ -53,7 +53,7 @@
 "","","","","",""
 "`P0009R18 <https://wg21.link/P0009R18>`__","LWG","mdspan: A Non-Owning Multidimensional Array Reference","July 2022","",""
 "`P0429R9 <https://wg21.link/P0429R9>`__","LWG","A Standard ``flat_map``","July 2022","",""
-"`P1169R4 <https://wg21.link/P1169R4>`__","LWG","``static operator()``","July 2022","",""
+"`P1169R4 <https://wg21.link/P1169R4>`__","LWG","``static operator()``","July 2022","|Complete|","16.0"
 "`P1222R4 <https://wg21.link/P1222R4>`__","LWG","A Standard ``flat_set``","July 2022","",""
 "`P1223R5 <https://wg21.link/P1223R5>`__","LWG","``ranges::find_last()``, ``ranges::find_last_if()``, and ``ranges::find_last_if_not()``","July 2022","",""
 "`P1467R9 <https://wg21.link/P1467R9>`__","LWG","Extended ``floating-point`` types and standard names","July 2022","",""
Index: libcxx/docs/ReleaseNotes.rst
===================================================================
--- libcxx/docs/ReleaseNotes.rst
+++ libcxx/docs/ReleaseNotes.rst
@@ -42,6 +42,7 @@
 - P2445R1 - ``std::forward_like``
 - P2273R3 - Making ``std::unique_ptr`` constexpr
 - P0591R4 - Utility functions to implement uses-allocator construction
+- P1169R4 - ``static operator()``
 
 Improvements and New Features
 -----------------------------


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135016.464509.patch
Type: text/x-patch
Size: 3785 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20221001/c9c84d94/attachment.bin>


More information about the libcxx-commits mailing list