Add check that the specialization of std::allocator_traits on
pmr::polymorphic_allocator<T> defines allocate_at_least.

libstdc++-v3/Changelog:
        PR libstdc++/125890
        * testsuite/20_util/polymorphic_allocator/at_least.cc: New test.
---
 .../20_util/polymorphic_allocator/at_least.cc | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 
libstdc++-v3/testsuite/20_util/polymorphic_allocator/at_least.cc

diff --git a/libstdc++-v3/testsuite/20_util/polymorphic_allocator/at_least.cc 
b/libstdc++-v3/testsuite/20_util/polymorphic_allocator/at_least.cc
new file mode 100644
index 00000000000..4384645dde5
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/polymorphic_allocator/at_least.cc
@@ -0,0 +1,24 @@
+// { dg-do run { target c++23 } }
+
+#include <memory_resource>
+#include <testsuite_hooks.h>
+
+void
+alloc_at_least()
+{
+  struct A { char a; };
+  using alloc_A = std::pmr::polymorphic_allocator<A>;
+  using traits_A = std::allocator_traits<alloc_A>;
+  alloc_A alloc_a;
+  // This just forwards to alloc_a::allocate:
+  std::allocation_result result = traits_A::allocate_at_least(alloc_a, 1);
+  VERIFY(result.count == 1);
+  VERIFY(result.ptr != nullptr);
+  auto [pointer, count] = result;
+  traits_A::deallocate(alloc_a, pointer, count);
+}
+
+int main()
+{
+  alloc_at_least();
+}
-- 
2.54.0

Reply via email to