[PATCH] D53867: [libcxx] Implement http://wg21.link/p1006, constexpr in pointer_traits

Louis Dionne via Phabricator reviews at reviews.llvm.org
Tue Oct 30 08:27:50 PDT 2018


ldionne updated this revision to Diff 171708.
ldionne added a comment.

Add link in upcoming_meeting.html


Repository:
  rCXX libc++

https://reviews.llvm.org/D53867

Files:
  libcxx/include/memory
  libcxx/test/std/utilities/memory/pointer.traits/pointer_to.pass.cpp
  libcxx/www/upcoming_meeting.html


Index: libcxx/www/upcoming_meeting.html
===================================================================
--- libcxx/www/upcoming_meeting.html
+++ libcxx/www/upcoming_meeting.html
@@ -54,7 +54,7 @@
 	<tr><td><a href="https://wg21.link/P0655R0">P0655R0</a></td><td>LWG</td><td>visit<R>: Explicit Return Type for visit</td><td>San Diego</td><td><i> </i></td></tr>
 	<tr><td><a href="https://wg21.link/P0972R0">P0972R0</a></td><td>LWG</td><td><chrono> zero(), min(), and max() should be noexcept</td><td>San Diego</td><td>See <a href="https://reviews.llvm.org/D53828">D53828</a></td></tr>
 	<tr><td><a href="https://wg21.link/P1004R0">P1004R0</a></td><td>LWG</td><td>Making std::vector constexpr</td><td>San Diego</td><td><i> </i></td></tr>
-	<tr><td><a href="https://wg21.link/P1006R0">P1006R0</a></td><td>LWG</td><td>Constexpr in std::pointer_traits</td><td>San Diego</td><td><i> </i></td></tr>
+	<tr><td><a href="https://wg21.link/P1006R0">P1006R0</a></td><td>LWG</td><td>Constexpr in std::pointer_traits</td><td>San Diego</td><td>See <a href="https://reviews.llvm.org/D53867">D53867</a></td></tr>
 	<tr><td><a href="https://wg21.link/P1032R0">P1032R0</a></td><td>LWG</td><td>Misc constexpr bits</td><td>San Diego</td><td><i> </i></td></tr>
 	<tr><td><a href="http://wiki.edg.com/pub/LWGBatavia2018/LibraryWorkingGroup/D1148R0a.pdf">D1148</a></td><td>LWG</td><td>Cleaning up Clause 20</td><td>San Diego</td><td><i> </i></td></tr>
 	<tr><td><a href="http://wiki.edg.com/pub/LWGBatavia2018/LibraryWorkingGroup/D1163R0V2.pdf">D1163</a></td><td>LWG</td><td>Explicitly Implicifying explicit Constructors</td><td>San Diego</td><td><i> </i></td></tr>
Index: libcxx/test/std/utilities/memory/pointer.traits/pointer_to.pass.cpp
===================================================================
--- libcxx/test/std/utilities/memory/pointer.traits/pointer_to.pass.cpp
+++ libcxx/test/std/utilities/memory/pointer.traits/pointer_to.pass.cpp
@@ -12,15 +12,18 @@
 // template <class T>
 // struct pointer_traits<T*>
 // {
-//     static pointer pointer_to(<details>);
+//     constexpr static pointer pointer_to(<details>);
 //     ...
 // };
 
 #include <memory>
 #include <cassert>
+#include "test_macros.h"
 
-int main()
-{
+#if TEST_STD_VER >= 20
+constexpr
+#endif
+bool check() {
     {
         int i = 0;
         static_assert((std::is_same<int *, decltype(std::pointer_traits<int*>::pointer_to(i))>::value), "");
@@ -30,4 +33,12 @@
     {
         (std::pointer_traits<void*>::element_type)0;
     }
+    return true;
+}
+
+int main() {
+    check();
+#if TEST_STD_VER >= 20
+    static_assert(check(), "");
+#endif
 }
Index: libcxx/include/memory
===================================================================
--- libcxx/include/memory
+++ libcxx/include/memory
@@ -43,7 +43,7 @@
 
     template <class U> using rebind = U*;
 
-    static pointer pointer_to(<details>) noexcept;
+    static constexpr pointer pointer_to(<details>) noexcept;
 };
 
 template <class T> constexpr T* to_address(T* p) noexcept; // C++20
@@ -984,7 +984,7 @@
 private:
     struct __nat {};
 public:
-    _LIBCPP_INLINE_VISIBILITY
+    _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
     static pointer pointer_to(typename conditional<is_void<element_type>::value,
                                       __nat, element_type>::type& __r) _NOEXCEPT
         {return _VSTD::addressof(__r);}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53867.171708.patch
Type: text/x-patch
Size: 3392 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20181030/fa32a5db/attachment.bin>


More information about the libcxx-commits mailing list