1 // Debugging string implementation -*- C++ -*-
3 // Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 // Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // Under Section 7 of GPL version 3, you are granted additional
18 // permissions described in the GCC Runtime Library Exception, version
19 // 3.1, as published by the Free Software Foundation.
21 // You should have received a copy of the GNU General Public License and
22 // a copy of the GCC Runtime Library Exception along with this program;
23 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 // <http://www.gnu.org/licenses/>.
26 /** @file debug/string
27 * This file is a GNU debug extension to the Standard C++ Library.
30 #ifndef _GLIBCXX_DEBUG_STRING
31 #define _GLIBCXX_DEBUG_STRING 1
34 #include <debug/safe_sequence.h>
35 #include <debug/safe_iterator.h>
39 /// Class std::basic_string with safety/checking/debug instrumentation.
40 template<typename _CharT, typename _Traits = std::char_traits<_CharT>,
41 typename _Allocator = std::allocator<_CharT> >
43 : public std::basic_string<_CharT, _Traits, _Allocator>,
44 public __gnu_debug::_Safe_sequence<basic_string<_CharT, _Traits,
47 typedef std::basic_string<_CharT, _Traits, _Allocator> _Base;
48 typedef __gnu_debug::_Safe_sequence<basic_string> _Safe_base;
52 typedef _Traits traits_type;
53 typedef typename _Traits::char_type value_type;
54 typedef _Allocator allocator_type;
55 typedef typename _Base::size_type size_type;
56 typedef typename _Base::difference_type difference_type;
57 typedef typename _Base::reference reference;
58 typedef typename _Base::const_reference const_reference;
59 typedef typename _Base::pointer pointer;
60 typedef typename _Base::const_pointer const_pointer;
62 typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, basic_string>
64 typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator,
65 basic_string> const_iterator;
67 typedef std::reverse_iterator<iterator> reverse_iterator;
68 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
72 // 21.3.1 construct/copy/destroy:
73 explicit basic_string(const _Allocator& __a = _Allocator())
77 // Provides conversion from a release-mode string to a debug-mode string
78 basic_string(const _Base& __base) : _Base(__base), _Safe_base() { }
80 // _GLIBCXX_RESOLVE_LIB_DEFECTS
81 // 42. string ctors specify wrong default allocator
82 basic_string(const basic_string& __str)
83 : _Base(__str, 0, _Base::npos, __str.get_allocator()), _Safe_base()
86 // _GLIBCXX_RESOLVE_LIB_DEFECTS
87 // 42. string ctors specify wrong default allocator
88 basic_string(const basic_string& __str, size_type __pos,
89 size_type __n = _Base::npos,
90 const _Allocator& __a = _Allocator())
91 : _Base(__str, __pos, __n, __a)
94 basic_string(const _CharT* __s, size_type __n,
95 const _Allocator& __a = _Allocator())
96 : _Base(__gnu_debug::__check_string(__s, __n), __n, __a)
99 basic_string(const _CharT* __s, const _Allocator& __a = _Allocator())
100 : _Base(__gnu_debug::__check_string(__s), __a)
101 { this->assign(__s); }
103 basic_string(size_type __n, _CharT __c,
104 const _Allocator& __a = _Allocator())
105 : _Base(__n, __c, __a)
108 template<typename _InputIterator>
109 basic_string(_InputIterator __begin, _InputIterator __end,
110 const _Allocator& __a = _Allocator())
111 : _Base(__gnu_debug::__check_valid_range(__begin, __end), __end, __a)
114 #ifdef __GXX_EXPERIMENTAL_CXX0X__
115 basic_string(basic_string&& __str)
116 : _Base(std::forward<_Base>(__str))
119 basic_string(std::initializer_list<_CharT> __l,
120 const _Allocator& __a = _Allocator())
123 #endif // __GXX_EXPERIMENTAL_CXX0X__
128 operator=(const basic_string& __str)
130 *static_cast<_Base*>(this) = __str;
131 this->_M_invalidate_all();
136 operator=(const _CharT* __s)
138 __glibcxx_check_string(__s);
139 *static_cast<_Base*>(this) = __s;
140 this->_M_invalidate_all();
145 operator=(_CharT __c)
147 *static_cast<_Base*>(this) = __c;
148 this->_M_invalidate_all();
152 #ifdef __GXX_EXPERIMENTAL_CXX0X__
154 operator=(basic_string&& __str)
156 *static_cast<_Base*>(this) = std::forward<_Base>(__str);
157 this->_M_invalidate_all();
162 operator=(std::initializer_list<_CharT> __l)
164 *static_cast<_Base*>(this) = __l;
165 this->_M_invalidate_all();
168 #endif // __GXX_EXPERIMENTAL_CXX0X__
173 { return iterator(_Base::begin(), this); }
177 { return const_iterator(_Base::begin(), this); }
181 { return iterator(_Base::end(), this); }
185 { return const_iterator(_Base::end(), this); }
189 { return reverse_iterator(end()); }
191 const_reverse_iterator
193 { return const_reverse_iterator(end()); }
197 { return reverse_iterator(begin()); }
199 const_reverse_iterator
201 { return const_reverse_iterator(begin()); }
206 using _Base::max_size;
209 resize(size_type __n, _CharT __c)
211 _Base::resize(__n, __c);
212 this->_M_invalidate_all();
216 resize(size_type __n)
217 { this->resize(__n, _CharT()); }
219 #ifdef __GXX_EXPERIMENTAL_CXX0X__
220 using _Base::shrink_to_fit;
223 using _Base::capacity;
224 using _Base::reserve;
230 this->_M_invalidate_all();
235 // 21.3.4 element access:
237 operator[](size_type __pos) const
239 _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(),
240 _M_message(__gnu_debug::__msg_subscript_oob)
241 ._M_sequence(*this, "this")
242 ._M_integer(__pos, "__pos")
243 ._M_integer(this->size(), "size"));
244 return _M_base()[__pos];
248 operator[](size_type __pos)
250 #ifdef _GLIBCXX_DEBUG_PEDANTIC
251 __glibcxx_check_subscript(__pos);
253 // as an extension v3 allows s[s.size()] when s is non-const.
254 _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(),
255 _M_message(__gnu_debug::__msg_subscript_oob)
256 ._M_sequence(*this, "this")
257 ._M_integer(__pos, "__pos")
258 ._M_integer(this->size(), "size"));
260 return _M_base()[__pos];
265 #ifdef __GXX_EXPERIMENTAL_CXX0X__
272 operator+=(const basic_string& __str)
275 this->_M_invalidate_all();
280 operator+=(const _CharT* __s)
282 __glibcxx_check_string(__s);
284 this->_M_invalidate_all();
289 operator+=(_CharT __c)
292 this->_M_invalidate_all();
296 #ifdef __GXX_EXPERIMENTAL_CXX0X__
298 operator+=(std::initializer_list<_CharT> __l)
301 this->_M_invalidate_all();
304 #endif // __GXX_EXPERIMENTAL_CXX0X__
307 append(const basic_string& __str)
309 _Base::append(__str);
310 this->_M_invalidate_all();
315 append(const basic_string& __str, size_type __pos, size_type __n)
317 _Base::append(__str, __pos, __n);
318 this->_M_invalidate_all();
323 append(const _CharT* __s, size_type __n)
325 __glibcxx_check_string_len(__s, __n);
326 _Base::append(__s, __n);
327 this->_M_invalidate_all();
332 append(const _CharT* __s)
334 __glibcxx_check_string(__s);
336 this->_M_invalidate_all();
341 append(size_type __n, _CharT __c)
343 _Base::append(__n, __c);
344 this->_M_invalidate_all();
348 template<typename _InputIterator>
350 append(_InputIterator __first, _InputIterator __last)
352 __glibcxx_check_valid_range(__first, __last);
353 _Base::append(__first, __last);
354 this->_M_invalidate_all();
358 // _GLIBCXX_RESOLVE_LIB_DEFECTS
359 // 7. string clause minor problems
361 push_back(_CharT __c)
363 _Base::push_back(__c);
364 this->_M_invalidate_all();
368 assign(const basic_string& __x)
371 this->_M_invalidate_all();
375 #ifdef __GXX_EXPERIMENTAL_CXX0X__
377 assign(basic_string&& __x)
379 _Base::assign(std::forward<_Base>(__x));
380 this->_M_invalidate_all();
383 #endif // __GXX_EXPERIMENTAL_CXX0X__
386 assign(const basic_string& __str, size_type __pos, size_type __n)
388 _Base::assign(__str, __pos, __n);
389 this->_M_invalidate_all();
394 assign(const _CharT* __s, size_type __n)
396 __glibcxx_check_string_len(__s, __n);
397 _Base::assign(__s, __n);
398 this->_M_invalidate_all();
403 assign(const _CharT* __s)
405 __glibcxx_check_string(__s);
407 this->_M_invalidate_all();
412 assign(size_type __n, _CharT __c)
414 _Base::assign(__n, __c);
415 this->_M_invalidate_all();
419 template<typename _InputIterator>
421 assign(_InputIterator __first, _InputIterator __last)
423 __glibcxx_check_valid_range(__first, __last);
424 _Base::assign(__first, __last);
425 this->_M_invalidate_all();
429 #ifdef __GXX_EXPERIMENTAL_CXX0X__
431 assign(std::initializer_list<_CharT> __l)
434 this->_M_invalidate_all();
437 #endif // __GXX_EXPERIMENTAL_CXX0X__
440 insert(size_type __pos1, const basic_string& __str)
442 _Base::insert(__pos1, __str);
443 this->_M_invalidate_all();
448 insert(size_type __pos1, const basic_string& __str,
449 size_type __pos2, size_type __n)
451 _Base::insert(__pos1, __str, __pos2, __n);
452 this->_M_invalidate_all();
457 insert(size_type __pos, const _CharT* __s, size_type __n)
459 __glibcxx_check_string(__s);
460 _Base::insert(__pos, __s, __n);
461 this->_M_invalidate_all();
466 insert(size_type __pos, const _CharT* __s)
468 __glibcxx_check_string(__s);
469 _Base::insert(__pos, __s);
470 this->_M_invalidate_all();
475 insert(size_type __pos, size_type __n, _CharT __c)
477 _Base::insert(__pos, __n, __c);
478 this->_M_invalidate_all();
483 insert(iterator __p, _CharT __c)
485 __glibcxx_check_insert(__p);
486 typename _Base::iterator __res = _Base::insert(__p.base(), __c);
487 this->_M_invalidate_all();
488 return iterator(__res, this);
492 insert(iterator __p, size_type __n, _CharT __c)
494 __glibcxx_check_insert(__p);
495 _Base::insert(__p.base(), __n, __c);
496 this->_M_invalidate_all();
499 template<typename _InputIterator>
501 insert(iterator __p, _InputIterator __first, _InputIterator __last)
503 __glibcxx_check_insert_range(__p, __first, __last);
504 _Base::insert(__p.base(), __first, __last);
505 this->_M_invalidate_all();
508 #ifdef __GXX_EXPERIMENTAL_CXX0X__
510 insert(iterator __p, std::initializer_list<_CharT> __l)
512 _Base::insert(__p, __l);
513 this->_M_invalidate_all();
515 #endif // __GXX_EXPERIMENTAL_CXX0X__
518 erase(size_type __pos = 0, size_type __n = _Base::npos)
520 _Base::erase(__pos, __n);
521 this->_M_invalidate_all();
526 erase(iterator __position)
528 __glibcxx_check_erase(__position);
529 typename _Base::iterator __res = _Base::erase(__position.base());
530 this->_M_invalidate_all();
531 return iterator(__res, this);
535 erase(iterator __first, iterator __last)
537 // _GLIBCXX_RESOLVE_LIB_DEFECTS
538 // 151. can't currently clear() empty container
539 __glibcxx_check_erase_range(__first, __last);
540 typename _Base::iterator __res = _Base::erase(__first.base(),
542 this->_M_invalidate_all();
543 return iterator(__res, this);
547 replace(size_type __pos1, size_type __n1, const basic_string& __str)
549 _Base::replace(__pos1, __n1, __str);
550 this->_M_invalidate_all();
555 replace(size_type __pos1, size_type __n1, const basic_string& __str,
556 size_type __pos2, size_type __n2)
558 _Base::replace(__pos1, __n1, __str, __pos2, __n2);
559 this->_M_invalidate_all();
564 replace(size_type __pos, size_type __n1, const _CharT* __s,
567 __glibcxx_check_string_len(__s, __n2);
568 _Base::replace(__pos, __n1, __s, __n2);
569 this->_M_invalidate_all();
574 replace(size_type __pos, size_type __n1, const _CharT* __s)
576 __glibcxx_check_string(__s);
577 _Base::replace(__pos, __n1, __s);
578 this->_M_invalidate_all();
583 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
585 _Base::replace(__pos, __n1, __n2, __c);
586 this->_M_invalidate_all();
591 replace(iterator __i1, iterator __i2, const basic_string& __str)
593 __glibcxx_check_erase_range(__i1, __i2);
594 _Base::replace(__i1.base(), __i2.base(), __str);
595 this->_M_invalidate_all();
600 replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
602 __glibcxx_check_erase_range(__i1, __i2);
603 __glibcxx_check_string_len(__s, __n);
604 _Base::replace(__i1.base(), __i2.base(), __s, __n);
605 this->_M_invalidate_all();
610 replace(iterator __i1, iterator __i2, const _CharT* __s)
612 __glibcxx_check_erase_range(__i1, __i2);
613 __glibcxx_check_string(__s);
614 _Base::replace(__i1.base(), __i2.base(), __s);
615 this->_M_invalidate_all();
620 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
622 __glibcxx_check_erase_range(__i1, __i2);
623 _Base::replace(__i1.base(), __i2.base(), __n, __c);
624 this->_M_invalidate_all();
628 template<typename _InputIterator>
630 replace(iterator __i1, iterator __i2,
631 _InputIterator __j1, _InputIterator __j2)
633 __glibcxx_check_erase_range(__i1, __i2);
634 __glibcxx_check_valid_range(__j1, __j2);
635 _Base::replace(__i1.base(), __i2.base(), __j1, __j2);
636 this->_M_invalidate_all();
640 #ifdef __GXX_EXPERIMENTAL_CXX0X__
641 basic_string& replace(iterator __i1, iterator __i2,
642 std::initializer_list<_CharT> __l)
644 __glibcxx_check_erase_range(__i1, __i2);
645 _Base::replace(__i1.base(), __i2.base(), __l);
646 this->_M_invalidate_all();
649 #endif // __GXX_EXPERIMENTAL_CXX0X__
652 copy(_CharT* __s, size_type __n, size_type __pos = 0) const
654 __glibcxx_check_string_len(__s, __n);
655 return _Base::copy(__s, __n, __pos);
659 swap(basic_string<_CharT,_Traits,_Allocator>& __x)
663 this->_M_invalidate_all();
664 __x._M_invalidate_all();
667 // 21.3.6 string operations:
671 const _CharT* __res = _Base::c_str();
672 this->_M_invalidate_all();
679 const _CharT* __res = _Base::data();
680 this->_M_invalidate_all();
684 using _Base::get_allocator;
687 find(const basic_string& __str, size_type __pos = 0) const
688 { return _Base::find(__str, __pos); }
691 find(const _CharT* __s, size_type __pos, size_type __n) const
693 __glibcxx_check_string(__s);
694 return _Base::find(__s, __pos, __n);
698 find(const _CharT* __s, size_type __pos = 0) const
700 __glibcxx_check_string(__s);
701 return _Base::find(__s, __pos);
705 find(_CharT __c, size_type __pos = 0) const
706 { return _Base::find(__c, __pos); }
709 rfind(const basic_string& __str, size_type __pos = _Base::npos) const
710 { return _Base::rfind(__str, __pos); }
713 rfind(const _CharT* __s, size_type __pos, size_type __n) const
715 __glibcxx_check_string_len(__s, __n);
716 return _Base::rfind(__s, __pos, __n);
720 rfind(const _CharT* __s, size_type __pos = _Base::npos) const
722 __glibcxx_check_string(__s);
723 return _Base::rfind(__s, __pos);
727 rfind(_CharT __c, size_type __pos = _Base::npos) const
728 { return _Base::rfind(__c, __pos); }
731 find_first_of(const basic_string& __str, size_type __pos = 0) const
732 { return _Base::find_first_of(__str, __pos); }
735 find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
737 __glibcxx_check_string(__s);
738 return _Base::find_first_of(__s, __pos, __n);
742 find_first_of(const _CharT* __s, size_type __pos = 0) const
744 __glibcxx_check_string(__s);
745 return _Base::find_first_of(__s, __pos);
749 find_first_of(_CharT __c, size_type __pos = 0) const
750 { return _Base::find_first_of(__c, __pos); }
753 find_last_of(const basic_string& __str,
754 size_type __pos = _Base::npos) const
755 { return _Base::find_last_of(__str, __pos); }
758 find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
760 __glibcxx_check_string(__s);
761 return _Base::find_last_of(__s, __pos, __n);
765 find_last_of(const _CharT* __s, size_type __pos = _Base::npos) const
767 __glibcxx_check_string(__s);
768 return _Base::find_last_of(__s, __pos);
772 find_last_of(_CharT __c, size_type __pos = _Base::npos) const
773 { return _Base::find_last_of(__c, __pos); }
776 find_first_not_of(const basic_string& __str, size_type __pos = 0) const
777 { return _Base::find_first_not_of(__str, __pos); }
780 find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
782 __glibcxx_check_string_len(__s, __n);
783 return _Base::find_first_not_of(__s, __pos, __n);
787 find_first_not_of(const _CharT* __s, size_type __pos = 0) const
789 __glibcxx_check_string(__s);
790 return _Base::find_first_not_of(__s, __pos);
794 find_first_not_of(_CharT __c, size_type __pos = 0) const
795 { return _Base::find_first_not_of(__c, __pos); }
798 find_last_not_of(const basic_string& __str,
799 size_type __pos = _Base::npos) const
800 { return _Base::find_last_not_of(__str, __pos); }
803 find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
805 __glibcxx_check_string(__s);
806 return _Base::find_last_not_of(__s, __pos, __n);
810 find_last_not_of(const _CharT* __s, size_type __pos = _Base::npos) const
812 __glibcxx_check_string(__s);
813 return _Base::find_last_not_of(__s, __pos);
817 find_last_not_of(_CharT __c, size_type __pos = _Base::npos) const
818 { return _Base::find_last_not_of(__c, __pos); }
821 substr(size_type __pos = 0, size_type __n = _Base::npos) const
822 { return basic_string(_Base::substr(__pos, __n)); }
825 compare(const basic_string& __str) const
826 { return _Base::compare(__str); }
829 compare(size_type __pos1, size_type __n1,
830 const basic_string& __str) const
831 { return _Base::compare(__pos1, __n1, __str); }
834 compare(size_type __pos1, size_type __n1, const basic_string& __str,
835 size_type __pos2, size_type __n2) const
836 { return _Base::compare(__pos1, __n1, __str, __pos2, __n2); }
839 compare(const _CharT* __s) const
841 __glibcxx_check_string(__s);
842 return _Base::compare(__s);
845 // _GLIBCXX_RESOLVE_LIB_DEFECTS
846 // 5. string::compare specification questionable
848 compare(size_type __pos1, size_type __n1, const _CharT* __s) const
850 __glibcxx_check_string(__s);
851 return _Base::compare(__pos1, __n1, __s);
854 // _GLIBCXX_RESOLVE_LIB_DEFECTS
855 // 5. string::compare specification questionable
857 compare(size_type __pos1, size_type __n1,const _CharT* __s,
858 size_type __n2) const
860 __glibcxx_check_string_len(__s, __n2);
861 return _Base::compare(__pos1, __n1, __s, __n2);
865 _M_base() { return *this; }
868 _M_base() const { return *this; }
870 using _Safe_base::_M_invalidate_all;
873 template<typename _CharT, typename _Traits, typename _Allocator>
874 inline basic_string<_CharT,_Traits,_Allocator>
875 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
876 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
877 { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
879 template<typename _CharT, typename _Traits, typename _Allocator>
880 inline basic_string<_CharT,_Traits,_Allocator>
881 operator+(const _CharT* __lhs,
882 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
884 __glibcxx_check_string(__lhs);
885 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
888 template<typename _CharT, typename _Traits, typename _Allocator>
889 inline basic_string<_CharT,_Traits,_Allocator>
890 operator+(_CharT __lhs,
891 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
892 { return basic_string<_CharT,_Traits,_Allocator>(1, __lhs) += __rhs; }
894 template<typename _CharT, typename _Traits, typename _Allocator>
895 inline basic_string<_CharT,_Traits,_Allocator>
896 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
899 __glibcxx_check_string(__rhs);
900 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
903 template<typename _CharT, typename _Traits, typename _Allocator>
904 inline basic_string<_CharT,_Traits,_Allocator>
905 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
907 { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
909 template<typename _CharT, typename _Traits, typename _Allocator>
911 operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
912 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
913 { return __lhs._M_base() == __rhs._M_base(); }
915 template<typename _CharT, typename _Traits, typename _Allocator>
917 operator==(const _CharT* __lhs,
918 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
920 __glibcxx_check_string(__lhs);
921 return __lhs == __rhs._M_base();
924 template<typename _CharT, typename _Traits, typename _Allocator>
926 operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
929 __glibcxx_check_string(__rhs);
930 return __lhs._M_base() == __rhs;
933 template<typename _CharT, typename _Traits, typename _Allocator>
935 operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
936 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
937 { return __lhs._M_base() != __rhs._M_base(); }
939 template<typename _CharT, typename _Traits, typename _Allocator>
941 operator!=(const _CharT* __lhs,
942 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
944 __glibcxx_check_string(__lhs);
945 return __lhs != __rhs._M_base();
948 template<typename _CharT, typename _Traits, typename _Allocator>
950 operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
953 __glibcxx_check_string(__rhs);
954 return __lhs._M_base() != __rhs;
957 template<typename _CharT, typename _Traits, typename _Allocator>
959 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
960 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
961 { return __lhs._M_base() < __rhs._M_base(); }
963 template<typename _CharT, typename _Traits, typename _Allocator>
965 operator<(const _CharT* __lhs,
966 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
968 __glibcxx_check_string(__lhs);
969 return __lhs < __rhs._M_base();
972 template<typename _CharT, typename _Traits, typename _Allocator>
974 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
977 __glibcxx_check_string(__rhs);
978 return __lhs._M_base() < __rhs;
981 template<typename _CharT, typename _Traits, typename _Allocator>
983 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
984 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
985 { return __lhs._M_base() <= __rhs._M_base(); }
987 template<typename _CharT, typename _Traits, typename _Allocator>
989 operator<=(const _CharT* __lhs,
990 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
992 __glibcxx_check_string(__lhs);
993 return __lhs <= __rhs._M_base();
996 template<typename _CharT, typename _Traits, typename _Allocator>
998 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1001 __glibcxx_check_string(__rhs);
1002 return __lhs._M_base() <= __rhs;
1005 template<typename _CharT, typename _Traits, typename _Allocator>
1007 operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1008 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1009 { return __lhs._M_base() >= __rhs._M_base(); }
1011 template<typename _CharT, typename _Traits, typename _Allocator>
1013 operator>=(const _CharT* __lhs,
1014 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1016 __glibcxx_check_string(__lhs);
1017 return __lhs >= __rhs._M_base();
1020 template<typename _CharT, typename _Traits, typename _Allocator>
1022 operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1023 const _CharT* __rhs)
1025 __glibcxx_check_string(__rhs);
1026 return __lhs._M_base() >= __rhs;
1029 template<typename _CharT, typename _Traits, typename _Allocator>
1031 operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1032 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1033 { return __lhs._M_base() > __rhs._M_base(); }
1035 template<typename _CharT, typename _Traits, typename _Allocator>
1037 operator>(const _CharT* __lhs,
1038 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1040 __glibcxx_check_string(__lhs);
1041 return __lhs > __rhs._M_base();
1044 template<typename _CharT, typename _Traits, typename _Allocator>
1046 operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1047 const _CharT* __rhs)
1049 __glibcxx_check_string(__rhs);
1050 return __lhs._M_base() > __rhs;
1054 template<typename _CharT, typename _Traits, typename _Allocator>
1056 swap(basic_string<_CharT,_Traits,_Allocator>& __lhs,
1057 basic_string<_CharT,_Traits,_Allocator>& __rhs)
1058 { __lhs.swap(__rhs); }
1060 template<typename _CharT, typename _Traits, typename _Allocator>
1061 std::basic_ostream<_CharT, _Traits>&
1062 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
1063 const basic_string<_CharT, _Traits, _Allocator>& __str)
1064 { return __os << __str._M_base(); }
1066 template<typename _CharT, typename _Traits, typename _Allocator>
1067 std::basic_istream<_CharT,_Traits>&
1068 operator>>(std::basic_istream<_CharT,_Traits>& __is,
1069 basic_string<_CharT,_Traits,_Allocator>& __str)
1071 std::basic_istream<_CharT,_Traits>& __res = __is >> __str._M_base();
1072 __str._M_invalidate_all();
1076 template<typename _CharT, typename _Traits, typename _Allocator>
1077 std::basic_istream<_CharT,_Traits>&
1078 getline(std::basic_istream<_CharT,_Traits>& __is,
1079 basic_string<_CharT,_Traits,_Allocator>& __str, _CharT __delim)
1081 std::basic_istream<_CharT,_Traits>& __res = getline(__is,
1084 __str._M_invalidate_all();
1088 template<typename _CharT, typename _Traits, typename _Allocator>
1089 std::basic_istream<_CharT,_Traits>&
1090 getline(std::basic_istream<_CharT,_Traits>& __is,
1091 basic_string<_CharT,_Traits,_Allocator>& __str)
1093 std::basic_istream<_CharT,_Traits>& __res = getline(__is,
1095 __str._M_invalidate_all();
1099 typedef basic_string<char> string;
1101 #ifdef _GLIBCXX_USE_WCHAR_T
1102 typedef basic_string<wchar_t> wstring;
1105 } // namespace __gnu_debug