34#ifndef _BASIC_STRING_H
35#define _BASIC_STRING_H 1
37#pragma GCC system_header
43#if __cplusplus >= 201103L
47#if __cplusplus >= 201703L
51namespace std _GLIBCXX_VISIBILITY(default)
53_GLIBCXX_BEGIN_NAMESPACE_VERSION
55#if __cplusplus >= 201703L
57# define __cpp_lib_constexpr_string 201611L
60#if _GLIBCXX_USE_CXX11_ABI
61_GLIBCXX_BEGIN_NAMESPACE_CXX11
80 template<
typename _CharT,
typename _Traits,
typename _Alloc>
84 rebind<_CharT>::other _Char_alloc_type;
89 typedef _Traits traits_type;
90 typedef typename _Traits::char_type value_type;
91 typedef _Char_alloc_type allocator_type;
92 typedef typename _Alloc_traits::size_type size_type;
93 typedef typename _Alloc_traits::difference_type difference_type;
94 typedef typename _Alloc_traits::reference reference;
95 typedef typename _Alloc_traits::const_reference const_reference;
96 typedef typename _Alloc_traits::pointer pointer;
97 typedef typename _Alloc_traits::const_pointer const_pointer;
98 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
99 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
105 static const size_type
npos =
static_cast<size_type
>(-1);
109#if __cplusplus < 201103L
110 typedef iterator __const_iterator;
112 typedef const_iterator __const_iterator;
116#if __cplusplus >= 201703L
118 typedef basic_string_view<_CharT, _Traits> __sv_type;
120 template<
typename _Tp,
typename _Res>
122 __and_<is_convertible<const _Tp&, __sv_type>,
123 __not_<is_convertible<const _Tp*, const basic_string*>>,
124 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
129 _S_to_string_view(__sv_type __svt)
noexcept
138 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
154 struct _Alloc_hider : allocator_type
156#if __cplusplus < 201103L
157 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
158 : allocator_type(__a), _M_p(__dat) { }
160 _Alloc_hider(pointer __dat,
const _Alloc& __a)
161 : allocator_type(__a), _M_p(__dat) { }
163 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
164 : allocator_type(
std::move(__a)), _M_p(__dat) { }
170 _Alloc_hider _M_dataplus;
171 size_type _M_string_length;
173 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
177 _CharT _M_local_buf[_S_local_capacity + 1];
178 size_type _M_allocated_capacity;
183 { _M_dataplus._M_p = __p; }
186 _M_length(size_type __length)
187 { _M_string_length = __length; }
191 {
return _M_dataplus._M_p; }
196#if __cplusplus >= 201103L
199 return pointer(_M_local_buf);
204 _M_local_data()
const
206#if __cplusplus >= 201103L
209 return const_pointer(_M_local_buf);
214 _M_capacity(size_type __capacity)
215 { _M_allocated_capacity = __capacity; }
218 _M_set_length(size_type __n)
221 traits_type::assign(_M_data()[__n], _CharT());
226 {
return _M_data() == _M_local_data(); }
230 _M_create(size_type&, size_type);
236 _M_destroy(_M_allocated_capacity);
240 _M_destroy(size_type __size)
throw()
241 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
245 template<
typename _InIterator>
247 _M_construct_aux(_InIterator __beg, _InIterator __end,
250 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
251 _M_construct(__beg, __end, _Tag());
256 template<
typename _Integer>
258 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
259 { _M_construct_aux_2(
static_cast<size_type
>(__beg), __end); }
262 _M_construct_aux_2(size_type __req, _CharT __c)
263 { _M_construct(__req, __c); }
265 template<
typename _InIterator>
267 _M_construct(_InIterator __beg, _InIterator __end)
269 typedef typename std::__is_integer<_InIterator>::__type _Integral;
270 _M_construct_aux(__beg, __end, _Integral());
274 template<
typename _InIterator>
276 _M_construct(_InIterator __beg, _InIterator __end,
281 template<
typename _FwdIterator>
283 _M_construct(_FwdIterator __beg, _FwdIterator __end,
287 _M_construct(size_type __req, _CharT __c);
291 {
return _M_dataplus; }
293 const allocator_type&
294 _M_get_allocator()
const
295 {
return _M_dataplus; }
299#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
302 template<
typename _Tp,
bool _Requires =
303 !__are_same<_Tp, _CharT*>::__value
304 && !__are_same<_Tp, const _CharT*>::__value
305 && !__are_same<_Tp, iterator>::__value
306 && !__are_same<_Tp, const_iterator>::__value>
307 struct __enable_if_not_native_iterator
309 template<
typename _Tp>
310 struct __enable_if_not_native_iterator<_Tp, false> { };
314 _M_check(size_type __pos,
const char* __s)
const
316 if (__pos > this->
size())
317 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
318 "this->size() (which is %zu)"),
319 __s, __pos, this->
size());
324 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
327 __throw_length_error(__N(__s));
333 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
335 const bool __testoff = __off < this->
size() - __pos;
336 return __testoff ? __off : this->
size() - __pos;
341 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
343 return (less<const _CharT*>()(__s, _M_data())
344 || less<const _CharT*>()(_M_data() + this->
size(), __s));
350 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
353 traits_type::assign(*__d, *__s);
355 traits_type::copy(__d, __s, __n);
359 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
362 traits_type::assign(*__d, *__s);
364 traits_type::move(__d, __s, __n);
368 _S_assign(_CharT* __d, size_type __n, _CharT __c)
371 traits_type::assign(*__d, __c);
373 traits_type::assign(__d, __n, __c);
378 template<
class _Iterator>
380 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
382 for (; __k1 != __k2; ++__k1, (void)++__p)
383 traits_type::assign(*__p, *__k1);
387 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
388 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
391 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
393 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
396 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
397 { _S_copy(__p, __k1, __k2 - __k1); }
400 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
402 { _S_copy(__p, __k1, __k2 - __k1); }
405 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
407 const difference_type __d = difference_type(__n1 - __n2);
409 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
410 return __gnu_cxx::__numeric_traits<int>::__max;
411 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
412 return __gnu_cxx::__numeric_traits<int>::__min;
421 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
425 _M_erase(size_type __pos, size_type __n);
436 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
437 : _M_dataplus(_M_local_data())
438 { _M_set_length(0); }
445 : _M_dataplus(_M_local_data(), __a)
446 { _M_set_length(0); }
453 : _M_dataplus(_M_local_data(),
454 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
455 { _M_construct(__str._M_data(), __str._M_data() + __str.length()); }
466 const _Alloc& __a = _Alloc())
467 : _M_dataplus(_M_local_data(), __a)
469 const _CharT* __start = __str._M_data()
470 + __str._M_check(__pos,
"basic_string::basic_string");
471 _M_construct(__start, __start + __str._M_limit(__pos,
npos));
482 : _M_dataplus(_M_local_data())
484 const _CharT* __start = __str._M_data()
485 + __str._M_check(__pos,
"basic_string::basic_string");
486 _M_construct(__start, __start + __str._M_limit(__pos, __n));
497 size_type __n,
const _Alloc& __a)
498 : _M_dataplus(_M_local_data(), __a)
500 const _CharT* __start
501 = __str._M_data() + __str._M_check(__pos,
"string::string");
502 _M_construct(__start, __start + __str._M_limit(__pos, __n));
515 const _Alloc& __a = _Alloc())
516 : _M_dataplus(_M_local_data(), __a)
517 { _M_construct(__s, __s + __n); }
524#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
527 template<
typename = _RequireAllocator<_Alloc>>
529 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
530 : _M_dataplus(_M_local_data(), __a)
532 const _CharT* __end = __s ? __s + traits_type::length(__s)
534 : reinterpret_cast<const _CharT*>(__alignof__(_CharT));
535 _M_construct(__s, __end, random_access_iterator_tag());
544#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
547 template<
typename = _RequireAllocator<_Alloc>>
549 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
550 : _M_dataplus(_M_local_data(), __a)
551 { _M_construct(__n, __c); }
553#if __cplusplus >= 201103L
562 : _M_dataplus(_M_local_data(), std::move(__str._M_get_allocator()))
564 if (__str._M_is_local())
566 traits_type::copy(_M_local_buf, __str._M_local_buf,
567 _S_local_capacity + 1);
571 _M_data(__str._M_data());
572 _M_capacity(__str._M_allocated_capacity);
578 _M_length(__str.length());
579 __str._M_data(__str._M_local_data());
580 __str._M_set_length(0);
588 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
589 : _M_dataplus(_M_local_data(), __a)
590 { _M_construct(__l.begin(), __l.end()); }
593 : _M_dataplus(_M_local_data(), __a)
594 { _M_construct(__str.begin(), __str.end()); }
597 noexcept(_Alloc_traits::_S_always_equal())
598 : _M_dataplus(_M_local_data(), __a)
600 if (__str._M_is_local())
602 traits_type::copy(_M_local_buf, __str._M_local_buf,
603 _S_local_capacity + 1);
604 _M_length(__str.length());
605 __str._M_set_length(0);
607 else if (_Alloc_traits::_S_always_equal()
608 || __str.get_allocator() == __a)
610 _M_data(__str._M_data());
611 _M_length(__str.length());
612 _M_capacity(__str._M_allocated_capacity);
613 __str._M_data(__str._M_local_buf);
614 __str._M_set_length(0);
617 _M_construct(__str.begin(), __str.end());
628#if __cplusplus >= 201103L
629 template<
typename _InputIterator,
630 typename = std::_RequireInputIter<_InputIterator>>
632 template<
typename _InputIterator>
634 basic_string(_InputIterator __beg, _InputIterator __end,
635 const _Alloc& __a = _Alloc())
636 : _M_dataplus(_M_local_data(), __a)
637 { _M_construct(__beg, __end); }
639#if __cplusplus >= 201703L
647 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
648 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
649 const _Alloc& __a = _Alloc())
657 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
659 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
660 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
676#if __cplusplus >= 201103L
677 if (_Alloc_traits::_S_propagate_on_copy_assign())
679 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
680 && _M_get_allocator() != __str._M_get_allocator())
684 if (__str.size() <= _S_local_capacity)
686 _M_destroy(_M_allocated_capacity);
687 _M_data(_M_local_data());
692 const auto __len = __str.size();
693 auto __alloc = __str._M_get_allocator();
695 auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1);
696 _M_destroy(_M_allocated_capacity);
699 _M_set_length(__len);
702 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
705 return this->
assign(__str);
714 {
return this->
assign(__s); }
730#if __cplusplus >= 201103L
742 noexcept(_Alloc_traits::_S_nothrow_move())
744 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
745 && !_Alloc_traits::_S_always_equal()
746 && _M_get_allocator() != __str._M_get_allocator())
749 _M_destroy(_M_allocated_capacity);
750 _M_data(_M_local_data());
754 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
756 if (__str._M_is_local())
760 this->_S_copy(_M_data(), __str._M_data(), __str.size());
761 _M_set_length(__str.size());
763 else if (_Alloc_traits::_S_propagate_on_move_assign()
764 || _Alloc_traits::_S_always_equal()
765 || _M_get_allocator() == __str._M_get_allocator())
768 pointer __data =
nullptr;
769 size_type __capacity;
772 if (_Alloc_traits::_S_always_equal())
776 __capacity = _M_allocated_capacity;
779 _M_destroy(_M_allocated_capacity);
782 _M_data(__str._M_data());
783 _M_length(__str.length());
784 _M_capacity(__str._M_allocated_capacity);
787 __str._M_data(__data);
788 __str._M_capacity(__capacity);
791 __str._M_data(__str._M_local_buf);
806 this->
assign(__l.begin(), __l.size());
811#if __cplusplus >= 201703L
816 template<
typename _Tp>
817 _If_sv<_Tp, basic_string&>
819 {
return this->
assign(__svt); }
825 operator __sv_type() const noexcept
826 {
return __sv_type(
data(),
size()); }
835 begin() _GLIBCXX_NOEXCEPT
836 {
return iterator(_M_data()); }
843 begin() const _GLIBCXX_NOEXCEPT
844 {
return const_iterator(_M_data()); }
851 end() _GLIBCXX_NOEXCEPT
852 {
return iterator(_M_data() + this->
size()); }
859 end() const _GLIBCXX_NOEXCEPT
860 {
return const_iterator(_M_data() + this->
size()); }
868 rbegin() _GLIBCXX_NOEXCEPT
869 {
return reverse_iterator(this->
end()); }
876 const_reverse_iterator
877 rbegin() const _GLIBCXX_NOEXCEPT
878 {
return const_reverse_iterator(this->
end()); }
886 rend() _GLIBCXX_NOEXCEPT
887 {
return reverse_iterator(this->
begin()); }
894 const_reverse_iterator
895 rend() const _GLIBCXX_NOEXCEPT
896 {
return const_reverse_iterator(this->
begin()); }
898#if __cplusplus >= 201103L
905 {
return const_iterator(this->_M_data()); }
912 cend() const noexcept
913 {
return const_iterator(this->_M_data() + this->
size()); }
920 const_reverse_iterator
922 {
return const_reverse_iterator(this->
end()); }
929 const_reverse_iterator
930 crend() const noexcept
931 {
return const_reverse_iterator(this->
begin()); }
939 size() const _GLIBCXX_NOEXCEPT
940 {
return _M_string_length; }
945 length() const _GLIBCXX_NOEXCEPT
946 {
return _M_string_length; }
951 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
964 resize(size_type __n, _CharT __c);
978 { this->
resize(__n, _CharT()); }
980#if __cplusplus >= 201103L
1004 return _M_is_local() ? size_type(_S_local_capacity)
1005 : _M_allocated_capacity;
1026 reserve(size_type __res_arg = 0);
1032 clear() _GLIBCXX_NOEXCEPT
1033 { _M_set_length(0); }
1039 _GLIBCXX_NODISCARD
bool
1040 empty() const _GLIBCXX_NOEXCEPT
1041 {
return this->
size() == 0; }
1055 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
1057 __glibcxx_assert(__pos <=
size());
1058 return _M_data()[__pos];
1076 __glibcxx_assert(__pos <=
size());
1078 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1079 return _M_data()[__pos];
1093 at(size_type __n)
const
1095 if (__n >= this->
size())
1096 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1097 "(which is %zu) >= this->size() "
1100 return _M_data()[__n];
1117 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1118 "(which is %zu) >= this->size() "
1121 return _M_data()[__n];
1124#if __cplusplus >= 201103L
1132 __glibcxx_assert(!
empty());
1141 front() const noexcept
1143 __glibcxx_assert(!
empty());
1154 __glibcxx_assert(!
empty());
1163 back() const noexcept
1165 __glibcxx_assert(!
empty());
1178 {
return this->
append(__str); }
1187 {
return this->
append(__s); }
1201#if __cplusplus >= 201103L
1209 {
return this->
append(__l.begin(), __l.size()); }
1212#if __cplusplus >= 201703L
1218 template<
typename _Tp>
1219 _If_sv<_Tp, basic_string&>
1221 {
return this->
append(__svt); }
1231 {
return _M_append(__str._M_data(), __str.size()); }
1248 {
return _M_append(__str._M_data()
1249 + __str._M_check(__pos,
"basic_string::append"),
1250 __str._M_limit(__pos, __n)); }
1259 append(
const _CharT* __s, size_type __n)
1261 __glibcxx_requires_string_len(__s, __n);
1262 _M_check_length(size_type(0), __n,
"basic_string::append");
1263 return _M_append(__s, __n);
1272 append(
const _CharT* __s)
1274 __glibcxx_requires_string(__s);
1275 const size_type __n = traits_type::length(__s);
1276 _M_check_length(size_type(0), __n,
"basic_string::append");
1277 return _M_append(__s, __n);
1289 append(size_type __n, _CharT __c)
1290 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1292#if __cplusplus >= 201103L
1299 append(initializer_list<_CharT> __l)
1300 {
return this->
append(__l.begin(), __l.size()); }
1311#if __cplusplus >= 201103L
1312 template<
class _InputIterator,
1313 typename = std::_RequireInputIter<_InputIterator>>
1315 template<
class _InputIterator>
1318 append(_InputIterator __first, _InputIterator __last)
1321#if __cplusplus >= 201703L
1327 template<
typename _Tp>
1328 _If_sv<_Tp, basic_string&>
1331 __sv_type __sv = __svt;
1332 return this->
append(__sv.data(), __sv.size());
1342 template<
typename _Tp>
1343 _If_sv<_Tp, basic_string&>
1344 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1346 __sv_type __sv = __svt;
1347 return _M_append(__sv.data()
1348 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1349 std::__sv_limit(__sv.size(), __pos, __n));
1360 const size_type __size = this->
size();
1362 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1363 traits_type::assign(this->_M_data()[__size], __c);
1364 this->_M_set_length(__size + 1);
1375 this->_M_assign(__str);
1379#if __cplusplus >= 201103L
1390 noexcept(_Alloc_traits::_S_nothrow_move())
1394 return *
this = std::move(__str);
1413 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1414 + __str._M_check(__pos,
"basic_string::assign"),
1415 __str._M_limit(__pos, __n)); }
1428 assign(
const _CharT* __s, size_type __n)
1430 __glibcxx_requires_string_len(__s, __n);
1431 return _M_replace(size_type(0), this->
size(), __s, __n);
1444 assign(
const _CharT* __s)
1446 __glibcxx_requires_string(__s);
1447 return _M_replace(size_type(0), this->
size(), __s,
1448 traits_type::length(__s));
1461 assign(size_type __n, _CharT __c)
1462 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1472#if __cplusplus >= 201103L
1473 template<
class _InputIterator,
1474 typename = std::_RequireInputIter<_InputIterator>>
1476 template<
class _InputIterator>
1479 assign(_InputIterator __first, _InputIterator __last)
1482#if __cplusplus >= 201103L
1489 assign(initializer_list<_CharT> __l)
1490 {
return this->
assign(__l.begin(), __l.size()); }
1493#if __cplusplus >= 201703L
1499 template<
typename _Tp>
1500 _If_sv<_Tp, basic_string&>
1503 __sv_type __sv = __svt;
1504 return this->
assign(__sv.data(), __sv.size());
1514 template<
typename _Tp>
1515 _If_sv<_Tp, basic_string&>
1516 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1518 __sv_type __sv = __svt;
1519 return _M_replace(size_type(0), this->
size(),
1521 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
1522 std::__sv_limit(__sv.size(), __pos, __n));
1526#if __cplusplus >= 201103L
1543 insert(const_iterator __p, size_type __n, _CharT __c)
1545 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1546 const size_type __pos = __p -
begin();
1547 this->
replace(__p, __p, __n, __c);
1548 return iterator(this->_M_data() + __pos);
1565 insert(iterator __p, size_type __n, _CharT __c)
1566 { this->
replace(__p, __p, __n, __c); }
1569#if __cplusplus >= 201103L
1584 template<
class _InputIterator,
1585 typename = std::_RequireInputIter<_InputIterator>>
1587 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1589 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1590 const size_type __pos = __p -
begin();
1591 this->
replace(__p, __p, __beg, __end);
1592 return iterator(this->_M_data() + __pos);
1607 template<
class _InputIterator>
1609 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1610 { this->
replace(__p, __p, __beg, __end); }
1613#if __cplusplus >= 201103L
1621 insert(const_iterator __p, initializer_list<_CharT> __l)
1622 {
return this->
insert(__p, __l.begin(), __l.end()); }
1624#ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
1627 insert(iterator __p, initializer_list<_CharT> __l)
1629 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1630 this->
insert(__p -
begin(), __l.begin(), __l.size());
1649 {
return this->
replace(__pos1, size_type(0),
1650 __str._M_data(), __str.size()); }
1672 size_type __pos2, size_type __n =
npos)
1673 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1674 + __str._M_check(__pos2,
"basic_string::insert"),
1675 __str._M_limit(__pos2, __n)); }
1694 insert(size_type __pos,
const _CharT* __s, size_type __n)
1695 {
return this->
replace(__pos, size_type(0), __s, __n); }
1713 insert(size_type __pos,
const _CharT* __s)
1715 __glibcxx_requires_string(__s);
1716 return this->
replace(__pos, size_type(0), __s,
1717 traits_type::length(__s));
1737 insert(size_type __pos, size_type __n, _CharT __c)
1738 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1739 size_type(0), __n, __c); }
1755 insert(__const_iterator __p, _CharT __c)
1757 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1758 const size_type __pos = __p -
begin();
1759 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1760 return iterator(_M_data() + __pos);
1763#if __cplusplus >= 201703L
1770 template<
typename _Tp>
1771 _If_sv<_Tp, basic_string&>
1772 insert(size_type __pos,
const _Tp& __svt)
1774 __sv_type __sv = __svt;
1775 return this->
insert(__pos, __sv.data(), __sv.size());
1787 template<
typename _Tp>
1788 _If_sv<_Tp, basic_string&>
1789 insert(size_type __pos1,
const _Tp& __svt,
1790 size_type __pos2, size_type __n =
npos)
1792 __sv_type __sv = __svt;
1793 return this->
replace(__pos1, size_type(0),
1795 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
1796 std::__sv_limit(__sv.size(), __pos2, __n));
1816 erase(size_type __pos = 0, size_type __n =
npos)
1818 _M_check(__pos,
"basic_string::erase");
1820 this->_M_set_length(__pos);
1822 this->_M_erase(__pos, _M_limit(__pos, __n));
1835 erase(__const_iterator __position)
1837 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1838 && __position <
end());
1839 const size_type __pos = __position -
begin();
1840 this->_M_erase(__pos, size_type(1));
1841 return iterator(_M_data() + __pos);
1854 erase(__const_iterator __first, __const_iterator __last)
1856 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1857 && __last <=
end());
1858 const size_type __pos = __first -
begin();
1859 if (__last ==
end())
1860 this->_M_set_length(__pos);
1862 this->_M_erase(__pos, __last - __first);
1863 return iterator(this->_M_data() + __pos);
1866#if __cplusplus >= 201103L
1875 __glibcxx_assert(!
empty());
1876 _M_erase(
size() - 1, 1);
1899 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1921 size_type __pos2, size_type __n2 =
npos)
1922 {
return this->
replace(__pos1, __n1, __str._M_data()
1923 + __str._M_check(__pos2,
"basic_string::replace"),
1924 __str._M_limit(__pos2, __n2)); }
1945 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1948 __glibcxx_requires_string_len(__s, __n2);
1949 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1950 _M_limit(__pos, __n1), __s, __n2);
1970 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1972 __glibcxx_requires_string(__s);
1973 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1994 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1995 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1996 _M_limit(__pos, __n1), __n2, __c); }
2012 replace(__const_iterator __i1, __const_iterator __i2,
2014 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
2032 replace(__const_iterator __i1, __const_iterator __i2,
2033 const _CharT* __s, size_type __n)
2035 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2037 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2054 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2056 __glibcxx_requires_string(__s);
2057 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2075 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2078 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2080 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2098#if __cplusplus >= 201103L
2099 template<
class _InputIterator,
2100 typename = std::_RequireInputIter<_InputIterator>>
2102 replace(const_iterator __i1, const_iterator __i2,
2103 _InputIterator __k1, _InputIterator __k2)
2105 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2107 __glibcxx_requires_valid_range(__k1, __k2);
2108 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2109 std::__false_type());
2112 template<
class _InputIterator>
2113#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2114 typename __enable_if_not_native_iterator<_InputIterator>::__type
2118 replace(iterator __i1, iterator __i2,
2119 _InputIterator __k1, _InputIterator __k2)
2121 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2123 __glibcxx_requires_valid_range(__k1, __k2);
2124 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2125 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2132 replace(__const_iterator __i1, __const_iterator __i2,
2133 _CharT* __k1, _CharT* __k2)
2135 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2137 __glibcxx_requires_valid_range(__k1, __k2);
2143 replace(__const_iterator __i1, __const_iterator __i2,
2144 const _CharT* __k1,
const _CharT* __k2)
2146 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2148 __glibcxx_requires_valid_range(__k1, __k2);
2154 replace(__const_iterator __i1, __const_iterator __i2,
2155 iterator __k1, iterator __k2)
2157 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2159 __glibcxx_requires_valid_range(__k1, __k2);
2161 __k1.base(), __k2 - __k1);
2165 replace(__const_iterator __i1, __const_iterator __i2,
2166 const_iterator __k1, const_iterator __k2)
2168 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2170 __glibcxx_requires_valid_range(__k1, __k2);
2172 __k1.base(), __k2 - __k1);
2175#if __cplusplus >= 201103L
2191 initializer_list<_CharT> __l)
2192 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2195#if __cplusplus >= 201703L
2203 template<
typename _Tp>
2204 _If_sv<_Tp, basic_string&>
2205 replace(size_type __pos, size_type __n,
const _Tp& __svt)
2207 __sv_type __sv = __svt;
2208 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2220 template<
typename _Tp>
2221 _If_sv<_Tp, basic_string&>
2222 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2223 size_type __pos2, size_type __n2 =
npos)
2225 __sv_type __sv = __svt;
2226 return this->
replace(__pos1, __n1,
2228 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2229 std::__sv_limit(__sv.size(), __pos2, __n2));
2241 template<
typename _Tp>
2242 _If_sv<_Tp, basic_string&>
2243 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2245 __sv_type __sv = __svt;
2246 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2251 template<
class _Integer>
2253 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2254 _Integer __n, _Integer __val, __true_type)
2255 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2257 template<
class _InputIterator>
2259 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2260 _InputIterator __k1, _InputIterator __k2,
2264 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2268 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2269 const size_type __len2);
2272 _M_append(
const _CharT* __s, size_type __n);
2289 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2309 c_str() const _GLIBCXX_NOEXCEPT
2310 {
return _M_data(); }
2321 data() const _GLIBCXX_NOEXCEPT
2322 {
return _M_data(); }
2324#if __cplusplus >= 201703L
2333 {
return _M_data(); }
2341 {
return _M_get_allocator(); }
2356 find(
const _CharT* __s, size_type __pos, size_type __n)
const
2372 {
return this->
find(__str.data(), __pos, __str.size()); }
2374#if __cplusplus >= 201703L
2381 template<
typename _Tp>
2382 _If_sv<_Tp, size_type>
2383 find(
const _Tp& __svt, size_type __pos = 0) const
2384 noexcept(is_same<_Tp, __sv_type>::value)
2386 __sv_type __sv = __svt;
2387 return this->
find(__sv.data(), __pos, __sv.size());
2402 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2404 __glibcxx_requires_string(__s);
2405 return this->
find(__s, __pos, traits_type::length(__s));
2419 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2434 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2436#if __cplusplus >= 201703L
2443 template<
typename _Tp>
2444 _If_sv<_Tp, size_type>
2445 rfind(
const _Tp& __svt, size_type __pos =
npos)
const
2446 noexcept(is_same<_Tp, __sv_type>::value)
2448 __sv_type __sv = __svt;
2449 return this->
rfind(__sv.data(), __pos, __sv.size());
2466 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
2480 rfind(
const _CharT* __s, size_type __pos =
npos)
const
2482 __glibcxx_requires_string(__s);
2483 return this->
rfind(__s, __pos, traits_type::length(__s));
2497 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
2513 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2515#if __cplusplus >= 201703L
2523 template<
typename _Tp>
2524 _If_sv<_Tp, size_type>
2526 noexcept(is_same<_Tp, __sv_type>::value)
2528 __sv_type __sv = __svt;
2529 return this->
find_first_of(__sv.data(), __pos, __sv.size());
2546 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2563 __glibcxx_requires_string(__s);
2564 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2580 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2581 {
return this->
find(__c, __pos); }
2597 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2599#if __cplusplus >= 201703L
2607 template<
typename _Tp>
2608 _If_sv<_Tp, size_type>
2610 noexcept(is_same<_Tp, __sv_type>::value)
2612 __sv_type __sv = __svt;
2613 return this->
find_last_of(__sv.data(), __pos, __sv.size());
2630 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2647 __glibcxx_requires_string(__s);
2648 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2665 {
return this->
rfind(__c, __pos); }
2682#if __cplusplus >= 201703L
2690 template<
typename _Tp>
2691 _If_sv<_Tp, size_type>
2693 noexcept(is_same<_Tp, __sv_type>::value)
2695 __sv_type __sv = __svt;
2714 size_type __n)
const _GLIBCXX_NOEXCEPT;
2730 __glibcxx_requires_string(__s);
2764#if __cplusplus >= 201703L
2772 template<
typename _Tp>
2773 _If_sv<_Tp, size_type>
2775 noexcept(is_same<_Tp, __sv_type>::value)
2777 __sv_type __sv = __svt;
2796 size_type __n)
const _GLIBCXX_NOEXCEPT;
2812 __glibcxx_requires_string(__s);
2843 substr(size_type __pos = 0, size_type __n =
npos)
const
2845 _M_check(__pos,
"basic_string::substr"), __n); }
2864 const size_type __size = this->
size();
2865 const size_type __osize = __str.size();
2866 const size_type __len =
std::min(__size, __osize);
2868 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2870 __r = _S_compare(__size, __osize);
2874#if __cplusplus >= 201703L
2880 template<
typename _Tp>
2882 compare(
const _Tp& __svt)
const
2883 noexcept(is_same<_Tp, __sv_type>::value)
2885 __sv_type __sv = __svt;
2886 const size_type __size = this->
size();
2887 const size_type __osize = __sv.size();
2888 const size_type __len =
std::min(__size, __osize);
2890 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
2892 __r = _S_compare(__size, __osize);
2904 template<
typename _Tp>
2906 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
2907 noexcept(is_same<_Tp, __sv_type>::value)
2909 __sv_type __sv = __svt;
2910 return __sv_type(*this).substr(__pos, __n).compare(__sv);
2923 template<
typename _Tp>
2925 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
2926 size_type __pos2, size_type __n2 =
npos)
const
2927 noexcept(is_same<_Tp, __sv_type>::value)
2929 __sv_type __sv = __svt;
2930 return __sv_type(*
this)
2931 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
2982 size_type __pos2, size_type __n2 =
npos)
const;
2999 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
3023 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
3050 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3051 size_type __n2)
const;
3053#if __cplusplus > 201703L
3055 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3056 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3059 starts_with(_CharT __x)
const noexcept
3060 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3063 starts_with(
const _CharT* __x)
const noexcept
3064 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3067 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3068 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3071 ends_with(_CharT __x)
const noexcept
3072 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3075 ends_with(
const _CharT* __x)
const noexcept
3076 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3080 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3082_GLIBCXX_END_NAMESPACE_CXX11
3148 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3151 typedef typename _Alloc::template rebind<_CharT>::other _CharT_alloc_type;
3155 typedef _Traits traits_type;
3156 typedef typename _Traits::char_type value_type;
3157 typedef _Alloc allocator_type;
3158 typedef typename _CharT_alloc_type::size_type size_type;
3159 typedef typename _CharT_alloc_type::difference_type difference_type;
3160#if __cplusplus < 201103L
3161 typedef typename _CharT_alloc_type::reference reference;
3162 typedef typename _CharT_alloc_type::const_reference const_reference;
3164 typedef value_type& reference;
3165 typedef const value_type& const_reference;
3167 typedef typename _CharT_alloc_type::pointer pointer;
3168 typedef typename _CharT_alloc_type::const_pointer const_pointer;
3169 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
3170 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
3177 typedef iterator __const_iterator;
3196 size_type _M_length;
3197 size_type _M_capacity;
3198 _Atomic_word _M_refcount;
3201 struct _Rep : _Rep_base
3204 typedef typename _Alloc::template 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);
3445 traits_type::move(__d, __s, __n);
3449 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
3452 traits_type::assign(*__d, __c);
3454 traits_type::assign(__d, __n, __c);
3459 template<
class _Iterator>
3461 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
3463 for (; __k1 != __k2; ++__k1, (void)++__p)
3464 traits_type::assign(*__p, *__k1);
3468 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
3469 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3472 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
3474 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3477 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
3478 { _M_copy(__p, __k1, __k2 - __k1); }
3481 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
3483 { _M_copy(__p, __k1, __k2 - __k1); }
3486 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
3488 const difference_type __d = difference_type(__n1 - __n2);
3490 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
3491 return __gnu_cxx::__numeric_traits<int>::__max;
3492 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
3493 return __gnu_cxx::__numeric_traits<int>::__min;
3499 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
3505 _S_empty_rep() _GLIBCXX_NOEXCEPT
3506 {
return _Rep::_S_empty_rep(); }
3508#if __cplusplus >= 201703L
3510 typedef basic_string_view<_CharT, _Traits> __sv_type;
3512 template<
typename _Tp,
typename _Res>
3514 __and_<is_convertible<const _Tp&, __sv_type>,
3515 __not_<is_convertible<const _Tp*, const basic_string*>>,
3516 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
3521 _S_to_string_view(__sv_type __svt)
noexcept
3530 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
3554#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3556 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc())
3558 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc())
3584 const _Alloc& __a = _Alloc());
3602 size_type __n,
const _Alloc& __a);
3614 const _Alloc& __a = _Alloc());
3620 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc());
3627 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3629#if __cplusplus >= 201103L
3638#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3641 : _M_dataplus(std::move(__str._M_dataplus))
3643#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3644 __str._M_data(_S_empty_rep()._M_refdata());
3646 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3658 : _M_dataplus(__str._M_rep()->_M_grab(__a, __str.
get_allocator()), __a)
3662 : _M_dataplus(__str._M_data(), __a)
3664 if (__a == __str.get_allocator())
3666#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3667 __str._M_data(_S_empty_rep()._M_refdata());
3669 __str._M_data(_S_construct(size_type(), _CharT(), __a));
3673 _M_dataplus._M_p = _S_construct(__str.begin(), __str.end(), __a);
3683 template<
class _InputIterator>
3684 basic_string(_InputIterator __beg, _InputIterator __end,
3685 const _Alloc& __a = _Alloc());
3687#if __cplusplus >= 201703L
3695 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3696 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
3697 const _Alloc& __a = _Alloc())
3705 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3707 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
3708 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
3723 {
return this->
assign(__str); }
3731 {
return this->
assign(__s); }
3747#if __cplusplus >= 201103L
3771 this->
assign(__l.begin(), __l.size());
3776#if __cplusplus >= 201703L
3781 template<
typename _Tp>
3782 _If_sv<_Tp, basic_string&>
3784 {
return this->
assign(__svt); }
3790 operator __sv_type() const noexcept
3791 {
return __sv_type(
data(),
size()); }
3803 return iterator(_M_data());
3812 {
return const_iterator(_M_data()); }
3822 return iterator(_M_data() + this->
size());
3831 {
return const_iterator(_M_data() + this->
size()); }
3847 const_reverse_iterator
3865 const_reverse_iterator
3869#if __cplusplus >= 201103L
3876 {
return const_iterator(this->_M_data()); }
3884 {
return const_iterator(this->_M_data() + this->
size()); }
3891 const_reverse_iterator
3900 const_reverse_iterator
3911 {
return _M_rep()->_M_length; }
3917 {
return _M_rep()->_M_length; }
3922 {
return _Rep::_S_max_size; }
3935 resize(size_type __n, _CharT __c);
3949 { this->
resize(__n, _CharT()); }
3951#if __cplusplus >= 201103L
3974 {
return _M_rep()->_M_capacity; }
3994 reserve(size_type __res_arg = 0);
3999#if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
4003 if (_M_rep()->_M_is_shared())
4006 _M_data(_S_empty_rep()._M_refdata());
4009 _M_rep()->_M_set_length_and_sharable(0);
4015 { _M_mutate(0, this->
size(), 0); }
4022 _GLIBCXX_NODISCARD
bool
4024 {
return this->
size() == 0; }
4040 __glibcxx_assert(__pos <=
size());
4041 return _M_data()[__pos];
4059 __glibcxx_assert(__pos <=
size());
4061 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
4063 return _M_data()[__pos];
4079 if (__n >= this->
size())
4080 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
4081 "(which is %zu) >= this->size() "
4084 return _M_data()[__n];
4102 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
4103 "(which is %zu) >= this->size() "
4107 return _M_data()[__n];
4110#if __cplusplus >= 201103L
4118 __glibcxx_assert(!
empty());
4129 __glibcxx_assert(!
empty());
4140 __glibcxx_assert(!
empty());
4151 __glibcxx_assert(!
empty());
4164 {
return this->
append(__str); }
4173 {
return this->
append(__s); }
4187#if __cplusplus >= 201103L
4195 {
return this->
append(__l.begin(), __l.size()); }
4198#if __cplusplus >= 201703L
4204 template<
typename _Tp>
4205 _If_sv<_Tp, basic_string&>
4207 {
return this->
append(__svt); }
4241 append(
const _CharT* __s, size_type __n);
4251 __glibcxx_requires_string(__s);
4252 return this->
append(__s, traits_type::length(__s));
4264 append(size_type __n, _CharT __c);
4266#if __cplusplus >= 201103L
4274 {
return this->
append(__l.begin(), __l.size()); }
4285 template<
class _InputIterator>
4287 append(_InputIterator __first, _InputIterator __last)
4288 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
4290#if __cplusplus >= 201703L
4296 template<
typename _Tp>
4297 _If_sv<_Tp, basic_string&>
4300 __sv_type __sv = __svt;
4301 return this->
append(__sv.data(), __sv.size());
4312 template<
typename _Tp>
4313 _If_sv<_Tp, basic_string&>
4314 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
4316 __sv_type __sv = __svt;
4317 return append(__sv.data()
4318 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
4319 std::__sv_limit(__sv.size(), __pos, __n));
4330 const size_type __len = 1 + this->
size();
4331 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
4333 traits_type::assign(_M_data()[this->
size()], __c);
4334 _M_rep()->_M_set_length_and_sharable(__len);
4345#if __cplusplus >= 201103L
4378 {
return this->
assign(__str._M_data()
4379 + __str._M_check(__pos,
"basic_string::assign"),
4380 __str._M_limit(__pos, __n)); }
4393 assign(
const _CharT* __s, size_type __n);
4407 __glibcxx_requires_string(__s);
4408 return this->
assign(__s, traits_type::length(__s));
4422 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4432 template<
class _InputIterator>
4434 assign(_InputIterator __first, _InputIterator __last)
4435 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4437#if __cplusplus >= 201103L
4445 {
return this->
assign(__l.begin(), __l.size()); }
4448#if __cplusplus >= 201703L
4454 template<
typename _Tp>
4455 _If_sv<_Tp, basic_string&>
4458 __sv_type __sv = __svt;
4459 return this->
assign(__sv.data(), __sv.size());
4469 template<
typename _Tp>
4470 _If_sv<_Tp, basic_string&>
4471 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
4473 __sv_type __sv = __svt;
4474 return assign(__sv.data()
4475 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
4476 std::__sv_limit(__sv.size(), __pos, __n));
4494 insert(iterator __p, size_type __n, _CharT __c)
4495 { this->
replace(__p, __p, __n, __c); }
4509 template<
class _InputIterator>
4511 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4512 { this->
replace(__p, __p, __beg, __end); }
4514#if __cplusplus >= 201103L
4524 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4525 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4543 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4565 size_type __pos2, size_type __n =
npos)
4566 {
return this->
insert(__pos1, __str._M_data()
4567 + __str._M_check(__pos2,
"basic_string::insert"),
4568 __str._M_limit(__pos2, __n)); }
4587 insert(size_type __pos,
const _CharT* __s, size_type __n);
4607 __glibcxx_requires_string(__s);
4608 return this->
insert(__pos, __s, traits_type::length(__s));
4628 insert(size_type __pos, size_type __n, _CharT __c)
4629 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4630 size_type(0), __n, __c); }
4648 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4649 const size_type __pos = __p - _M_ibegin();
4650 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4651 _M_rep()->_M_set_leaked();
4652 return iterator(_M_data() + __pos);
4655#if __cplusplus >= 201703L
4662 template<
typename _Tp>
4663 _If_sv<_Tp, basic_string&>
4664 insert(size_type __pos,
const _Tp& __svt)
4666 __sv_type __sv = __svt;
4667 return this->
insert(__pos, __sv.data(), __sv.size());
4678 template<
typename _Tp>
4679 _If_sv<_Tp, basic_string&>
4680 insert(size_type __pos1,
const _Tp& __svt,
4681 size_type __pos2, size_type __n =
npos)
4683 __sv_type __sv = __svt;
4684 return this->
replace(__pos1, size_type(0), __sv.data()
4685 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
4686 std::__sv_limit(__sv.size(), __pos2, __n));
4708 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4709 _M_limit(__pos, __n), size_type(0));
4724 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4725 && __position < _M_iend());
4726 const size_type __pos = __position - _M_ibegin();
4727 _M_mutate(__pos, size_type(1), size_type(0));
4728 _M_rep()->_M_set_leaked();
4729 return iterator(_M_data() + __pos);
4744#if __cplusplus >= 201103L
4753 __glibcxx_assert(!
empty());
4777 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4799 size_type __pos2, size_type __n2 =
npos)
4800 {
return this->
replace(__pos1, __n1, __str._M_data()
4801 + __str._M_check(__pos2,
"basic_string::replace"),
4802 __str._M_limit(__pos2, __n2)); }
4823 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4843 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4845 __glibcxx_requires_string(__s);
4846 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4867 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4868 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4869 _M_limit(__pos, __n1), __n2, __c); }
4886 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4904 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4906 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4907 && __i2 <= _M_iend());
4908 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4925 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4927 __glibcxx_requires_string(__s);
4928 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4946 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4948 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4949 && __i2 <= _M_iend());
4950 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4968 template<
class _InputIterator>
4971 _InputIterator __k1, _InputIterator __k2)
4973 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4974 && __i2 <= _M_iend());
4975 __glibcxx_requires_valid_range(__k1, __k2);
4976 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4977 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
4985 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4986 && __i2 <= _M_iend());
4987 __glibcxx_requires_valid_range(__k1, __k2);
4988 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
4993 replace(iterator __i1, iterator __i2,
4994 const _CharT* __k1,
const _CharT* __k2)
4996 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4997 && __i2 <= _M_iend());
4998 __glibcxx_requires_valid_range(__k1, __k2);
4999 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5004 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
5006 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5007 && __i2 <= _M_iend());
5008 __glibcxx_requires_valid_range(__k1, __k2);
5009 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5010 __k1.base(), __k2 - __k1);
5014 replace(iterator __i1, iterator __i2,
5015 const_iterator __k1, const_iterator __k2)
5017 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5018 && __i2 <= _M_iend());
5019 __glibcxx_requires_valid_range(__k1, __k2);
5020 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5021 __k1.base(), __k2 - __k1);
5024#if __cplusplus >= 201103L
5041 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
5044#if __cplusplus >= 201703L
5052 template<
typename _Tp>
5053 _If_sv<_Tp, basic_string&>
5054 replace(size_type __pos, size_type __n,
const _Tp& __svt)
5056 __sv_type __sv = __svt;
5057 return this->
replace(__pos, __n, __sv.data(), __sv.size());
5069 template<
typename _Tp>
5070 _If_sv<_Tp, basic_string&>
5071 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
5072 size_type __pos2, size_type __n2 =
npos)
5074 __sv_type __sv = __svt;
5075 return this->
replace(__pos1, __n1,
5077 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
5078 std::__sv_limit(__sv.size(), __pos2, __n2));
5090 template<
typename _Tp>
5091 _If_sv<_Tp, basic_string&>
5092 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
5094 __sv_type __sv = __svt;
5095 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
5100 template<
class _Integer>
5102 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
5103 _Integer __val, __true_type)
5104 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
5106 template<
class _InputIterator>
5108 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
5109 _InputIterator __k2, __false_type);
5112 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
5116 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
5121 template<
class _InIterator>
5123 _S_construct_aux(_InIterator __beg, _InIterator __end,
5124 const _Alloc& __a, __false_type)
5126 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
5127 return _S_construct(__beg, __end, __a, _Tag());
5132 template<
class _Integer>
5134 _S_construct_aux(_Integer __beg, _Integer __end,
5135 const _Alloc& __a, __true_type)
5136 {
return _S_construct_aux_2(
static_cast<size_type
>(__beg),
5140 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
5141 {
return _S_construct(__req, __c, __a); }
5143 template<
class _InIterator>
5145 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
5147 typedef typename std::__is_integer<_InIterator>::__type _Integral;
5148 return _S_construct_aux(__beg, __end, __a, _Integral());
5152 template<
class _InIterator>
5154 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
5155 input_iterator_tag);
5159 template<
class _FwdIterator>
5161 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
5162 forward_iterator_tag);
5165 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
5182 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
5193 _GLIBCXX_NOEXCEPT_IF(allocator_traits<_Alloc>::is_always_equal::value);
5204 {
return _M_data(); }
5216 {
return _M_data(); }
5218#if __cplusplus >= 201703L
5238 {
return _M_dataplus; }
5253 find(
const _CharT* __s, size_type __pos, size_type __n)
const
5269 {
return this->
find(__str.data(), __pos, __str.size()); }
5282 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
5284 __glibcxx_requires_string(__s);
5285 return this->
find(__s, __pos, traits_type::length(__s));
5299 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
5301#if __cplusplus >= 201703L
5308 template<
typename _Tp>
5309 _If_sv<_Tp, size_type>
5310 find(
const _Tp& __svt, size_type __pos = 0) const
5311 noexcept(
is_same<_Tp, __sv_type>::value)
5313 __sv_type __sv = __svt;
5314 return this->
find(__sv.data(), __pos, __sv.size());
5331 {
return this->
rfind(__str.data(), __pos, __str.size()); }
5346 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
5360 rfind(
const _CharT* __s, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT
5362 __glibcxx_requires_string(__s);
5363 return this->
rfind(__s, __pos, traits_type::length(__s));
5377 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
5379#if __cplusplus >= 201703L
5386 template<
typename _Tp>
5387 _If_sv<_Tp, size_type>
5388 rfind(
const _Tp& __svt, size_type __pos =
npos)
const
5391 __sv_type __sv = __svt;
5392 return this->
rfind(__sv.data(), __pos, __sv.size());
5410 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
5425 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
5442 __glibcxx_requires_string(__s);
5443 return this->
find_first_of(__s, __pos, traits_type::length(__s));
5460 {
return this->
find(__c, __pos); }
5462#if __cplusplus >= 201703L
5470 template<
typename _Tp>
5471 _If_sv<_Tp, size_type>
5473 noexcept(
is_same<_Tp, __sv_type>::value)
5475 __sv_type __sv = __svt;
5476 return this->
find_first_of(__sv.data(), __pos, __sv.size());
5494 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5509 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
5526 __glibcxx_requires_string(__s);
5527 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5544 {
return this->
rfind(__c, __pos); }
5546#if __cplusplus >= 201703L
5554 template<
typename _Tp>
5555 _If_sv<_Tp, size_type>
5559 __sv_type __sv = __svt;
5560 return this->
find_last_of(__sv.data(), __pos, __sv.size());
5593 size_type __n)
const _GLIBCXX_NOEXCEPT;
5609 __glibcxx_requires_string(__s);
5627#if __cplusplus >= 201703L
5635 template<
typename _Tp>
5636 _If_sv<_Tp, size_type>
5638 noexcept(
is_same<_Tp, __sv_type>::value)
5640 __sv_type __sv = __svt;
5675 size_type __n)
const _GLIBCXX_NOEXCEPT;
5691 __glibcxx_requires_string(__s);
5709#if __cplusplus >= 201703L
5717 template<
typename _Tp>
5718 _If_sv<_Tp, size_type>
5722 __sv_type __sv = __svt;
5742 _M_check(__pos,
"basic_string::substr"), __n); }
5761 const size_type __size = this->
size();
5762 const size_type __osize = __str.size();
5763 const size_type __len =
std::min(__size, __osize);
5765 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5767 __r = _S_compare(__size, __osize);
5771#if __cplusplus >= 201703L
5777 template<
typename _Tp>
5779 compare(
const _Tp& __svt)
const
5782 __sv_type __sv = __svt;
5783 const size_type __size = this->
size();
5784 const size_type __osize = __sv.size();
5785 const size_type __len =
std::min(__size, __osize);
5787 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
5789 __r = _S_compare(__size, __osize);
5801 template<
typename _Tp>
5803 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
5804 noexcept(is_same<_Tp, __sv_type>::value)
5806 __sv_type __sv = __svt;
5807 return __sv_type(*this).substr(__pos, __n).compare(__sv);
5820 template<
typename _Tp>
5822 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
5823 size_type __pos2, size_type __n2 =
npos)
const
5824 noexcept(is_same<_Tp, __sv_type>::value)
5826 __sv_type __sv = __svt;
5827 return __sv_type(*
this)
5828 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
5879 size_type __pos2, size_type __n2 =
npos)
const;
5896 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5920 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5947 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5948 size_type __n2)
const;
5950#if __cplusplus > 201703L
5952 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
5953 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5956 starts_with(_CharT __x)
const noexcept
5957 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5960 starts_with(
const _CharT* __x)
const noexcept
5961 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5964 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
5965 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5968 ends_with(_CharT __x)
const noexcept
5969 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5972 ends_with(
const _CharT* __x)
const noexcept
5973 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5976# ifdef _GLIBCXX_TM_TS_INTERNAL
5978 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
5981 ::_txnal_cow_string_c_str(
const void *that);
5983 ::_txnal_cow_string_D1(
void *that);
5985 ::_txnal_cow_string_D1_commit(
void *that);
5990#if __cpp_deduction_guides >= 201606
5991_GLIBCXX_BEGIN_NAMESPACE_CXX11
5992 template<
typename _InputIterator,
typename _CharT
5993 =
typename iterator_traits<_InputIterator>::value_type,
5994 typename _Allocator = allocator<_CharT>,
5995 typename = _RequireInputIter<_InputIterator>,
5996 typename = _RequireAllocator<_Allocator>>
5997 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
5998 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
6002 template<
typename _CharT,
typename _Traits,
6003 typename _Allocator = allocator<_CharT>,
6004 typename = _RequireAllocator<_Allocator>>
6005 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
6006 -> basic_string<_CharT, _Traits, _Allocator>;
6008 template<
typename _CharT,
typename _Traits,
6009 typename _Allocator = allocator<_CharT>,
6010 typename = _RequireAllocator<_Allocator>>
6011 basic_string(basic_string_view<_CharT, _Traits>,
6012 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6013 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6014 const _Allocator& = _Allocator())
6015 -> basic_string<_CharT, _Traits, _Allocator>;
6016_GLIBCXX_END_NAMESPACE_CXX11
6026 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6027 basic_string<_CharT, _Traits, _Alloc>
6032 __str.append(__rhs);
6042 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6043 basic_string<_CharT,_Traits,_Alloc>
6045 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6053 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6054 basic_string<_CharT,_Traits,_Alloc>
6055 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6063 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6064 inline basic_string<_CharT, _Traits, _Alloc>
6066 const _CharT* __rhs)
6069 __str.append(__rhs);
6079 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6080 inline basic_string<_CharT, _Traits, _Alloc>
6084 typedef typename __string_type::size_type __size_type;
6085 __string_type __str(__lhs);
6086 __str.append(__size_type(1), __rhs);
6090#if __cplusplus >= 201103L
6091 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6092 inline basic_string<_CharT, _Traits, _Alloc>
6093 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6094 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
6095 {
return std::move(__lhs.append(__rhs)); }
6097 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6098 inline basic_string<_CharT, _Traits, _Alloc>
6099 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6100 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6101 {
return std::move(__rhs.insert(0, __lhs)); }
6103 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6104 inline basic_string<_CharT, _Traits, _Alloc>
6105 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6106 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6108 const auto __size = __lhs.size() + __rhs.size();
6109 const bool __cond = (__size > __lhs.capacity()
6110 && __size <= __rhs.capacity());
6111 return __cond ? std::move(__rhs.insert(0, __lhs))
6112 :
std::move(__lhs.append(__rhs));
6115 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6116 inline basic_string<_CharT, _Traits, _Alloc>
6118 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6119 {
return std::move(__rhs.insert(0, __lhs)); }
6121 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6122 inline basic_string<_CharT, _Traits, _Alloc>
6124 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6125 {
return std::move(__rhs.insert(0, 1, __lhs)); }
6127 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6128 inline basic_string<_CharT, _Traits, _Alloc>
6129 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6130 const _CharT* __rhs)
6131 {
return std::move(__lhs.append(__rhs)); }
6133 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6134 inline basic_string<_CharT, _Traits, _Alloc>
6135 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6137 {
return std::move(__lhs.append(1, __rhs)); }
6147 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6152 {
return __lhs.compare(__rhs) == 0; }
6154 template<
typename _CharT>
6156 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
6157 operator==(
const basic_string<_CharT>& __lhs,
6158 const basic_string<_CharT>& __rhs) _GLIBCXX_NOEXCEPT
6159 {
return (__lhs.size() == __rhs.size()
6169 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6171 operator==(
const _CharT* __lhs,
6173 {
return __rhs.compare(__lhs) == 0; }
6181 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6184 const _CharT* __rhs)
6185 {
return __lhs.compare(__rhs) == 0; }
6194 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6199 {
return !(__lhs == __rhs); }
6207 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6209 operator!=(
const _CharT* __lhs,
6211 {
return !(__lhs == __rhs); }
6219 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6222 const _CharT* __rhs)
6223 {
return !(__lhs == __rhs); }
6232 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6237 {
return __lhs.compare(__rhs) < 0; }
6245 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6248 const _CharT* __rhs)
6249 {
return __lhs.compare(__rhs) < 0; }
6257 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6259 operator<(
const _CharT* __lhs,
6261 {
return __rhs.compare(__lhs) > 0; }
6270 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6275 {
return __lhs.compare(__rhs) > 0; }
6283 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6286 const _CharT* __rhs)
6287 {
return __lhs.compare(__rhs) > 0; }
6295 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6297 operator>(
const _CharT* __lhs,
6299 {
return __rhs.compare(__lhs) < 0; }
6308 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6313 {
return __lhs.compare(__rhs) <= 0; }
6321 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6324 const _CharT* __rhs)
6325 {
return __lhs.compare(__rhs) <= 0; }
6333 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6335 operator<=(
const _CharT* __lhs,
6337 {
return __rhs.compare(__lhs) >= 0; }
6346 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6351 {
return __lhs.compare(__rhs) >= 0; }
6359 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6362 const _CharT* __rhs)
6363 {
return __lhs.compare(__rhs) >= 0; }
6371 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6373 operator>=(
const _CharT* __lhs,
6375 {
return __rhs.compare(__lhs) <= 0; }
6384 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6388 _GLIBCXX_NOEXCEPT_IF(
noexcept(__lhs.swap(__rhs)))
6389 { __lhs.swap(__rhs); }
6404 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6405 basic_istream<_CharT, _Traits>&
6406 operator>>(basic_istream<_CharT, _Traits>& __is,
6407 basic_string<_CharT, _Traits, _Alloc>& __str);
6410 basic_istream<char>&
6422 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6429 return __ostream_insert(__os, __str.data(), __str.size());
6445 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6446 basic_istream<_CharT, _Traits>&
6447 getline(basic_istream<_CharT, _Traits>& __is,
6448 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
6462 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6463 inline basic_istream<_CharT, _Traits>&
6468#if __cplusplus >= 201103L
6470 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6471 inline basic_istream<_CharT, _Traits>&
6477 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6478 inline basic_istream<_CharT, _Traits>&
6485 basic_istream<char>&
6486 getline(basic_istream<char>& __in, basic_string<char>& __str,
6489#ifdef _GLIBCXX_USE_WCHAR_T
6491 basic_istream<wchar_t>&
6492 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
6496_GLIBCXX_END_NAMESPACE_VERSION
6499#if __cplusplus >= 201103L
6503namespace std _GLIBCXX_VISIBILITY(default)
6505_GLIBCXX_BEGIN_NAMESPACE_VERSION
6506_GLIBCXX_BEGIN_NAMESPACE_CXX11
6508#if _GLIBCXX_USE_C99_STDLIB
6511 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6512 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
6516 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6517 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
6520 inline unsigned long
6521 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6522 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
6526 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6527 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
6530 inline unsigned long long
6531 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6532 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
6537 stof(
const string& __str,
size_t* __idx = 0)
6538 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
6541 stod(
const string& __str,
size_t* __idx = 0)
6542 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
6545 stold(
const string& __str,
size_t* __idx = 0)
6546 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
6549#if _GLIBCXX_USE_C99_STDIO
6554 to_string(
int __val)
6555 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(
int),
6559 to_string(
unsigned __val)
6560 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6561 4 *
sizeof(
unsigned),
6565 to_string(
long __val)
6566 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 *
sizeof(
long),
6570 to_string(
unsigned long __val)
6571 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6572 4 *
sizeof(
unsigned long),
6576 to_string(
long long __val)
6577 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6578 4 *
sizeof(
long long),
6582 to_string(
unsigned long long __val)
6583 {
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf,
6584 4 *
sizeof(
unsigned long long),
6588 to_string(
float __val)
6591 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6592 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6597 to_string(
double __val)
6600 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6601 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6606 to_string(
long double __val)
6609 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6610 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6615#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
6617 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6618 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
6622 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6623 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
6626 inline unsigned long
6627 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6628 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
6632 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6633 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
6636 inline unsigned long long
6637 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6638 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
6643 stof(
const wstring& __str,
size_t* __idx = 0)
6644 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
6647 stod(
const wstring& __str,
size_t* __idx = 0)
6648 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
6651 stold(
const wstring& __str,
size_t* __idx = 0)
6652 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
6654#ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
6657 to_wstring(
int __val)
6658 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
int),
6662 to_wstring(
unsigned __val)
6663 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6664 4 *
sizeof(
unsigned),
6668 to_wstring(
long __val)
6669 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
long),
6673 to_wstring(
unsigned long __val)
6674 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6675 4 *
sizeof(
unsigned long),
6679 to_wstring(
long long __val)
6680 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6681 4 *
sizeof(
long long),
6685 to_wstring(
unsigned long long __val)
6686 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6687 4 *
sizeof(
unsigned long long),
6691 to_wstring(
float __val)
6694 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6695 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6700 to_wstring(
double __val)
6703 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6704 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6709 to_wstring(
long double __val)
6712 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6713 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6719_GLIBCXX_END_NAMESPACE_CXX11
6720_GLIBCXX_END_NAMESPACE_VERSION
6725#if __cplusplus >= 201103L
6729namespace std _GLIBCXX_VISIBILITY(default)
6731_GLIBCXX_BEGIN_NAMESPACE_VERSION
6735#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
6739 :
public __hash_base<size_t, string>
6742 operator()(
const string& __s)
const noexcept
6743 {
return std::_Hash_impl::hash(__s.data(), __s.length()); }
6750#ifdef _GLIBCXX_USE_WCHAR_T
6754 :
public __hash_base<size_t, wstring>
6757 operator()(
const wstring& __s)
const noexcept
6758 {
return std::_Hash_impl::hash(__s.
data(),
6759 __s.
length() *
sizeof(
wchar_t)); }
6768#ifdef _GLIBCXX_USE_CHAR8_T
6771 struct hash<u8string>
6772 :
public __hash_base<size_t, u8string>
6775 operator()(
const u8string& __s)
const noexcept
6776 {
return std::_Hash_impl::hash(__s.data(),
6777 __s.length() *
sizeof(
char8_t)); }
6788 :
public __hash_base<size_t, u16string>
6791 operator()(
const u16string& __s)
const noexcept
6792 {
return std::_Hash_impl::hash(__s.
data(),
6793 __s.
length() *
sizeof(
char16_t)); }
6803 :
public __hash_base<size_t, u32string>
6806 operator()(
const u32string& __s)
const noexcept
6807 {
return std::_Hash_impl::hash(__s.
data(),
6808 __s.
length() *
sizeof(
char32_t)); }
6815#if __cplusplus >= 201402L
6817#define __cpp_lib_string_udls 201304
6819 inline namespace literals
6821 inline namespace string_literals
6823#pragma GCC diagnostic push
6824#pragma GCC diagnostic ignored "-Wliteral-suffix"
6825 _GLIBCXX_DEFAULT_ABI_TAG
6826 inline basic_string<char>
6827 operator""s(
const char* __str,
size_t __len)
6828 {
return basic_string<char>{__str, __len}; }
6830#ifdef _GLIBCXX_USE_WCHAR_T
6831 _GLIBCXX_DEFAULT_ABI_TAG
6832 inline basic_string<wchar_t>
6833 operator""s(
const wchar_t* __str,
size_t __len)
6834 {
return basic_string<wchar_t>{__str, __len}; }
6837#ifdef _GLIBCXX_USE_CHAR8_T
6838 _GLIBCXX_DEFAULT_ABI_TAG
6839 inline basic_string<char8_t>
6840 operator""s(
const char8_t* __str,
size_t __len)
6841 {
return basic_string<char8_t>{__str, __len}; }
6844 _GLIBCXX_DEFAULT_ABI_TAG
6845 inline basic_string<char16_t>
6846 operator""s(
const char16_t* __str,
size_t __len)
6847 {
return basic_string<char16_t>{__str, __len}; }
6849 _GLIBCXX_DEFAULT_ABI_TAG
6850 inline basic_string<char32_t>
6851 operator""s(
const char32_t* __str,
size_t __len)
6852 {
return basic_string<char32_t>{__str, __len}; }
6854#pragma GCC diagnostic pop
6858#if __cplusplus >= 201703L
6859 namespace __detail::__variant
6861 template<
typename>
struct _Never_valueless_alt;
6865 template<
typename _Tp,
typename _Traits,
typename _Alloc>
6866 struct _Never_valueless_alt<
std::basic_string<_Tp, _Traits, _Alloc>>
6868 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
6869 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
6876_GLIBCXX_END_NAMESPACE_VERSION
_GLIBCXX20_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.
_GLIBCXX14_CONSTEXPR const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
_GLIBCXX_END_NAMESPACE_CXX11 typedef basic_string< char > string
A string of char.
basic_string< wchar_t > wstring
A string of wchar_t.
ISO C++ entities toplevel namespace is std.
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.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
_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 & operator=(const _CharT *__s)
Copy contents of s into this string.
void push_back(_CharT __c)
Append a single character.
const_iterator cend() const noexcept
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
size_type find(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
const _CharT * data() const noexcept
Return const pointer to contents.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character of C string.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
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.
int compare(const basic_string &__str) const
Compare to a string.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with 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.
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 & assign(const basic_string &__str)
Set value to contents of another string.
reverse_iterator rbegin()
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n=npos)
Insert a substring.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
basic_string & assign(basic_string &&__str) noexcept(allocator_traits< _Alloc >::is_always_equal::value)
Set value to contents of another string.
void pop_back()
Remove the last character.
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 & operator+=(const basic_string &__str)
Append a string to this string.
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 & operator+=(const _CharT *__s)
Append a C string.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
const_reference back() const noexcept
const_reverse_iterator rend() const noexcept
const_iterator end() const noexcept
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
basic_string & append(const basic_string &__str)
Append a string to this string.
const_iterator begin() const noexcept
basic_string & operator=(basic_string &&__str) noexcept(/*conditional */)
Move assign the value of str to this string.
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
basic_string & operator+=(_CharT __c)
Append a character.
const_reverse_iterator crend() const noexcept
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
void resize(size_type __n)
Resizes the string to the specified number of characters.
const_reverse_iterator rbegin() const noexcept
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
_GLIBCXX_NODISCARD bool empty() const noexcept
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n=npos)
Set value to a substring of a string.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
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 & assign(const _CharT *__s)
Set value to contents of a C string.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
const_iterator cbegin() const noexcept
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
~basic_string() noexcept
Destroy the string instance.
size_type capacity() const noexcept
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.
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 & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
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.
basic_string & append(const _CharT *__s)
Append a C string.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character not in C string.
reference at(size_type __n)
Provides access to the data contained in the string.
iterator insert(iterator __p, _CharT __c)
Insert one character.
Basis for explicit traits specializations.
Uniform interface to all pointer-like types.
Forward iterators support a superset of input iterator operations.
Uniform interface to C++98 and C++11 allocators.