34 #ifndef _BASIC_STRING_H 35 #define _BASIC_STRING_H 1 37 #pragma GCC system_header 43 #if __cplusplus >= 201103L 47 #if __cplusplus >= 201703L 51 namespace std _GLIBCXX_VISIBILITY(default)
53 _GLIBCXX_BEGIN_NAMESPACE_VERSION
55 #if __cplusplus == 201703L 57 # define __cpp_lib_constexpr_string 201611L 58 #elif __cplusplus > 201703L 60 # define __cpp_lib_constexpr_string 201811L 63 #if _GLIBCXX_USE_CXX11_ABI 64 _GLIBCXX_BEGIN_NAMESPACE_CXX11
83 template<
typename _CharT,
typename _Traits,
typename _Alloc>
87 rebind<_CharT>::other _Char_alloc_type;
92 typedef _Traits traits_type;
93 typedef typename _Traits::char_type value_type;
94 typedef _Char_alloc_type allocator_type;
95 typedef typename _Alloc_traits::size_type size_type;
96 typedef typename _Alloc_traits::difference_type difference_type;
97 typedef typename _Alloc_traits::reference reference;
98 typedef typename _Alloc_traits::const_reference const_reference;
99 typedef typename _Alloc_traits::pointer pointer;
100 typedef typename _Alloc_traits::const_pointer const_pointer;
101 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
102 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
108 static const size_type
npos =
static_cast<size_type
>(-1);
112 #if __cplusplus < 201103L 113 typedef iterator __const_iterator;
115 typedef const_iterator __const_iterator;
119 #if __cplusplus >= 201703L 121 typedef basic_string_view<_CharT, _Traits> __sv_type;
123 template<
typename _Tp,
typename _Res>
125 __and_<is_convertible<const _Tp&, __sv_type>,
126 __not_<is_convertible<const _Tp*, const basic_string*>>,
127 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
132 _S_to_string_view(__sv_type __svt) noexcept
141 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
157 struct _Alloc_hider : allocator_type
159 #if __cplusplus < 201103L 160 _Alloc_hider(pointer __dat,
const _Alloc& __a = _Alloc())
161 : allocator_type(__a), _M_p(__dat) { }
163 _Alloc_hider(pointer __dat,
const _Alloc& __a)
164 : allocator_type(__a), _M_p(__dat) { }
166 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
167 : allocator_type(
std::
move(__a)), _M_p(__dat) { }
173 _Alloc_hider _M_dataplus;
174 size_type _M_string_length;
176 enum { _S_local_capacity = 15 /
sizeof(_CharT) };
180 _CharT _M_local_buf[_S_local_capacity + 1];
181 size_type _M_allocated_capacity;
186 { _M_dataplus._M_p = __p; }
189 _M_length(size_type __length)
190 { _M_string_length = __length; }
194 {
return _M_dataplus._M_p; }
199 #if __cplusplus >= 201103L 202 return pointer(_M_local_buf);
207 _M_local_data()
const 209 #if __cplusplus >= 201103L 212 return const_pointer(_M_local_buf);
217 _M_capacity(size_type __capacity)
218 { _M_allocated_capacity = __capacity; }
221 _M_set_length(size_type __n)
224 traits_type::assign(_M_data()[__n], _CharT());
229 {
return _M_data() == _M_local_data(); }
233 _M_create(size_type&, size_type);
239 _M_destroy(_M_allocated_capacity);
243 _M_destroy(size_type __size)
throw()
244 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
248 template<
typename _InIterator>
250 _M_construct_aux(_InIterator __beg, _InIterator __end,
253 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
254 _M_construct(__beg, __end, _Tag());
259 template<
typename _Integer>
261 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
262 { _M_construct_aux_2(static_cast<size_type>(__beg), __end); }
265 _M_construct_aux_2(size_type __req, _CharT __c)
266 { _M_construct(__req, __c); }
268 template<
typename _InIterator>
270 _M_construct(_InIterator __beg, _InIterator __end)
272 typedef typename std::__is_integer<_InIterator>::__type _Integral;
273 _M_construct_aux(__beg, __end, _Integral());
277 template<
typename _InIterator>
279 _M_construct(_InIterator __beg, _InIterator __end,
284 template<
typename _FwdIterator>
286 _M_construct(_FwdIterator __beg, _FwdIterator __end,
290 _M_construct(size_type __req, _CharT __c);
294 {
return _M_dataplus; }
296 const allocator_type&
297 _M_get_allocator()
const 298 {
return _M_dataplus; }
302 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 305 template<
typename _Tp,
bool _Requires =
306 !__are_same<_Tp, _CharT*>::__value
307 && !__are_same<_Tp, const _CharT*>::__value
308 && !__are_same<_Tp, iterator>::__value
309 && !__are_same<_Tp, const_iterator>::__value>
310 struct __enable_if_not_native_iterator
312 template<
typename _Tp>
313 struct __enable_if_not_native_iterator<_Tp, false> { };
317 _M_check(size_type __pos,
const char* __s)
const 319 if (__pos > this->
size())
320 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 321 "this->size() (which is %zu)"),
322 __s, __pos, this->
size());
327 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 330 __throw_length_error(__N(__s));
336 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
338 const bool __testoff = __off < this->
size() - __pos;
339 return __testoff ? __off : this->
size() - __pos;
344 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
346 return (less<const _CharT*>()(__s, _M_data())
347 || less<const _CharT*>()(_M_data() + this->
size(), __s));
353 _S_copy(_CharT* __d,
const _CharT* __s, size_type __n)
356 traits_type::assign(*__d, *__s);
358 traits_type::copy(__d, __s, __n);
362 _S_move(_CharT* __d,
const _CharT* __s, size_type __n)
365 traits_type::assign(*__d, *__s);
371 _S_assign(_CharT* __d, size_type __n, _CharT __c)
374 traits_type::assign(*__d, __c);
376 traits_type::assign(__d, __n, __c);
381 template<
class _Iterator>
383 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
385 for (; __k1 != __k2; ++__k1, (void)++__p)
386 traits_type::assign(*__p, *__k1);
390 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
391 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
394 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
396 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
399 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
400 { _S_copy(__p, __k1, __k2 - __k1); }
403 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
405 { _S_copy(__p, __k1, __k2 - __k1); }
408 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
410 const difference_type __d = difference_type(__n1 - __n2);
412 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
413 return __gnu_cxx::__numeric_traits<int>::__max;
414 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
415 return __gnu_cxx::__numeric_traits<int>::__min;
424 _M_mutate(size_type __pos, size_type __len1,
const _CharT* __s,
428 _M_erase(size_type __pos, size_type __n);
439 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
440 : _M_dataplus(_M_local_data())
441 { _M_set_length(0); }
448 : _M_dataplus(_M_local_data(), __a)
449 { _M_set_length(0); }
456 : _M_dataplus(_M_local_data(),
457 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
458 { _M_construct(__str._M_data(), __str._M_data() + __str.length()); }
469 const _Alloc& __a = _Alloc())
470 : _M_dataplus(_M_local_data(), __a)
472 const _CharT* __start = __str._M_data()
473 + __str._M_check(__pos,
"basic_string::basic_string");
474 _M_construct(__start, __start + __str._M_limit(__pos,
npos));
485 : _M_dataplus(_M_local_data())
487 const _CharT* __start = __str._M_data()
488 + __str._M_check(__pos,
"basic_string::basic_string");
489 _M_construct(__start, __start + __str._M_limit(__pos, __n));
500 size_type __n,
const _Alloc& __a)
501 : _M_dataplus(_M_local_data(), __a)
503 const _CharT* __start
504 = __str._M_data() + __str._M_check(__pos,
"string::string");
505 _M_construct(__start, __start + __str._M_limit(__pos, __n));
518 const _Alloc& __a = _Alloc())
519 : _M_dataplus(_M_local_data(), __a)
520 { _M_construct(__s, __s + __n); }
527 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS 530 template<
typename = _RequireAllocator<_Alloc>>
532 basic_string(
const _CharT* __s,
const _Alloc& __a = _Alloc())
533 : _M_dataplus(_M_local_data(), __a)
535 const _CharT* __end = __s ? __s + traits_type::length(__s)
537 : reinterpret_cast<const _CharT*>(__alignof__(_CharT));
538 _M_construct(__s, __end, random_access_iterator_tag());
547 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS 550 template<
typename = _RequireAllocator<_Alloc>>
552 basic_string(size_type __n, _CharT __c,
const _Alloc& __a = _Alloc())
553 : _M_dataplus(_M_local_data(), __a)
554 { _M_construct(__n, __c); }
556 #if __cplusplus >= 201103L 565 : _M_dataplus(_M_local_data(),
std::move(__str._M_get_allocator()))
567 if (__str._M_is_local())
569 traits_type::copy(_M_local_buf, __str._M_local_buf,
570 _S_local_capacity + 1);
574 _M_data(__str._M_data());
575 _M_capacity(__str._M_allocated_capacity);
581 _M_length(__str.length());
582 __str._M_data(__str._M_local_data());
583 __str._M_set_length(0);
591 basic_string(initializer_list<_CharT> __l,
const _Alloc& __a = _Alloc())
592 : _M_dataplus(_M_local_data(), __a)
593 { _M_construct(__l.begin(), __l.end()); }
596 : _M_dataplus(_M_local_data(), __a)
597 { _M_construct(__str.begin(), __str.end()); }
600 noexcept(_Alloc_traits::_S_always_equal())
601 : _M_dataplus(_M_local_data(), __a)
603 if (__str._M_is_local())
605 traits_type::copy(_M_local_buf, __str._M_local_buf,
606 _S_local_capacity + 1);
607 _M_length(__str.length());
608 __str._M_set_length(0);
610 else if (_Alloc_traits::_S_always_equal()
611 || __str.get_allocator() == __a)
613 _M_data(__str._M_data());
614 _M_length(__str.length());
615 _M_capacity(__str._M_allocated_capacity);
616 __str._M_data(__str._M_local_buf);
617 __str._M_set_length(0);
620 _M_construct(__str.begin(), __str.end());
631 #if __cplusplus >= 201103L 632 template<
typename _InputIterator,
633 typename = std::_RequireInputIter<_InputIterator>>
635 template<
typename _InputIterator>
637 basic_string(_InputIterator __beg, _InputIterator __end,
638 const _Alloc& __a = _Alloc())
639 : _M_dataplus(_M_local_data(), __a)
640 { _M_construct(__beg, __end); }
642 #if __cplusplus >= 201703L 650 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
651 basic_string(
const _Tp& __t, size_type __pos, size_type __n,
652 const _Alloc& __a = _Alloc())
660 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
662 basic_string(
const _Tp& __t,
const _Alloc& __a = _Alloc())
663 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
679 return this->
assign(__str);
688 {
return this->
assign(__s); }
704 #if __cplusplus >= 201103L 716 noexcept(_Alloc_traits::_S_nothrow_move())
718 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
719 && !_Alloc_traits::_S_always_equal()
720 && _M_get_allocator() != __str._M_get_allocator())
723 _M_destroy(_M_allocated_capacity);
724 _M_data(_M_local_data());
728 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
730 if (__str._M_is_local())
738 this->_S_copy(_M_data(), __str._M_data(), __str.size());
739 _M_set_length(__str.size());
742 else if (_Alloc_traits::_S_propagate_on_move_assign()
743 || _Alloc_traits::_S_always_equal()
744 || _M_get_allocator() == __str._M_get_allocator())
747 pointer __data =
nullptr;
748 size_type __capacity;
751 if (_Alloc_traits::_S_always_equal())
755 __capacity = _M_allocated_capacity;
758 _M_destroy(_M_allocated_capacity);
761 _M_data(__str._M_data());
762 _M_length(__str.length());
763 _M_capacity(__str._M_allocated_capacity);
766 __str._M_data(__data);
767 __str._M_capacity(__capacity);
770 __str._M_data(__str._M_local_buf);
785 this->
assign(__l.begin(), __l.size());
790 #if __cplusplus >= 201703L 795 template<
typename _Tp>
796 _If_sv<_Tp, basic_string&>
798 {
return this->
assign(__svt); }
804 operator __sv_type() const noexcept
805 {
return __sv_type(
data(),
size()); }
814 begin() _GLIBCXX_NOEXCEPT
815 {
return iterator(_M_data()); }
822 begin() const _GLIBCXX_NOEXCEPT
823 {
return const_iterator(_M_data()); }
830 end() _GLIBCXX_NOEXCEPT
831 {
return iterator(_M_data() + this->
size()); }
838 end() const _GLIBCXX_NOEXCEPT
839 {
return const_iterator(_M_data() + this->
size()); }
847 rbegin() _GLIBCXX_NOEXCEPT
848 {
return reverse_iterator(this->
end()); }
855 const_reverse_iterator
856 rbegin() const _GLIBCXX_NOEXCEPT
857 {
return const_reverse_iterator(this->
end()); }
865 rend() _GLIBCXX_NOEXCEPT
866 {
return reverse_iterator(this->
begin()); }
873 const_reverse_iterator
874 rend() const _GLIBCXX_NOEXCEPT
875 {
return const_reverse_iterator(this->
begin()); }
877 #if __cplusplus >= 201103L 884 {
return const_iterator(this->_M_data()); }
891 cend() const noexcept
892 {
return const_iterator(this->_M_data() + this->
size()); }
899 const_reverse_iterator
901 {
return const_reverse_iterator(this->
end()); }
908 const_reverse_iterator
909 crend() const noexcept
910 {
return const_reverse_iterator(this->
begin()); }
918 size() const _GLIBCXX_NOEXCEPT
919 {
return _M_string_length; }
924 length() const _GLIBCXX_NOEXCEPT
925 {
return _M_string_length; }
930 {
return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
943 resize(size_type __n, _CharT __c);
957 { this->
resize(__n, _CharT()); }
959 #if __cplusplus >= 201103L 960 #pragma GCC diagnostic push 961 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 966 #pragma GCC diagnostic pop 976 return _M_is_local() ? size_type(_S_local_capacity)
977 : _M_allocated_capacity;
1003 #if __cplusplus > 201703L 1004 [[deprecated(
"use shrink_to_fit() instead")]]
1013 clear() _GLIBCXX_NOEXCEPT
1014 { _M_set_length(0); }
1020 _GLIBCXX_NODISCARD
bool 1021 empty() const _GLIBCXX_NOEXCEPT
1022 {
return this->
size() == 0; }
1036 operator[] (size_type __pos)
const _GLIBCXX_NOEXCEPT
1038 __glibcxx_assert(__pos <=
size());
1039 return _M_data()[__pos];
1057 __glibcxx_assert(__pos <=
size());
1059 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
1060 return _M_data()[__pos];
1074 at(size_type __n)
const 1076 if (__n >= this->
size())
1077 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 1078 "(which is %zu) >= this->size() " 1081 return _M_data()[__n];
1098 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 1099 "(which is %zu) >= this->size() " 1102 return _M_data()[__n];
1105 #if __cplusplus >= 201103L 1113 __glibcxx_assert(!
empty());
1122 front() const noexcept
1124 __glibcxx_assert(!
empty());
1135 __glibcxx_assert(!
empty());
1144 back() const noexcept
1146 __glibcxx_assert(!
empty());
1159 {
return this->
append(__str); }
1168 {
return this->
append(__s); }
1182 #if __cplusplus >= 201103L 1190 {
return this->
append(__l.begin(), __l.size()); }
1193 #if __cplusplus >= 201703L 1199 template<
typename _Tp>
1200 _If_sv<_Tp, basic_string&>
1202 {
return this->
append(__svt); }
1212 {
return _M_append(__str._M_data(), __str.size()); }
1229 {
return _M_append(__str._M_data()
1230 + __str._M_check(__pos,
"basic_string::append"),
1231 __str._M_limit(__pos, __n)); }
1240 append(
const _CharT* __s, size_type __n)
1242 __glibcxx_requires_string_len(__s, __n);
1243 _M_check_length(size_type(0), __n,
"basic_string::append");
1244 return _M_append(__s, __n);
1253 append(
const _CharT* __s)
1255 __glibcxx_requires_string(__s);
1256 const size_type __n = traits_type::length(__s);
1257 _M_check_length(size_type(0), __n,
"basic_string::append");
1258 return _M_append(__s, __n);
1270 append(size_type __n, _CharT __c)
1271 {
return _M_replace_aux(this->
size(), size_type(0), __n, __c); }
1273 #if __cplusplus >= 201103L 1280 append(initializer_list<_CharT> __l)
1281 {
return this->
append(__l.begin(), __l.size()); }
1292 #if __cplusplus >= 201103L 1293 template<
class _InputIterator,
1294 typename = std::_RequireInputIter<_InputIterator>>
1296 template<
class _InputIterator>
1299 append(_InputIterator __first, _InputIterator __last)
1302 #if __cplusplus >= 201703L 1308 template<
typename _Tp>
1309 _If_sv<_Tp, basic_string&>
1312 __sv_type __sv = __svt;
1313 return this->
append(__sv.data(), __sv.size());
1323 template<
typename _Tp>
1324 _If_sv<_Tp, basic_string&>
1325 append(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1327 __sv_type __sv = __svt;
1328 return _M_append(__sv.data()
1329 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
1330 std::__sv_limit(__sv.size(), __pos, __n));
1341 const size_type __size = this->
size();
1343 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1344 traits_type::assign(this->_M_data()[__size], __c);
1345 this->_M_set_length(__size + 1);
1356 #if __cplusplus >= 201103L 1357 if (_Alloc_traits::_S_propagate_on_copy_assign())
1359 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
1360 && _M_get_allocator() != __str._M_get_allocator())
1364 if (__str.size() <= _S_local_capacity)
1366 _M_destroy(_M_allocated_capacity);
1367 _M_data(_M_local_data());
1372 const auto __len = __str.size();
1373 auto __alloc = __str._M_get_allocator();
1375 auto __ptr = _Alloc_traits::allocate(__alloc, __len + 1);
1376 _M_destroy(_M_allocated_capacity);
1379 _M_set_length(__len);
1382 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
1385 this->_M_assign(__str);
1389 #if __cplusplus >= 201103L 1400 noexcept(_Alloc_traits::_S_nothrow_move())
1423 {
return _M_replace(size_type(0), this->
size(), __str._M_data()
1424 + __str._M_check(__pos,
"basic_string::assign"),
1425 __str._M_limit(__pos, __n)); }
1438 assign(
const _CharT* __s, size_type __n)
1440 __glibcxx_requires_string_len(__s, __n);
1441 return _M_replace(size_type(0), this->
size(), __s, __n);
1454 assign(
const _CharT* __s)
1456 __glibcxx_requires_string(__s);
1457 return _M_replace(size_type(0), this->
size(), __s,
1458 traits_type::length(__s));
1471 assign(size_type __n, _CharT __c)
1472 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
1482 #if __cplusplus >= 201103L 1483 template<
class _InputIterator,
1484 typename = std::_RequireInputIter<_InputIterator>>
1486 template<
class _InputIterator>
1489 assign(_InputIterator __first, _InputIterator __last)
1492 #if __cplusplus >= 201103L 1499 assign(initializer_list<_CharT> __l)
1500 {
return this->
assign(__l.begin(), __l.size()); }
1503 #if __cplusplus >= 201703L 1509 template<
typename _Tp>
1510 _If_sv<_Tp, basic_string&>
1513 __sv_type __sv = __svt;
1514 return this->
assign(__sv.data(), __sv.size());
1524 template<
typename _Tp>
1525 _If_sv<_Tp, basic_string&>
1526 assign(
const _Tp& __svt, size_type __pos, size_type __n =
npos)
1528 __sv_type __sv = __svt;
1529 return _M_replace(size_type(0), this->
size(),
1531 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
1532 std::__sv_limit(__sv.size(), __pos, __n));
1536 #if __cplusplus >= 201103L 1553 insert(const_iterator __p, size_type __n, _CharT __c)
1555 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1556 const size_type __pos = __p -
begin();
1557 this->
replace(__p, __p, __n, __c);
1558 return iterator(this->_M_data() + __pos);
1575 insert(iterator __p, size_type __n, _CharT __c)
1576 { this->
replace(__p, __p, __n, __c); }
1579 #if __cplusplus >= 201103L 1594 template<
class _InputIterator,
1595 typename = std::_RequireInputIter<_InputIterator>>
1597 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1599 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1600 const size_type __pos = __p -
begin();
1601 this->
replace(__p, __p, __beg, __end);
1602 return iterator(this->_M_data() + __pos);
1617 template<
class _InputIterator>
1619 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1620 { this->
replace(__p, __p, __beg, __end); }
1623 #if __cplusplus >= 201103L 1631 insert(const_iterator __p, initializer_list<_CharT> __l)
1632 {
return this->
insert(__p, __l.begin(), __l.end()); }
1634 #ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS 1637 insert(iterator __p, initializer_list<_CharT> __l)
1639 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1640 this->
insert(__p -
begin(), __l.begin(), __l.size());
1659 {
return this->
replace(__pos1, size_type(0),
1660 __str._M_data(), __str.size()); }
1682 size_type __pos2, size_type __n =
npos)
1683 {
return this->
replace(__pos1, size_type(0), __str._M_data()
1684 + __str._M_check(__pos2,
"basic_string::insert"),
1685 __str._M_limit(__pos2, __n)); }
1704 insert(size_type __pos,
const _CharT* __s, size_type __n)
1705 {
return this->
replace(__pos, size_type(0), __s, __n); }
1723 insert(size_type __pos,
const _CharT* __s)
1725 __glibcxx_requires_string(__s);
1726 return this->
replace(__pos, size_type(0), __s,
1727 traits_type::length(__s));
1747 insert(size_type __pos, size_type __n, _CharT __c)
1748 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
1749 size_type(0), __n, __c); }
1765 insert(__const_iterator __p, _CharT __c)
1767 _GLIBCXX_DEBUG_PEDASSERT(__p >=
begin() && __p <=
end());
1768 const size_type __pos = __p -
begin();
1769 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
1770 return iterator(_M_data() + __pos);
1773 #if __cplusplus >= 201703L 1780 template<
typename _Tp>
1781 _If_sv<_Tp, basic_string&>
1782 insert(size_type __pos,
const _Tp& __svt)
1784 __sv_type __sv = __svt;
1785 return this->
insert(__pos, __sv.data(), __sv.size());
1796 template<
typename _Tp>
1797 _If_sv<_Tp, basic_string&>
1798 insert(size_type __pos1,
const _Tp& __svt,
1799 size_type __pos2, size_type __n =
npos)
1801 __sv_type __sv = __svt;
1802 return this->
replace(__pos1, size_type(0),
1804 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
1805 std::__sv_limit(__sv.size(), __pos2, __n));
1825 erase(size_type __pos = 0, size_type __n =
npos)
1827 _M_check(__pos,
"basic_string::erase");
1829 this->_M_set_length(__pos);
1831 this->_M_erase(__pos, _M_limit(__pos, __n));
1844 erase(__const_iterator __position)
1846 _GLIBCXX_DEBUG_PEDASSERT(__position >=
begin()
1847 && __position <
end());
1848 const size_type __pos = __position -
begin();
1849 this->_M_erase(__pos, size_type(1));
1850 return iterator(_M_data() + __pos);
1863 erase(__const_iterator __first, __const_iterator __last)
1865 _GLIBCXX_DEBUG_PEDASSERT(__first >=
begin() && __first <= __last
1866 && __last <=
end());
1867 const size_type __pos = __first -
begin();
1868 if (__last ==
end())
1869 this->_M_set_length(__pos);
1871 this->_M_erase(__pos, __last - __first);
1872 return iterator(this->_M_data() + __pos);
1875 #if __cplusplus >= 201103L 1884 __glibcxx_assert(!
empty());
1885 _M_erase(
size() - 1, 1);
1908 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
1930 size_type __pos2, size_type __n2 =
npos)
1931 {
return this->
replace(__pos1, __n1, __str._M_data()
1932 + __str._M_check(__pos2,
"basic_string::replace"),
1933 __str._M_limit(__pos2, __n2)); }
1954 replace(size_type __pos, size_type __n1,
const _CharT* __s,
1957 __glibcxx_requires_string_len(__s, __n2);
1958 return _M_replace(_M_check(__pos,
"basic_string::replace"),
1959 _M_limit(__pos, __n1), __s, __n2);
1979 replace(size_type __pos, size_type __n1,
const _CharT* __s)
1981 __glibcxx_requires_string(__s);
1982 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
2003 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
2004 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
2005 _M_limit(__pos, __n1), __n2, __c); }
2021 replace(__const_iterator __i1, __const_iterator __i2,
2023 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
2041 replace(__const_iterator __i1, __const_iterator __i2,
2042 const _CharT* __s, size_type __n)
2044 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2046 return this->
replace(__i1 -
begin(), __i2 - __i1, __s, __n);
2063 replace(__const_iterator __i1, __const_iterator __i2,
const _CharT* __s)
2065 __glibcxx_requires_string(__s);
2066 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
2084 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2087 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2089 return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __c);
2107 #if __cplusplus >= 201103L 2108 template<
class _InputIterator,
2109 typename = std::_RequireInputIter<_InputIterator>>
2111 replace(const_iterator __i1, const_iterator __i2,
2112 _InputIterator __k1, _InputIterator __k2)
2114 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2116 __glibcxx_requires_valid_range(__k1, __k2);
2117 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2118 std::__false_type());
2121 template<
class _InputIterator>
2122 #ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST 2123 typename __enable_if_not_native_iterator<_InputIterator>::__type
2127 replace(iterator __i1, iterator __i2,
2128 _InputIterator __k1, _InputIterator __k2)
2130 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2132 __glibcxx_requires_valid_range(__k1, __k2);
2133 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2134 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2141 replace(__const_iterator __i1, __const_iterator __i2,
2142 _CharT* __k1, _CharT* __k2)
2144 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2146 __glibcxx_requires_valid_range(__k1, __k2);
2152 replace(__const_iterator __i1, __const_iterator __i2,
2153 const _CharT* __k1,
const _CharT* __k2)
2155 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2157 __glibcxx_requires_valid_range(__k1, __k2);
2163 replace(__const_iterator __i1, __const_iterator __i2,
2164 iterator __k1, iterator __k2)
2166 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2168 __glibcxx_requires_valid_range(__k1, __k2);
2170 __k1.base(), __k2 - __k1);
2174 replace(__const_iterator __i1, __const_iterator __i2,
2175 const_iterator __k1, const_iterator __k2)
2177 _GLIBCXX_DEBUG_PEDASSERT(
begin() <= __i1 && __i1 <= __i2
2179 __glibcxx_requires_valid_range(__k1, __k2);
2181 __k1.base(), __k2 - __k1);
2184 #if __cplusplus >= 201103L 2200 initializer_list<_CharT> __l)
2201 {
return this->
replace(__i1, __i2, __l.begin(), __l.size()); }
2204 #if __cplusplus >= 201703L 2212 template<
typename _Tp>
2213 _If_sv<_Tp, basic_string&>
2214 replace(size_type __pos, size_type __n,
const _Tp& __svt)
2216 __sv_type __sv = __svt;
2217 return this->
replace(__pos, __n, __sv.data(), __sv.size());
2229 template<
typename _Tp>
2230 _If_sv<_Tp, basic_string&>
2231 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
2232 size_type __pos2, size_type __n2 =
npos)
2234 __sv_type __sv = __svt;
2235 return this->
replace(__pos1, __n1,
2237 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
2238 std::__sv_limit(__sv.size(), __pos2, __n2));
2250 template<
typename _Tp>
2251 _If_sv<_Tp, basic_string&>
2252 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
2254 __sv_type __sv = __svt;
2255 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
2260 template<
class _Integer>
2262 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2263 _Integer __n, _Integer __val, __true_type)
2264 {
return _M_replace_aux(__i1 -
begin(), __i2 - __i1, __n, __val); }
2266 template<
class _InputIterator>
2268 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2269 _InputIterator __k1, _InputIterator __k2,
2273 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2277 _M_replace(size_type __pos, size_type __len1,
const _CharT* __s,
2278 const size_type __len2);
2281 _M_append(
const _CharT* __s, size_type __n);
2298 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
2318 c_str() const _GLIBCXX_NOEXCEPT
2319 {
return _M_data(); }
2330 data() const _GLIBCXX_NOEXCEPT
2331 {
return _M_data(); }
2333 #if __cplusplus >= 201703L 2342 {
return _M_data(); }
2350 {
return _M_get_allocator(); }
2365 find(
const _CharT* __s, size_type __pos, size_type __n)
const 2381 {
return this->
find(__str.data(), __pos, __str.size()); }
2383 #if __cplusplus >= 201703L 2390 template<
typename _Tp>
2391 _If_sv<_Tp, size_type>
2392 find(
const _Tp& __svt, size_type __pos = 0) const
2393 noexcept(is_same<_Tp, __sv_type>::value)
2395 __sv_type __sv = __svt;
2396 return this->
find(__sv.data(), __pos, __sv.size());
2411 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2413 __glibcxx_requires_string(__s);
2414 return this->
find(__s, __pos, traits_type::length(__s));
2428 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2443 {
return this->
rfind(__str.data(), __pos, __str.size()); }
2445 #if __cplusplus >= 201703L 2452 template<
typename _Tp>
2453 _If_sv<_Tp, size_type>
2454 rfind(
const _Tp& __svt, size_type __pos =
npos)
const 2455 noexcept(is_same<_Tp, __sv_type>::value)
2457 __sv_type __sv = __svt;
2458 return this->
rfind(__sv.data(), __pos, __sv.size());
2475 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const 2489 rfind(
const _CharT* __s, size_type __pos =
npos)
const 2491 __glibcxx_requires_string(__s);
2492 return this->
rfind(__s, __pos, traits_type::length(__s));
2506 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
2522 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
2524 #if __cplusplus >= 201703L 2532 template<
typename _Tp>
2533 _If_sv<_Tp, size_type>
2535 noexcept(is_same<_Tp, __sv_type>::value)
2537 __sv_type __sv = __svt;
2538 return this->
find_first_of(__sv.data(), __pos, __sv.size());
2555 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const 2572 __glibcxx_requires_string(__s);
2573 return this->
find_first_of(__s, __pos, traits_type::length(__s));
2589 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2590 {
return this->
find(__c, __pos); }
2606 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
2608 #if __cplusplus >= 201703L 2616 template<
typename _Tp>
2617 _If_sv<_Tp, size_type>
2619 noexcept(is_same<_Tp, __sv_type>::value)
2621 __sv_type __sv = __svt;
2622 return this->
find_last_of(__sv.data(), __pos, __sv.size());
2639 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const 2656 __glibcxx_requires_string(__s);
2657 return this->
find_last_of(__s, __pos, traits_type::length(__s));
2674 {
return this->
rfind(__c, __pos); }
2691 #if __cplusplus >= 201703L 2699 template<
typename _Tp>
2700 _If_sv<_Tp, size_type>
2702 noexcept(is_same<_Tp, __sv_type>::value)
2704 __sv_type __sv = __svt;
2723 size_type __n)
const _GLIBCXX_NOEXCEPT;
2739 __glibcxx_requires_string(__s);
2773 #if __cplusplus >= 201703L 2781 template<
typename _Tp>
2782 _If_sv<_Tp, size_type>
2784 noexcept(is_same<_Tp, __sv_type>::value)
2786 __sv_type __sv = __svt;
2805 size_type __n)
const _GLIBCXX_NOEXCEPT;
2821 __glibcxx_requires_string(__s);
2852 substr(size_type __pos = 0, size_type __n =
npos)
const 2854 _M_check(__pos,
"basic_string::substr"), __n); }
2873 const size_type __size = this->
size();
2874 const size_type __osize = __str.size();
2875 const size_type __len =
std::min(__size, __osize);
2877 int __r = traits_type::compare(_M_data(), __str.data(), __len);
2879 __r = _S_compare(__size, __osize);
2883 #if __cplusplus >= 201703L 2889 template<
typename _Tp>
2891 compare(
const _Tp& __svt)
const 2892 noexcept(is_same<_Tp, __sv_type>::value)
2894 __sv_type __sv = __svt;
2895 const size_type __size = this->
size();
2896 const size_type __osize = __sv.size();
2897 const size_type __len =
std::min(__size, __osize);
2899 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
2901 __r = _S_compare(__size, __osize);
2913 template<
typename _Tp>
2915 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const 2916 noexcept(is_same<_Tp, __sv_type>::value)
2918 __sv_type __sv = __svt;
2919 return __sv_type(*this).substr(__pos, __n).compare(__sv);
2932 template<
typename _Tp>
2934 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
2935 size_type __pos2, size_type __n2 =
npos)
const 2936 noexcept(is_same<_Tp, __sv_type>::value)
2938 __sv_type __sv = __svt;
2939 return __sv_type(*
this)
2940 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
2991 size_type __pos2, size_type __n2 =
npos)
const;
3008 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
3032 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
3059 compare(size_type __pos, size_type __n1,
const _CharT* __s,
3060 size_type __n2)
const;
3062 #if __cplusplus > 201703L 3064 starts_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3065 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3068 starts_with(_CharT __x)
const noexcept
3069 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3072 starts_with(
const _CharT* __x)
const noexcept
3073 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
3076 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
3077 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3080 ends_with(_CharT __x)
const noexcept
3081 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3084 ends_with(
const _CharT* __x)
const noexcept
3085 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
3088 #if __cplusplus > 202002L 3090 contains(basic_string_view<_CharT, _Traits> __x)
const noexcept
3091 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3094 contains(_CharT __x)
const noexcept
3095 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3098 contains(
const _CharT* __x)
const noexcept
3099 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
3103 template<
typename,
typename,
typename>
friend class basic_stringbuf;
3105 _GLIBCXX_END_NAMESPACE_CXX11
3106 #else // !_GLIBCXX_USE_CXX11_ABI 3171 template<
typename _CharT,
typename _Traits,
typename _Alloc>
3175 rebind<_CharT>::other _CharT_alloc_type;
3180 typedef _Traits traits_type;
3181 typedef typename _Traits::char_type value_type;
3182 typedef _Alloc allocator_type;
3183 typedef typename _CharT_alloc_traits::size_type size_type;
3184 typedef typename _CharT_alloc_traits::difference_type difference_type;
3185 #if __cplusplus < 201103L 3186 typedef typename _CharT_alloc_type::reference reference;
3187 typedef typename _CharT_alloc_type::const_reference const_reference;
3189 typedef value_type& reference;
3190 typedef const value_type& const_reference;
3192 typedef typename _CharT_alloc_traits::pointer pointer;
3193 typedef typename _CharT_alloc_traits::const_pointer const_pointer;
3194 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
3195 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
3202 typedef iterator __const_iterator;
3221 size_type _M_length;
3222 size_type _M_capacity;
3223 _Atomic_word _M_refcount;
3226 struct _Rep : _Rep_base
3230 rebind<char>::other _Raw_bytes_alloc;
3245 static const size_type _S_max_size;
3246 static const _CharT _S_terminal;
3250 static size_type _S_empty_rep_storage[];
3253 _S_empty_rep() _GLIBCXX_NOEXCEPT
3258 void* __p =
reinterpret_cast<void*
>(&_S_empty_rep_storage);
3259 return *
reinterpret_cast<_Rep*
>(__p);
3263 _M_is_leaked()
const _GLIBCXX_NOEXCEPT
3265 #if defined(__GTHREADS) 3270 return __atomic_load_n(&this->_M_refcount, __ATOMIC_RELAXED) < 0;
3272 return this->_M_refcount < 0;
3277 _M_is_shared()
const _GLIBCXX_NOEXCEPT
3279 #if defined(__GTHREADS) 3285 return __atomic_load_n(&this->_M_refcount, __ATOMIC_ACQUIRE) > 0;
3287 return this->_M_refcount > 0;
3292 _M_set_leaked() _GLIBCXX_NOEXCEPT
3293 { this->_M_refcount = -1; }
3296 _M_set_sharable() _GLIBCXX_NOEXCEPT
3297 { this->_M_refcount = 0; }
3300 _M_set_length_and_sharable(size_type __n) _GLIBCXX_NOEXCEPT
3302 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3303 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3306 this->_M_set_sharable();
3307 this->_M_length = __n;
3308 traits_type::assign(this->_M_refdata()[__n], _S_terminal);
3315 _M_refdata()
throw()
3316 {
return reinterpret_cast<_CharT*
>(
this + 1); }
3319 _M_grab(
const _Alloc& __alloc1,
const _Alloc& __alloc2)
3321 return (!_M_is_leaked() && __alloc1 == __alloc2)
3322 ? _M_refcopy() : _M_clone(__alloc1);
3327 _S_create(size_type, size_type,
const _Alloc&);
3330 _M_dispose(
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3332 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3333 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3337 _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(&this->_M_refcount);
3346 if (__gnu_cxx::__exchange_and_add_dispatch(&this->_M_refcount,
3349 _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(&this->_M_refcount);
3356 _M_destroy(
const _Alloc&)
throw();
3359 _M_refcopy()
throw()
3361 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3362 if (__builtin_expect(
this != &_S_empty_rep(),
false))
3364 __gnu_cxx::__atomic_add_dispatch(&this->_M_refcount, 1);
3365 return _M_refdata();
3369 _M_clone(
const _Alloc&, size_type __res = 0);
3373 struct _Alloc_hider : _Alloc
3375 _Alloc_hider(_CharT* __dat,
const _Alloc& __a) _GLIBCXX_NOEXCEPT
3376 : _Alloc(__a), _M_p(__dat) { }
3386 static const size_type
npos =
static_cast<size_type
>(-1);
3390 mutable _Alloc_hider _M_dataplus;
3393 _M_data() const _GLIBCXX_NOEXCEPT
3394 {
return _M_dataplus._M_p; }
3397 _M_data(_CharT* __p) _GLIBCXX_NOEXCEPT
3398 {
return (_M_dataplus._M_p = __p); }
3401 _M_rep() const _GLIBCXX_NOEXCEPT
3402 {
return &((
reinterpret_cast<_Rep*
> (_M_data()))[-1]); }
3407 _M_ibegin() const _GLIBCXX_NOEXCEPT
3408 {
return iterator(_M_data()); }
3411 _M_iend() const _GLIBCXX_NOEXCEPT
3412 {
return iterator(_M_data() + this->
size()); }
3417 if (!_M_rep()->_M_is_leaked())
3422 _M_check(size_type __pos,
const char* __s)
const 3424 if (__pos > this->
size())
3425 __throw_out_of_range_fmt(__N(
"%s: __pos (which is %zu) > " 3426 "this->size() (which is %zu)"),
3427 __s, __pos, this->
size());
3432 _M_check_length(size_type __n1, size_type __n2,
const char* __s)
const 3435 __throw_length_error(__N(__s));
3440 _M_limit(size_type __pos, size_type __off)
const _GLIBCXX_NOEXCEPT
3442 const bool __testoff = __off < this->
size() - __pos;
3443 return __testoff ? __off : this->
size() - __pos;
3448 _M_disjunct(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT
3450 return (less<const _CharT*>()(__s, _M_data())
3451 || less<const _CharT*>()(_M_data() + this->
size(), __s));
3457 _M_copy(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3460 traits_type::assign(*__d, *__s);
3462 traits_type::copy(__d, __s, __n);
3466 _M_move(_CharT* __d,
const _CharT* __s, size_type __n) _GLIBCXX_NOEXCEPT
3469 traits_type::assign(*__d, *__s);
3475 _M_assign(_CharT* __d, size_type __n, _CharT __c) _GLIBCXX_NOEXCEPT
3478 traits_type::assign(*__d, __c);
3480 traits_type::assign(__d, __n, __c);
3485 template<
class _Iterator>
3487 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
3489 for (; __k1 != __k2; ++__k1, (void)++__p)
3490 traits_type::assign(*__p, *__k1);
3494 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
3495 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3498 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
3500 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
3503 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
3504 { _M_copy(__p, __k1, __k2 - __k1); }
3507 _S_copy_chars(_CharT* __p,
const _CharT* __k1,
const _CharT* __k2)
3509 { _M_copy(__p, __k1, __k2 - __k1); }
3512 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
3514 const difference_type __d = difference_type(__n1 - __n2);
3516 if (__d > __gnu_cxx::__numeric_traits<int>::__max)
3517 return __gnu_cxx::__numeric_traits<int>::__max;
3518 else if (__d < __gnu_cxx::__numeric_traits<int>::__min)
3519 return __gnu_cxx::__numeric_traits<int>::__min;
3525 _M_mutate(size_type __pos, size_type __len1, size_type __len2);
3531 _S_empty_rep() _GLIBCXX_NOEXCEPT
3532 {
return _Rep::_S_empty_rep(); }
3534 #if __cplusplus >= 201703L 3536 typedef basic_string_view<_CharT, _Traits> __sv_type;
3538 template<
typename _Tp,
typename _Res>
3540 __and_<is_convertible<const _Tp&, __sv_type>,
3541 __not_<is_convertible<const _Tp*, const basic_string*>>,
3542 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
3547 _S_to_string_view(__sv_type __svt) noexcept
3556 explicit __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
3580 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3582 : _M_dataplus(_S_empty_rep()._M_refdata(), _Alloc())
3584 : _M_dataplus(_S_construct(size_type(), _CharT(), _Alloc()), _Alloc())
3593 : _M_dataplus(_S_construct(size_type(), _CharT(), __a), __a)
3602 : _M_dataplus(__str._M_rep()->_M_grab(_Alloc(__str.
get_allocator()),
3616 const _Alloc& __a = _Alloc());
3634 size_type __n,
const _Alloc& __a);
3646 const _Alloc& __a = _Alloc())
3647 : _M_dataplus(_S_construct(__s, __s + __n, __a), __a)
3655 #if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS 3658 template<
typename = _RequireAllocator<_Alloc>>
3661 : _M_dataplus(_S_construct(__s, __s ? __s + traits_type::
length(__s) :
3662 __s +
npos, __a), __a)
3672 : _M_dataplus(_S_construct(__n, __c, __a), __a)
3675 #if __cplusplus >= 201103L 3684 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3687 : _M_dataplus(
std::move(__str._M_dataplus))
3689 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3690 __str._M_data(_S_empty_rep()._M_refdata());
3692 __str._M_data(_S_construct(size_type(), _CharT(),
get_allocator()));
3702 : _M_dataplus(_S_construct(__l.
begin(), __l.
end(), __a), __a)
3706 : _M_dataplus(__str._M_rep()->_M_grab(__a, __str.
get_allocator()), __a)
3710 : _M_dataplus(__str._M_data(), __a)
3712 if (__a == __str.get_allocator())
3714 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 3715 __str._M_data(_S_empty_rep()._M_refdata());
3717 __str._M_data(_S_construct(size_type(), _CharT(), __a));
3721 _M_dataplus._M_p = _S_construct(__str.begin(), __str.end(), __a);
3731 template<
class _InputIterator>
3733 const _Alloc& __a = _Alloc())
3734 : _M_dataplus(_S_construct(__beg, __end, __a), __a)
3737 #if __cplusplus >= 201703L 3745 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3747 const _Alloc& __a = _Alloc())
3755 template<
typename _Tp,
typename = _If_sv<_Tp,
void>>
3758 :
basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
3773 {
return this->
assign(__str); }
3781 {
return this->
assign(__s); }
3797 #if __cplusplus >= 201103L 3821 this->
assign(__l.begin(), __l.size());
3826 #if __cplusplus >= 201703L 3831 template<
typename _Tp>
3832 _If_sv<_Tp, basic_string&>
3834 {
return this->
assign(__svt); }
3853 return iterator(_M_data());
3862 {
return const_iterator(_M_data()); }
3872 return iterator(_M_data() + this->
size());
3881 {
return const_iterator(_M_data() + this->
size()); }
3897 const_reverse_iterator
3915 const_reverse_iterator
3919 #if __cplusplus >= 201103L 3926 {
return const_iterator(this->_M_data()); }
3934 {
return const_iterator(this->_M_data() + this->
size()); }
3941 const_reverse_iterator
3950 const_reverse_iterator
3961 {
return _M_rep()->_M_length; }
3967 {
return _M_rep()->_M_length; }
3972 {
return _Rep::_S_max_size; }
3985 resize(size_type __n, _CharT __c);
3999 { this->
resize(__n, _CharT()); }
4001 #if __cplusplus >= 201103L 4002 #pragma GCC diagnostic push 4003 #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 4008 #pragma GCC diagnostic pop 4017 {
return _M_rep()->_M_capacity; }
4040 #if __cplusplus > 201703L 4041 [[deprecated(
"use shrink_to_fit() instead")]]
4049 #if _GLIBCXX_FULLY_DYNAMIC_STRING == 0 4053 if (_M_rep()->_M_is_shared())
4056 _M_data(_S_empty_rep()._M_refdata());
4059 _M_rep()->_M_set_length_and_sharable(0);
4065 { _M_mutate(0, this->
size(), 0); }
4072 _GLIBCXX_NODISCARD
bool 4074 {
return this->
size() == 0; }
4090 __glibcxx_assert(__pos <=
size());
4091 return _M_data()[__pos];
4109 __glibcxx_assert(__pos <=
size());
4111 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos <
size());
4113 return _M_data()[__pos];
4129 if (__n >= this->
size())
4130 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 4131 "(which is %zu) >= this->size() " 4134 return _M_data()[__n];
4152 __throw_out_of_range_fmt(__N(
"basic_string::at: __n " 4153 "(which is %zu) >= this->size() " 4157 return _M_data()[__n];
4160 #if __cplusplus >= 201103L 4168 __glibcxx_assert(!
empty());
4179 __glibcxx_assert(!
empty());
4190 __glibcxx_assert(!
empty());
4201 __glibcxx_assert(!
empty());
4214 {
return this->
append(__str); }
4223 {
return this->
append(__s); }
4237 #if __cplusplus >= 201103L 4245 {
return this->
append(__l.begin(), __l.size()); }
4248 #if __cplusplus >= 201703L 4254 template<
typename _Tp>
4255 _If_sv<_Tp, basic_string&>
4257 {
return this->
append(__svt); }
4291 append(
const _CharT* __s, size_type __n);
4301 __glibcxx_requires_string(__s);
4302 return this->
append(__s, traits_type::length(__s));
4314 append(size_type __n, _CharT __c);
4316 #if __cplusplus >= 201103L 4324 {
return this->
append(__l.begin(), __l.size()); }
4335 template<
class _InputIterator>
4337 append(_InputIterator __first, _InputIterator __last)
4338 {
return this->
replace(_M_iend(), _M_iend(), __first, __last); }
4340 #if __cplusplus >= 201703L 4346 template<
typename _Tp>
4347 _If_sv<_Tp, basic_string&>
4351 return this->
append(__sv.data(), __sv.size());
4362 template<
typename _Tp>
4363 _If_sv<_Tp, basic_string&>
4367 return append(__sv.data()
4368 + std::__sv_check(__sv.size(), __pos,
"basic_string::append"),
4369 std::__sv_limit(__sv.size(), __pos, __n));
4380 const size_type __len = 1 + this->
size();
4381 if (__len > this->
capacity() || _M_rep()->_M_is_shared())
4383 traits_type::assign(_M_data()[this->
size()], __c);
4384 _M_rep()->_M_set_length_and_sharable(__len);
4395 #if __cplusplus >= 201103L 4428 {
return this->
assign(__str._M_data()
4429 + __str._M_check(__pos,
"basic_string::assign"),
4430 __str._M_limit(__pos, __n)); }
4443 assign(
const _CharT* __s, size_type __n);
4457 __glibcxx_requires_string(__s);
4458 return this->
assign(__s, traits_type::length(__s));
4472 {
return _M_replace_aux(size_type(0), this->
size(), __n, __c); }
4482 template<
class _InputIterator>
4484 assign(_InputIterator __first, _InputIterator __last)
4485 {
return this->
replace(_M_ibegin(), _M_iend(), __first, __last); }
4487 #if __cplusplus >= 201103L 4495 {
return this->
assign(__l.begin(), __l.size()); }
4498 #if __cplusplus >= 201703L 4504 template<
typename _Tp>
4505 _If_sv<_Tp, basic_string&>
4509 return this->
assign(__sv.data(), __sv.size());
4519 template<
typename _Tp>
4520 _If_sv<_Tp, basic_string&>
4524 return assign(__sv.data()
4525 + std::__sv_check(__sv.size(), __pos,
"basic_string::assign"),
4526 std::__sv_limit(__sv.size(), __pos, __n));
4544 insert(iterator __p, size_type __n, _CharT __c)
4545 { this->
replace(__p, __p, __n, __c); }
4559 template<
class _InputIterator>
4561 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
4562 { this->
replace(__p, __p, __beg, __end); }
4564 #if __cplusplus >= 201103L 4574 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4575 this->
insert(__p - _M_ibegin(), __l.begin(), __l.size());
4593 {
return this->
insert(__pos1, __str, size_type(0), __str.size()); }
4615 size_type __pos2, size_type __n =
npos)
4616 {
return this->
insert(__pos1, __str._M_data()
4617 + __str._M_check(__pos2,
"basic_string::insert"),
4618 __str._M_limit(__pos2, __n)); }
4637 insert(size_type __pos,
const _CharT* __s, size_type __n);
4657 __glibcxx_requires_string(__s);
4658 return this->
insert(__pos, __s, traits_type::length(__s));
4678 insert(size_type __pos, size_type __n, _CharT __c)
4679 {
return _M_replace_aux(_M_check(__pos,
"basic_string::insert"),
4680 size_type(0), __n, __c); }
4698 _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
4699 const size_type __pos = __p - _M_ibegin();
4700 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
4701 _M_rep()->_M_set_leaked();
4702 return iterator(_M_data() + __pos);
4705 #if __cplusplus >= 201703L 4712 template<
typename _Tp>
4713 _If_sv<_Tp, basic_string&>
4717 return this->
insert(__pos, __sv.data(), __sv.size());
4728 template<
typename _Tp>
4729 _If_sv<_Tp, basic_string&>
4731 size_type __pos2, size_type __n =
npos)
4734 return this->
replace(__pos1, size_type(0), __sv.data()
4735 + std::__sv_check(__sv.size(), __pos2,
"basic_string::insert"),
4736 std::__sv_limit(__sv.size(), __pos2, __n));
4758 _M_mutate(_M_check(__pos,
"basic_string::erase"),
4759 _M_limit(__pos, __n), size_type(0));
4774 _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
4775 && __position < _M_iend());
4776 const size_type __pos = __position - _M_ibegin();
4777 _M_mutate(__pos, size_type(1), size_type(0));
4778 _M_rep()->_M_set_leaked();
4779 return iterator(_M_data() + __pos);
4794 #if __cplusplus >= 201103L 4803 __glibcxx_assert(!
empty());
4827 {
return this->
replace(__pos, __n, __str._M_data(), __str.size()); }
4849 size_type __pos2, size_type __n2 =
npos)
4850 {
return this->
replace(__pos1, __n1, __str._M_data()
4851 + __str._M_check(__pos2,
"basic_string::replace"),
4852 __str._M_limit(__pos2, __n2)); }
4873 replace(size_type __pos, size_type __n1,
const _CharT* __s,
4893 replace(size_type __pos, size_type __n1,
const _CharT* __s)
4895 __glibcxx_requires_string(__s);
4896 return this->
replace(__pos, __n1, __s, traits_type::length(__s));
4917 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
4918 {
return _M_replace_aux(_M_check(__pos,
"basic_string::replace"),
4919 _M_limit(__pos, __n1), __n2, __c); }
4936 {
return this->
replace(__i1, __i2, __str._M_data(), __str.size()); }
4954 replace(iterator __i1, iterator __i2,
const _CharT* __s, size_type __n)
4956 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4957 && __i2 <= _M_iend());
4958 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
4975 replace(iterator __i1, iterator __i2,
const _CharT* __s)
4977 __glibcxx_requires_string(__s);
4978 return this->
replace(__i1, __i2, __s, traits_type::length(__s));
4996 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
4998 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
4999 && __i2 <= _M_iend());
5000 return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
5018 template<
class _InputIterator>
5021 _InputIterator __k1, _InputIterator __k2)
5023 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5024 && __i2 <= _M_iend());
5025 __glibcxx_requires_valid_range(__k1, __k2);
5026 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
5027 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
5035 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5036 && __i2 <= _M_iend());
5037 __glibcxx_requires_valid_range(__k1, __k2);
5038 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5043 replace(iterator __i1, iterator __i2,
5044 const _CharT* __k1,
const _CharT* __k2)
5046 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5047 && __i2 <= _M_iend());
5048 __glibcxx_requires_valid_range(__k1, __k2);
5049 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5054 replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
5056 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5057 && __i2 <= _M_iend());
5058 __glibcxx_requires_valid_range(__k1, __k2);
5059 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5060 __k1.base(), __k2 - __k1);
5064 replace(iterator __i1, iterator __i2,
5065 const_iterator __k1, const_iterator __k2)
5067 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
5068 && __i2 <= _M_iend());
5069 __glibcxx_requires_valid_range(__k1, __k2);
5070 return this->
replace(__i1 - _M_ibegin(), __i2 - __i1,
5071 __k1.base(), __k2 - __k1);
5074 #if __cplusplus >= 201103L 5091 {
return this->
replace(__i1, __i2, __l.begin(), __l.end()); }
5094 #if __cplusplus >= 201703L 5102 template<
typename _Tp>
5103 _If_sv<_Tp, basic_string&>
5104 replace(size_type __pos, size_type __n,
const _Tp& __svt)
5107 return this->
replace(__pos, __n, __sv.data(), __sv.size());
5119 template<
typename _Tp>
5120 _If_sv<_Tp, basic_string&>
5121 replace(size_type __pos1, size_type __n1,
const _Tp& __svt,
5122 size_type __pos2, size_type __n2 =
npos)
5125 return this->
replace(__pos1, __n1,
5127 + std::__sv_check(__sv.size(), __pos2,
"basic_string::replace"),
5128 std::__sv_limit(__sv.size(), __pos2, __n2));
5140 template<
typename _Tp>
5141 _If_sv<_Tp, basic_string&>
5142 replace(const_iterator __i1, const_iterator __i2,
const _Tp& __svt)
5145 return this->
replace(__i1 -
begin(), __i2 - __i1, __sv);
5150 template<
class _Integer>
5153 _Integer __val, __true_type)
5154 {
return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
5156 template<
class _InputIterator>
5158 _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
5159 _InputIterator __k2, __false_type);
5162 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
5166 _M_replace_safe(size_type __pos1, size_type __n1,
const _CharT* __s,
5171 template<
class _InIterator>
5173 _S_construct_aux(_InIterator __beg, _InIterator __end,
5174 const _Alloc& __a, __false_type)
5176 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
5177 return _S_construct(__beg, __end, __a, _Tag());
5182 template<
class _Integer>
5184 _S_construct_aux(_Integer __beg, _Integer __end,
5185 const _Alloc& __a, __true_type)
5186 {
return _S_construct_aux_2(static_cast<size_type>(__beg),
5190 _S_construct_aux_2(size_type __req, _CharT __c,
const _Alloc& __a)
5191 {
return _S_construct(__req, __c, __a); }
5193 template<
class _InIterator>
5195 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a)
5197 typedef typename std::__is_integer<_InIterator>::__type _Integral;
5198 return _S_construct_aux(__beg, __end, __a, _Integral());
5202 template<
class _InIterator>
5204 _S_construct(_InIterator __beg, _InIterator __end,
const _Alloc& __a,
5205 input_iterator_tag);
5209 template<
class _FwdIterator>
5211 _S_construct(_FwdIterator __beg, _FwdIterator __end,
const _Alloc& __a,
5212 forward_iterator_tag);
5215 _S_construct(size_type __req, _CharT __c,
const _Alloc& __a);
5232 copy(_CharT* __s, size_type __n, size_type __pos = 0)
const;
5243 _GLIBCXX_NOEXCEPT_IF(allocator_traits<_Alloc>::is_always_equal::value);
5254 {
return _M_data(); }
5266 {
return _M_data(); }
5268 #if __cplusplus >= 201703L 5288 {
return _M_dataplus; }
5303 find(
const _CharT* __s, size_type __pos, size_type __n)
const 5319 {
return this->
find(__str.data(), __pos, __str.size()); }
5332 find(
const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
5334 __glibcxx_requires_string(__s);
5335 return this->
find(__s, __pos, traits_type::length(__s));
5349 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
5351 #if __cplusplus >= 201703L 5358 template<
typename _Tp>
5359 _If_sv<_Tp, size_type>
5360 find(
const _Tp& __svt, size_type __pos = 0) const
5364 return this->
find(__sv.data(), __pos, __sv.size());
5381 {
return this->
rfind(__str.data(), __pos, __str.size()); }
5396 rfind(
const _CharT* __s, size_type __pos, size_type __n)
const 5410 rfind(
const _CharT* __s, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT
5412 __glibcxx_requires_string(__s);
5413 return this->
rfind(__s, __pos, traits_type::length(__s));
5427 rfind(_CharT __c, size_type __pos =
npos)
const _GLIBCXX_NOEXCEPT;
5429 #if __cplusplus >= 201703L 5436 template<
typename _Tp>
5437 _If_sv<_Tp, size_type>
5442 return this->
rfind(__sv.data(), __pos, __sv.size());
5460 {
return this->
find_first_of(__str.data(), __pos, __str.size()); }
5475 find_first_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5492 __glibcxx_requires_string(__s);
5493 return this->
find_first_of(__s, __pos, traits_type::length(__s));
5510 {
return this->
find(__c, __pos); }
5512 #if __cplusplus >= 201703L 5520 template<
typename _Tp>
5521 _If_sv<_Tp, size_type>
5526 return this->
find_first_of(__sv.data(), __pos, __sv.size());
5544 {
return this->
find_last_of(__str.data(), __pos, __str.size()); }
5559 find_last_of(
const _CharT* __s, size_type __pos, size_type __n)
const 5576 __glibcxx_requires_string(__s);
5577 return this->
find_last_of(__s, __pos, traits_type::length(__s));
5594 {
return this->
rfind(__c, __pos); }
5596 #if __cplusplus >= 201703L 5604 template<
typename _Tp>
5605 _If_sv<_Tp, size_type>
5610 return this->
find_last_of(__sv.data(), __pos, __sv.size());
5643 size_type __n)
const _GLIBCXX_NOEXCEPT;
5659 __glibcxx_requires_string(__s);
5677 #if __cplusplus >= 201703L 5685 template<
typename _Tp>
5686 _If_sv<_Tp, size_type>
5725 size_type __n)
const _GLIBCXX_NOEXCEPT;
5741 __glibcxx_requires_string(__s);
5759 #if __cplusplus >= 201703L 5767 template<
typename _Tp>
5768 _If_sv<_Tp, size_type>
5792 _M_check(__pos,
"basic_string::substr"), __n); }
5811 const size_type __size = this->
size();
5812 const size_type __osize = __str.size();
5813 const size_type __len =
std::min(__size, __osize);
5815 int __r = traits_type::compare(_M_data(), __str.data(), __len);
5817 __r = _S_compare(__size, __osize);
5821 #if __cplusplus >= 201703L 5827 template<
typename _Tp>
5833 const size_type __size = this->
size();
5834 const size_type __osize = __sv.size();
5835 const size_type __len =
std::min(__size, __osize);
5837 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
5839 __r = _S_compare(__size, __osize);
5851 template<
typename _Tp>
5853 compare(size_type __pos, size_type __n,
const _Tp& __svt)
const 5857 return __sv_type(*this).substr(__pos, __n).compare(__sv);
5870 template<
typename _Tp>
5872 compare(size_type __pos1, size_type __n1,
const _Tp& __svt,
5873 size_type __pos2, size_type __n2 =
npos)
const 5878 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
5929 size_type __pos2, size_type __n2 =
npos)
const;
5946 compare(
const _CharT* __s)
const _GLIBCXX_NOEXCEPT;
5970 compare(size_type __pos, size_type __n1,
const _CharT* __s)
const;
5997 compare(size_type __pos, size_type __n1,
const _CharT* __s,
5998 size_type __n2)
const;
6000 #if __cplusplus > 201703L 6003 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
6006 starts_with(_CharT __x)
const noexcept
6007 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
6010 starts_with(
const _CharT* __x)
const noexcept
6011 {
return __sv_type(this->
data(), this->
size()).starts_with(__x); }
6014 ends_with(basic_string_view<_CharT, _Traits> __x)
const noexcept
6015 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
6018 ends_with(_CharT __x)
const noexcept
6019 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
6022 ends_with(
const _CharT* __x)
const noexcept
6023 {
return __sv_type(this->
data(), this->
size()).ends_with(__x); }
6026 #if __cplusplus >= 202011L \ 6027 || (__cplusplus == 202002L && !defined __STRICT_ANSI__) 6029 contains(basic_string_view<_CharT, _Traits> __x)
const noexcept
6030 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
6033 contains(_CharT __x)
const noexcept
6034 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
6037 contains(
const _CharT* __x)
const noexcept
6038 {
return __sv_type(this->
data(), this->
size()).contains(__x); }
6041 # ifdef _GLIBCXX_TM_TS_INTERNAL 6043 ::_txnal_cow_string_C1_for_exceptions(
void* that,
const char* s,
6046 ::_txnal_cow_string_c_str(
const void *that);
6048 ::_txnal_cow_string_D1(
void *that);
6050 ::_txnal_cow_string_D1_commit(
void *that);
6053 #endif // !_GLIBCXX_USE_CXX11_ABI 6055 #if __cpp_deduction_guides >= 201606 6056 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6057 template<
typename _InputIterator,
typename _CharT
6058 =
typename iterator_traits<_InputIterator>::value_type,
6059 typename _Allocator = allocator<_CharT>,
6060 typename = _RequireInputIter<_InputIterator>,
6061 typename = _RequireAllocator<_Allocator>>
6062 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
6063 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
6067 template<
typename _CharT,
typename _Traits,
6068 typename _Allocator = allocator<_CharT>,
6069 typename = _RequireAllocator<_Allocator>>
6070 basic_string(basic_string_view<_CharT, _Traits>,
const _Allocator& = _Allocator())
6071 -> basic_string<_CharT, _Traits, _Allocator>;
6073 template<
typename _CharT,
typename _Traits,
6074 typename _Allocator = allocator<_CharT>,
6075 typename = _RequireAllocator<_Allocator>>
6076 basic_string(basic_string_view<_CharT, _Traits>,
6077 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6078 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
6079 const _Allocator& = _Allocator())
6080 -> basic_string<_CharT, _Traits, _Allocator>;
6081 _GLIBCXX_END_NAMESPACE_CXX11
6091 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6092 basic_string<_CharT, _Traits, _Alloc>
6097 __str.append(__rhs);
6107 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6108 basic_string<_CharT,_Traits,_Alloc>
6110 const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6118 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6119 basic_string<_CharT,_Traits,_Alloc>
6120 operator+(_CharT __lhs,
const basic_string<_CharT,_Traits,_Alloc>& __rhs);
6128 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6129 inline basic_string<_CharT, _Traits, _Alloc>
6131 const _CharT* __rhs)
6134 __str.append(__rhs);
6144 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6145 inline basic_string<_CharT, _Traits, _Alloc>
6149 typedef typename __string_type::size_type __size_type;
6150 __string_type __str(__lhs);
6151 __str.append(__size_type(1), __rhs);
6155 #if __cplusplus >= 201103L 6156 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6157 inline basic_string<_CharT, _Traits, _Alloc>
6158 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6159 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
6160 {
return std::move(__lhs.append(__rhs)); }
6162 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6163 inline basic_string<_CharT, _Traits, _Alloc>
6164 operator+(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6165 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6166 {
return std::move(__rhs.insert(0, __lhs)); }
6168 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6169 inline basic_string<_CharT, _Traits, _Alloc>
6170 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6171 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6173 #if _GLIBCXX_USE_CXX11_ABI 6174 using _Alloc_traits = allocator_traits<_Alloc>;
6175 bool __use_rhs =
false;
6176 if _GLIBCXX17_CONSTEXPR (
typename _Alloc_traits::is_always_equal{})
6178 else if (__lhs.get_allocator() == __rhs.get_allocator())
6183 const auto __size = __lhs.size() + __rhs.size();
6184 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
6185 return std::move(__rhs.insert(0, __lhs));
6190 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6191 inline basic_string<_CharT, _Traits, _Alloc>
6193 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6194 {
return std::move(__rhs.insert(0, __lhs)); }
6196 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6197 inline basic_string<_CharT, _Traits, _Alloc>
6199 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
6200 {
return std::move(__rhs.insert(0, 1, __lhs)); }
6202 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6203 inline basic_string<_CharT, _Traits, _Alloc>
6204 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6205 const _CharT* __rhs)
6206 {
return std::move(__lhs.append(__rhs)); }
6208 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6209 inline basic_string<_CharT, _Traits, _Alloc>
6210 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
6212 {
return std::move(__lhs.append(1, __rhs)); }
6222 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6227 {
return __lhs.compare(__rhs) == 0; }
6229 template<
typename _CharT>
6231 typename __gnu_cxx::__enable_if<__is_char<_CharT>::__value,
bool>::__type
6232 operator==(
const basic_string<_CharT>& __lhs,
6233 const basic_string<_CharT>& __rhs) _GLIBCXX_NOEXCEPT
6234 {
return (__lhs.size() == __rhs.size()
6244 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6247 const _CharT* __rhs)
6248 {
return __lhs.compare(__rhs) == 0; }
6250 #if __cpp_lib_three_way_comparison 6258 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6260 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6261 const basic_string<_CharT, _Traits, _Alloc>& __rhs) noexcept
6262 -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
6263 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
6272 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6274 operator<=>(
const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6275 const _CharT* __rhs) noexcept
6276 -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
6277 {
return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
6285 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6287 operator==(
const _CharT* __lhs,
6289 {
return __rhs.compare(__lhs) == 0; }
6298 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6303 {
return !(__lhs == __rhs); }
6311 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6313 operator!=(
const _CharT* __lhs,
6315 {
return !(__lhs == __rhs); }
6323 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6326 const _CharT* __rhs)
6327 {
return !(__lhs == __rhs); }
6336 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6338 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6341 {
return __lhs.
compare(__rhs) < 0; }
6349 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6351 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6352 const _CharT* __rhs)
6353 {
return __lhs.compare(__rhs) < 0; }
6361 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6363 operator<(
const _CharT* __lhs,
6365 {
return __rhs.compare(__lhs) > 0; }
6374 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6379 {
return __lhs.compare(__rhs) > 0; }
6387 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6390 const _CharT* __rhs)
6391 {
return __lhs.compare(__rhs) > 0; }
6399 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6401 operator>(
const _CharT* __lhs,
6403 {
return __rhs.compare(__lhs) < 0; }
6412 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6414 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6417 {
return __lhs.
compare(__rhs) <= 0; }
6425 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6427 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
6428 const _CharT* __rhs)
6429 {
return __lhs.compare(__rhs) <= 0; }
6437 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6439 operator<=(
const _CharT* __lhs,
6441 {
return __rhs.compare(__lhs) >= 0; }
6450 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6455 {
return __lhs.compare(__rhs) >= 0; }
6463 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6466 const _CharT* __rhs)
6467 {
return __lhs.compare(__rhs) >= 0; }
6475 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6477 operator>=(
const _CharT* __lhs,
6479 {
return __rhs.compare(__lhs) <= 0; }
6480 #endif // three-way comparison 6489 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6493 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
6494 { __lhs.swap(__rhs); }
6509 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6510 basic_istream<_CharT, _Traits>&
6511 operator>>(basic_istream<_CharT, _Traits>& __is,
6512 basic_string<_CharT, _Traits, _Alloc>& __str);
6515 basic_istream<char>&
6516 operator>>(basic_istream<char>& __is, basic_string<char>& __str);
6527 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6528 inline basic_ostream<_CharT, _Traits>&
6529 operator<<(basic_ostream<_CharT, _Traits>& __os,
6534 return __ostream_insert(__os, __str.data(), __str.size());
6550 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6551 basic_istream<_CharT, _Traits>&
6552 getline(basic_istream<_CharT, _Traits>& __is,
6553 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
6567 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6568 inline basic_istream<_CharT, _Traits>&
6573 #if __cplusplus >= 201103L 6575 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6576 inline basic_istream<_CharT, _Traits>&
6582 template<
typename _CharT,
typename _Traits,
typename _Alloc>
6583 inline basic_istream<_CharT, _Traits>&
6590 basic_istream<char>&
6591 getline(basic_istream<char>& __in, basic_string<char>& __str,
6594 #ifdef _GLIBCXX_USE_WCHAR_T 6596 basic_istream<wchar_t>&
6597 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
6601 _GLIBCXX_END_NAMESPACE_VERSION
6604 #if __cplusplus >= 201103L 6609 namespace std _GLIBCXX_VISIBILITY(default)
6611 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6612 _GLIBCXX_BEGIN_NAMESPACE_CXX11
6614 #if _GLIBCXX_USE_C99_STDLIB 6617 stoi(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6618 {
return __gnu_cxx::__stoa<long, int>(&std::strtol,
"stoi", __str.c_str(),
6622 stol(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6623 {
return __gnu_cxx::__stoa(&std::strtol,
"stol", __str.c_str(),
6626 inline unsigned long 6627 stoul(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6628 {
return __gnu_cxx::__stoa(&std::strtoul,
"stoul", __str.c_str(),
6632 stoll(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6633 {
return __gnu_cxx::__stoa(&std::strtoll,
"stoll", __str.c_str(),
6636 inline unsigned long long 6637 stoull(
const string& __str,
size_t* __idx = 0,
int __base = 10)
6638 {
return __gnu_cxx::__stoa(&std::strtoull,
"stoull", __str.c_str(),
6643 stof(
const string& __str,
size_t* __idx = 0)
6644 {
return __gnu_cxx::__stoa(&std::strtof,
"stof", __str.c_str(), __idx); }
6647 stod(
const string& __str,
size_t* __idx = 0)
6648 {
return __gnu_cxx::__stoa(&std::strtod,
"stod", __str.c_str(), __idx); }
6651 stold(
const string& __str,
size_t* __idx = 0)
6652 {
return __gnu_cxx::__stoa(&std::strtold,
"stold", __str.c_str(), __idx); }
6653 #endif // _GLIBCXX_USE_C99_STDLIB 6658 to_string(
int __val)
6660 const bool __neg = __val < 0;
6661 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
6662 const auto __len = __detail::__to_chars_len(__uval);
6663 string __str(__neg + __len,
'-');
6664 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
6669 to_string(
unsigned __val)
6671 string __str(__detail::__to_chars_len(__val),
'\0');
6672 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
6677 to_string(
long __val)
6679 const bool __neg = __val < 0;
6680 const unsigned long __uval = __neg ? (
unsigned long)~__val + 1ul : __val;
6681 const auto __len = __detail::__to_chars_len(__uval);
6682 string __str(__neg + __len,
'-');
6683 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
6688 to_string(
unsigned long __val)
6690 string __str(__detail::__to_chars_len(__val),
'\0');
6691 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
6696 to_string(
long long __val)
6698 const bool __neg = __val < 0;
6699 const unsigned long long __uval
6700 = __neg ? (
unsigned long long)~__val + 1ull : __val;
6701 const auto __len = __detail::__to_chars_len(__uval);
6702 string __str(__neg + __len,
'-');
6703 __detail::__to_chars_10_impl(&__str[__neg], __len, __uval);
6708 to_string(
unsigned long long __val)
6710 string __str(__detail::__to_chars_len(__val),
'\0');
6711 __detail::__to_chars_10_impl(&__str[0], __str.size(), __val);
6715 #if _GLIBCXX_USE_C99_STDIO 6719 to_string(
float __val)
6722 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6723 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6728 to_string(
double __val)
6731 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6732 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6737 to_string(
long double __val)
6740 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6741 return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, __n,
6744 #endif // _GLIBCXX_USE_C99_STDIO 6746 #if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR 6748 stoi(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6749 {
return __gnu_cxx::__stoa<long, int>(&std::wcstol,
"stoi", __str.c_str(),
6753 stol(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6754 {
return __gnu_cxx::__stoa(&std::wcstol,
"stol", __str.c_str(),
6757 inline unsigned long 6758 stoul(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6759 {
return __gnu_cxx::__stoa(&std::wcstoul,
"stoul", __str.c_str(),
6763 stoll(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6764 {
return __gnu_cxx::__stoa(&std::wcstoll,
"stoll", __str.c_str(),
6767 inline unsigned long long 6768 stoull(
const wstring& __str,
size_t* __idx = 0,
int __base = 10)
6769 {
return __gnu_cxx::__stoa(&std::wcstoull,
"stoull", __str.c_str(),
6774 stof(
const wstring& __str,
size_t* __idx = 0)
6775 {
return __gnu_cxx::__stoa(&std::wcstof,
"stof", __str.c_str(), __idx); }
6778 stod(
const wstring& __str,
size_t* __idx = 0)
6779 {
return __gnu_cxx::__stoa(&std::wcstod,
"stod", __str.c_str(), __idx); }
6782 stold(
const wstring& __str,
size_t* __idx = 0)
6783 {
return __gnu_cxx::__stoa(&std::wcstold,
"stold", __str.c_str(), __idx); }
6785 #ifndef _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6788 to_wstring(
int __val)
6789 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(int),
6793 to_wstring(
unsigned __val)
6794 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6795 4 *
sizeof(unsigned),
6799 to_wstring(
long __val)
6800 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, 4 *
sizeof(long),
6804 to_wstring(
unsigned long __val)
6805 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6806 4 *
sizeof(
unsigned long),
6810 to_wstring(
long long __val)
6811 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6812 4 *
sizeof(
long long),
6816 to_wstring(
unsigned long long __val)
6817 {
return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf,
6818 4 *
sizeof(
unsigned long long),
6822 to_wstring(
float __val)
6825 __gnu_cxx::__numeric_traits<float>::__max_exponent10 + 20;
6826 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6831 to_wstring(
double __val)
6834 __gnu_cxx::__numeric_traits<double>::__max_exponent10 + 20;
6835 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6840 to_wstring(
long double __val)
6843 __gnu_cxx::__numeric_traits<long double>::__max_exponent10 + 20;
6844 return __gnu_cxx::__to_xstring<wstring>(&std::vswprintf, __n,
6847 #endif // _GLIBCXX_HAVE_BROKEN_VSWPRINTF 6848 #endif // _GLIBCXX_USE_WCHAR_T && _GLIBCXX_USE_C99_WCHAR 6850 _GLIBCXX_END_NAMESPACE_CXX11
6851 _GLIBCXX_END_NAMESPACE_VERSION
6856 #if __cplusplus >= 201103L 6860 namespace std _GLIBCXX_VISIBILITY(default)
6862 _GLIBCXX_BEGIN_NAMESPACE_VERSION
6866 #ifndef _GLIBCXX_COMPATIBILITY_CXX0X 6870 :
public __hash_base<size_t, string>
6873 operator()(
const string& __s)
const noexcept
6874 {
return std::_Hash_impl::hash(__s.
data(), __s.
length()); }
6881 #ifdef _GLIBCXX_USE_WCHAR_T 6885 :
public __hash_base<size_t, wstring>
6888 operator()(
const wstring& __s)
const noexcept
6889 {
return std::_Hash_impl::hash(__s.
data(),
6890 __s.
length() *
sizeof(wchar_t)); }
6899 #ifdef _GLIBCXX_USE_CHAR8_T 6902 struct hash<u8string>
6903 :
public __hash_base<size_t, u8string>
6906 operator()(
const u8string& __s)
const noexcept
6907 {
return std::_Hash_impl::hash(__s.data(),
6908 __s.length() *
sizeof(char8_t)); }
6919 :
public __hash_base<size_t, u16string>
6922 operator()(
const u16string& __s)
const noexcept
6923 {
return std::_Hash_impl::hash(__s.
data(),
6924 __s.
length() *
sizeof(char16_t)); }
6934 :
public __hash_base<size_t, u32string>
6937 operator()(
const u32string& __s)
const noexcept
6938 {
return std::_Hash_impl::hash(__s.
data(),
6939 __s.
length() *
sizeof(char32_t)); }
6946 #if __cplusplus >= 201402L 6948 #define __cpp_lib_string_udls 201304 6950 inline namespace literals
6952 inline namespace string_literals
6954 #pragma GCC diagnostic push 6955 #pragma GCC diagnostic ignored "-Wliteral-suffix" 6956 _GLIBCXX_DEFAULT_ABI_TAG
6957 inline basic_string<char>
6958 operator""s(
const char* __str,
size_t __len)
6959 {
return basic_string<char>{__str, __len}; }
6961 #ifdef _GLIBCXX_USE_WCHAR_T 6962 _GLIBCXX_DEFAULT_ABI_TAG
6963 inline basic_string<wchar_t>
6964 operator""s(
const wchar_t* __str,
size_t __len)
6965 {
return basic_string<wchar_t>{__str, __len}; }
6968 #ifdef _GLIBCXX_USE_CHAR8_T 6969 _GLIBCXX_DEFAULT_ABI_TAG
6970 inline basic_string<char8_t>
6971 operator""s(
const char8_t* __str,
size_t __len)
6972 {
return basic_string<char8_t>{__str, __len}; }
6975 _GLIBCXX_DEFAULT_ABI_TAG
6976 inline basic_string<char16_t>
6977 operator""s(
const char16_t* __str,
size_t __len)
6978 {
return basic_string<char16_t>{__str, __len}; }
6980 _GLIBCXX_DEFAULT_ABI_TAG
6981 inline basic_string<char32_t>
6982 operator""s(
const char32_t* __str,
size_t __len)
6983 {
return basic_string<char32_t>{__str, __len}; }
6985 #pragma GCC diagnostic pop 6989 #if __cplusplus >= 201703L 6990 namespace __detail::__variant
6992 template<
typename>
struct _Never_valueless_alt;
6996 template<
typename _Tp,
typename _Traits,
typename _Alloc>
6997 struct _Never_valueless_alt<
std::basic_string<_Tp, _Traits, _Alloc>>
6999 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
7000 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
7007 _GLIBCXX_END_NAMESPACE_VERSION
_If_sv< _Tp, basic_string & > insert(size_type __pos1, const _Tp &__svt, size_type __pos2, size_type __n=npos)
Insert a string_view.
basic_string & replace(iterator __i1, iterator __i2, const _CharT *__s, size_type __n)
Replace range of characters with C substring.
basic_string & replace(iterator __i1, iterator __i2, const basic_string &__str)
Replace range of characters with 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, const _CharT *__s)
Replace range of characters with C string.
allocator_type get_allocator() const noexcept
Return copy of allocator used to construct this string.
_If_sv< _Tp, basic_string & > append(const _Tp &__svt)
Append a string_view.
void swap(basic_string &__s) noexcept(/*conditional */)
Swap contents with another string.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
_If_sv< _Tp, size_type > find_last_not_of(const _Tp &__svt, size_type __pos=npos) const noexcept(is_same< _Tp, __sv_type >::value)
Find last position of a character not in a string_view.
basic_string & operator=(basic_string &&__str) noexcept(/*conditional */)
Move assign the value of str to this string.
typename enable_if< _Cond, _Tp >::type enable_if_t
Alias template for enable_if.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
const_reference back() const noexcept
const_iterator end() const noexcept
const_reference at(size_type __n) const
Provides access to the data contained in the string.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
basic_string(const _CharT *__s, size_type __n, const _Alloc &__a=_Alloc())
Construct string initialized by a character array.
_If_sv< _Tp, size_type > find_first_not_of(const _Tp &__svt, size_type __pos=0) const noexcept(is_same< _Tp, __sv_type >::value)
Find position of a character not in a string_view.
Uniform interface to all pointer-like types.
basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc &__a=_Alloc())
Construct string as copy of a range.
_CharT * data() noexcept
Return non-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.
const_reverse_iterator rbegin() const noexcept
_If_sv< _Tp, basic_string & > replace(const_iterator __i1, const_iterator __i2, const _Tp &__svt)
Replace range of characters with string_view.
const_reverse_iterator crbegin() const noexcept
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
const_reference operator[](size_type __pos) const noexcept
Subscript access to the data contained in the string.
size_type rfind(const _CharT *__s, size_type __pos=npos) const noexcept
Find last position of a C string.
reference operator[](size_type __pos)
Subscript access to the data contained in the string.
void insert(iterator __p, _InputIterator __beg, _InputIterator __end)
Insert a range of characters.
const_reference front() const noexcept
basic_string & append(const basic_string &__str)
Append a string to this string.
~basic_string() noexcept
Destroy the string instance.
size_type find_last_not_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character not in string.
_If_sv< _Tp, basic_string & > insert(size_type __pos, const _Tp &__svt)
Insert a string_view.
basic_string & insert(size_type __pos1, const basic_string &__str)
Insert value of a string.
basic_string & assign(size_type __n, _CharT __c)
Set value to multiple characters.
basic_string & insert(size_type __pos1, const basic_string &__str, size_type __pos2, size_type __n=npos)
Insert a substring.
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
static const size_type npos
Value returned by various member functions when they fail.
Forward iterators support a superset of input iterator operations.
_If_sv< _Tp, int > compare(size_type __pos1, size_type __n1, const _Tp &__svt, size_type __pos2, size_type __n2=npos) const noexcept(is_same< _Tp, __sv_type >::value)
Compare to a string_view.
Uniform interface to all allocator types.
void resize(size_type __n)
Resizes the string to the specified number of characters.
_If_sv< _Tp, size_type > find_first_of(const _Tp &__svt, size_type __pos=0) const noexcept(is_same< _Tp, __sv_type >::value)
Find position of a character of a string_view.
_If_sv< _Tp, basic_string & > replace(size_type __pos, size_type __n, const _Tp &__svt)
Replace range of characters with string_view.
basic_string & operator=(initializer_list< _CharT > __l)
Set value to string constructed from initializer list.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
_If_sv< _Tp, size_type > rfind(const _Tp &__svt, size_type __pos=npos) const noexcept(is_same< _Tp, __sv_type >::value)
Find last position of a string_view.
size_type find_first_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character of C string.
_If_sv< _Tp, basic_string & > operator+=(const _Tp &__svt)
Append a string_view.
Primary class template hash.
const_iterator cbegin() const noexcept
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
basic_string & operator+=(_CharT __c)
Append a character.
basic_string(size_type __n, _CharT __c, const _Alloc &__a=_Alloc())
Construct string as multiple characters.
basic_string() noexcept
Default constructor creates an empty string.
size_type find(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a C string.
size_type find_last_of(_CharT __c, size_type __pos=npos) const noexcept
Find last position of a character.
basic_string & operator=(_CharT __c)
Set value to string of length 1.
Template class basic_istream.
reference at(size_type __n)
Provides access to the data contained in the string.
_If_sv< _Tp, size_type > find(const _Tp &__svt, size_type __pos=0) const noexcept(is_same< _Tp, __sv_type >::value)
Find position of a string_view.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
basic_string< wchar_t > wstring
A string of wchar_t.
_If_sv< _Tp, size_type > find_last_of(const _Tp &__svt, size_type __pos=npos) const noexcept(is_same< _Tp, __sv_type >::value)
Find last position of a character of string.
basic_string & assign(const basic_string &__str, size_type __pos, size_type __n=npos)
Set value to a substring of a string.
A non-owning reference to a string.
bool empty() 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.
constexpr _Iterator __base(_Iterator __it)
void reserve()
Equivalent to shrink_to_fit().
basic_string(const _Tp &__t, const _Alloc &__a=_Alloc())
Construct string from a string_view.
basic_string(const _Tp &__t, size_type __pos, size_type __n, const _Alloc &__a=_Alloc())
Construct string from a substring of a string_view.
basic_string & append(_InputIterator __first, _InputIterator __last)
Append a range of characters.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
const _CharT * data() const noexcept
Return const pointer to contents.
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(basic_string &&__str) noexcept
Move construct string.
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.
size_type find_first_not_of(const _CharT *__s, size_type __pos=0) const noexcept
Find position of a character not in C string.
_If_sv< _Tp, int > compare(size_type __pos, size_type __n, const _Tp &__svt) const noexcept(is_same< _Tp, __sv_type >::value)
Compare to a string_view.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
basic_string & insert(size_type __pos, const _CharT *__s)
Insert a C string.
void insert(iterator __p, initializer_list< _CharT > __l)
Insert an initializer_list of characters.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
_If_sv< _Tp, basic_string & > assign(const _Tp &__svt)
Set value from a string_view.
reverse_iterator rbegin()
basic_string & assign(const _CharT *__s)
Set value to contents of a C string.
iterator insert(iterator __p, _CharT __c)
Insert one character.
basic_string & assign(initializer_list< _CharT > __l)
Set value to an initializer_list of characters.
basic_string & insert(size_type __pos, size_type __n, _CharT __c)
Insert multiple characters.
_If_sv< _Tp, int > compare(const _Tp &__svt) const noexcept(is_same< _Tp, __sv_type >::value)
Compare to a string_view.
basic_string & append(initializer_list< _CharT > __l)
Append an initializer_list of characters.
int compare(const basic_string &__str) const
Compare to a string.
basic_string & replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
Replace characters with multiple characters.
basic_string(const _CharT *__s, const _Alloc &__a=_Alloc())
Construct string as copy of a C string.
const_reverse_iterator rend() const noexcept
void pop_back()
Remove the last character.
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
char_type widen(char __c) const
Widens characters.
basic_string & operator+=(const _CharT *__s)
Append a C string.
basic_string & replace(iterator __i1, iterator __i2, _InputIterator __k1, _InputIterator __k2)
Replace range of characters with range.
ISO C++ entities toplevel namespace is std.
const_iterator begin() const noexcept
Basis for explicit traits specializations.
_If_sv< _Tp, basic_string & > assign(const _Tp &__svt, size_type __pos, size_type __n=npos)
Set value from a range of characters in a string_view.
Managing sequences of characters and character-like objects.
basic_string & assign(basic_string &&__str) noexcept(allocator_traits< _Alloc >::is_always_equal::value)
Set value to contents of another string.
size_type capacity() const noexcept
_If_sv< _Tp, basic_string & > append(const _Tp &__svt, size_type __pos, size_type __n=npos)
Append a range of characters from a string_view.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
Uniform interface to C++98 and C++11 allocators.
basic_string & operator+=(initializer_list< _CharT > __l)
Append an initializer_list of characters.
void push_back(_CharT __c)
Append a single character.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
iterator erase(iterator __position)
Remove one character.
const_iterator cend() const noexcept
basic_string & replace(size_type __pos, size_type __n1, const _CharT *__s)
Replace characters with value of a C string.
basic_string & replace(iterator __i1, iterator __i2, initializer_list< _CharT > __l)
Replace range of characters with initializer_list.
const_reverse_iterator crend() const noexcept
basic_string & assign(_InputIterator __first, _InputIterator __last)
Set value to a range of characters.
_If_sv< _Tp, basic_string & > operator=(const _Tp &__svt)
Set value to string constructed from a string_view.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
basic_string & replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
Replace range of characters with multiple characters.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
basic_string(const _Alloc &__a)
Construct an empty string using allocator a.
basic_string & operator=(const _CharT *__s)
Copy contents of s into this string.
basic_string & operator=(const basic_string &__str)
Assign the value of str to this string.
_If_sv< _Tp, basic_string & > replace(size_type __pos1, size_type __n1, const _Tp &__svt, size_type __pos2, size_type __n2=npos)
Replace range of characters with string_view.
basic_string(const basic_string &__str)
Construct string with copy of value of str.
size_type find(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a 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.
basic_string(initializer_list< _CharT > __l, const _Alloc &__a=_Alloc())
Construct string from an initializer list.
basic_string & append(const _CharT *__s)
Append a C string.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.