Skip to content

Commit 428b320

Browse files
authored
[libc++] Fix allocate_at_least test that assumes the size_type of the allocator (#131682)
If the size_type of the allocator is not the same as std::size_t, this test would fail.
1 parent 23743f5 commit 428b320

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_at_least.pass.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,18 @@ struct has_allocate_at_least {
4545
constexpr bool test() {
4646
{ // check that std::allocate_at_least forwards to allocator::allocate if no allocate_at_least exists
4747
no_allocate_at_least<int> alloc;
48-
std::same_as<std::allocation_result<int*>> decltype(auto) ret =
49-
std::allocator_traits<decltype(alloc)>::allocate_at_least(alloc, 1);
48+
using AllocTraits = std::allocator_traits<decltype(alloc)>;
49+
std::same_as<std::allocation_result<int*, AllocTraits::size_type>> decltype(auto) ret =
50+
AllocTraits::allocate_at_least(alloc, 1);
5051
assert(ret.count == 1);
5152
assert(ret.ptr == &alloc.t);
5253
}
5354

5455
{ // check that std::allocate_at_least forwards to allocator::allocate_at_least if allocate_at_least exists
5556
has_allocate_at_least<int> alloc;
56-
std::same_as<std::allocation_result<int*>> decltype(auto) ret =
57-
std::allocator_traits<decltype(alloc)>::allocate_at_least(alloc, 1);
57+
using AllocTraits = std::allocator_traits<decltype(alloc)>;
58+
std::same_as<std::allocation_result<int*, AllocTraits::size_type>> decltype(auto) ret =
59+
AllocTraits::allocate_at_least(alloc, 1);
5860
assert(ret.count == 2);
5961
assert(ret.ptr == &alloc.t2);
6062
}

0 commit comments

Comments
 (0)