libstdc++: basic_string.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34#ifndef _BASIC_STRING_H
35#define _BASIC_STRING_H 1
36
37#pragma GCC system_header
38
41
42#if __cplusplus >= 201103L
44#endif
45
46#if __cplusplus >= 201703L
48#endif
49
50#if __cplusplus > 202302L
52#endif
53
55
56#if ! _GLIBCXX_USE_CXX11_ABI
58#else
59
60namespace std _GLIBCXX_VISIBILITY(default)
61{
62_GLIBCXX_BEGIN_NAMESPACE_VERSION
63_GLIBCXX_BEGIN_NAMESPACE_CXX11
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85 template<typename _CharT, typename _Traits, typename _Alloc>
86 class basic_string
87 {
88#if __cplusplus >= 202002L
89 static_assert(is_same_v<_CharT, typename _Traits::char_type>);
90 static_assert(is_same_v<_CharT, typename _Alloc::value_type>);
91 using _Char_alloc_type = _Alloc;
92#else
94 rebind<_CharT>::other _Char_alloc_type;
95#endif
96
98
99
100 public:
101 typedef _Traits traits_type;
102 typedef typename _Traits::char_type value_type;
103 typedef _Char_alloc_type allocator_type;
104 typedef typename _Alloc_traits::size_type size_type;
105 typedef typename _Alloc_traits::difference_type difference_type;
106 typedef typename _Alloc_traits::reference reference;
107 typedef typename _Alloc_traits::const_reference const_reference;
108 typedef typename _Alloc_traits::pointer pointer;
109 typedef typename _Alloc_traits::const_pointer const_pointer;
110 typedef __gnu_cxx::__normal_iterator<pointer, basic_string> iterator;
111 typedef __gnu_cxx::__normal_iterator<const_pointer, basic_string>
112 const_iterator;
115
116
117 static const size_type npos = static_cast<size_type>(-1);
118
119 protected:
120
121#if __cplusplus < 201103L
122 typedef iterator __const_iterator;
123#else
124 typedef const_iterator __const_iterator;
125#endif
126
127 private:
128 static _GLIBCXX20_CONSTEXPR pointer
129 _S_allocate(_Char_alloc_type& __a, size_type __n)
130 {
131 pointer __p = _Alloc_traits::allocate(__a, __n);
132#if __glibcxx_constexpr_string >= 201907L
133
134
135 if constexpr (!is_same_v<_Traits, char_traits<_CharT>>)
136 if (std::__is_constant_evaluated())
137
138 for (size_type __i = 0; __i < __n; ++__i)
139 std::construct_at(__builtin_addressof(__p[__i]));
140#endif
141 return __p;
142 }
143
144#if __cplusplus >= 201703L
145
146 typedef basic_string_view<_CharT, _Traits> __sv_type;
147
148 template<typename _Tp, typename _Res>
150 __and_<is_convertible<const _Tp&, __sv_type>,
151 __not_<is_convertible<const _Tp*, const basic_string*>>,
152 __not_<is_convertible<const _Tp&, const _CharT*>>>::value,
153 _Res>;
154
155
156 _GLIBCXX20_CONSTEXPR
157 static __sv_type
158 _S_to_string_view(__sv_type __svt) noexcept
159 { return __svt; }
160
161
162
163
164
165 struct __sv_wrapper
166 {
167 _GLIBCXX20_CONSTEXPR explicit
168 __sv_wrapper(__sv_type __sv) noexcept : _M_sv(__sv) { }
169
170 __sv_type _M_sv;
171 };
172
173
174
175
176
177
178
179 _GLIBCXX20_CONSTEXPR
180 explicit
181 basic_string(__sv_wrapper __svw, const _Alloc& __a)
183#endif
184
185
186 struct _Alloc_hider : allocator_type
187 {
188#if __cplusplus < 201103L
189 _Alloc_hider(pointer __dat, const _Alloc& __a = _Alloc())
190 : allocator_type(__a), _M_p(__dat) { }
191#else
192 _GLIBCXX20_CONSTEXPR
193 _Alloc_hider(pointer __dat, const _Alloc& __a)
194 : allocator_type(__a), _M_p(__dat) { }
195
196 _GLIBCXX20_CONSTEXPR
197 _Alloc_hider(pointer __dat, _Alloc&& __a = _Alloc())
198 : allocator_type(std::move(__a)), _M_p(__dat) { }
199#endif
200
201 pointer _M_p;
202 };
203
204 _Alloc_hider _M_dataplus;
205 size_type _M_string_length;
206
207 enum { _S_local_capacity = 15 / sizeof(_CharT) };
208
209 union
210 {
211 _CharT _M_local_buf[_S_local_capacity + 1];
212 size_type _M_allocated_capacity;
213 };
214
215 _GLIBCXX20_CONSTEXPR
216 void
217 _M_data(pointer __p)
218 { _M_dataplus._M_p = __p; }
219
220 _GLIBCXX20_CONSTEXPR
221 void
222 _M_length(size_type __length)
223 { _M_string_length = __length; }
224
225 _GLIBCXX20_CONSTEXPR
226 pointer
227 _M_data() const
228 { return _M_dataplus._M_p; }
229
230 _GLIBCXX20_CONSTEXPR
231 pointer
232 _M_local_data()
233 {
234#if __cplusplus >= 201103L
236#else
237 return pointer(_M_local_buf);
238#endif
239 }
240
241 _GLIBCXX20_CONSTEXPR
242 const_pointer
243 _M_local_data() const
244 {
245#if __cplusplus >= 201103L
247#else
248 return const_pointer(_M_local_buf);
249#endif
250 }
251
252 _GLIBCXX20_CONSTEXPR
253 void
254 _M_capacity(size_type __capacity)
255 { _M_allocated_capacity = __capacity; }
256
257 _GLIBCXX20_CONSTEXPR
258 void
259 _M_set_length(size_type __n)
260 {
261 _M_length(__n);
262 traits_type::assign(_M_data()[__n], _CharT());
263 }
264
265 _GLIBCXX20_CONSTEXPR
266 bool
267 _M_is_local() const
268 {
269 if (_M_data() == _M_local_data())
270 {
271 if (_M_string_length > _S_local_capacity)
272 __builtin_unreachable();
273 return true;
274 }
275 return false;
276 }
277
278
279 _GLIBCXX20_CONSTEXPR
280 pointer
281 _M_create(size_type&, size_type);
282
283 _GLIBCXX20_CONSTEXPR
284 void
285 _M_dispose()
286 {
287 if (!_M_is_local())
288 _M_destroy(_M_allocated_capacity);
289 }
290
291 _GLIBCXX20_CONSTEXPR
292 void
293 _M_destroy(size_type __size) throw()
294 { _Alloc_traits::deallocate(_M_get_allocator(), _M_data(), __size + 1); }
295
296#if __cplusplus < 201103L || defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
297
298
299 template<typename _InIterator>
300 void
301 _M_construct_aux(_InIterator __beg, _InIterator __end,
302 std::__false_type)
303 {
304 typedef typename iterator_traits<_InIterator>::iterator_category _Tag;
305 _M_construct(__beg, __end, _Tag());
306 }
307
308
309
310 template<typename _Integer>
311 void
312 _M_construct_aux(_Integer __beg, _Integer __end, std::__true_type)
313 { _M_construct_aux_2(static_cast<size_type>(__beg), __end); }
314
315 void
316 _M_construct_aux_2(size_type __req, _CharT __c)
317 { _M_construct(__req, __c); }
318#endif
319
320
321 template<typename _InIterator>
322 _GLIBCXX20_CONSTEXPR
323 void
324 _M_construct(_InIterator __beg, _InIterator __end,
326
327
328
329 template<typename _FwdIterator>
330 _GLIBCXX20_CONSTEXPR
331 void
332 _M_construct(_FwdIterator __beg, _FwdIterator __end,
334
335 _GLIBCXX20_CONSTEXPR
336 void
337 _M_construct(size_type __req, _CharT __c);
338
339 _GLIBCXX20_CONSTEXPR
340 allocator_type&
341 _M_get_allocator()
342 { return _M_dataplus; }
343
344 _GLIBCXX20_CONSTEXPR
345 const allocator_type&
346 _M_get_allocator() const
347 { return _M_dataplus; }
348
349
350 __attribute__((__always_inline__))
351 _GLIBCXX14_CONSTEXPR
352 void
353 _M_init_local_buf() _GLIBCXX_NOEXCEPT
354 {
355#if __glibcxx_is_constant_evaluated
356 if (std::is_constant_evaluated())
357 for (size_type __i = 0; __i <= _S_local_capacity; ++__i)
358 _M_local_buf[__i] = _CharT();
359#endif
360 }
361
362 __attribute__((__always_inline__))
363 _GLIBCXX14_CONSTEXPR
364 pointer
365 _M_use_local_data() _GLIBCXX_NOEXCEPT
366 {
367#if __cpp_lib_is_constant_evaluated
368 _M_init_local_buf();
369#endif
370 return _M_local_data();
371 }
372
373 private:
374
375#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
376
377
378 template<typename _Tp, bool _Requires =
379 !__are_same<_Tp, _CharT*>::__value
380 && !__are_same<_Tp, const _CharT*>::__value
381 && !__are_same<_Tp, iterator>::__value
382 && !__are_same<_Tp, const_iterator>::__value>
383 struct __enable_if_not_native_iterator
384 { typedef basic_string& __type; };
385 template<typename _Tp>
386 struct __enable_if_not_native_iterator<_Tp, false> { };
387#endif
388
389 _GLIBCXX20_CONSTEXPR
390 size_type
391 _M_check(size_type __pos, const char* __s) const
392 {
393 if (__pos > this->size())
394 __throw_out_of_range_fmt(__N("%s: __pos (which is %zu) > "
395 "this->size() (which is %zu)"),
396 __s, __pos, this->size());
397 return __pos;
398 }
399
400 _GLIBCXX20_CONSTEXPR
401 void
402 _M_check_length(size_type __n1, size_type __n2, const char* __s) const
403 {
404 if (this->max_size() - (this->size() - __n1) < __n2)
405 __throw_length_error(__N(__s));
406 }
407
408
409
410 _GLIBCXX20_CONSTEXPR
411 size_type
412 _M_limit(size_type __pos, size_type __off) const _GLIBCXX_NOEXCEPT
413 {
414 const bool __testoff = __off < this->size() - __pos;
415 return __testoff ? __off : this->size() - __pos;
416 }
417
418
419 bool
420 _M_disjunct(const _CharT* __s) const _GLIBCXX_NOEXCEPT
421 {
422 return (less<const _CharT*>()(__s, _M_data())
423 || less<const _CharT*>()(_M_data() + this->size(), __s));
424 }
425
426
427
428 _GLIBCXX20_CONSTEXPR
429 static void
430 _S_copy(_CharT* __d, const _CharT* __s, size_type __n)
431 {
432 if (__n == 1)
433 traits_type::assign(*__d, *__s);
434 else
435 traits_type::copy(__d, __s, __n);
436 }
437
438 _GLIBCXX20_CONSTEXPR
439 static void
440 _S_move(_CharT* __d, const _CharT* __s, size_type __n)
441 {
442 if (__n == 1)
443 traits_type::assign(*__d, *__s);
444 else
445 traits_type::move(__d, __s, __n);
446 }
447
448 _GLIBCXX20_CONSTEXPR
449 static void
450 _S_assign(_CharT* __d, size_type __n, _CharT __c)
451 {
452 if (__n == 1)
453 traits_type::assign(*__d, __c);
454 else
455 traits_type::assign(__d, __n, __c);
456 }
457
458
459
460 template<class _Iterator>
461 _GLIBCXX20_CONSTEXPR
462 static void
463 _S_copy_chars(_CharT* __p, _Iterator __k1, _Iterator __k2)
464 {
465 for (; __k1 != __k2; ++__k1, (void)++__p)
466 traits_type::assign(*__p, *__k1);
467 }
468
469 _GLIBCXX20_CONSTEXPR
470 static void
471 _S_copy_chars(_CharT* __p, iterator __k1, iterator __k2) _GLIBCXX_NOEXCEPT
472 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
473
474 _GLIBCXX20_CONSTEXPR
475 static void
476 _S_copy_chars(_CharT* __p, const_iterator __k1, const_iterator __k2)
477 _GLIBCXX_NOEXCEPT
478 { _S_copy_chars(__p, __k1.base(), __k2.base()); }
479
480 _GLIBCXX20_CONSTEXPR
481 static void
482 _S_copy_chars(_CharT* __p, _CharT* __k1, _CharT* __k2) _GLIBCXX_NOEXCEPT
483 { _S_copy(__p, __k1, __k2 - __k1); }
484
485 _GLIBCXX20_CONSTEXPR
486 static void
487 _S_copy_chars(_CharT* __p, const _CharT* __k1, const _CharT* __k2)
488 _GLIBCXX_NOEXCEPT
489 { _S_copy(__p, __k1, __k2 - __k1); }
490
491 _GLIBCXX20_CONSTEXPR
492 static int
493 _S_compare(size_type __n1, size_type __n2) _GLIBCXX_NOEXCEPT
494 {
495 const difference_type __d = difference_type(__n1 - __n2);
496
497 if (__d > __gnu_cxx::__numeric_traits::__max)
498 return __gnu_cxx::__numeric_traits::__max;
499 else if (__d < __gnu_cxx::__numeric_traits::__min)
500 return __gnu_cxx::__numeric_traits::__min;
501 else
502 return int(__d);
503 }
504
505 _GLIBCXX20_CONSTEXPR
506 void
508
509 _GLIBCXX20_CONSTEXPR
510 void
511 _M_mutate(size_type __pos, size_type __len1, const _CharT* __s,
512 size_type __len2);
513
514 _GLIBCXX20_CONSTEXPR
515 void
516 _M_erase(size_type __pos, size_type __n);
517
518 public:
519
520
521
522
523
524
525
526 _GLIBCXX20_CONSTEXPR
528 _GLIBCXX_NOEXCEPT_IF(is_nothrow_default_constructible<_Alloc>::value)
529#if __cpp_concepts && __glibcxx_type_trait_variable_templates
530 requires is_default_constructible_v<_Alloc>
531#endif
532 : _M_dataplus(_M_local_data())
533 {
534 _M_init_local_buf();
535 _M_set_length(0);
536 }
537
538
539
540
541 _GLIBCXX20_CONSTEXPR
542 explicit
543 basic_string(const _Alloc& __a) _GLIBCXX_NOEXCEPT
544 : _M_dataplus(_M_local_data(), __a)
545 {
546 _M_init_local_buf();
547 _M_set_length(0);
548 }
549
550
551
552
553
554 _GLIBCXX20_CONSTEXPR
556 : _M_dataplus(_M_local_data(),
557 _Alloc_traits::_S_select_on_copy(__str._M_get_allocator()))
558 {
559 _M_construct(__str._M_data(), __str._M_data() + __str.length(),
561 }
562
563
564
565
566
567
568
569
570
571 _GLIBCXX20_CONSTEXPR
573 const _Alloc& __a = _Alloc())
574 : _M_dataplus(_M_local_data(), __a)
575 {
576 const _CharT* __start = __str._M_data()
577 + __str._M_check(__pos, "basic_string::basic_string");
578 _M_construct(__start, __start + __str._M_limit(__pos, npos),
580 }
581
582
583
584
585
586
587
588 _GLIBCXX20_CONSTEXPR
590 size_type __n)
591 : _M_dataplus(_M_local_data())
592 {
593 const _CharT* __start = __str._M_data()
594 + __str._M_check(__pos, "basic_string::basic_string");
595 _M_construct(__start, __start + __str._M_limit(__pos, __n),
597 }
598
599
600
601
602
603
604
605
606 _GLIBCXX20_CONSTEXPR
608 size_type __n, const _Alloc& __a)
609 : _M_dataplus(_M_local_data(), __a)
610 {
611 const _CharT* __start
612 = __str._M_data() + __str._M_check(__pos, "string::string");
613 _M_construct(__start, __start + __str._M_limit(__pos, __n),
615 }
616
617
618
619
620
621
622
623
624
625
626 _GLIBCXX20_CONSTEXPR
627 basic_string(const _CharT* __s, size_type __n,
628 const _Alloc& __a = _Alloc())
629 : _M_dataplus(_M_local_data(), __a)
630 {
631
632 if (__s == 0 && __n > 0)
633 std::__throw_logic_error(__N("basic_string: "
634 "construction from null is not valid"));
636 }
637
638
639
640
641
642
643#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
644
645
646 template<typename = _RequireAllocator<_Alloc>>
647#endif
648 _GLIBCXX20_CONSTEXPR
649 basic_string(const _CharT* __s, const _Alloc& __a = _Alloc())
650 : _M_dataplus(_M_local_data(), __a)
651 {
652
653 if (__s == 0)
654 std::__throw_logic_error(__N("basic_string: "
655 "construction from null is not valid"));
656 const _CharT* __end = __s + traits_type::length(__s);
657 _M_construct(__s, __end, forward_iterator_tag());
658 }
659
660
661
662
663
664
665
666#if __cpp_deduction_guides && ! defined _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
667
668
669 template<typename = _RequireAllocator<_Alloc>>
670#endif
671 _GLIBCXX20_CONSTEXPR
672 basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc())
673 : _M_dataplus(_M_local_data(), __a)
674 { _M_construct(__n, __c); }
675
676#if __cplusplus >= 201103L
677
678
679
680
681
682
683
684 _GLIBCXX20_CONSTEXPR
686 : _M_dataplus(_M_local_data(), std::move(__str._M_get_allocator()))
687 {
688 if (__str._M_is_local())
689 {
690 _M_init_local_buf();
691 traits_type::copy(_M_local_buf, __str._M_local_buf,
692 __str.length() + 1);
693 }
694 else
695 {
696 _M_data(__str._M_data());
697 _M_capacity(__str._M_allocated_capacity);
698 }
699
700
701
702
703 _M_length(__str.length());
704 __str._M_data(__str._M_use_local_data());
705 __str._M_set_length(0);
706 }
707
708
709
710
711
712
713 _GLIBCXX20_CONSTEXPR
714 basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc())
715 : _M_dataplus(_M_local_data(), __a)
717
718 _GLIBCXX20_CONSTEXPR
720 : _M_dataplus(_M_local_data(), __a)
722
723 _GLIBCXX20_CONSTEXPR
725 noexcept(_Alloc_traits::_S_always_equal())
726 : _M_dataplus(_M_local_data(), __a)
727 {
728 if (__str._M_is_local())
729 {
730 _M_init_local_buf();
731 traits_type::copy(_M_local_buf, __str._M_local_buf,
732 __str.length() + 1);
733 _M_length(__str.length());
734 __str._M_set_length(0);
735 }
736 else if (_Alloc_traits::_S_always_equal()
737 || __str.get_allocator() == __a)
738 {
739 _M_data(__str._M_data());
740 _M_length(__str.length());
741 _M_capacity(__str._M_allocated_capacity);
742 __str._M_data(__str._M_use_local_data());
743 __str._M_set_length(0);
744 }
745 else
747 }
748#endif
749
750#if __cplusplus >= 202100L
753#endif
754
755
756
757
758
759
760
761#if __cplusplus >= 201103L
762 template<typename _InputIterator,
763 typename = std::_RequireInputIter<_InputIterator>>
764#else
765 template<typename _InputIterator>
766#endif
767 _GLIBCXX20_CONSTEXPR
768 basic_string(_InputIterator __beg, _InputIterator __end,
769 const _Alloc& __a = _Alloc())
770 : _M_dataplus(_M_local_data(), __a), _M_string_length(0)
771 {
772#if __cplusplus >= 201103L
774#else
775 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
776 _M_construct_aux(__beg, __end, _Integral());
777#endif
778 }
779
780#if __cplusplus >= 201703L
781
782
783
784
785
786
787
788 template<typename _Tp,
789 typename = enable_if_t<is_convertible_v<const _Tp&, __sv_type>>>
790 _GLIBCXX20_CONSTEXPR
791 basic_string(const _Tp& __t, size_type __pos, size_type __n,
792 const _Alloc& __a = _Alloc())
794
795
796
797
798
799
800 template<typename _Tp, typename = _If_sv<_Tp, void>>
801 _GLIBCXX20_CONSTEXPR
802 explicit
803 basic_string(const _Tp& __t, const _Alloc& __a = _Alloc())
804 : basic_string(__sv_wrapper(_S_to_string_view(__t)), __a) { }
805#endif
806
807
808
809
810 _GLIBCXX20_CONSTEXPR
812 { _M_dispose(); }
813
814
815
816
817
818 _GLIBCXX20_CONSTEXPR
821 {
822 return this->assign(__str);
823 }
824
825
826
827
828
829 _GLIBCXX20_CONSTEXPR
832 { return this->assign(__s); }
833
834
835
836
837
838
839
840
841 _GLIBCXX20_CONSTEXPR
844 {
845 this->assign(1, __c);
846 return *this;
847 }
848
849#if __cplusplus >= 201103L
850
851
852
853
854
855
856
857
858
859 _GLIBCXX20_CONSTEXPR
862 noexcept(_Alloc_traits::_S_nothrow_move())
863 {
864 const bool __equal_allocs = _Alloc_traits::_S_always_equal()
865 || _M_get_allocator() == __str._M_get_allocator();
866 if (!_M_is_local() && _Alloc_traits::_S_propagate_on_move_assign()
867 && !__equal_allocs)
868 {
869
870 _M_destroy(_M_allocated_capacity);
871 _M_data(_M_local_data());
872 _M_set_length(0);
873 }
874
875 std::__alloc_on_move(_M_get_allocator(), __str._M_get_allocator());
876
877 if (__str._M_is_local())
878 {
879
880
881
883 {
884 if (__str.size())
885 this->_S_copy(_M_data(), __str._M_data(), __str.size());
886 _M_set_length(__str.size());
887 }
888 }
889 else if (_Alloc_traits::_S_propagate_on_move_assign() || __equal_allocs)
890 {
891
892 pointer __data = nullptr;
893 size_type __capacity;
894 if (!_M_is_local())
895 {
896 if (__equal_allocs)
897 {
898
899 __data = _M_data();
900 __capacity = _M_allocated_capacity;
901 }
902 else
903 _M_destroy(_M_allocated_capacity);
904 }
905
906 _M_data(__str._M_data());
907 _M_length(__str.length());
908 _M_capacity(__str._M_allocated_capacity);
909 if (__data)
910 {
911 __str._M_data(__data);
912 __str._M_capacity(__capacity);
913 }
914 else
915 __str._M_data(__str._M_use_local_data());
916 }
917 else
919 __str.clear();
920 return *this;
921 }
922
923
924
925
926
927 _GLIBCXX20_CONSTEXPR
929 operator=(initializer_list<_CharT> __l)
930 {
931 this->assign(__l.begin(), __l.size());
932 return *this;
933 }
934#endif
935
936#if __cplusplus >= 201703L
937
938
939
940
941 template<typename _Tp>
942 _GLIBCXX20_CONSTEXPR
943 _If_sv<_Tp, basic_string&>
945 { return this->assign(__svt); }
946
947
948
949
950
951 _GLIBCXX20_CONSTEXPR
952 operator __sv_type() const noexcept
953 { return __sv_type(data(), size()); }
954#endif
955
956
957
958
959
960
961 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
962 iterator
963 begin() _GLIBCXX_NOEXCEPT
964 { return iterator(_M_data()); }
965
966
967
968
969
970 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
971 const_iterator
972 begin() const _GLIBCXX_NOEXCEPT
973 { return const_iterator(_M_data()); }
974
975
976
977
978
979 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
980 iterator
981 end() _GLIBCXX_NOEXCEPT
982 { return iterator(_M_data() + this->size()); }
983
984
985
986
987
988 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
989 const_iterator
990 end() const _GLIBCXX_NOEXCEPT
991 { return const_iterator(_M_data() + this->size()); }
992
993
994
995
996
997
998 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
999 reverse_iterator
1000 rbegin() _GLIBCXX_NOEXCEPT
1001 { return reverse_iterator(this->end()); }
1002
1003
1004
1005
1006
1007
1008 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1009 const_reverse_iterator
1010 rbegin() const _GLIBCXX_NOEXCEPT
1011 { return const_reverse_iterator(this->end()); }
1012
1013
1014
1015
1016
1017
1018 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1019 reverse_iterator
1020 rend() _GLIBCXX_NOEXCEPT
1021 { return reverse_iterator(this->begin()); }
1022
1023
1024
1025
1026
1027
1028 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1029 const_reverse_iterator
1030 rend() const _GLIBCXX_NOEXCEPT
1031 { return const_reverse_iterator(this->begin()); }
1032
1033#if __cplusplus >= 201103L
1034
1035
1036
1037
1038 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1039 const_iterator
1040 cbegin() const noexcept
1041 { return const_iterator(this->_M_data()); }
1042
1043
1044
1045
1046
1047 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1048 const_iterator
1049 cend() const noexcept
1050 { return const_iterator(this->_M_data() + this->size()); }
1051
1052
1053
1054
1055
1056
1057 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1058 const_reverse_iterator
1059 crbegin() const noexcept
1060 { return const_reverse_iterator(this->end()); }
1061
1062
1063
1064
1065
1066
1067 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1068 const_reverse_iterator
1069 crend() const noexcept
1070 { return const_reverse_iterator(this->begin()); }
1071#endif
1072
1073 public:
1074
1075
1076
1077 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1078 size_type
1079 size() const _GLIBCXX_NOEXCEPT
1080 { return _M_string_length; }
1081
1082
1083
1084 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1085 size_type
1086 length() const _GLIBCXX_NOEXCEPT
1087 { return _M_string_length; }
1088
1089
1090 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1091 size_type
1092 max_size() const _GLIBCXX_NOEXCEPT
1093 { return (_Alloc_traits::max_size(_M_get_allocator()) - 1) / 2; }
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105 _GLIBCXX20_CONSTEXPR
1106 void
1107 resize(size_type __n, _CharT __c);
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119 _GLIBCXX20_CONSTEXPR
1120 void
1121 resize(size_type __n)
1122 { this->resize(__n, _CharT()); }
1123
1124#if __cplusplus >= 201103L
1125#pragma GCC diagnostic push
1126#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1127
1128 _GLIBCXX20_CONSTEXPR
1129 void
1132#pragma GCC diagnostic pop
1133#endif
1134
1135#ifdef __glibcxx_string_resize_and_overwrite
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165 template<typename _Operation>
1166 constexpr void
1167 resize_and_overwrite(size_type __n, _Operation __op);
1168#endif
1169
1170#if __cplusplus >= 201103L
1171
1172 template<typename _Operation>
1173 _GLIBCXX20_CONSTEXPR void
1175#endif
1176
1177
1178
1179
1180
1181 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1182 size_type
1183 capacity() const _GLIBCXX_NOEXCEPT
1184 {
1185 return _M_is_local() ? size_type(_S_local_capacity)
1186 : _M_allocated_capacity;
1187 }
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206 _GLIBCXX20_CONSTEXPR
1207 void
1208 reserve(size_type __res_arg);
1209
1210
1211
1212
1213#if __cplusplus > 201703L
1214 [[deprecated("use shrink_to_fit() instead")]]
1215#endif
1216 _GLIBCXX20_CONSTEXPR
1217 void
1219
1220
1221
1222
1223 _GLIBCXX20_CONSTEXPR
1224 void
1225 clear() _GLIBCXX_NOEXCEPT
1226 { _M_set_length(0); }
1227
1228
1229
1230
1231
1232 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1233 bool
1234 empty() const _GLIBCXX_NOEXCEPT
1235 { return this->size() == 0; }
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1249 const_reference
1250 operator[] (size_type __pos) const _GLIBCXX_NOEXCEPT
1251 {
1252 __glibcxx_assert(__pos <= size());
1253 return _M_data()[__pos];
1254 }
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1267 reference
1269 {
1270
1271
1272 __glibcxx_assert(__pos <= size());
1273
1274 _GLIBCXX_DEBUG_PEDASSERT(__cplusplus >= 201103L || __pos < size());
1275 return _M_data()[__pos];
1276 }
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1289 const_reference
1290 at(size_type __n) const
1291 {
1292 if (__n >= this->size())
1293 __throw_out_of_range_fmt(__N("basic_string::at: __n "
1294 "(which is %zu) >= this->size() "
1295 "(which is %zu)"),
1296 __n, this->size());
1297 return _M_data()[__n];
1298 }
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1311 reference
1312 at(size_type __n)
1313 {
1314 if (__n >= size())
1315 __throw_out_of_range_fmt(__N("basic_string::at: __n "
1316 "(which is %zu) >= this->size() "
1317 "(which is %zu)"),
1318 __n, this->size());
1319 return _M_data()[__n];
1320 }
1321
1322#if __cplusplus >= 201103L
1323
1324
1325
1326
1327 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1328 reference
1329 front() noexcept
1330 {
1331 __glibcxx_assert(());
1333 }
1334
1335
1336
1337
1338
1339 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1340 const_reference
1341 front() const noexcept
1342 {
1343 __glibcxx_assert(());
1345 }
1346
1347
1348
1349
1350
1351 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1352 reference
1353 back() noexcept
1354 {
1355 __glibcxx_assert(());
1357 }
1358
1359
1360
1361
1362
1363 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
1364 const_reference
1365 back() const noexcept
1366 {
1367 __glibcxx_assert(());
1369 }
1370#endif
1371
1372
1373
1374
1375
1376
1377
1378 _GLIBCXX20_CONSTEXPR
1381 { return this->append(__str); }
1382
1383
1384
1385
1386
1387
1388 _GLIBCXX20_CONSTEXPR
1391 { return this->append(__s); }
1392
1393
1394
1395
1396
1397
1398 _GLIBCXX20_CONSTEXPR
1401 {
1403 return *this;
1404 }
1405
1406#if __cplusplus >= 201103L
1407
1408
1409
1410
1411
1412 _GLIBCXX20_CONSTEXPR
1414 operator+=(initializer_list<_CharT> __l)
1415 { return this->append(__l.begin(), __l.size()); }
1416#endif
1417
1418#if __cplusplus >= 201703L
1419
1420
1421
1422
1423
1424 template<typename _Tp>
1425 _GLIBCXX20_CONSTEXPR
1426 _If_sv<_Tp, basic_string&>
1428 { return this->append(__svt); }
1429#endif
1430
1431
1432
1433
1434
1435
1436 _GLIBCXX20_CONSTEXPR
1439 { return this->append(__str._M_data(), __str.size()); }
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454 _GLIBCXX20_CONSTEXPR
1457 { return this->append(__str._M_data()
1458 + __str._M_check(__pos, "basic_string::append"),
1459 __str._M_limit(__pos, __n)); }
1460
1461
1462
1463
1464
1465
1466
1467 _GLIBCXX20_CONSTEXPR
1469 append(const _CharT* __s, size_type __n)
1470 {
1471 __glibcxx_requires_string_len(__s, __n);
1472 _M_check_length(size_type(0), __n, "basic_string::append");
1473 return _M_append(__s, __n);
1474 }
1475
1476
1477
1478
1479
1480
1481 _GLIBCXX20_CONSTEXPR
1483 append(const _CharT* __s)
1484 {
1485 __glibcxx_requires_string(__s);
1486 const size_type __n = traits_type::length(__s);
1487 _M_check_length(size_type(0), __n, "basic_string::append");
1488 return _M_append(__s, __n);
1489 }
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499 _GLIBCXX20_CONSTEXPR
1501 append(size_type __n, _CharT __c)
1502 { return _M_replace_aux(this->size(), size_type(0), __n, __c); }
1503
1504#if __cplusplus >= 201103L
1505
1506
1507
1508
1509
1510 _GLIBCXX20_CONSTEXPR
1512 append(initializer_list<_CharT> __l)
1513 { return this->append(__l.begin(), __l.size()); }
1514#endif
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524#if __cplusplus >= 201103L
1525 template<class _InputIterator,
1526 typename = std::_RequireInputIter<_InputIterator>>
1527 _GLIBCXX20_CONSTEXPR
1528#else
1529 template<class _InputIterator>
1530#endif
1532 append(_InputIterator __first, _InputIterator __last)
1533 { return this->replace(end(), end(), __first, __last); }
1534
1535#if __cplusplus >= 201703L
1536
1537
1538
1539
1540
1541 template<typename _Tp>
1542 _GLIBCXX20_CONSTEXPR
1543 _If_sv<_Tp, basic_string&>
1544 append(const _Tp& __svt)
1545 {
1546 __sv_type __sv = __svt;
1547 return this->append(__sv.data(), __sv.size());
1548 }
1549
1550
1551
1552
1553
1554
1555
1556
1557 template<typename _Tp>
1558 _GLIBCXX20_CONSTEXPR
1559 _If_sv<_Tp, basic_string&>
1560 append(const _Tp& __svt, size_type __pos, size_type __n = npos)
1561 {
1562 __sv_type __sv = __svt;
1563 return _M_append(__sv.data()
1564 + std::__sv_check(__sv.size(), __pos, "basic_string::append"),
1565 std::__sv_limit(__sv.size(), __pos, __n));
1566 }
1567#endif
1568
1569
1570
1571
1572
1573 _GLIBCXX20_CONSTEXPR
1574 void
1576 {
1577 const size_type __size = this->size();
1578 if (__size + 1 > this->capacity())
1579 this->_M_mutate(__size, size_type(0), 0, size_type(1));
1580 traits_type::assign(this->_M_data()[__size], __c);
1581 this->_M_set_length(__size + 1);
1582 }
1583
1584
1585
1586
1587
1588
1589 _GLIBCXX20_CONSTEXPR
1592 {
1593#if __cplusplus >= 201103L
1594 if (_Alloc_traits::_S_propagate_on_copy_assign())
1595 {
1596 if (!_Alloc_traits::_S_always_equal() && !_M_is_local()
1597 && _M_get_allocator() != __str._M_get_allocator())
1598 {
1599
1600
1601 if (__str.size() <= _S_local_capacity)
1602 {
1603 _M_destroy(_M_allocated_capacity);
1604 _M_data(_M_use_local_data());
1605 _M_set_length(0);
1606 }
1607 else
1608 {
1609 const auto __len = __str.size();
1610 auto __alloc = __str._M_get_allocator();
1611
1612 auto __ptr = _S_allocate(__alloc, __len + 1);
1613 _M_destroy(_M_allocated_capacity);
1614 _M_data(__ptr);
1615 _M_capacity(__len);
1616 _M_set_length(__len);
1617 }
1618 }
1619 std::__alloc_on_copy(_M_get_allocator(), __str._M_get_allocator());
1620 }
1621#endif
1622 this->_M_assign(__str);
1623 return *this;
1624 }
1625
1626#if __cplusplus >= 201103L
1627
1628
1629
1630
1631
1632
1633
1634
1635 _GLIBCXX20_CONSTEXPR
1638 noexcept(_Alloc_traits::_S_nothrow_move())
1639 {
1640
1641
1642 return *this = std::move(__str);
1643 }
1644#endif
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659 _GLIBCXX20_CONSTEXPR
1662 { return _M_replace(size_type(0), this->size(), __str._M_data()
1663 + __str._M_check(__pos, "basic_string::assign"),
1664 __str._M_limit(__pos, __n)); }
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676 _GLIBCXX20_CONSTEXPR
1678 assign(const _CharT* __s, size_type __n)
1679 {
1680 __glibcxx_requires_string_len(__s, __n);
1681 return _M_replace(size_type(0), this->size(), __s, __n);
1682 }
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693 _GLIBCXX20_CONSTEXPR
1695 assign(const _CharT* __s)
1696 {
1697 __glibcxx_requires_string(__s);
1698 return _M_replace(size_type(0), this->size(), __s,
1699 traits_type::length(__s));
1700 }
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711 _GLIBCXX20_CONSTEXPR
1713 assign(size_type __n, _CharT __c)
1714 { return _M_replace_aux(size_type(0), this->size(), __n, __c); }
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724#if __cplusplus >= 201103L
1725#pragma GCC diagnostic push
1726#pragma GCC diagnostic ignored "-Wc++17-extensions"
1727 template<class _InputIterator,
1728 typename = std::_RequireInputIter<_InputIterator>>
1729 _GLIBCXX20_CONSTEXPR
1731 assign(_InputIterator __first, _InputIterator __last)
1732 {
1733#if __cplusplus >= 202002L
1734 if constexpr (contiguous_iterator<_InputIterator>
1735 && is_same_v<iter_value_t<_InputIterator>, _CharT>)
1736#else
1737 if constexpr (__is_one_of<_InputIterator, const_iterator, iterator,
1738 const _CharT*, _CharT*>::value)
1739#endif
1740 {
1741 __glibcxx_requires_valid_range(__first, __last);
1742 return _M_replace(size_type(0), size(),
1743 std::__to_address(__first), __last - __first);
1744 }
1745 else
1747 }
1748#pragma GCC diagnostic pop
1749#else
1750 template<class _InputIterator>
1752 assign(_InputIterator __first, _InputIterator __last)
1753 { return this->replace(begin(), end(), __first, __last); }
1754#endif
1755
1756#if __cplusplus >= 201103L
1757
1758
1759
1760
1761
1762 _GLIBCXX20_CONSTEXPR
1764 assign(initializer_list<_CharT> __l)
1765 {
1766
1767
1768 const size_type __n = __l.size();
1771 else
1772 {
1773 if (__n)
1774 _S_copy(_M_data(), __l.begin(), __n);
1775 _M_set_length(__n);
1776 }
1777 return *this;
1778 }
1779#endif
1780
1781#if __cplusplus >= 201703L
1782
1783
1784
1785
1786
1787 template<typename _Tp>
1788 _GLIBCXX20_CONSTEXPR
1789 _If_sv<_Tp, basic_string&>
1790 assign(const _Tp& __svt)
1791 {
1792 __sv_type __sv = __svt;
1793 return this->assign(__sv.data(), __sv.size());
1794 }
1795
1796
1797
1798
1799
1800
1801
1802
1803 template<typename _Tp>
1804 _GLIBCXX20_CONSTEXPR
1805 _If_sv<_Tp, basic_string&>
1806 assign(const _Tp& __svt, size_type __pos, size_type __n = npos)
1807 {
1808 __sv_type __sv = __svt;
1809 return _M_replace(size_type(0), this->size(),
1810 __sv.data()
1811 + std::__sv_check(__sv.size(), __pos, "basic_string::assign"),
1812 std::__sv_limit(__sv.size(), __pos, __n));
1813 }
1814#endif
1815
1816#if __cplusplus >= 201103L
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832 _GLIBCXX20_CONSTEXPR
1833 iterator
1834 insert(const_iterator __p, size_type __n, _CharT __c)
1835 {
1836 _GLIBCXX_DEBUG_PEDASSERT(__p >= begin() && __p <= end());
1837 const size_type __pos = __p - begin();
1838 this->replace(__p, __p, __n, __c);
1839 return iterator(this->_M_data() + __pos);
1840 }
1841#else
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855 void
1856 insert(iterator __p, size_type __n, _CharT __c)
1857 { this->replace(__p, __p, __n, __c); }
1858#endif
1859
1860#if __cplusplus >= 201103L
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875 template<class _InputIterator,
1876 typename = std::_RequireInputIter<_InputIterator>>
1877 _GLIBCXX20_CONSTEXPR
1878 iterator
1879 insert(const_iterator __p, _InputIterator __beg, _InputIterator __end)
1880 {
1881 _GLIBCXX_DEBUG_PEDASSERT(__p >= begin() && __p <= end());
1882 const size_type __pos = __p - begin();
1883 this->replace(__p, __p, __beg, __end);
1884 return iterator(this->_M_data() + __pos);
1885 }
1886#else
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899 template<class _InputIterator>
1900 void
1901 insert(iterator __p, _InputIterator __beg, _InputIterator __end)
1902 { this->replace(__p, __p, __beg, __end); }
1903#endif
1904
1905#if __cplusplus >= 201103L
1906
1907
1908
1909
1910
1911
1912 _GLIBCXX20_CONSTEXPR
1913 iterator
1914 insert(const_iterator __p, initializer_list<_CharT> __l)
1915 { return this->insert(__p, __l.begin(), __l.end()); }
1916
1917#ifdef _GLIBCXX_DEFINING_STRING_INSTANTIATIONS
1918
1919 void
1920 insert(iterator __p, initializer_list<_CharT> __l)
1921 {
1922 _GLIBCXX_DEBUG_PEDASSERT(__p >= begin() && __p <= end());
1923 this->insert(__p - begin(), __l.begin(), __l.size());
1924 }
1925#endif
1926#endif
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940 _GLIBCXX20_CONSTEXPR
1943 { return this->replace(__pos1, size_type(0),
1944 __str._M_data(), __str.size()); }
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964 _GLIBCXX20_CONSTEXPR
1967 size_type __pos2, size_type __n = npos)
1968 { return this->replace(__pos1, size_type(0), __str._M_data()
1969 + __str._M_check(__pos2, "basic_string::insert"),
1970 __str._M_limit(__pos2, __n)); }
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988 _GLIBCXX20_CONSTEXPR
1990 insert(size_type __pos, const _CharT* __s, size_type __n)
1991 { return this->replace(__pos, size_type(0), __s, __n); }
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008 _GLIBCXX20_CONSTEXPR
2010 insert(size_type __pos, const _CharT* __s)
2011 {
2012 __glibcxx_requires_string(__s);
2013 return this->replace(__pos, size_type(0), __s,
2014 traits_type::length(__s));
2015 }
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033 _GLIBCXX20_CONSTEXPR
2035 insert(size_type __pos, size_type __n, _CharT __c)
2036 { return _M_replace_aux(_M_check(__pos, "basic_string::insert"),
2037 size_type(0), __n, __c); }
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052 _GLIBCXX20_CONSTEXPR
2053 iterator
2054 insert(__const_iterator __p, _CharT __c)
2055 {
2056 _GLIBCXX_DEBUG_PEDASSERT(__p >= begin() && __p <= end());
2057 const size_type __pos = __p - begin();
2058 _M_replace_aux(__pos, size_type(0), size_type(1), __c);
2059 return iterator(_M_data() + __pos);
2060 }
2061
2062#if __cplusplus >= 201703L
2063
2064
2065
2066
2067
2068
2069 template<typename _Tp>
2070 _GLIBCXX20_CONSTEXPR
2071 _If_sv<_Tp, basic_string&>
2072 insert(size_type __pos, const _Tp& __svt)
2073 {
2074 __sv_type __sv = __svt;
2075 return this->insert(__pos, __sv.data(), __sv.size());
2076 }
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086 template<typename _Tp>
2087 _GLIBCXX20_CONSTEXPR
2088 _If_sv<_Tp, basic_string&>
2089 insert(size_type __pos1, const _Tp& __svt,
2090 size_type __pos2, size_type __n = npos)
2091 {
2092 __sv_type __sv = __svt;
2093 return this->replace(__pos1, size_type(0),
2094 __sv.data()
2095 + std::__sv_check(__sv.size(), __pos2, "basic_string::insert"),
2096 std::__sv_limit(__sv.size(), __pos2, __n));
2097 }
2098#endif
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115 _GLIBCXX20_CONSTEXPR
2117 erase(size_type __pos = 0, size_type __n = npos)
2118 {
2119 _M_check(__pos, "basic_string::erase");
2120 if (__n == npos)
2121 this->_M_set_length(__pos);
2122 else if (__n != 0)
2123 this->_M_erase(__pos, _M_limit(__pos, __n));
2124 return *this;
2125 }
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135 _GLIBCXX20_CONSTEXPR
2136 iterator
2137 erase(__const_iterator __position)
2138 {
2139 _GLIBCXX_DEBUG_PEDASSERT(__position >= begin()
2140 && __position < end());
2141 const size_type __pos = __position - begin();
2142 this->_M_erase(__pos, size_type(1));
2143 return iterator(_M_data() + __pos);
2144 }
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155 _GLIBCXX20_CONSTEXPR
2156 iterator
2157 erase(__const_iterator __first, __const_iterator __last)
2158 {
2159 _GLIBCXX_DEBUG_PEDASSERT(__first >= begin() && __first <= __last
2160 && __last <= end());
2161 const size_type __pos = __first - begin();
2162 if (__last == end())
2163 this->_M_set_length(__pos);
2164 else
2165 this->_M_erase(__pos, __last - __first);
2166 return iterator(this->_M_data() + __pos);
2167 }
2168
2169#if __cplusplus >= 201103L
2170
2171
2172
2173
2174
2175 _GLIBCXX20_CONSTEXPR
2176 void
2178 {
2179 __glibcxx_assert(());
2180 _M_erase(size() - 1, 1);
2181 }
2182#endif
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201 _GLIBCXX20_CONSTEXPR
2204 { return this->replace(__pos, __n, __str._M_data(), __str.size()); }
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224 _GLIBCXX20_CONSTEXPR
2227 size_type __pos2, size_type __n2 = npos)
2228 { return this->replace(__pos1, __n1, __str._M_data()
2229 + __str._M_check(__pos2, "basic_string::replace"),
2230 __str._M_limit(__pos2, __n2)); }
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250 _GLIBCXX20_CONSTEXPR
2252 replace(size_type __pos, size_type __n1, const _CharT* __s,
2253 size_type __n2)
2254 {
2255 __glibcxx_requires_string_len(__s, __n2);
2256 return _M_replace(_M_check(__pos, "basic_string::replace"),
2257 _M_limit(__pos, __n1), __s, __n2);
2258 }
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276 _GLIBCXX20_CONSTEXPR
2278 replace(size_type __pos, size_type __n1, const _CharT* __s)
2279 {
2280 __glibcxx_requires_string(__s);
2281 return this->replace(__pos, __n1, __s, traits_type::length(__s));
2282 }
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301 _GLIBCXX20_CONSTEXPR
2303 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
2304 { return _M_replace_aux(_M_check(__pos, "basic_string::replace"),
2305 _M_limit(__pos, __n1), __n2, __c); }
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320 _GLIBCXX20_CONSTEXPR
2322 replace(__const_iterator __i1, __const_iterator __i2,
2324 { return this->replace(__i1, __i2, __str._M_data(), __str.size()); }
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341 _GLIBCXX20_CONSTEXPR
2343 replace(__const_iterator __i1, __const_iterator __i2,
2344 const _CharT* __s, size_type __n)
2345 {
2346 _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2
2347 && __i2 <= end());
2348 return this->replace(__i1 - begin(), __i2 - __i1, __s, __n);
2349 }
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364 _GLIBCXX20_CONSTEXPR
2366 replace(__const_iterator __i1, __const_iterator __i2, const _CharT* __s)
2367 {
2368 __glibcxx_requires_string(__s);
2369 return this->replace(__i1, __i2, __s, traits_type::length(__s));
2370 }
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386 _GLIBCXX20_CONSTEXPR
2388 replace(__const_iterator __i1, __const_iterator __i2, size_type __n,
2389 _CharT __c)
2390 {
2391 _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2
2392 && __i2 <= end());
2393 return _M_replace_aux(__i1 - begin(), __i2 - __i1, __n, __c);
2394 }
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411#if __cplusplus >= 201103L
2412 template<class _InputIterator,
2413 typename = std::_RequireInputIter<_InputIterator>>
2414 _GLIBCXX20_CONSTEXPR
2416 replace(const_iterator __i1, const_iterator __i2,
2417 _InputIterator __k1, _InputIterator __k2)
2418 {
2419 _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2
2420 && __i2 <= end());
2421 __glibcxx_requires_valid_range(__k1, __k2);
2422 return this->_M_replace_dispatch(__i1, __i2, __k1, __k2,
2423 std::__false_type());
2424 }
2425#else
2426 template<class _InputIterator>
2427#ifdef _GLIBCXX_DISAMBIGUATE_REPLACE_INST
2428 typename __enable_if_not_native_iterator<_InputIterator>::__type
2429#else
2431#endif
2432 replace(iterator __i1, iterator __i2,
2433 _InputIterator __k1, _InputIterator __k2)
2434 {
2435 _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2
2436 && __i2 <= end());
2437 __glibcxx_requires_valid_range(__k1, __k2);
2438 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
2439 return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
2440 }
2441#endif
2442
2443
2444
2445 _GLIBCXX20_CONSTEXPR
2447 replace(__const_iterator __i1, __const_iterator __i2,
2448 _CharT* __k1, _CharT* __k2)
2449 {
2450 _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2
2451 && __i2 <= end());
2452 __glibcxx_requires_valid_range(__k1, __k2);
2453 return this->replace(__i1 - begin(), __i2 - __i1,
2454 __k1, __k2 - __k1);
2455 }
2456
2457 _GLIBCXX20_CONSTEXPR
2459 replace(__const_iterator __i1, __const_iterator __i2,
2460 const _CharT* __k1, const _CharT* __k2)
2461 {
2462 _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2
2463 && __i2 <= end());
2464 __glibcxx_requires_valid_range(__k1, __k2);
2465 return this->replace(__i1 - begin(), __i2 - __i1,
2466 __k1, __k2 - __k1);
2467 }
2468
2469 _GLIBCXX20_CONSTEXPR
2471 replace(__const_iterator __i1, __const_iterator __i2,
2472 iterator __k1, iterator __k2)
2473 {
2474 _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2
2475 && __i2 <= end());
2476 __glibcxx_requires_valid_range(__k1, __k2);
2477 return this->replace(__i1 - begin(), __i2 - __i1,
2478 __k1.base(), __k2 - __k1);
2479 }
2480
2481 _GLIBCXX20_CONSTEXPR
2483 replace(__const_iterator __i1, __const_iterator __i2,
2484 const_iterator __k1, const_iterator __k2)
2485 {
2486 _GLIBCXX_DEBUG_PEDASSERT(begin() <= __i1 && __i1 <= __i2
2487 && __i2 <= end());
2488 __glibcxx_requires_valid_range(__k1, __k2);
2489 return this->replace(__i1 - begin(), __i2 - __i1,
2490 __k1.base(), __k2 - __k1);
2491 }
2492
2493#if __cplusplus >= 201103L
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508 _GLIBCXX20_CONSTEXPR
2510 initializer_list<_CharT> __l)
2511 { return this->replace(__i1, __i2, __l.begin(), __l.size()); }
2512#endif
2513
2514#if __cplusplus >= 201703L
2515
2516
2517
2518
2519
2520
2521
2522 template<typename _Tp>
2523 _GLIBCXX20_CONSTEXPR
2524 _If_sv<_Tp, basic_string&>
2525 replace(size_type __pos, size_type __n, const _Tp& __svt)
2526 {
2527 __sv_type __sv = __svt;
2528 return this->replace(__pos, __n, __sv.data(), __sv.size());
2529 }
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540 template<typename _Tp>
2541 _GLIBCXX20_CONSTEXPR
2542 _If_sv<_Tp, basic_string&>
2543 replace(size_type __pos1, size_type __n1, const _Tp& __svt,
2544 size_type __pos2, size_type __n2 = npos)
2545 {
2546 __sv_type __sv = __svt;
2547 return this->replace(__pos1, __n1,
2548 __sv.data()
2549 + std::__sv_check(__sv.size(), __pos2, "basic_string::replace"),
2550 std::__sv_limit(__sv.size(), __pos2, __n2));
2551 }
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562 template<typename _Tp>
2563 _GLIBCXX20_CONSTEXPR
2564 _If_sv<_Tp, basic_string&>
2565 replace(const_iterator __i1, const_iterator __i2, const _Tp& __svt)
2566 {
2567 __sv_type __sv = __svt;
2568 return this->replace(__i1 - begin(), __i2 - __i1, __sv);
2569 }
2570#endif
2571
2572 private:
2573 template<class _Integer>
2574 _GLIBCXX20_CONSTEXPR
2576 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2577 _Integer __n, _Integer __val, __true_type)
2578 { return _M_replace_aux(__i1 - begin(), __i2 - __i1, __n, __val); }
2579
2580 template<class _InputIterator>
2581 _GLIBCXX20_CONSTEXPR
2583 _M_replace_dispatch(const_iterator __i1, const_iterator __i2,
2584 _InputIterator __k1, _InputIterator __k2,
2585 __false_type);
2586
2587 _GLIBCXX20_CONSTEXPR
2589 _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
2590 _CharT __c);
2591
2592 __attribute__((__noinline__, __noclone__, __cold__)) void
2593 _M_replace_cold(pointer __p, size_type __len1, const _CharT* __s,
2594 const size_type __len2, const size_type __how_much);
2595
2596 _GLIBCXX20_CONSTEXPR
2598 _M_replace(size_type __pos, size_type __len1, const _CharT* __s,
2599 const size_type __len2);
2600
2601 _GLIBCXX20_CONSTEXPR
2603 _M_append(const _CharT* __s, size_type __n);
2604
2605 public:
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619 _GLIBCXX20_CONSTEXPR
2620 size_type
2621 copy(_CharT* __s, size_type __n, size_type __pos = 0) const;
2622
2623
2624
2625
2626
2627
2628
2629
2630 _GLIBCXX20_CONSTEXPR
2631 void
2633
2634
2635
2636
2637
2638
2639
2640
2641 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2642 const _CharT*
2643 c_str() const _GLIBCXX_NOEXCEPT
2644 { return _M_data(); }
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2655 const _CharT*
2656 data() const _GLIBCXX_NOEXCEPT
2657 { return _M_data(); }
2658
2659#if __cplusplus >= 201703L
2660
2661
2662
2663
2664
2665
2666 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2667 _CharT*
2668 data() noexcept
2669 { return _M_data(); }
2670#endif
2671
2672
2673
2674
2675 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2676 allocator_type
2678 { return _M_get_allocator(); }
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2693 size_type
2694 find(const _CharT* __s, size_type __pos, size_type __n) const
2695 _GLIBCXX_NOEXCEPT;
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2708 size_type
2710 _GLIBCXX_NOEXCEPT
2711 { return this->find(__str.data(), __pos, __str.size()); }
2712
2713#if __cplusplus >= 201703L
2714
2715
2716
2717
2718
2719
2720 template<typename _Tp>
2721 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2722 _If_sv<_Tp, size_type>
2723 find(const _Tp& __svt, size_type __pos = 0) const
2724 noexcept(is_same<_Tp, __sv_type>::value)
2725 {
2726 __sv_type __sv = __svt;
2727 return this->find(__sv.data(), __pos, __sv.size());
2728 }
2729#endif
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2742 size_type
2743 find(const _CharT* __s, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2744 {
2745 __glibcxx_requires_string(__s);
2746 return this->find(__s, __pos, traits_type::length(__s));
2747 }
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2760 size_type
2761 find(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT;
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2774 size_type
2776 _GLIBCXX_NOEXCEPT
2777 { return this->rfind(__str.data(), __pos, __str.size()); }
2778
2779#if __cplusplus >= 201703L
2780
2781
2782
2783
2784
2785
2786 template<typename _Tp>
2787 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2788 _If_sv<_Tp, size_type>
2789 rfind(const _Tp& __svt, size_type __pos = npos) const
2790 noexcept(is_same<_Tp, __sv_type>::value)
2791 {
2792 __sv_type __sv = __svt;
2793 return this->rfind(__sv.data(), __pos, __sv.size());
2794 }
2795#endif
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2810 size_type
2811 rfind(const _CharT* __s, size_type __pos, size_type __n) const
2812 _GLIBCXX_NOEXCEPT;
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2825 size_type
2826 rfind(const _CharT* __s, size_type __pos = npos) const
2827 {
2828 __glibcxx_requires_string(__s);
2829 return this->rfind(__s, __pos, traits_type::length(__s));
2830 }
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2843 size_type
2844 rfind(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT;
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2858 size_type
2860 _GLIBCXX_NOEXCEPT
2861 { return this->find_first_of(__str.data(), __pos, __str.size()); }
2862
2863#if __cplusplus >= 201703L
2864
2865
2866
2867
2868
2869
2870
2871 template<typename _Tp>
2872 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2873 _If_sv<_Tp, size_type>
2874 find_first_of(const _Tp& __svt, size_type __pos = 0) const
2875 noexcept(is_same<_Tp, __sv_type>::value)
2876 {
2877 __sv_type __sv = __svt;
2878 return this->find_first_of(__sv.data(), __pos, __sv.size());
2879 }
2880#endif
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2895 size_type
2896 find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
2897 _GLIBCXX_NOEXCEPT;
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2910 size_type
2911 find_first_of(const _CharT* __s, size_type __pos = 0) const
2912 _GLIBCXX_NOEXCEPT
2913 {
2914 __glibcxx_requires_string(__s);
2915 return this->find_first_of(__s, __pos, traits_type::length(__s));
2916 }
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2931 size_type
2932 find_first_of(_CharT __c, size_type __pos = 0) const _GLIBCXX_NOEXCEPT
2933 { return this->find(__c, __pos); }
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2947 size_type
2949 _GLIBCXX_NOEXCEPT
2950 { return this->find_last_of(__str.data(), __pos, __str.size()); }
2951
2952#if __cplusplus >= 201703L
2953
2954
2955
2956
2957
2958
2959
2960 template<typename _Tp>
2961 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2962 _If_sv<_Tp, size_type>
2963 find_last_of(const _Tp& __svt, size_type __pos = npos) const
2964 noexcept(is_same<_Tp, __sv_type>::value)
2965 {
2966 __sv_type __sv = __svt;
2967 return this->find_last_of(__sv.data(), __pos, __sv.size());
2968 }
2969#endif
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2984 size_type
2985 find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
2986 _GLIBCXX_NOEXCEPT;
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
2999 size_type
3000 find_last_of(const _CharT* __s, size_type __pos = npos) const
3001 _GLIBCXX_NOEXCEPT
3002 {
3003 __glibcxx_requires_string(__s);
3004 return this->find_last_of(__s, __pos, traits_type::length(__s));
3005 }
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3020 size_type
3021 find_last_of(_CharT __c, size_type __pos = npos) const _GLIBCXX_NOEXCEPT
3022 { return this->rfind(__c, __pos); }
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3035 size_type
3037 _GLIBCXX_NOEXCEPT
3038 { return this->find_first_not_of(__str.data(), __pos, __str.size()); }
3039
3040#if __cplusplus >= 201703L
3041
3042
3043
3044
3045
3046
3047
3048 template<typename _Tp>
3049 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3050 _If_sv<_Tp, size_type>
3052 noexcept(is_same<_Tp, __sv_type>::value)
3053 {
3054 __sv_type __sv = __svt;
3055 return this->find_first_not_of(__sv.data(), __pos, __sv.size());
3056 }
3057#endif
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3072 size_type
3074 size_type __n) const _GLIBCXX_NOEXCEPT;
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3087 size_type
3089 _GLIBCXX_NOEXCEPT
3090 {
3091 __glibcxx_requires_string(__s);
3092 return this->find_first_not_of(__s, __pos, traits_type::length(__s));
3093 }
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3106 size_type
3108 _GLIBCXX_NOEXCEPT;
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3122 size_type
3124 _GLIBCXX_NOEXCEPT
3125 { return this->find_last_not_of(__str.data(), __pos, __str.size()); }
3126
3127#if __cplusplus >= 201703L
3128
3129
3130
3131
3132
3133
3134
3135 template<typename _Tp>
3136 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3137 _If_sv<_Tp, size_type>
3139 noexcept(is_same<_Tp, __sv_type>::value)
3140 {
3141 __sv_type __sv = __svt;
3142 return this->find_last_not_of(__sv.data(), __pos, __sv.size());
3143 }
3144#endif
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3159 size_type
3161 size_type __n) const _GLIBCXX_NOEXCEPT;
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3174 size_type
3176 _GLIBCXX_NOEXCEPT
3177 {
3178 __glibcxx_requires_string(__s);
3179 return this->find_last_not_of(__s, __pos, traits_type::length(__s));
3180 }
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3193 size_type
3195 _GLIBCXX_NOEXCEPT;
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3211 substr(size_type __pos = 0, size_type __n = npos) const
3213 _M_check(__pos, "basic_string::substr"), __n); }
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3230 int
3232 {
3233 const size_type __size = this->size();
3234 const size_type __osize = __str.size();
3235 const size_type __len = std::min(__size, __osize);
3236
3237 int __r = traits_type::compare(_M_data(), __str.data(), __len);
3238 if (!__r)
3239 __r = _S_compare(__size, __osize);
3240 return __r;
3241 }
3242
3243#if __cplusplus >= 201703L
3244
3245
3246
3247
3248
3249 template<typename _Tp>
3250 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3251 _If_sv<_Tp, int>
3252 compare(const _Tp& __svt) const
3253 noexcept(is_same<_Tp, __sv_type>::value)
3254 {
3255 __sv_type __sv = __svt;
3256 const size_type __size = this->size();
3257 const size_type __osize = __sv.size();
3258 const size_type __len = std::min(__size, __osize);
3259
3260 int __r = traits_type::compare(_M_data(), __sv.data(), __len);
3261 if (!__r)
3262 __r = _S_compare(__size, __osize);
3263 return __r;
3264 }
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274 template<typename _Tp>
3275 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3276 _If_sv<_Tp, int>
3277 compare(size_type __pos, size_type __n, const _Tp& __svt) const
3278 noexcept(is_same<_Tp, __sv_type>::value)
3279 {
3280 __sv_type __sv = __svt;
3281 return __sv_type(*this).substr(__pos, __n).compare(__sv);
3282 }
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294 template<typename _Tp>
3295 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3296 _If_sv<_Tp, int>
3297 compare(size_type __pos1, size_type __n1, const _Tp& __svt,
3298 size_type __pos2, size_type __n2 = npos) const
3299 noexcept(is_same<_Tp, __sv_type>::value)
3300 {
3301 __sv_type __sv = __svt;
3302 return __sv_type(*this)
3303 .substr(__pos1, __n1).compare(__sv.substr(__pos2, __n2));
3304 }
3305#endif
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3327 int
3328 compare(size_type __pos, size_type __n, const basic_string& __str) const
3329 {
3330 _M_check(__pos, "basic_string::compare");
3331 __n = _M_limit(__pos, __n);
3332 const size_type __osize = __str.size();
3333 const size_type __len = std::min(__n, __osize);
3334 int __r = traits_type::compare(_M_data() + __pos, __str.data(), __len);
3335 if (!__r)
3336 __r = _S_compare(__n, __osize);
3337 return __r;
3338 }
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3364 int
3366 size_type __pos2, size_type __n2 = npos) const
3367 {
3368 _M_check(__pos1, "basic_string::compare");
3369 __str._M_check(__pos2, "basic_string::compare");
3370 __n1 = _M_limit(__pos1, __n1);
3371 __n2 = __str._M_limit(__pos2, __n2);
3372 const size_type __len = std::min(__n1, __n2);
3373 int __r = traits_type::compare(_M_data() + __pos1,
3374 __str.data() + __pos2, __len);
3375 if (!__r)
3376 __r = _S_compare(__n1, __n2);
3377 return __r;
3378 }
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3395 int
3396 compare(const _CharT* __s) const _GLIBCXX_NOEXCEPT
3397 {
3398 __glibcxx_requires_string(__s);
3399 const size_type __size = this->size();
3400 const size_type __osize = traits_type::length(__s);
3401 const size_type __len = std::min(__size, __osize);
3402 int __r = traits_type::compare(_M_data(), __s, __len);
3403 if (!__r)
3404 __r = _S_compare(__size, __osize);
3405 return __r;
3406 }
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3430 int
3431 compare(size_type __pos, size_type __n1, const _CharT* __s) const
3432 {
3433 __glibcxx_requires_string(__s);
3434 _M_check(__pos, "basic_string::compare");
3435 __n1 = _M_limit(__pos, __n1);
3436 const size_type __osize = traits_type::length(__s);
3437 const size_type __len = std::min(__n1, __osize);
3438 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3439 if (!__r)
3440 __r = _S_compare(__n1, __osize);
3441 return __r;
3442 }
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3469 int
3470 compare(size_type __pos, size_type __n1, const _CharT* __s,
3471 size_type __n2) const
3472 {
3473 __glibcxx_requires_string_len(__s, __n2);
3474 _M_check(__pos, "basic_string::compare");
3475 __n1 = _M_limit(__pos, __n1);
3476 const size_type __len = std::min(__n1, __n2);
3477 int __r = traits_type::compare(_M_data() + __pos, __s, __len);
3478 if (!__r)
3479 __r = _S_compare(__n1, __n2);
3480 return __r;
3481 }
3482
3483#if __cplusplus >= 202002L
3484 [[nodiscard]]
3485 constexpr bool
3486 starts_with(basic_string_view<_CharT, _Traits> __x) const noexcept
3487 { return __sv_type(this->data(), this->size()).starts_with(__x); }
3488
3489 [[nodiscard]]
3490 constexpr bool
3491 starts_with(_CharT __x) const noexcept
3492 { return __sv_type(this->data(), this->size()).starts_with(__x); }
3493
3494 [[nodiscard, __gnu__::__nonnull__]]
3495 constexpr bool
3496 starts_with(const _CharT* __x) const noexcept
3497 { return __sv_type(this->data(), this->size()).starts_with(__x); }
3498
3499 [[nodiscard]]
3500 constexpr bool
3501 ends_with(basic_string_view<_CharT, _Traits> __x) const noexcept
3502 { return __sv_type(this->data(), this->size()).ends_with(__x); }
3503
3504 [[nodiscard]]
3505 constexpr bool
3506 ends_with(_CharT __x) const noexcept
3507 { return __sv_type(this->data(), this->size()).ends_with(__x); }
3508
3509 [[nodiscard, __gnu__::__nonnull__]]
3510 constexpr bool
3511 ends_with(const _CharT* __x) const noexcept
3512 { return __sv_type(this->data(), this->size()).ends_with(__x); }
3513#endif
3514
3515#if __cplusplus > 202002L
3516 [[nodiscard]]
3517 constexpr bool
3518 contains(basic_string_view<_CharT, _Traits> __x) const noexcept
3519 { return __sv_type(this->data(), this->size()).contains(__x); }
3520
3521 [[nodiscard]]
3522 constexpr bool
3523 contains(_CharT __x) const noexcept
3524 { return __sv_type(this->data(), this->size()).contains(__x); }
3525
3526 [[nodiscard, __gnu__::__nonnull__]]
3527 constexpr bool
3528 contains(const _CharT* __x) const noexcept
3529 { return __sv_type(this->data(), this->size()).contains(__x); }
3530#endif
3531
3532
3533 template<typename, typename, typename> friend class basic_stringbuf;
3534 };
3535_GLIBCXX_END_NAMESPACE_CXX11
3536_GLIBCXX_END_NAMESPACE_VERSION
3537}
3538#endif
3539
3540namespace std _GLIBCXX_VISIBILITY(default)
3541{
3542_GLIBCXX_BEGIN_NAMESPACE_VERSION
3543
3544#if __cpp_deduction_guides >= 201606
3545_GLIBCXX_BEGIN_NAMESPACE_CXX11
3546 template<typename _InputIterator, typename _CharT
3547 = typename iterator_traits<_InputIterator>::value_type,
3548 typename _Allocator = allocator<_CharT>,
3549 typename = _RequireInputIter<_InputIterator>,
3550 typename = _RequireAllocator<_Allocator>>
3551 basic_string(_InputIterator, _InputIterator, _Allocator = _Allocator())
3552 -> basic_string<_CharT, char_traits<_CharT>, _Allocator>;
3553
3554
3555
3556 template<typename _CharT, typename _Traits,
3557 typename _Allocator = allocator<_CharT>,
3558 typename = _RequireAllocator<_Allocator>>
3559 basic_string(basic_string_view<_CharT, _Traits>, const _Allocator& = _Allocator())
3560 -> basic_string<_CharT, _Traits, _Allocator>;
3561
3562 template<typename _CharT, typename _Traits,
3563 typename _Allocator = allocator<_CharT>,
3564 typename = _RequireAllocator<_Allocator>>
3565 basic_string(basic_string_view<_CharT, _Traits>,
3566 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3567 typename basic_string<_CharT, _Traits, _Allocator>::size_type,
3568 const _Allocator& = _Allocator())
3569 -> basic_string<_CharT, _Traits, _Allocator>;
3570_GLIBCXX_END_NAMESPACE_CXX11
3571#endif
3572
3573 template<typename _Str>
3574 _GLIBCXX20_CONSTEXPR
3575 inline _Str
3576 __str_concat(typename _Str::value_type const* __lhs,
3577 typename _Str::size_type __lhs_len,
3578 typename _Str::value_type const* __rhs,
3579 typename _Str::size_type __rhs_len,
3580 typename _Str::allocator_type const& __a)
3581 {
3582 typedef typename _Str::allocator_type allocator_type;
3584 _Str __str(_Alloc_traits::_S_select_on_copy(__a));
3585 __str.reserve(__lhs_len + __rhs_len);
3586 __str.append(__lhs, __lhs_len);
3587 __str.append(__rhs, __rhs_len);
3588 return __str;
3589 }
3590
3591
3592
3593
3594
3595
3596
3597
3598 template<typename _CharT, typename _Traits, typename _Alloc>
3599 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3600 inline basic_string<_CharT, _Traits, _Alloc>
3603 {
3605 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3606 __rhs.c_str(), __rhs.size(),
3607 __lhs.get_allocator());
3608 }
3609
3610
3611
3612
3613
3614
3615
3616 template<typename _CharT, typename _Traits, typename _Alloc>
3617 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3618 inline basic_string<_CharT,_Traits,_Alloc>
3621 {
3622 __glibcxx_requires_string(__lhs);
3624 return std::__str_concat<_Str>(__lhs, _Traits::length(__lhs),
3625 __rhs.c_str(), __rhs.size(),
3626 __rhs.get_allocator());
3627 }
3628
3629
3630
3631
3632
3633
3634
3635 template<typename _CharT, typename _Traits, typename _Alloc>
3636 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3637 inline basic_string<_CharT,_Traits,_Alloc>
3639 {
3641 return std::__str_concat<_Str>(__builtin_addressof(__lhs), 1,
3642 __rhs.c_str(), __rhs.size(),
3643 __rhs.get_allocator());
3644 }
3645
3646
3647
3648
3649
3650
3651
3652 template<typename _CharT, typename _Traits, typename _Alloc>
3653 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3654 inline basic_string<_CharT, _Traits, _Alloc>
3656 const _CharT* __rhs)
3657 {
3658 __glibcxx_requires_string(__rhs);
3660 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3661 __rhs, _Traits::length(__rhs),
3662 __lhs.get_allocator());
3663 }
3664
3665
3666
3667
3668
3669
3670 template<typename _CharT, typename _Traits, typename _Alloc>
3671 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3672 inline basic_string<_CharT, _Traits, _Alloc>
3674 {
3676 return std::__str_concat<_Str>(__lhs.c_str(), __lhs.size(),
3677 __builtin_addressof(__rhs), 1,
3678 __lhs.get_allocator());
3679 }
3680
3681#if __cplusplus >= 201103L
3682 template<typename _CharT, typename _Traits, typename _Alloc>
3683 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3684 inline basic_string<_CharT, _Traits, _Alloc>
3685 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3686 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3687 { return std::move(__lhs.append(__rhs)); }
3688
3689 template<typename _CharT, typename _Traits, typename _Alloc>
3690 _GLIBCXX20_CONSTEXPR
3691 inline basic_string<_CharT, _Traits, _Alloc>
3692 operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3693 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3694 { return std::move(__rhs.insert(0, __lhs)); }
3695
3696 template<typename _CharT, typename _Traits, typename _Alloc>
3697 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3698 inline basic_string<_CharT, _Traits, _Alloc>
3699 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3700 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3701 {
3702#if _GLIBCXX_USE_CXX11_ABI
3703 using _Alloc_traits = allocator_traits<_Alloc>;
3704 bool __use_rhs = false;
3705 if _GLIBCXX17_CONSTEXPR (typename _Alloc_traits::is_always_equal{})
3706 __use_rhs = true;
3707 else if (__lhs.get_allocator() == __rhs.get_allocator())
3708 __use_rhs = true;
3709 if (__use_rhs)
3710#endif
3711 {
3712 const auto __size = __lhs.size() + __rhs.size();
3713 if (__size > __lhs.capacity() && __size <= __rhs.capacity())
3714 return std::move(__rhs.insert(0, __lhs));
3715 }
3716 return std::move(__lhs.append(__rhs));
3717 }
3718
3719 template<typename _CharT, typename _Traits, typename _Alloc>
3720 _GLIBCXX_NODISCARD _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3721 inline basic_string<_CharT, _Traits, _Alloc>
3723 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3724 { return std::move(__rhs.insert(0, __lhs)); }
3725
3726 template<typename _CharT, typename _Traits, typename _Alloc>
3727 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3728 inline basic_string<_CharT, _Traits, _Alloc>
3730 basic_string<_CharT, _Traits, _Alloc>&& __rhs)
3731 { return std::move(__rhs.insert(0, 1, __lhs)); }
3732
3733 template<typename _CharT, typename _Traits, typename _Alloc>
3734 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3735 inline basic_string<_CharT, _Traits, _Alloc>
3736 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3737 const _CharT* __rhs)
3738 { return std::move(__lhs.append(__rhs)); }
3739
3740 template<typename _CharT, typename _Traits, typename _Alloc>
3741 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3742 inline basic_string<_CharT, _Traits, _Alloc>
3743 operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
3744 _CharT __rhs)
3745 { return std::move(__lhs.append(1, __rhs)); }
3746#endif
3747
3748
3749
3750
3751
3752
3753
3754
3755 template<typename _CharT, typename _Traits, typename _Alloc>
3756 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3757 inline bool
3760 _GLIBCXX_NOEXCEPT
3761 {
3762 return __lhs.size() == __rhs.size()
3763 && !_Traits::compare(__lhs.data(), __rhs.data(), __lhs.size());
3764 }
3765
3766
3767
3768
3769
3770
3771
3772 template<typename _CharT, typename _Traits, typename _Alloc>
3773 _GLIBCXX_NODISCARD _GLIBCXX20_CONSTEXPR
3774 inline bool
3776 const _CharT* __rhs)
3777 {
3778 return __lhs.size() == _Traits::length(__rhs)
3779 && !_Traits::compare(__lhs.data(), __rhs, __lhs.size());
3780 }
3781
3782#if __cpp_lib_three_way_comparison
3783
3784
3785
3786
3787
3788
3789
3790 template<typename _CharT, typename _Traits, typename _Alloc>
3791 [[nodiscard]]
3792 constexpr auto
3795 -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
3796 { return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
3797
3798
3799
3800
3801
3802
3803
3804
3805 template<typename _CharT, typename _Traits, typename _Alloc>
3806 [[nodiscard]]
3807 constexpr auto
3809 const _CharT* __rhs) noexcept
3810 -> decltype(__detail::__char_traits_cmp_cat<_Traits>(0))
3811 { return __detail::__char_traits_cmp_cat<_Traits>(__lhs.compare(__rhs)); }
3812#else
3813
3814
3815
3816
3817
3818
3819 template<typename _CharT, typename _Traits, typename _Alloc>
3820 _GLIBCXX_NODISCARD
3821 inline bool
3822 operator==(const _CharT* __lhs,
3823 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3824 { return __rhs == __lhs; }
3825
3826
3827
3828
3829
3830
3831
3832
3833 template<typename _CharT, typename _Traits, typename _Alloc>
3834 _GLIBCXX_NODISCARD
3835 inline bool
3836 operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3837 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3838 _GLIBCXX_NOEXCEPT
3839 { return !(__lhs == __rhs); }
3840
3841
3842
3843
3844
3845
3846
3847 template<typename _CharT, typename _Traits, typename _Alloc>
3848 _GLIBCXX_NODISCARD
3849 inline bool
3850 operator!=(const _CharT* __lhs,
3851 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3852 { return !(__rhs == __lhs); }
3853
3854
3855
3856
3857
3858
3859
3860 template<typename _CharT, typename _Traits, typename _Alloc>
3861 _GLIBCXX_NODISCARD
3862 inline bool
3863 operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3864 const _CharT* __rhs)
3865 { return !(__lhs == __rhs); }
3866
3867
3868
3869
3870
3871
3872
3873
3874 template<typename _CharT, typename _Traits, typename _Alloc>
3875 _GLIBCXX_NODISCARD
3876 inline bool
3877 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3878 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3879 _GLIBCXX_NOEXCEPT
3880 { return __lhs.compare(__rhs) < 0; }
3881
3882
3883
3884
3885
3886
3887
3888 template<typename _CharT, typename _Traits, typename _Alloc>
3889 _GLIBCXX_NODISCARD
3890 inline bool
3891 operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3892 const _CharT* __rhs)
3893 { return __lhs.compare(__rhs) < 0; }
3894
3895
3896
3897
3898
3899
3900
3901 template<typename _CharT, typename _Traits, typename _Alloc>
3902 _GLIBCXX_NODISCARD
3903 inline bool
3905 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3906 { return __rhs.compare(__lhs) > 0; }
3907
3908
3909
3910
3911
3912
3913
3914
3915 template<typename _CharT, typename _Traits, typename _Alloc>
3916 _GLIBCXX_NODISCARD
3917 inline bool
3918 operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3919 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3920 _GLIBCXX_NOEXCEPT
3921 { return __lhs.compare(__rhs) > 0; }
3922
3923
3924
3925
3926
3927
3928
3929 template<typename _CharT, typename _Traits, typename _Alloc>
3930 _GLIBCXX_NODISCARD
3931 inline bool
3932 operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3933 const _CharT* __rhs)
3934 { return __lhs.compare(__rhs) > 0; }
3935
3936
3937
3938
3939
3940
3941
3942 template<typename _CharT, typename _Traits, typename _Alloc>
3943 _GLIBCXX_NODISCARD
3944 inline bool
3946 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3947 { return __rhs.compare(__lhs) < 0; }
3948
3949
3950
3951
3952
3953
3954
3955
3956 template<typename _CharT, typename _Traits, typename _Alloc>
3957 _GLIBCXX_NODISCARD
3958 inline bool
3959 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3960 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3961 _GLIBCXX_NOEXCEPT
3962 { return __lhs.compare(__rhs) <= 0; }
3963
3964
3965
3966
3967
3968
3969
3970 template<typename _CharT, typename _Traits, typename _Alloc>
3971 _GLIBCXX_NODISCARD
3972 inline bool
3973 operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
3974 const _CharT* __rhs)
3975 { return __lhs.compare(__rhs) <= 0; }
3976
3977
3978
3979
3980
3981
3982
3983 template<typename _CharT, typename _Traits, typename _Alloc>
3984 _GLIBCXX_NODISCARD
3985 inline bool
3987 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
3988 { return __rhs.compare(__lhs) >= 0; }
3989
3990
3991
3992
3993
3994
3995
3996
3997 template<typename _CharT, typename _Traits, typename _Alloc>
3998 _GLIBCXX_NODISCARD
3999 inline bool
4000 operator>=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
4001 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
4002 _GLIBCXX_NOEXCEPT
4003 { return __lhs.compare(__rhs) >= 0; }
4004
4005
4006
4007
4008
4009
4010
4011 template<typename _CharT, typename _Traits, typename _Alloc>
4012 _GLIBCXX_NODISCARD
4013 inline bool
4014 operator>=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
4015 const _CharT* __rhs)
4016 { return __lhs.compare(__rhs) >= 0; }
4017
4018
4019
4020
4021
4022
4023
4024 template<typename _CharT, typename _Traits, typename _Alloc>
4025 _GLIBCXX_NODISCARD
4026 inline bool
4028 const basic_string<_CharT, _Traits, _Alloc>& __rhs)
4029 { return __rhs.compare(__lhs) <= 0; }
4030#endif
4031
4032
4033
4034
4035
4036
4037
4038
4039 template<typename _CharT, typename _Traits, typename _Alloc>
4040 _GLIBCXX20_CONSTEXPR
4041 inline void
4044 _GLIBCXX_NOEXCEPT_IF(noexcept(__lhs.swap(__rhs)))
4045 { __lhs.swap(__rhs); }
4046
4047
4048
4049
4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060 template<typename _CharT, typename _Traits, typename _Alloc>
4061 basic_istream<_CharT, _Traits>&
4062 operator>>(basic_istream<_CharT, _Traits>& __is,
4063 basic_string<_CharT, _Traits, _Alloc>& __str);
4064
4065 template<>
4066 basic_istream&
4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078 template<typename _CharT, typename _Traits, typename _Alloc>
4082 {
4083
4084
4085 return __ostream_insert(__os, __str.data(), __str.size());
4086 }
4087
4088
4089
4090
4091
4092
4093
4094
4095
4096
4097
4098
4099
4100
4101 template<typename _CharT, typename _Traits, typename _Alloc>
4102 basic_istream<_CharT, _Traits>&
4103 getline(basic_istream<_CharT, _Traits>& __is,
4104 basic_string<_CharT, _Traits, _Alloc>& __str, _CharT __delim);
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
4116
4117
4118 template<typename _CharT, typename _Traits, typename _Alloc>
4119 inline basic_istream<_CharT, _Traits>&
4123
4124#if __cplusplus >= 201103L
4125
4126 template<typename _CharT, typename _Traits, typename _Alloc>
4127 inline basic_istream<_CharT, _Traits>&
4130 { return std::getline(__is, __str, __delim); }
4131
4132
4133 template<typename _CharT, typename _Traits, typename _Alloc>
4134 inline basic_istream<_CharT, _Traits>&
4138#endif
4139
4140 template<>
4141 basic_istream&
4142 getline(basic_istream& __in, basic_string& __str,
4143 char __delim);
4144
4145#ifdef _GLIBCXX_USE_WCHAR_T
4146 template<>
4147 basic_istream<wchar_t>&
4148 getline(basic_istream<wchar_t>& __in, basic_string<wchar_t>& __str,
4149 wchar_t __delim);
4150#endif
4151
4152_GLIBCXX_END_NAMESPACE_VERSION
4153}
4154
4155#if __cplusplus >= 201103L
4156
4159
4160namespace std _GLIBCXX_VISIBILITY(default)
4161{
4162_GLIBCXX_BEGIN_NAMESPACE_VERSION
4163_GLIBCXX_BEGIN_NAMESPACE_CXX11
4164
4165
4166 inline int
4167 stoi(const string& __str, size_t* __idx = 0, int __base = 10)
4168 { return __gnu_cxx::__stoa<long, int>(&std::strtol, "stoi", __str.c_str(),
4169 __idx, __base); }
4170
4171 inline long
4172 stol(const string& __str, size_t* __idx = 0, int __base = 10)
4173 { return __gnu_cxx::__stoa(&std::strtol, "stol", __str.c_str(),
4174 __idx, __base); }
4175
4176 inline unsigned long
4177 stoul(const string& __str, size_t* __idx = 0, int __base = 10)
4178 { return __gnu_cxx::__stoa(&std::strtoul, "stoul", __str.c_str(),
4179 __idx, __base); }
4180
4181#if _GLIBCXX_USE_C99_STDLIB
4182 inline long long
4183 stoll(const string& __str, size_t* __idx = 0, int __base = 10)
4184 { return __gnu_cxx::__stoa(&std::strtoll, "stoll", __str.c_str(),
4185 __idx, __base); }
4186
4187 inline unsigned long long
4188 stoull(const string& __str, size_t* __idx = 0, int __base = 10)
4189 { return __gnu_cxx::__stoa(&std::strtoull, "stoull", __str.c_str(),
4190 __idx, __base); }
4191#elif __LONG_WIDTH__ == __LONG_LONG_WIDTH__
4192 inline long long
4193 stoll(const string& __str, size_t* __idx = 0, int __base = 10)
4194 { return std::stol(__str, __idx, __base); }
4195
4196 inline unsigned long long
4197 stoull(const string& __str, size_t* __idx = 0, int __base = 10)
4198 { return std::stoul(__str, __idx, __base); }
4199#endif
4200
4201 inline double
4202 stod(const string& __str, size_t* __idx = 0)
4203 { return __gnu_cxx::__stoa(&std::strtod, "stod", __str.c_str(), __idx); }
4204
4205#if _GLIBCXX_HAVE_STRTOF
4206
4207 inline float
4208 stof(const string& __str, size_t* __idx = 0)
4209 { return __gnu_cxx::__stoa(&std::strtof, "stof", __str.c_str(), __idx); }
4210#else
4211 inline float
4212 stof(const string& __str, size_t* __idx = 0)
4213 {
4214 double __d = std::stod(__str, __idx);
4215 if (__builtin_isfinite(__d) && __d != 0.0)
4216 {
4217 double __abs_d = __builtin_fabs(__d);
4218 if (__abs_d < __FLT_MIN__ || __abs_d > __FLT_MAX__)
4219 {
4220 errno = ERANGE;
4221 std::__throw_out_of_range("stof");
4222 }
4223 }
4224 return __d;
4225 }
4226#endif
4227
4228#if _GLIBCXX_HAVE_STRTOLD && ! _GLIBCXX_HAVE_BROKEN_STRTOLD
4229 inline long double
4230 stold(const string& __str, size_t* __idx = 0)
4231 { return __gnu_cxx::__stoa(&std::strtold, "stold", __str.c_str(), __idx); }
4232#elif __DBL_MANT_DIG__ == __LDBL_MANT_DIG__
4233 inline long double
4234 stold(const string& __str, size_t* __idx = 0)
4235 { return std::stod(__str, __idx); }
4236#endif
4237
4238
4239
4240
4241 _GLIBCXX_NODISCARD
4242 inline string
4243 to_string(int __val)
4244#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4245 noexcept
4246#endif
4247 {
4248 const bool __neg = __val < 0;
4249 const unsigned __uval = __neg ? (unsigned)~__val + 1u : __val;
4250 const auto __len = __detail::__to_chars_len(__uval);
4251 string __str;
4252 __str.__resize_and_overwrite(__neg + __len, [=](char* __p, size_t __n) {
4253 __p[0] = '-';
4254 __detail::__to_chars_10_impl(__p + (int)__neg, __len, __uval);
4255 return __n;
4256 });
4257 return __str;
4258 }
4259
4260 _GLIBCXX_NODISCARD
4261 inline string
4262 to_string(unsigned __val)
4263#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_INT__) <= 32
4264 noexcept
4265#endif
4266 {
4267 const auto __len = __detail::__to_chars_len(__val);
4268 string __str;
4269 __str.__resize_and_overwrite(__len, [__val](char* __p, size_t __n) {
4270 __detail::__to_chars_10_impl(__p, __n, __val);
4271 return __n;
4272 });
4273 return __str;
4274 }
4275
4276 _GLIBCXX_NODISCARD
4277 inline string
4278 to_string(long __val)
4279#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4280 noexcept
4281#endif
4282 {
4283 const bool __neg = __val < 0;
4284 const unsigned long __uval = __neg ? (unsigned long)~__val + 1ul : __val;
4285 const auto __len = __detail::__to_chars_len(__uval);
4286 string __str;
4287 __str.__resize_and_overwrite(__neg + __len, [=](char* __p, size_t __n) {
4288 __p[0] = '-';
4289 __detail::__to_chars_10_impl(__p + (int)__neg, __len, __uval);
4290 return __n;
4291 });
4292 return __str;
4293 }
4294
4295 _GLIBCXX_NODISCARD
4296 inline string
4297 to_string(unsigned long __val)
4298#if _GLIBCXX_USE_CXX11_ABI && (__CHAR_BIT__ * __SIZEOF_LONG__) <= 32
4299 noexcept
4300#endif
4301 {
4302 const auto __len = __detail::__to_chars_len(__val);
4303 string __str;
4304 __str.__resize_and_overwrite(__len, [__val](char* __p, size_t __n) {
4305 __detail::__to_chars_10_impl(__p, __n, __val);
4306 return __n;
4307 });
4308 return __str;
4309 }
4310
4311 _GLIBCXX_NODISCARD
4312 inline string
4313 to_string(long long __val)
4314 {
4315 const bool __neg = __val < 0;
4316 const unsigned long long __uval
4317 = __neg ? (unsigned long long)~__val + 1ull : __val;
4318 const auto __len = __detail::__to_chars_len(__uval);
4319 string __str;
4320 __str.__resize_and_overwrite(__neg + __len, [=](char* __p, size_t __n) {
4321 __p[0] = '-';
4322 __detail::__to_chars_10_impl(__p + (int)__neg, __len, __uval);
4323 return __n;
4324 });
4325 return __str;
4326 }
4327
4328 _GLIBCXX_NODISCARD
4329 inline string
4330 to_string(unsigned long long __val)
4331 {
4332 const auto __len = __detail::__to_chars_len(__val);
4333 string __str;
4334 __str.__resize_and_overwrite(__len, [__val](char* __p, size_t __n) {
4335 __detail::__to_chars_10_impl(__p, __n, __val);
4336 return __n;
4337 });
4338 return __str;
4339 }
4340
4341#if __glibcxx_to_string >= 202306L
4342
4343 [[nodiscard]]
4344 inline string
4345 to_string(float __val)
4346 {
4347 string __str;
4348 size_t __len = 15;
4349 do {
4350 __str.resize_and_overwrite(__len,
4351 [__val, &__len] (char* __p, size_t __n) {
4352 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4353 if (__err == errc{}) [[likely]]
4354 return __end - __p;
4355 __len *= 2;
4356 return __p - __p;;
4357 });
4358 } while (__str.empty());
4359 return __str;
4360 }
4361
4362 [[nodiscard]]
4363 inline string
4364 to_string(double __val)
4365 {
4366 string __str;
4367 size_t __len = 15;
4368 do {
4369 __str.resize_and_overwrite(__len,
4370 [__val, &__len] (char* __p, size_t __n) {
4371 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4372 if (__err == errc{}) [[likely]]
4373 return __end - __p;
4374 __len *= 2;
4375 return __p - __p;;
4376 });
4377 } while (__str.empty());
4378 return __str;
4379 }
4380
4381 [[nodiscard]]
4382 inline string
4383 to_string(long double __val)
4384 {
4385 string __str;
4386 size_t __len = 15;
4387 do {
4388 __str.resize_and_overwrite(__len,
4389 [__val, &__len] (char* __p, size_t __n) {
4390 auto [__end, __err] = std::to_chars(__p, __p + __n, __val);
4391 if (__err == errc{}) [[likely]]
4392 return __end - __p;
4393 __len *= 2;
4394 return __p - __p;;
4395 });
4396 } while (__str.empty());
4397 return __str;
4398 }
4399#elif _GLIBCXX_USE_C99_STDIO
4400
4401
4402 _GLIBCXX_NODISCARD
4403 inline string
4404 to_string(float __val)
4405 {
4406 const int __n =
4407 __gnu_cxx::__numeric_traits::__max_exponent10 + 20;
4408 return __gnu_cxx::__to_xstring(&std::vsnprintf, __n,
4409 "%f", __val);
4410 }
4411
4412 _GLIBCXX_NODISCARD
4413 inline string
4414 to_string(double __val)
4415 {
4416 const int __n =
4417 __gnu_cxx::__numeric_traits::__max_exponent10 + 20;
4418 return __gnu_cxx::__to_xstring(&std::vsnprintf, __n,
4419 "%f", __val);
4420 }
4421
4422 _GLIBCXX_NODISCARD
4423 inline string
4424 to_string(long double __val)
4425 {
4426 const int __n =
4427 __gnu_cxx::__numeric_traits::__max_exponent10 + 20;
4428 return __gnu_cxx::__to_xstring(&std::vsnprintf, __n,
4429 "%Lf", __val);
4430 }
4431#endif
4432
4433#if defined(_GLIBCXX_USE_WCHAR_T) && _GLIBCXX_USE_C99_WCHAR
4434 inline int
4435 stoi(const wstring& __str, size_t* __idx = 0, int __base = 10)
4436 { return __gnu_cxx::__stoa<long, int>(&std::wcstol, "stoi", __str.c_str(),
4437 __idx, __base); }
4438
4439 inline long
4440 stol(const wstring& __str, size_t* __idx = 0, int __base = 10)
4441 { return __gnu_cxx::__stoa(&std::wcstol, "stol", __str.c_str(),
4442 __idx, __base); }
4443
4444 inline unsigned long
4445 stoul(const wstring& __str, size_t* __idx = 0, int __base = 10)
4446 { return __gnu_cxx::__stoa(&std::wcstoul, "stoul", __str.c_str(),
4447 __idx, __base); }
4448
4449 inline long long
4450 stoll(const wstring& __str, size_t* __idx = 0, int __base = 10)
4451 { return __gnu_cxx::__stoa(&std::wcstoll, "stoll", __str.c_str(),
4452 __idx, __base); }
4453
4454 inline unsigned long long
4455 stoull(const wstring& __str, size_t* __idx = 0, int __base = 10)
4456 { return __gnu_cxx::__stoa(&std::wcstoull, "stoull", __str.c_str(),
4457 __idx, __base); }
4458
4459
4460 inline float
4461 stof(const wstring& __str, size_t* __idx = 0)
4462 { return __gnu_cxx::__stoa(&std::wcstof, "stof", __str.c_str(), __idx); }
4463
4464 inline double
4465 stod(const wstring& __str, size_t* __idx = 0)
4466 { return __gnu_cxx::__stoa(&std::wcstod, "stod", __str.c_str(), __idx); }
4467
4468 inline long double
4469 stold(const wstring& __str, size_t* __idx = 0)
4470 { return __gnu_cxx::__stoa(&std::wcstold, "stold", __str.c_str(), __idx); }
4471#endif
4472
4473#ifdef _GLIBCXX_USE_WCHAR_T
4474#pragma GCC diagnostic push
4475#pragma GCC diagnostic ignored "-Wc++17-extensions"
4476 _GLIBCXX20_CONSTEXPR
4477 inline void
4478 __to_wstring_numeric(const char* __s, int __len, wchar_t* __wout)
4479 {
4480
4481
4482 if constexpr (wchar_t('0') == L'0' && wchar_t('-') == L'-'
4483 && wchar_t('.') == L'.' && wchar_t('e') == L'e')
4484 {
4485 for (int __i = 0; __i < __len; ++__i)
4486 __wout[__i] = (wchar_t) __s[__i];
4487 }
4488 else
4489 {
4490 wchar_t __wc[256];
4491 for (int __i = '0'; __i <= '9'; ++__i)
4492 __wc[__i] = L'0' + __i;
4493 __wc['.'] = L'.';
4494 __wc['+'] = L'+';
4495 __wc['-'] = L'-';
4496 __wc['a'] = L'a';
4497 __wc['b'] = L'b';
4498 __wc['c'] = L'c';
4499 __wc['d'] = L'd';
4500 __wc['e'] = L'e';
4501 __wc['f'] = L'f';
4502 __wc['n'] = L'n';
4503 __wc['p'] = L'p';
4504 __wc['x'] = L'x';
4505 __wc['A'] = L'A';
4506 __wc['B'] = L'B';
4507 __wc['C'] = L'C';
4508 __wc['D'] = L'D';
4509 __wc['E'] = L'E';
4510 __wc['F'] = L'F';
4511 __wc['N'] = L'N';
4512 __wc['P'] = L'P';
4513 __wc['X'] = L'X';
4514
4515 for (int __i = 0; __i < __len; ++__i)
4516 __wout[__i] = __wc[(int)__s[__i]];
4517 }
4518 }
4519
4520#if __glibcxx_constexpr_string >= 201907L
4521 constexpr
4522#endif
4524#if __cplusplus >= 201703L
4525 __to_wstring_numeric(string_view __s)
4526#else
4527 __to_wstring_numeric(const string& __s)
4528#endif
4529 {
4530 if constexpr (wchar_t('0') == L'0' && wchar_t('-') == L'-'
4531 && wchar_t('.') == L'.' && wchar_t('e') == L'e')
4532 return wstring(__s.data(), __s.data() + __s.size());
4533 else
4534 {
4536 auto __f = __s.data();
4537 __ws.__resize_and_overwrite(__s.size(),
4538 [__f] (wchar_t* __to, int __n) {
4539 std::__to_wstring_numeric(__f, __n, __to);
4540 return __n;
4541 });
4542 return __ws;
4543 }
4544 }
4545#pragma GCC diagnostic pop
4546
4547 _GLIBCXX_NODISCARD
4549 to_wstring(int __val)
4550 { return std::__to_wstring_numeric(std::to_string(__val)); }
4551
4552 _GLIBCXX_NODISCARD
4554 to_wstring(unsigned __val)
4555 { return std::__to_wstring_numeric(std::to_string(__val)); }
4556
4557 _GLIBCXX_NODISCARD
4559 to_wstring(long __val)
4560 { return std::__to_wstring_numeric(std::to_string(__val)); }
4561
4562 _GLIBCXX_NODISCARD
4564 to_wstring(unsigned long __val)
4565 { return std::__to_wstring_numeric(std::to_string(__val)); }
4566
4567 _GLIBCXX_NODISCARD
4569 to_wstring(long long __val)
4570 { return std::__to_wstring_numeric(std::to_string(__val)); }
4571
4572 _GLIBCXX_NODISCARD
4574 to_wstring(unsigned long long __val)
4575 { return std::__to_wstring_numeric(std::to_string(__val)); }
4576
4577#if __glibcxx_to_string || _GLIBCXX_USE_C99_STDIO
4578 _GLIBCXX_NODISCARD
4580 to_wstring(float __val)
4581 { return std::__to_wstring_numeric(std::to_string(__val)); }
4582
4583 _GLIBCXX_NODISCARD
4585 to_wstring(double __val)
4586 { return std::__to_wstring_numeric(std::to_string(__val)); }
4587
4588 _GLIBCXX_NODISCARD
4590 to_wstring(long double __val)
4591 { return std::__to_wstring_numeric(std::to_string(__val)); }
4592#endif
4593#endif
4594
4595_GLIBCXX_END_NAMESPACE_CXX11
4596_GLIBCXX_END_NAMESPACE_VERSION
4597}
4598
4599#endif
4600
4601#if __cplusplus >= 201103L
4602
4604
4605namespace std _GLIBCXX_VISIBILITY(default)
4606{
4607_GLIBCXX_BEGIN_NAMESPACE_VERSION
4608
4609
4610
4611
4612 template<typename _CharT, typename _Alloc,
4613 typename _StrT = basic_string<_CharT, char_traits<_CharT>, _Alloc>>
4614 struct __str_hash_base
4615 : public __hash_base<size_t, _StrT>
4616 {
4617 [[__nodiscard__]]
4618 size_t
4619 operator()(const _StrT& __s) const noexcept
4620 { return _Hash_impl::hash(__s.data(), __s.length() * sizeof(_CharT)); }
4621 };
4622
4623#ifndef _GLIBCXX_COMPATIBILITY_CXX0X
4624
4625 template<typename _Alloc>
4627 : public __str_hash_base<char, _Alloc>
4628 { };
4629
4630
4631 template<typename _Alloc>
4633 : public __str_hash_base<wchar_t, _Alloc>
4634 { };
4635
4636 template<typename _Alloc>
4638 _Alloc>>>
4640 { };
4641#endif
4642
4643#ifdef _GLIBCXX_USE_CHAR8_T
4644
4645 template<typename _Alloc>
4646 struct hash<basic_string<char8_t, char_traits<char8_t>, _Alloc>>
4647 : public __str_hash_base<char8_t, _Alloc>
4648 { };
4649#endif
4650
4651
4652 template<typename _Alloc>
4654 : public __str_hash_base<char16_t, _Alloc>
4655 { };
4656
4657
4658 template<typename _Alloc>
4660 : public __str_hash_base<char32_t, _Alloc>
4661 { };
4662
4663#if ! _GLIBCXX_INLINE_VERSION
4664
4669#ifdef _GLIBCXX_USE_CHAR8_T
4670 template<> struct __is_fast_hash<hash> : std::false_type { };
4671#endif
4672#else
4673
4674 template<typename _CharT, typename _Traits, typename _Alloc>
4675 struct __is_fast_hash<hash<basic_string<_CharT, _Traits, _Alloc>>>
4677 { };
4678#endif
4679
4680#ifdef __glibcxx_string_udls
4681 inline namespace literals
4682 {
4683 inline namespace string_literals
4684 {
4685#pragma GCC diagnostic push
4686#pragma GCC diagnostic ignored "-Wliteral-suffix"
4687
4688#if __glibcxx_constexpr_string >= 201907L
4689# define _GLIBCXX_STRING_CONSTEXPR constexpr
4690#else
4691# define _GLIBCXX_STRING_CONSTEXPR
4692#endif
4693
4694 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4695 inline basic_string
4696 operator""s(const char* __str, size_t __len)
4697 { return basic_string{__str, __len}; }
4698
4699 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4700 inline basic_string<wchar_t>
4701 operator""s(const wchar_t* __str, size_t __len)
4702 { return basic_string<wchar_t>{__str, __len}; }
4703
4704#ifdef _GLIBCXX_USE_CHAR8_T
4705 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4706 inline basic_string<char8_t>
4707 operator""s(const char8_t* __str, size_t __len)
4708 { return basic_string<char8_t>{__str, __len}; }
4709#endif
4710
4711 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4712 inline basic_string<char16_t>
4713 operator""s(const char16_t* __str, size_t __len)
4714 { return basic_string<char16_t>{__str, __len}; }
4715
4716 _GLIBCXX_DEFAULT_ABI_TAG _GLIBCXX_STRING_CONSTEXPR
4717 inline basic_string<char32_t>
4718 operator""s(const char32_t* __str, size_t __len)
4719 { return basic_string<char32_t>{__str, __len}; }
4720
4721#undef _GLIBCXX_STRING_CONSTEXPR
4722#pragma GCC diagnostic pop
4723 }
4724 }
4725#endif
4726
4727#if __cplusplus >= 201703L
4728 namespace __detail::__variant
4729 {
4730 template<typename> struct _Never_valueless_alt;
4731
4732
4733
4734 template<typename _Tp, typename _Traits, typename _Alloc>
4735 struct _Never_valueless_alt<std::basic_string<_Tp, _Traits, _Alloc>>
4736 : __and_<
4737 is_nothrow_move_constructible<std::basic_string<_Tp, _Traits, _Alloc>>,
4738 is_nothrow_move_assignable<std::basic_string<_Tp, _Traits, _Alloc>>
4739 >::type
4740 { };
4741 }
4742#endif
4743
4744_GLIBCXX_END_NAMESPACE_VERSION
4745}
4746
4747#endif
4748
4749#endif
constexpr bool operator<=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator>=(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator<(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr bool operator>(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
__bool_constant< false > false_type
The type used as a compile-time boolean with false value.
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 _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
constexpr iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
basic_string< char32_t > u32string
A string of char32_t.
basic_string< char16_t > u16string
A string of char16_t.
basic_string< wchar_t > wstring
A string of wchar_t.
ISO C++ entities toplevel namespace is std.
basic_istream< _CharT, _Traits > & getline(basic_istream< _CharT, _Traits > &__is, basic_string< _CharT, _Traits, _Alloc > &__str, _CharT __delim)
Read a line from stream into a string.
std::basic_istream< _CharT, _Traits > & operator>>(std::basic_istream< _CharT, _Traits > &__is, bitset< _Nb > &__x)
Global I/O operators for bitsets.
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
char_type widen(char __c) const
Widens characters.
Template class basic_istream.
Template class basic_ostream.
Primary class template hash.
Basis for explicit traits specializations.
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.
void push_back(_CharT __c)
Append a single character.
const_iterator cend() const noexcept
size_type find_first_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character of string.
const _CharT * data() const noexcept
Return const pointer to contents.
void __resize_and_overwrite(size_type __n, _Operation __op)
Non-standard version of resize_and_overwrite for C++11 and above.
basic_string substr(size_type __pos=0, size_type __n=npos) const
Get a substring.
size_type find(const _CharT *__s, size_type __pos, size_type __n) const noexcept
Find position of a C substring.
size_type find_last_not_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character not in string.
int compare(const basic_string &__str) const
Compare to a string.
size_type find_first_not_of(const basic_string &__str, size_type __pos=0) const noexcept
Find position of a character not in string.
void insert(iterator __p, size_type __n, _CharT __c)
Insert multiple characters.
basic_string & assign(const basic_string &__str)
Set value to contents of another string.
reverse_iterator rbegin()
void pop_back()
Remove the last character.
size_type copy(_CharT *__s, size_type __n, size_type __pos=0) const
Copy substring into C string.
size_type length() const noexcept
Returns the number of characters in the string, not including any null-termination.
size_type find_last_of(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a character of string.
basic_string & operator+=(const basic_string &__str)
Append a string to this string.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
size_type rfind(const basic_string &__str, size_type __pos=npos) const noexcept
Find last position of a string.
void shrink_to_fit() noexcept
A non-binding request to reduce capacity() to size().
void resize(size_type __n, _CharT __c)
Resizes the string to the specified number of characters.
void reserve()
Equivalent to shrink_to_fit().
const_reference at(size_type __n) const
Provides access to the data contained in the string.
basic_string & append(const basic_string &__str)
Append a string to this string.
const_reverse_iterator crend() 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.
bool empty() const noexcept
const _CharT * c_str() const noexcept
Return const pointer to null-terminated contents.
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.
const_iterator cbegin() const noexcept
~basic_string() noexcept
Destroy the string instance.
size_type capacity() const noexcept
basic_string() noexcept
Default constructor creates an empty string.
size_type max_size() const noexcept
Returns the size() of the largest possible string.
basic_string & erase(size_type __pos=0, size_type __n=npos)
Remove characters.
basic_string & replace(size_type __pos, size_type __n, const basic_string &__str)
Replace characters with value from another string.
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.