diff --git a/libcxx/include/string b/libcxx/include/string --- a/libcxx/include/string +++ b/libcxx/include/string @@ -4165,10 +4165,11 @@ const basic_string<_CharT, _Traits, _Allocator>& __rhs) { using _String = basic_string<_CharT, _Traits, _Allocator>; - _String __r(_String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator())); typename _String::size_type __lhs_sz = __lhs.size(); typename _String::size_type __rhs_sz = __rhs.size(); - __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz); + _String __r(_String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator())); + __r.reserve(__lhs_sz + __rhs_sz); + __r.append(__lhs.data(), __lhs_sz); __r.append(__rhs.data(), __rhs_sz); return __r; } @@ -4178,10 +4179,11 @@ operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs) { using _String = basic_string<_CharT, _Traits, _Allocator>; - _String __r(_String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator())); typename _String::size_type __lhs_sz = _Traits::length(__lhs); typename _String::size_type __rhs_sz = __rhs.size(); - __r.__init(__lhs, __lhs_sz, __lhs_sz + __rhs_sz); + _String __r(_String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator())); + __r.reserve(__lhs_sz + __rhs_sz); + __r.append(__lhs, __lhs_sz); __r.append(__rhs.data(), __rhs_sz); return __r; } @@ -4191,9 +4193,10 @@ operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs) { using _String = basic_string<_CharT, _Traits, _Allocator>; - _String __r(_String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator())); typename _String::size_type __rhs_sz = __rhs.size(); - __r.__init(&__lhs, 1, 1 + __rhs_sz); + _String __r(_String::__alloc_traits::select_on_container_copy_construction(__rhs.get_allocator())); + __r.reserve(__rhs_sz + 1); + __r.push_back(__lhs); __r.append(__rhs.data(), __rhs_sz); return __r; } @@ -4204,10 +4207,11 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) { using _String = basic_string<_CharT, _Traits, _Allocator>; - _String __r(_String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator())); typename _String::size_type __lhs_sz = __lhs.size(); typename _String::size_type __rhs_sz = _Traits::length(__rhs); - __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz); + _String __r(_String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator())); + __r.reserve(__lhs_sz + __rhs_sz); + __r.append(__lhs.data(), __lhs_sz); __r.append(__rhs, __rhs_sz); return __r; } @@ -4217,9 +4221,10 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs) { using _String = basic_string<_CharT, _Traits, _Allocator>; - _String __r(_String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator())); typename _String::size_type __lhs_sz = __lhs.size(); - __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + 1); + _String __r(_String::__alloc_traits::select_on_container_copy_construction(__lhs.get_allocator())); + __r.reserve(__lhs_sz + 1); + __r.append(__lhs.data(), __lhs_sz); __r.push_back(__rhs); return __r; }