34 #ifndef _BASIC_STRING_H
35 #define _BASIC_STRING_H 1
37 #pragma GCC system_header
43 #if __cplusplus >= 201103L
47 #if __cplusplus >= 201703L
48 # include <string_view>
51 namespace std _GLIBCXX_VISIBILITY(default)
53 _GLIBCXX_BEGIN_NAMESPACE_VERSION
55 #if __cplusplus == 201703L
57 # define __cpp_lib_constexpr_string 201611L
58 #elif __cplusplus > 201703L
60 # define __cpp_lib_constexpr_string 201811L
63 #if _GLIBCXX_USE_CXX11_ABI
64 _GLIBCXX_BEGIN_NAMESPACE_CXX11
83 template<
typename _CharT,
typename _Traits,
typename _Alloc>
87 rebind<_CharT>::other _Char_alloc_type;
92 typedef _Traits traits_type;
93 typedef typename _Traits::char_type value_type;
94 typedef _Char_alloc_type allocator_type;
95 typedef typename _Alloc_traits::size_type size_type;
96 typedef typename _Alloc_traits::difference_type difference_type;
97 typedef typename _Alloc_traits::reference reference;
98 typedef typename _Alloc_traits::const_reference const_reference;
99 typedef typename _Alloc_traits::pointer pointer;
100 typedef typename _Alloc_traits::const_pointer const_pointer;
101 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
102 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
108 static const size_type
npos =
static_cast<size_type
>(-1);
112 #if __cplusplus < 201103L
113 typedef iterator __const_iterator;
115 typedef const_iterator __const_iterator;
119 #if __cplusplus >= 201703L
121 typedef basic_string_view<_CharT, _Traits> __sv_type;
123 template<
typename _Tp,
typename _Res>
125 __and_<is_convertible<const _Tp&, __sv_type>,
126 __not_<is_convertible<const _Tp*, const basic_string*>>,
127 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
132 _S_to_string_view(__sv_type __svt) noexcept
141 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
157 struct _Alloc_hider : allocator_type
159 #if __cplusplus < 201103L
160 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
161 : allocator_type(__a), _M_p(__dat) { }
163 _Alloc_hider(pointer __dat,
const _Alloc& __a)
164 : allocator_type(__a), _M_p(__dat) { }
166 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
167 : allocator_type(
std::
move(__a)), _M_p(__dat) { }
173 _Alloc_hider _M_dataplus;
174 size_type _M_string_length;
176 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
180 _CharT _M_local_buf[_S_local_capacity + 1];
181 size_type _M_allocated_capacity;
186 { _M_dataplus._M_p = __p; }
189 _M_length(size_type __length)
190 { _M_string_length = __length; }
194 {
return _M_dataplus._M_p; }
199 #if __cplusplus >= 201103L
202 return pointer(_M_local_buf);
207 _M_local_data()
const
209 #if __cplusplus >= 201103L
212 return const_pointer(_M_local_buf);
217 _M_capacity(size_type __capacity)
218 { _M_allocated_capacity = __capacity; }
221 _M_set_length(size_type __n)
224 traits_type::assign(_M_data()[__n], _CharT());
229 {
return _M_data() == _M_local_data(); }
233 _M_create(size_type&, size_type);
239 _M_destroy(_M_allocated_capacity);
243 _M_destroy(size_type __size)
throw()
244 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
248 template<
typename _InIterator>
250 _M_construct_aux(_InIterator __beg, _InIterator __end,
253 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
254 _M_construct(__beg, __end, _Tag());
259 template<
typename _Integer>
261 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
262 { _M_construct_aux_2(
static_cast<size_type
>(__beg), __end); }
265 _M_construct_aux_2(size_type __req, _CharT __c)
266 { _M_construct(__req, __c); }
268 template<
typename _InIterator>
270 _M_construct(_InIterator __beg, _InIterator __end)
272 typedef typename std::__is_integer<_InIterator>::__type _Integral;
273 _M_construct_aux(__beg, __end, _Integral());
277 template<
typename _InIterator>
279 _M_construct(_InIterator __beg, _InIterator __end,
284 template<
typename _FwdIterator>
286 _M_construct(_FwdIterator __beg, _FwdIterator __end,
290 _M_construct(size_type __req, _CharT __c);
294 {
return _M_dataplus; }
296 const allocator_type&
297 _M_get_allocator()
const
298 {
return _M_dataplus; }
302 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
305 template<
typename _Tp,
bool _Requires =
306 !__are_same<_Tp, _CharT*>::__value
307 && !__are_same<_Tp, const _CharT*>::__value
308 && !__are_same<_Tp, iterator>::__value
309 && !__are_same<_Tp, const_iterator>::__value>
310 struct __enable_if_not_native_iterator
312 template<
typename _Tp>
313 struct __enable_if_not_native_iterator<_Tp, false> { };
317 _M_check(size_type __pos,
const char* __s)
const
319 if (__pos > this->
size())
320 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
321 "this->size() (which is %zu)"),
322 __s, __pos, this->
size());
327 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
330 __throw_length_error(__N(__s));
336 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
338 const bool __testoff = __off < this->
size() - __pos;
339 return __testoff ? __off : this->
size() - __pos;
344 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
346 return (less<const _CharT*>()(__s, _M_data())
347 || less<const _CharT*>()(_M_data() + this->
size(), __s));
353 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
356 traits_type::assign(*__d, *__s);
358 traits_type::copy(__d, __s, __n);
362 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
365 traits_type::assign(*__d, *__s);
371 _S_assign(_CharT* __d, size_type __n, _CharT __c)
374 traits_type::assign(*__d, __c);
376 traits_type::assign(__d, __n, __c);
381 template<
class _Iterator>
383 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
385 for (; __k1 != __k2; ++__k1, (void)++__p)
386 traits_type::assign(*__p, *__k1);
390 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
391 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
394 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
396 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
399 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
400 { _S_copy(__p, __k1, __k2 - __k1); }
403 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
405 { _S_copy(__p, __k1, __k2 - __k1); }
408 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
410 const difference_type __d = difference_type(__n1 - __n2);
412 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
413 return __gnu_cxx::__numeric_traits<int>::__max;
414 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
415 return __gnu_cxx::__numeric_traits<int>::__min;
424 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
428 _M_erase(size_type __pos, size_type __n);
439 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
440 : _M_dataplus(_M_local_data())
441 { _M_set_length(0); }
448 : _M_dataplus(_M_local_data(), __a)
449 { _M_set_length(0); }
456 : _M_dataplus(_M_local_data(),
457 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
458 { _M_construct(__str._M_data(), __str._M_data() + __str.length()); }
469 const _Alloc& __a = _Alloc())
470 : _M_dataplus(_M_local_data(), __a)
472 const _CharT* __start = __str._M_data()
473 + __str._M_check(__pos,
"basic_string::basic_string");
474 _M_construct(__start, __start + __str._M_limit(__pos,
npos));
485 : _M_dataplus(_M_local_data())
487 const _CharT* __start = __str._M_data()
488 + __str._M_check(__pos,
"basic_string::basic_string");
489 _M_construct(__start, __start + __str._M_limit(__pos, __n));
500 size_type __n,
const _Alloc& __a)
501 : _M_dataplus(_M_local_data(), __a)
503 const _CharT* __start
504 = __str._M_data() + __str._M_check(__pos,
"string::string");
505 _M_construct(__start, __start + __str._M_limit(__pos, __n));
518 const _Alloc& __a = _Alloc())
519 : _M_dataplus(_M_local_data(), __a)
520 { _M_construct(__s, __s + __n); }
527 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
530 template<
typename = _RequireAllocator<_Alloc>>
532 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
533 : _M_dataplus(_M_local_data(), __a)
534 { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+
npos); }
542 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
545 template<
typename = _RequireAllocator<_Alloc>>
547 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
548 : _M_dataplus(_M_local_data(), __a)
549 { _M_construct(__n, __c); }
551 #if __cplusplus >= 201103L
560 : _M_dataplus(_M_local_data(),
std::move(__str._M_get_allocator()))
562 if (__str._M_is_local())
564 traits_type::copy(_M_local_buf, __str._M_local_buf,
565 _S_local_capacity + 1);
569 _M_data(__str._M_data());
570 _M_capacity(__str._M_allocated_capacity);
576 _M_length(__str.length());
577 __str._M_data(__str._M_local_data());
578 __str._M_set_length(0);
586 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
587 : _M_dataplus(_M_local_data(), __a)
588 { _M_construct(__l.begin(), __l.end()); }
591 : _M_dataplus(_M_local_data(), __a)
592 { _M_construct(__str.begin(), __str.end()); }
595 noexcept(_Alloc_traits::_S_always_equal())
596 : _M_dataplus(_M_local_data(), __a)
598 if (__str._M_is_local())
600 traits_type::copy(_M_local_buf, __str._M_local_buf,
601 _S_local_capacity + 1);
602 _M_length(__str.length());
603 __str._M_set_length(0);
605 else if (_Alloc_traits::_S_always_equal()
606 || __str.get_allocator() == __a)
608 _M_data(__str._M_data());
609 _M_length(__str.length());
610 _M_capacity(__str._M_allocated_capacity);
611 __str._M_data(__str._M_local_buf);
612 __str._M_set_length(0);
615 _M_construct(__str.begin(), __str.end());
626 #if __cplusplus >= 201103L
627 template<
typename _InputIterator,
628 typename = std::_RequireInputIter<_InputIterator>>
630 template<
typename _InputIterator>
632 basic_string(_InputIterator __beg, _InputIterator __end,
633 const _Alloc& __a = _Alloc())
634 : _M_dataplus(_M_local_data(), __a)
635 { _M_construct(__beg, __end); }
637 #if __cplusplus >= 201703L
645 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
646 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
647 const _Alloc& __a = _Alloc())
655 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
657 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
658 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
674 return this->
assign(__str);
683 {
return this->
assign(__s); }
699 #if __cplusplus >= 201103L
711 noexcept(_Alloc_traits::_S_nothrow_move())
713 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
714 && !_Alloc_traits::_S_always_equal()
715 && _M_get_allocator() != __str._M_get_allocator())
718 _M_destroy(_M_allocated_capacity);
719 _M_data(_M_local_data());
723 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
725 if (__str._M_is_local())
729 this->_S_copy(_M_data(), __str._M_data(), __str.size());
730 _M_set_length(__str.size());
732 else if (_Alloc_traits::_S_propagate_on_move_assign()
733 || _Alloc_traits::_S_always_equal()
734 || _M_get_allocator() == __str._M_get_allocator())
737 pointer __data =
nullptr;
738 size_type __capacity;
741 if (_Alloc_traits::_S_always_equal())
745 __capacity = _M_allocated_capacity;
748 _M_destroy(_M_allocated_capacity);
751 _M_data(__str._M_data());
752 _M_length(__str.length());
753 _M_capacity(__str._M_allocated_capacity);
756 __str._M_data(__data);
757 __str._M_capacity(__capacity);
760 __str._M_data(__str._M_local_buf);
775 this->
assign(__l.begin(), __l.size());
780 #if __cplusplus >= 201703L
785 template<
typename _Tp>
786 _If_sv<_Tp, basic_string&>
788 {
return this->
assign(__svt); }
794 operator __sv_type() const noexcept
795 {
return __sv_type(
data(),
size()); }
804 begin() _GLIBCXX_NOEXCEPT
805 {
return iterator(_M_data()); }
812 begin() const _GLIBCXX_NOEXCEPT
813 {
return const_iterator(_M_data()); }
820 end() _GLIBCXX_NOEXCEPT
821 {
return iterator(_M_data() + this->
size()); }
828 end() const _GLIBCXX_NOEXCEPT
829 {
return const_iterator(_M_data() + this->
size()); }
837 rbegin() _GLIBCXX_NOEXCEPT
838 {
return reverse_iterator(this->
end()); }
845 const_reverse_iterator
846 rbegin() const _GLIBCXX_NOEXCEPT
847 {
return const_reverse_iterator(this->
end()); }
855 rend() _GLIBCXX_NOEXCEPT
856 {
return reverse_iterator(this->
begin()); }
863 const_reverse_iterator
864 rend() const _GLIBCXX_NOEXCEPT
865 {
return const_reverse_iterator(this->
begin()); }
867 #if __cplusplus >= 201103L
874 {
return const_iterator(this->_M_data()); }
881 cend() const noexcept
882 {
return const_iterator(this->_M_data() + this->
size()); }
889 const_reverse_iterator
891 {
return const_reverse_iterator(this->
end()); }
898 const_reverse_iterator
899 crend() const noexcept
900 {
return const_reverse_iterator(this->
begin()); }
908 size() const _GLIBCXX_NOEXCEPT
909 {
return _M_string_length; }
914 length() const _GLIBCXX_NOEXCEPT
915 {
return _M_string_length; }
920 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
933 resize(size_type __n, _CharT __c);
947 { this->
resize(__n, _CharT()); }
949 #if __cplusplus >= 201103L
973 return _M_is_local() ? size_type(_S_local_capacity)
974 : _M_allocated_capacity;
995 reserve(size_type __res_arg = 0);
1001 clear() _GLIBCXX_NOEXCEPT
1002 { _M_set_length(0); }
1008 _GLIBCXX_NODISCARD
bool
1009 empty() const _GLIBCXX_NOEXCEPT
1010 {
return this->
size() == 0; }
1024 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
1026 __glibcxx_assert(__pos <=
size());
1027 return _M_data()[__pos];
1045 __glibcxx_assert(__pos <=
size());
1047 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1048 return _M_data()[__pos];
1062 at(size_type __n)
const
1064 if (__n >= this->
size())
1065 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1066 "(which is %zu) >= this->size() "
1069 return _M_data()[__n];
1086 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1087 "(which is %zu) >= this->size() "
1090 return _M_data()[__n];
1093 #if __cplusplus >= 201103L
1101 __glibcxx_assert(!
empty());
1110 front() const noexcept
1112 __glibcxx_assert(!
empty());
1123 __glibcxx_assert(!
empty());
1132 back() const noexcept
1134 __glibcxx_assert(!
empty());
1147 {
return this->
append(__str); }
1156 {
return this->
append(__s); }
1170 #if __cplusplus >= 201103L
1178 {
return this->
append(__l.begin(), __l.size()); }
1181 #if __cplusplus >= 201703L
1187 template<
typename _Tp>
1188 _If_sv<_Tp, basic_string&>
1190 {
return this->
append(__svt); }
1200 {
return _M_append(__str._M_data(), __str.size()); }
1217 {
return _M_append(__str._M_data()
1218 + __str._M_check(__pos,
"basic_string::append"),
1219 __str._M_limit(__pos, __n)); }
1228 append(
const _CharT* __s, size_type __n)
1230 __glibcxx_requires_string_len(__s, __n);
1231 _M_check_length(size_type(0), __n,
"basic_string::append");
1232 return _M_append(__s, __n);
1241 append(
const _CharT* __s)
1243 __glibcxx_requires_string(__s);
1244 const size_type __n = traits_type::length(__s);
1245 _M_check_length(size_type(0), __n,
"basic_string::append");
1246 return _M_append(__s, __n);
1258 append(size_type __n, _CharT __c)
1259 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1261 #if __cplusplus >= 201103L
1268 append(initializer_list<_CharT> __l)
1269 {
return this->
append(__l.begin(), __l.size()); }
1280 #if __cplusplus >= 201103L
1281 template<
class _InputIterator,
1282 typename = std::_RequireInputIter<_InputIterator>>
1284 template<
class _InputIterator>
1287 append(_InputIterator __first, _InputIterator __last)
1290 #if __cplusplus >= 201703L
1296 template<
typename _Tp>
1297 _If_sv<_Tp, basic_string&>
1300 __sv_type __sv = __svt;
1301 return this->
append(__sv.data(), __sv.size());
1311 template<
typename _Tp>
1312 _If_sv<_Tp, basic_string&>
1313 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1315 __sv_type __sv = __svt;
1316 return _M_append(__sv.data()
1317 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1318 std::__sv_limit(__sv.size(), __pos, __n));
1329 const size_type __size = this->
size();
1331 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1332 traits_type::assign(this->_M_data()[__size], __c);
1333 this->_M_set_length(__size + 1);
1344 #if __cplusplus >= 201103L
1345 if (_Alloc_traits::_S_propagate_on_copy_assign())
1347 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
1348 && _M_get_allocator() != __str._M_get_allocator())
1352 if (__str.size() <= _S_local_capacity)
1354 _M_destroy(_M_allocated_capacity);
1355 _M_data(_M_local_data());
1360 const auto __len = __str.size();
1361 auto __alloc = __str._M_get_allocator();
1363 auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1);
1364 _M_destroy(_M_allocated_capacity);
1367 _M_set_length(__len);
1370 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
1373 this->_M_assign(__str);
1377 #if __cplusplus >= 201103L
1388 noexcept(_Alloc_traits::_S_nothrow_move())
1411 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1412 + __str._M_check(__pos,
"basic_string::assign"),
1413 __str._M_limit(__pos, __n)); }
1426 assign(
const _CharT* __s, size_type __n)
1428 __glibcxx_requires_string_len(__s, __n);
1429 return _M_replace(size_type(0), this->
size(), __s, __n);
1442 assign(
const _CharT* __s)
1444 __glibcxx_requires_string(__s);
1445 return _M_replace(size_type(0), this->
size(), __s,
1446 traits_type::length(__s));
1459 assign(size_type __n, _CharT __c)
1460 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1470 #if __cplusplus >= 201103L
1471 template<
class _InputIterator,
1472 typename = std::_RequireInputIter<_InputIterator>>
1474 template<
class _InputIterator>
1477 assign(_InputIterator __first, _InputIterator __last)
1480 #if __cplusplus >= 201103L
1487 assign(initializer_list<_CharT> __l)
1488 {
return this->
assign(__l.begin(), __l.size()); }
1491 #if __cplusplus >= 201703L
1497 template<
typename _Tp>
1498 _If_sv<_Tp, basic_string&>
1501 __sv_type __sv = __svt;
1502 return this->
assign(__sv.data(), __sv.size());
1512 template<
typename _Tp>
1513 _If_sv<_Tp, basic_string&>
1514 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1516 __sv_type __sv = __svt;
1517 return _M_replace(size_type(0), this->
size(),
1519 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
1520 std::__sv_limit(__sv.size(), __pos, __n));
1524 #if __cplusplus >= 201103L
1541 insert(const_iterator __p, size_type __n, _CharT __c)
1543 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1544 const size_type __pos = __p -
begin();
1545 this->
replace(__p, __p, __n, __c);
1546 return iterator(this->_M_data() + __pos);
1563 insert(iterator __p, size_type __n, _CharT __c)
1564 { this->
replace(__p, __p, __n, __c); }
1567 #if __cplusplus >= 201103L
1582 template<
class _InputIterator,
1583 typename = std::_RequireInputIter<_InputIterator>>
1585 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1587 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1588 const size_type __pos = __p -
begin();
1589 this->
replace(__p, __p, __beg, __end);
1590 return iterator(this->_M_data() + __pos);
1605 template<
class _InputIterator>
1607 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1608 { this->
replace(__p, __p, __beg, __end); }
1611 #if __cplusplus >= 201103L
1619 insert(const_iterator __p, initializer_list<_CharT> __l)
1620 {
return this->
insert(__p, __l.begin(), __l.end()); }
1622 #ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
1625 insert(iterator __p, initializer_list<_CharT> __l)
1627 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1628 this->
insert(__p -
begin(), __l.begin(), __l.size());
1647 {
return this->
replace(__pos1, size_type(0),
1648 __str._M_data(), __str.size()); }
1670 size_type __pos2, size_type __n =
npos)
1671 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1672 + __str._M_check(__pos2,
"basic_string::insert"),
1673 __str._M_limit(__pos2, __n)); }
1692 insert(size_type __pos,
const _CharT* __s, size_type __n)
1693 {
return this->
replace(__pos, size_type(0), __s, __n); }
1711 insert(size_type __pos,
const _CharT* __s)
1713 __glibcxx_requires_string(__s);
1714 return this->
replace(__pos, size_type(0), __s,
1715 traits_type::length(__s));
1735 insert(size_type __pos, size_type __n, _CharT __c)
1736 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1737 size_type(0), __n, __c); }
1753 insert(__const_iterator __p, _CharT __c)
1755 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1756 const size_type __pos = __p -
begin();
1757 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1758 return iterator(_M_data() + __pos);
1761 #if __cplusplus >= 201703L
1768 template<
typename _Tp>
1769 _If_sv<_Tp, basic_string&>
1770 insert(size_type __pos,
const _Tp& __svt)
1772 __sv_type __sv = __svt;
1773 return this->
insert(__pos, __sv.data(), __sv.size());
1784 template<
typename _Tp>
1785 _If_sv<_Tp, basic_string&>
1786 insert(size_type __pos1,
const _Tp& __svt,
1787 size_type __pos2, size_type __n =
npos)
1789 __sv_type __sv = __svt;
1790 return this->
replace(__pos1, size_type(0),
1792 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
1793 std::__sv_limit(__sv.size(), __pos2, __n));
1813 erase(size_type __pos = 0, size_type __n =
npos)
1815 _M_check(__pos,
"basic_string::erase");
1817 this->_M_set_length(__pos);
1819 this->_M_erase(__pos, _M_limit(__pos, __n));
1832 erase(__const_iterator __position)
1834 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1835 && __position <
end());
1836 const size_type __pos = __position -
begin();
1837 this->_M_erase(__pos, size_type(1));
1838 return iterator(_M_data() + __pos);
1851 erase(__const_iterator __first, __const_iterator __last)
1853 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1854 && __last <=
end());
1855 const size_type __pos = __first -
begin();
1856 if (__last ==
end())
1857 this->_M_set_length(__pos);
1859 this->_M_erase(__pos, __last - __first);
1860 return iterator(this->_M_data() + __pos);
1863 #if __cplusplus >= 201103L
1872 __glibcxx_assert(!
empty());
1873 _M_erase(
size() - 1, 1);
1896 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1918 size_type __pos2, size_type __n2 =
npos)
1919 {
return this->
replace(__pos1, __n1, __str._M_data()
1920 + __str._M_check(__pos2,
"basic_string::replace"),
1921 __str._M_limit(__pos2, __n2)); }
1942 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1945 __glibcxx_requires_string_len(__s, __n2);
1946 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1947 _M_limit(__pos, __n1), __s, __n2);
1967 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1969 __glibcxx_requires_string(__s);
1970 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1991 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1992 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1993 _M_limit(__pos, __n1), __n2, __c); }
2009 replace(__const_iterator __i1, __const_iterator __i2,
2011 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
2029 replace(__const_iterator __i1, __const_iterator __i2,
2030 const _CharT* __s, size_type __n)
2032 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2034 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2051 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2053 __glibcxx_requires_string(__s);
2054 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2072 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2075 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2077 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2095 #if __cplusplus >= 201103L
2096 template<
class _InputIterator,
2097 typename = std::_RequireInputIter<_InputIterator>>
2099 replace(const_iterator __i1, const_iterator __i2,
2100 _InputIterator __k1, _InputIterator __k2)
2102 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2104 __glibcxx_requires_valid_range(__k1, __k2);
2105 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2106 std::__false_type());
2109 template<
class _InputIterator>
2110 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2111 typename __enable_if_not_native_iterator<_InputIterator>::__type
2115 replace(iterator __i1, iterator __i2,
2116 _InputIterator __k1, _InputIterator __k2)
2118 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2120 __glibcxx_requires_valid_range(__k1, __k2);
2121 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2122 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2129 replace(__const_iterator __i1, __const_iterator __i2,
2130 _CharT* __k1, _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 const _CharT* __k1,
const _CharT* __k2)
2143 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2145 __glibcxx_requires_valid_range(__k1, __k2);
2151 replace(__const_iterator __i1, __const_iterator __i2,
2152 iterator __k1, iterator __k2)
2154 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2156 __glibcxx_requires_valid_range(__k1, __k2);
2158 __k1.base(), __k2 - __k1);
2162 replace(__const_iterator __i1, __const_iterator __i2,
2163 const_iterator __k1, const_iterator __k2)
2165 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2167 __glibcxx_requires_valid_range(__k1, __k2);
2169 __k1.base(), __k2 - __k1);
2172 #if __cplusplus >= 201103L
2188 initializer_list<_CharT> __l)
2189 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2192 #if __cplusplus >= 201703L
2200 template<
typename _Tp>
2201 _If_sv<_Tp, basic_string&>
2202 replace(size_type __pos, size_type __n,
const _Tp& __svt)
2204 __sv_type __sv = __svt;
2205 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2217 template<
typename _Tp>
2218 _If_sv<_Tp, basic_string&>
2219 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2220 size_type __pos2, size_type __n2 =
npos)
2222 __sv_type __sv = __svt;
2223 return this->
replace(__pos1, __n1,
2225 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2226 std::__sv_limit(__sv.size(), __pos2, __n2));
2238 template<
typename _Tp>
2239 _If_sv<_Tp, basic_string&>
2240 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2242 __sv_type __sv = __svt;
2243 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2248 template<
class _Integer>
2250 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2251 _Integer __n, _Integer __val, __true_type)
2252 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2254 template<
class _InputIterator>
2256 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2257 _InputIterator __k1, _InputIterator __k2,
2261 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2265 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2266 const size_type __len2);
2269 _M_append(
const _CharT* __s, size_type __n);
2286 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2306 c_str() const _GLIBCXX_NOEXCEPT
2307 {
return _M_data(); }
2318 data() const _GLIBCXX_NOEXCEPT
2319 {
return _M_data(); }
2321 #if __cplusplus >= 201703L
2330 {
return _M_data(); }
2338 {
return _M_get_allocator(); }
2353 find(
const _CharT* __s, size_type __pos, size_type __n)
const
2369 {
return this->
find(__str.data(), __pos, __str.size()); }
2371 #if __cplusplus >= 201703L
2378 template<
typename _Tp>
2379 _If_sv<_Tp, size_type>
2380 find(
const _Tp& __svt, size_type __pos = 0) const
2381 noexcept(is_same<_Tp, __sv_type>::value)
2383 __sv_type __sv = __svt;
2384 return this->
find(__sv.data(), __pos, __sv.size());
2399 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2401 __glibcxx_requires_string(__s);
2402 return this->
find(__s, __pos, traits_type::length(__s));
2416 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2431 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2433 #if __cplusplus >= 201703L
2440 template<
typename _Tp>
2441 _If_sv<_Tp, size_type>
2442 rfind(
const _Tp& __svt, size_type __pos =
npos)
const
2443 noexcept(is_same<_Tp, __sv_type>::value)
2445 __sv_type __sv = __svt;
2446 return this->
rfind(__sv.data(), __pos, __sv.size());
2463 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
2477 rfind(
const _CharT* __s, size_type __pos =
npos)
const
2479 __glibcxx_requires_string(__s);
2480 return this->
rfind(__s, __pos, traits_type::length(__s));
2494 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
2510 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2512 #if __cplusplus >= 201703L
2520 template<
typename _Tp>
2521 _If_sv<_Tp, size_type>
2523 noexcept(is_same<_Tp, __sv_type>::value)
2525 __sv_type __sv = __svt;
2526 return this->
find_first_of(__sv.data(), __pos, __sv.size());
2543 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2560 __glibcxx_requires_string(__s);
2561 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2577 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2578 {
return this->
find(__c, __pos); }
2594 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2596 #if __cplusplus >= 201703L
2604 template<
typename _Tp>
2605 _If_sv<_Tp, size_type>
2607 noexcept(is_same<_Tp, __sv_type>::value)
2609 __sv_type __sv = __svt;
2610 return this->
find_last_of(__sv.data(), __pos, __sv.size());
2627 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2644 __glibcxx_requires_string(__s);
2645 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2662 {
return this->
rfind(__c, __pos); }
2679 #if __cplusplus >= 201703L
2687 template<
typename _Tp>
2688 _If_sv<_Tp, size_type>
2690 noexcept(is_same<_Tp, __sv_type>::value)
2692 __sv_type __sv = __svt;
2711 size_type __n)
const _GLIBCXX_NOEXCEPT;
2727 __glibcxx_requires_string(__s);
2761 #if __cplusplus >= 201703L
2769 template<
typename _Tp>
2770 _If_sv<_Tp, size_type>
2772 noexcept(is_same<_Tp, __sv_type>::value)
2774 __sv_type __sv = __svt;
2793 size_type __n)
const _GLIBCXX_NOEXCEPT;
2809 __glibcxx_requires_string(__s);
2840 substr(size_type __pos = 0, size_type __n =
npos)
const
2842 _M_check(__pos,
"basic_string::substr"), __n); }
2861 const size_type __size = this->
size();
2862 const size_type __osize = __str.size();
2863 const size_type __len =
std::min(__size, __osize);
2865 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2867 __r = _S_compare(__size, __osize);
2871 #if __cplusplus >= 201703L
2877 template<
typename _Tp>
2879 compare(
const _Tp& __svt)
const
2880 noexcept(is_same<_Tp, __sv_type>::value)
2882 __sv_type __sv = __svt;
2883 const size_type __size = this->
size();
2884 const size_type __osize = __sv.size();
2885 const size_type __len =
std::min(__size, __osize);
2887 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
2889 __r = _S_compare(__size, __osize);
2901 template<
typename _Tp>
2903 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
2904 noexcept(is_same<_Tp, __sv_type>::value)
2906 __sv_type __sv = __svt;
2907 return __sv_type(*this).substr(__pos, __n).compare(__sv);
2920 template<
typename _Tp>
2922 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
2923 size_type __pos2, size_type __n2 =
npos)
const
2924 noexcept(is_same<_Tp, __sv_type>::value)
2926 __sv_type __sv = __svt;
2927 return __sv_type(*
this)
2928 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
2979 size_type __pos2, size_type __n2 =
npos)
const;
2996 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
3020 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
3047 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3048 size_type __n2)
const;
3050 #if __cplusplus > 201703L
3052 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3053 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3056 starts_with(_CharT __x)
const noexcept
3057 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3060 starts_with(
const _CharT* __x)
const noexcept
3061 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3064 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3065 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3068 ends_with(_CharT __x)
const noexcept
3069 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3072 ends_with(
const _CharT* __x)
const noexcept
3073 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3077 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3079 _GLIBCXX_END_NAMESPACE_CXX11
3145 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3149 rebind<_CharT>::other _CharT_alloc_type;
3154 typedef _Traits traits_type;
3155 typedef typename _Traits::char_type value_type;
3156 typedef _Alloc allocator_type;
3157 typedef typename _CharT_alloc_traits::size_type size_type;
3158 typedef typename _CharT_alloc_traits::difference_type difference_type;
3159 #if __cplusplus < 201103L
3160 typedef typename _CharT_alloc_type::reference reference;
3161 typedef typename _CharT_alloc_type::const_reference const_reference;
3163 typedef value_type& reference;
3164 typedef const value_type& const_reference;
3166 typedef typename _CharT_alloc_traits::pointer pointer;
3167 typedef typename _CharT_alloc_traits::const_pointer const_pointer;
3168 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
3169 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
3176 typedef iterator __const_iterator;
3195 size_type _M_length;
3196 size_type _M_capacity;
3197 _Atomic_word _M_refcount;
3200 struct _Rep : _Rep_base
3204 rebind<char>::other _Raw_bytes_alloc;
3219 static const size_type _S_max_size;
3220 static const _CharT _S_terminal;
3224 static size_type _S_empty_rep_storage[];
3227 _S_empty_rep() _GLIBCXX_NOEXCEPT
3232 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
3233 return *
reinterpret_cast<_Rep*
>(__p);
3237 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
3239 #if defined(__GTHREADS)
3244 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
3246 return this->_M_refcount < 0;
3251 _M_is_shared()
const _GLIBCXX_NOEXCEPT
3253 #if defined(__GTHREADS)
3259 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
3261 return this->_M_refcount > 0;
3266 _M_set_leaked() _GLIBCXX_NOEXCEPT
3267 { this->_M_refcount = -1; }
3270 _M_set_sharable() _GLIBCXX_NOEXCEPT
3271 { this->_M_refcount = 0; }
3274 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
3276 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3277 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3280 this->_M_set_sharable();
3281 this->_M_length = __n;
3282 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
3289 _M_refdata()
throw()
3290 {
return reinterpret_cast<_CharT*
>(
this + 1); }
3293 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
3295 return (!_M_is_leaked() && __alloc1 == __alloc2)
3296 ? _M_refcopy() : _M_clone(__alloc1);
3301 _S_create(size_type, size_type,
const _Alloc&);
3304 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3306 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3307 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3311 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
3320 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
3323 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
3330 _M_destroy(
const _Alloc&)
throw();
3333 _M_refcopy()
throw()
3335 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3336 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3338 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
3339 return _M_refdata();
3343 _M_clone(
const _Alloc&, size_type __res = 0);
3347 struct _Alloc_hider : _Alloc
3349 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3350 : _Alloc(__a), _M_p(__dat) { }
3360 static const size_type
npos =
static_cast<size_type
>(-1);
3364 mutable _Alloc_hider _M_dataplus;
3367 _M_data() const _GLIBCXX_NOEXCEPT
3368 {
return _M_dataplus._M_p; }
3371 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
3372 {
return (_M_dataplus._M_p = __p); }
3375 _M_rep() const _GLIBCXX_NOEXCEPT
3376 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
3381 _M_ibegin() const _GLIBCXX_NOEXCEPT
3382 {
return iterator(_M_data()); }
3385 _M_iend() const _GLIBCXX_NOEXCEPT
3386 {
return iterator(_M_data() + this->
size()); }
3391 if (!_M_rep()->_M_is_leaked())
3396 _M_check(size_type __pos,
const char* __s)
const
3398 if (__pos > this->
size())
3399 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
3400 "this->size() (which is %zu)"),
3401 __s, __pos, this->
size());
3406 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
3409 __throw_length_error(__N(__s));
3414 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
3416 const bool __testoff = __off < this->
size() - __pos;
3417 return __testoff ? __off : this->
size() - __pos;
3422 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3424 return (less<const _CharT*>()(__s, _M_data())
3425 || less<const _CharT*>()(_M_data() + this->
size(), __s));
3431 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3434 traits_type::assign(*__d, *__s);
3436 traits_type::copy(__d, __s, __n);
3440 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3443 traits_type::assign(*__d, *__s);
3449 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
3452 traits_type::assign(*__d, __c);
3454 traits_type::assign(__d, __n, __c);
3459 template<
class _Iterator>
3461 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
3463 for (; __k1 != __k2; ++__k1, (void)++__p)
3464 traits_type::assign(*__p, *__k1);
3468 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
3469 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3472 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
3474 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3477 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
3478 { _M_copy(__p, __k1, __k2 - __k1); }
3481 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
3483 { _M_copy(__p, __k1, __k2 - __k1); }
3486 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
3488 const difference_type __d = difference_type(__n1 - __n2);
3490 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
3491 return __gnu_cxx::__numeric_traits<int>::__max;
3492 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
3493 return __gnu_cxx::__numeric_traits<int>::__min;
3499 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
3505 _S_empty_rep() _GLIBCXX_NOEXCEPT
3506 {
return _Rep::_S_empty_rep(); }
3508 #if __cplusplus >= 201703L
3510 typedef basic_string_view<_CharT, _Traits> __sv_type;
3512 template<
typename _Tp,
typename _Res>
3514 __and_<is_convertible<const _Tp&, __sv_type>,
3515 __not_<is_convertible<const _Tp*, const basic_string*>>,
3516 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
3521 _S_to_string_view(__sv_type __svt) noexcept
3530 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
3554 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3556 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc())
3558 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc())
3584 const _Alloc& __a = _Alloc());
3602 size_type __n,
const _Alloc& __a);
3614 const _Alloc& __a = _Alloc());
3621 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
3624 template<
typename = _RequireAllocator<_Alloc>>
3627 : _M_dataplus(_S_construct(__s, __s ? __s + traits_type::
length(__s) :
3628 __s +
npos, __a), __a)
3637 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3639 #if __cplusplus >= 201103L
3648 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3651 : _M_dataplus(
std::move(__str._M_dataplus))
3653 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3654 __str._M_data(_S_empty_rep()._M_refdata());
3656 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3668 : _M_dataplus(__str._M_rep()->_M_grab(__a, __str.
get_allocator()), __a)
3672 : _M_dataplus(__str._M_data(), __a)
3674 if (__a == __str.get_allocator())
3676 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3677 __str._M_data(_S_empty_rep()._M_refdata());
3679 __str._M_data(_S_construct(size_type(), _CharT(), __a));
3683 _M_dataplus._M_p = _S_construct(__str.begin(), __str.end(), __a);
3693 template<
class _InputIterator>
3694 basic_string(_InputIterator __beg, _InputIterator __end,
3695 const _Alloc& __a = _Alloc());
3697 #if __cplusplus >= 201703L
3705 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3706 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
3707 const _Alloc& __a = _Alloc())
3715 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3717 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
3718 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
3733 {
return this->
assign(__str); }
3741 {
return this->
assign(__s); }
3757 #if __cplusplus >= 201103L
3781 this->
assign(__l.begin(), __l.size());
3786 #if __cplusplus >= 201703L
3791 template<
typename _Tp>
3792 _If_sv<_Tp, basic_string&>
3794 {
return this->
assign(__svt); }
3800 operator __sv_type() const noexcept
3801 {
return __sv_type(
data(),
size()); }
3813 return iterator(_M_data());
3822 {
return const_iterator(_M_data()); }
3832 return iterator(_M_data() + this->
size());
3841 {
return const_iterator(_M_data() + this->
size()); }
3857 const_reverse_iterator
3875 const_reverse_iterator
3879 #if __cplusplus >= 201103L
3886 {
return const_iterator(this->_M_data()); }
3894 {
return const_iterator(this->_M_data() + this->
size()); }
3901 const_reverse_iterator
3910 const_reverse_iterator
3921 {
return _M_rep()->_M_length; }
3927 {
return _M_rep()->_M_length; }
3932 {
return _Rep::_S_max_size; }
3945 resize(size_type __n, _CharT __c);
3959 { this->
resize(__n, _CharT()); }
3961 #if __cplusplus >= 201103L
3966 #if __cpp_exceptions
3984 {
return _M_rep()->_M_capacity; }
4004 reserve(size_type __res_arg = 0);
4009 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
4013 if (_M_rep()->_M_is_shared())
4016 _M_data(_S_empty_rep()._M_refdata());
4019 _M_rep()->_M_set_length_and_sharable(0);
4025 { _M_mutate(0, this->
size(), 0); }
4032 _GLIBCXX_NODISCARD
bool
4034 {
return this->
size() == 0; }
4050 __glibcxx_assert(__pos <=
size());
4051 return _M_data()[__pos];
4069 __glibcxx_assert(__pos <=
size());
4071 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
4073 return _M_data()[__pos];
4089 if (__n >= this->
size())
4090 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
4091 "(which is %zu) >= this->size() "
4094 return _M_data()[__n];
4112 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
4113 "(which is %zu) >= this->size() "
4117 return _M_data()[__n];
4120 #if __cplusplus >= 201103L
4128 __glibcxx_assert(!
empty());
4139 __glibcxx_assert(!
empty());
4150 __glibcxx_assert(!
empty());
4161 __glibcxx_assert(!
empty());
4174 {
return this->
append(__str); }
4183 {
return this->
append(__s); }
4197 #if __cplusplus >= 201103L
4205 {
return this->
append(__l.begin(), __l.size()); }
4208 #if __cplusplus >= 201703L
4214 template<
typename _Tp>
4215 _If_sv<_Tp, basic_string&>
4217 {
return this->
append(__svt); }
4251 append(
const _CharT* __s, size_type __n);
4261 __glibcxx_requires_string(__s);
4262 return this->
append(__s, traits_type::length(__s));
4274 append(size_type __n, _CharT __c);
4276 #if __cplusplus >= 201103L
4284 {
return this->
append(__l.begin(), __l.size()); }
4295 template<
class _InputIterator>
4297 append(_InputIterator __first, _InputIterator __last)
4298 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
4300 #if __cplusplus >= 201703L
4306 template<
typename _Tp>
4307 _If_sv<_Tp, basic_string&>
4310 __sv_type __sv = __svt;
4311 return this->
append(__sv.data(), __sv.size());
4322 template<
typename _Tp>
4323 _If_sv<_Tp, basic_string&>
4324 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
4326 __sv_type __sv = __svt;
4327 return append(__sv.data()
4328 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
4329 std::__sv_limit(__sv.size(), __pos, __n));
4340 const size_type __len = 1 + this->
size();
4341 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
4343 traits_type::assign(_M_data()[this->
size()], __c);
4344 _M_rep()->_M_set_length_and_sharable(__len);
4355 #if __cplusplus >= 201103L
4388 {
return this->
assign(__str._M_data()
4389 + __str._M_check(__pos,
"basic_string::assign"),
4390 __str._M_limit(__pos, __n)); }
4403 assign(
const _CharT* __s, size_type __n);
4417 __glibcxx_requires_string(__s);
4418 return this->
assign(__s, traits_type::length(__s));
4432 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4442 template<
class _InputIterator>
4444 assign(_InputIterator __first, _InputIterator __last)
4445 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4447 #if __cplusplus >= 201103L
4455 {
return this->
assign(__l.begin(), __l.size()); }
4458 #if __cplusplus >= 201703L
4464 template<
typename _Tp>
4465 _If_sv<_Tp, basic_string&>
4468 __sv_type __sv = __svt;
4469 return this->
assign(__sv.data(), __sv.size());
4479 template<
typename _Tp>
4480 _If_sv<_Tp, basic_string&>
4481 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
4483 __sv_type __sv = __svt;
4484 return assign(__sv.data()
4485 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
4486 std::__sv_limit(__sv.size(), __pos, __n));
4504 insert(iterator __p, size_type __n, _CharT __c)
4505 { this->
replace(__p, __p, __n, __c); }
4519 template<
class _InputIterator>
4521 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4522 { this->
replace(__p, __p, __beg, __end); }
4524 #if __cplusplus >= 201103L
4534 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4535 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4553 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4575 size_type __pos2, size_type __n =
npos)
4576 {
return this->
insert(__pos1, __str._M_data()
4577 + __str._M_check(__pos2,
"basic_string::insert"),
4578 __str._M_limit(__pos2, __n)); }
4597 insert(size_type __pos,
const _CharT* __s, size_type __n);
4617 __glibcxx_requires_string(__s);
4618 return this->
insert(__pos, __s, traits_type::length(__s));
4638 insert(size_type __pos, size_type __n, _CharT __c)
4639 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4640 size_type(0), __n, __c); }
4658 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4659 const size_type __pos = __p - _M_ibegin();
4660 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4661 _M_rep()->_M_set_leaked();
4662 return iterator(_M_data() + __pos);
4665 #if __cplusplus >= 201703L
4672 template<
typename _Tp>
4673 _If_sv<_Tp, basic_string&>
4674 insert(size_type __pos,
const _Tp& __svt)
4676 __sv_type __sv = __svt;
4677 return this->
insert(__pos, __sv.data(), __sv.size());
4688 template<
typename _Tp>
4689 _If_sv<_Tp, basic_string&>
4690 insert(size_type __pos1,
const _Tp& __svt,
4691 size_type __pos2, size_type __n =
npos)
4693 __sv_type __sv = __svt;
4694 return this->
replace(__pos1, size_type(0), __sv.data()
4695 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
4696 std::__sv_limit(__sv.size(), __pos2, __n));
4718 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4719 _M_limit(__pos, __n), size_type(0));
4734 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4735 && __position < _M_iend());
4736 const size_type __pos = __position - _M_ibegin();
4737 _M_mutate(__pos, size_type(1), size_type(0));
4738 _M_rep()->_M_set_leaked();
4739 return iterator(_M_data() + __pos);
4754 #if __cplusplus >= 201103L
4763 __glibcxx_assert(!
empty());
4787 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4809 size_type __pos2, size_type __n2 =
npos)
4810 {
return this->
replace(__pos1, __n1, __str._M_data()
4811 + __str._M_check(__pos2,
"basic_string::replace"),
4812 __str._M_limit(__pos2, __n2)); }
4833 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4853 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4855 __glibcxx_requires_string(__s);
4856 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4877 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4878 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4879 _M_limit(__pos, __n1), __n2, __c); }
4896 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4914 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4916 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4917 && __i2 <= _M_iend());
4918 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4935 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4937 __glibcxx_requires_string(__s);
4938 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4956 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4958 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4959 && __i2 <= _M_iend());
4960 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4978 template<
class _InputIterator>
4981 _InputIterator __k1, _InputIterator __k2)
4983 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4984 && __i2 <= _M_iend());
4985 __glibcxx_requires_valid_range(__k1, __k2);
4986 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4987 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4995 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4996 && __i2 <= _M_iend());
4997 __glibcxx_requires_valid_range(__k1, __k2);
4998 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5003 replace(iterator __i1, iterator __i2,
5004 const _CharT* __k1,
const _CharT* __k2)
5006 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5007 && __i2 <= _M_iend());
5008 __glibcxx_requires_valid_range(__k1, __k2);
5009 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5014 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
5016 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5017 && __i2 <= _M_iend());
5018 __glibcxx_requires_valid_range(__k1, __k2);
5019 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5020 __k1.base(), __k2 - __k1);
5024 replace(iterator __i1, iterator __i2,
5025 const_iterator __k1, const_iterator __k2)
5027 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5028 && __i2 <= _M_iend());
5029 __glibcxx_requires_valid_range(__k1, __k2);
5030 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5031 __k1.base(), __k2 - __k1);
5034 #if __cplusplus >= 201103L
5051 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
5054 #if __cplusplus >= 201703L
5062 template<
typename _Tp>
5063 _If_sv<_Tp, basic_string&>
5064 replace(size_type __pos, size_type __n,
const _Tp& __svt)
5066 __sv_type __sv = __svt;
5067 return this->
replace(__pos, __n, __sv.data(), __sv.size());
5079 template<
typename _Tp>
5080 _If_sv<_Tp, basic_string&>
5081 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
5082 size_type __pos2, size_type __n2 =
npos)
5084 __sv_type __sv = __svt;
5085 return this->
replace(__pos1, __n1,
5087 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
5088 std::__sv_limit(__sv.size(), __pos2, __n2));
5100 template<
typename _Tp>
5101 _If_sv<_Tp, basic_string&>
5102 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
5104 __sv_type __sv = __svt;
5105 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
5110 template<
class _Integer>
5112 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
5113 _Integer __val, __true_type)
5114 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
5116 template<
class _InputIterator>
5118 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
5119 _InputIterator __k2, __false_type);
5122 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
5126 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
5131 template<
class _InIterator>
5133 _S_construct_aux(_InIterator __beg, _InIterator __end,
5134 const _Alloc& __a, __false_type)
5136 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
5137 return _S_construct(__beg, __end, __a, _Tag());
5142 template<
class _Integer>
5144 _S_construct_aux(_Integer __beg, _Integer __end,
5145 const _Alloc& __a, __true_type)
5146 {
return _S_construct_aux_2(
static_cast<size_type
>(__beg),
5150 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
5151 {
return _S_construct(__req, __c, __a); }
5153 template<
class _InIterator>
5155 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
5157 typedef typename std::__is_integer<_InIterator>::__type _Integral;
5158 return _S_construct_aux(__beg, __end, __a, _Integral());
5162 template<
class _InIterator>
5164 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
5165 input_iterator_tag);
5169 template<
class _FwdIterator>
5171 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
5172 forward_iterator_tag);
5175 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
5192 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
5203 _GLIBCXX_NOEXCEPT_IF(allocator_traits<_Alloc>::is_always_equal::value);
5214 {
return _M_data(); }
5226 {
return _M_data(); }
5228 #if __cplusplus >= 201703L
5248 {
return _M_dataplus; }
5263 find(
const _CharT* __s, size_type __pos, size_type __n)
const
5279 {
return this->
find(__str.data(), __pos, __str.size()); }
5292 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
5294 __glibcxx_requires_string(__s);
5295 return this->
find(__s, __pos, traits_type::length(__s));
5309 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
5311 #if __cplusplus >= 201703L
5318 template<
typename _Tp>
5319 _If_sv<_Tp, size_type>
5320 find(
const _Tp& __svt, size_type __pos = 0) const
5321 noexcept(
is_same<_Tp, __sv_type>::value)
5323 __sv_type __sv = __svt;
5324 return this->
find(__sv.data(), __pos, __sv.size());
5341 {
return this->
rfind(__str.data(), __pos, __str.size()); }
5356 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
5370 rfind(
const _CharT* __s, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT
5372 __glibcxx_requires_string(__s);
5373 return this->
rfind(__s, __pos, traits_type::length(__s));
5387 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
5389 #if __cplusplus >= 201703L
5396 template<
typename _Tp>
5397 _If_sv<_Tp, size_type>
5398 rfind(
const _Tp& __svt, size_type __pos =
npos)
const
5401 __sv_type __sv = __svt;
5402 return this->
rfind(__sv.data(), __pos, __sv.size());
5420 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
5435 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
5452 __glibcxx_requires_string(__s);
5453 return this->
find_first_of(__s, __pos, traits_type::length(__s));
5470 {
return this->
find(__c, __pos); }
5472 #if __cplusplus >= 201703L
5480 template<
typename _Tp>
5481 _If_sv<_Tp, size_type>
5483 noexcept(
is_same<_Tp, __sv_type>::value)
5485 __sv_type __sv = __svt;
5486 return this->
find_first_of(__sv.data(), __pos, __sv.size());
5504 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5519 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
5536 __glibcxx_requires_string(__s);
5537 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5554 {
return this->
rfind(__c, __pos); }
5556 #if __cplusplus >= 201703L
5564 template<
typename _Tp>
5565 _If_sv<_Tp, size_type>
5569 __sv_type __sv = __svt;
5570 return this->
find_last_of(__sv.data(), __pos, __sv.size());
5603 size_type __n)
const _GLIBCXX_NOEXCEPT;
5619 __glibcxx_requires_string(__s);
5637 #if __cplusplus >= 201703L
5645 template<
typename _Tp>
5646 _If_sv<_Tp, size_type>
5648 noexcept(
is_same<_Tp, __sv_type>::value)
5650 __sv_type __sv = __svt;
5685 size_type __n)
const _GLIBCXX_NOEXCEPT;
5701 __glibcxx_requires_string(__s);
5719 #if __cplusplus >= 201703L
5727 template<
typename _Tp>
5728 _If_sv<_Tp, size_type>
5732 __sv_type __sv = __svt;
5752 _M_check(__pos,
"basic_string::substr"), __n); }
5771 const size_type __size = this->
size();
5772 const size_type __osize = __str.size();
5773 const size_type __len =
std::min(__size, __osize);
5775 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5777 __r = _S_compare(__size, __osize);
5781 #if __cplusplus >= 201703L
5787 template<
typename _Tp>
5789 compare(
const _Tp& __svt)
const
5792 __sv_type __sv = __svt;
5793 const size_type __size = this->
size();
5794 const size_type __osize = __sv.size();
5795 const size_type __len =
std::min(__size, __osize);
5797 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
5799 __r = _S_compare(__size, __osize);
5811 template<
typename _Tp>
5813 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
5814 noexcept(is_same<_Tp, __sv_type>::value)
5816 __sv_type __sv = __svt;
5817 return __sv_type(*this).substr(__pos, __n).compare(__sv);
5830 template<
typename _Tp>
5832 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
5833 size_type __pos2, size_type __n2 =
npos)
const
5834 noexcept(is_same<_Tp, __sv_type>::value)
5836 __sv_type __sv = __svt;
5837 return __sv_type(*
this)
5838 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
5889 size_type __pos2, size_type __n2 =
npos)
const;
5906 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5930 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5957 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5958 size_type __n2)
const;
5960 #if __cplusplus > 201703L
5962 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
5963 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5966 starts_with(_CharT __x)
const noexcept
5967 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5970 starts_with(
const _CharT* __x)
const noexcept
5971 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5974 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
5975 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5978 ends_with(_CharT __x)
const noexcept
5979 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5982 ends_with(
const _CharT* __x)
const noexcept
5983 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5986 # ifdef _GLIBCXX_TM_TS_INTERNAL
5988 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
5991 ::_txnal_cow_string_c_str(
const void *that);
5993 ::_txnal_cow_string_D1(
void *that);
5995 ::_txnal_cow_string_D1_commit(
void *that);
6000 #if __cpp_deduction_guides >= 201606
6001 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6002 template<
typename _InputIterator,
typename _CharT
6003 =
typename iterator_traits<_InputIterator>::value_type,
6004 typename _Allocator = allocator<_CharT>,
6005 typename = _RequireInputIter<_InputIterator>,
6006 typename = _RequireAllocator<_Allocator>>
6007 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
6008 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
6012 template<
typename _CharT,
typename _Traits,
6013 typename _Allocator = allocator<_CharT>,
6014 typename = _RequireAllocator<_Allocator>>
6015 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
6016 -> basic_string<_CharT, _Traits, _Allocator>;
6018 template<
typename _CharT,
typename _Traits,
6019 typename _Allocator = allocator<_CharT>,
6020 typename = _RequireAllocator<_Allocator>>
6021 basic_string(basic_string_view<_CharT, _Traits>,
6022 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6023 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6024 const _Allocator& = _Allocator())
6025 -> basic_string<_CharT, _Traits, _Allocator>;
6026 _GLIBCXX_END_NAMESPACE_CXX11
6036 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6037 basic_string<_CharT, _Traits, _Alloc>
6042 __str.append(__rhs);
6052 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6053 basic_string<_CharT,_Traits,_Alloc>
6055 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6063 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6064 basic_string<_CharT,_Traits,_Alloc>
6065 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6073 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6074 inline basic_string<_CharT, _Traits, _Alloc>
6076 const _CharT* __rhs)
6079 __str.append(__rhs);
6089 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6090 inline basic_string<_CharT, _Traits, _Alloc>
6094 typedef typename __string_type::size_type __size_type;
6095 __string_type __str(__lhs);
6096 __str.append(__size_type(1), __rhs);
6100 #if __cplusplus >= 201103L
6101 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6102 inline basic_string<_CharT, _Traits, _Alloc>
6103 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6104 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
6105 {
return std::move(__lhs.append(__rhs)); }
6107 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6108 inline basic_string<_CharT, _Traits, _Alloc>
6109 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6110 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6111 {
return std::move(__rhs.insert(0, __lhs)); }
6113 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6114 inline basic_string<_CharT, _Traits, _Alloc>
6115 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6116 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6118 #if _GLIBCXX_USE_CXX11_ABI
6119 using _Alloc_traits = allocator_traits<_Alloc>;
6120 bool __use_rhs =
false;
6121 if _GLIBCXX17_CONSTEXPR (
typename _Alloc_traits::is_always_equal{})
6123 else if (__lhs.get_allocator() == __rhs.get_allocator())
6128 const auto __size = __lhs.size() + __rhs.size();
6129 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
6130 return std::move(__rhs.insert(0, __lhs));
6135 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6136 inline basic_string<_CharT, _Traits, _Alloc>
6138 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6139 {
return std::move(__rhs.insert(0, __lhs)); }
6141 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6142 inline basic_string<_CharT, _Traits, _Alloc>
6144 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6145 {
return std::move(__rhs.insert(0, 1, __lhs)); }
6147 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6148 inline basic_string<_CharT, _Traits, _Alloc>
6149 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6150 const _CharT* __rhs)
6151 {
return std::move(__lhs.append(__rhs)); }
6153 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6154 inline basic_string<_CharT, _Traits, _Alloc>
6155 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6157 {
return std::move(__lhs.append(1, __rhs)); }
6167 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6172 {
return __lhs.compare(__rhs) == 0; }
6174 template<
typename _CharT>
6176 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
6177 operator==(
const basic_string<_CharT>& __lhs,
6178 const basic_string<_CharT>& __rhs) _GLIBCXX_NOEXCEPT
6179 {
return (__lhs.size() == __rhs.size()
6189 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6192 const _CharT* __rhs)
6193 {
return __lhs.compare(__rhs) == 0; }
6195 #if __cpp_lib_three_way_comparison
6203 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6205 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6206 const basic_string<_CharT, _Traits, _Alloc>& __rhs) noexcept
6207 -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
6208 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
6217 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6219 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6220 const _CharT* __rhs) noexcept
6221 -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
6222 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
6230 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6232 operator==(
const _CharT* __lhs,
6234 {
return __rhs.compare(__lhs) == 0; }
6243 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6248 {
return !(__lhs == __rhs); }
6256 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6258 operator!=(
const _CharT* __lhs,
6260 {
return !(__lhs == __rhs); }
6268 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6271 const _CharT* __rhs)
6272 {
return !(__lhs == __rhs); }
6281 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6286 {
return __lhs.compare(__rhs) < 0; }
6294 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6297 const _CharT* __rhs)
6298 {
return __lhs.compare(__rhs) < 0; }
6306 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6308 operator<(
const _CharT* __lhs,
6310 {
return __rhs.compare(__lhs) > 0; }
6319 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6324 {
return __lhs.compare(__rhs) > 0; }
6332 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6335 const _CharT* __rhs)
6336 {
return __lhs.compare(__rhs) > 0; }
6344 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6346 operator>(
const _CharT* __lhs,
6348 {
return __rhs.compare(__lhs) < 0; }
6357 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6362 {
return __lhs.compare(__rhs) <= 0; }
6370 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6373 const _CharT* __rhs)
6374 {
return __lhs.compare(__rhs) <= 0; }
6382 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6384 operator<=(
const _CharT* __lhs,
6386 {
return __rhs.compare(__lhs) >= 0; }
6395 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6400 {
return __lhs.compare(__rhs) >= 0; }
6408 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6411 const _CharT* __rhs)
6412 {
return __lhs.compare(__rhs) >= 0; }
6420 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6422 operator>=(
const _CharT* __lhs,
6424 {
return __rhs.compare(__lhs) <= 0; }
6434 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6438 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
6439 { __lhs.swap(__rhs); }
6454 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6455 basic_istream<_CharT, _Traits>&
6456 operator>>(basic_istream<_CharT, _Traits>& __is,
6457 basic_string<_CharT, _Traits, _Alloc>& __str);
6460 basic_istream<char>&
6472 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6479 return __ostream_insert(__os, __str.data(), __str.size());
6495 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6496 basic_istream<_CharT, _Traits>&
6497 getline(basic_istream<_CharT, _Traits>& __is,
6498 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
6512 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6513 inline basic_istream<_CharT, _Traits>&
6518 #if __cplusplus >= 201103L
6520 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6521 inline basic_istream<_CharT, _Traits>&
6527 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6528 inline basic_istream<_CharT, _Traits>&
6535 basic_istream<char>&
6536 getline(basic_istream<char>& __in, basic_string<char>& __str,
6539 #ifdef _GLIBCXX_USE_WCHAR_T
6541 basic_istream<wchar_t>&
6542 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
6546 _GLIBCXX_END_NAMESPACE_VERSION
6549 #if __cplusplus >= 201103L
6554 namespace std _GLIBCXX_VISIBILITY(default)
6556 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6557 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6559 #if _GLIBCXX_USE_C99_STDLIB
6562 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6563 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
6567 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6568 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
6571 inline unsigned long
6572 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6573 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
6577 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6578 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
6581 inline unsigned long long
6582 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6583 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
6588 stof(
const string& __str,
size_t* __idx = 0)
6589 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
6592 stod(
const string& __str,
size_t* __idx = 0)
6593 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
6596 stold(
const string& __str,
size_t* __idx = 0)
6597 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
6603 to_string(
int __val)
6605 const bool __neg = __val < 0;
6606 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
6607 const auto __len = __detail::__to_chars_len(__uval);
6608 string __str(__neg + __len,
'-');
6609 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
6614 to_string(
unsigned __val)
6616 string __str(__detail::__to_chars_len(__val),
'\0');
6617 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
6622 to_string(
long __val)
6624 const bool __neg = __val < 0;
6625 const unsigned long __uval = __neg ? (
unsigned long)~__val + 1ul : __val;
6626 const auto __len = __detail::__to_chars_len(__uval);
6627 string __str(__neg + __len,
'-');
6628 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
6633 to_string(
unsigned long __val)
6635 string __str(__detail::__to_chars_len(__val),
'\0');
6636 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
6641 to_string(
long long __val)
6643 const bool __neg = __val < 0;
6644 const unsigned long long __uval
6645 = __neg ? (
unsigned long long)~__val + 1ull : __val;
6646 const auto __len = __detail::__to_chars_len(__uval);
6647 string __str(__neg + __len,
'-');
6648 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
6653 to_string(
unsigned long long __val)
6655 string __str(__detail::__to_chars_len(__val),
'\0');
6656 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
6660 #if _GLIBCXX_USE_C99_STDIO
6664 to_string(
float __val)
6667 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6668 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6673 to_string(
double __val)
6676 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6677 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6682 to_string(
long double __val)
6685 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6686 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6691 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
6693 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6694 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
6698 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6699 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
6702 inline unsigned long
6703 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6704 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
6708 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6709 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
6712 inline unsigned long long
6713 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6714 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
6719 stof(
const wstring& __str,
size_t* __idx = 0)
6720 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
6723 stod(
const wstring& __str,
size_t* __idx = 0)
6724 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
6727 stold(
const wstring& __str,
size_t* __idx = 0)
6728 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
6730 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
6733 to_wstring(
int __val)
6734 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
int),
6738 to_wstring(
unsigned __val)
6739 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6740 4 *
sizeof(
unsigned),
6744 to_wstring(
long __val)
6745 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
long),
6749 to_wstring(
unsigned long __val)
6750 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6751 4 *
sizeof(
unsigned long),
6755 to_wstring(
long long __val)
6756 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6757 4 *
sizeof(
long long),
6761 to_wstring(
unsigned long long __val)
6762 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6763 4 *
sizeof(
unsigned long long),
6767 to_wstring(
float __val)
6770 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6771 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6776 to_wstring(
double __val)
6779 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6780 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6785 to_wstring(
long double __val)
6788 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6789 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6795 _GLIBCXX_END_NAMESPACE_CXX11
6796 _GLIBCXX_END_NAMESPACE_VERSION
6801 #if __cplusplus >= 201103L
6805 namespace std _GLIBCXX_VISIBILITY(default)
6807 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6811 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
6815 :
public __hash_base<size_t, string>
6818 operator()(
const string& __s)
const noexcept
6819 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
6826 #ifdef _GLIBCXX_USE_WCHAR_T
6830 :
public __hash_base<size_t, wstring>
6833 operator()(
const wstring& __s)
const noexcept
6834 {
return std::_Hash_impl::hash(__s.
data(),
6835 __s.
length() *
sizeof(
wchar_t)); }
6844 #ifdef _GLIBCXX_USE_CHAR8_T
6847 struct hash<u8string>
6848 :
public __hash_base<size_t, u8string>
6851 operator()(
const u8string& __s)
const noexcept
6852 {
return std::_Hash_impl::hash(__s.data(),
6853 __s.length() *
sizeof(char8_t)); }
6864 :
public __hash_base<size_t, u16string>
6867 operator()(
const u16string& __s)
const noexcept
6868 {
return std::_Hash_impl::hash(__s.
data(),
6869 __s.
length() *
sizeof(char16_t)); }
6879 :
public __hash_base<size_t, u32string>
6882 operator()(
const u32string& __s)
const noexcept
6883 {
return std::_Hash_impl::hash(__s.
data(),
6884 __s.
length() *
sizeof(char32_t)); }
6891 #if __cplusplus >= 201402L
6893 #define __cpp_lib_string_udls 201304
6895 inline namespace literals
6897 inline namespace string_literals
6899 #pragma GCC diagnostic push
6900 #pragma GCC diagnostic ignored "-Wliteral-suffix"
6901 _GLIBCXX_DEFAULT_ABI_TAG
6902 inline basic_string<char>
6903 operator""s(
const char* __str,
size_t __len)
6904 {
return basic_string<char>{__str, __len}; }
6906 #ifdef _GLIBCXX_USE_WCHAR_T
6907 _GLIBCXX_DEFAULT_ABI_TAG
6908 inline basic_string<wchar_t>
6909 operator""s(
const wchar_t* __str,
size_t __len)
6910 {
return basic_string<wchar_t>{__str, __len}; }
6913 #ifdef _GLIBCXX_USE_CHAR8_T
6914 _GLIBCXX_DEFAULT_ABI_TAG
6915 inline basic_string<char8_t>
6916 operator""s(
const char8_t* __str,
size_t __len)
6917 {
return basic_string<char8_t>{__str, __len}; }
6920 _GLIBCXX_DEFAULT_ABI_TAG
6921 inline basic_string<char16_t>
6922 operator""s(
const char16_t* __str,
size_t __len)
6923 {
return basic_string<char16_t>{__str, __len}; }
6925 _GLIBCXX_DEFAULT_ABI_TAG
6926 inline basic_string<char32_t>
6927 operator""s(
const char32_t* __str,
size_t __len)
6928 {
return basic_string<char32_t>{__str, __len}; }
6930 #pragma GCC diagnostic pop
6934 #if __cplusplus >= 201703L
6935 namespace __detail::__variant
6937 template<
typename>
struct _Never_valueless_alt;
6941 template<
typename _Tp,
typename _Traits,
typename _Alloc>
6942 struct _Never_valueless_alt<
std::basic_string<_Tp, _Traits, _Alloc>>
6944 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
6945 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
6952 _GLIBCXX_END_NAMESPACE_VERSION
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
basic_string< wchar_t > wstring
A string of wchar_t.
ISO C++ entities toplevel namespace is std.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
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.
constexpr _Iterator __base(_Iterator __it)
char_type widen(char __c) const
Widens characters.
Template class basic_ostream.
Primary class template hash.
Uniform interface to all allocator types.
Managing sequences of characters and character-like objects.
const_reverse_iterator crbegin() const noexcept
void swap(basic_string &__s) noexcept(/*conditional */)
Swap contents with another string.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
void push_back(_CharT __c)
Append a single character.
const_iterator cend() const noexcept
size_type find(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C 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 & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character of C string.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
size_type rfind(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a C string.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
iterator erase(iterator __position)
Remove one character.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a 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.
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
int compare(const basic_string &__str) const
Compare to a string.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
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 & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
const_reference front() const noexcept
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.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
reverse_iterator rbegin()
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list 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(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
void pop_back()
Remove the last character.
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
basic_string(basic_string &&__str) noexcept
Move construct string.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
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 & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n=npos)
Insert a substring.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
basic_string & assign(basic_string &&__str) noexcept(allocator_traits< _Alloc >::is_always_equal::value)
Set value to contents of another string.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
const _CharT * data() const noexcept
Return const pointer to contents.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
const_reference back() const noexcept
const_reverse_iterator rend() const noexcept
const_iterator end() const noexcept
basic_string & operator+=(_CharT __c)
Append a character.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
basic_string & append(const basic_string &__str)
Append a string to this string.
const_iterator begin() const noexcept
const_reverse_iterator crend() const noexcept
void resize(size_type __n)
Resizes the string to the specified number of characters.
const_reverse_iterator rbegin() const noexcept
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
basic_string & operator=(basic_string &&__str) noexcept(/*conditional */)
Move assign the value of str to this string.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
bool empty() const noexcept
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
static const size_type npos
Value returned by various member functions when they fail.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
const_iterator cbegin() const noexcept
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
~basic_string() noexcept
Destroy the string instance.
size_type capacity() const noexcept
basic_string & operator+=(const _CharT *__s)
Append a C string.
basic_string() noexcept
Default constructor creates an empty string.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character of 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.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
basic_string(const _CharT *__s, const _Alloc &__a=_Alloc())
Construct string as copy of a C 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(const _CharT *__s)
Append a C string.
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character not in C string.
reference at(size_type __n)
Provides access to the data contained in the string.
iterator insert(iterator __p, _CharT __c)
Insert one character.
Basis for explicit traits specializations.
Uniform interface to all pointer-like types.
Forward iterators support a superset of input iterator operations.
Uniform interface to C++98 and C++11 allocators.