[libcxx-commits] [libcxx] 8697d6c - [libcxx] Add compatible with constraint tests for some shared_ptr constructors.

via libcxx-commits libcxx-commits at lists.llvm.org
Sat Aug 1 12:07:32 PDT 2020


Author: zoecarver
Date: 2020-08-01T12:06:31-07:00
New Revision: 8697d6cfa8947c4033dfe1d2ac708482d75a28d4

URL: https://github.com/llvm/llvm-project/commit/8697d6cfa8947c4033dfe1d2ac708482d75a28d4
DIFF: https://github.com/llvm/llvm-project/commit/8697d6cfa8947c4033dfe1d2ac708482d75a28d4.diff

LOG: [libcxx] Add compatible with constraint tests for some shared_ptr constructors.

Add shared_ptr tests where the element type and pointer type aren't 'convertible' but are 'compatible'.

Responding to a comment from D81414.

Differential Revision: https://reviews.llvm.org/D81532

Added: 
    

Modified: 
    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

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp
index bb41fa89be37..e736eb57e056 100644
--- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp
+++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp
@@ -28,6 +28,9 @@ struct A
 
 int A::count = 0;
 
+struct Base { };
+struct Derived : Base { };
+
 int main(int, char**)
 {
     {
@@ -46,5 +49,11 @@ int main(int, char**)
     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;
 }

diff  --git a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp
index e17ae6f34312..af9bfe9ab057 100644
--- a/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp
+++ b/libcxx/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp
@@ -28,6 +28,8 @@ struct A
 
 int A::count = 0;
 
+struct Base { };
+struct Derived : Base { };
 
 int main(int, char**)
 {
@@ -87,5 +89,13 @@ int main(int, char**)
     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;
 }


        


More information about the libcxx-commits mailing list