34 #ifndef _BASIC_STRING_H 35 #define _BASIC_STRING_H 1 37 #pragma GCC system_header 43 #if __cplusplus >= 201103L 47 #if __cplusplus > 201402L 51 namespace std _GLIBCXX_VISIBILITY(default)
53 _GLIBCXX_BEGIN_NAMESPACE_VERSION
55 #if __cplusplus >= 201703L 57 # define __cpp_lib_constexpr_string 201611L 60 #if _GLIBCXX_USE_CXX11_ABI 61 _GLIBCXX_BEGIN_NAMESPACE_CXX11
80 template<
typename _CharT,
typename _Traits,
typename _Alloc>
84 rebind<_CharT>::other _Char_alloc_type;
89 typedef _Traits traits_type;
90 typedef typename _Traits::char_type value_type;
91 typedef _Char_alloc_type allocator_type;
92 typedef typename _Alloc_traits::size_type size_type;
93 typedef typename _Alloc_traits::difference_type difference_type;
94 typedef typename _Alloc_traits::reference reference;
95 typedef typename _Alloc_traits::const_reference const_reference;
96 typedef typename _Alloc_traits::pointer pointer;
97 typedef typename _Alloc_traits::const_pointer const_pointer;
98 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
99 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
105 static const size_type
npos =
static_cast<size_type
>(-1);
109 #if __cplusplus < 201103L 110 typedef iterator __const_iterator;
112 typedef const_iterator __const_iterator;
115 #if __cplusplus > 201402L 117 typedef basic_string_view<_CharT, _Traits> __sv_type;
119 template<
typename _Tp,
typename _Res>
121 __and_<is_convertible<const _Tp&, __sv_type>,
122 __not_<is_convertible<const _Tp*, const basic_string*>>,
123 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
128 _S_to_string_view(__sv_type __svt) noexcept
137 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
143 struct _Alloc_hider : allocator_type
145 #if __cplusplus < 201103L 146 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
147 : allocator_type(__a), _M_p(__dat) { }
149 _Alloc_hider(pointer __dat,
const _Alloc& __a)
150 : allocator_type(__a), _M_p(__dat) { }
152 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
153 : allocator_type(
std::move(__a)), _M_p(__dat) { }
159 _Alloc_hider _M_dataplus;
160 size_type _M_string_length;
162 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
166 _CharT _M_local_buf[_S_local_capacity + 1];
167 size_type _M_allocated_capacity;
172 { _M_dataplus._M_p = __p; }
175 _M_length(size_type __length)
176 { _M_string_length = __length; }
180 {
return _M_dataplus._M_p; }
185 #if __cplusplus >= 201103L 188 return pointer(_M_local_buf);
193 _M_local_data()
const 195 #if __cplusplus >= 201103L 198 return const_pointer(_M_local_buf);
203 _M_capacity(size_type __capacity)
204 { _M_allocated_capacity = __capacity; }
207 _M_set_length(size_type __n)
210 traits_type::assign(_M_data()[__n], _CharT());
215 {
return _M_data() == _M_local_data(); }
219 _M_create(size_type&, size_type);
225 _M_destroy(_M_allocated_capacity);
229 _M_destroy(size_type __size)
throw()
230 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
234 template<
typename _InIterator>
236 _M_construct_aux(_InIterator __beg, _InIterator __end,
239 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
240 _M_construct(__beg, __end, _Tag());
245 template<
typename _Integer>
247 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
248 { _M_construct_aux_2(static_cast<size_type>(__beg), __end); }
251 _M_construct_aux_2(size_type __req, _CharT __c)
252 { _M_construct(__req, __c); }
254 template<
typename _InIterator>
256 _M_construct(_InIterator __beg, _InIterator __end)
258 typedef typename std::__is_integer<_InIterator>::__type _Integral;
259 _M_construct_aux(__beg, __end, _Integral());
263 template<
typename _InIterator>
265 _M_construct(_InIterator __beg, _InIterator __end,
270 template<
typename _FwdIterator>
272 _M_construct(_FwdIterator __beg, _FwdIterator __end,
276 _M_construct(size_type __req, _CharT __c);
280 {
return _M_dataplus; }
282 const allocator_type&
283 _M_get_allocator()
const 284 {
return _M_dataplus; }
288 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 291 template<
typename _Tp,
bool _Requires =
292 !__are_same<_Tp, _CharT*>::__value
293 && !__are_same<_Tp, const _CharT*>::__value
294 && !__are_same<_Tp, iterator>::__value
295 && !__are_same<_Tp, const_iterator>::__value>
296 struct __enable_if_not_native_iterator
298 template<
typename _Tp>
299 struct __enable_if_not_native_iterator<_Tp, false> { };
303 _M_check(size_type __pos,
const char* __s)
const 305 if (__pos > this->
size())
306 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 307 "this->size() (which is %zu)"),
308 __s, __pos, this->
size());
313 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 316 __throw_length_error(__N(__s));
322 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
324 const bool __testoff = __off < this->
size() - __pos;
325 return __testoff ? __off : this->
size() - __pos;
330 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
332 return (less<const _CharT*>()(__s, _M_data())
333 || less<const _CharT*>()(_M_data() + this->
size(), __s));
339 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
342 traits_type::assign(*__d, *__s);
344 traits_type::copy(__d, __s, __n);
348 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
351 traits_type::assign(*__d, *__s);
353 traits_type::move(__d, __s, __n);
357 _S_assign(_CharT* __d, size_type __n, _CharT __c)
360 traits_type::assign(*__d, __c);
362 traits_type::assign(__d, __n, __c);
367 template<
class _Iterator>
369 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
371 for (; __k1 != __k2; ++__k1, (void)++__p)
372 traits_type::assign(*__p, *__k1);
376 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
377 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
380 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
382 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
385 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
386 { _S_copy(__p, __k1, __k2 - __k1); }
389 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
391 { _S_copy(__p, __k1, __k2 - __k1); }
394 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
396 const difference_type __d = difference_type(__n1 - __n2);
398 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
399 return __gnu_cxx::__numeric_traits<int>::__max;
400 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
401 return __gnu_cxx::__numeric_traits<int>::__min;
410 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
414 _M_erase(size_type __pos, size_type __n);
425 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
426 : _M_dataplus(_M_local_data())
427 { _M_set_length(0); }
434 : _M_dataplus(_M_local_data(), __a)
435 { _M_set_length(0); }
442 : _M_dataplus(_M_local_data(),
443 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
444 { _M_construct(__str._M_data(), __str._M_data() + __str.length()); }
455 const _Alloc& __a = _Alloc())
456 : _M_dataplus(_M_local_data(), __a)
458 const _CharT* __start = __str._M_data()
459 + __str._M_check(__pos,
"basic_string::basic_string");
460 _M_construct(__start, __start + __str._M_limit(__pos,
npos));
471 : _M_dataplus(_M_local_data())
473 const _CharT* __start = __str._M_data()
474 + __str._M_check(__pos,
"basic_string::basic_string");
475 _M_construct(__start, __start + __str._M_limit(__pos, __n));
486 size_type __n,
const _Alloc& __a)
487 : _M_dataplus(_M_local_data(), __a)
489 const _CharT* __start
490 = __str._M_data() + __str._M_check(__pos,
"string::string");
491 _M_construct(__start, __start + __str._M_limit(__pos, __n));
504 const _Alloc& __a = _Alloc())
505 : _M_dataplus(_M_local_data(), __a)
506 { _M_construct(__s, __s + __n); }
513 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS 516 template<
typename = _RequireAllocator<_Alloc>>
518 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
519 : _M_dataplus(_M_local_data(), __a)
520 { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+
npos); }
528 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS 531 template<
typename = _RequireAllocator<_Alloc>>
533 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
534 : _M_dataplus(_M_local_data(), __a)
535 { _M_construct(__n, __c); }
537 #if __cplusplus >= 201103L 546 : _M_dataplus(_M_local_data(), std::move(__str._M_get_allocator()))
548 if (__str._M_is_local())
550 traits_type::copy(_M_local_buf, __str._M_local_buf,
551 _S_local_capacity + 1);
555 _M_data(__str._M_data());
556 _M_capacity(__str._M_allocated_capacity);
562 _M_length(__str.length());
563 __str._M_data(__str._M_local_data());
564 __str._M_set_length(0);
572 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
573 : _M_dataplus(_M_local_data(), __a)
574 { _M_construct(__l.begin(), __l.end()); }
577 : _M_dataplus(_M_local_data(), __a)
578 { _M_construct(__str.begin(), __str.end()); }
581 noexcept(_Alloc_traits::_S_always_equal())
582 : _M_dataplus(_M_local_data(), __a)
584 if (__str._M_is_local())
586 traits_type::copy(_M_local_buf, __str._M_local_buf,
587 _S_local_capacity + 1);
588 _M_length(__str.length());
589 __str._M_set_length(0);
591 else if (_Alloc_traits::_S_always_equal()
592 || __str.get_allocator() == __a)
594 _M_data(__str._M_data());
595 _M_length(__str.length());
596 _M_capacity(__str._M_allocated_capacity);
597 __str._M_data(__str._M_local_buf);
598 __str._M_set_length(0);
601 _M_construct(__str.begin(), __str.end());
612 #if __cplusplus >= 201103L 613 template<
typename _InputIterator,
614 typename = std::_RequireInputIter<_InputIterator>>
616 template<
typename _InputIterator>
618 basic_string(_InputIterator __beg, _InputIterator __end,
619 const _Alloc& __a = _Alloc())
620 : _M_dataplus(_M_local_data(), __a)
621 { _M_construct(__beg, __end); }
623 #if __cplusplus > 201402L 631 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
632 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
633 const _Alloc& __a = _Alloc())
641 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
643 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
644 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
670 #if __cplusplus >= 201103L 671 if (_Alloc_traits::_S_propagate_on_copy_assign())
673 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
674 && _M_get_allocator() != __str._M_get_allocator())
678 if (__str.size() <= _S_local_capacity)
680 _M_destroy(_M_allocated_capacity);
681 _M_data(_M_local_data());
686 const auto __len = __str.size();
687 auto __alloc = __str._M_get_allocator();
689 auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1);
690 _M_destroy(_M_allocated_capacity);
693 _M_set_length(__len);
696 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
699 return this->
assign(__str);
708 {
return this->
assign(__s); }
724 #if __cplusplus >= 201103L 737 noexcept(_Alloc_traits::_S_nothrow_move())
739 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
740 && !_Alloc_traits::_S_always_equal()
741 && _M_get_allocator() != __str._M_get_allocator())
744 _M_destroy(_M_allocated_capacity);
745 _M_data(_M_local_data());
749 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
751 if (__str._M_is_local())
755 this->_S_copy(_M_data(), __str._M_data(), __str.size());
756 _M_set_length(__str.size());
758 else if (_Alloc_traits::_S_propagate_on_move_assign()
759 || _Alloc_traits::_S_always_equal()
760 || _M_get_allocator() == __str._M_get_allocator())
763 pointer __data =
nullptr;
764 size_type __capacity;
767 if (_Alloc_traits::_S_always_equal())
771 __capacity = _M_allocated_capacity;
774 _M_destroy(_M_allocated_capacity);
777 _M_data(__str._M_data());
778 _M_length(__str.length());
779 _M_capacity(__str._M_allocated_capacity);
782 __str._M_data(__data);
783 __str._M_capacity(__capacity);
786 __str._M_data(__str._M_local_buf);
801 this->
assign(__l.begin(), __l.size());
806 #if __cplusplus > 201402L 811 template<
typename _Tp>
812 _If_sv<_Tp, basic_string&>
814 {
return this->
assign(__svt); }
820 operator __sv_type() const noexcept
821 {
return __sv_type(
data(),
size()); }
830 begin() _GLIBCXX_NOEXCEPT
831 {
return iterator(_M_data()); }
838 begin() const _GLIBCXX_NOEXCEPT
839 {
return const_iterator(_M_data()); }
846 end() _GLIBCXX_NOEXCEPT
847 {
return iterator(_M_data() + this->
size()); }
854 end() const _GLIBCXX_NOEXCEPT
855 {
return const_iterator(_M_data() + this->
size()); }
863 rbegin() _GLIBCXX_NOEXCEPT
864 {
return reverse_iterator(this->
end()); }
871 const_reverse_iterator
872 rbegin() const _GLIBCXX_NOEXCEPT
873 {
return const_reverse_iterator(this->
end()); }
881 rend() _GLIBCXX_NOEXCEPT
882 {
return reverse_iterator(this->
begin()); }
889 const_reverse_iterator
890 rend() const _GLIBCXX_NOEXCEPT
891 {
return const_reverse_iterator(this->
begin()); }
893 #if __cplusplus >= 201103L 900 {
return const_iterator(this->_M_data()); }
907 cend() const noexcept
908 {
return const_iterator(this->_M_data() + this->
size()); }
915 const_reverse_iterator
917 {
return const_reverse_iterator(this->
end()); }
924 const_reverse_iterator
925 crend() const noexcept
926 {
return const_reverse_iterator(this->
begin()); }
934 size() const _GLIBCXX_NOEXCEPT
935 {
return _M_string_length; }
940 length() const _GLIBCXX_NOEXCEPT
941 {
return _M_string_length; }
946 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
959 resize(size_type __n, _CharT __c);
973 { this->
resize(__n, _CharT()); }
975 #if __cplusplus >= 201103L 999 return _M_is_local() ? size_type(_S_local_capacity)
1000 : _M_allocated_capacity;
1021 reserve(size_type __res_arg = 0);
1027 clear() _GLIBCXX_NOEXCEPT
1028 { _M_set_length(0); }
1035 empty() const _GLIBCXX_NOEXCEPT
1036 {
return this->
size() == 0; }
1050 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
1052 __glibcxx_assert(__pos <=
size());
1053 return _M_data()[__pos];
1071 __glibcxx_assert(__pos <=
size());
1073 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1074 return _M_data()[__pos];
1088 at(size_type __n)
const 1090 if (__n >= this->
size())
1091 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 1092 "(which is %zu) >= this->size() " 1095 return _M_data()[__n];
1112 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 1113 "(which is %zu) >= this->size() " 1116 return _M_data()[__n];
1119 #if __cplusplus >= 201103L 1127 __glibcxx_assert(!
empty());
1136 front() const noexcept
1138 __glibcxx_assert(!
empty());
1149 __glibcxx_assert(!
empty());
1158 back() const noexcept
1160 __glibcxx_assert(!
empty());
1173 {
return this->
append(__str); }
1182 {
return this->
append(__s); }
1196 #if __cplusplus >= 201103L 1204 {
return this->
append(__l.begin(), __l.size()); }
1207 #if __cplusplus > 201402L 1213 template<
typename _Tp>
1214 _If_sv<_Tp, basic_string&>
1216 {
return this->
append(__svt); }
1226 {
return _M_append(__str._M_data(), __str.size()); }
1243 {
return _M_append(__str._M_data()
1244 + __str._M_check(__pos,
"basic_string::append"),
1245 __str._M_limit(__pos, __n)); }
1254 append(
const _CharT* __s, size_type __n)
1256 __glibcxx_requires_string_len(__s, __n);
1257 _M_check_length(size_type(0), __n,
"basic_string::append");
1258 return _M_append(__s, __n);
1267 append(
const _CharT* __s)
1269 __glibcxx_requires_string(__s);
1270 const size_type __n = traits_type::length(__s);
1271 _M_check_length(size_type(0), __n,
"basic_string::append");
1272 return _M_append(__s, __n);
1284 append(size_type __n, _CharT __c)
1285 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1287 #if __cplusplus >= 201103L 1294 append(initializer_list<_CharT> __l)
1295 {
return this->
append(__l.begin(), __l.size()); }
1306 #if __cplusplus >= 201103L 1307 template<
class _InputIterator,
1308 typename = std::_RequireInputIter<_InputIterator>>
1310 template<
class _InputIterator>
1313 append(_InputIterator __first, _InputIterator __last)
1316 #if __cplusplus > 201402L 1322 template<
typename _Tp>
1323 _If_sv<_Tp, basic_string&>
1326 __sv_type __sv = __svt;
1327 return this->
append(__sv.data(), __sv.size());
1337 template<
typename _Tp>
1338 _If_sv<_Tp, basic_string&>
1339 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1341 __sv_type __sv = __svt;
1342 return _M_append(__sv.data()
1343 + __sv._M_check(__pos,
"basic_string::append"),
1344 __sv._M_limit(__pos, __n));
1355 const size_type __size = this->
size();
1357 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1358 traits_type::assign(this->_M_data()[__size], __c);
1359 this->_M_set_length(__size + 1);
1370 this->_M_assign(__str);
1374 #if __cplusplus >= 201103L 1385 noexcept(_Alloc_traits::_S_nothrow_move())
1389 return *
this = std::move(__str);
1408 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1409 + __str._M_check(__pos,
"basic_string::assign"),
1410 __str._M_limit(__pos, __n)); }
1423 assign(
const _CharT* __s, size_type __n)
1425 __glibcxx_requires_string_len(__s, __n);
1426 return _M_replace(size_type(0), this->
size(), __s, __n);
1439 assign(
const _CharT* __s)
1441 __glibcxx_requires_string(__s);
1442 return _M_replace(size_type(0), this->
size(), __s,
1443 traits_type::length(__s));
1456 assign(size_type __n, _CharT __c)
1457 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1467 #if __cplusplus >= 201103L 1468 template<
class _InputIterator,
1469 typename = std::_RequireInputIter<_InputIterator>>
1471 template<
class _InputIterator>
1474 assign(_InputIterator __first, _InputIterator __last)
1477 #if __cplusplus >= 201103L 1484 assign(initializer_list<_CharT> __l)
1485 {
return this->
assign(__l.begin(), __l.size()); }
1488 #if __cplusplus > 201402L 1494 template<
typename _Tp>
1495 _If_sv<_Tp, basic_string&>
1498 __sv_type __sv = __svt;
1499 return this->
assign(__sv.data(), __sv.size());
1509 template<
typename _Tp>
1510 _If_sv<_Tp, basic_string&>
1511 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1513 __sv_type __sv = __svt;
1514 return _M_replace(size_type(0), this->
size(), __sv.data()
1515 + __sv._M_check(__pos,
"basic_string::assign"),
1516 __sv._M_limit(__pos, __n));
1520 #if __cplusplus >= 201103L 1537 insert(const_iterator __p, size_type __n, _CharT __c)
1539 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1540 const size_type __pos = __p -
begin();
1541 this->
replace(__p, __p, __n, __c);
1542 return iterator(this->_M_data() + __pos);
1559 insert(iterator __p, size_type __n, _CharT __c)
1560 { this->
replace(__p, __p, __n, __c); }
1563 #if __cplusplus >= 201103L 1578 template<
class _InputIterator,
1579 typename = std::_RequireInputIter<_InputIterator>>
1581 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1583 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1584 const size_type __pos = __p -
begin();
1585 this->
replace(__p, __p, __beg, __end);
1586 return iterator(this->_M_data() + __pos);
1601 template<
class _InputIterator>
1603 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1604 { this->
replace(__p, __p, __beg, __end); }
1607 #if __cplusplus >= 201103L 1615 insert(iterator __p, initializer_list<_CharT> __l)
1617 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1618 this->
insert(__p -
begin(), __l.begin(), __l.size());
1636 {
return this->
replace(__pos1, size_type(0),
1637 __str._M_data(), __str.size()); }
1659 size_type __pos2, size_type __n =
npos)
1660 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1661 + __str._M_check(__pos2,
"basic_string::insert"),
1662 __str._M_limit(__pos2, __n)); }
1681 insert(size_type __pos,
const _CharT* __s, size_type __n)
1682 {
return this->
replace(__pos, size_type(0), __s, __n); }
1700 insert(size_type __pos,
const _CharT* __s)
1702 __glibcxx_requires_string(__s);
1703 return this->
replace(__pos, size_type(0), __s,
1704 traits_type::length(__s));
1724 insert(size_type __pos, size_type __n, _CharT __c)
1725 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1726 size_type(0), __n, __c); }
1742 insert(__const_iterator __p, _CharT __c)
1744 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1745 const size_type __pos = __p -
begin();
1746 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1747 return iterator(_M_data() + __pos);
1750 #if __cplusplus > 201402L 1757 template<
typename _Tp>
1758 _If_sv<_Tp, basic_string&>
1759 insert(size_type __pos,
const _Tp& __svt)
1761 __sv_type __sv = __svt;
1762 return this->
insert(__pos, __sv.data(), __sv.size());
1774 template<
typename _Tp>
1775 _If_sv<_Tp, basic_string&>
1776 insert(size_type __pos1,
const _Tp& __svt,
1777 size_type __pos2, size_type __n =
npos)
1779 __sv_type __sv = __svt;
1780 return this->
replace(__pos1, size_type(0), __sv.data()
1781 + __sv._M_check(__pos2,
"basic_string::insert"),
1782 __sv._M_limit(__pos2, __n));
1802 erase(size_type __pos = 0, size_type __n =
npos)
1804 _M_check(__pos,
"basic_string::erase");
1806 this->_M_set_length(__pos);
1808 this->_M_erase(__pos, _M_limit(__pos, __n));
1821 erase(__const_iterator __position)
1823 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1824 && __position <
end());
1825 const size_type __pos = __position -
begin();
1826 this->_M_erase(__pos, size_type(1));
1827 return iterator(_M_data() + __pos);
1840 erase(__const_iterator __first, __const_iterator __last)
1842 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1843 && __last <=
end());
1844 const size_type __pos = __first -
begin();
1845 if (__last ==
end())
1846 this->_M_set_length(__pos);
1848 this->_M_erase(__pos, __last - __first);
1849 return iterator(this->_M_data() + __pos);
1852 #if __cplusplus >= 201103L 1861 __glibcxx_assert(!
empty());
1862 _M_erase(
size() - 1, 1);
1885 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1907 size_type __pos2, size_type __n2 =
npos)
1908 {
return this->
replace(__pos1, __n1, __str._M_data()
1909 + __str._M_check(__pos2,
"basic_string::replace"),
1910 __str._M_limit(__pos2, __n2)); }
1931 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1934 __glibcxx_requires_string_len(__s, __n2);
1935 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1936 _M_limit(__pos, __n1), __s, __n2);
1956 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1958 __glibcxx_requires_string(__s);
1959 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1980 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1981 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1982 _M_limit(__pos, __n1), __n2, __c); }
1998 replace(__const_iterator __i1, __const_iterator __i2,
2000 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
2018 replace(__const_iterator __i1, __const_iterator __i2,
2019 const _CharT* __s, size_type __n)
2021 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2023 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2040 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2042 __glibcxx_requires_string(__s);
2043 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2061 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2064 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2066 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2084 #if __cplusplus >= 201103L 2085 template<
class _InputIterator,
2086 typename = std::_RequireInputIter<_InputIterator>>
2088 replace(const_iterator __i1, const_iterator __i2,
2089 _InputIterator __k1, _InputIterator __k2)
2091 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2093 __glibcxx_requires_valid_range(__k1, __k2);
2094 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2095 std::__false_type());
2098 template<
class _InputIterator>
2099 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 2100 typename __enable_if_not_native_iterator<_InputIterator>::__type
2104 replace(iterator __i1, iterator __i2,
2105 _InputIterator __k1, _InputIterator __k2)
2107 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2109 __glibcxx_requires_valid_range(__k1, __k2);
2110 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2111 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2118 replace(__const_iterator __i1, __const_iterator __i2,
2119 _CharT* __k1, _CharT* __k2)
2121 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2123 __glibcxx_requires_valid_range(__k1, __k2);
2129 replace(__const_iterator __i1, __const_iterator __i2,
2130 const _CharT* __k1,
const _CharT* __k2)
2132 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2134 __glibcxx_requires_valid_range(__k1, __k2);
2140 replace(__const_iterator __i1, __const_iterator __i2,
2141 iterator __k1, iterator __k2)
2143 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2145 __glibcxx_requires_valid_range(__k1, __k2);
2147 __k1.base(), __k2 - __k1);
2151 replace(__const_iterator __i1, __const_iterator __i2,
2152 const_iterator __k1, const_iterator __k2)
2154 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2156 __glibcxx_requires_valid_range(__k1, __k2);
2158 __k1.base(), __k2 - __k1);
2161 #if __cplusplus >= 201103L 2177 initializer_list<_CharT> __l)
2178 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2181 #if __cplusplus > 201402L 2189 template<
typename _Tp>
2190 _If_sv<_Tp, basic_string&>
2191 replace(size_type __pos, size_type __n,
const _Tp& __svt)
2193 __sv_type __sv = __svt;
2194 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2206 template<
typename _Tp>
2207 _If_sv<_Tp, basic_string&>
2208 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2209 size_type __pos2, size_type __n2 =
npos)
2211 __sv_type __sv = __svt;
2212 return this->
replace(__pos1, __n1, __sv.data()
2213 + __sv._M_check(__pos2,
"basic_string::replace"),
2214 __sv._M_limit(__pos2, __n2));
2226 template<
typename _Tp>
2227 _If_sv<_Tp, basic_string&>
2228 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2230 __sv_type __sv = __svt;
2231 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2236 template<
class _Integer>
2238 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2239 _Integer __n, _Integer __val, __true_type)
2240 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2242 template<
class _InputIterator>
2244 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2245 _InputIterator __k1, _InputIterator __k2,
2249 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2253 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2254 const size_type __len2);
2257 _M_append(
const _CharT* __s, size_type __n);
2274 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2294 c_str() const _GLIBCXX_NOEXCEPT
2295 {
return _M_data(); }
2306 data() const _GLIBCXX_NOEXCEPT
2307 {
return _M_data(); }
2309 #if __cplusplus > 201402L 2318 {
return _M_data(); }
2326 {
return _M_get_allocator(); }
2341 find(
const _CharT* __s, size_type __pos, size_type __n)
const 2357 {
return this->
find(__str.data(), __pos, __str.size()); }
2359 #if __cplusplus > 201402L 2366 template<
typename _Tp>
2367 _If_sv<_Tp, size_type>
2368 find(
const _Tp& __svt, size_type __pos = 0) const
2369 noexcept(is_same<_Tp, __sv_type>::value)
2371 __sv_type __sv = __svt;
2372 return this->
find(__sv.data(), __pos, __sv.size());
2387 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2389 __glibcxx_requires_string(__s);
2390 return this->
find(__s, __pos, traits_type::length(__s));
2404 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2419 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2421 #if __cplusplus > 201402L 2428 template<
typename _Tp>
2429 _If_sv<_Tp, size_type>
2430 rfind(
const _Tp& __svt, size_type __pos =
npos)
const 2431 noexcept(is_same<_Tp, __sv_type>::value)
2433 __sv_type __sv = __svt;
2434 return this->
rfind(__sv.data(), __pos, __sv.size());
2451 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const 2465 rfind(
const _CharT* __s, size_type __pos =
npos)
const 2467 __glibcxx_requires_string(__s);
2468 return this->
rfind(__s, __pos, traits_type::length(__s));
2482 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
2498 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2500 #if __cplusplus > 201402L 2508 template<
typename _Tp>
2509 _If_sv<_Tp, size_type>
2511 noexcept(is_same<_Tp, __sv_type>::value)
2513 __sv_type __sv = __svt;
2514 return this->
find_first_of(__sv.data(), __pos, __sv.size());
2531 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const 2548 __glibcxx_requires_string(__s);
2549 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2565 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2566 {
return this->
find(__c, __pos); }
2582 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2584 #if __cplusplus > 201402L 2592 template<
typename _Tp>
2593 _If_sv<_Tp, size_type>
2595 noexcept(is_same<_Tp, __sv_type>::value)
2597 __sv_type __sv = __svt;
2598 return this->
find_last_of(__sv.data(), __pos, __sv.size());
2615 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const 2632 __glibcxx_requires_string(__s);
2633 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2650 {
return this->
rfind(__c, __pos); }
2667 #if __cplusplus > 201402L 2675 template<
typename _Tp>
2676 _If_sv<_Tp, size_type>
2678 noexcept(is_same<_Tp, __sv_type>::value)
2680 __sv_type __sv = __svt;
2699 size_type __n)
const _GLIBCXX_NOEXCEPT;
2715 __glibcxx_requires_string(__s);
2749 #if __cplusplus > 201402L 2757 template<
typename _Tp>
2758 _If_sv<_Tp, size_type>
2760 noexcept(is_same<_Tp, __sv_type>::value)
2762 __sv_type __sv = __svt;
2781 size_type __n)
const _GLIBCXX_NOEXCEPT;
2797 __glibcxx_requires_string(__s);
2828 substr(size_type __pos = 0, size_type __n =
npos)
const 2830 _M_check(__pos,
"basic_string::substr"), __n); }
2849 const size_type __size = this->
size();
2850 const size_type __osize = __str.size();
2851 const size_type __len =
std::min(__size, __osize);
2853 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2855 __r = _S_compare(__size, __osize);
2859 #if __cplusplus > 201402L 2865 template<
typename _Tp>
2867 compare(
const _Tp& __svt)
const 2868 noexcept(is_same<_Tp, __sv_type>::value)
2870 __sv_type __sv = __svt;
2871 const size_type __size = this->
size();
2872 const size_type __osize = __sv.size();
2873 const size_type __len =
std::min(__size, __osize);
2875 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
2877 __r = _S_compare(__size, __osize);
2889 template<
typename _Tp>
2891 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const 2892 noexcept(is_same<_Tp, __sv_type>::value)
2894 __sv_type __sv = __svt;
2895 return __sv_type(*this).substr(__pos, __n).compare(__sv);
2908 template<
typename _Tp>
2910 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
2911 size_type __pos2, size_type __n2 =
npos)
const 2912 noexcept(is_same<_Tp, __sv_type>::value)
2914 __sv_type __sv = __svt;
2915 return __sv_type(*
this)
2916 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
2967 size_type __pos2, size_type __n2 =
npos)
const;
2984 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
3008 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
3035 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3036 size_type __n2)
const;
3039 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3041 _GLIBCXX_END_NAMESPACE_CXX11
3042 #else // !_GLIBCXX_USE_CXX11_ABI 3107 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3110 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
3114 typedef _Traits traits_type;
3115 typedef typename _Traits::char_type value_type;
3116 typedef _Alloc allocator_type;
3117 typedef typename _CharT_alloc_type::size_type size_type;
3118 typedef typename _CharT_alloc_type::difference_type difference_type;
3119 typedef typename _CharT_alloc_type::reference reference;
3120 typedef typename _CharT_alloc_type::const_reference const_reference;
3121 typedef typename _CharT_alloc_type::pointer pointer;
3122 typedef typename _CharT_alloc_type::const_pointer const_pointer;
3123 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
3124 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
3146 size_type _M_length;
3147 size_type _M_capacity;
3148 _Atomic_word _M_refcount;
3151 struct _Rep : _Rep_base
3154 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
3169 static const size_type _S_max_size;
3170 static const _CharT _S_terminal;
3174 static size_type _S_empty_rep_storage[];
3177 _S_empty_rep() _GLIBCXX_NOEXCEPT
3182 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
3183 return *
reinterpret_cast<_Rep*
>(__p);
3187 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
3189 #if defined(__GTHREADS) 3194 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
3196 return this->_M_refcount < 0;
3201 _M_is_shared()
const _GLIBCXX_NOEXCEPT
3203 #if defined(__GTHREADS) 3209 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
3211 return this->_M_refcount > 0;
3216 _M_set_leaked() _GLIBCXX_NOEXCEPT
3217 { this->_M_refcount = -1; }
3220 _M_set_sharable() _GLIBCXX_NOEXCEPT
3221 { this->_M_refcount = 0; }
3224 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
3226 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3227 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3230 this->_M_set_sharable();
3231 this->_M_length = __n;
3232 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
3239 _M_refdata()
throw()
3240 {
return reinterpret_cast<_CharT*
>(
this + 1); }
3243 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
3245 return (!_M_is_leaked() && __alloc1 == __alloc2)
3246 ? _M_refcopy() : _M_clone(__alloc1);
3251 _S_create(size_type, size_type,
const _Alloc&);
3254 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3256 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3257 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3261 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
3270 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
3273 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
3280 _M_destroy(
const _Alloc&)
throw();
3283 _M_refcopy()
throw()
3285 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3286 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3288 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
3289 return _M_refdata();
3293 _M_clone(
const _Alloc&, size_type __res = 0);
3297 struct _Alloc_hider : _Alloc
3299 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3300 : _Alloc(__a), _M_p(__dat) { }
3310 static const size_type
npos =
static_cast<size_type
>(-1);
3314 mutable _Alloc_hider _M_dataplus;
3317 _M_data() const _GLIBCXX_NOEXCEPT
3318 {
return _M_dataplus._M_p; }
3321 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
3322 {
return (_M_dataplus._M_p = __p); }
3325 _M_rep() const _GLIBCXX_NOEXCEPT
3326 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
3331 _M_ibegin() const _GLIBCXX_NOEXCEPT
3332 {
return iterator(_M_data()); }
3335 _M_iend() const _GLIBCXX_NOEXCEPT
3336 {
return iterator(_M_data() + this->
size()); }
3341 if (!_M_rep()->_M_is_leaked())
3346 _M_check(size_type __pos,
const char* __s)
const 3348 if (__pos > this->
size())
3349 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 3350 "this->size() (which is %zu)"),
3351 __s, __pos, this->
size());
3356 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 3359 __throw_length_error(__N(__s));
3364 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
3366 const bool __testoff = __off < this->
size() - __pos;
3367 return __testoff ? __off : this->
size() - __pos;
3372 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3374 return (less<const _CharT*>()(__s, _M_data())
3375 || less<const _CharT*>()(_M_data() + this->
size(), __s));
3381 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3384 traits_type::assign(*__d, *__s);
3386 traits_type::copy(__d, __s, __n);
3390 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3393 traits_type::assign(*__d, *__s);
3395 traits_type::move(__d, __s, __n);
3399 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
3402 traits_type::assign(*__d, __c);
3404 traits_type::assign(__d, __n, __c);
3409 template<
class _Iterator>
3411 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
3413 for (; __k1 != __k2; ++__k1, (void)++__p)
3414 traits_type::assign(*__p, *__k1);
3418 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
3419 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3422 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
3424 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3427 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
3428 { _M_copy(__p, __k1, __k2 - __k1); }
3431 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
3433 { _M_copy(__p, __k1, __k2 - __k1); }
3436 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
3438 const difference_type __d = difference_type(__n1 - __n2);
3440 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
3441 return __gnu_cxx::__numeric_traits<int>::__max;
3442 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
3443 return __gnu_cxx::__numeric_traits<int>::__min;
3449 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
3455 _S_empty_rep() _GLIBCXX_NOEXCEPT
3456 {
return _Rep::_S_empty_rep(); }
3458 #if __cplusplus > 201402L 3460 typedef basic_string_view<_CharT, _Traits> __sv_type;
3462 template<
typename _Tp,
typename _Res>
3464 __and_<is_convertible<const _Tp&, __sv_type>,
3465 __not_<is_convertible<const _Tp*, const basic_string*>>,
3466 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
3471 _S_to_string_view(__sv_type __svt) noexcept
3480 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
3494 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3495 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
3497 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
3522 const _Alloc& __a = _Alloc());
3540 size_type __n,
const _Alloc& __a);
3552 const _Alloc& __a = _Alloc());
3558 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
3565 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3567 #if __cplusplus >= 201103L 3576 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3579 : _M_dataplus(__str._M_dataplus)
3581 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3582 __str._M_data(_S_empty_rep()._M_refdata());
3584 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3602 template<
class _InputIterator>
3603 basic_string(_InputIterator __beg, _InputIterator __end,
3604 const _Alloc& __a = _Alloc());
3606 #if __cplusplus > 201402L 3614 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3615 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
3616 const _Alloc& __a = _Alloc())
3624 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3626 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
3627 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
3652 {
return this->
assign(__str); }
3660 {
return this->
assign(__s); }
3676 #if __cplusplus >= 201103L 3700 this->
assign(__l.begin(), __l.size());
3705 #if __cplusplus > 201402L 3710 template<
typename _Tp>
3711 _If_sv<_Tp, basic_string&>
3713 {
return this->
assign(__svt); }
3719 operator __sv_type() const noexcept
3720 {
return __sv_type(
data(),
size()); }
3732 return iterator(_M_data());
3741 {
return const_iterator(_M_data()); }
3751 return iterator(_M_data() + this->
size());
3760 {
return const_iterator(_M_data() + this->
size()); }
3776 const_reverse_iterator
3794 const_reverse_iterator
3798 #if __cplusplus >= 201103L 3805 {
return const_iterator(this->_M_data()); }
3813 {
return const_iterator(this->_M_data() + this->
size()); }
3820 const_reverse_iterator
3829 const_reverse_iterator
3840 {
return _M_rep()->_M_length; }
3846 {
return _M_rep()->_M_length; }
3851 {
return _Rep::_S_max_size; }
3864 resize(size_type __n, _CharT __c);
3878 { this->
resize(__n, _CharT()); }
3880 #if __cplusplus >= 201103L 3885 #if __cpp_exceptions 3903 {
return _M_rep()->_M_capacity; }
3923 reserve(size_type __res_arg = 0);
3928 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3932 if (_M_rep()->_M_is_shared())
3935 _M_data(_S_empty_rep()._M_refdata());
3938 _M_rep()->_M_set_length_and_sharable(0);
3944 { _M_mutate(0, this->
size(), 0); }
3953 {
return this->
size() == 0; }
3969 __glibcxx_assert(__pos <=
size());
3970 return _M_data()[__pos];
3988 __glibcxx_assert(__pos <=
size());
3990 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
3992 return _M_data()[__pos];
4008 if (__n >= this->
size())
4009 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 4010 "(which is %zu) >= this->size() " 4013 return _M_data()[__n];
4031 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 4032 "(which is %zu) >= this->size() " 4036 return _M_data()[__n];
4039 #if __cplusplus >= 201103L 4047 __glibcxx_assert(!
empty());
4058 __glibcxx_assert(!
empty());
4069 __glibcxx_assert(!
empty());
4080 __glibcxx_assert(!
empty());
4093 {
return this->
append(__str); }
4102 {
return this->
append(__s); }
4116 #if __cplusplus >= 201103L 4124 {
return this->
append(__l.begin(), __l.size()); }
4127 #if __cplusplus > 201402L 4133 template<
typename _Tp>
4134 _If_sv<_Tp, basic_string&>
4136 {
return this->
append(__svt); }
4170 append(
const _CharT* __s, size_type __n);
4180 __glibcxx_requires_string(__s);
4181 return this->
append(__s, traits_type::length(__s));
4193 append(size_type __n, _CharT __c);
4195 #if __cplusplus >= 201103L 4203 {
return this->
append(__l.begin(), __l.size()); }
4214 template<
class _InputIterator>
4216 append(_InputIterator __first, _InputIterator __last)
4217 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
4219 #if __cplusplus > 201402L 4225 template<
typename _Tp>
4226 _If_sv<_Tp, basic_string&>
4229 __sv_type __sv = __svt;
4230 return this->
append(__sv.data(), __sv.size());
4241 template<
typename _Tp>
4242 _If_sv<_Tp, basic_string&>
4243 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
4245 __sv_type __sv = __svt;
4246 return append(__sv.data()
4247 + __sv._M_check(__pos,
"basic_string::append"),
4248 __sv._M_limit(__pos, __n));
4259 const size_type __len = 1 + this->
size();
4260 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
4262 traits_type::assign(_M_data()[this->
size()], __c);
4263 _M_rep()->_M_set_length_and_sharable(__len);
4274 #if __cplusplus >= 201103L 4307 {
return this->
assign(__str._M_data()
4308 + __str._M_check(__pos,
"basic_string::assign"),
4309 __str._M_limit(__pos, __n)); }
4322 assign(
const _CharT* __s, size_type __n);
4336 __glibcxx_requires_string(__s);
4337 return this->
assign(__s, traits_type::length(__s));
4351 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4361 template<
class _InputIterator>
4363 assign(_InputIterator __first, _InputIterator __last)
4364 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4366 #if __cplusplus >= 201103L 4374 {
return this->
assign(__l.begin(), __l.size()); }
4377 #if __cplusplus > 201402L 4383 template<
typename _Tp>
4384 _If_sv<_Tp, basic_string&>
4387 __sv_type __sv = __svt;
4388 return this->
assign(__sv.data(), __sv.size());
4398 template<
typename _Tp>
4399 _If_sv<_Tp, basic_string&>
4400 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
4402 __sv_type __sv = __svt;
4403 return assign(__sv.data()
4404 + __sv._M_check(__pos,
"basic_string::assign"),
4405 __sv._M_limit(__pos, __n));
4423 insert(iterator __p, size_type __n, _CharT __c)
4424 { this->
replace(__p, __p, __n, __c); }
4438 template<
class _InputIterator>
4440 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4441 { this->
replace(__p, __p, __beg, __end); }
4443 #if __cplusplus >= 201103L 4453 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4454 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4472 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4494 size_type __pos2, size_type __n =
npos)
4495 {
return this->
insert(__pos1, __str._M_data()
4496 + __str._M_check(__pos2,
"basic_string::insert"),
4497 __str._M_limit(__pos2, __n)); }
4516 insert(size_type __pos,
const _CharT* __s, size_type __n);
4536 __glibcxx_requires_string(__s);
4537 return this->
insert(__pos, __s, traits_type::length(__s));
4557 insert(size_type __pos, size_type __n, _CharT __c)
4558 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4559 size_type(0), __n, __c); }
4577 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4578 const size_type __pos = __p - _M_ibegin();
4579 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4580 _M_rep()->_M_set_leaked();
4581 return iterator(_M_data() + __pos);
4584 #if __cplusplus > 201402L 4591 template<
typename _Tp>
4592 _If_sv<_Tp, basic_string&>
4593 insert(size_type __pos,
const _Tp& __svt)
4595 __sv_type __sv = __svt;
4596 return this->
insert(__pos, __sv.data(), __sv.size());
4608 template<
typename _Tp>
4609 _If_sv<_Tp, basic_string&>
4610 insert(size_type __pos1,
const _Tp& __svt,
4611 size_type __pos2, size_type __n =
npos)
4613 __sv_type __sv = __svt;
4614 return this->
replace(__pos1, size_type(0), __sv.data()
4615 + __sv._M_check(__pos2,
"basic_string::insert"),
4616 __sv._M_limit(__pos2, __n));
4638 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4639 _M_limit(__pos, __n), size_type(0));
4654 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4655 && __position < _M_iend());
4656 const size_type __pos = __position - _M_ibegin();
4657 _M_mutate(__pos, size_type(1), size_type(0));
4658 _M_rep()->_M_set_leaked();
4659 return iterator(_M_data() + __pos);
4674 #if __cplusplus >= 201103L 4683 __glibcxx_assert(!
empty());
4707 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4729 size_type __pos2, size_type __n2 =
npos)
4730 {
return this->
replace(__pos1, __n1, __str._M_data()
4731 + __str._M_check(__pos2,
"basic_string::replace"),
4732 __str._M_limit(__pos2, __n2)); }
4753 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4773 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4775 __glibcxx_requires_string(__s);
4776 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4797 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4798 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4799 _M_limit(__pos, __n1), __n2, __c); }
4816 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4834 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4836 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4837 && __i2 <= _M_iend());
4838 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4855 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4857 __glibcxx_requires_string(__s);
4858 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4876 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4878 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4879 && __i2 <= _M_iend());
4880 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4898 template<
class _InputIterator>
4901 _InputIterator __k1, _InputIterator __k2)
4903 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4904 && __i2 <= _M_iend());
4905 __glibcxx_requires_valid_range(__k1, __k2);
4906 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4907 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4915 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4916 && __i2 <= _M_iend());
4917 __glibcxx_requires_valid_range(__k1, __k2);
4918 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4923 replace(iterator __i1, iterator __i2,
4924 const _CharT* __k1,
const _CharT* __k2)
4926 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4927 && __i2 <= _M_iend());
4928 __glibcxx_requires_valid_range(__k1, __k2);
4929 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4934 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4936 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4937 && __i2 <= _M_iend());
4938 __glibcxx_requires_valid_range(__k1, __k2);
4939 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4940 __k1.base(), __k2 - __k1);
4944 replace(iterator __i1, iterator __i2,
4945 const_iterator __k1, const_iterator __k2)
4947 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4948 && __i2 <= _M_iend());
4949 __glibcxx_requires_valid_range(__k1, __k2);
4950 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4951 __k1.base(), __k2 - __k1);
4954 #if __cplusplus >= 201103L 4971 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
4974 #if __cplusplus > 201402L 4982 template<
typename _Tp>
4983 _If_sv<_Tp, basic_string&>
4984 replace(size_type __pos, size_type __n,
const _Tp& __svt)
4986 __sv_type __sv = __svt;
4987 return this->
replace(__pos, __n, __sv.data(), __sv.size());
4999 template<
typename _Tp>
5000 _If_sv<_Tp, basic_string&>
5001 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
5002 size_type __pos2, size_type __n2 =
npos)
5004 __sv_type __sv = __svt;
5005 return this->
replace(__pos1, __n1,
5006 __sv.data() + __sv._M_check(__pos2,
"basic_string::replace"),
5007 __sv._M_limit(__pos2, __n2));
5019 template<
typename _Tp>
5020 _If_sv<_Tp, basic_string&>
5021 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
5023 __sv_type __sv = __svt;
5024 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
5029 template<
class _Integer>
5031 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
5032 _Integer __val, __true_type)
5033 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
5035 template<
class _InputIterator>
5037 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
5038 _InputIterator __k2, __false_type);
5041 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
5045 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
5050 template<
class _InIterator>
5052 _S_construct_aux(_InIterator __beg, _InIterator __end,
5053 const _Alloc& __a, __false_type)
5055 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
5056 return _S_construct(__beg, __end, __a, _Tag());
5061 template<
class _Integer>
5063 _S_construct_aux(_Integer __beg, _Integer __end,
5064 const _Alloc& __a, __true_type)
5065 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
5069 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
5070 {
return _S_construct(__req, __c, __a); }
5072 template<
class _InIterator>
5074 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
5076 typedef typename std::__is_integer<_InIterator>::__type _Integral;
5077 return _S_construct_aux(__beg, __end, __a, _Integral());
5081 template<
class _InIterator>
5083 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
5084 input_iterator_tag);
5088 template<
class _FwdIterator>
5090 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
5091 forward_iterator_tag);
5094 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
5111 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
5133 {
return _M_data(); }
5145 {
return _M_data(); }
5147 #if __cplusplus > 201402L 5167 {
return _M_dataplus; }
5182 find(
const _CharT* __s, size_type __pos, size_type __n)
const 5198 {
return this->
find(__str.data(), __pos, __str.size()); }
5211 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
5213 __glibcxx_requires_string(__s);
5214 return this->
find(__s, __pos, traits_type::length(__s));
5228 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
5230 #if __cplusplus > 201402L 5237 template<
typename _Tp>
5238 _If_sv<_Tp, size_type>
5239 find(
const _Tp& __svt, size_type __pos = 0) const
5240 noexcept(
is_same<_Tp, __sv_type>::value)
5242 __sv_type __sv = __svt;
5243 return this->
find(__sv.data(), __pos, __sv.size());
5260 {
return this->
rfind(__str.data(), __pos, __str.size()); }
5275 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const 5289 rfind(
const _CharT* __s, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT
5291 __glibcxx_requires_string(__s);
5292 return this->
rfind(__s, __pos, traits_type::length(__s));
5306 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
5308 #if __cplusplus > 201402L 5315 template<
typename _Tp>
5316 _If_sv<_Tp, size_type>
5317 rfind(
const _Tp& __svt, size_type __pos =
npos)
const 5320 __sv_type __sv = __svt;
5321 return this->
rfind(__sv.data(), __pos, __sv.size());
5339 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
5354 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5371 __glibcxx_requires_string(__s);
5372 return this->
find_first_of(__s, __pos, traits_type::length(__s));
5389 {
return this->
find(__c, __pos); }
5391 #if __cplusplus > 201402L 5399 template<
typename _Tp>
5400 _If_sv<_Tp, size_type>
5402 noexcept(
is_same<_Tp, __sv_type>::value)
5404 __sv_type __sv = __svt;
5405 return this->
find_first_of(__sv.data(), __pos, __sv.size());
5423 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5438 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5455 __glibcxx_requires_string(__s);
5456 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5473 {
return this->
rfind(__c, __pos); }
5475 #if __cplusplus > 201402L 5483 template<
typename _Tp>
5484 _If_sv<_Tp, size_type>
5488 __sv_type __sv = __svt;
5489 return this->
find_last_of(__sv.data(), __pos, __sv.size());
5522 size_type __n)
const _GLIBCXX_NOEXCEPT;
5538 __glibcxx_requires_string(__s);
5556 #if __cplusplus > 201402L 5564 template<
typename _Tp>
5565 _If_sv<_Tp, size_type>
5567 noexcept(
is_same<_Tp, __sv_type>::value)
5569 __sv_type __sv = __svt;
5604 size_type __n)
const _GLIBCXX_NOEXCEPT;
5620 __glibcxx_requires_string(__s);
5638 #if __cplusplus > 201402L 5646 template<
typename _Tp>
5647 _If_sv<_Tp, size_type>
5651 __sv_type __sv = __svt;
5671 _M_check(__pos,
"basic_string::substr"), __n); }
5690 const size_type __size = this->
size();
5691 const size_type __osize = __str.size();
5692 const size_type __len =
std::min(__size, __osize);
5694 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5696 __r = _S_compare(__size, __osize);
5700 #if __cplusplus > 201402L 5706 template<
typename _Tp>
5708 compare(
const _Tp& __svt)
const 5711 __sv_type __sv = __svt;
5712 const size_type __size = this->
size();
5713 const size_type __osize = __sv.size();
5714 const size_type __len =
std::min(__size, __osize);
5716 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
5718 __r = _S_compare(__size, __osize);
5730 template<
typename _Tp>
5732 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const 5733 noexcept(is_same<_Tp, __sv_type>::value)
5735 __sv_type __sv = __svt;
5736 return __sv_type(*this).substr(__pos, __n).compare(__sv);
5749 template<
typename _Tp>
5751 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
5752 size_type __pos2, size_type __n2 =
npos)
const 5753 noexcept(is_same<_Tp, __sv_type>::value)
5755 __sv_type __sv = __svt;
5756 return __sv_type(*
this)
5757 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
5808 size_type __pos2, size_type __n2 =
npos)
const;
5825 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5849 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5876 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5877 size_type __n2)
const;
5879 # ifdef _GLIBCXX_TM_TS_INTERNAL 5881 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
5884 ::_txnal_cow_string_c_str(
const void *that);
5886 ::_txnal_cow_string_D1(
void *that);
5888 ::_txnal_cow_string_D1_commit(
void *that);
5891 #endif // !_GLIBCXX_USE_CXX11_ABI 5893 #if __cpp_deduction_guides >= 201606 5894 _GLIBCXX_BEGIN_NAMESPACE_CXX11
5895 template<
typename _InputIterator,
typename _CharT
5896 =
typename iterator_traits<_InputIterator>::value_type,
5897 typename _Allocator = allocator<_CharT>,
5898 typename = _RequireInputIter<_InputIterator>,
5899 typename = _RequireAllocator<_Allocator>>
5900 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
5901 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
5905 template<
typename _CharT,
typename _Traits,
5906 typename _Allocator = allocator<_CharT>,
5907 typename = _RequireAllocator<_Allocator>>
5908 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
5909 -> basic_string<_CharT, _Traits, _Allocator>;
5911 template<
typename _CharT,
typename _Traits,
5912 typename _Allocator = allocator<_CharT>,
5913 typename = _RequireAllocator<_Allocator>>
5914 basic_string(basic_string_view<_CharT, _Traits>,
5915 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
5916 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
5917 const _Allocator& = _Allocator())
5918 -> basic_string<_CharT, _Traits, _Allocator>;
5919 _GLIBCXX_END_NAMESPACE_CXX11
5929 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5930 basic_string<_CharT, _Traits, _Alloc>
5935 __str.append(__rhs);
5945 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5946 basic_string<_CharT,_Traits,_Alloc>
5948 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
5956 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5957 basic_string<_CharT,_Traits,_Alloc>
5958 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
5966 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5967 inline basic_string<_CharT, _Traits, _Alloc>
5969 const _CharT* __rhs)
5972 __str.append(__rhs);
5982 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5983 inline basic_string<_CharT, _Traits, _Alloc>
5987 typedef typename __string_type::size_type __size_type;
5988 __string_type __str(__lhs);
5989 __str.append(__size_type(1), __rhs);
5993 #if __cplusplus >= 201103L 5994 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5995 inline basic_string<_CharT, _Traits, _Alloc>
5996 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
5997 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
5998 {
return std::move(__lhs.append(__rhs)); }
6000 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6001 inline basic_string<_CharT, _Traits, _Alloc>
6002 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6003 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6004 {
return std::move(__rhs.insert(0, __lhs)); }
6006 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6007 inline basic_string<_CharT, _Traits, _Alloc>
6008 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6009 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6011 const auto __size = __lhs.size() + __rhs.size();
6012 const bool __cond = (__size > __lhs.capacity()
6013 && __size <= __rhs.capacity());
6014 return __cond ? std::move(__rhs.insert(0, __lhs))
6015 : std::move(__lhs.append(__rhs));
6018 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6019 inline basic_string<_CharT, _Traits, _Alloc>
6021 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6022 {
return std::move(__rhs.insert(0, __lhs)); }
6024 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6025 inline basic_string<_CharT, _Traits, _Alloc>
6027 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6028 {
return std::move(__rhs.insert(0, 1, __lhs)); }
6030 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6031 inline basic_string<_CharT, _Traits, _Alloc>
6032 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6033 const _CharT* __rhs)
6034 {
return std::move(__lhs.append(__rhs)); }
6036 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6037 inline basic_string<_CharT, _Traits, _Alloc>
6038 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6040 {
return std::move(__lhs.append(1, __rhs)); }
6050 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6055 {
return __lhs.compare(__rhs) == 0; }
6057 template<
typename _CharT>
6059 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
6060 operator==(
const basic_string<_CharT>& __lhs,
6061 const basic_string<_CharT>& __rhs) _GLIBCXX_NOEXCEPT
6062 {
return (__lhs.size() == __rhs.size()
6072 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6074 operator==(
const _CharT* __lhs,
6076 {
return __rhs.compare(__lhs) == 0; }
6084 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6087 const _CharT* __rhs)
6088 {
return __lhs.compare(__rhs) == 0; }
6097 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6102 {
return !(__lhs == __rhs); }
6110 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6112 operator!=(
const _CharT* __lhs,
6114 {
return !(__lhs == __rhs); }
6122 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6125 const _CharT* __rhs)
6126 {
return !(__lhs == __rhs); }
6135 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6137 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6140 {
return __lhs.
compare(__rhs) < 0; }
6148 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6150 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6151 const _CharT* __rhs)
6152 {
return __lhs.compare(__rhs) < 0; }
6160 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6162 operator<(
const _CharT* __lhs,
6164 {
return __rhs.compare(__lhs) > 0; }
6173 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6178 {
return __lhs.compare(__rhs) > 0; }
6186 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6189 const _CharT* __rhs)
6190 {
return __lhs.compare(__rhs) > 0; }
6198 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6200 operator>(
const _CharT* __lhs,
6202 {
return __rhs.compare(__lhs) < 0; }
6211 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6213 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6216 {
return __lhs.
compare(__rhs) <= 0; }
6224 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6226 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6227 const _CharT* __rhs)
6228 {
return __lhs.compare(__rhs) <= 0; }
6236 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6238 operator<=(
const _CharT* __lhs,
6240 {
return __rhs.compare(__lhs) >= 0; }
6249 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6254 {
return __lhs.compare(__rhs) >= 0; }
6262 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6265 const _CharT* __rhs)
6266 {
return __lhs.compare(__rhs) >= 0; }
6274 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6276 operator>=(
const _CharT* __lhs,
6278 {
return __rhs.compare(__lhs) <= 0; }
6287 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6291 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
6292 { __lhs.swap(__rhs); }
6307 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6308 basic_istream<_CharT, _Traits>&
6309 operator>>(basic_istream<_CharT, _Traits>& __is,
6310 basic_string<_CharT, _Traits, _Alloc>& __str);
6313 basic_istream<char>&
6314 operator>>(basic_istream<char>& __is, basic_string<char>& __str);
6325 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6326 inline basic_ostream<_CharT, _Traits>&
6327 operator<<(basic_ostream<_CharT, _Traits>& __os,
6332 return __ostream_insert(__os, __str.data(), __str.size());
6348 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6349 basic_istream<_CharT, _Traits>&
6350 getline(basic_istream<_CharT, _Traits>& __is,
6351 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
6365 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6366 inline basic_istream<_CharT, _Traits>&
6371 #if __cplusplus >= 201103L 6373 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6374 inline basic_istream<_CharT, _Traits>&
6380 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6381 inline basic_istream<_CharT, _Traits>&
6388 basic_istream<char>&
6389 getline(basic_istream<char>& __in, basic_string<char>& __str,
6392 #ifdef _GLIBCXX_USE_WCHAR_T 6394 basic_istream<wchar_t>&
6395 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
6399 _GLIBCXX_END_NAMESPACE_VERSION
6402 #if __cplusplus >= 201103L 6406 namespace std _GLIBCXX_VISIBILITY(default)
6408 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6409 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6411 #if _GLIBCXX_USE_C99_STDLIB 6414 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6415 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
6419 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6420 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
6423 inline unsigned long 6424 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6425 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
6429 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6430 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
6433 inline unsigned long long 6434 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6435 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
6440 stof(
const string& __str,
size_t* __idx = 0)
6441 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
6444 stod(
const string& __str,
size_t* __idx = 0)
6445 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
6448 stold(
const string& __str,
size_t* __idx = 0)
6449 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
6450 #endif // _GLIBCXX_USE_C99_STDLIB 6452 #if _GLIBCXX_USE_C99_STDIO 6457 to_string(
int __val)
6458 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
6462 to_string(
unsigned __val)
6463 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6464 4 *
sizeof(unsigned),
6468 to_string(
long __val)
6469 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
6473 to_string(
unsigned long __val)
6474 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6475 4 *
sizeof(
unsigned long),
6479 to_string(
long long __val)
6480 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6481 4 *
sizeof(
long long),
6485 to_string(
unsigned long long __val)
6486 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6487 4 *
sizeof(
unsigned long long),
6491 to_string(
float __val)
6494 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6495 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6500 to_string(
double __val)
6503 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6504 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6509 to_string(
long double __val)
6512 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6513 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6516 #endif // _GLIBCXX_USE_C99_STDIO 6518 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR 6520 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6521 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
6525 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6526 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
6529 inline unsigned long 6530 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6531 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
6535 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6536 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
6539 inline unsigned long long 6540 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6541 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
6546 stof(
const wstring& __str,
size_t* __idx = 0)
6547 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
6550 stod(
const wstring& __str,
size_t* __idx = 0)
6551 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
6554 stold(
const wstring& __str,
size_t* __idx = 0)
6555 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
6557 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6560 to_wstring(
int __val)
6561 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
6565 to_wstring(
unsigned __val)
6566 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6567 4 *
sizeof(unsigned),
6571 to_wstring(
long __val)
6572 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
6576 to_wstring(
unsigned long __val)
6577 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6578 4 *
sizeof(
unsigned long),
6582 to_wstring(
long long __val)
6583 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6584 4 *
sizeof(
long long),
6588 to_wstring(
unsigned long long __val)
6589 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6590 4 *
sizeof(
unsigned long long),
6594 to_wstring(
float __val)
6597 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6598 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6603 to_wstring(
double __val)
6606 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6607 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6612 to_wstring(
long double __val)
6615 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6616 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6619 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6620 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR 6622 _GLIBCXX_END_NAMESPACE_CXX11
6623 _GLIBCXX_END_NAMESPACE_VERSION
6628 #if __cplusplus >= 201103L 6632 namespace std _GLIBCXX_VISIBILITY(default)
6634 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6638 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X 6642 :
public __hash_base<size_t, string>
6645 operator()(
const string& __s)
const noexcept
6646 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
6653 #ifdef _GLIBCXX_USE_WCHAR_T 6657 :
public __hash_base<size_t, wstring>
6660 operator()(
const wstring& __s)
const noexcept
6661 {
return std::_Hash_impl::hash(__s.
data(),
6662 __s.
length() *
sizeof(wchar_t)); }
6671 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 6675 :
public __hash_base<size_t, u16string>
6678 operator()(
const u16string& __s)
const noexcept
6679 {
return std::_Hash_impl::hash(__s.
data(),
6680 __s.
length() *
sizeof(char16_t)); }
6690 :
public __hash_base<size_t, u32string>
6693 operator()(
const u32string& __s)
const noexcept
6694 {
return std::_Hash_impl::hash(__s.
data(),
6695 __s.
length() *
sizeof(char32_t)); }
6703 #if __cplusplus > 201103L 6705 #define __cpp_lib_string_udls 201304 6707 inline namespace literals
6709 inline namespace string_literals
6711 #pragma GCC diagnostic push 6712 #pragma GCC diagnostic ignored "-Wliteral-suffix" 6713 _GLIBCXX_DEFAULT_ABI_TAG
6714 inline basic_string<char>
6715 operator""s(
const char* __str,
size_t __len)
6716 {
return basic_string<char>{__str, __len}; }
6718 #ifdef _GLIBCXX_USE_WCHAR_T 6719 _GLIBCXX_DEFAULT_ABI_TAG
6720 inline basic_string<wchar_t>
6721 operator""s(
const wchar_t* __str,
size_t __len)
6722 {
return basic_string<wchar_t>{__str, __len}; }
6725 #ifdef _GLIBCXX_USE_C99_STDINT_TR1 6726 _GLIBCXX_DEFAULT_ABI_TAG
6727 inline basic_string<char16_t>
6728 operator""s(
const char16_t* __str,
size_t __len)
6729 {
return basic_string<char16_t>{__str, __len}; }
6731 _GLIBCXX_DEFAULT_ABI_TAG
6732 inline basic_string<char32_t>
6733 operator""s(
const char32_t* __str,
size_t __len)
6734 {
return basic_string<char32_t>{__str, __len}; }
6737 #pragma GCC diagnostic pop 6741 #endif // __cplusplus > 201103L 6743 _GLIBCXX_END_NAMESPACE_VERSION
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
~basic_string() noexcept
Destroy the string instance.
const_reverse_iterator rbegin() const noexcept
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
size_type find_last_not_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character not in string.
size_type find_last_not_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character not in C string.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
basic_string & replace(size_type __pos1, size_type __n1, const basic_string &__str, size_type __pos2, size_type __n2=npos)
Replace characters with value from another string.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
iterator insert(iterator __p, _CharT __c)
Insert one character.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
Uniform interface to all pointer-like types.
void push_back(_CharT __c)
Append a single character.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
basic_string & operator=(basic_string &&__str)
Move assign the value of str to this string.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
Primary class template hash.
basic_string & append(const _CharT *__s)
Append a C string.
basic_string & assign(basic_string &&__str)
Set value to contents of another string.
const_reverse_iterator crbegin() const noexcept
bool empty() const noexcept
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
iterator erase(iterator __position)
Remove one character.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
size_type rfind(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a C string.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
char_type widen(char __c) const
Widens characters.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
Template class basic_istream.
int compare(const basic_string &__str) const
Compare to a string.
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
basic_string< wchar_t > wstring
A string of wchar_t.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
const_reverse_iterator rend() const noexcept
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n=npos)
Set value to a substring of a string.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
size_type find(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
reverse_iterator rbegin()
const _CharT * data() const noexcept
Return const pointer to contents.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character not in C string.
const_iterator cend() const noexcept
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
basic_string & operator+=(_CharT __c)
Append a character.
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
void pop_back()
Remove the last character.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character of C string.
ISO C++ entities toplevel namespace is std.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
const_iterator end() const noexcept
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
const_reverse_iterator crend() const noexcept
Managing sequences of characters and character-like objects.
basic_string & operator+=(const _CharT *__s)
Append a C string.
size_type capacity() const noexcept
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n=npos)
Insert a substring.
basic_string()
Default constructor creates an empty string.
const_iterator cbegin() const noexcept
size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.
void resize(size_type __n)
Resizes the string to the specified number of characters.
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
const_reference front() const noexcept
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
const_iterator begin() const noexcept
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
const_reference back() const noexcept
void swap(basic_string &__s)
Swap contents with another string.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character of C string.
basic_istream< _CharT, _Traits > & getline(basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__str, _CharT __delim)
Read a line from stream into a string.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
basic_string(basic_string &&__str) noexcept
Move construct string.
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
Uniform interface to C++98 and C++11 allocators.
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
Forward iterators support a superset of input iterator operations.
Basis for explicit traits specializations.
basic_string & append(const basic_string &__str)
Append a string to this string.
reference at(size_type __n)
Provides access to the data contained in the string.
static const size_type npos
Value returned by various member functions when they fail.