34 #ifndef _BASIC_STRING_H
35 #define _BASIC_STRING_H 1
37 #pragma GCC system_header
43 #if __cplusplus >= 201103L
47 #if __cplusplus > 201402L
52 namespace std _GLIBCXX_VISIBILITY(default)
54 _GLIBCXX_BEGIN_NAMESPACE_VERSION
56 #if _GLIBCXX_USE_CXX11_ABI
57 _GLIBCXX_BEGIN_NAMESPACE_CXX11
76 template<
typename _CharT,
typename _Traits,
typename _Alloc>
80 rebind<_CharT>::other _Char_alloc_type;
85 typedef _Traits traits_type;
86 typedef typename _Traits::char_type value_type;
87 typedef _Char_alloc_type allocator_type;
88 typedef typename _Alloc_traits::size_type size_type;
89 typedef typename _Alloc_traits::difference_type difference_type;
90 typedef typename _Alloc_traits::reference reference;
91 typedef typename _Alloc_traits::const_reference const_reference;
92 typedef typename _Alloc_traits::pointer pointer;
93 typedef typename _Alloc_traits::const_pointer const_pointer;
94 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
95 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
101 static const size_type
npos =
static_cast<size_type
>(-1);
105 #if __cplusplus < 201103L
106 typedef iterator __const_iterator;
108 typedef const_iterator __const_iterator;
111 #if __cplusplus > 201402L
113 typedef basic_string_view<_CharT, _Traits> __sv_type;
115 template<
typename _Tp,
typename _Res>
117 __and_<is_convertible<const _Tp&, __sv_type>,
118 __not_<is_convertible<const _Tp*, const basic_string*>>,
119 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
124 _S_to_string_view(__sv_type __svt) noexcept
133 explicit __sv_wrapper(__sv_type __sv)
noexcept : _M_sv(__sv) { }
139 struct _Alloc_hider : allocator_type
141 #if __cplusplus < 201103L
142 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
143 : allocator_type(__a), _M_p(__dat) { }
145 _Alloc_hider(pointer __dat,
const _Alloc& __a)
146 : allocator_type(__a), _M_p(__dat) { }
148 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
149 : allocator_type(std::move(__a)), _M_p(__dat) { }
155 _Alloc_hider _M_dataplus;
156 size_type _M_string_length;
158 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
162 _CharT _M_local_buf[_S_local_capacity + 1];
163 size_type _M_allocated_capacity;
168 { _M_dataplus._M_p = __p; }
171 _M_length(size_type __length)
172 { _M_string_length = __length; }
176 {
return _M_dataplus._M_p; }
181 #if __cplusplus >= 201103L
184 return pointer(_M_local_buf);
189 _M_local_data()
const
191 #if __cplusplus >= 201103L
194 return const_pointer(_M_local_buf);
199 _M_capacity(size_type __capacity)
200 { _M_allocated_capacity = __capacity; }
203 _M_set_length(size_type __n)
206 traits_type::assign(_M_data()[__n], _CharT());
211 {
return _M_data() == _M_local_data(); }
215 _M_create(size_type&, size_type);
221 _M_destroy(_M_allocated_capacity);
225 _M_destroy(size_type __size)
throw()
226 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
230 template<
typename _InIterator>
232 _M_construct_aux(_InIterator __beg, _InIterator __end,
235 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
236 _M_construct(__beg, __end, _Tag());
241 template<
typename _Integer>
243 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
244 { _M_construct_aux_2(static_cast<size_type>(__beg), __end); }
247 _M_construct_aux_2(size_type __req, _CharT __c)
248 { _M_construct(__req, __c); }
250 template<
typename _InIterator>
252 _M_construct(_InIterator __beg, _InIterator __end)
254 typedef typename std::__is_integer<_InIterator>::__type _Integral;
255 _M_construct_aux(__beg, __end, _Integral());
259 template<
typename _InIterator>
261 _M_construct(_InIterator __beg, _InIterator __end,
266 template<
typename _FwdIterator>
268 _M_construct(_FwdIterator __beg, _FwdIterator __end,
272 _M_construct(size_type __req, _CharT __c);
276 {
return _M_dataplus; }
278 const allocator_type&
279 _M_get_allocator()
const
280 {
return _M_dataplus; }
284 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
287 template<
typename _Tp,
bool _Requires =
288 !__are_same<_Tp, _CharT*>::__value
289 && !__are_same<_Tp, const _CharT*>::__value
290 && !__are_same<_Tp, iterator>::__value
291 && !__are_same<_Tp, const_iterator>::__value>
292 struct __enable_if_not_native_iterator
294 template<
typename _Tp>
295 struct __enable_if_not_native_iterator<_Tp, false> { };
299 _M_check(size_type __pos,
const char* __s)
const
301 if (__pos > this->
size())
302 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
303 "this->size() (which is %zu)"),
304 __s, __pos, this->
size());
309 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
312 __throw_length_error(__N(__s));
318 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
320 const bool __testoff = __off < this->
size() - __pos;
321 return __testoff ? __off : this->
size() - __pos;
326 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
328 return (less<const _CharT*>()(__s, _M_data())
329 || less<const _CharT*>()(_M_data() + this->
size(), __s));
335 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
338 traits_type::assign(*__d, *__s);
340 traits_type::copy(__d, __s, __n);
344 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
347 traits_type::assign(*__d, *__s);
349 traits_type::move(__d, __s, __n);
353 _S_assign(_CharT* __d, size_type __n, _CharT __c)
356 traits_type::assign(*__d, __c);
358 traits_type::assign(__d, __n, __c);
363 template<
class _Iterator>
365 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
367 for (; __k1 != __k2; ++__k1, (void)++__p)
368 traits_type::assign(*__p, *__k1);
372 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
373 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
376 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
378 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
381 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
382 { _S_copy(__p, __k1, __k2 - __k1); }
385 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
387 { _S_copy(__p, __k1, __k2 - __k1); }
390 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
392 const difference_type __d = difference_type(__n1 - __n2);
394 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
395 return __gnu_cxx::__numeric_traits<int>::__max;
396 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
397 return __gnu_cxx::__numeric_traits<int>::__min;
406 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
410 _M_erase(size_type __pos, size_type __n);
421 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
422 : _M_dataplus(_M_local_data())
423 { _M_set_length(0); }
430 : _M_dataplus(_M_local_data(), __a)
431 { _M_set_length(0); }
438 : _M_dataplus(_M_local_data(),
439 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
440 { _M_construct(__str._M_data(), __str._M_data() + __str.length()); }
451 const _Alloc& __a = _Alloc())
452 : _M_dataplus(_M_local_data(), __a)
454 const _CharT* __start = __str._M_data()
455 + __str._M_check(__pos,
"basic_string::basic_string");
456 _M_construct(__start, __start + __str._M_limit(__pos,
npos));
467 : _M_dataplus(_M_local_data())
469 const _CharT* __start = __str._M_data()
470 + __str._M_check(__pos,
"basic_string::basic_string");
471 _M_construct(__start, __start + __str._M_limit(__pos, __n));
482 size_type __n,
const _Alloc& __a)
483 : _M_dataplus(_M_local_data(), __a)
485 const _CharT* __start
486 = __str._M_data() + __str._M_check(__pos,
"string::string");
487 _M_construct(__start, __start + __str._M_limit(__pos, __n));
500 const _Alloc& __a = _Alloc())
501 : _M_dataplus(_M_local_data(), __a)
502 { _M_construct(__s, __s + __n); }
509 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
512 template<
typename = _RequireAllocator<_Alloc>>
514 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
515 : _M_dataplus(_M_local_data(), __a)
516 { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+
npos); }
524 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
527 template<
typename = _RequireAllocator<_Alloc>>
529 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
530 : _M_dataplus(_M_local_data(), __a)
531 { _M_construct(__n, __c); }
533 #if __cplusplus >= 201103L
542 : _M_dataplus(_M_local_data(), std::move(__str._M_get_allocator()))
544 if (__str._M_is_local())
546 traits_type::copy(_M_local_buf, __str._M_local_buf,
547 _S_local_capacity + 1);
551 _M_data(__str._M_data());
552 _M_capacity(__str._M_allocated_capacity);
558 _M_length(__str.length());
559 __str._M_data(__str._M_local_data());
560 __str._M_set_length(0);
568 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
569 : _M_dataplus(_M_local_data(), __a)
570 { _M_construct(__l.begin(), __l.end()); }
573 : _M_dataplus(_M_local_data(), __a)
574 { _M_construct(__str.begin(), __str.end()); }
577 noexcept(_Alloc_traits::_S_always_equal())
578 : _M_dataplus(_M_local_data(), __a)
580 if (__str._M_is_local())
582 traits_type::copy(_M_local_buf, __str._M_local_buf,
583 _S_local_capacity + 1);
584 _M_length(__str.length());
585 __str._M_set_length(0);
587 else if (_Alloc_traits::_S_always_equal()
588 || __str.get_allocator() == __a)
590 _M_data(__str._M_data());
591 _M_length(__str.length());
592 _M_capacity(__str._M_allocated_capacity);
593 __str._M_data(__str._M_local_buf);
594 __str._M_set_length(0);
597 _M_construct(__str.begin(), __str.end());
608 #if __cplusplus >= 201103L
609 template<
typename _InputIterator,
610 typename = std::_RequireInputIter<_InputIterator>>
612 template<
typename _InputIterator>
614 basic_string(_InputIterator __beg, _InputIterator __end,
615 const _Alloc& __a = _Alloc())
616 : _M_dataplus(_M_local_data(), __a)
617 { _M_construct(__beg, __end); }
619 #if __cplusplus > 201402L
627 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
628 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
629 const _Alloc& __a = _Alloc())
630 : basic_string(_S_to_string_view(__t).
substr(__pos, __n), __a) { }
637 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
639 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
640 : basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
666 #if __cplusplus >= 201103L
667 if (_Alloc_traits::_S_propagate_on_copy_assign())
669 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
670 && _M_get_allocator() != __str._M_get_allocator())
674 if (__str.size() <= _S_local_capacity)
676 _M_destroy(_M_allocated_capacity);
677 _M_data(_M_local_data());
682 const auto __len = __str.size();
683 auto __alloc = __str._M_get_allocator();
685 auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1);
686 _M_destroy(_M_allocated_capacity);
689 _M_set_length(__len);
692 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
695 return this->
assign(__str);
704 {
return this->
assign(__s); }
720 #if __cplusplus >= 201103L
733 noexcept(_Alloc_traits::_S_nothrow_move())
735 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
736 && !_Alloc_traits::_S_always_equal()
737 && _M_get_allocator() != __str._M_get_allocator())
740 _M_destroy(_M_allocated_capacity);
741 _M_data(_M_local_data());
745 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
747 if (!__str._M_is_local()
748 && (_Alloc_traits::_S_propagate_on_move_assign()
749 || _Alloc_traits::_S_always_equal()))
751 pointer __data =
nullptr;
752 size_type __capacity;
755 if (_Alloc_traits::_S_always_equal())
758 __capacity = _M_allocated_capacity;
761 _M_destroy(_M_allocated_capacity);
764 _M_data(__str._M_data());
765 _M_length(__str.length());
766 _M_capacity(__str._M_allocated_capacity);
769 __str._M_data(__data);
770 __str._M_capacity(__capacity);
773 __str._M_data(__str._M_local_buf);
788 this->
assign(__l.begin(), __l.size());
793 #if __cplusplus > 201402L
798 template<
typename _Tp>
799 _If_sv<_Tp, basic_string&>
801 {
return this->
assign(__svt); }
807 operator __sv_type() const noexcept
808 {
return __sv_type(
data(),
size()); }
817 begin() _GLIBCXX_NOEXCEPT
818 {
return iterator(_M_data()); }
825 begin() const _GLIBCXX_NOEXCEPT
826 {
return const_iterator(_M_data()); }
833 end() _GLIBCXX_NOEXCEPT
834 {
return iterator(_M_data() + this->
size()); }
841 end() const _GLIBCXX_NOEXCEPT
842 {
return const_iterator(_M_data() + this->
size()); }
850 rbegin() _GLIBCXX_NOEXCEPT
851 {
return reverse_iterator(this->
end()); }
858 const_reverse_iterator
859 rbegin() const _GLIBCXX_NOEXCEPT
860 {
return const_reverse_iterator(this->
end()); }
868 rend() _GLIBCXX_NOEXCEPT
869 {
return reverse_iterator(this->
begin()); }
876 const_reverse_iterator
877 rend() const _GLIBCXX_NOEXCEPT
878 {
return const_reverse_iterator(this->
begin()); }
880 #if __cplusplus >= 201103L
887 {
return const_iterator(this->_M_data()); }
894 cend() const noexcept
895 {
return const_iterator(this->_M_data() + this->
size()); }
902 const_reverse_iterator
904 {
return const_reverse_iterator(this->
end()); }
911 const_reverse_iterator
912 crend() const noexcept
913 {
return const_reverse_iterator(this->
begin()); }
921 size() const _GLIBCXX_NOEXCEPT
922 {
return _M_string_length; }
927 length() const _GLIBCXX_NOEXCEPT
928 {
return _M_string_length; }
933 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
946 resize(size_type __n, _CharT __c);
960 { this->
resize(__n, _CharT()); }
962 #if __cplusplus >= 201103L
986 return _M_is_local() ? size_type(_S_local_capacity)
987 : _M_allocated_capacity;
1008 reserve(size_type __res_arg = 0);
1014 clear() _GLIBCXX_NOEXCEPT
1015 { _M_set_length(0); }
1022 empty() const _GLIBCXX_NOEXCEPT
1023 {
return this->
size() == 0; }
1037 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
1039 __glibcxx_assert(__pos <=
size());
1040 return _M_data()[__pos];
1058 __glibcxx_assert(__pos <=
size());
1060 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1061 return _M_data()[__pos];
1075 at(size_type __n)
const
1077 if (__n >= this->
size())
1078 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1079 "(which is %zu) >= this->size() "
1082 return _M_data()[__n];
1099 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1100 "(which is %zu) >= this->size() "
1103 return _M_data()[__n];
1106 #if __cplusplus >= 201103L
1114 __glibcxx_assert(!
empty());
1123 front() const noexcept
1125 __glibcxx_assert(!
empty());
1136 __glibcxx_assert(!
empty());
1145 back() const noexcept
1147 __glibcxx_assert(!
empty());
1160 {
return this->
append(__str); }
1169 {
return this->
append(__s); }
1183 #if __cplusplus >= 201103L
1191 {
return this->
append(__l.begin(), __l.size()); }
1194 #if __cplusplus > 201402L
1200 template<
typename _Tp>
1201 _If_sv<_Tp, basic_string&>
1203 {
return this->
append(__svt); }
1213 {
return _M_append(__str._M_data(), __str.size()); }
1230 {
return _M_append(__str._M_data()
1231 + __str._M_check(__pos,
"basic_string::append"),
1232 __str._M_limit(__pos, __n)); }
1241 append(
const _CharT* __s, size_type __n)
1243 __glibcxx_requires_string_len(__s, __n);
1244 _M_check_length(size_type(0), __n,
"basic_string::append");
1245 return _M_append(__s, __n);
1254 append(
const _CharT* __s)
1256 __glibcxx_requires_string(__s);
1257 const size_type __n = traits_type::length(__s);
1258 _M_check_length(size_type(0), __n,
"basic_string::append");
1259 return _M_append(__s, __n);
1271 append(size_type __n, _CharT __c)
1272 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1274 #if __cplusplus >= 201103L
1281 append(initializer_list<_CharT> __l)
1282 {
return this->
append(__l.begin(), __l.size()); }
1293 #if __cplusplus >= 201103L
1294 template<
class _InputIterator,
1295 typename = std::_RequireInputIter<_InputIterator>>
1297 template<
class _InputIterator>
1300 append(_InputIterator __first, _InputIterator __last)
1303 #if __cplusplus > 201402L
1309 template<
typename _Tp>
1310 _If_sv<_Tp, basic_string&>
1313 __sv_type __sv = __svt;
1314 return this->
append(__sv.data(), __sv.size());
1324 template<
typename _Tp>
1325 _If_sv<_Tp, basic_string&>
1326 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1328 __sv_type __sv = __svt;
1329 return _M_append(__sv.data()
1330 + __sv._M_check(__pos,
"basic_string::append"),
1331 __sv._M_limit(__pos, __n));
1342 const size_type __size = this->
size();
1344 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1345 traits_type::assign(this->_M_data()[__size], __c);
1346 this->_M_set_length(__size + 1);
1357 this->_M_assign(__str);
1361 #if __cplusplus >= 201103L
1372 noexcept(_Alloc_traits::_S_nothrow_move())
1376 return *
this = std::move(__str);
1395 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1396 + __str._M_check(__pos,
"basic_string::assign"),
1397 __str._M_limit(__pos, __n)); }
1410 assign(
const _CharT* __s, size_type __n)
1412 __glibcxx_requires_string_len(__s, __n);
1413 return _M_replace(size_type(0), this->
size(), __s, __n);
1426 assign(
const _CharT* __s)
1428 __glibcxx_requires_string(__s);
1429 return _M_replace(size_type(0), this->
size(), __s,
1430 traits_type::length(__s));
1443 assign(size_type __n, _CharT __c)
1444 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1454 #if __cplusplus >= 201103L
1455 template<
class _InputIterator,
1456 typename = std::_RequireInputIter<_InputIterator>>
1458 template<
class _InputIterator>
1461 assign(_InputIterator __first, _InputIterator __last)
1464 #if __cplusplus >= 201103L
1471 assign(initializer_list<_CharT> __l)
1472 {
return this->
assign(__l.begin(), __l.size()); }
1475 #if __cplusplus > 201402L
1481 template<
typename _Tp>
1482 _If_sv<_Tp, basic_string&>
1485 __sv_type __sv = __svt;
1486 return this->
assign(__sv.data(), __sv.size());
1496 template<
typename _Tp>
1497 _If_sv<_Tp, basic_string&>
1498 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1500 __sv_type __sv = __svt;
1501 return _M_replace(size_type(0), this->
size(), __sv.data()
1502 + __sv._M_check(__pos,
"basic_string::assign"),
1503 __sv._M_limit(__pos, __n));
1507 #if __cplusplus >= 201103L
1524 insert(const_iterator __p, size_type __n, _CharT __c)
1526 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1527 const size_type __pos = __p -
begin();
1528 this->
replace(__p, __p, __n, __c);
1529 return iterator(this->_M_data() + __pos);
1546 insert(iterator __p, size_type __n, _CharT __c)
1547 { this->
replace(__p, __p, __n, __c); }
1550 #if __cplusplus >= 201103L
1565 template<
class _InputIterator,
1566 typename = std::_RequireInputIter<_InputIterator>>
1568 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1570 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1571 const size_type __pos = __p -
begin();
1572 this->
replace(__p, __p, __beg, __end);
1573 return iterator(this->_M_data() + __pos);
1588 template<
class _InputIterator>
1590 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1591 { this->
replace(__p, __p, __beg, __end); }
1594 #if __cplusplus >= 201103L
1602 insert(iterator __p, initializer_list<_CharT> __l)
1604 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1605 this->
insert(__p -
begin(), __l.begin(), __l.size());
1623 {
return this->
replace(__pos1, size_type(0),
1624 __str._M_data(), __str.size()); }
1646 size_type __pos2, size_type __n =
npos)
1647 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1648 + __str._M_check(__pos2,
"basic_string::insert"),
1649 __str._M_limit(__pos2, __n)); }
1668 insert(size_type __pos,
const _CharT* __s, size_type __n)
1669 {
return this->
replace(__pos, size_type(0), __s, __n); }
1687 insert(size_type __pos,
const _CharT* __s)
1689 __glibcxx_requires_string(__s);
1690 return this->
replace(__pos, size_type(0), __s,
1691 traits_type::length(__s));
1711 insert(size_type __pos, size_type __n, _CharT __c)
1712 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1713 size_type(0), __n, __c); }
1729 insert(__const_iterator __p, _CharT __c)
1731 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1732 const size_type __pos = __p -
begin();
1733 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1734 return iterator(_M_data() + __pos);
1737 #if __cplusplus > 201402L
1744 template<
typename _Tp>
1745 _If_sv<_Tp, basic_string&>
1746 insert(size_type __pos,
const _Tp& __svt)
1748 __sv_type __sv = __svt;
1749 return this->
insert(__pos, __sv.data(), __sv.size());
1761 template<
typename _Tp>
1762 _If_sv<_Tp, basic_string&>
1763 insert(size_type __pos1,
const _Tp& __svt,
1764 size_type __pos2, size_type __n =
npos)
1766 __sv_type __sv = __svt;
1767 return this->
replace(__pos1, size_type(0), __sv.data()
1768 + __sv._M_check(__pos2,
"basic_string::insert"),
1769 __sv._M_limit(__pos2, __n));
1789 erase(size_type __pos = 0, size_type __n =
npos)
1791 _M_check(__pos,
"basic_string::erase");
1793 this->_M_set_length(__pos);
1795 this->_M_erase(__pos, _M_limit(__pos, __n));
1808 erase(__const_iterator __position)
1810 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1811 && __position <
end());
1812 const size_type __pos = __position -
begin();
1813 this->_M_erase(__pos, size_type(1));
1814 return iterator(_M_data() + __pos);
1827 erase(__const_iterator __first, __const_iterator __last)
1829 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1830 && __last <=
end());
1831 const size_type __pos = __first -
begin();
1832 if (__last ==
end())
1833 this->_M_set_length(__pos);
1835 this->_M_erase(__pos, __last - __first);
1836 return iterator(this->_M_data() + __pos);
1839 #if __cplusplus >= 201103L
1848 __glibcxx_assert(!
empty());
1849 _M_erase(
size() - 1, 1);
1872 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1894 size_type __pos2, size_type __n2 =
npos)
1895 {
return this->
replace(__pos1, __n1, __str._M_data()
1896 + __str._M_check(__pos2,
"basic_string::replace"),
1897 __str._M_limit(__pos2, __n2)); }
1918 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1921 __glibcxx_requires_string_len(__s, __n2);
1922 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1923 _M_limit(__pos, __n1), __s, __n2);
1943 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1945 __glibcxx_requires_string(__s);
1946 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1967 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1968 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1969 _M_limit(__pos, __n1), __n2, __c); }
1985 replace(__const_iterator __i1, __const_iterator __i2,
1987 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
2005 replace(__const_iterator __i1, __const_iterator __i2,
2006 const _CharT* __s, size_type __n)
2008 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2010 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2027 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2029 __glibcxx_requires_string(__s);
2030 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2048 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2051 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2053 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2071 #if __cplusplus >= 201103L
2072 template<
class _InputIterator,
2073 typename = std::_RequireInputIter<_InputIterator>>
2075 replace(const_iterator __i1, const_iterator __i2,
2076 _InputIterator __k1, _InputIterator __k2)
2078 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2080 __glibcxx_requires_valid_range(__k1, __k2);
2081 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2082 std::__false_type());
2085 template<
class _InputIterator>
2086 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2087 typename __enable_if_not_native_iterator<_InputIterator>::__type
2091 replace(iterator __i1, iterator __i2,
2092 _InputIterator __k1, _InputIterator __k2)
2094 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2096 __glibcxx_requires_valid_range(__k1, __k2);
2097 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2098 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2105 replace(__const_iterator __i1, __const_iterator __i2,
2106 _CharT* __k1, _CharT* __k2)
2108 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2110 __glibcxx_requires_valid_range(__k1, __k2);
2116 replace(__const_iterator __i1, __const_iterator __i2,
2117 const _CharT* __k1,
const _CharT* __k2)
2119 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2121 __glibcxx_requires_valid_range(__k1, __k2);
2127 replace(__const_iterator __i1, __const_iterator __i2,
2128 iterator __k1, iterator __k2)
2130 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2132 __glibcxx_requires_valid_range(__k1, __k2);
2134 __k1.base(), __k2 - __k1);
2138 replace(__const_iterator __i1, __const_iterator __i2,
2139 const_iterator __k1, const_iterator __k2)
2141 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2143 __glibcxx_requires_valid_range(__k1, __k2);
2145 __k1.base(), __k2 - __k1);
2148 #if __cplusplus >= 201103L
2164 initializer_list<_CharT> __l)
2165 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2168 #if __cplusplus > 201402L
2176 template<
typename _Tp>
2177 _If_sv<_Tp, basic_string&>
2178 replace(size_type __pos, size_type __n,
const _Tp& __svt)
2180 __sv_type __sv = __svt;
2181 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2193 template<
typename _Tp>
2194 _If_sv<_Tp, basic_string&>
2195 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2196 size_type __pos2, size_type __n2 =
npos)
2198 __sv_type __sv = __svt;
2199 return this->
replace(__pos1, __n1, __sv.data()
2200 + __sv._M_check(__pos2,
"basic_string::replace"),
2201 __sv._M_limit(__pos2, __n2));
2213 template<
typename _Tp>
2214 _If_sv<_Tp, basic_string&>
2215 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2217 __sv_type __sv = __svt;
2218 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2223 template<
class _Integer>
2225 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2226 _Integer __n, _Integer __val, __true_type)
2227 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2229 template<
class _InputIterator>
2231 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2232 _InputIterator __k1, _InputIterator __k2,
2236 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2240 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2241 const size_type __len2);
2244 _M_append(
const _CharT* __s, size_type __n);
2261 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2281 c_str() const _GLIBCXX_NOEXCEPT
2282 {
return _M_data(); }
2293 data() const _GLIBCXX_NOEXCEPT
2294 {
return _M_data(); }
2296 #if __cplusplus > 201402L
2305 {
return _M_data(); }
2313 {
return _M_get_allocator(); }
2328 find(
const _CharT* __s, size_type __pos, size_type __n)
const
2344 {
return this->
find(__str.data(), __pos, __str.size()); }
2346 #if __cplusplus > 201402L
2353 template<
typename _Tp>
2354 _If_sv<_Tp, size_type>
2355 find(
const _Tp& __svt, size_type __pos = 0) const
2356 noexcept(is_same<_Tp, __sv_type>::value)
2358 __sv_type __sv = __svt;
2359 return this->
find(__sv.data(), __pos, __sv.size());
2374 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2376 __glibcxx_requires_string(__s);
2377 return this->
find(__s, __pos, traits_type::length(__s));
2391 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2406 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2408 #if __cplusplus > 201402L
2415 template<
typename _Tp>
2416 _If_sv<_Tp, size_type>
2417 rfind(
const _Tp& __svt, size_type __pos =
npos) const
2418 noexcept(is_same<_Tp, __sv_type>::value)
2420 __sv_type __sv = __svt;
2421 return this->
rfind(__sv.data(), __pos, __sv.size());
2438 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
2452 rfind(
const _CharT* __s, size_type __pos =
npos)
const
2454 __glibcxx_requires_string(__s);
2455 return this->
rfind(__s, __pos, traits_type::length(__s));
2469 rfind(_CharT __c, size_type __pos =
npos) const _GLIBCXX_NOEXCEPT;
2485 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2487 #if __cplusplus > 201402L
2495 template<
typename _Tp>
2496 _If_sv<_Tp, size_type>
2498 noexcept(is_same<_Tp, __sv_type>::value)
2500 __sv_type __sv = __svt;
2501 return this->
find_first_of(__sv.data(), __pos, __sv.size());
2518 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2535 __glibcxx_requires_string(__s);
2536 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2552 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2553 {
return this->
find(__c, __pos); }
2569 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2571 #if __cplusplus > 201402L
2579 template<
typename _Tp>
2580 _If_sv<_Tp, size_type>
2582 noexcept(is_same<_Tp, __sv_type>::value)
2584 __sv_type __sv = __svt;
2585 return this->
find_last_of(__sv.data(), __pos, __sv.size());
2602 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2619 __glibcxx_requires_string(__s);
2620 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2637 {
return this->
rfind(__c, __pos); }
2654 #if __cplusplus > 201402L
2662 template<
typename _Tp>
2663 _If_sv<_Tp, size_type>
2665 noexcept(is_same<_Tp, __sv_type>::value)
2667 __sv_type __sv = __svt;
2686 size_type __n)
const _GLIBCXX_NOEXCEPT;
2702 __glibcxx_requires_string(__s);
2736 #if __cplusplus > 201402L
2744 template<
typename _Tp>
2745 _If_sv<_Tp, size_type>
2747 noexcept(is_same<_Tp, __sv_type>::value)
2749 __sv_type __sv = __svt;
2768 size_type __n)
const _GLIBCXX_NOEXCEPT;
2784 __glibcxx_requires_string(__s);
2815 substr(size_type __pos = 0, size_type __n =
npos)
const
2817 _M_check(__pos,
"basic_string::substr"), __n); }
2836 const size_type __size = this->
size();
2837 const size_type __osize = __str.size();
2838 const size_type __len =
std::min(__size, __osize);
2840 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2842 __r = _S_compare(__size, __osize);
2846 #if __cplusplus > 201402L
2852 template<
typename _Tp>
2854 compare(
const _Tp& __svt)
const
2855 noexcept(is_same<_Tp, __sv_type>::value)
2857 __sv_type __sv = __svt;
2858 const size_type __size = this->
size();
2859 const size_type __osize = __sv.size();
2860 const size_type __len =
std::min(__size, __osize);
2862 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
2864 __r = _S_compare(__size, __osize);
2876 template<
typename _Tp>
2878 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
2879 noexcept(is_same<_Tp, __sv_type>::value)
2881 __sv_type __sv = __svt;
2882 return __sv_type(*this).substr(__pos, __n).compare(__sv);
2895 template<
typename _Tp>
2897 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
2898 size_type __pos2, size_type __n2 = npos) const
2899 noexcept(is_same<_Tp, __sv_type>::value)
2901 __sv_type __sv = __svt;
2902 return __sv_type(*
this)
2903 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
2954 size_type __pos2, size_type __n2 = npos)
const;
2971 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
2995 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
3022 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3023 size_type __n2)
const;
3026 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3028 _GLIBCXX_END_NAMESPACE_CXX11
3029 #else // !_GLIBCXX_USE_CXX11_ABI
3094 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3097 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
3101 typedef _Traits traits_type;
3102 typedef typename _Traits::char_type value_type;
3103 typedef _Alloc allocator_type;
3104 typedef typename _CharT_alloc_type::size_type size_type;
3105 typedef typename _CharT_alloc_type::difference_type difference_type;
3106 typedef typename _CharT_alloc_type::reference reference;
3107 typedef typename _CharT_alloc_type::const_reference const_reference;
3108 typedef typename _CharT_alloc_type::pointer pointer;
3109 typedef typename _CharT_alloc_type::const_pointer const_pointer;
3110 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
3111 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
3133 size_type _M_length;
3134 size_type _M_capacity;
3135 _Atomic_word _M_refcount;
3138 struct _Rep : _Rep_base
3141 typedef typename _Alloc::template rebind<char>::other _Raw_bytes_alloc;
3156 static const size_type _S_max_size;
3157 static const _CharT _S_terminal;
3161 static size_type _S_empty_rep_storage[];
3164 _S_empty_rep() _GLIBCXX_NOEXCEPT
3169 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
3170 return *
reinterpret_cast<_Rep*
>(__p);
3174 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
3176 #if defined(__GTHREADS)
3181 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
3183 return this->_M_refcount < 0;
3188 _M_is_shared()
const _GLIBCXX_NOEXCEPT
3190 #if defined(__GTHREADS)
3196 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
3198 return this->_M_refcount > 0;
3203 _M_set_leaked() _GLIBCXX_NOEXCEPT
3204 { this->_M_refcount = -1; }
3207 _M_set_sharable() _GLIBCXX_NOEXCEPT
3208 { this->_M_refcount = 0; }
3211 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
3213 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3214 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3217 this->_M_set_sharable();
3218 this->_M_length = __n;
3219 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
3226 _M_refdata()
throw()
3227 {
return reinterpret_cast<_CharT*
>(
this + 1); }
3230 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
3232 return (!_M_is_leaked() && __alloc1 == __alloc2)
3233 ? _M_refcopy() : _M_clone(__alloc1);
3238 _S_create(size_type, size_type,
const _Alloc&);
3241 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3243 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3244 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3248 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
3257 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
3260 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
3267 _M_destroy(
const _Alloc&)
throw();
3270 _M_refcopy()
throw()
3272 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3273 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3275 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
3276 return _M_refdata();
3280 _M_clone(
const _Alloc&, size_type __res = 0);
3284 struct _Alloc_hider : _Alloc
3286 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3287 : _Alloc(__a), _M_p(__dat) { }
3297 static const size_type npos =
static_cast<size_type
>(-1);
3301 mutable _Alloc_hider _M_dataplus;
3304 _M_data() const _GLIBCXX_NOEXCEPT
3305 {
return _M_dataplus._M_p; }
3308 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
3309 {
return (_M_dataplus._M_p = __p); }
3312 _M_rep() const _GLIBCXX_NOEXCEPT
3313 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
3318 _M_ibegin() const _GLIBCXX_NOEXCEPT
3319 {
return iterator(_M_data()); }
3322 _M_iend() const _GLIBCXX_NOEXCEPT
3323 {
return iterator(_M_data() + this->
size()); }
3328 if (!_M_rep()->_M_is_leaked())
3333 _M_check(size_type __pos,
const char* __s)
const
3335 if (__pos > this->
size())
3336 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
3337 "this->size() (which is %zu)"),
3338 __s, __pos, this->
size());
3343 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
3346 __throw_length_error(__N(__s));
3351 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
3353 const bool __testoff = __off < this->
size() - __pos;
3354 return __testoff ? __off : this->
size() - __pos;
3359 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3361 return (less<const _CharT*>()(__s, _M_data())
3362 || less<const _CharT*>()(_M_data() + this->
size(), __s));
3368 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3371 traits_type::assign(*__d, *__s);
3373 traits_type::copy(__d, __s, __n);
3377 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3380 traits_type::assign(*__d, *__s);
3382 traits_type::move(__d, __s, __n);
3386 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
3389 traits_type::assign(*__d, __c);
3391 traits_type::assign(__d, __n, __c);
3396 template<
class _Iterator>
3398 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
3400 for (; __k1 != __k2; ++__k1, (void)++__p)
3401 traits_type::assign(*__p, *__k1);
3405 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
3406 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3409 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
3411 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3414 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
3415 { _M_copy(__p, __k1, __k2 - __k1); }
3418 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
3420 { _M_copy(__p, __k1, __k2 - __k1); }
3423 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
3425 const difference_type __d = difference_type(__n1 - __n2);
3427 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
3428 return __gnu_cxx::__numeric_traits<int>::__max;
3429 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
3430 return __gnu_cxx::__numeric_traits<int>::__min;
3436 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
3442 _S_empty_rep() _GLIBCXX_NOEXCEPT
3443 {
return _Rep::_S_empty_rep(); }
3445 #if __cplusplus > 201402L
3447 typedef basic_string_view<_CharT, _Traits> __sv_type;
3449 template<
typename _Tp,
typename _Res>
3451 __and_<is_convertible<const _Tp&, __sv_type>,
3452 __not_<is_convertible<const _Tp*, const basic_string*>>,
3453 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
3458 _S_to_string_view(__sv_type __svt)
noexcept
3467 explicit __sv_wrapper(__sv_type __sv)
noexcept : _M_sv(__sv) { }
3481 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3482 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) { }
3484 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc()){ }
3509 const _Alloc& __a = _Alloc());
3527 size_type __n,
const _Alloc& __a);
3539 const _Alloc& __a = _Alloc());
3545 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
3552 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3554 #if __cplusplus >= 201103L
3563 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3566 : _M_dataplus(__str._M_dataplus)
3568 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3569 __str._M_data(_S_empty_rep()._M_refdata());
3571 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3589 template<
class _InputIterator>
3590 basic_string(_InputIterator __beg, _InputIterator __end,
3591 const _Alloc& __a = _Alloc());
3593 #if __cplusplus > 201402L
3601 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3602 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
3603 const _Alloc& __a = _Alloc())
3604 : basic_string(_S_to_string_view(__t).
substr(__pos, __n), __a) { }
3611 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3613 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
3614 : basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
3639 {
return this->
assign(__str); }
3647 {
return this->
assign(__s); }
3663 #if __cplusplus >= 201103L
3687 this->
assign(__l.begin(), __l.size());
3692 #if __cplusplus > 201402L
3697 template<
typename _Tp>
3698 _If_sv<_Tp, basic_string&>
3700 {
return this->
assign(__svt); }
3706 operator __sv_type() const noexcept
3707 {
return __sv_type(
data(),
size()); }
3719 return iterator(_M_data());
3728 {
return const_iterator(_M_data()); }
3738 return iterator(_M_data() + this->
size());
3747 {
return const_iterator(_M_data() + this->
size()); }
3763 const_reverse_iterator
3781 const_reverse_iterator
3785 #if __cplusplus >= 201103L
3792 {
return const_iterator(this->_M_data()); }
3800 {
return const_iterator(this->_M_data() + this->
size()); }
3807 const_reverse_iterator
3816 const_reverse_iterator
3827 {
return _M_rep()->_M_length; }
3833 {
return _M_rep()->_M_length; }
3838 {
return _Rep::_S_max_size; }
3851 resize(size_type __n, _CharT __c);
3865 { this->
resize(__n, _CharT()); }
3867 #if __cplusplus >= 201103L
3872 #if __cpp_exceptions
3890 {
return _M_rep()->_M_capacity; }
3910 reserve(size_type __res_arg = 0);
3915 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3919 if (_M_rep()->_M_is_shared())
3922 _M_data(_S_empty_rep()._M_refdata());
3925 _M_rep()->_M_set_length_and_sharable(0);
3931 { _M_mutate(0, this->
size(), 0); }
3940 {
return this->
size() == 0; }
3956 __glibcxx_assert(__pos <=
size());
3957 return _M_data()[__pos];
3975 __glibcxx_assert(__pos <=
size());
3977 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
3979 return _M_data()[__pos];
3995 if (__n >= this->
size())
3996 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
3997 "(which is %zu) >= this->size() "
4000 return _M_data()[__n];
4018 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
4019 "(which is %zu) >= this->size() "
4023 return _M_data()[__n];
4026 #if __cplusplus >= 201103L
4034 __glibcxx_assert(!
empty());
4045 __glibcxx_assert(!
empty());
4056 __glibcxx_assert(!
empty());
4067 __glibcxx_assert(!
empty());
4080 {
return this->
append(__str); }
4089 {
return this->
append(__s); }
4103 #if __cplusplus >= 201103L
4111 {
return this->
append(__l.begin(), __l.size()); }
4114 #if __cplusplus > 201402L
4120 template<
typename _Tp>
4121 _If_sv<_Tp, basic_string&>
4123 {
return this->
append(__svt); }
4157 append(
const _CharT* __s, size_type __n);
4167 __glibcxx_requires_string(__s);
4168 return this->
append(__s, traits_type::length(__s));
4180 append(size_type __n, _CharT __c);
4182 #if __cplusplus >= 201103L
4190 {
return this->
append(__l.begin(), __l.size()); }
4201 template<
class _InputIterator>
4203 append(_InputIterator __first, _InputIterator __last)
4204 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
4206 #if __cplusplus > 201402L
4212 template<
typename _Tp>
4213 _If_sv<_Tp, basic_string&>
4216 __sv_type __sv = __svt;
4217 return this->
append(__sv.data(), __sv.size());
4228 template<
typename _Tp>
4229 _If_sv<_Tp, basic_string&>
4230 append(
const _Tp& __svt, size_type __pos, size_type __n = npos)
4232 __sv_type __sv = __svt;
4233 return append(__sv.data()
4234 + __sv._M_check(__pos,
"basic_string::append"),
4235 __sv._M_limit(__pos, __n));
4246 const size_type __len = 1 + this->
size();
4247 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
4249 traits_type::assign(_M_data()[this->
size()], __c);
4250 _M_rep()->_M_set_length_and_sharable(__len);
4261 #if __cplusplus >= 201103L
4294 {
return this->
assign(__str._M_data()
4295 + __str._M_check(__pos,
"basic_string::assign"),
4296 __str._M_limit(__pos, __n)); }
4309 assign(
const _CharT* __s, size_type __n);
4323 __glibcxx_requires_string(__s);
4324 return this->
assign(__s, traits_type::length(__s));
4338 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4348 template<
class _InputIterator>
4350 assign(_InputIterator __first, _InputIterator __last)
4351 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4353 #if __cplusplus >= 201103L
4361 {
return this->
assign(__l.begin(), __l.size()); }
4364 #if __cplusplus > 201402L
4370 template<
typename _Tp>
4371 _If_sv<_Tp, basic_string&>
4374 __sv_type __sv = __svt;
4375 return this->
assign(__sv.data(), __sv.size());
4385 template<
typename _Tp>
4386 _If_sv<_Tp, basic_string&>
4387 assign(
const _Tp& __svt, size_type __pos, size_type __n = npos)
4389 __sv_type __sv = __svt;
4390 return assign(__sv.data()
4391 + __sv._M_check(__pos,
"basic_string::assign"),
4392 __sv._M_limit(__pos, __n));
4410 insert(iterator __p, size_type __n, _CharT __c)
4411 { this->
replace(__p, __p, __n, __c); }
4425 template<
class _InputIterator>
4427 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4428 { this->
replace(__p, __p, __beg, __end); }
4430 #if __cplusplus >= 201103L
4440 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4441 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4459 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4481 size_type __pos2, size_type __n = npos)
4482 {
return this->
insert(__pos1, __str._M_data()
4483 + __str._M_check(__pos2,
"basic_string::insert"),
4484 __str._M_limit(__pos2, __n)); }
4503 insert(size_type __pos,
const _CharT* __s, size_type __n);
4523 __glibcxx_requires_string(__s);
4524 return this->
insert(__pos, __s, traits_type::length(__s));
4544 insert(size_type __pos, size_type __n, _CharT __c)
4545 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4546 size_type(0), __n, __c); }
4564 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4565 const size_type __pos = __p - _M_ibegin();
4566 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4567 _M_rep()->_M_set_leaked();
4568 return iterator(_M_data() + __pos);
4571 #if __cplusplus > 201402L
4578 template<
typename _Tp>
4579 _If_sv<_Tp, basic_string&>
4580 insert(size_type __pos,
const _Tp& __svt)
4582 __sv_type __sv = __svt;
4583 return this->
insert(__pos, __sv.data(), __sv.size());
4595 template<
typename _Tp>
4596 _If_sv<_Tp, basic_string&>
4597 insert(size_type __pos1,
const _Tp& __svt,
4598 size_type __pos2, size_type __n = npos)
4600 __sv_type __sv = __svt;
4601 return this->
replace(__pos1, size_type(0), __sv.data()
4602 + __sv._M_check(__pos2,
"basic_string::insert"),
4603 __sv._M_limit(__pos2, __n));
4623 erase(size_type __pos = 0, size_type __n = npos)
4625 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4626 _M_limit(__pos, __n), size_type(0));
4641 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4642 && __position < _M_iend());
4643 const size_type __pos = __position - _M_ibegin();
4644 _M_mutate(__pos, size_type(1), size_type(0));
4645 _M_rep()->_M_set_leaked();
4646 return iterator(_M_data() + __pos);
4661 #if __cplusplus >= 201103L
4670 __glibcxx_assert(!
empty());
4694 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4716 size_type __pos2, size_type __n2 = npos)
4717 {
return this->
replace(__pos1, __n1, __str._M_data()
4718 + __str._M_check(__pos2,
"basic_string::replace"),
4719 __str._M_limit(__pos2, __n2)); }
4740 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4760 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4762 __glibcxx_requires_string(__s);
4763 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4784 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4785 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4786 _M_limit(__pos, __n1), __n2, __c); }
4803 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4821 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4823 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4824 && __i2 <= _M_iend());
4825 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4842 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4844 __glibcxx_requires_string(__s);
4845 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4863 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4865 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4866 && __i2 <= _M_iend());
4867 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4885 template<
class _InputIterator>
4888 _InputIterator __k1, _InputIterator __k2)
4890 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4891 && __i2 <= _M_iend());
4892 __glibcxx_requires_valid_range(__k1, __k2);
4893 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4894 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4902 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4903 && __i2 <= _M_iend());
4904 __glibcxx_requires_valid_range(__k1, __k2);
4905 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4910 replace(iterator __i1, iterator __i2,
4911 const _CharT* __k1,
const _CharT* __k2)
4913 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4914 && __i2 <= _M_iend());
4915 __glibcxx_requires_valid_range(__k1, __k2);
4916 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4921 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
4923 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4924 && __i2 <= _M_iend());
4925 __glibcxx_requires_valid_range(__k1, __k2);
4926 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4927 __k1.base(), __k2 - __k1);
4931 replace(iterator __i1, iterator __i2,
4932 const_iterator __k1, const_iterator __k2)
4934 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4935 && __i2 <= _M_iend());
4936 __glibcxx_requires_valid_range(__k1, __k2);
4937 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4938 __k1.base(), __k2 - __k1);
4941 #if __cplusplus >= 201103L
4958 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
4961 #if __cplusplus > 201402L
4969 template<
typename _Tp>
4970 _If_sv<_Tp, basic_string&>
4971 replace(size_type __pos, size_type __n,
const _Tp& __svt)
4973 __sv_type __sv = __svt;
4974 return this->
replace(__pos, __n, __sv.data(), __sv.size());
4986 template<
typename _Tp>
4987 _If_sv<_Tp, basic_string&>
4988 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
4989 size_type __pos2, size_type __n2 = npos)
4991 __sv_type __sv = __svt;
4992 return this->
replace(__pos1, __n1,
4993 __sv.data() + __sv._M_check(__pos2,
"basic_string::replace"),
4994 __sv._M_limit(__pos2, __n2));
5006 template<
typename _Tp>
5007 _If_sv<_Tp, basic_string&>
5008 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
5010 __sv_type __sv = __svt;
5011 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
5016 template<
class _Integer>
5018 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
5019 _Integer __val, __true_type)
5020 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
5022 template<
class _InputIterator>
5024 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
5025 _InputIterator __k2, __false_type);
5028 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
5032 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
5037 template<
class _InIterator>
5039 _S_construct_aux(_InIterator __beg, _InIterator __end,
5040 const _Alloc& __a, __false_type)
5042 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
5043 return _S_construct(__beg, __end, __a, _Tag());
5048 template<
class _Integer>
5050 _S_construct_aux(_Integer __beg, _Integer __end,
5051 const _Alloc& __a, __true_type)
5052 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
5056 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
5057 {
return _S_construct(__req, __c, __a); }
5059 template<
class _InIterator>
5061 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
5063 typedef typename std::__is_integer<_InIterator>::__type _Integral;
5064 return _S_construct_aux(__beg, __end, __a, _Integral());
5068 template<
class _InIterator>
5070 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
5071 input_iterator_tag);
5075 template<
class _FwdIterator>
5077 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
5078 forward_iterator_tag);
5081 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
5098 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
5120 {
return _M_data(); }
5132 {
return _M_data(); }
5134 #if __cplusplus > 201402L
5154 {
return _M_dataplus; }
5169 find(
const _CharT* __s, size_type __pos, size_type __n)
const
5185 {
return this->
find(__str.data(), __pos, __str.size()); }
5198 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
5200 __glibcxx_requires_string(__s);
5201 return this->
find(__s, __pos, traits_type::length(__s));
5215 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
5217 #if __cplusplus > 201402L
5224 template<
typename _Tp>
5225 _If_sv<_Tp, size_type>
5226 find(
const _Tp& __svt, size_type __pos = 0) const
5227 noexcept(
is_same<_Tp, __sv_type>::value)
5229 __sv_type __sv = __svt;
5230 return this->
find(__sv.data(), __pos, __sv.size());
5247 {
return this->
rfind(__str.data(), __pos, __str.size()); }
5262 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
5276 rfind(
const _CharT* __s, size_type __pos = npos) const _GLIBCXX_NOEXCEPT
5278 __glibcxx_requires_string(__s);
5279 return this->
rfind(__s, __pos, traits_type::length(__s));
5293 rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT;
5295 #if __cplusplus > 201402L
5302 template<
typename _Tp>
5303 _If_sv<_Tp, size_type>
5304 rfind(
const _Tp& __svt, size_type __pos = npos) const
5305 noexcept(
is_same<_Tp, __sv_type>::value)
5307 __sv_type __sv = __svt;
5308 return this->
rfind(__sv.data(), __pos, __sv.size());
5326 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
5341 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
5358 __glibcxx_requires_string(__s);
5359 return this->
find_first_of(__s, __pos, traits_type::length(__s));
5376 {
return this->
find(__c, __pos); }
5378 #if __cplusplus > 201402L
5386 template<
typename _Tp>
5387 _If_sv<_Tp, size_type>
5389 noexcept(
is_same<_Tp, __sv_type>::value)
5391 __sv_type __sv = __svt;
5392 return this->
find_first_of(__sv.data(), __pos, __sv.size());
5410 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5425 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
5442 __glibcxx_requires_string(__s);
5443 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5460 {
return this->
rfind(__c, __pos); }
5462 #if __cplusplus > 201402L
5470 template<
typename _Tp>
5471 _If_sv<_Tp, size_type>
5472 find_last_of(
const _Tp& __svt, size_type __pos = npos) const
5473 noexcept(
is_same<_Tp, __sv_type>::value)
5475 __sv_type __sv = __svt;
5476 return this->
find_last_of(__sv.data(), __pos, __sv.size());
5509 size_type __n)
const _GLIBCXX_NOEXCEPT;
5525 __glibcxx_requires_string(__s);
5543 #if __cplusplus > 201402L
5551 template<
typename _Tp>
5552 _If_sv<_Tp, size_type>
5554 noexcept(
is_same<_Tp, __sv_type>::value)
5556 __sv_type __sv = __svt;
5591 size_type __n)
const _GLIBCXX_NOEXCEPT;
5607 __glibcxx_requires_string(__s);
5625 #if __cplusplus > 201402L
5633 template<
typename _Tp>
5634 _If_sv<_Tp, size_type>
5636 noexcept(
is_same<_Tp, __sv_type>::value)
5638 __sv_type __sv = __svt;
5656 substr(size_type __pos = 0, size_type __n = npos)
const
5658 _M_check(__pos,
"basic_string::substr"), __n); }
5677 const size_type __size = this->
size();
5678 const size_type __osize = __str.size();
5679 const size_type __len =
std::min(__size, __osize);
5681 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5683 __r = _S_compare(__size, __osize);
5687 #if __cplusplus > 201402L
5693 template<
typename _Tp>
5695 compare(
const _Tp& __svt)
const
5698 __sv_type __sv = __svt;
5699 const size_type __size = this->
size();
5700 const size_type __osize = __sv.size();
5701 const size_type __len =
std::min(__size, __osize);
5703 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
5705 __r = _S_compare(__size, __osize);
5717 template<
typename _Tp>
5719 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
5720 noexcept(is_same<_Tp, __sv_type>::value)
5722 __sv_type __sv = __svt;
5723 return __sv_type(*this).substr(__pos, __n).compare(__sv);
5736 template<
typename _Tp>
5738 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
5739 size_type __pos2, size_type __n2 = npos) const
5740 noexcept(is_same<_Tp, __sv_type>::value)
5742 __sv_type __sv = __svt;
5743 return __sv_type(*
this)
5744 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
5795 size_type __pos2, size_type __n2 = npos)
const;
5812 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5836 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5863 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5864 size_type __n2)
const;
5866 # ifdef _GLIBCXX_TM_TS_INTERNAL
5868 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
5871 ::_txnal_cow_string_c_str(
const void *that);
5873 ::_txnal_cow_string_D1(
void *that);
5875 ::_txnal_cow_string_D1_commit(
void *that);
5878 #endif // !_GLIBCXX_USE_CXX11_ABI
5880 #if __cpp_deduction_guides >= 201606
5881 _GLIBCXX_BEGIN_NAMESPACE_CXX11
5882 template<
typename _InputIterator,
typename _CharT
5883 =
typename iterator_traits<_InputIterator>::value_type,
5884 typename _Allocator = allocator<_CharT>,
5885 typename = _RequireInputIter<_InputIterator>,
5886 typename = _RequireAllocator<_Allocator>>
5887 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
5888 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
5892 template<
typename _CharT,
typename _Traits,
5893 typename _Allocator = allocator<_CharT>,
5894 typename = _RequireAllocator<_Allocator>>
5895 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
5896 -> basic_string<_CharT, _Traits, _Allocator>;
5898 template<
typename _CharT,
typename _Traits,
5899 typename _Allocator = allocator<_CharT>,
5900 typename = _RequireAllocator<_Allocator>>
5902 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
5903 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
5904 const _Allocator& = _Allocator())
5905 -> basic_string<_CharT, _Traits, _Allocator>;
5906 _GLIBCXX_END_NAMESPACE_CXX11
5916 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5917 basic_string<_CharT, _Traits, _Alloc>
5922 __str.append(__rhs);
5932 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5933 basic_string<_CharT,_Traits,_Alloc>
5935 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
5943 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5944 basic_string<_CharT,_Traits,_Alloc>
5945 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
5953 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5954 inline basic_string<_CharT, _Traits, _Alloc>
5956 const _CharT* __rhs)
5959 __str.append(__rhs);
5969 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5970 inline basic_string<_CharT, _Traits, _Alloc>
5974 typedef typename __string_type::size_type __size_type;
5975 __string_type __str(__lhs);
5976 __str.append(__size_type(1), __rhs);
5980 #if __cplusplus >= 201103L
5981 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5982 inline basic_string<_CharT, _Traits, _Alloc>
5983 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
5984 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
5985 {
return std::move(__lhs.append(__rhs)); }
5987 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5988 inline basic_string<_CharT, _Traits, _Alloc>
5989 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
5990 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
5991 {
return std::move(__rhs.insert(0, __lhs)); }
5993 template<
typename _CharT,
typename _Traits,
typename _Alloc>
5994 inline basic_string<_CharT, _Traits, _Alloc>
5995 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
5996 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
5998 const auto __size = __lhs.size() + __rhs.size();
5999 const bool __cond = (__size > __lhs.capacity()
6000 && __size <= __rhs.capacity());
6001 return __cond ? std::move(__rhs.insert(0, __lhs))
6002 : std::move(__lhs.append(__rhs));
6005 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6006 inline basic_string<_CharT, _Traits, _Alloc>
6008 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6009 {
return std::move(__rhs.insert(0, __lhs)); }
6011 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6012 inline basic_string<_CharT, _Traits, _Alloc>
6014 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6015 {
return std::move(__rhs.insert(0, 1, __lhs)); }
6017 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6018 inline basic_string<_CharT, _Traits, _Alloc>
6019 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6020 const _CharT* __rhs)
6021 {
return std::move(__lhs.append(__rhs)); }
6023 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6024 inline basic_string<_CharT, _Traits, _Alloc>
6025 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6027 {
return std::move(__lhs.append(1, __rhs)); }
6037 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6042 {
return __lhs.compare(__rhs) == 0; }
6044 template<
typename _CharT>
6046 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
6047 operator==(
const basic_string<_CharT>& __lhs,
6048 const basic_string<_CharT>& __rhs) _GLIBCXX_NOEXCEPT
6049 {
return (__lhs.size() == __rhs.size()
6059 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6061 operator==(
const _CharT* __lhs,
6063 {
return __rhs.compare(__lhs) == 0; }
6071 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6074 const _CharT* __rhs)
6075 {
return __lhs.compare(__rhs) == 0; }
6084 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6089 {
return !(__lhs == __rhs); }
6097 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6099 operator!=(
const _CharT* __lhs,
6101 {
return !(__lhs == __rhs); }
6109 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6112 const _CharT* __rhs)
6113 {
return !(__lhs == __rhs); }
6122 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6124 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6127 {
return __lhs.
compare(__rhs) < 0; }
6135 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6137 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6138 const _CharT* __rhs)
6139 {
return __lhs.compare(__rhs) < 0; }
6147 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6149 operator<(
const _CharT* __lhs,
6151 {
return __rhs.compare(__lhs) > 0; }
6160 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6165 {
return __lhs.compare(__rhs) > 0; }
6173 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6176 const _CharT* __rhs)
6177 {
return __lhs.compare(__rhs) > 0; }
6185 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6187 operator>(
const _CharT* __lhs,
6189 {
return __rhs.compare(__lhs) < 0; }
6198 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6200 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6203 {
return __lhs.
compare(__rhs) <= 0; }
6211 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6213 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6214 const _CharT* __rhs)
6215 {
return __lhs.compare(__rhs) <= 0; }
6223 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6225 operator<=(
const _CharT* __lhs,
6227 {
return __rhs.compare(__lhs) >= 0; }
6236 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6241 {
return __lhs.compare(__rhs) >= 0; }
6249 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6252 const _CharT* __rhs)
6253 {
return __lhs.compare(__rhs) >= 0; }
6261 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6263 operator>=(
const _CharT* __lhs,
6265 {
return __rhs.compare(__lhs) <= 0; }
6274 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6278 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
6279 { __lhs.swap(__rhs); }
6294 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6295 basic_istream<_CharT, _Traits>&
6296 operator>>(basic_istream<_CharT, _Traits>& __is,
6297 basic_string<_CharT, _Traits, _Alloc>& __str);
6300 basic_istream<char>&
6301 operator>>(basic_istream<char>& __is, basic_string<char>& __str);
6312 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6313 inline basic_ostream<_CharT, _Traits>&
6314 operator<<(basic_ostream<_CharT, _Traits>& __os,
6319 return __ostream_insert(__os, __str.data(), __str.size());
6335 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6336 basic_istream<_CharT, _Traits>&
6337 getline(basic_istream<_CharT, _Traits>& __is,
6338 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
6352 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6353 inline basic_istream<_CharT, _Traits>&
6358 #if __cplusplus >= 201103L
6360 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6361 inline basic_istream<_CharT, _Traits>&
6367 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6368 inline basic_istream<_CharT, _Traits>&
6375 basic_istream<char>&
6376 getline(basic_istream<char>& __in, basic_string<char>& __str,
6379 #ifdef _GLIBCXX_USE_WCHAR_T
6381 basic_istream<wchar_t>&
6382 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
6386 _GLIBCXX_END_NAMESPACE_VERSION
6389 #if __cplusplus >= 201103L
6393 namespace std _GLIBCXX_VISIBILITY(default)
6395 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6396 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6398 #if _GLIBCXX_USE_C99_STDLIB
6401 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6402 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
6406 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6407 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
6410 inline unsigned long
6411 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6412 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
6416 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6417 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
6420 inline unsigned long long
6421 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6422 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
6427 stof(
const string& __str,
size_t* __idx = 0)
6428 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
6431 stod(
const string& __str,
size_t* __idx = 0)
6432 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
6435 stold(
const string& __str,
size_t* __idx = 0)
6436 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
6437 #endif // _GLIBCXX_USE_C99_STDLIB
6439 #if _GLIBCXX_USE_C99_STDIO
6444 to_string(
int __val)
6445 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(int),
6449 to_string(
unsigned __val)
6450 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6451 4 *
sizeof(unsigned),
6455 to_string(
long __val)
6456 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(long),
6460 to_string(
unsigned long __val)
6461 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6462 4 *
sizeof(
unsigned long),
6466 to_string(
long long __val)
6467 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6468 4 *
sizeof(
long long),
6472 to_string(
unsigned long long __val)
6473 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6474 4 *
sizeof(
unsigned long long),
6478 to_string(
float __val)
6481 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6482 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6487 to_string(
double __val)
6490 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6491 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6496 to_string(
long double __val)
6499 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6500 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6503 #endif // _GLIBCXX_USE_C99_STDIO
6505 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
6507 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6508 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
6512 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6513 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
6516 inline unsigned long
6517 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6518 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
6522 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6523 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
6526 inline unsigned long long
6527 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6528 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
6533 stof(
const wstring& __str,
size_t* __idx = 0)
6534 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
6537 stod(
const wstring& __str,
size_t* __idx = 0)
6538 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
6541 stold(
const wstring& __str,
size_t* __idx = 0)
6542 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
6544 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
6547 to_wstring(
int __val)
6548 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
6552 to_wstring(
unsigned __val)
6553 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6554 4 *
sizeof(unsigned),
6558 to_wstring(
long __val)
6559 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
6563 to_wstring(
unsigned long __val)
6564 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6565 4 *
sizeof(
unsigned long),
6569 to_wstring(
long long __val)
6570 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6571 4 *
sizeof(
long long),
6575 to_wstring(
unsigned long long __val)
6576 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6577 4 *
sizeof(
unsigned long long),
6581 to_wstring(
float __val)
6584 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6585 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6590 to_wstring(
double __val)
6593 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6594 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6599 to_wstring(
long double __val)
6602 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6603 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6606 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF
6607 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR
6609 _GLIBCXX_END_NAMESPACE_CXX11
6610 _GLIBCXX_END_NAMESPACE_VERSION
6615 #if __cplusplus >= 201103L
6619 namespace std _GLIBCXX_VISIBILITY(default)
6621 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6625 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
6629 :
public __hash_base<size_t, string>
6632 operator()(
const string& __s)
const noexcept
6633 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
6640 #ifdef _GLIBCXX_USE_WCHAR_T
6644 :
public __hash_base<size_t, wstring>
6648 {
return std::_Hash_impl::hash(__s.
data(),
6649 __s.
length() *
sizeof(wchar_t)); }
6658 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
6662 :
public __hash_base<size_t, u16string>
6666 {
return std::_Hash_impl::hash(__s.
data(),
6667 __s.
length() *
sizeof(char16_t)); }
6677 :
public __hash_base<size_t, u32string>
6681 {
return std::_Hash_impl::hash(__s.
data(),
6682 __s.
length() *
sizeof(char32_t)); }
6690 #if __cplusplus > 201103L
6692 #define __cpp_lib_string_udls 201304
6694 inline namespace literals
6696 inline namespace string_literals
6698 #pragma GCC diagnostic push
6699 #pragma GCC diagnostic ignored "-Wliteral-suffix"
6700 _GLIBCXX_DEFAULT_ABI_TAG
6701 inline basic_string<char>
6702 operator""s(
const char* __str,
size_t __len)
6703 {
return basic_string<char>{__str, __len}; }
6705 #ifdef _GLIBCXX_USE_WCHAR_T
6706 _GLIBCXX_DEFAULT_ABI_TAG
6707 inline basic_string<wchar_t>
6708 operator""s(
const wchar_t* __str,
size_t __len)
6709 {
return basic_string<wchar_t>{__str, __len}; }
6712 #ifdef _GLIBCXX_USE_C99_STDINT_TR1
6713 _GLIBCXX_DEFAULT_ABI_TAG
6714 inline basic_string<char16_t>
6715 operator""s(
const char16_t* __str,
size_t __len)
6716 {
return basic_string<char16_t>{__str, __len}; }
6718 _GLIBCXX_DEFAULT_ABI_TAG
6719 inline basic_string<char32_t>
6720 operator""s(
const char32_t* __str,
size_t __len)
6721 {
return basic_string<char32_t>{__str, __len}; }
6724 #pragma GCC diagnostic pop
6728 #endif // __cplusplus > 201103L
6730 _GLIBCXX_END_NAMESPACE_VERSION
bool empty() const noexcept
size_type rfind(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a C string.
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
void pop_back()
Remove the last character.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
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)
Append a string to this string.
basic_string & assign(basic_string &&__str)
Set value to contents of another string.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
basic_string(const _Alloc &__a)
Construct an empty string using allocator a.
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
Uniform interface to all pointer-like types.
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
Uniform interface to C++98 and C++11 allocators.
size_type capacity() const noexcept
const_iterator cbegin() const noexcept
int compare(const basic_string &__str) const
Compare to a string.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
iterator erase(iterator __position)
Remove one character.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
basic_string< wchar_t > wstring
A string of wchar_t.
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
enable_if< ::__array_traits< _Tp, _Nm >::_Is_swappable::value >::type noexcept(noexcept(__one.swap(__two)))
swap
basic_string & append(const basic_string &__str)
Append a string to this 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.
const_reverse_iterator rbegin() const noexcept
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
void swap(basic_string &__s)
Swap contents with another string.
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.
Forward iterators support a superset of input iterator operations.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character of C string.
const_reverse_iterator rend() const noexcept
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
const_iterator end() const noexcept
static const size_type npos
Value returned by various member functions when they fail.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character of C string.
reverse_iterator rbegin()
const _CharT * data() const noexcept
Return const pointer to contents.
reference at(size_type __n)
Provides access to the data contained in the string.
iterator insert(iterator __p, _CharT __c)
Insert one character.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
const_iterator cend() const noexcept
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n=npos)
Insert a substring.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
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.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n=npos)
Set value to a substring of a string.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
basic_string & append(const _CharT *__s)
Append a C string.
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.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
size_type find(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
Template class basic_istream.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
basic_string & operator+=(const _CharT *__s)
Append a C string.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
Managing sequences of characters and character-like objects.
const_reference front() const noexcept
basic_string & operator+=(_CharT __c)
Append a character.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
~basic_string() noexcept
Destroy the string instance.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
Primary class template hash.
char_type widen(char __c) const
Widens characters.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
basic_string & operator=(basic_string &&__str)
Move assign the value of str to this string.
const_reference back() const noexcept
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
Basis for explicit traits specializations.
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
const_reverse_iterator crbegin() const noexcept
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
const_reverse_iterator crend() const noexcept
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
const_iterator begin() const noexcept
void resize(size_type __n)
Resizes the string to the specified number of characters.
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.
void push_back(_CharT __c)
Append a single character.
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character not in C string.