34 #ifndef _BASIC_STRING_H
35 #define _BASIC_STRING_H 1
37 #pragma GCC system_header
43 #if __cplusplus >= 201103L
47 #if __cplusplus >= 201703L
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;
112 #if __cplusplus >= 201703L
114 typedef basic_string_view<_CharT, _Traits> __sv_type;
116 template<
typename _Tp,
typename _Res>
118 __and_<is_convertible<const _Tp&, __sv_type>,
119 __not_<is_convertible<const _Tp*, const basic_string*>>,
120 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
125 _S_to_string_view(__sv_type __svt) noexcept
134 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
150 struct _Alloc_hider : allocator_type
152 #if __cplusplus < 201103L
153 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
154 : allocator_type(__a), _M_p(__dat) { }
156 _Alloc_hider(pointer __dat,
const _Alloc& __a)
157 : allocator_type(__a), _M_p(__dat) { }
159 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
160 : allocator_type(
std::
move(__a)), _M_p(__dat) { }
166 _Alloc_hider _M_dataplus;
167 size_type _M_string_length;
169 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
173 _CharT _M_local_buf[_S_local_capacity + 1];
174 size_type _M_allocated_capacity;
179 { _M_dataplus._M_p = __p; }
182 _M_length(size_type __length)
183 { _M_string_length = __length; }
187 {
return _M_dataplus._M_p; }
192 #if __cplusplus >= 201103L
195 return pointer(_M_local_buf);
200 _M_local_data()
const
202 #if __cplusplus >= 201103L
205 return const_pointer(_M_local_buf);
210 _M_capacity(size_type __capacity)
211 { _M_allocated_capacity = __capacity; }
214 _M_set_length(size_type __n)
217 traits_type::assign(_M_data()[__n], _CharT());
222 {
return _M_data() == _M_local_data(); }
226 _M_create(size_type&, size_type);
232 _M_destroy(_M_allocated_capacity);
236 _M_destroy(size_type __size)
throw()
237 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
241 template<
typename _InIterator>
243 _M_construct_aux(_InIterator __beg, _InIterator __end,
246 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
247 _M_construct(__beg, __end, _Tag());
252 template<
typename _Integer>
254 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
255 { _M_construct_aux_2(
static_cast<size_type
>(__beg), __end); }
258 _M_construct_aux_2(size_type __req, _CharT __c)
259 { _M_construct(__req, __c); }
261 template<
typename _InIterator>
263 _M_construct(_InIterator __beg, _InIterator __end)
265 typedef typename std::__is_integer<_InIterator>::__type _Integral;
266 _M_construct_aux(__beg, __end, _Integral());
270 template<
typename _InIterator>
272 _M_construct(_InIterator __beg, _InIterator __end,
277 template<
typename _FwdIterator>
279 _M_construct(_FwdIterator __beg, _FwdIterator __end,
283 _M_construct(size_type __req, _CharT __c);
287 {
return _M_dataplus; }
289 const allocator_type&
290 _M_get_allocator()
const
291 {
return _M_dataplus; }
295 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
298 template<
typename _Tp,
bool _Requires =
299 !__are_same<_Tp, _CharT*>::__value
300 && !__are_same<_Tp, const _CharT*>::__value
301 && !__are_same<_Tp, iterator>::__value
302 && !__are_same<_Tp, const_iterator>::__value>
303 struct __enable_if_not_native_iterator
305 template<
typename _Tp>
306 struct __enable_if_not_native_iterator<_Tp, false> { };
310 _M_check(size_type __pos,
const char* __s)
const
312 if (__pos > this->
size())
313 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
314 "this->size() (which is %zu)"),
315 __s, __pos, this->
size());
320 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
323 __throw_length_error(__N(__s));
329 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
331 const bool __testoff = __off < this->
size() - __pos;
332 return __testoff ? __off : this->
size() - __pos;
337 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
339 return (less<const _CharT*>()(__s, _M_data())
340 || less<const _CharT*>()(_M_data() + this->
size(), __s));
346 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
349 traits_type::assign(*__d, *__s);
351 traits_type::copy(__d, __s, __n);
355 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
358 traits_type::assign(*__d, *__s);
364 _S_assign(_CharT* __d, size_type __n, _CharT __c)
367 traits_type::assign(*__d, __c);
369 traits_type::assign(__d, __n, __c);
374 template<
class _Iterator>
376 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
378 for (; __k1 != __k2; ++__k1, (void)++__p)
379 traits_type::assign(*__p, *__k1);
383 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
384 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
387 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
389 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
392 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
393 { _S_copy(__p, __k1, __k2 - __k1); }
396 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
398 { _S_copy(__p, __k1, __k2 - __k1); }
401 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
403 const difference_type __d = difference_type(__n1 - __n2);
405 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
406 return __gnu_cxx::__numeric_traits<int>::__max;
407 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
408 return __gnu_cxx::__numeric_traits<int>::__min;
417 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
421 _M_erase(size_type __pos, size_type __n);
432 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
433 : _M_dataplus(_M_local_data())
434 { _M_set_length(0); }
441 : _M_dataplus(_M_local_data(), __a)
442 { _M_set_length(0); }
449 : _M_dataplus(_M_local_data(),
450 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
451 { _M_construct(__str._M_data(), __str._M_data() + __str.length()); }
462 const _Alloc& __a = _Alloc())
463 : _M_dataplus(_M_local_data(), __a)
465 const _CharT* __start = __str._M_data()
466 + __str._M_check(__pos,
"basic_string::basic_string");
467 _M_construct(__start, __start + __str._M_limit(__pos,
npos));
478 : _M_dataplus(_M_local_data())
480 const _CharT* __start = __str._M_data()
481 + __str._M_check(__pos,
"basic_string::basic_string");
482 _M_construct(__start, __start + __str._M_limit(__pos, __n));
493 size_type __n,
const _Alloc& __a)
494 : _M_dataplus(_M_local_data(), __a)
496 const _CharT* __start
497 = __str._M_data() + __str._M_check(__pos,
"string::string");
498 _M_construct(__start, __start + __str._M_limit(__pos, __n));
511 const _Alloc& __a = _Alloc())
512 : _M_dataplus(_M_local_data(), __a)
513 { _M_construct(__s, __s + __n); }
520 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
523 template<
typename = _RequireAllocator<_Alloc>>
525 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
526 : _M_dataplus(_M_local_data(), __a)
527 { _M_construct(__s, __s ? __s + traits_type::length(__s) : __s+
npos); }
535 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
538 template<
typename = _RequireAllocator<_Alloc>>
540 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
541 : _M_dataplus(_M_local_data(), __a)
542 { _M_construct(__n, __c); }
544 #if __cplusplus >= 201103L
553 : _M_dataplus(_M_local_data(),
std::move(__str._M_get_allocator()))
555 if (__str._M_is_local())
557 traits_type::copy(_M_local_buf, __str._M_local_buf,
558 _S_local_capacity + 1);
562 _M_data(__str._M_data());
563 _M_capacity(__str._M_allocated_capacity);
569 _M_length(__str.length());
570 __str._M_data(__str._M_local_data());
571 __str._M_set_length(0);
579 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
580 : _M_dataplus(_M_local_data(), __a)
581 { _M_construct(__l.begin(), __l.end()); }
584 : _M_dataplus(_M_local_data(), __a)
585 { _M_construct(__str.begin(), __str.end()); }
588 noexcept(_Alloc_traits::_S_always_equal())
589 : _M_dataplus(_M_local_data(), __a)
591 if (__str._M_is_local())
593 traits_type::copy(_M_local_buf, __str._M_local_buf,
594 _S_local_capacity + 1);
595 _M_length(__str.length());
596 __str._M_set_length(0);
598 else if (_Alloc_traits::_S_always_equal()
599 || __str.get_allocator() == __a)
601 _M_data(__str._M_data());
602 _M_length(__str.length());
603 _M_capacity(__str._M_allocated_capacity);
604 __str._M_data(__str._M_local_buf);
605 __str._M_set_length(0);
608 _M_construct(__str.begin(), __str.end());
619 #if __cplusplus >= 201103L
620 template<
typename _InputIterator,
621 typename = std::_RequireInputIter<_InputIterator>>
623 template<
typename _InputIterator>
625 basic_string(_InputIterator __beg, _InputIterator __end,
626 const _Alloc& __a = _Alloc())
627 : _M_dataplus(_M_local_data(), __a)
628 { _M_construct(__beg, __end); }
630 #if __cplusplus >= 201703L
638 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
639 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
640 const _Alloc& __a = _Alloc())
648 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
650 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
651 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
667 return this->
assign(__str);
676 {
return this->
assign(__s); }
692 #if __cplusplus >= 201103L
704 noexcept(_Alloc_traits::_S_nothrow_move())
706 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
707 && !_Alloc_traits::_S_always_equal()
708 && _M_get_allocator() != __str._M_get_allocator())
711 _M_destroy(_M_allocated_capacity);
712 _M_data(_M_local_data());
716 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
718 if (__str._M_is_local())
726 this->_S_copy(_M_data(), __str._M_data(), __str.size());
727 _M_set_length(__str.size());
730 else if (_Alloc_traits::_S_propagate_on_move_assign()
731 || _Alloc_traits::_S_always_equal()
732 || _M_get_allocator() == __str._M_get_allocator())
735 pointer __data =
nullptr;
736 size_type __capacity;
739 if (_Alloc_traits::_S_always_equal())
743 __capacity = _M_allocated_capacity;
746 _M_destroy(_M_allocated_capacity);
749 _M_data(__str._M_data());
750 _M_length(__str.length());
751 _M_capacity(__str._M_allocated_capacity);
754 __str._M_data(__data);
755 __str._M_capacity(__capacity);
758 __str._M_data(__str._M_local_buf);
773 this->
assign(__l.begin(), __l.size());
778 #if __cplusplus >= 201703L
783 template<
typename _Tp>
784 _If_sv<_Tp, basic_string&>
786 {
return this->
assign(__svt); }
792 operator __sv_type() const noexcept
793 {
return __sv_type(
data(),
size()); }
802 begin() _GLIBCXX_NOEXCEPT
803 {
return iterator(_M_data()); }
810 begin() const _GLIBCXX_NOEXCEPT
811 {
return const_iterator(_M_data()); }
818 end() _GLIBCXX_NOEXCEPT
819 {
return iterator(_M_data() + this->
size()); }
826 end() const _GLIBCXX_NOEXCEPT
827 {
return const_iterator(_M_data() + this->
size()); }
835 rbegin() _GLIBCXX_NOEXCEPT
836 {
return reverse_iterator(this->
end()); }
843 const_reverse_iterator
844 rbegin() const _GLIBCXX_NOEXCEPT
845 {
return const_reverse_iterator(this->
end()); }
853 rend() _GLIBCXX_NOEXCEPT
854 {
return reverse_iterator(this->
begin()); }
861 const_reverse_iterator
862 rend() const _GLIBCXX_NOEXCEPT
863 {
return const_reverse_iterator(this->
begin()); }
865 #if __cplusplus >= 201103L
872 {
return const_iterator(this->_M_data()); }
879 cend() const noexcept
880 {
return const_iterator(this->_M_data() + this->
size()); }
887 const_reverse_iterator
889 {
return const_reverse_iterator(this->
end()); }
896 const_reverse_iterator
897 crend() const noexcept
898 {
return const_reverse_iterator(this->
begin()); }
906 size() const _GLIBCXX_NOEXCEPT
907 {
return _M_string_length; }
912 length() const _GLIBCXX_NOEXCEPT
913 {
return _M_string_length; }
918 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
931 resize(size_type __n, _CharT __c);
945 { this->
resize(__n, _CharT()); }
947 #if __cplusplus >= 201103L
948 #pragma GCC diagnostic push
949 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
954 #pragma GCC diagnostic pop
964 return _M_is_local() ? size_type(_S_local_capacity)
965 : _M_allocated_capacity;
991 #if __cplusplus > 201703L
992 [[deprecated(
"use shrink_to_fit() instead")]]
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); }
3076 #if __cplusplus > 202002L
3078 contains(basic_string_view<_CharT, _Traits> __x)
const noexcept
3079 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3082 contains(_CharT __x)
const noexcept
3083 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3086 contains(
const _CharT* __x)
const noexcept
3087 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3091 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3093 _GLIBCXX_END_NAMESPACE_CXX11
3159 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3163 rebind<_CharT>::other _CharT_alloc_type;
3168 typedef _Traits traits_type;
3169 typedef typename _Traits::char_type value_type;
3170 typedef _Alloc allocator_type;
3171 typedef typename _CharT_alloc_traits::size_type size_type;
3172 typedef typename _CharT_alloc_traits::difference_type difference_type;
3173 #if __cplusplus < 201103L
3174 typedef typename _CharT_alloc_type::reference reference;
3175 typedef typename _CharT_alloc_type::const_reference const_reference;
3177 typedef value_type& reference;
3178 typedef const value_type& const_reference;
3180 typedef typename _CharT_alloc_traits::pointer pointer;
3181 typedef typename _CharT_alloc_traits::const_pointer const_pointer;
3182 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
3183 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
3190 typedef iterator __const_iterator;
3209 size_type _M_length;
3210 size_type _M_capacity;
3211 _Atomic_word _M_refcount;
3214 struct _Rep : _Rep_base
3218 rebind<char>::other _Raw_bytes_alloc;
3233 static const size_type _S_max_size;
3234 static const _CharT _S_terminal;
3238 static size_type _S_empty_rep_storage[];
3241 _S_empty_rep() _GLIBCXX_NOEXCEPT
3246 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
3247 return *
reinterpret_cast<_Rep*
>(__p);
3251 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
3253 #if defined(__GTHREADS)
3258 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
3260 return this->_M_refcount < 0;
3265 _M_is_shared()
const _GLIBCXX_NOEXCEPT
3267 #if defined(__GTHREADS)
3273 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
3275 return this->_M_refcount > 0;
3280 _M_set_leaked() _GLIBCXX_NOEXCEPT
3281 { this->_M_refcount = -1; }
3284 _M_set_sharable() _GLIBCXX_NOEXCEPT
3285 { this->_M_refcount = 0; }
3288 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
3290 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3291 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3294 this->_M_set_sharable();
3295 this->_M_length = __n;
3296 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
3303 _M_refdata()
throw()
3304 {
return reinterpret_cast<_CharT*
>(
this + 1); }
3307 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
3309 return (!_M_is_leaked() && __alloc1 == __alloc2)
3310 ? _M_refcopy() : _M_clone(__alloc1);
3315 _S_create(size_type, size_type,
const _Alloc&);
3318 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3320 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3321 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3325 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
3334 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
3337 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
3344 _M_destroy(
const _Alloc&)
throw();
3347 _M_refcopy()
throw()
3349 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3350 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3352 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
3353 return _M_refdata();
3357 _M_clone(
const _Alloc&, size_type __res = 0);
3361 struct _Alloc_hider : _Alloc
3363 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3364 : _Alloc(__a), _M_p(__dat) { }
3374 static const size_type
npos =
static_cast<size_type
>(-1);
3378 mutable _Alloc_hider _M_dataplus;
3381 _M_data() const _GLIBCXX_NOEXCEPT
3382 {
return _M_dataplus._M_p; }
3385 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
3386 {
return (_M_dataplus._M_p = __p); }
3389 _M_rep() const _GLIBCXX_NOEXCEPT
3390 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
3395 _M_ibegin() const _GLIBCXX_NOEXCEPT
3396 {
return iterator(_M_data()); }
3399 _M_iend() const _GLIBCXX_NOEXCEPT
3400 {
return iterator(_M_data() + this->
size()); }
3405 if (!_M_rep()->_M_is_leaked())
3410 _M_check(size_type __pos,
const char* __s)
const
3412 if (__pos > this->
size())
3413 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
3414 "this->size() (which is %zu)"),
3415 __s, __pos, this->
size());
3420 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
3423 __throw_length_error(__N(__s));
3428 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
3430 const bool __testoff = __off < this->
size() - __pos;
3431 return __testoff ? __off : this->
size() - __pos;
3436 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3438 return (less<const _CharT*>()(__s, _M_data())
3439 || less<const _CharT*>()(_M_data() + this->
size(), __s));
3445 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3448 traits_type::assign(*__d, *__s);
3450 traits_type::copy(__d, __s, __n);
3454 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3457 traits_type::assign(*__d, *__s);
3463 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
3466 traits_type::assign(*__d, __c);
3468 traits_type::assign(__d, __n, __c);
3473 template<
class _Iterator>
3475 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
3477 for (; __k1 != __k2; ++__k1, (void)++__p)
3478 traits_type::assign(*__p, *__k1);
3482 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
3483 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3486 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
3488 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3491 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
3492 { _M_copy(__p, __k1, __k2 - __k1); }
3495 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
3497 { _M_copy(__p, __k1, __k2 - __k1); }
3500 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
3502 const difference_type __d = difference_type(__n1 - __n2);
3504 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
3505 return __gnu_cxx::__numeric_traits<int>::__max;
3506 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
3507 return __gnu_cxx::__numeric_traits<int>::__min;
3513 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
3519 _S_empty_rep() _GLIBCXX_NOEXCEPT
3520 {
return _Rep::_S_empty_rep(); }
3522 #if __cplusplus >= 201703L
3524 typedef basic_string_view<_CharT, _Traits> __sv_type;
3526 template<
typename _Tp,
typename _Res>
3528 __and_<is_convertible<const _Tp&, __sv_type>,
3529 __not_<is_convertible<const _Tp*, const basic_string*>>,
3530 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
3535 _S_to_string_view(__sv_type __svt) noexcept
3544 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
3568 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3570 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc())
3572 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc())
3581 : _M_dataplus(_S_construct(size_type(), _CharT(), __a), __a)
3590 : _M_dataplus(__str._M_rep()->_M_grab(_Alloc(__str.
get_allocator()),
3604 const _Alloc& __a = _Alloc());
3622 size_type __n,
const _Alloc& __a);
3634 const _Alloc& __a = _Alloc())
3635 : _M_dataplus(_S_construct(__s, __s + __n, __a), __a)
3643 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
3646 template<
typename = _RequireAllocator<_Alloc>>
3649 : _M_dataplus(_S_construct(__s, __s ? __s + traits_type::
length(__s) :
3650 __s +
npos, __a), __a)
3660 : _M_dataplus(_S_construct(__n, __c, __a), __a)
3663 #if __cplusplus >= 201103L
3672 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3675 : _M_dataplus(
std::move(__str._M_dataplus))
3677 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3678 __str._M_data(_S_empty_rep()._M_refdata());
3680 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3690 : _M_dataplus(_S_construct(__l.
begin(), __l.
end(), __a), __a)
3694 : _M_dataplus(__str._M_rep()->_M_grab(__a, __str.
get_allocator()), __a)
3698 : _M_dataplus(__str._M_data(), __a)
3700 if (__a == __str.get_allocator())
3702 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3703 __str._M_data(_S_empty_rep()._M_refdata());
3705 __str._M_data(_S_construct(size_type(), _CharT(), __a));
3709 _M_dataplus._M_p = _S_construct(__str.begin(), __str.end(), __a);
3719 template<
class _InputIterator>
3721 const _Alloc& __a = _Alloc())
3722 : _M_dataplus(_S_construct(__beg, __end, __a), __a)
3725 #if __cplusplus >= 201703L
3733 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3735 const _Alloc& __a = _Alloc())
3743 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3746 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
3761 {
return this->
assign(__str); }
3769 {
return this->
assign(__s); }
3785 #if __cplusplus >= 201103L
3809 this->
assign(__l.begin(), __l.size());
3814 #if __cplusplus >= 201703L
3819 template<
typename _Tp>
3820 _If_sv<_Tp, basic_string&>
3822 {
return this->
assign(__svt); }
3841 return iterator(_M_data());
3850 {
return const_iterator(_M_data()); }
3860 return iterator(_M_data() + this->
size());
3869 {
return const_iterator(_M_data() + this->
size()); }
3885 const_reverse_iterator
3903 const_reverse_iterator
3907 #if __cplusplus >= 201103L
3914 {
return const_iterator(this->_M_data()); }
3922 {
return const_iterator(this->_M_data() + this->
size()); }
3929 const_reverse_iterator
3938 const_reverse_iterator
3949 {
return _M_rep()->_M_length; }
3955 {
return _M_rep()->_M_length; }
3960 {
return _Rep::_S_max_size; }
3973 resize(size_type __n, _CharT __c);
3987 { this->
resize(__n, _CharT()); }
3989 #if __cplusplus >= 201103L
3990 #pragma GCC diagnostic push
3991 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
3996 #pragma GCC diagnostic pop
4005 {
return _M_rep()->_M_capacity; }
4028 #if __cplusplus > 201703L
4029 [[deprecated(
"use shrink_to_fit() instead")]]
4037 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
4041 if (_M_rep()->_M_is_shared())
4044 _M_data(_S_empty_rep()._M_refdata());
4047 _M_rep()->_M_set_length_and_sharable(0);
4053 { _M_mutate(0, this->
size(), 0); }
4060 _GLIBCXX_NODISCARD
bool
4062 {
return this->
size() == 0; }
4078 __glibcxx_assert(__pos <=
size());
4079 return _M_data()[__pos];
4097 __glibcxx_assert(__pos <=
size());
4099 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
4101 return _M_data()[__pos];
4117 if (__n >= this->
size())
4118 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
4119 "(which is %zu) >= this->size() "
4122 return _M_data()[__n];
4140 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
4141 "(which is %zu) >= this->size() "
4145 return _M_data()[__n];
4148 #if __cplusplus >= 201103L
4156 __glibcxx_assert(!
empty());
4167 __glibcxx_assert(!
empty());
4178 __glibcxx_assert(!
empty());
4189 __glibcxx_assert(!
empty());
4202 {
return this->
append(__str); }
4211 {
return this->
append(__s); }
4225 #if __cplusplus >= 201103L
4233 {
return this->
append(__l.begin(), __l.size()); }
4236 #if __cplusplus >= 201703L
4242 template<
typename _Tp>
4243 _If_sv<_Tp, basic_string&>
4245 {
return this->
append(__svt); }
4279 append(
const _CharT* __s, size_type __n);
4289 __glibcxx_requires_string(__s);
4290 return this->
append(__s, traits_type::length(__s));
4302 append(size_type __n, _CharT __c);
4304 #if __cplusplus >= 201103L
4312 {
return this->
append(__l.begin(), __l.size()); }
4323 template<
class _InputIterator>
4325 append(_InputIterator __first, _InputIterator __last)
4326 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
4328 #if __cplusplus >= 201703L
4334 template<
typename _Tp>
4335 _If_sv<_Tp, basic_string&>
4339 return this->
append(__sv.data(), __sv.size());
4350 template<
typename _Tp>
4351 _If_sv<_Tp, basic_string&>
4355 return append(__sv.data()
4356 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
4357 std::__sv_limit(__sv.size(), __pos, __n));
4368 const size_type __len = 1 + this->
size();
4369 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
4371 traits_type::assign(_M_data()[this->
size()], __c);
4372 _M_rep()->_M_set_length_and_sharable(__len);
4383 #if __cplusplus >= 201103L
4416 {
return this->
assign(__str._M_data()
4417 + __str._M_check(__pos,
"basic_string::assign"),
4418 __str._M_limit(__pos, __n)); }
4431 assign(
const _CharT* __s, size_type __n);
4445 __glibcxx_requires_string(__s);
4446 return this->
assign(__s, traits_type::length(__s));
4460 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4470 template<
class _InputIterator>
4472 assign(_InputIterator __first, _InputIterator __last)
4473 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4475 #if __cplusplus >= 201103L
4483 {
return this->
assign(__l.begin(), __l.size()); }
4486 #if __cplusplus >= 201703L
4492 template<
typename _Tp>
4493 _If_sv<_Tp, basic_string&>
4497 return this->
assign(__sv.data(), __sv.size());
4507 template<
typename _Tp>
4508 _If_sv<_Tp, basic_string&>
4512 return assign(__sv.data()
4513 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
4514 std::__sv_limit(__sv.size(), __pos, __n));
4532 insert(iterator __p, size_type __n, _CharT __c)
4533 { this->
replace(__p, __p, __n, __c); }
4547 template<
class _InputIterator>
4549 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4550 { this->
replace(__p, __p, __beg, __end); }
4552 #if __cplusplus >= 201103L
4562 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4563 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4581 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4603 size_type __pos2, size_type __n =
npos)
4604 {
return this->
insert(__pos1, __str._M_data()
4605 + __str._M_check(__pos2,
"basic_string::insert"),
4606 __str._M_limit(__pos2, __n)); }
4625 insert(size_type __pos,
const _CharT* __s, size_type __n);
4645 __glibcxx_requires_string(__s);
4646 return this->
insert(__pos, __s, traits_type::length(__s));
4666 insert(size_type __pos, size_type __n, _CharT __c)
4667 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4668 size_type(0), __n, __c); }
4686 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4687 const size_type __pos = __p - _M_ibegin();
4688 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4689 _M_rep()->_M_set_leaked();
4690 return iterator(_M_data() + __pos);
4693 #if __cplusplus >= 201703L
4700 template<
typename _Tp>
4701 _If_sv<_Tp, basic_string&>
4705 return this->
insert(__pos, __sv.data(), __sv.size());
4717 template<
typename _Tp>
4718 _If_sv<_Tp, basic_string&>
4720 size_type __pos2, size_type __n =
npos)
4723 return this->
replace(__pos1, size_type(0), __sv.data()
4724 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
4725 std::__sv_limit(__sv.size(), __pos2, __n));
4747 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4748 _M_limit(__pos, __n), size_type(0));
4763 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4764 && __position < _M_iend());
4765 const size_type __pos = __position - _M_ibegin();
4766 _M_mutate(__pos, size_type(1), size_type(0));
4767 _M_rep()->_M_set_leaked();
4768 return iterator(_M_data() + __pos);
4783 #if __cplusplus >= 201103L
4792 __glibcxx_assert(!
empty());
4816 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4838 size_type __pos2, size_type __n2 =
npos)
4839 {
return this->
replace(__pos1, __n1, __str._M_data()
4840 + __str._M_check(__pos2,
"basic_string::replace"),
4841 __str._M_limit(__pos2, __n2)); }
4862 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4882 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4884 __glibcxx_requires_string(__s);
4885 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4906 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4907 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4908 _M_limit(__pos, __n1), __n2, __c); }
4925 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4943 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4945 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4946 && __i2 <= _M_iend());
4947 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4964 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4966 __glibcxx_requires_string(__s);
4967 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4985 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4987 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4988 && __i2 <= _M_iend());
4989 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
5007 template<
class _InputIterator>
5010 _InputIterator __k1, _InputIterator __k2)
5012 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5013 && __i2 <= _M_iend());
5014 __glibcxx_requires_valid_range(__k1, __k2);
5015 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
5016 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
5024 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5025 && __i2 <= _M_iend());
5026 __glibcxx_requires_valid_range(__k1, __k2);
5027 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5032 replace(iterator __i1, iterator __i2,
5033 const _CharT* __k1,
const _CharT* __k2)
5035 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5036 && __i2 <= _M_iend());
5037 __glibcxx_requires_valid_range(__k1, __k2);
5038 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5043 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
5045 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5046 && __i2 <= _M_iend());
5047 __glibcxx_requires_valid_range(__k1, __k2);
5048 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5049 __k1.base(), __k2 - __k1);
5053 replace(iterator __i1, iterator __i2,
5054 const_iterator __k1, const_iterator __k2)
5056 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5057 && __i2 <= _M_iend());
5058 __glibcxx_requires_valid_range(__k1, __k2);
5059 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5060 __k1.base(), __k2 - __k1);
5063 #if __cplusplus >= 201103L
5080 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
5083 #if __cplusplus >= 201703L
5091 template<
typename _Tp>
5092 _If_sv<_Tp, basic_string&>
5093 replace(size_type __pos, size_type __n,
const _Tp& __svt)
5096 return this->
replace(__pos, __n, __sv.data(), __sv.size());
5108 template<
typename _Tp>
5109 _If_sv<_Tp, basic_string&>
5110 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
5111 size_type __pos2, size_type __n2 =
npos)
5114 return this->
replace(__pos1, __n1,
5116 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
5117 std::__sv_limit(__sv.size(), __pos2, __n2));
5129 template<
typename _Tp>
5130 _If_sv<_Tp, basic_string&>
5131 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
5134 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
5139 template<
class _Integer>
5142 _Integer __val, __true_type)
5143 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
5145 template<
class _InputIterator>
5147 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
5148 _InputIterator __k2, __false_type);
5151 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
5155 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
5160 template<
class _InIterator>
5162 _S_construct_aux(_InIterator __beg, _InIterator __end,
5163 const _Alloc& __a, __false_type)
5165 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
5166 return _S_construct(__beg, __end, __a, _Tag());
5171 template<
class _Integer>
5173 _S_construct_aux(_Integer __beg, _Integer __end,
5174 const _Alloc& __a, __true_type)
5175 {
return _S_construct_aux_2(
static_cast<size_type
>(__beg),
5179 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
5180 {
return _S_construct(__req, __c, __a); }
5182 template<
class _InIterator>
5184 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
5186 typedef typename std::__is_integer<_InIterator>::__type _Integral;
5187 return _S_construct_aux(__beg, __end, __a, _Integral());
5191 template<
class _InIterator>
5193 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
5194 input_iterator_tag);
5198 template<
class _FwdIterator>
5200 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
5201 forward_iterator_tag);
5204 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
5221 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
5232 _GLIBCXX_NOEXCEPT_IF(allocator_traits<_Alloc>::is_always_equal::value);
5243 {
return _M_data(); }
5255 {
return _M_data(); }
5257 #if __cplusplus >= 201703L
5277 {
return _M_dataplus; }
5292 find(
const _CharT* __s, size_type __pos, size_type __n)
const
5308 {
return this->
find(__str.data(), __pos, __str.size()); }
5321 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
5323 __glibcxx_requires_string(__s);
5324 return this->
find(__s, __pos, traits_type::length(__s));
5338 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
5340 #if __cplusplus >= 201703L
5347 template<
typename _Tp>
5348 _If_sv<_Tp, size_type>
5349 find(
const _Tp& __svt, size_type __pos = 0) const
5353 return this->
find(__sv.data(), __pos, __sv.size());
5370 {
return this->
rfind(__str.data(), __pos, __str.size()); }
5385 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
5399 rfind(
const _CharT* __s, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT
5401 __glibcxx_requires_string(__s);
5402 return this->
rfind(__s, __pos, traits_type::length(__s));
5416 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
5418 #if __cplusplus >= 201703L
5425 template<
typename _Tp>
5426 _If_sv<_Tp, size_type>
5431 return this->
rfind(__sv.data(), __pos, __sv.size());
5449 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
5464 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
5481 __glibcxx_requires_string(__s);
5482 return this->
find_first_of(__s, __pos, traits_type::length(__s));
5499 {
return this->
find(__c, __pos); }
5501 #if __cplusplus >= 201703L
5509 template<
typename _Tp>
5510 _If_sv<_Tp, size_type>
5515 return this->
find_first_of(__sv.data(), __pos, __sv.size());
5533 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5548 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
5565 __glibcxx_requires_string(__s);
5566 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5583 {
return this->
rfind(__c, __pos); }
5585 #if __cplusplus >= 201703L
5593 template<
typename _Tp>
5594 _If_sv<_Tp, size_type>
5599 return this->
find_last_of(__sv.data(), __pos, __sv.size());
5632 size_type __n)
const _GLIBCXX_NOEXCEPT;
5648 __glibcxx_requires_string(__s);
5666 #if __cplusplus >= 201703L
5674 template<
typename _Tp>
5675 _If_sv<_Tp, size_type>
5714 size_type __n)
const _GLIBCXX_NOEXCEPT;
5730 __glibcxx_requires_string(__s);
5748 #if __cplusplus >= 201703L
5756 template<
typename _Tp>
5757 _If_sv<_Tp, size_type>
5781 _M_check(__pos,
"basic_string::substr"), __n); }
5800 const size_type __size = this->
size();
5801 const size_type __osize = __str.size();
5802 const size_type __len =
std::min(__size, __osize);
5804 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5806 __r = _S_compare(__size, __osize);
5810 #if __cplusplus >= 201703L
5816 template<
typename _Tp>
5822 const size_type __size = this->
size();
5823 const size_type __osize = __sv.size();
5824 const size_type __len =
std::min(__size, __osize);
5826 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
5828 __r = _S_compare(__size, __osize);
5840 template<
typename _Tp>
5842 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
5846 return __sv_type(*this).substr(__pos, __n).compare(__sv);
5859 template<
typename _Tp>
5861 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
5862 size_type __pos2, size_type __n2 =
npos)
const
5867 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
5918 size_type __pos2, size_type __n2 =
npos)
const;
5935 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5959 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5986 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5987 size_type __n2)
const;
5989 #if __cplusplus > 201703L
5992 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5995 starts_with(_CharT __x)
const noexcept
5996 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5999 starts_with(
const _CharT* __x)
const noexcept
6000 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
6003 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
6004 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
6007 ends_with(_CharT __x)
const noexcept
6008 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
6011 ends_with(
const _CharT* __x)
const noexcept
6012 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
6015 #if __cplusplus >= 202011L \
6016 || (__cplusplus == 202002L && !defined __STRICT_ANSI__)
6018 contains(basic_string_view<_CharT, _Traits> __x)
const noexcept
6019 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
6022 contains(_CharT __x)
const noexcept
6023 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
6026 contains(
const _CharT* __x)
const noexcept
6027 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
6030 # ifdef _GLIBCXX_TM_TS_INTERNAL
6032 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
6035 ::_txnal_cow_string_c_str(
const void *that);
6037 ::_txnal_cow_string_D1(
void *that);
6039 ::_txnal_cow_string_D1_commit(
void *that);
6044 #if __cpp_deduction_guides >= 201606
6045 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6046 template<
typename _InputIterator,
typename _CharT
6047 =
typename iterator_traits<_InputIterator>::value_type,
6048 typename _Allocator = allocator<_CharT>,
6049 typename = _RequireInputIter<_InputIterator>,
6050 typename = _RequireAllocator<_Allocator>>
6051 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
6052 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
6056 template<
typename _CharT,
typename _Traits,
6057 typename _Allocator = allocator<_CharT>,
6058 typename = _RequireAllocator<_Allocator>>
6059 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
6060 -> basic_string<_CharT, _Traits, _Allocator>;
6062 template<
typename _CharT,
typename _Traits,
6063 typename _Allocator = allocator<_CharT>,
6064 typename = _RequireAllocator<_Allocator>>
6065 basic_string(basic_string_view<_CharT, _Traits>,
6066 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6067 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6068 const _Allocator& = _Allocator())
6069 -> basic_string<_CharT, _Traits, _Allocator>;
6070 _GLIBCXX_END_NAMESPACE_CXX11
6080 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6081 basic_string<_CharT, _Traits, _Alloc>
6086 __str.append(__rhs);
6096 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6097 basic_string<_CharT,_Traits,_Alloc>
6099 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6107 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6108 basic_string<_CharT,_Traits,_Alloc>
6109 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6117 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6118 inline basic_string<_CharT, _Traits, _Alloc>
6120 const _CharT* __rhs)
6123 __str.append(__rhs);
6133 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6134 inline basic_string<_CharT, _Traits, _Alloc>
6138 typedef typename __string_type::size_type __size_type;
6139 __string_type __str(__lhs);
6140 __str.append(__size_type(1), __rhs);
6144 #if __cplusplus >= 201103L
6145 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6146 inline basic_string<_CharT, _Traits, _Alloc>
6147 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6148 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
6149 {
return std::move(__lhs.append(__rhs)); }
6151 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6152 inline basic_string<_CharT, _Traits, _Alloc>
6153 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6154 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6155 {
return std::move(__rhs.insert(0, __lhs)); }
6157 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6158 inline basic_string<_CharT, _Traits, _Alloc>
6159 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6160 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6162 #if _GLIBCXX_USE_CXX11_ABI
6163 using _Alloc_traits = allocator_traits<_Alloc>;
6164 bool __use_rhs =
false;
6165 if _GLIBCXX17_CONSTEXPR (
typename _Alloc_traits::is_always_equal{})
6167 else if (__lhs.get_allocator() == __rhs.get_allocator())
6172 const auto __size = __lhs.size() + __rhs.size();
6173 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
6174 return std::move(__rhs.insert(0, __lhs));
6179 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6180 inline basic_string<_CharT, _Traits, _Alloc>
6182 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6183 {
return std::move(__rhs.insert(0, __lhs)); }
6185 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6186 inline basic_string<_CharT, _Traits, _Alloc>
6188 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6189 {
return std::move(__rhs.insert(0, 1, __lhs)); }
6191 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6192 inline basic_string<_CharT, _Traits, _Alloc>
6193 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6194 const _CharT* __rhs)
6195 {
return std::move(__lhs.append(__rhs)); }
6197 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6198 inline basic_string<_CharT, _Traits, _Alloc>
6199 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6201 {
return std::move(__lhs.append(1, __rhs)); }
6211 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6216 {
return __lhs.compare(__rhs) == 0; }
6218 template<
typename _CharT>
6220 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
6221 operator==(
const basic_string<_CharT>& __lhs,
6222 const basic_string<_CharT>& __rhs) _GLIBCXX_NOEXCEPT
6223 {
return (__lhs.size() == __rhs.size()
6233 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6236 const _CharT* __rhs)
6237 {
return __lhs.compare(__rhs) == 0; }
6239 #if __cpp_lib_three_way_comparison
6247 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6249 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6250 const basic_string<_CharT, _Traits, _Alloc>& __rhs) noexcept
6251 -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
6252 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
6261 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6263 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6264 const _CharT* __rhs) noexcept
6265 -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
6266 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
6274 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6276 operator==(
const _CharT* __lhs,
6278 {
return __rhs.compare(__lhs) == 0; }
6287 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6292 {
return !(__lhs == __rhs); }
6300 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6302 operator!=(
const _CharT* __lhs,
6304 {
return !(__lhs == __rhs); }
6312 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6315 const _CharT* __rhs)
6316 {
return !(__lhs == __rhs); }
6325 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6330 {
return __lhs.compare(__rhs) < 0; }
6338 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6341 const _CharT* __rhs)
6342 {
return __lhs.compare(__rhs) < 0; }
6350 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6352 operator<(
const _CharT* __lhs,
6354 {
return __rhs.compare(__lhs) > 0; }
6363 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6368 {
return __lhs.compare(__rhs) > 0; }
6376 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6379 const _CharT* __rhs)
6380 {
return __lhs.compare(__rhs) > 0; }
6388 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6390 operator>(
const _CharT* __lhs,
6392 {
return __rhs.compare(__lhs) < 0; }
6401 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6406 {
return __lhs.compare(__rhs) <= 0; }
6414 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6417 const _CharT* __rhs)
6418 {
return __lhs.compare(__rhs) <= 0; }
6426 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6428 operator<=(
const _CharT* __lhs,
6430 {
return __rhs.compare(__lhs) >= 0; }
6439 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6444 {
return __lhs.compare(__rhs) >= 0; }
6452 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6455 const _CharT* __rhs)
6456 {
return __lhs.compare(__rhs) >= 0; }
6464 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6466 operator>=(
const _CharT* __lhs,
6468 {
return __rhs.compare(__lhs) <= 0; }
6478 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6482 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
6483 { __lhs.swap(__rhs); }
6498 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6499 basic_istream<_CharT, _Traits>&
6500 operator>>(basic_istream<_CharT, _Traits>& __is,
6501 basic_string<_CharT, _Traits, _Alloc>& __str);
6504 basic_istream<char>&
6516 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6523 return __ostream_insert(__os, __str.data(), __str.size());
6539 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6540 basic_istream<_CharT, _Traits>&
6541 getline(basic_istream<_CharT, _Traits>& __is,
6542 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
6556 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6557 inline basic_istream<_CharT, _Traits>&
6562 #if __cplusplus >= 201103L
6564 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6565 inline basic_istream<_CharT, _Traits>&
6571 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6572 inline basic_istream<_CharT, _Traits>&
6579 basic_istream<char>&
6580 getline(basic_istream<char>& __in, basic_string<char>& __str,
6583 #ifdef _GLIBCXX_USE_WCHAR_T
6585 basic_istream<wchar_t>&
6586 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
6590 _GLIBCXX_END_NAMESPACE_VERSION
6593 #if __cplusplus >= 201103L
6598 namespace std _GLIBCXX_VISIBILITY(default)
6600 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6601 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6603 #if _GLIBCXX_USE_C99_STDLIB
6606 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6607 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
6611 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6612 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
6615 inline unsigned long
6616 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6617 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
6621 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6622 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
6625 inline unsigned long long
6626 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6627 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
6632 stof(
const string& __str,
size_t* __idx = 0)
6633 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
6636 stod(
const string& __str,
size_t* __idx = 0)
6637 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
6640 stold(
const string& __str,
size_t* __idx = 0)
6641 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
6647 to_string(
int __val)
6649 const bool __neg = __val < 0;
6650 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
6651 const auto __len = __detail::__to_chars_len(__uval);
6652 string __str(__neg + __len,
'-');
6653 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
6658 to_string(
unsigned __val)
6660 string __str(__detail::__to_chars_len(__val),
'\0');
6661 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
6666 to_string(
long __val)
6668 const bool __neg = __val < 0;
6669 const unsigned long __uval = __neg ? (
unsigned long)~__val + 1ul : __val;
6670 const auto __len = __detail::__to_chars_len(__uval);
6671 string __str(__neg + __len,
'-');
6672 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
6677 to_string(
unsigned long __val)
6679 string __str(__detail::__to_chars_len(__val),
'\0');
6680 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
6685 to_string(
long long __val)
6687 const bool __neg = __val < 0;
6688 const unsigned long long __uval
6689 = __neg ? (
unsigned long long)~__val + 1ull : __val;
6690 const auto __len = __detail::__to_chars_len(__uval);
6691 string __str(__neg + __len,
'-');
6692 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
6697 to_string(
unsigned long long __val)
6699 string __str(__detail::__to_chars_len(__val),
'\0');
6700 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
6704 #if _GLIBCXX_USE_C99_STDIO
6708 to_string(
float __val)
6711 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6712 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6717 to_string(
double __val)
6720 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6721 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6726 to_string(
long double __val)
6729 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6730 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6735 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
6737 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6738 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
6742 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6743 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
6746 inline unsigned long
6747 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6748 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
6752 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6753 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
6756 inline unsigned long long
6757 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6758 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
6763 stof(
const wstring& __str,
size_t* __idx = 0)
6764 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
6767 stod(
const wstring& __str,
size_t* __idx = 0)
6768 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
6771 stold(
const wstring& __str,
size_t* __idx = 0)
6772 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
6774 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
6777 to_wstring(
int __val)
6778 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
int),
6782 to_wstring(
unsigned __val)
6783 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6784 4 *
sizeof(
unsigned),
6788 to_wstring(
long __val)
6789 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
long),
6793 to_wstring(
unsigned long __val)
6794 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6795 4 *
sizeof(
unsigned long),
6799 to_wstring(
long long __val)
6800 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6801 4 *
sizeof(
long long),
6805 to_wstring(
unsigned long long __val)
6806 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6807 4 *
sizeof(
unsigned long long),
6811 to_wstring(
float __val)
6814 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6815 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6820 to_wstring(
double __val)
6823 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6824 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6829 to_wstring(
long double __val)
6832 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6833 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6839 _GLIBCXX_END_NAMESPACE_CXX11
6840 _GLIBCXX_END_NAMESPACE_VERSION
6845 #if __cplusplus >= 201103L
6849 namespace std _GLIBCXX_VISIBILITY(default)
6851 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6855 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
6859 :
public __hash_base<size_t, string>
6862 operator()(
const string& __s)
const noexcept
6863 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
6870 #ifdef _GLIBCXX_USE_WCHAR_T
6874 :
public __hash_base<size_t, wstring>
6877 operator()(
const wstring& __s)
const noexcept
6878 {
return std::_Hash_impl::hash(__s.
data(),
6879 __s.
length() *
sizeof(
wchar_t)); }
6888 #ifdef _GLIBCXX_USE_CHAR8_T
6891 struct hash<u8string>
6892 :
public __hash_base<size_t, u8string>
6895 operator()(
const u8string& __s)
const noexcept
6896 {
return std::_Hash_impl::hash(__s.data(),
6897 __s.length() *
sizeof(char8_t)); }
6908 :
public __hash_base<size_t, u16string>
6911 operator()(
const u16string& __s)
const noexcept
6912 {
return std::_Hash_impl::hash(__s.
data(),
6913 __s.
length() *
sizeof(char16_t)); }
6923 :
public __hash_base<size_t, u32string>
6926 operator()(
const u32string& __s)
const noexcept
6927 {
return std::_Hash_impl::hash(__s.
data(),
6928 __s.
length() *
sizeof(char32_t)); }
6935 #if __cplusplus >= 201402L
6937 #define __cpp_lib_string_udls 201304
6939 inline namespace literals
6941 inline namespace string_literals
6943 #pragma GCC diagnostic push
6944 #pragma GCC diagnostic ignored "-Wliteral-suffix"
6945 _GLIBCXX_DEFAULT_ABI_TAG
6946 inline basic_string<char>
6947 operator""s(
const char* __str,
size_t __len)
6948 {
return basic_string<char>{__str, __len}; }
6950 #ifdef _GLIBCXX_USE_WCHAR_T
6951 _GLIBCXX_DEFAULT_ABI_TAG
6952 inline basic_string<wchar_t>
6953 operator""s(
const wchar_t* __str,
size_t __len)
6954 {
return basic_string<wchar_t>{__str, __len}; }
6957 #ifdef _GLIBCXX_USE_CHAR8_T
6958 _GLIBCXX_DEFAULT_ABI_TAG
6959 inline basic_string<char8_t>
6960 operator""s(
const char8_t* __str,
size_t __len)
6961 {
return basic_string<char8_t>{__str, __len}; }
6964 _GLIBCXX_DEFAULT_ABI_TAG
6965 inline basic_string<char16_t>
6966 operator""s(
const char16_t* __str,
size_t __len)
6967 {
return basic_string<char16_t>{__str, __len}; }
6969 _GLIBCXX_DEFAULT_ABI_TAG
6970 inline basic_string<char32_t>
6971 operator""s(
const char32_t* __str,
size_t __len)
6972 {
return basic_string<char32_t>{__str, __len}; }
6974 #pragma GCC diagnostic pop
6978 #if __cplusplus >= 201703L
6979 namespace __detail::__variant
6981 template<
typename>
struct _Never_valueless_alt;
6985 template<
typename _Tp,
typename _Traits,
typename _Alloc>
6986 struct _Never_valueless_alt<
std::basic_string<_Tp, _Traits, _Alloc>>
6988 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
6989 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
6996 _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 _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
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.
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.
_If_sv< _Tp, basic_string & > append(const _Tp &__svt)
Append a string_view.
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(_InputIterator __beg, _InputIterator __end, const _Alloc &__a=_Alloc())
Construct string as copy of a range.
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.
_If_sv< _Tp, size_type > find_last_of(const _Tp &__svt, size_type __pos=npos) const noexcept(is_same< _Tp, __sv_type >::value)
Find last position of a character of 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.
_If_sv< _Tp, size_type > find(const _Tp &__svt, size_type __pos=0) const noexcept(is_same< _Tp, __sv_type >::value)
Find position of a string_view.
basic_string(const _Alloc &__a)
Construct an empty string using allocator a.
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.
_If_sv< _Tp, basic_string & > append(const _Tp &__svt, size_type __pos, size_type __n=npos)
Append a range of characters from a string_view.
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.
_If_sv< _Tp, basic_string & > operator=(const _Tp &__svt)
Set value to string constructed from a string_view.
basic_string(const basic_string &__str)
Construct string with copy of value of str.
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.
_If_sv< _Tp, basic_string & > replace(const_iterator __i1, const_iterator __i2, const _Tp &__svt)
Replace range of characters with string_view.
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.
_If_sv< _Tp, basic_string & > insert(size_type __pos, const _Tp &__svt)
Insert a string_view.
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.
basic_string(const _Tp &__t, size_type __pos, size_type __n, const _Alloc &__a=_Alloc())
Construct string from a substring of a string_view.
reverse_iterator rbegin()
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
_If_sv< _Tp, basic_string & > operator+=(const _Tp &__svt)
Append a string_view.
basic_string(initializer_list< _CharT > __l, const _Alloc &__a=_Alloc())
Construct string from an initializer list.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
basic_string(const _Tp &__t, const _Alloc &__a=_Alloc())
Construct string from a string_view.
_If_sv< _Tp, basic_string & > replace(size_type __pos, size_type __n, const _Tp &__svt)
Replace range of characters with string_view.
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.
_If_sv< _Tp, basic_string & > assign(const _Tp &__svt)
Set value from a string_view.
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.
_If_sv< _Tp, int > compare(const _Tp &__svt) const noexcept(is_same< _Tp, __sv_type >::value)
Compare to a string_view.
_If_sv< _Tp, size_type > rfind(const _Tp &__svt, size_type __pos=npos) const noexcept(is_same< _Tp, __sv_type >::value)
Find last position of a string_view.
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.
basic_string(size_type __n, _CharT __c, const _Alloc &__a=_Alloc())
Construct string as multiple characters.
_If_sv< _Tp, basic_string & > assign(const _Tp &__svt, size_type __pos, size_type __n=npos)
Set value from a range of characters in a string_view.
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.
void reserve()
Equivalent to shrink_to_fit().
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
_If_sv< _Tp, basic_string & > insert(size_type __pos1, const _Tp &__svt, size_type __pos2, size_type __n=npos)
Insert a string_view.
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.
_If_sv< _Tp, size_type > find_first_not_of(const _Tp &__svt, size_type __pos=0) const noexcept(is_same< _Tp, __sv_type >::value)
Find position of a character not in a string_view.
basic_string & append(const basic_string &__str)
Append a string to this string.
_CharT * data() noexcept
Return non-const pointer to contents.
const_iterator begin() const noexcept
_If_sv< _Tp, int > compare(size_type __pos1, size_type __n1, const _Tp &__svt, size_type __pos2, size_type __n2=npos) const noexcept(is_same< _Tp, __sv_type >::value)
Compare to a string_view.
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
_If_sv< _Tp, basic_string & > replace(size_type __pos1, size_type __n1, const _Tp &__svt, size_type __pos2, size_type __n2=npos)
Replace range of characters with string_view.
_If_sv< _Tp, int > compare(size_type __pos, size_type __n, const _Tp &__svt) const noexcept(is_same< _Tp, __sv_type >::value)
Compare to a string_view.
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.
_If_sv< _Tp, size_type > find_last_not_of(const _Tp &__svt, size_type __pos=npos) const noexcept(is_same< _Tp, __sv_type >::value)
Find last position of a character not in a string_view.
basic_string(const _CharT *__s, size_type __n, const _Alloc &__a=_Alloc())
Construct string initialized by a character array.
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.
_If_sv< _Tp, size_type > find_first_of(const _Tp &__svt, size_type __pos=0) const noexcept(is_same< _Tp, __sv_type >::value)
Find position of a character of a string_view.
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.