| 4345 | |
| 4346 | template <typename char_type_, typename allocator_> |
| 4347 | bool basic_string<char_type_, allocator_>::try_append(const_pointer str, size_type length) noexcept { |
| 4348 | auto result = _with_alloc([&](sz_alloc_type &alloc) { |
| 4349 | // Sometimes we are inserting part of this string into itself. |
| 4350 | // By the time `sz_string_expand` finished, the old `str` pointer may be invalidated, |
| 4351 | // so we need to handle that special case separately. |
| 4352 | auto this_span = span(); |
| 4353 | if (str >= this_span.begin() && str < this_span.end()) { |
| 4354 | auto str_offset_in_this = str - data(); |
| 4355 | sz_ptr_t start = sz_string_expand(&string_, SZ_SIZE_MAX, length, &alloc); |
| 4356 | if (!start) return sz_bad_alloc_k; |
| 4357 | sz_copy(start + this_span.size(), start + str_offset_in_this, length); |
| 4358 | } |
| 4359 | else { |
| 4360 | sz_ptr_t start = sz_string_expand(&string_, SZ_SIZE_MAX, length, &alloc); |
| 4361 | if (!start) return sz_bad_alloc_k; |
| 4362 | sz_copy(start + this_span.size(), str, length); |
| 4363 | } |
| 4364 | return sz_success_k; |
| 4365 | }); |
| 4366 | return result == status_t::success_k; |
| 4367 | } |
| 4368 | |
| 4369 | template <typename char_type_, typename allocator_> |
| 4370 | template <typename pattern_type> |
no test coverage detected