[libcxx-commits] [libcxx] af4b261 - [libc++] Add minor test for polymorphic_allocator.construct with mixed argument pair

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Mar 30 07:36:02 PDT 2023


Author: Louis Dionne
Date: 2023-03-30T10:35:52-04:00
New Revision: af4b2617e32c09d5a0b8c6d6f0ab44e7b3629f44

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

LOG: [libc++] Add minor test for polymorphic_allocator.construct with mixed argument pair

Re-applying the patch after fixing an issue.

Added: 
    

Modified: 
    libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/construct_pair.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/construct_pair.pass.cpp b/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/construct_pair.pass.cpp
index 4677bf00f1958..eafbc46605e54 100644
--- a/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/construct_pair.pass.cpp
+++ b/libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/construct_pair.pass.cpp
@@ -25,20 +25,38 @@
 
 int constructed = 0;
 
+template <int>
 struct default_constructible {
   default_constructible() : x(42) { ++constructed; }
   int x = 0;
 };
 
 int main(int, char**) {
-  // pair<default_constructible, default_constructible> as T()
+  // pair<default_constructible, default_constructible>
   {
-    typedef default_constructible T;
+    typedef default_constructible<0> T;
     typedef std::pair<T, T> P;
     typedef std::pmr::polymorphic_allocator<void> A;
     alignas(P) char buffer[sizeof(P)];
     P* ptr = reinterpret_cast<P*>(buffer);
     A a;
+    constructed = 0;
+    a.construct(ptr);
+    assert(constructed == 2);
+    assert(ptr->first.x == 42);
+    assert(ptr->second.x == 42);
+  }
+
+  // pair<default_constructible<0>, default_constructible<1>>
+  {
+    typedef default_constructible<0> T;
+    typedef default_constructible<1> U;
+    typedef std::pair<T, U> P;
+    typedef std::pmr::polymorphic_allocator<void> A;
+    alignas(P) char buffer[sizeof(P)];
+    P* ptr = reinterpret_cast<P*>(buffer);
+    A a;
+    constructed = 0;
     a.construct(ptr);
     assert(constructed == 2);
     assert(ptr->first.x == 42);


        


More information about the libcxx-commits mailing list