https://gcc.gnu.org/g:372ff3c0613e11b9fdeaaaa49bc3a40bda8e224b
commit r17-1770-g372ff3c0613e11b9fdeaaaa49bc3a40bda8e224b Author: Nathan Myers <[email protected]> Date: Mon Jun 22 19:03:31 2026 -0400 libstdc: check pmr traits allocate_at_least (P0401) [PR125890] 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. Diff: --- .../20_util/polymorphic_allocator/at_least.cc | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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 000000000000..4384645dde5a --- /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(); +}
