| 4270 | |
| 4271 | template <typename char_type_, typename allocator_> |
| 4272 | bool basic_string<char_type_, allocator_>::try_resize(size_type count, value_type character) noexcept { |
| 4273 | sz_ptr_t string_start; |
| 4274 | sz_size_t string_length; |
| 4275 | sz_size_t string_space; |
| 4276 | sz_bool_t string_is_external; |
| 4277 | sz_string_unpack(&string_, &string_start, &string_length, &string_space, &string_is_external); |
| 4278 | |
| 4279 | // Allocate more space if needed. |
| 4280 | if (count >= string_space) { |
| 4281 | if (_with_alloc([&](sz_alloc_type &alloc) { |
| 4282 | return sz_string_expand(&string_, SZ_SIZE_MAX, count - string_length, &alloc) ? sz_success_k |
| 4283 | : sz_bad_alloc_k; |
| 4284 | }) != status_t::success_k) |
| 4285 | return false; |
| 4286 | sz_string_unpack(&string_, &string_start, &string_length, &string_space, &string_is_external); |
| 4287 | } |
| 4288 | |
| 4289 | // Fill the trailing characters. |
| 4290 | if (count > string_length) { |
| 4291 | sz_fill(string_start + string_length, count - string_length, character); |
| 4292 | string_start[count] = '\0'; |
| 4293 | // Safe for both SSO and heap strings: on little-endian, internal.length |
| 4294 | // overlaps with LSB of external.length, so += affects only the length byte. |
| 4295 | // On big-endian, the struct layout places them at matching positions. |
| 4296 | string_.external.length += count - string_length; |
| 4297 | } |
| 4298 | else { sz_string_erase(&string_, count, SZ_SIZE_MAX); } |
| 4299 | return true; |
| 4300 | } |
| 4301 | |
| 4302 | template <typename char_type_, typename allocator_> |
| 4303 | bool basic_string<char_type_, allocator_>::try_assign(string_view other) noexcept { |
no test coverage detected