[libcxx-commits] [libcxx] b66a6e4 - [libc++] Add minor test for polymorphic_allocator.construct with mixed argument pair
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Mar 29 14:02:51 PDT 2023
Author: Louis Dionne
Date: 2023-03-29T17:02:26-04:00
New Revision: b66a6e4b104b245ed448e3dea944fa7e842a96b2
URL: https://github.com/llvm/llvm-project/commit/b66a6e4b104b245ed448e3dea944fa7e842a96b2
DIFF: https://github.com/llvm/llvm-project/commit/b66a6e4b104b245ed448e3dea944fa7e842a96b2.diff
LOG: [libc++] Add minor test for polymorphic_allocator.construct with mixed argument pair
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..75bfe6f97da72 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,15 +25,16 @@
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)];
@@ -45,5 +46,20 @@ int main(int, char**) {
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;
+ a.construct(ptr);
+ assert(constructed == 2);
+ assert(ptr->first.x == 42);
+ assert(ptr->second.x == 42);
+ }
+
return 0;
}
More information about the libcxx-commits
mailing list