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); }
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())
3567 : _M_dataplus(_S_construct(size_type(), _CharT(), __a), __a)
3576 : _M_dataplus(__str._M_rep()->_M_grab(_Alloc(__str.
get_allocator()),
3590 const _Alloc& __a = _Alloc());
3608 size_type __n,
const _Alloc& __a);
3620 const _Alloc& __a = _Alloc())
3621 : _M_dataplus(_S_construct(__s, __s + __n, __a), __a)
3629 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
3632 template<
typename = _RequireAllocator<_Alloc>>
3635 : _M_dataplus(_S_construct(__s, __s ? __s + traits_type::
length(__s) :
3636 __s +
npos, __a), __a)
3646 : _M_dataplus(_S_construct(__n, __c, __a), __a)
3649 #if __cplusplus >= 201103L
3658 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3661 : _M_dataplus(
std::move(__str._M_dataplus))
3663 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3664 __str._M_data(_S_empty_rep()._M_refdata());
3666 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3676 : _M_dataplus(_S_construct(__l.
begin(), __l.
end(), __a), __a)
3680 : _M_dataplus(__str._M_rep()->_M_grab(__a, __str.
get_allocator()), __a)
3684 : _M_dataplus(__str._M_data(), __a)
3686 if (__a == __str.get_allocator())
3688 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3689 __str._M_data(_S_empty_rep()._M_refdata());
3691 __str._M_data(_S_construct(size_type(), _CharT(), __a));
3695 _M_dataplus._M_p = _S_construct(__str.begin(), __str.end(), __a);
3705 template<
class _InputIterator>
3707 const _Alloc& __a = _Alloc())
3708 : _M_dataplus(_S_construct(__beg, __end, __a), __a)
3711 #if __cplusplus >= 201703L
3719 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3721 const _Alloc& __a = _Alloc())
3729 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3732 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
3747 {
return this->
assign(__str); }
3755 {
return this->
assign(__s); }
3771 #if __cplusplus >= 201103L
3795 this->
assign(__l.begin(), __l.size());
3800 #if __cplusplus >= 201703L
3805 template<
typename _Tp>
3806 _If_sv<_Tp, basic_string&>
3808 {
return this->
assign(__svt); }
3827 return iterator(_M_data());
3836 {
return const_iterator(_M_data()); }
3846 return iterator(_M_data() + this->
size());
3855 {
return const_iterator(_M_data() + this->
size()); }
3871 const_reverse_iterator
3889 const_reverse_iterator
3893 #if __cplusplus >= 201103L
3900 {
return const_iterator(this->_M_data()); }
3908 {
return const_iterator(this->_M_data() + this->
size()); }
3915 const_reverse_iterator
3924 const_reverse_iterator
3935 {
return _M_rep()->_M_length; }
3941 {
return _M_rep()->_M_length; }
3946 {
return _Rep::_S_max_size; }
3959 resize(size_type __n, _CharT __c);
3973 { this->
resize(__n, _CharT()); }
3975 #if __cplusplus >= 201103L
3976 #pragma GCC diagnostic push
3977 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
3982 #pragma GCC diagnostic pop
3991 {
return _M_rep()->_M_capacity; }
4014 #if __cplusplus > 201703L
4015 [[deprecated(
"use shrink_to_fit() instead")]]
4023 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
4027 if (_M_rep()->_M_is_shared())
4030 _M_data(_S_empty_rep()._M_refdata());
4033 _M_rep()->_M_set_length_and_sharable(0);
4039 { _M_mutate(0, this->
size(), 0); }
4046 _GLIBCXX_NODISCARD
bool
4048 {
return this->
size() == 0; }
4064 __glibcxx_assert(__pos <=
size());
4065 return _M_data()[__pos];
4083 __glibcxx_assert(__pos <=
size());
4085 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
4087 return _M_data()[__pos];
4103 if (__n >= this->
size())
4104 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
4105 "(which is %zu) >= this->size() "
4108 return _M_data()[__n];
4126 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
4127 "(which is %zu) >= this->size() "
4131 return _M_data()[__n];
4134 #if __cplusplus >= 201103L
4142 __glibcxx_assert(!
empty());
4153 __glibcxx_assert(!
empty());
4164 __glibcxx_assert(!
empty());
4175 __glibcxx_assert(!
empty());
4188 {
return this->
append(__str); }
4197 {
return this->
append(__s); }
4211 #if __cplusplus >= 201103L
4219 {
return this->
append(__l.begin(), __l.size()); }
4222 #if __cplusplus >= 201703L
4228 template<
typename _Tp>
4229 _If_sv<_Tp, basic_string&>
4231 {
return this->
append(__svt); }
4265 append(
const _CharT* __s, size_type __n);
4275 __glibcxx_requires_string(__s);
4276 return this->
append(__s, traits_type::length(__s));
4288 append(size_type __n, _CharT __c);
4290 #if __cplusplus >= 201103L
4298 {
return this->
append(__l.begin(), __l.size()); }
4309 template<
class _InputIterator>
4311 append(_InputIterator __first, _InputIterator __last)
4312 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
4314 #if __cplusplus >= 201703L
4320 template<
typename _Tp>
4321 _If_sv<_Tp, basic_string&>
4325 return this->
append(__sv.data(), __sv.size());
4336 template<
typename _Tp>
4337 _If_sv<_Tp, basic_string&>
4341 return append(__sv.data()
4342 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
4343 std::__sv_limit(__sv.size(), __pos, __n));
4354 const size_type __len = 1 + this->
size();
4355 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
4357 traits_type::assign(_M_data()[this->
size()], __c);
4358 _M_rep()->_M_set_length_and_sharable(__len);
4369 #if __cplusplus >= 201103L
4402 {
return this->
assign(__str._M_data()
4403 + __str._M_check(__pos,
"basic_string::assign"),
4404 __str._M_limit(__pos, __n)); }
4417 assign(
const _CharT* __s, size_type __n);
4431 __glibcxx_requires_string(__s);
4432 return this->
assign(__s, traits_type::length(__s));
4446 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4456 template<
class _InputIterator>
4458 assign(_InputIterator __first, _InputIterator __last)
4459 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4461 #if __cplusplus >= 201103L
4469 {
return this->
assign(__l.begin(), __l.size()); }
4472 #if __cplusplus >= 201703L
4478 template<
typename _Tp>
4479 _If_sv<_Tp, basic_string&>
4483 return this->
assign(__sv.data(), __sv.size());
4493 template<
typename _Tp>
4494 _If_sv<_Tp, basic_string&>
4498 return assign(__sv.data()
4499 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
4500 std::__sv_limit(__sv.size(), __pos, __n));
4518 insert(iterator __p, size_type __n, _CharT __c)
4519 { this->
replace(__p, __p, __n, __c); }
4533 template<
class _InputIterator>
4535 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4536 { this->
replace(__p, __p, __beg, __end); }
4538 #if __cplusplus >= 201103L
4548 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4549 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4567 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4589 size_type __pos2, size_type __n =
npos)
4590 {
return this->
insert(__pos1, __str._M_data()
4591 + __str._M_check(__pos2,
"basic_string::insert"),
4592 __str._M_limit(__pos2, __n)); }
4611 insert(size_type __pos,
const _CharT* __s, size_type __n);
4631 __glibcxx_requires_string(__s);
4632 return this->
insert(__pos, __s, traits_type::length(__s));
4652 insert(size_type __pos, size_type __n, _CharT __c)
4653 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4654 size_type(0), __n, __c); }
4672 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4673 const size_type __pos = __p - _M_ibegin();
4674 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4675 _M_rep()->_M_set_leaked();
4676 return iterator(_M_data() + __pos);
4679 #if __cplusplus >= 201703L
4686 template<
typename _Tp>
4687 _If_sv<_Tp, basic_string&>
4691 return this->
insert(__pos, __sv.data(), __sv.size());
4703 template<
typename _Tp>
4704 _If_sv<_Tp, basic_string&>
4706 size_type __pos2, size_type __n =
npos)
4709 return this->
replace(__pos1, size_type(0), __sv.data()
4710 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
4711 std::__sv_limit(__sv.size(), __pos2, __n));
4733 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4734 _M_limit(__pos, __n), size_type(0));
4749 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4750 && __position < _M_iend());
4751 const size_type __pos = __position - _M_ibegin();
4752 _M_mutate(__pos, size_type(1), size_type(0));
4753 _M_rep()->_M_set_leaked();
4754 return iterator(_M_data() + __pos);
4769 #if __cplusplus >= 201103L
4778 __glibcxx_assert(!
empty());
4802 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4824 size_type __pos2, size_type __n2 =
npos)
4825 {
return this->
replace(__pos1, __n1, __str._M_data()
4826 + __str._M_check(__pos2,
"basic_string::replace"),
4827 __str._M_limit(__pos2, __n2)); }
4848 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4868 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4870 __glibcxx_requires_string(__s);
4871 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4892 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4893 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4894 _M_limit(__pos, __n1), __n2, __c); }
4911 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4929 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4931 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4932 && __i2 <= _M_iend());
4933 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4950 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4952 __glibcxx_requires_string(__s);
4953 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4971 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4973 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4974 && __i2 <= _M_iend());
4975 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4993 template<
class _InputIterator>
4996 _InputIterator __k1, _InputIterator __k2)
4998 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4999 && __i2 <= _M_iend());
5000 __glibcxx_requires_valid_range(__k1, __k2);
5001 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
5002 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
5010 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5011 && __i2 <= _M_iend());
5012 __glibcxx_requires_valid_range(__k1, __k2);
5013 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5018 replace(iterator __i1, iterator __i2,
5019 const _CharT* __k1,
const _CharT* __k2)
5021 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5022 && __i2 <= _M_iend());
5023 __glibcxx_requires_valid_range(__k1, __k2);
5024 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5029 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
5031 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5032 && __i2 <= _M_iend());
5033 __glibcxx_requires_valid_range(__k1, __k2);
5034 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5035 __k1.base(), __k2 - __k1);
5039 replace(iterator __i1, iterator __i2,
5040 const_iterator __k1, const_iterator __k2)
5042 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5043 && __i2 <= _M_iend());
5044 __glibcxx_requires_valid_range(__k1, __k2);
5045 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5046 __k1.base(), __k2 - __k1);
5049 #if __cplusplus >= 201103L
5066 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
5069 #if __cplusplus >= 201703L
5077 template<
typename _Tp>
5078 _If_sv<_Tp, basic_string&>
5079 replace(size_type __pos, size_type __n,
const _Tp& __svt)
5082 return this->
replace(__pos, __n, __sv.data(), __sv.size());
5094 template<
typename _Tp>
5095 _If_sv<_Tp, basic_string&>
5096 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
5097 size_type __pos2, size_type __n2 =
npos)
5100 return this->
replace(__pos1, __n1,
5102 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
5103 std::__sv_limit(__sv.size(), __pos2, __n2));
5115 template<
typename _Tp>
5116 _If_sv<_Tp, basic_string&>
5117 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
5120 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
5125 template<
class _Integer>
5128 _Integer __val, __true_type)
5129 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
5131 template<
class _InputIterator>
5133 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
5134 _InputIterator __k2, __false_type);
5137 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
5141 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
5146 template<
class _InIterator>
5148 _S_construct_aux(_InIterator __beg, _InIterator __end,
5149 const _Alloc& __a, __false_type)
5151 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
5152 return _S_construct(__beg, __end, __a, _Tag());
5157 template<
class _Integer>
5159 _S_construct_aux(_Integer __beg, _Integer __end,
5160 const _Alloc& __a, __true_type)
5161 {
return _S_construct_aux_2(
static_cast<size_type
>(__beg),
5165 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
5166 {
return _S_construct(__req, __c, __a); }
5168 template<
class _InIterator>
5170 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
5172 typedef typename std::__is_integer<_InIterator>::__type _Integral;
5173 return _S_construct_aux(__beg, __end, __a, _Integral());
5177 template<
class _InIterator>
5179 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
5180 input_iterator_tag);
5184 template<
class _FwdIterator>
5186 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
5187 forward_iterator_tag);
5190 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
5207 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
5218 _GLIBCXX_NOEXCEPT_IF(allocator_traits<_Alloc>::is_always_equal::value);
5229 {
return _M_data(); }
5241 {
return _M_data(); }
5243 #if __cplusplus >= 201703L
5263 {
return _M_dataplus; }
5278 find(
const _CharT* __s, size_type __pos, size_type __n)
const
5294 {
return this->
find(__str.data(), __pos, __str.size()); }
5307 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
5309 __glibcxx_requires_string(__s);
5310 return this->
find(__s, __pos, traits_type::length(__s));
5324 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
5326 #if __cplusplus >= 201703L
5333 template<
typename _Tp>
5334 _If_sv<_Tp, size_type>
5335 find(
const _Tp& __svt, size_type __pos = 0) const
5339 return this->
find(__sv.data(), __pos, __sv.size());
5356 {
return this->
rfind(__str.data(), __pos, __str.size()); }
5371 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
5385 rfind(
const _CharT* __s, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT
5387 __glibcxx_requires_string(__s);
5388 return this->
rfind(__s, __pos, traits_type::length(__s));
5402 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
5404 #if __cplusplus >= 201703L
5411 template<
typename _Tp>
5412 _If_sv<_Tp, size_type>
5417 return this->
rfind(__sv.data(), __pos, __sv.size());
5435 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
5450 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
5467 __glibcxx_requires_string(__s);
5468 return this->
find_first_of(__s, __pos, traits_type::length(__s));
5485 {
return this->
find(__c, __pos); }
5487 #if __cplusplus >= 201703L
5495 template<
typename _Tp>
5496 _If_sv<_Tp, size_type>
5501 return this->
find_first_of(__sv.data(), __pos, __sv.size());
5519 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5534 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
5551 __glibcxx_requires_string(__s);
5552 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5569 {
return this->
rfind(__c, __pos); }
5571 #if __cplusplus >= 201703L
5579 template<
typename _Tp>
5580 _If_sv<_Tp, size_type>
5585 return this->
find_last_of(__sv.data(), __pos, __sv.size());
5618 size_type __n)
const _GLIBCXX_NOEXCEPT;
5634 __glibcxx_requires_string(__s);
5652 #if __cplusplus >= 201703L
5660 template<
typename _Tp>
5661 _If_sv<_Tp, size_type>
5700 size_type __n)
const _GLIBCXX_NOEXCEPT;
5716 __glibcxx_requires_string(__s);
5734 #if __cplusplus >= 201703L
5742 template<
typename _Tp>
5743 _If_sv<_Tp, size_type>
5767 _M_check(__pos,
"basic_string::substr"), __n); }
5786 const size_type __size = this->
size();
5787 const size_type __osize = __str.size();
5788 const size_type __len =
std::min(__size, __osize);
5790 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5792 __r = _S_compare(__size, __osize);
5796 #if __cplusplus >= 201703L
5802 template<
typename _Tp>
5808 const size_type __size = this->
size();
5809 const size_type __osize = __sv.size();
5810 const size_type __len =
std::min(__size, __osize);
5812 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
5814 __r = _S_compare(__size, __osize);
5826 template<
typename _Tp>
5828 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
5832 return __sv_type(*this).substr(__pos, __n).compare(__sv);
5845 template<
typename _Tp>
5847 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
5848 size_type __pos2, size_type __n2 =
npos)
const
5853 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
5904 size_type __pos2, size_type __n2 =
npos)
const;
5921 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5945 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5972 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5973 size_type __n2)
const;
5975 #if __cplusplus > 201703L
5978 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5981 starts_with(_CharT __x)
const noexcept
5982 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5985 starts_with(
const _CharT* __x)
const noexcept
5986 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5989 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
5990 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5993 ends_with(_CharT __x)
const noexcept
5994 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5997 ends_with(
const _CharT* __x)
const noexcept
5998 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
6001 # ifdef _GLIBCXX_TM_TS_INTERNAL
6003 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
6006 ::_txnal_cow_string_c_str(
const void *that);
6008 ::_txnal_cow_string_D1(
void *that);
6010 ::_txnal_cow_string_D1_commit(
void *that);
6015 #if __cpp_deduction_guides >= 201606
6016 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6017 template<
typename _InputIterator,
typename _CharT
6018 =
typename iterator_traits<_InputIterator>::value_type,
6019 typename _Allocator = allocator<_CharT>,
6020 typename = _RequireInputIter<_InputIterator>,
6021 typename = _RequireAllocator<_Allocator>>
6022 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
6023 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
6027 template<
typename _CharT,
typename _Traits,
6028 typename _Allocator = allocator<_CharT>,
6029 typename = _RequireAllocator<_Allocator>>
6030 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
6031 -> basic_string<_CharT, _Traits, _Allocator>;
6033 template<
typename _CharT,
typename _Traits,
6034 typename _Allocator = allocator<_CharT>,
6035 typename = _RequireAllocator<_Allocator>>
6036 basic_string(basic_string_view<_CharT, _Traits>,
6037 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6038 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6039 const _Allocator& = _Allocator())
6040 -> basic_string<_CharT, _Traits, _Allocator>;
6041 _GLIBCXX_END_NAMESPACE_CXX11
6051 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6052 basic_string<_CharT, _Traits, _Alloc>
6057 __str.append(__rhs);
6067 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6068 basic_string<_CharT,_Traits,_Alloc>
6070 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6078 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6079 basic_string<_CharT,_Traits,_Alloc>
6080 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6088 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6089 inline basic_string<_CharT, _Traits, _Alloc>
6091 const _CharT* __rhs)
6094 __str.append(__rhs);
6104 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6105 inline basic_string<_CharT, _Traits, _Alloc>
6109 typedef typename __string_type::size_type __size_type;
6110 __string_type __str(__lhs);
6111 __str.append(__size_type(1), __rhs);
6115 #if __cplusplus >= 201103L
6116 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6117 inline basic_string<_CharT, _Traits, _Alloc>
6118 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6119 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
6120 {
return std::move(__lhs.append(__rhs)); }
6122 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6123 inline basic_string<_CharT, _Traits, _Alloc>
6124 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6125 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6126 {
return std::move(__rhs.insert(0, __lhs)); }
6128 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6129 inline basic_string<_CharT, _Traits, _Alloc>
6130 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6131 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6133 #if _GLIBCXX_USE_CXX11_ABI
6134 using _Alloc_traits = allocator_traits<_Alloc>;
6135 bool __use_rhs =
false;
6136 if _GLIBCXX17_CONSTEXPR (
typename _Alloc_traits::is_always_equal{})
6138 else if (__lhs.get_allocator() == __rhs.get_allocator())
6143 const auto __size = __lhs.size() + __rhs.size();
6144 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
6145 return std::move(__rhs.insert(0, __lhs));
6150 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6151 inline basic_string<_CharT, _Traits, _Alloc>
6153 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6154 {
return std::move(__rhs.insert(0, __lhs)); }
6156 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6157 inline basic_string<_CharT, _Traits, _Alloc>
6159 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6160 {
return std::move(__rhs.insert(0, 1, __lhs)); }
6162 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6163 inline basic_string<_CharT, _Traits, _Alloc>
6164 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6165 const _CharT* __rhs)
6166 {
return std::move(__lhs.append(__rhs)); }
6168 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6169 inline basic_string<_CharT, _Traits, _Alloc>
6170 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6172 {
return std::move(__lhs.append(1, __rhs)); }
6182 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6187 {
return __lhs.compare(__rhs) == 0; }
6189 template<
typename _CharT>
6191 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
6192 operator==(
const basic_string<_CharT>& __lhs,
6193 const basic_string<_CharT>& __rhs) _GLIBCXX_NOEXCEPT
6194 {
return (__lhs.size() == __rhs.size()
6204 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6207 const _CharT* __rhs)
6208 {
return __lhs.compare(__rhs) == 0; }
6210 #if __cpp_lib_three_way_comparison
6218 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6220 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6221 const basic_string<_CharT, _Traits, _Alloc>& __rhs) noexcept
6222 -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
6223 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
6232 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6234 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6235 const _CharT* __rhs) noexcept
6236 -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
6237 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
6245 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6247 operator==(
const _CharT* __lhs,
6249 {
return __rhs.compare(__lhs) == 0; }
6258 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6263 {
return !(__lhs == __rhs); }
6271 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6273 operator!=(
const _CharT* __lhs,
6275 {
return !(__lhs == __rhs); }
6283 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6286 const _CharT* __rhs)
6287 {
return !(__lhs == __rhs); }
6296 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6301 {
return __lhs.compare(__rhs) < 0; }
6309 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6312 const _CharT* __rhs)
6313 {
return __lhs.compare(__rhs) < 0; }
6321 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6323 operator<(
const _CharT* __lhs,
6325 {
return __rhs.compare(__lhs) > 0; }
6334 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6339 {
return __lhs.compare(__rhs) > 0; }
6347 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6350 const _CharT* __rhs)
6351 {
return __lhs.compare(__rhs) > 0; }
6359 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6361 operator>(
const _CharT* __lhs,
6363 {
return __rhs.compare(__lhs) < 0; }
6372 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6377 {
return __lhs.compare(__rhs) <= 0; }
6385 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6388 const _CharT* __rhs)
6389 {
return __lhs.compare(__rhs) <= 0; }
6397 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6399 operator<=(
const _CharT* __lhs,
6401 {
return __rhs.compare(__lhs) >= 0; }
6410 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6415 {
return __lhs.compare(__rhs) >= 0; }
6423 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6426 const _CharT* __rhs)
6427 {
return __lhs.compare(__rhs) >= 0; }
6435 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6437 operator>=(
const _CharT* __lhs,
6439 {
return __rhs.compare(__lhs) <= 0; }
6449 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6453 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
6454 { __lhs.swap(__rhs); }
6469 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6470 basic_istream<_CharT, _Traits>&
6471 operator>>(basic_istream<_CharT, _Traits>& __is,
6472 basic_string<_CharT, _Traits, _Alloc>& __str);
6475 basic_istream<char>&
6487 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6494 return __ostream_insert(__os, __str.data(), __str.size());
6510 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6511 basic_istream<_CharT, _Traits>&
6512 getline(basic_istream<_CharT, _Traits>& __is,
6513 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
6527 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6528 inline basic_istream<_CharT, _Traits>&
6533 #if __cplusplus >= 201103L
6535 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6536 inline basic_istream<_CharT, _Traits>&
6542 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6543 inline basic_istream<_CharT, _Traits>&
6550 basic_istream<char>&
6551 getline(basic_istream<char>& __in, basic_string<char>& __str,
6554 #ifdef _GLIBCXX_USE_WCHAR_T
6556 basic_istream<wchar_t>&
6557 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
6561 _GLIBCXX_END_NAMESPACE_VERSION
6564 #if __cplusplus >= 201103L
6569 namespace std _GLIBCXX_VISIBILITY(default)
6571 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6572 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6574 #if _GLIBCXX_USE_C99_STDLIB
6577 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6578 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
6582 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6583 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
6586 inline unsigned long
6587 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6588 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
6592 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6593 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
6596 inline unsigned long long
6597 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6598 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
6603 stof(
const string& __str,
size_t* __idx = 0)
6604 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
6607 stod(
const string& __str,
size_t* __idx = 0)
6608 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
6611 stold(
const string& __str,
size_t* __idx = 0)
6612 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
6618 to_string(
int __val)
6620 const bool __neg = __val < 0;
6621 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
6622 const auto __len = __detail::__to_chars_len(__uval);
6623 string __str(__neg + __len,
'-');
6624 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
6629 to_string(
unsigned __val)
6631 string __str(__detail::__to_chars_len(__val),
'\0');
6632 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
6637 to_string(
long __val)
6639 const bool __neg = __val < 0;
6640 const unsigned long __uval = __neg ? (
unsigned long)~__val + 1ul : __val;
6641 const auto __len = __detail::__to_chars_len(__uval);
6642 string __str(__neg + __len,
'-');
6643 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
6648 to_string(
unsigned long __val)
6650 string __str(__detail::__to_chars_len(__val),
'\0');
6651 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
6656 to_string(
long long __val)
6658 const bool __neg = __val < 0;
6659 const unsigned long long __uval
6660 = __neg ? (
unsigned long long)~__val + 1ull : __val;
6661 const auto __len = __detail::__to_chars_len(__uval);
6662 string __str(__neg + __len,
'-');
6663 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
6668 to_string(
unsigned long long __val)
6670 string __str(__detail::__to_chars_len(__val),
'\0');
6671 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
6675 #if _GLIBCXX_USE_C99_STDIO
6679 to_string(
float __val)
6682 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6683 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6688 to_string(
double __val)
6691 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6692 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6697 to_string(
long double __val)
6700 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6701 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6706 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
6708 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6709 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
6713 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6714 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
6717 inline unsigned long
6718 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6719 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
6723 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6724 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
6727 inline unsigned long long
6728 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6729 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
6734 stof(
const wstring& __str,
size_t* __idx = 0)
6735 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
6738 stod(
const wstring& __str,
size_t* __idx = 0)
6739 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
6742 stold(
const wstring& __str,
size_t* __idx = 0)
6743 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
6745 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
6748 to_wstring(
int __val)
6749 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
int),
6753 to_wstring(
unsigned __val)
6754 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6755 4 *
sizeof(
unsigned),
6759 to_wstring(
long __val)
6760 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
long),
6764 to_wstring(
unsigned long __val)
6765 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6766 4 *
sizeof(
unsigned long),
6770 to_wstring(
long long __val)
6771 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6772 4 *
sizeof(
long long),
6776 to_wstring(
unsigned long long __val)
6777 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6778 4 *
sizeof(
unsigned long long),
6782 to_wstring(
float __val)
6785 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6786 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6791 to_wstring(
double __val)
6794 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6795 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6800 to_wstring(
long double __val)
6803 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6804 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6810 _GLIBCXX_END_NAMESPACE_CXX11
6811 _GLIBCXX_END_NAMESPACE_VERSION
6816 #if __cplusplus >= 201103L
6820 namespace std _GLIBCXX_VISIBILITY(default)
6822 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6826 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
6830 :
public __hash_base<size_t, string>
6833 operator()(
const string& __s)
const noexcept
6834 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
6841 #ifdef _GLIBCXX_USE_WCHAR_T
6845 :
public __hash_base<size_t, wstring>
6848 operator()(
const wstring& __s)
const noexcept
6849 {
return std::_Hash_impl::hash(__s.
data(),
6850 __s.
length() *
sizeof(
wchar_t)); }
6859 #ifdef _GLIBCXX_USE_CHAR8_T
6862 struct hash<u8string>
6863 :
public __hash_base<size_t, u8string>
6866 operator()(
const u8string& __s)
const noexcept
6867 {
return std::_Hash_impl::hash(__s.data(),
6868 __s.length() *
sizeof(char8_t)); }
6879 :
public __hash_base<size_t, u16string>
6882 operator()(
const u16string& __s)
const noexcept
6883 {
return std::_Hash_impl::hash(__s.
data(),
6884 __s.
length() *
sizeof(char16_t)); }
6894 :
public __hash_base<size_t, u32string>
6897 operator()(
const u32string& __s)
const noexcept
6898 {
return std::_Hash_impl::hash(__s.
data(),
6899 __s.
length() *
sizeof(char32_t)); }
6906 #if __cplusplus >= 201402L
6908 #define __cpp_lib_string_udls 201304
6910 inline namespace literals
6912 inline namespace string_literals
6914 #pragma GCC diagnostic push
6915 #pragma GCC diagnostic ignored "-Wliteral-suffix"
6916 _GLIBCXX_DEFAULT_ABI_TAG
6917 inline basic_string<char>
6918 operator""s(
const char* __str,
size_t __len)
6919 {
return basic_string<char>{__str, __len}; }
6921 #ifdef _GLIBCXX_USE_WCHAR_T
6922 _GLIBCXX_DEFAULT_ABI_TAG
6923 inline basic_string<wchar_t>
6924 operator""s(
const wchar_t* __str,
size_t __len)
6925 {
return basic_string<wchar_t>{__str, __len}; }
6928 #ifdef _GLIBCXX_USE_CHAR8_T
6929 _GLIBCXX_DEFAULT_ABI_TAG
6930 inline basic_string<char8_t>
6931 operator""s(
const char8_t* __str,
size_t __len)
6932 {
return basic_string<char8_t>{__str, __len}; }
6935 _GLIBCXX_DEFAULT_ABI_TAG
6936 inline basic_string<char16_t>
6937 operator""s(
const char16_t* __str,
size_t __len)
6938 {
return basic_string<char16_t>{__str, __len}; }
6940 _GLIBCXX_DEFAULT_ABI_TAG
6941 inline basic_string<char32_t>
6942 operator""s(
const char32_t* __str,
size_t __len)
6943 {
return basic_string<char32_t>{__str, __len}; }
6945 #pragma GCC diagnostic pop
6949 #if __cplusplus >= 201703L
6950 namespace __detail::__variant
6952 template<
typename>
struct _Never_valueless_alt;
6956 template<
typename _Tp,
typename _Traits,
typename _Alloc>
6957 struct _Never_valueless_alt<
std::basic_string<_Tp, _Traits, _Alloc>>
6959 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
6960 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
6967 _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.