[libcxx-commits] [PATCH] D81532: [libcxx] Add compatible with constraint tests for some shared_ptr constructors.

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Aug 1 12:07:33 PDT 2020


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8697d6cfa894: [libcxx] Add compatible with constraint tests for some shared_ptr constructors. (authored by zoecarver).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81532/new/

https://reviews.llvm.org/D81532

Files:
  libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp
  libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp


Index: libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp
===================================================================
--- libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp
+++ libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp
@@ -28,6 +28,8 @@
 
 int A::count = 0;
 
+struct Base { };
+struct Derived : Base { };
 
 int main(int, char**)
 {
@@ -87,5 +89,13 @@
     assert(test_deleter<A>::dealloc_count == 1);
 #endif
 
+    {
+        // Make sure that we can construct a shared_ptr where the element type and pointer type
+        // aren't "convertible" but are "compatible".
+        static_assert(!std::is_constructible<std::shared_ptr<Derived[4]>,
+                                             Base[4], test_deleter<Derived[4]>,
+                                             test_allocator<Derived[4]> >::value, "");
+    }
+
   return 0;
 }
Index: libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp
===================================================================
--- libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp
+++ libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp
@@ -28,6 +28,9 @@
 
 int A::count = 0;
 
+struct Base { };
+struct Derived : Base { };
+
 int main(int, char**)
 {
     {
@@ -46,5 +49,11 @@
     assert(test_deleter<A>::count == 0);
     assert(test_deleter<A>::dealloc_count == 1);
 
+    {
+        // Make sure that we can construct a shared_ptr where the element type and pointer type
+        // aren't "convertible" but are "compatible".
+        static_assert(!std::is_constructible<std::shared_ptr<Derived[4]>, Base[4], test_deleter<Derived[4]> >::value, "");
+    }
+
   return 0;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81532.282408.patch
Type: text/x-patch
Size: 2081 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200801/c7affcd9/attachment.bin>


More information about the libcxx-commits mailing list