summaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/include/string
diff options
context:
space:
mode:
authorhalyavin <[email protected]>2023-09-26 11:14:38 +0300
committerhalyavin <[email protected]>2023-09-26 11:42:52 +0300
commit7fcf8b470c7f4b97acf6f2833afa770c1372f231 (patch)
treec7583ae7054d92eb5788c03760b6b9c50f7cc6c6 /contrib/libs/cxxsupp/libcxx/include/string
parent4c226ec97b09cd6fc38f8a0bbe57f52d384abe3f (diff)
Update libc++ to 9b03c08e (6 Mar 2022).
Notable changes: * don't warn that coroutines are not supported when using experimental/coroutine * add _LIBCPP_HIDE_FROM_ABI to __quoted_proxy constructors * ADL-proof calls of __quoted * fix ctype facet `is` method for Windows * change return type of bit_width to int (LWG3656) * make private __wrap_iter constructors explicit * fix delayed initialization of `__fill_` in basic_ios * ranges::iter_move cleanup * ADL-proof __synth_three_way * reject random number generators with signed types * use C++ overloads from math.h on AIX * add explicit to some internal constructors * replace _LIBCPP_HAS_NO_STRONG_ENUMS with C++ version check * use `inline constexpr bool` instead of `constexpr bool` for helpers in ranges * reject uniform_int_distribution<bool>, uniform_int_distribution<char> and all user types * allow std::mergeable and std::sortable even with incomplete ranges * fix double close bug in std::filesystem::remove_all * remove recursion in basic_string::insert because it interferes with constexpr * fix error checking of wctob_l calls * pack _Flags class on AIX * fix integer type in __estimate_column_width exposed by AIX * qualify all std::move calls with std * make chrono includes granular * set std::numeric_limits::tinyness_before to true on ARM * add ranges::in_found_result and ranges::min_max_result
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/string')
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/string83
1 files changed, 42 insertions, 41 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/string b/contrib/libs/cxxsupp/libcxx/include/string
index a1bfff1f6a2..3fbb874e267 100644
--- a/contrib/libs/cxxsupp/libcxx/include/string
+++ b/contrib/libs/cxxsupp/libcxx/include/string
@@ -1465,12 +1465,35 @@ private:
return !__libcpp_is_constant_evaluated() && (__sz < __min_cap);
}
- _LIBCPP_INLINE_VISIBILITY
- allocator_type& __alloc() _NOEXCEPT
- {return __r_.second();}
- _LIBCPP_INLINE_VISIBILITY
- const allocator_type& __alloc() const _NOEXCEPT
- {return __r_.second();}
+ template <class _ForwardIterator>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
+ iterator __insert_from_safe_copy(size_type __n, size_type __ip, _ForwardIterator __first, _ForwardIterator __last) {
+ size_type __sz = size();
+ size_type __cap = capacity();
+ value_type* __p;
+ if (__cap - __sz >= __n)
+ {
+ __p = std::__to_address(__get_pointer());
+ size_type __n_move = __sz - __ip;
+ if (__n_move != 0)
+ traits_type::move(__p + __ip + __n, __p + __ip, __n_move);
+ }
+ else
+ {
+ __grow_by(__cap, __sz + __n - __cap, __sz, __ip, 0, __n);
+ __p = std::__to_address(__get_long_pointer());
+ }
+ __sz += __n;
+ __set_size(__sz);
+ traits_type::assign(__p[__sz], value_type());
+ for (__p += __ip; __first != __last; ++__p, ++__first)
+ traits_type::assign(*__p, *__first);
+
+ return begin() + __ip;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI allocator_type& __alloc() _NOEXCEPT { return __r_.second(); }
+ _LIBCPP_HIDE_FROM_ABI const allocator_type& __alloc() const _NOEXCEPT { return __r_.second(); }
#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
@@ -2814,45 +2837,23 @@ __enable_if_t
>
basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last)
{
- _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
- "string::insert(iterator, range) called with an iterator not"
- " referring to this string");
+ _LIBCPP_DEBUG_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this,
+ "string::insert(iterator, range) called with an iterator not referring to this string");
size_type __ip = static_cast<size_type>(__pos - begin());
- size_type __n = static_cast<size_type>(_VSTD::distance(__first, __last));
- if (__n)
+ size_type __n = static_cast<size_type>(std::distance(__first, __last));
+ if (__n == 0)
+ return begin() + __ip;
+
+ if (__string_is_trivial_iterator<_ForwardIterator>::value && !__addr_in_range(*__first))
{
- if (__string_is_trivial_iterator<_ForwardIterator>::value &&
- !__addr_in_range(*__first))
- {
- size_type __sz = size();
- size_type __cap = capacity();
- value_type* __p;
- if (__cap - __sz >= __n)
- {
- __p = _VSTD::__to_address(__get_pointer());
- size_type __n_move = __sz - __ip;
- if (__n_move != 0)
- traits_type::move(__p + __ip + __n, __p + __ip, __n_move);
- }
- else
- {
- __grow_by(__cap, __sz + __n - __cap, __sz, __ip, 0, __n);
- __p = _VSTD::__to_address(__get_long_pointer());
- }
- __sz += __n;
- __set_size(__sz);
- traits_type::assign(__p[__sz], value_type());
- for (__p += __ip; __first != __last; ++__p, (void) ++__first)
- traits_type::assign(*__p, *__first);
- }
- else
- {
- const basic_string __temp(__first, __last, __alloc());
- return insert(__pos, __temp.data(), __temp.data() + __temp.size());
- }
+ return __insert_from_safe_copy(__n, __ip, __first, __last);
+ }
+ else
+ {
+ const basic_string __temp(__first, __last, __alloc());
+ return __insert_from_safe_copy(__n, __ip, __temp.begin(), __temp.end());
}
- return begin() + __ip;
}
template <class _CharT, class _Traits, class _Allocator>