|
19 | 19 |
|
20 | 20 | _LIBCPP_BEGIN_NAMESPACE_STD |
21 | 21 |
|
| 22 | +template <class _Pointer, class _SizeT = size_t> |
| 23 | +struct __allocation_result { |
| 24 | + _Pointer ptr; |
| 25 | + _SizeT count; |
| 26 | + |
| 27 | + _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR __allocation_result(_Pointer __ptr, _SizeT __count) |
| 28 | + : ptr(__ptr), count(__count) {} |
| 29 | +}; |
| 30 | +_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(__allocation_result); |
| 31 | + |
22 | 32 | #if _LIBCPP_STD_VER >= 23 |
23 | 33 |
|
24 | 34 | template <class _Alloc> |
25 | 35 | [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto __allocate_at_least(_Alloc& __alloc, size_t __n) { |
26 | | - return std::allocator_traits<_Alloc>::allocate_at_least(__alloc, __n); |
| 36 | + auto __res = std::allocator_traits<_Alloc>::allocate_at_least(__alloc, __n); |
| 37 | + return __allocation_result{__res.ptr, __res.count}; |
27 | 38 | } |
28 | 39 |
|
29 | 40 | #else |
30 | 41 |
|
31 | | -template <class _Pointer> |
32 | | -struct __allocation_result { |
33 | | - _Pointer ptr; |
34 | | - size_t count; |
35 | | -}; |
36 | | - |
37 | | -template <class _Alloc> |
| 42 | +template <class _Alloc, class _Traits = allocator_traits<_Alloc> > |
38 | 43 | [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI |
39 | | -_LIBCPP_CONSTEXPR __allocation_result<typename allocator_traits<_Alloc>::pointer> |
| 44 | +_LIBCPP_CONSTEXPR __allocation_result<typename _Traits::pointer, typename _Traits::size_type> |
40 | 45 | __allocate_at_least(_Alloc& __alloc, size_t __n) { |
41 | | - return {__alloc.allocate(__n), __n}; |
| 46 | + return __allocation_result<typename _Traits::pointer, typename _Traits::size_type>(__alloc.allocate(__n), __n); |
42 | 47 | } |
43 | 48 |
|
44 | 49 | #endif // _LIBCPP_STD_VER >= 23 |
|
0 commit comments