@@ -34,7 +34,7 @@ inline constexpr ::fast_io::basic_allocation_least_result<chtype *> string_alloc
3434 // n is not possible to SIZE_MAX since that would overflow the memory which is not possible
3535 ::std::size_t const np1{static_cast <::std::size_t >(n + 1u )};
3636 auto [ptr, allocn]{typed_allocator_type::allocate_at_least (np1)};
37- ::std::construct_at (:: fast_io::freestanding::non_overlapped_copy_n(first, n, ptr), chtype{}) ;
37+ *:: fast_io::freestanding::non_overlapped_copy_n (first, n, ptr) = 0 ;
3838 return {ptr, static_cast <::std::size_t >(allocn - 1u )};
3939}
4040
@@ -54,17 +54,36 @@ inline constexpr void string_heap_dilate_uncheck(::fast_io::containers::details:
5454 {
5555 beginptr = nullptr ;
5656 }
57- if constexpr (typed_allocator_type::has_reallocate)
57+ #if __cpp_constexpr_dynamic_alloc >= 201907L
58+ if consteval
5859 {
59- auto [newptr, newcap] = typed_allocator_type::reallocate_at_least (beginptr, rsize + 1u );
60+ auto [newptr, newcap] = typed_allocator_type::allocate_at_least (rsize + 1u );
61+ if (beginptr != nullptr )
62+ {
63+ for (::std::size_t i{}; i != strsize; ++i)
64+ {
65+ ::std::construct_at (newptr + i, beginptr[i]);
66+ }
67+ typed_allocator_type::deallocate_n (beginptr, bfsize);
68+ }
6069 ptr = newptr;
6170 rsize = newcap - 1u ;
6271 }
6372 else
73+ #endif
6474 {
65- auto [newptr, newcap] = typed_allocator_type::reallocate_n_at_least (beginptr, bfsize, rsize + 1u );
66- ptr = newptr;
67- rsize = newcap - 1u ;
75+ if constexpr (typed_allocator_type::has_reallocate)
76+ {
77+ auto [newptr, newcap] = typed_allocator_type::reallocate_at_least (beginptr, rsize + 1u );
78+ ptr = newptr;
79+ rsize = newcap - 1u ;
80+ }
81+ else
82+ {
83+ auto [newptr, newcap] = typed_allocator_type::reallocate_n_at_least (beginptr, bfsize, rsize + 1u );
84+ ptr = newptr;
85+ rsize = newcap - 1u ;
86+ }
6887 }
6988 imp = {ptr, ptr + strsize, ptr + rsize};
7089}
0 commit comments