diff options
Diffstat (limited to 'libcxx/include/string')
-rw-r--r-- | libcxx/include/string | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/libcxx/include/string b/libcxx/include/string index 0c9f1cf1b2b..383b5c072ec 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -956,6 +956,8 @@ public: void resize(size_type __n, value_type __c); _LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, value_type());} + _LIBCPP_INLINE_VISIBILITY void __resize_default_init(size_type __n); + void reserve(size_type __res_arg = 0); _LIBCPP_INLINE_VISIBILITY void shrink_to_fit() _NOEXCEPT {reserve();} @@ -1010,6 +1012,10 @@ public: basic_string& append(const value_type* __s, size_type __n); basic_string& append(const value_type* __s); basic_string& append(size_type __n, value_type __c); + + _LIBCPP_INLINE_VISIBILITY + void __append_default_init(size_type __n); + template <class _ForwardIterator> _LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS basic_string& __append_forward_unsafe(_ForwardIterator, _ForwardIterator); @@ -2428,6 +2434,23 @@ basic_string<_CharT, _Traits, _Allocator>::append(size_type __n, value_type __c) } template <class _CharT, class _Traits, class _Allocator> +inline void +basic_string<_CharT, _Traits, _Allocator>::__append_default_init(size_type __n) +{ + if (__n) + { + size_type __cap = capacity(); + size_type __sz = size(); + if (__cap - __sz < __n) + __grow_by(__cap, __sz + __n - __cap, __sz, __sz, 0); + pointer __p = __get_pointer(); + __sz += __n; + __set_size(__sz); + traits_type::assign(__p[__sz], value_type()); + } +} + +template <class _CharT, class _Traits, class _Allocator> void basic_string<_CharT, _Traits, _Allocator>::push_back(value_type __c) { @@ -3083,6 +3106,17 @@ basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c) } template <class _CharT, class _Traits, class _Allocator> +inline void +basic_string<_CharT, _Traits, _Allocator>::__resize_default_init(size_type __n) +{ + size_type __sz = size(); + if (__n > __sz) { + __append_default_init(__n - __sz); + } else + __erase_to_end(__n); +} + +template <class _CharT, class _Traits, class _Allocator> inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT |