34 #ifndef _BASIC_STRING_H
35 #define _BASIC_STRING_H 1
37 #pragma GCC system_header
43 #if __cplusplus >= 201103L
47 #if __cplusplus >= 201703L
48 # include <string_view>
51 namespace std _GLIBCXX_VISIBILITY(default)
53 _GLIBCXX_BEGIN_NAMESPACE_VERSION
55 #ifdef __cpp_lib_is_constant_evaluated
57 # define __cpp_lib_constexpr_string 201811L
58 #elif __cplusplus >= 201703L
60 # define __cpp_lib_constexpr_string 201611L
61 #elif __cplusplus > 201703L
64 #if _GLIBCXX_USE_CXX11_ABI
65 _GLIBCXX_BEGIN_NAMESPACE_CXX11
84 template<
typename _CharT,
typename _Traits,
typename _Alloc>
88 rebind<_CharT>::other _Char_alloc_type;
93 typedef _Traits traits_type;
94 typedef typename _Traits::char_type value_type;
95 typedef _Char_alloc_type allocator_type;
96 typedef typename _Alloc_traits::size_type size_type;
97 typedef typename _Alloc_traits::difference_type difference_type;
98 typedef typename _Alloc_traits::reference reference;
99 typedef typename _Alloc_traits::const_reference const_reference;
100 typedef typename _Alloc_traits::pointer pointer;
101 typedef typename _Alloc_traits::const_pointer const_pointer;
102 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
103 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
109 static const size_type
npos =
static_cast<size_type
>(-1);
113 #if __cplusplus < 201103L
114 typedef iterator __const_iterator;
116 typedef const_iterator __const_iterator;
120 #if __cplusplus >= 201703L
122 typedef basic_string_view<_CharT, _Traits> __sv_type;
124 template<
typename _Tp,
typename _Res>
126 __and_<is_convertible<const _Tp&, __sv_type>,
127 __not_<is_convertible<const _Tp*, const basic_string*>>,
128 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
133 _S_to_string_view(__sv_type __svt) noexcept
142 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
158 struct _Alloc_hider : allocator_type
160 #if __cplusplus < 201103L
161 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
162 : allocator_type(__a), _M_p(__dat) { }
164 _Alloc_hider(pointer __dat,
const _Alloc& __a)
165 : allocator_type(__a), _M_p(__dat) { }
167 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
168 : allocator_type(
std::
move(__a)), _M_p(__dat) { }
174 _Alloc_hider _M_dataplus;
175 size_type _M_string_length;
177 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
181 _CharT _M_local_buf[_S_local_capacity + 1];
182 size_type _M_allocated_capacity;
187 { _M_dataplus._M_p = __p; }
190 _M_length(size_type __length)
191 { _M_string_length = __length; }
195 {
return _M_dataplus._M_p; }
200 #if __cplusplus >= 201103L
203 return pointer(_M_local_buf);
208 _M_local_data()
const
210 #if __cplusplus >= 201103L
213 return const_pointer(_M_local_buf);
218 _M_capacity(size_type __capacity)
219 { _M_allocated_capacity = __capacity; }
222 _M_set_length(size_type __n)
225 traits_type::assign(_M_data()[__n], _CharT());
230 {
return _M_data() == _M_local_data(); }
234 _M_create(size_type&, size_type);
240 _M_destroy(_M_allocated_capacity);
244 _M_destroy(size_type __size)
throw()
245 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
249 template<
typename _InIterator>
251 _M_construct_aux(_InIterator __beg, _InIterator __end,
254 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
255 _M_construct(__beg, __end, _Tag());
260 template<
typename _Integer>
262 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
263 { _M_construct_aux_2(
static_cast<size_type
>(__beg), __end); }
266 _M_construct_aux_2(size_type __req, _CharT __c)
267 { _M_construct(__req, __c); }
269 template<
typename _InIterator>
271 _M_construct(_InIterator __beg, _InIterator __end)
273 typedef typename std::__is_integer<_InIterator>::__type _Integral;
274 _M_construct_aux(__beg, __end, _Integral());
278 template<
typename _InIterator>
280 _M_construct(_InIterator __beg, _InIterator __end,
285 template<
typename _FwdIterator>
287 _M_construct(_FwdIterator __beg, _FwdIterator __end,
291 _M_construct(size_type __req, _CharT __c);
295 {
return _M_dataplus; }
297 const allocator_type&
298 _M_get_allocator()
const
299 {
return _M_dataplus; }
303 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
306 template<
typename _Tp,
bool _Requires =
307 !__are_same<_Tp, _CharT*>::__value
308 && !__are_same<_Tp, const _CharT*>::__value
309 && !__are_same<_Tp, iterator>::__value
310 && !__are_same<_Tp, const_iterator>::__value>
311 struct __enable_if_not_native_iterator
313 template<
typename _Tp>
314 struct __enable_if_not_native_iterator<_Tp, false> { };
318 _M_check(size_type __pos,
const char* __s)
const
320 if (__pos > this->
size())
321 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
322 "this->size() (which is %zu)"),
323 __s, __pos, this->
size());
328 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
331 __throw_length_error(__N(__s));
337 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
339 const bool __testoff = __off < this->
size() - __pos;
340 return __testoff ? __off : this->
size() - __pos;
345 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
347 return (less<const _CharT*>()(__s, _M_data())
348 || less<const _CharT*>()(_M_data() + this->
size(), __s));
354 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
357 traits_type::assign(*__d, *__s);
359 traits_type::copy(__d, __s, __n);
363 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
366 traits_type::assign(*__d, *__s);
372 _S_assign(_CharT* __d, size_type __n, _CharT __c)
375 traits_type::assign(*__d, __c);
377 traits_type::assign(__d, __n, __c);
382 template<
class _Iterator>
384 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
386 for (; __k1 != __k2; ++__k1, (void)++__p)
387 traits_type::assign(*__p, *__k1);
391 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
392 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
395 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
397 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
400 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
401 { _S_copy(__p, __k1, __k2 - __k1); }
404 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
406 { _S_copy(__p, __k1, __k2 - __k1); }
409 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
411 const difference_type __d = difference_type(__n1 - __n2);
413 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
414 return __gnu_cxx::__numeric_traits<int>::__max;
415 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
416 return __gnu_cxx::__numeric_traits<int>::__min;
425 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
429 _M_erase(size_type __pos, size_type __n);
440 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
441 : _M_dataplus(_M_local_data())
442 { _M_set_length(0); }
449 : _M_dataplus(_M_local_data(), __a)
450 { _M_set_length(0); }
457 : _M_dataplus(_M_local_data(),
458 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
459 { _M_construct(__str._M_data(), __str._M_data() + __str.length()); }
470 const _Alloc& __a = _Alloc())
471 : _M_dataplus(_M_local_data(), __a)
473 const _CharT* __start = __str._M_data()
474 + __str._M_check(__pos,
"basic_string::basic_string");
475 _M_construct(__start, __start + __str._M_limit(__pos,
npos));
486 : _M_dataplus(_M_local_data())
488 const _CharT* __start = __str._M_data()
489 + __str._M_check(__pos,
"basic_string::basic_string");
490 _M_construct(__start, __start + __str._M_limit(__pos, __n));
501 size_type __n,
const _Alloc& __a)
502 : _M_dataplus(_M_local_data(), __a)
504 const _CharT* __start
505 = __str._M_data() + __str._M_check(__pos,
"string::string");
506 _M_construct(__start, __start + __str._M_limit(__pos, __n));
519 const _Alloc& __a = _Alloc())
520 : _M_dataplus(_M_local_data(), __a)
521 { _M_construct(__s, __s + __n); }
528 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
531 template<
typename = _RequireAllocator<_Alloc>>
533 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
534 : _M_dataplus(_M_local_data(), __a)
536 const _CharT* __end = __s ? __s + traits_type::length(__s)
538 : reinterpret_cast<const _CharT*>(__alignof__(_CharT));
539 _M_construct(__s, __end, random_access_iterator_tag());
548 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
551 template<
typename = _RequireAllocator<_Alloc>>
553 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
554 : _M_dataplus(_M_local_data(), __a)
555 { _M_construct(__n, __c); }
557 #if __cplusplus >= 201103L
566 : _M_dataplus(_M_local_data(),
std::move(__str._M_get_allocator()))
568 if (__str._M_is_local())
570 traits_type::copy(_M_local_buf, __str._M_local_buf,
571 _S_local_capacity + 1);
575 _M_data(__str._M_data());
576 _M_capacity(__str._M_allocated_capacity);
582 _M_length(__str.length());
583 __str._M_data(__str._M_local_data());
584 __str._M_set_length(0);
592 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
593 : _M_dataplus(_M_local_data(), __a)
594 { _M_construct(__l.begin(), __l.end()); }
597 : _M_dataplus(_M_local_data(), __a)
598 { _M_construct(__str.begin(), __str.end()); }
601 noexcept(_Alloc_traits::_S_always_equal())
602 : _M_dataplus(_M_local_data(), __a)
604 if (__str._M_is_local())
606 traits_type::copy(_M_local_buf, __str._M_local_buf,
607 _S_local_capacity + 1);
608 _M_length(__str.length());
609 __str._M_set_length(0);
611 else if (_Alloc_traits::_S_always_equal()
612 || __str.get_allocator() == __a)
614 _M_data(__str._M_data());
615 _M_length(__str.length());
616 _M_capacity(__str._M_allocated_capacity);
617 __str._M_data(__str._M_local_buf);
618 __str._M_set_length(0);
621 _M_construct(__str.begin(), __str.end());
632 #if __cplusplus >= 201103L
633 template<
typename _InputIterator,
634 typename = std::_RequireInputIter<_InputIterator>>
636 template<
typename _InputIterator>
638 basic_string(_InputIterator __beg, _InputIterator __end,
639 const _Alloc& __a = _Alloc())
640 : _M_dataplus(_M_local_data(), __a)
641 { _M_construct(__beg, __end); }
643 #if __cplusplus >= 201703L
651 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
652 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
653 const _Alloc& __a = _Alloc())
661 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
663 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
664 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
680 return this->
assign(__str);
689 {
return this->
assign(__s); }
705 #if __cplusplus >= 201103L
717 noexcept(_Alloc_traits::_S_nothrow_move())
719 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
720 && !_Alloc_traits::_S_always_equal()
721 && _M_get_allocator() != __str._M_get_allocator())
724 _M_destroy(_M_allocated_capacity);
725 _M_data(_M_local_data());
729 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
731 if (__str._M_is_local())
735 this->_S_copy(_M_data(), __str._M_data(), __str.size());
736 _M_set_length(__str.size());
738 else if (_Alloc_traits::_S_propagate_on_move_assign()
739 || _Alloc_traits::_S_always_equal()
740 || _M_get_allocator() == __str._M_get_allocator())
743 pointer __data =
nullptr;
744 size_type __capacity;
747 if (_Alloc_traits::_S_always_equal())
751 __capacity = _M_allocated_capacity;
754 _M_destroy(_M_allocated_capacity);
757 _M_data(__str._M_data());
758 _M_length(__str.length());
759 _M_capacity(__str._M_allocated_capacity);
762 __str._M_data(__data);
763 __str._M_capacity(__capacity);
766 __str._M_data(__str._M_local_buf);
781 this->
assign(__l.begin(), __l.size());
786 #if __cplusplus >= 201703L
791 template<
typename _Tp>
792 _If_sv<_Tp, basic_string&>
794 {
return this->
assign(__svt); }
800 operator __sv_type() const noexcept
801 {
return __sv_type(
data(),
size()); }
810 begin() _GLIBCXX_NOEXCEPT
811 {
return iterator(_M_data()); }
818 begin() const _GLIBCXX_NOEXCEPT
819 {
return const_iterator(_M_data()); }
826 end() _GLIBCXX_NOEXCEPT
827 {
return iterator(_M_data() + this->
size()); }
834 end() const _GLIBCXX_NOEXCEPT
835 {
return const_iterator(_M_data() + this->
size()); }
843 rbegin() _GLIBCXX_NOEXCEPT
844 {
return reverse_iterator(this->
end()); }
851 const_reverse_iterator
852 rbegin() const _GLIBCXX_NOEXCEPT
853 {
return const_reverse_iterator(this->
end()); }
861 rend() _GLIBCXX_NOEXCEPT
862 {
return reverse_iterator(this->
begin()); }
869 const_reverse_iterator
870 rend() const _GLIBCXX_NOEXCEPT
871 {
return const_reverse_iterator(this->
begin()); }
873 #if __cplusplus >= 201103L
880 {
return const_iterator(this->_M_data()); }
887 cend() const noexcept
888 {
return const_iterator(this->_M_data() + this->
size()); }
895 const_reverse_iterator
897 {
return const_reverse_iterator(this->
end()); }
904 const_reverse_iterator
905 crend() const noexcept
906 {
return const_reverse_iterator(this->
begin()); }
914 size() const _GLIBCXX_NOEXCEPT
915 {
return _M_string_length; }
920 length() const _GLIBCXX_NOEXCEPT
921 {
return _M_string_length; }
926 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
939 resize(size_type __n, _CharT __c);
953 { this->
resize(__n, _CharT()); }
955 #if __cplusplus >= 201103L
979 return _M_is_local() ? size_type(_S_local_capacity)
980 : _M_allocated_capacity;
1001 reserve(size_type __res_arg = 0);
1007 clear() _GLIBCXX_NOEXCEPT
1008 { _M_set_length(0); }
1014 _GLIBCXX_NODISCARD
bool
1015 empty() const _GLIBCXX_NOEXCEPT
1016 {
return this->
size() == 0; }
1030 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
1032 __glibcxx_assert(__pos <=
size());
1033 return _M_data()[__pos];
1051 __glibcxx_assert(__pos <=
size());
1053 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1054 return _M_data()[__pos];
1068 at(size_type __n)
const
1070 if (__n >= this->
size())
1071 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1072 "(which is %zu) >= this->size() "
1075 return _M_data()[__n];
1092 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
1093 "(which is %zu) >= this->size() "
1096 return _M_data()[__n];
1099 #if __cplusplus >= 201103L
1107 __glibcxx_assert(!
empty());
1116 front() const noexcept
1118 __glibcxx_assert(!
empty());
1129 __glibcxx_assert(!
empty());
1138 back() const noexcept
1140 __glibcxx_assert(!
empty());
1153 {
return this->
append(__str); }
1162 {
return this->
append(__s); }
1176 #if __cplusplus >= 201103L
1184 {
return this->
append(__l.begin(), __l.size()); }
1187 #if __cplusplus >= 201703L
1193 template<
typename _Tp>
1194 _If_sv<_Tp, basic_string&>
1196 {
return this->
append(__svt); }
1206 {
return _M_append(__str._M_data(), __str.size()); }
1223 {
return _M_append(__str._M_data()
1224 + __str._M_check(__pos,
"basic_string::append"),
1225 __str._M_limit(__pos, __n)); }
1234 append(
const _CharT* __s, size_type __n)
1236 __glibcxx_requires_string_len(__s, __n);
1237 _M_check_length(size_type(0), __n,
"basic_string::append");
1238 return _M_append(__s, __n);
1247 append(
const _CharT* __s)
1249 __glibcxx_requires_string(__s);
1250 const size_type __n = traits_type::length(__s);
1251 _M_check_length(size_type(0), __n,
"basic_string::append");
1252 return _M_append(__s, __n);
1264 append(size_type __n, _CharT __c)
1265 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1267 #if __cplusplus >= 201103L
1274 append(initializer_list<_CharT> __l)
1275 {
return this->
append(__l.begin(), __l.size()); }
1286 #if __cplusplus >= 201103L
1287 template<
class _InputIterator,
1288 typename = std::_RequireInputIter<_InputIterator>>
1290 template<
class _InputIterator>
1293 append(_InputIterator __first, _InputIterator __last)
1296 #if __cplusplus >= 201703L
1302 template<
typename _Tp>
1303 _If_sv<_Tp, basic_string&>
1306 __sv_type __sv = __svt;
1307 return this->
append(__sv.data(), __sv.size());
1317 template<
typename _Tp>
1318 _If_sv<_Tp, basic_string&>
1319 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1321 __sv_type __sv = __svt;
1322 return _M_append(__sv.data()
1323 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1324 std::__sv_limit(__sv.size(), __pos, __n));
1335 const size_type __size = this->
size();
1337 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1338 traits_type::assign(this->_M_data()[__size], __c);
1339 this->_M_set_length(__size + 1);
1350 #if __cplusplus >= 201103L
1351 if (_Alloc_traits::_S_propagate_on_copy_assign())
1353 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
1354 && _M_get_allocator() != __str._M_get_allocator())
1358 if (__str.size() <= _S_local_capacity)
1360 _M_destroy(_M_allocated_capacity);
1361 _M_data(_M_local_data());
1366 const auto __len = __str.size();
1367 auto __alloc = __str._M_get_allocator();
1369 auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1);
1370 _M_destroy(_M_allocated_capacity);
1373 _M_set_length(__len);
1376 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
1379 this->_M_assign(__str);
1383 #if __cplusplus >= 201103L
1394 noexcept(_Alloc_traits::_S_nothrow_move())
1417 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1418 + __str._M_check(__pos,
"basic_string::assign"),
1419 __str._M_limit(__pos, __n)); }
1432 assign(
const _CharT* __s, size_type __n)
1434 __glibcxx_requires_string_len(__s, __n);
1435 return _M_replace(size_type(0), this->
size(), __s, __n);
1448 assign(
const _CharT* __s)
1450 __glibcxx_requires_string(__s);
1451 return _M_replace(size_type(0), this->
size(), __s,
1452 traits_type::length(__s));
1465 assign(size_type __n, _CharT __c)
1466 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1476 #if __cplusplus >= 201103L
1477 template<
class _InputIterator,
1478 typename = std::_RequireInputIter<_InputIterator>>
1480 template<
class _InputIterator>
1483 assign(_InputIterator __first, _InputIterator __last)
1486 #if __cplusplus >= 201103L
1493 assign(initializer_list<_CharT> __l)
1494 {
return this->
assign(__l.begin(), __l.size()); }
1497 #if __cplusplus >= 201703L
1503 template<
typename _Tp>
1504 _If_sv<_Tp, basic_string&>
1507 __sv_type __sv = __svt;
1508 return this->
assign(__sv.data(), __sv.size());
1518 template<
typename _Tp>
1519 _If_sv<_Tp, basic_string&>
1520 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1522 __sv_type __sv = __svt;
1523 return _M_replace(size_type(0), this->
size(),
1525 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
1526 std::__sv_limit(__sv.size(), __pos, __n));
1530 #if __cplusplus >= 201103L
1547 insert(const_iterator __p, size_type __n, _CharT __c)
1549 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1550 const size_type __pos = __p -
begin();
1551 this->
replace(__p, __p, __n, __c);
1552 return iterator(this->_M_data() + __pos);
1569 insert(iterator __p, size_type __n, _CharT __c)
1570 { this->
replace(__p, __p, __n, __c); }
1573 #if __cplusplus >= 201103L
1588 template<
class _InputIterator,
1589 typename = std::_RequireInputIter<_InputIterator>>
1591 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1593 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1594 const size_type __pos = __p -
begin();
1595 this->
replace(__p, __p, __beg, __end);
1596 return iterator(this->_M_data() + __pos);
1611 template<
class _InputIterator>
1613 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1614 { this->
replace(__p, __p, __beg, __end); }
1617 #if __cplusplus >= 201103L
1625 insert(const_iterator __p, initializer_list<_CharT> __l)
1626 {
return this->
insert(__p, __l.begin(), __l.end()); }
1628 #ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
1631 insert(iterator __p, initializer_list<_CharT> __l)
1633 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1634 this->
insert(__p -
begin(), __l.begin(), __l.size());
1653 {
return this->
replace(__pos1, size_type(0),
1654 __str._M_data(), __str.size()); }
1676 size_type __pos2, size_type __n =
npos)
1677 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1678 + __str._M_check(__pos2,
"basic_string::insert"),
1679 __str._M_limit(__pos2, __n)); }
1698 insert(size_type __pos,
const _CharT* __s, size_type __n)
1699 {
return this->
replace(__pos, size_type(0), __s, __n); }
1717 insert(size_type __pos,
const _CharT* __s)
1719 __glibcxx_requires_string(__s);
1720 return this->
replace(__pos, size_type(0), __s,
1721 traits_type::length(__s));
1741 insert(size_type __pos, size_type __n, _CharT __c)
1742 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1743 size_type(0), __n, __c); }
1759 insert(__const_iterator __p, _CharT __c)
1761 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1762 const size_type __pos = __p -
begin();
1763 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1764 return iterator(_M_data() + __pos);
1767 #if __cplusplus >= 201703L
1774 template<
typename _Tp>
1775 _If_sv<_Tp, basic_string&>
1776 insert(size_type __pos,
const _Tp& __svt)
1778 __sv_type __sv = __svt;
1779 return this->
insert(__pos, __sv.data(), __sv.size());
1790 template<
typename _Tp>
1791 _If_sv<_Tp, basic_string&>
1792 insert(size_type __pos1,
const _Tp& __svt,
1793 size_type __pos2, size_type __n =
npos)
1795 __sv_type __sv = __svt;
1796 return this->
replace(__pos1, size_type(0),
1798 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
1799 std::__sv_limit(__sv.size(), __pos2, __n));
1819 erase(size_type __pos = 0, size_type __n =
npos)
1821 _M_check(__pos,
"basic_string::erase");
1823 this->_M_set_length(__pos);
1825 this->_M_erase(__pos, _M_limit(__pos, __n));
1838 erase(__const_iterator __position)
1840 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1841 && __position <
end());
1842 const size_type __pos = __position -
begin();
1843 this->_M_erase(__pos, size_type(1));
1844 return iterator(_M_data() + __pos);
1857 erase(__const_iterator __first, __const_iterator __last)
1859 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1860 && __last <=
end());
1861 const size_type __pos = __first -
begin();
1862 if (__last ==
end())
1863 this->_M_set_length(__pos);
1865 this->_M_erase(__pos, __last - __first);
1866 return iterator(this->_M_data() + __pos);
1869 #if __cplusplus >= 201103L
1878 __glibcxx_assert(!
empty());
1879 _M_erase(
size() - 1, 1);
1902 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1924 size_type __pos2, size_type __n2 =
npos)
1925 {
return this->
replace(__pos1, __n1, __str._M_data()
1926 + __str._M_check(__pos2,
"basic_string::replace"),
1927 __str._M_limit(__pos2, __n2)); }
1948 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1951 __glibcxx_requires_string_len(__s, __n2);
1952 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1953 _M_limit(__pos, __n1), __s, __n2);
1973 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1975 __glibcxx_requires_string(__s);
1976 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
1997 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
1998 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
1999 _M_limit(__pos, __n1), __n2, __c); }
2015 replace(__const_iterator __i1, __const_iterator __i2,
2017 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
2035 replace(__const_iterator __i1, __const_iterator __i2,
2036 const _CharT* __s, size_type __n)
2038 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2040 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2057 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2059 __glibcxx_requires_string(__s);
2060 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2078 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2081 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2083 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2101 #if __cplusplus >= 201103L
2102 template<
class _InputIterator,
2103 typename = std::_RequireInputIter<_InputIterator>>
2105 replace(const_iterator __i1, const_iterator __i2,
2106 _InputIterator __k1, _InputIterator __k2)
2108 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2110 __glibcxx_requires_valid_range(__k1, __k2);
2111 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2112 std::__false_type());
2115 template<
class _InputIterator>
2116 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2117 typename __enable_if_not_native_iterator<_InputIterator>::__type
2121 replace(iterator __i1, iterator __i2,
2122 _InputIterator __k1, _InputIterator __k2)
2124 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2126 __glibcxx_requires_valid_range(__k1, __k2);
2127 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2128 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2135 replace(__const_iterator __i1, __const_iterator __i2,
2136 _CharT* __k1, _CharT* __k2)
2138 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2140 __glibcxx_requires_valid_range(__k1, __k2);
2146 replace(__const_iterator __i1, __const_iterator __i2,
2147 const _CharT* __k1,
const _CharT* __k2)
2149 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2151 __glibcxx_requires_valid_range(__k1, __k2);
2157 replace(__const_iterator __i1, __const_iterator __i2,
2158 iterator __k1, iterator __k2)
2160 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2162 __glibcxx_requires_valid_range(__k1, __k2);
2164 __k1.base(), __k2 - __k1);
2168 replace(__const_iterator __i1, __const_iterator __i2,
2169 const_iterator __k1, const_iterator __k2)
2171 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2173 __glibcxx_requires_valid_range(__k1, __k2);
2175 __k1.base(), __k2 - __k1);
2178 #if __cplusplus >= 201103L
2194 initializer_list<_CharT> __l)
2195 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2198 #if __cplusplus >= 201703L
2206 template<
typename _Tp>
2207 _If_sv<_Tp, basic_string&>
2208 replace(size_type __pos, size_type __n,
const _Tp& __svt)
2210 __sv_type __sv = __svt;
2211 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2223 template<
typename _Tp>
2224 _If_sv<_Tp, basic_string&>
2225 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2226 size_type __pos2, size_type __n2 =
npos)
2228 __sv_type __sv = __svt;
2229 return this->
replace(__pos1, __n1,
2231 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2232 std::__sv_limit(__sv.size(), __pos2, __n2));
2244 template<
typename _Tp>
2245 _If_sv<_Tp, basic_string&>
2246 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2248 __sv_type __sv = __svt;
2249 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2254 template<
class _Integer>
2256 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2257 _Integer __n, _Integer __val, __true_type)
2258 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2260 template<
class _InputIterator>
2262 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2263 _InputIterator __k1, _InputIterator __k2,
2267 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2271 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2272 const size_type __len2);
2275 _M_append(
const _CharT* __s, size_type __n);
2292 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2312 c_str() const _GLIBCXX_NOEXCEPT
2313 {
return _M_data(); }
2324 data() const _GLIBCXX_NOEXCEPT
2325 {
return _M_data(); }
2327 #if __cplusplus >= 201703L
2336 {
return _M_data(); }
2344 {
return _M_get_allocator(); }
2359 find(
const _CharT* __s, size_type __pos, size_type __n)
const
2375 {
return this->
find(__str.data(), __pos, __str.size()); }
2377 #if __cplusplus >= 201703L
2384 template<
typename _Tp>
2385 _If_sv<_Tp, size_type>
2386 find(
const _Tp& __svt, size_type __pos = 0) const
2387 noexcept(is_same<_Tp, __sv_type>::value)
2389 __sv_type __sv = __svt;
2390 return this->
find(__sv.data(), __pos, __sv.size());
2405 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2407 __glibcxx_requires_string(__s);
2408 return this->
find(__s, __pos, traits_type::length(__s));
2422 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2437 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2439 #if __cplusplus >= 201703L
2446 template<
typename _Tp>
2447 _If_sv<_Tp, size_type>
2448 rfind(
const _Tp& __svt, size_type __pos =
npos)
const
2449 noexcept(is_same<_Tp, __sv_type>::value)
2451 __sv_type __sv = __svt;
2452 return this->
rfind(__sv.data(), __pos, __sv.size());
2469 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
2483 rfind(
const _CharT* __s, size_type __pos =
npos)
const
2485 __glibcxx_requires_string(__s);
2486 return this->
rfind(__s, __pos, traits_type::length(__s));
2500 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
2516 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2518 #if __cplusplus >= 201703L
2526 template<
typename _Tp>
2527 _If_sv<_Tp, size_type>
2529 noexcept(is_same<_Tp, __sv_type>::value)
2531 __sv_type __sv = __svt;
2532 return this->
find_first_of(__sv.data(), __pos, __sv.size());
2549 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2566 __glibcxx_requires_string(__s);
2567 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2583 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2584 {
return this->
find(__c, __pos); }
2600 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2602 #if __cplusplus >= 201703L
2610 template<
typename _Tp>
2611 _If_sv<_Tp, size_type>
2613 noexcept(is_same<_Tp, __sv_type>::value)
2615 __sv_type __sv = __svt;
2616 return this->
find_last_of(__sv.data(), __pos, __sv.size());
2633 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
2650 __glibcxx_requires_string(__s);
2651 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2668 {
return this->
rfind(__c, __pos); }
2685 #if __cplusplus >= 201703L
2693 template<
typename _Tp>
2694 _If_sv<_Tp, size_type>
2696 noexcept(is_same<_Tp, __sv_type>::value)
2698 __sv_type __sv = __svt;
2717 size_type __n)
const _GLIBCXX_NOEXCEPT;
2733 __glibcxx_requires_string(__s);
2767 #if __cplusplus >= 201703L
2775 template<
typename _Tp>
2776 _If_sv<_Tp, size_type>
2778 noexcept(is_same<_Tp, __sv_type>::value)
2780 __sv_type __sv = __svt;
2799 size_type __n)
const _GLIBCXX_NOEXCEPT;
2815 __glibcxx_requires_string(__s);
2846 substr(size_type __pos = 0, size_type __n =
npos)
const
2848 _M_check(__pos,
"basic_string::substr"), __n); }
2867 const size_type __size = this->
size();
2868 const size_type __osize = __str.size();
2869 const size_type __len =
std::min(__size, __osize);
2871 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2873 __r = _S_compare(__size, __osize);
2877 #if __cplusplus >= 201703L
2883 template<
typename _Tp>
2885 compare(
const _Tp& __svt)
const
2886 noexcept(is_same<_Tp, __sv_type>::value)
2888 __sv_type __sv = __svt;
2889 const size_type __size = this->
size();
2890 const size_type __osize = __sv.size();
2891 const size_type __len =
std::min(__size, __osize);
2893 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
2895 __r = _S_compare(__size, __osize);
2907 template<
typename _Tp>
2909 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
2910 noexcept(is_same<_Tp, __sv_type>::value)
2912 __sv_type __sv = __svt;
2913 return __sv_type(*this).substr(__pos, __n).compare(__sv);
2926 template<
typename _Tp>
2928 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
2929 size_type __pos2, size_type __n2 =
npos)
const
2930 noexcept(is_same<_Tp, __sv_type>::value)
2932 __sv_type __sv = __svt;
2933 return __sv_type(*
this)
2934 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
2985 size_type __pos2, size_type __n2 =
npos)
const;
3002 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
3026 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
3053 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3054 size_type __n2)
const;
3056 #if __cplusplus > 201703L
3058 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3059 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3062 starts_with(_CharT __x)
const noexcept
3063 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3066 starts_with(
const _CharT* __x)
const noexcept
3067 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3070 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3071 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3074 ends_with(_CharT __x)
const noexcept
3075 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3078 ends_with(
const _CharT* __x)
const noexcept
3079 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3083 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3085 _GLIBCXX_END_NAMESPACE_CXX11
3151 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3155 rebind<_CharT>::other _CharT_alloc_type;
3160 typedef _Traits traits_type;
3161 typedef typename _Traits::char_type value_type;
3162 typedef _Alloc allocator_type;
3163 typedef typename _CharT_alloc_traits::size_type size_type;
3164 typedef typename _CharT_alloc_traits::difference_type difference_type;
3165 #if __cplusplus < 201103L
3166 typedef typename _CharT_alloc_type::reference reference;
3167 typedef typename _CharT_alloc_type::const_reference const_reference;
3169 typedef value_type& reference;
3170 typedef const value_type& const_reference;
3172 typedef typename _CharT_alloc_traits::pointer pointer;
3173 typedef typename _CharT_alloc_traits::const_pointer const_pointer;
3174 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
3175 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
3182 typedef iterator __const_iterator;
3201 size_type _M_length;
3202 size_type _M_capacity;
3203 _Atomic_word _M_refcount;
3206 struct _Rep : _Rep_base
3210 rebind<char>::other _Raw_bytes_alloc;
3225 static const size_type _S_max_size;
3226 static const _CharT _S_terminal;
3230 static size_type _S_empty_rep_storage[];
3233 _S_empty_rep() _GLIBCXX_NOEXCEPT
3238 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
3239 return *
reinterpret_cast<_Rep*
>(__p);
3243 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
3245 #if defined(__GTHREADS)
3250 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
3252 return this->_M_refcount < 0;
3257 _M_is_shared()
const _GLIBCXX_NOEXCEPT
3259 #if defined(__GTHREADS)
3265 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
3267 return this->_M_refcount > 0;
3272 _M_set_leaked() _GLIBCXX_NOEXCEPT
3273 { this->_M_refcount = -1; }
3276 _M_set_sharable() _GLIBCXX_NOEXCEPT
3277 { this->_M_refcount = 0; }
3280 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
3282 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3283 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3286 this->_M_set_sharable();
3287 this->_M_length = __n;
3288 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
3295 _M_refdata()
throw()
3296 {
return reinterpret_cast<_CharT*
>(
this + 1); }
3299 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
3301 return (!_M_is_leaked() && __alloc1 == __alloc2)
3302 ? _M_refcopy() : _M_clone(__alloc1);
3307 _S_create(size_type, size_type,
const _Alloc&);
3310 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3312 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3313 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3317 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
3326 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
3329 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
3336 _M_destroy(
const _Alloc&)
throw();
3339 _M_refcopy()
throw()
3341 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3342 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3344 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
3345 return _M_refdata();
3349 _M_clone(
const _Alloc&, size_type __res = 0);
3353 struct _Alloc_hider : _Alloc
3355 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3356 : _Alloc(__a), _M_p(__dat) { }
3366 static const size_type
npos =
static_cast<size_type
>(-1);
3370 mutable _Alloc_hider _M_dataplus;
3373 _M_data() const _GLIBCXX_NOEXCEPT
3374 {
return _M_dataplus._M_p; }
3377 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
3378 {
return (_M_dataplus._M_p = __p); }
3381 _M_rep() const _GLIBCXX_NOEXCEPT
3382 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
3387 _M_ibegin() const _GLIBCXX_NOEXCEPT
3388 {
return iterator(_M_data()); }
3391 _M_iend() const _GLIBCXX_NOEXCEPT
3392 {
return iterator(_M_data() + this->
size()); }
3397 if (!_M_rep()->_M_is_leaked())
3402 _M_check(size_type __pos,
const char* __s)
const
3404 if (__pos > this->
size())
3405 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > "
3406 "this->size() (which is %zu)"),
3407 __s, __pos, this->
size());
3412 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const
3415 __throw_length_error(__N(__s));
3420 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
3422 const bool __testoff = __off < this->
size() - __pos;
3423 return __testoff ? __off : this->
size() - __pos;
3428 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3430 return (less<const _CharT*>()(__s, _M_data())
3431 || less<const _CharT*>()(_M_data() + this->
size(), __s));
3437 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3440 traits_type::assign(*__d, *__s);
3442 traits_type::copy(__d, __s, __n);
3446 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3449 traits_type::assign(*__d, *__s);
3455 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
3458 traits_type::assign(*__d, __c);
3460 traits_type::assign(__d, __n, __c);
3465 template<
class _Iterator>
3467 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
3469 for (; __k1 != __k2; ++__k1, (void)++__p)
3470 traits_type::assign(*__p, *__k1);
3474 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
3475 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3478 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
3480 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3483 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
3484 { _M_copy(__p, __k1, __k2 - __k1); }
3487 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
3489 { _M_copy(__p, __k1, __k2 - __k1); }
3492 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
3494 const difference_type __d = difference_type(__n1 - __n2);
3496 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
3497 return __gnu_cxx::__numeric_traits<int>::__max;
3498 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
3499 return __gnu_cxx::__numeric_traits<int>::__min;
3505 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
3511 _S_empty_rep() _GLIBCXX_NOEXCEPT
3512 {
return _Rep::_S_empty_rep(); }
3514 #if __cplusplus >= 201703L
3516 typedef basic_string_view<_CharT, _Traits> __sv_type;
3518 template<
typename _Tp,
typename _Res>
3520 __and_<is_convertible<const _Tp&, __sv_type>,
3521 __not_<is_convertible<const _Tp*, const basic_string*>>,
3522 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
3527 _S_to_string_view(__sv_type __svt) noexcept
3536 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
3560 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3562 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc())
3564 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc())
3590 const _Alloc& __a = _Alloc());
3608 size_type __n,
const _Alloc& __a);
3620 const _Alloc& __a = _Alloc());
3627 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
3630 template<
typename = _RequireAllocator<_Alloc>>
3633 : _M_dataplus(_S_construct(__s, __s ? __s + traits_type::
length(__s) :
3634 __s +
npos, __a), __a)
3643 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc());
3645 #if __cplusplus >= 201103L
3654 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3657 : _M_dataplus(
std::move(__str._M_dataplus))
3659 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3660 __str._M_data(_S_empty_rep()._M_refdata());
3662 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3674 : _M_dataplus(__str._M_rep()->_M_grab(__a, __str.
get_allocator()), __a)
3678 : _M_dataplus(__str._M_data(), __a)
3680 if (__a == __str.get_allocator())
3682 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
3683 __str._M_data(_S_empty_rep()._M_refdata());
3685 __str._M_data(_S_construct(size_type(), _CharT(), __a));
3689 _M_dataplus._M_p = _S_construct(__str.begin(), __str.end(), __a);
3699 template<
class _InputIterator>
3700 basic_string(_InputIterator __beg, _InputIterator __end,
3701 const _Alloc& __a = _Alloc());
3703 #if __cplusplus >= 201703L
3711 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3712 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
3713 const _Alloc& __a = _Alloc())
3721 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3723 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
3724 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
3739 {
return this->
assign(__str); }
3747 {
return this->
assign(__s); }
3763 #if __cplusplus >= 201103L
3787 this->
assign(__l.begin(), __l.size());
3792 #if __cplusplus >= 201703L
3797 template<
typename _Tp>
3798 _If_sv<_Tp, basic_string&>
3800 {
return this->
assign(__svt); }
3806 operator __sv_type() const noexcept
3807 {
return __sv_type(
data(),
size()); }
3819 return iterator(_M_data());
3828 {
return const_iterator(_M_data()); }
3838 return iterator(_M_data() + this->
size());
3847 {
return const_iterator(_M_data() + this->
size()); }
3863 const_reverse_iterator
3881 const_reverse_iterator
3885 #if __cplusplus >= 201103L
3892 {
return const_iterator(this->_M_data()); }
3900 {
return const_iterator(this->_M_data() + this->
size()); }
3907 const_reverse_iterator
3916 const_reverse_iterator
3927 {
return _M_rep()->_M_length; }
3933 {
return _M_rep()->_M_length; }
3938 {
return _Rep::_S_max_size; }
3951 resize(size_type __n, _CharT __c);
3965 { this->
resize(__n, _CharT()); }
3967 #if __cplusplus >= 201103L
3972 #if __cpp_exceptions
3990 {
return _M_rep()->_M_capacity; }
4010 reserve(size_type __res_arg = 0);
4015 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0
4019 if (_M_rep()->_M_is_shared())
4022 _M_data(_S_empty_rep()._M_refdata());
4025 _M_rep()->_M_set_length_and_sharable(0);
4031 { _M_mutate(0, this->
size(), 0); }
4038 _GLIBCXX_NODISCARD
bool
4040 {
return this->
size() == 0; }
4056 __glibcxx_assert(__pos <=
size());
4057 return _M_data()[__pos];
4075 __glibcxx_assert(__pos <=
size());
4077 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
4079 return _M_data()[__pos];
4095 if (__n >= this->
size())
4096 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
4097 "(which is %zu) >= this->size() "
4100 return _M_data()[__n];
4118 __throw_out_of_range_fmt(__N(
"basic_string::at: __n "
4119 "(which is %zu) >= this->size() "
4123 return _M_data()[__n];
4126 #if __cplusplus >= 201103L
4134 __glibcxx_assert(!
empty());
4145 __glibcxx_assert(!
empty());
4156 __glibcxx_assert(!
empty());
4167 __glibcxx_assert(!
empty());
4180 {
return this->
append(__str); }
4189 {
return this->
append(__s); }
4203 #if __cplusplus >= 201103L
4211 {
return this->
append(__l.begin(), __l.size()); }
4214 #if __cplusplus >= 201703L
4220 template<
typename _Tp>
4221 _If_sv<_Tp, basic_string&>
4223 {
return this->
append(__svt); }
4257 append(
const _CharT* __s, size_type __n);
4267 __glibcxx_requires_string(__s);
4268 return this->
append(__s, traits_type::length(__s));
4280 append(size_type __n, _CharT __c);
4282 #if __cplusplus >= 201103L
4290 {
return this->
append(__l.begin(), __l.size()); }
4301 template<
class _InputIterator>
4303 append(_InputIterator __first, _InputIterator __last)
4304 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
4306 #if __cplusplus >= 201703L
4312 template<
typename _Tp>
4313 _If_sv<_Tp, basic_string&>
4316 __sv_type __sv = __svt;
4317 return this->
append(__sv.data(), __sv.size());
4328 template<
typename _Tp>
4329 _If_sv<_Tp, basic_string&>
4330 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
4332 __sv_type __sv = __svt;
4333 return append(__sv.data()
4334 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
4335 std::__sv_limit(__sv.size(), __pos, __n));
4346 const size_type __len = 1 + this->
size();
4347 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
4349 traits_type::assign(_M_data()[this->
size()], __c);
4350 _M_rep()->_M_set_length_and_sharable(__len);
4361 #if __cplusplus >= 201103L
4394 {
return this->
assign(__str._M_data()
4395 + __str._M_check(__pos,
"basic_string::assign"),
4396 __str._M_limit(__pos, __n)); }
4409 assign(
const _CharT* __s, size_type __n);
4423 __glibcxx_requires_string(__s);
4424 return this->
assign(__s, traits_type::length(__s));
4438 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4448 template<
class _InputIterator>
4450 assign(_InputIterator __first, _InputIterator __last)
4451 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4453 #if __cplusplus >= 201103L
4461 {
return this->
assign(__l.begin(), __l.size()); }
4464 #if __cplusplus >= 201703L
4470 template<
typename _Tp>
4471 _If_sv<_Tp, basic_string&>
4474 __sv_type __sv = __svt;
4475 return this->
assign(__sv.data(), __sv.size());
4485 template<
typename _Tp>
4486 _If_sv<_Tp, basic_string&>
4487 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
4489 __sv_type __sv = __svt;
4490 return assign(__sv.data()
4491 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
4492 std::__sv_limit(__sv.size(), __pos, __n));
4510 insert(iterator __p, size_type __n, _CharT __c)
4511 { this->
replace(__p, __p, __n, __c); }
4525 template<
class _InputIterator>
4527 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4528 { this->
replace(__p, __p, __beg, __end); }
4530 #if __cplusplus >= 201103L
4540 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4541 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4559 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4581 size_type __pos2, size_type __n =
npos)
4582 {
return this->
insert(__pos1, __str._M_data()
4583 + __str._M_check(__pos2,
"basic_string::insert"),
4584 __str._M_limit(__pos2, __n)); }
4603 insert(size_type __pos,
const _CharT* __s, size_type __n);
4623 __glibcxx_requires_string(__s);
4624 return this->
insert(__pos, __s, traits_type::length(__s));
4644 insert(size_type __pos, size_type __n, _CharT __c)
4645 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4646 size_type(0), __n, __c); }
4664 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4665 const size_type __pos = __p - _M_ibegin();
4666 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4667 _M_rep()->_M_set_leaked();
4668 return iterator(_M_data() + __pos);
4671 #if __cplusplus >= 201703L
4678 template<
typename _Tp>
4679 _If_sv<_Tp, basic_string&>
4680 insert(size_type __pos,
const _Tp& __svt)
4682 __sv_type __sv = __svt;
4683 return this->
insert(__pos, __sv.data(), __sv.size());
4694 template<
typename _Tp>
4695 _If_sv<_Tp, basic_string&>
4696 insert(size_type __pos1,
const _Tp& __svt,
4697 size_type __pos2, size_type __n =
npos)
4699 __sv_type __sv = __svt;
4700 return this->
replace(__pos1, size_type(0), __sv.data()
4701 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
4702 std::__sv_limit(__sv.size(), __pos2, __n));
4724 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4725 _M_limit(__pos, __n), size_type(0));
4740 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4741 && __position < _M_iend());
4742 const size_type __pos = __position - _M_ibegin();
4743 _M_mutate(__pos, size_type(1), size_type(0));
4744 _M_rep()->_M_set_leaked();
4745 return iterator(_M_data() + __pos);
4760 #if __cplusplus >= 201103L
4769 __glibcxx_assert(!
empty());
4793 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4815 size_type __pos2, size_type __n2 =
npos)
4816 {
return this->
replace(__pos1, __n1, __str._M_data()
4817 + __str._M_check(__pos2,
"basic_string::replace"),
4818 __str._M_limit(__pos2, __n2)); }
4839 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4859 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4861 __glibcxx_requires_string(__s);
4862 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4883 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4884 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4885 _M_limit(__pos, __n1), __n2, __c); }
4902 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4920 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4922 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4923 && __i2 <= _M_iend());
4924 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4941 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4943 __glibcxx_requires_string(__s);
4944 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4962 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4964 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4965 && __i2 <= _M_iend());
4966 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
4984 template<
class _InputIterator>
4987 _InputIterator __k1, _InputIterator __k2)
4989 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4990 && __i2 <= _M_iend());
4991 __glibcxx_requires_valid_range(__k1, __k2);
4992 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
4993 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
5001 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5002 && __i2 <= _M_iend());
5003 __glibcxx_requires_valid_range(__k1, __k2);
5004 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5009 replace(iterator __i1, iterator __i2,
5010 const _CharT* __k1,
const _CharT* __k2)
5012 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5013 && __i2 <= _M_iend());
5014 __glibcxx_requires_valid_range(__k1, __k2);
5015 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5020 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
5022 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5023 && __i2 <= _M_iend());
5024 __glibcxx_requires_valid_range(__k1, __k2);
5025 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5026 __k1.base(), __k2 - __k1);
5030 replace(iterator __i1, iterator __i2,
5031 const_iterator __k1, const_iterator __k2)
5033 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5034 && __i2 <= _M_iend());
5035 __glibcxx_requires_valid_range(__k1, __k2);
5036 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5037 __k1.base(), __k2 - __k1);
5040 #if __cplusplus >= 201103L
5057 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
5060 #if __cplusplus >= 201703L
5068 template<
typename _Tp>
5069 _If_sv<_Tp, basic_string&>
5070 replace(size_type __pos, size_type __n,
const _Tp& __svt)
5072 __sv_type __sv = __svt;
5073 return this->
replace(__pos, __n, __sv.data(), __sv.size());
5085 template<
typename _Tp>
5086 _If_sv<_Tp, basic_string&>
5087 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
5088 size_type __pos2, size_type __n2 =
npos)
5090 __sv_type __sv = __svt;
5091 return this->
replace(__pos1, __n1,
5093 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
5094 std::__sv_limit(__sv.size(), __pos2, __n2));
5106 template<
typename _Tp>
5107 _If_sv<_Tp, basic_string&>
5108 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
5110 __sv_type __sv = __svt;
5111 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
5116 template<
class _Integer>
5118 _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
5119 _Integer __val, __true_type)
5120 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
5122 template<
class _InputIterator>
5124 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
5125 _InputIterator __k2, __false_type);
5128 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
5132 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
5137 template<
class _InIterator>
5139 _S_construct_aux(_InIterator __beg, _InIterator __end,
5140 const _Alloc& __a, __false_type)
5142 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
5143 return _S_construct(__beg, __end, __a, _Tag());
5148 template<
class _Integer>
5150 _S_construct_aux(_Integer __beg, _Integer __end,
5151 const _Alloc& __a, __true_type)
5152 {
return _S_construct_aux_2(
static_cast<size_type
>(__beg),
5156 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
5157 {
return _S_construct(__req, __c, __a); }
5159 template<
class _InIterator>
5161 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
5163 typedef typename std::__is_integer<_InIterator>::__type _Integral;
5164 return _S_construct_aux(__beg, __end, __a, _Integral());
5168 template<
class _InIterator>
5170 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
5171 input_iterator_tag);
5175 template<
class _FwdIterator>
5177 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
5178 forward_iterator_tag);
5181 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
5198 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
5209 _GLIBCXX_NOEXCEPT_IF(allocator_traits<_Alloc>::is_always_equal::value);
5220 {
return _M_data(); }
5232 {
return _M_data(); }
5234 #if __cplusplus >= 201703L
5254 {
return _M_dataplus; }
5269 find(
const _CharT* __s, size_type __pos, size_type __n)
const
5285 {
return this->
find(__str.data(), __pos, __str.size()); }
5298 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
5300 __glibcxx_requires_string(__s);
5301 return this->
find(__s, __pos, traits_type::length(__s));
5315 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
5317 #if __cplusplus >= 201703L
5324 template<
typename _Tp>
5325 _If_sv<_Tp, size_type>
5326 find(
const _Tp& __svt, size_type __pos = 0) const
5327 noexcept(
is_same<_Tp, __sv_type>::value)
5329 __sv_type __sv = __svt;
5330 return this->
find(__sv.data(), __pos, __sv.size());
5347 {
return this->
rfind(__str.data(), __pos, __str.size()); }
5362 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const
5376 rfind(
const _CharT* __s, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT
5378 __glibcxx_requires_string(__s);
5379 return this->
rfind(__s, __pos, traits_type::length(__s));
5393 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
5395 #if __cplusplus >= 201703L
5402 template<
typename _Tp>
5403 _If_sv<_Tp, size_type>
5404 rfind(
const _Tp& __svt, size_type __pos =
npos)
const
5407 __sv_type __sv = __svt;
5408 return this->
rfind(__sv.data(), __pos, __sv.size());
5426 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
5441 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const
5458 __glibcxx_requires_string(__s);
5459 return this->
find_first_of(__s, __pos, traits_type::length(__s));
5476 {
return this->
find(__c, __pos); }
5478 #if __cplusplus >= 201703L
5486 template<
typename _Tp>
5487 _If_sv<_Tp, size_type>
5489 noexcept(
is_same<_Tp, __sv_type>::value)
5491 __sv_type __sv = __svt;
5492 return this->
find_first_of(__sv.data(), __pos, __sv.size());
5510 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5525 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const
5542 __glibcxx_requires_string(__s);
5543 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5560 {
return this->
rfind(__c, __pos); }
5562 #if __cplusplus >= 201703L
5570 template<
typename _Tp>
5571 _If_sv<_Tp, size_type>
5575 __sv_type __sv = __svt;
5576 return this->
find_last_of(__sv.data(), __pos, __sv.size());
5609 size_type __n)
const _GLIBCXX_NOEXCEPT;
5625 __glibcxx_requires_string(__s);
5643 #if __cplusplus >= 201703L
5651 template<
typename _Tp>
5652 _If_sv<_Tp, size_type>
5654 noexcept(
is_same<_Tp, __sv_type>::value)
5656 __sv_type __sv = __svt;
5691 size_type __n)
const _GLIBCXX_NOEXCEPT;
5707 __glibcxx_requires_string(__s);
5725 #if __cplusplus >= 201703L
5733 template<
typename _Tp>
5734 _If_sv<_Tp, size_type>
5738 __sv_type __sv = __svt;
5758 _M_check(__pos,
"basic_string::substr"), __n); }
5777 const size_type __size = this->
size();
5778 const size_type __osize = __str.size();
5779 const size_type __len =
std::min(__size, __osize);
5781 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5783 __r = _S_compare(__size, __osize);
5787 #if __cplusplus >= 201703L
5793 template<
typename _Tp>
5795 compare(
const _Tp& __svt)
const
5798 __sv_type __sv = __svt;
5799 const size_type __size = this->
size();
5800 const size_type __osize = __sv.size();
5801 const size_type __len =
std::min(__size, __osize);
5803 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
5805 __r = _S_compare(__size, __osize);
5817 template<
typename _Tp>
5819 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const
5820 noexcept(is_same<_Tp, __sv_type>::value)
5822 __sv_type __sv = __svt;
5823 return __sv_type(*this).substr(__pos, __n).compare(__sv);
5836 template<
typename _Tp>
5838 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
5839 size_type __pos2, size_type __n2 =
npos)
const
5840 noexcept(is_same<_Tp, __sv_type>::value)
5842 __sv_type __sv = __svt;
5843 return __sv_type(*
this)
5844 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
5895 size_type __pos2, size_type __n2 =
npos)
const;
5912 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5936 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5963 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5964 size_type __n2)
const;
5966 #if __cplusplus > 201703L
5968 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
5969 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5972 starts_with(_CharT __x)
const noexcept
5973 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5976 starts_with(
const _CharT* __x)
const noexcept
5977 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
5980 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
5981 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5984 ends_with(_CharT __x)
const noexcept
5985 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5988 ends_with(
const _CharT* __x)
const noexcept
5989 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
5992 # ifdef _GLIBCXX_TM_TS_INTERNAL
5994 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
5997 ::_txnal_cow_string_c_str(
const void *that);
5999 ::_txnal_cow_string_D1(
void *that);
6001 ::_txnal_cow_string_D1_commit(
void *that);
6006 #if __cpp_deduction_guides >= 201606
6007 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6008 template<
typename _InputIterator,
typename _CharT
6009 =
typename iterator_traits<_InputIterator>::value_type,
6010 typename _Allocator = allocator<_CharT>,
6011 typename = _RequireInputIter<_InputIterator>,
6012 typename = _RequireAllocator<_Allocator>>
6013 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
6014 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
6018 template<
typename _CharT,
typename _Traits,
6019 typename _Allocator = allocator<_CharT>,
6020 typename = _RequireAllocator<_Allocator>>
6021 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
6022 -> basic_string<_CharT, _Traits, _Allocator>;
6024 template<
typename _CharT,
typename _Traits,
6025 typename _Allocator = allocator<_CharT>,
6026 typename = _RequireAllocator<_Allocator>>
6027 basic_string(basic_string_view<_CharT, _Traits>,
6028 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6029 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6030 const _Allocator& = _Allocator())
6031 -> basic_string<_CharT, _Traits, _Allocator>;
6032 _GLIBCXX_END_NAMESPACE_CXX11
6042 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6043 basic_string<_CharT, _Traits, _Alloc>
6048 __str.append(__rhs);
6058 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6059 basic_string<_CharT,_Traits,_Alloc>
6061 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6069 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6070 basic_string<_CharT,_Traits,_Alloc>
6071 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6079 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6080 inline basic_string<_CharT, _Traits, _Alloc>
6082 const _CharT* __rhs)
6085 __str.append(__rhs);
6095 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6096 inline basic_string<_CharT, _Traits, _Alloc>
6100 typedef typename __string_type::size_type __size_type;
6101 __string_type __str(__lhs);
6102 __str.append(__size_type(1), __rhs);
6106 #if __cplusplus >= 201103L
6107 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6108 inline basic_string<_CharT, _Traits, _Alloc>
6109 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6110 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
6111 {
return std::move(__lhs.append(__rhs)); }
6113 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6114 inline basic_string<_CharT, _Traits, _Alloc>
6115 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6116 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6117 {
return std::move(__rhs.insert(0, __lhs)); }
6119 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6120 inline basic_string<_CharT, _Traits, _Alloc>
6121 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6122 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6124 #if _GLIBCXX_USE_CXX11_ABI
6125 using _Alloc_traits = allocator_traits<_Alloc>;
6126 bool __use_rhs =
false;
6127 if _GLIBCXX17_CONSTEXPR (
typename _Alloc_traits::is_always_equal{})
6129 else if (__lhs.get_allocator() == __rhs.get_allocator())
6134 const auto __size = __lhs.size() + __rhs.size();
6135 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
6136 return std::move(__rhs.insert(0, __lhs));
6141 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6142 inline basic_string<_CharT, _Traits, _Alloc>
6144 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6145 {
return std::move(__rhs.insert(0, __lhs)); }
6147 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6148 inline basic_string<_CharT, _Traits, _Alloc>
6150 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6151 {
return std::move(__rhs.insert(0, 1, __lhs)); }
6153 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6154 inline basic_string<_CharT, _Traits, _Alloc>
6155 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6156 const _CharT* __rhs)
6157 {
return std::move(__lhs.append(__rhs)); }
6159 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6160 inline basic_string<_CharT, _Traits, _Alloc>
6161 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6163 {
return std::move(__lhs.append(1, __rhs)); }
6173 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6178 {
return __lhs.compare(__rhs) == 0; }
6180 template<
typename _CharT>
6182 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
6183 operator==(
const basic_string<_CharT>& __lhs,
6184 const basic_string<_CharT>& __rhs) _GLIBCXX_NOEXCEPT
6185 {
return (__lhs.size() == __rhs.size()
6195 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6198 const _CharT* __rhs)
6199 {
return __lhs.compare(__rhs) == 0; }
6201 #if __cpp_lib_three_way_comparison
6209 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6211 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6212 const basic_string<_CharT, _Traits, _Alloc>& __rhs) noexcept
6213 -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
6214 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
6223 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6225 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6226 const _CharT* __rhs) noexcept
6227 -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
6228 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
6236 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6238 operator==(
const _CharT* __lhs,
6240 {
return __rhs.compare(__lhs) == 0; }
6249 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6254 {
return !(__lhs == __rhs); }
6262 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6264 operator!=(
const _CharT* __lhs,
6266 {
return !(__lhs == __rhs); }
6274 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6277 const _CharT* __rhs)
6278 {
return !(__lhs == __rhs); }
6287 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6292 {
return __lhs.compare(__rhs) < 0; }
6300 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6303 const _CharT* __rhs)
6304 {
return __lhs.compare(__rhs) < 0; }
6312 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6314 operator<(
const _CharT* __lhs,
6316 {
return __rhs.compare(__lhs) > 0; }
6325 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6330 {
return __lhs.compare(__rhs) > 0; }
6338 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6341 const _CharT* __rhs)
6342 {
return __lhs.compare(__rhs) > 0; }
6350 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6352 operator>(
const _CharT* __lhs,
6354 {
return __rhs.compare(__lhs) < 0; }
6363 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6368 {
return __lhs.compare(__rhs) <= 0; }
6376 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6379 const _CharT* __rhs)
6380 {
return __lhs.compare(__rhs) <= 0; }
6388 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6390 operator<=(
const _CharT* __lhs,
6392 {
return __rhs.compare(__lhs) >= 0; }
6401 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6406 {
return __lhs.compare(__rhs) >= 0; }
6414 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6417 const _CharT* __rhs)
6418 {
return __lhs.compare(__rhs) >= 0; }
6426 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6428 operator>=(
const _CharT* __lhs,
6430 {
return __rhs.compare(__lhs) <= 0; }
6440 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6444 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
6445 { __lhs.swap(__rhs); }
6460 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6461 basic_istream<_CharT, _Traits>&
6462 operator>>(basic_istream<_CharT, _Traits>& __is,
6463 basic_string<_CharT, _Traits, _Alloc>& __str);
6466 basic_istream<char>&
6478 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6485 return __ostream_insert(__os, __str.data(), __str.size());
6501 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6502 basic_istream<_CharT, _Traits>&
6503 getline(basic_istream<_CharT, _Traits>& __is,
6504 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
6518 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6519 inline basic_istream<_CharT, _Traits>&
6524 #if __cplusplus >= 201103L
6526 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6527 inline basic_istream<_CharT, _Traits>&
6533 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6534 inline basic_istream<_CharT, _Traits>&
6541 basic_istream<char>&
6542 getline(basic_istream<char>& __in, basic_string<char>& __str,
6545 #ifdef _GLIBCXX_USE_WCHAR_T
6547 basic_istream<wchar_t>&
6548 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
6552 _GLIBCXX_END_NAMESPACE_VERSION
6555 #if __cplusplus >= 201103L
6560 namespace std _GLIBCXX_VISIBILITY(default)
6562 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6563 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6565 #if _GLIBCXX_USE_C99_STDLIB
6568 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6569 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
6573 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6574 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
6577 inline unsigned long
6578 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6579 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
6583 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6584 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
6587 inline unsigned long long
6588 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6589 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
6594 stof(
const string& __str,
size_t* __idx = 0)
6595 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
6598 stod(
const string& __str,
size_t* __idx = 0)
6599 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
6602 stold(
const string& __str,
size_t* __idx = 0)
6603 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
6609 to_string(
int __val)
6611 const bool __neg = __val < 0;
6612 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
6613 const auto __len = __detail::__to_chars_len(__uval);
6614 string __str(__neg + __len,
'-');
6615 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
6620 to_string(
unsigned __val)
6622 string __str(__detail::__to_chars_len(__val),
'\0');
6623 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
6628 to_string(
long __val)
6630 const bool __neg = __val < 0;
6631 const unsigned long __uval = __neg ? (
unsigned long)~__val + 1ul : __val;
6632 const auto __len = __detail::__to_chars_len(__uval);
6633 string __str(__neg + __len,
'-');
6634 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
6639 to_string(
unsigned long __val)
6641 string __str(__detail::__to_chars_len(__val),
'\0');
6642 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
6647 to_string(
long long __val)
6649 const bool __neg = __val < 0;
6650 const unsigned long long __uval
6651 = __neg ? (
unsigned long long)~__val + 1ull : __val;
6652 const auto __len = __detail::__to_chars_len(__uval);
6653 string __str(__neg + __len,
'-');
6654 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
6659 to_string(
unsigned long long __val)
6661 string __str(__detail::__to_chars_len(__val),
'\0');
6662 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
6666 #if _GLIBCXX_USE_C99_STDIO
6670 to_string(
float __val)
6673 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6674 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6679 to_string(
double __val)
6682 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6683 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6688 to_string(
long double __val)
6691 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6692 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6697 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
6699 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6700 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
6704 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6705 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
6708 inline unsigned long
6709 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6710 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
6714 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6715 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
6718 inline unsigned long long
6719 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6720 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
6725 stof(
const wstring& __str,
size_t* __idx = 0)
6726 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
6729 stod(
const wstring& __str,
size_t* __idx = 0)
6730 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
6733 stold(
const wstring& __str,
size_t* __idx = 0)
6734 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
6736 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF
6739 to_wstring(
int __val)
6740 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
int),
6744 to_wstring(
unsigned __val)
6745 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6746 4 *
sizeof(
unsigned),
6750 to_wstring(
long __val)
6751 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(
long),
6755 to_wstring(
unsigned long __val)
6756 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6757 4 *
sizeof(
unsigned long),
6761 to_wstring(
long long __val)
6762 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6763 4 *
sizeof(
long long),
6767 to_wstring(
unsigned long long __val)
6768 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6769 4 *
sizeof(
unsigned long long),
6773 to_wstring(
float __val)
6776 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6777 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6782 to_wstring(
double __val)
6785 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6786 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6791 to_wstring(
long double __val)
6794 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6795 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6801 _GLIBCXX_END_NAMESPACE_CXX11
6802 _GLIBCXX_END_NAMESPACE_VERSION
6807 #if __cplusplus >= 201103L
6811 namespace std _GLIBCXX_VISIBILITY(default)
6813 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6817 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X
6821 :
public __hash_base<size_t, string>
6824 operator()(
const string& __s)
const noexcept
6825 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
6832 #ifdef _GLIBCXX_USE_WCHAR_T
6836 :
public __hash_base<size_t, wstring>
6839 operator()(
const wstring& __s)
const noexcept
6840 {
return std::_Hash_impl::hash(__s.
data(),
6841 __s.
length() *
sizeof(
wchar_t)); }
6850 #ifdef _GLIBCXX_USE_CHAR8_T
6853 struct hash<u8string>
6854 :
public __hash_base<size_t, u8string>
6857 operator()(
const u8string& __s)
const noexcept
6858 {
return std::_Hash_impl::hash(__s.data(),
6859 __s.length() *
sizeof(char8_t)); }
6870 :
public __hash_base<size_t, u16string>
6873 operator()(
const u16string& __s)
const noexcept
6874 {
return std::_Hash_impl::hash(__s.
data(),
6875 __s.
length() *
sizeof(char16_t)); }
6885 :
public __hash_base<size_t, u32string>
6888 operator()(
const u32string& __s)
const noexcept
6889 {
return std::_Hash_impl::hash(__s.
data(),
6890 __s.
length() *
sizeof(char32_t)); }
6897 #if __cplusplus >= 201402L
6899 #define __cpp_lib_string_udls 201304
6901 inline namespace literals
6903 inline namespace string_literals
6905 #pragma GCC diagnostic push
6906 #pragma GCC diagnostic ignored "-Wliteral-suffix"
6907 _GLIBCXX_DEFAULT_ABI_TAG
6908 inline basic_string<char>
6909 operator""s(
const char* __str,
size_t __len)
6910 {
return basic_string<char>{__str, __len}; }
6912 #ifdef _GLIBCXX_USE_WCHAR_T
6913 _GLIBCXX_DEFAULT_ABI_TAG
6914 inline basic_string<wchar_t>
6915 operator""s(
const wchar_t* __str,
size_t __len)
6916 {
return basic_string<wchar_t>{__str, __len}; }
6919 #ifdef _GLIBCXX_USE_CHAR8_T
6920 _GLIBCXX_DEFAULT_ABI_TAG
6921 inline basic_string<char8_t>
6922 operator""s(
const char8_t* __str,
size_t __len)
6923 {
return basic_string<char8_t>{__str, __len}; }
6926 _GLIBCXX_DEFAULT_ABI_TAG
6927 inline basic_string<char16_t>
6928 operator""s(
const char16_t* __str,
size_t __len)
6929 {
return basic_string<char16_t>{__str, __len}; }
6931 _GLIBCXX_DEFAULT_ABI_TAG
6932 inline basic_string<char32_t>
6933 operator""s(
const char32_t* __str,
size_t __len)
6934 {
return basic_string<char32_t>{__str, __len}; }
6936 #pragma GCC diagnostic pop
6940 #if __cplusplus >= 201703L
6941 namespace __detail::__variant
6943 template<
typename>
struct _Never_valueless_alt;
6947 template<
typename _Tp,
typename _Traits,
typename _Alloc>
6948 struct _Never_valueless_alt<
std::basic_string<_Tp, _Traits, _Alloc>>
6950 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
6951 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
6958 _GLIBCXX_END_NAMESPACE_VERSION
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
basic_string< wchar_t > wstring
A string of wchar_t.
ISO C++ entities toplevel namespace is std.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
basic_istream< _CharT, _Traits > & getline(basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__str, _CharT __delim)
Read a line from stream into a string.
constexpr _Iterator __base(_Iterator __it)
char_type widen(char __c) const
Widens characters.
Template class basic_ostream.
Primary class template hash.
Uniform interface to all allocator types.
Managing sequences of characters and character-like objects.
const_reverse_iterator crbegin() const noexcept
void swap(basic_string &__s) noexcept(/*conditional */)
Swap contents with another string.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
void push_back(_CharT __c)
Append a single character.
const_iterator cend() const noexcept
size_type find(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s)
Replace range of characters with C string.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
size_type find_last_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character of C string.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
size_type rfind(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a C string.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
iterator erase(iterator __position)
Remove one character.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a string.
size_type find_last_not_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character not in string.
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
int compare(const basic_string &__str) const
Compare to a string.
void reserve(size_type __res_arg=0)
Attempt to preallocate enough memory for specified number of characters.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
const_reference front() const noexcept
size_type find_last_not_of(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a character not in C string.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
reverse_iterator rbegin()
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
void pop_back()
Remove the last character.
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
basic_string(basic_string &&__str) noexcept
Move construct string.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n=npos)
Insert a substring.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
basic_string & assign(basic_string &&__str) noexcept(allocator_traits< _Alloc >::is_always_equal::value)
Set value to contents of another string.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
const _CharT * data() const noexcept
Return const pointer to contents.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
const_reference at(size_type __n) const
Provides access to the data contained in the string.
const_reference back() const noexcept
const_reverse_iterator rend() const noexcept
const_iterator end() const noexcept
basic_string & operator+=(_CharT __c)
Append a character.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
basic_string & append(const basic_string &__str)
Append a string to this string.
const_iterator begin() const noexcept
const_reverse_iterator crend() const noexcept
void resize(size_type __n)
Resizes the string to the specified number of characters.
const_reverse_iterator rbegin() const noexcept
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
basic_string & operator=(basic_string &&__str) noexcept(/*conditional */)
Move assign the value of str to this string.
size_type find_first_of(_CharT __c, size_type __pos=0) const noexcept
Find position of a character.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
bool empty() const noexcept
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
static const size_type npos
Value returned by various member functions when they fail.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
const_iterator cbegin() const noexcept
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with string.
~basic_string() noexcept
Destroy the string instance.
size_type capacity() const noexcept
basic_string & operator+=(const _CharT *__s)
Append a C string.
basic_string() noexcept
Default constructor creates an empty string.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character of C string.
basic_string & replace(size_type __pos1, size_type __n1, const basic_string &__str, size_type __pos2, size_type __n2=npos)
Replace characters with value from another string.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
basic_string(const _CharT *__s, const _Alloc &__a=_Alloc())
Construct string as copy of a C string.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n=npos)
Set value to a substring of a string.
basic_string & append(const _CharT *__s)
Append a C string.
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character not in C string.
reference at(size_type __n)
Provides access to the data contained in the string.
iterator insert(iterator __p, _CharT __c)
Insert one character.
Basis for explicit traits specializations.
Uniform interface to all pointer-like types.
Forward iterators support a superset of input iterator operations.
Uniform interface to C++98 and C++11 allocators.