1 // Debugging string implementation -*- C++ -*-
3 // Copyright (C) 2003, 2005, 2006
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 2, 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 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING. If not, write to the Free
19 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction. Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License. This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
31 /** @file debug/string
32 * This file is a GNU debug extension to the Standard C++ Library.
35 #ifndef _GLIBCXX_DEBUG_STRING
36 #define _GLIBCXX_DEBUG_STRING 1
39 #include <debug/safe_sequence.h>
40 #include <debug/safe_iterator.h>
44 template<typename _CharT, typename _Traits = std::char_traits<_CharT>,
45 typename _Allocator = std::allocator<_CharT> >
47 : public std::basic_string<_CharT, _Traits, _Allocator>,
48 public __gnu_debug::_Safe_sequence<basic_string<_CharT, _Traits,
51 typedef std::basic_string<_CharT, _Traits, _Allocator> _Base;
52 typedef __gnu_debug::_Safe_sequence<basic_string> _Safe_base;
56 typedef _Traits traits_type;
57 typedef typename _Traits::char_type value_type;
58 typedef _Allocator allocator_type;
59 typedef typename _Base::size_type size_type;
60 typedef typename _Base::difference_type difference_type;
61 typedef typename _Base::reference reference;
62 typedef typename _Base::const_reference const_reference;
63 typedef typename _Base::pointer pointer;
64 typedef typename _Base::const_pointer const_pointer;
66 typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, basic_string>
68 typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator,
69 basic_string> const_iterator;
71 typedef std::reverse_iterator<iterator> reverse_iterator;
72 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
76 // 21.3.1 construct/copy/destroy:
77 explicit basic_string(const _Allocator& __a = _Allocator())
81 // Provides conversion from a release-mode string to a debug-mode string
82 basic_string(const _Base& __base) : _Base(__base), _Safe_base() { }
84 // _GLIBCXX_RESOLVE_LIB_DEFECTS
85 // 42. string ctors specify wrong default allocator
86 basic_string(const basic_string& __str)
87 : _Base(__str, 0, _Base::npos, __str.get_allocator()), _Safe_base()
90 // _GLIBCXX_RESOLVE_LIB_DEFECTS
91 // 42. string ctors specify wrong default allocator
92 basic_string(const basic_string& __str, size_type __pos,
93 size_type __n = _Base::npos,
94 const _Allocator& __a = _Allocator())
95 : _Base(__str, __pos, __n, __a)
98 basic_string(const _CharT* __s, size_type __n,
99 const _Allocator& __a = _Allocator())
100 : _Base(__gnu_debug::__check_string(__s, __n), __n, __a)
103 basic_string(const _CharT* __s, const _Allocator& __a = _Allocator())
104 : _Base(__gnu_debug::__check_string(__s), __a)
105 { this->assign(__s); }
107 basic_string(size_type __n, _CharT __c,
108 const _Allocator& __a = _Allocator())
109 : _Base(__n, __c, __a)
112 template<typename _InputIterator>
113 basic_string(_InputIterator __begin, _InputIterator __end,
114 const _Allocator& __a = _Allocator())
115 : _Base(__gnu_debug::__check_valid_range(__begin, __end), __end, __a)
121 operator=(const basic_string& __str)
123 *static_cast<_Base*>(this) = __str;
124 this->_M_invalidate_all();
129 operator=(const _CharT* __s)
131 __glibcxx_check_string(__s);
132 *static_cast<_Base*>(this) = __s;
133 this->_M_invalidate_all();
138 operator=(_CharT __c)
140 *static_cast<_Base*>(this) = __c;
141 this->_M_invalidate_all();
148 { return iterator(_Base::begin(), this); }
152 { return const_iterator(_Base::begin(), this); }
156 { return iterator(_Base::end(), this); }
160 { return const_iterator(_Base::end(), this); }
164 { return reverse_iterator(end()); }
166 const_reverse_iterator
168 { return const_reverse_iterator(end()); }
172 { return reverse_iterator(begin()); }
174 const_reverse_iterator
176 { return const_reverse_iterator(begin()); }
181 using _Base::max_size;
184 resize(size_type __n, _CharT __c)
186 _Base::resize(__n, __c);
187 this->_M_invalidate_all();
191 resize(size_type __n)
192 { this->resize(__n, _CharT()); }
194 using _Base::capacity;
195 using _Base::reserve;
201 this->_M_invalidate_all();
206 // 21.3.4 element access:
208 operator[](size_type __pos) const
210 _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(),
211 _M_message(__gnu_debug::__msg_subscript_oob)
212 ._M_sequence(*this, "this")
213 ._M_integer(__pos, "__pos")
214 ._M_integer(this->size(), "size"));
215 return _M_base()[__pos];
219 operator[](size_type __pos)
221 #ifdef _GLIBCXX_DEBUG_PEDANTIC
222 __glibcxx_check_subscript(__pos);
224 // as an extension v3 allows s[s.size()] when s is non-const.
225 _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(),
226 _M_message(__gnu_debug::__msg_subscript_oob)
227 ._M_sequence(*this, "this")
228 ._M_integer(__pos, "__pos")
229 ._M_integer(this->size(), "size"));
231 return _M_base()[__pos];
238 operator+=(const basic_string& __str)
241 this->_M_invalidate_all();
246 operator+=(const _CharT* __s)
248 __glibcxx_check_string(__s);
250 this->_M_invalidate_all();
255 operator+=(_CharT __c)
258 this->_M_invalidate_all();
263 append(const basic_string& __str)
265 _Base::append(__str);
266 this->_M_invalidate_all();
271 append(const basic_string& __str, size_type __pos, size_type __n)
273 _Base::append(__str, __pos, __n);
274 this->_M_invalidate_all();
279 append(const _CharT* __s, size_type __n)
281 __glibcxx_check_string_len(__s, __n);
282 _Base::append(__s, __n);
283 this->_M_invalidate_all();
288 append(const _CharT* __s)
290 __glibcxx_check_string(__s);
292 this->_M_invalidate_all();
297 append(size_type __n, _CharT __c)
299 _Base::append(__n, __c);
300 this->_M_invalidate_all();
304 template<typename _InputIterator>
306 append(_InputIterator __first, _InputIterator __last)
308 __glibcxx_check_valid_range(__first, __last);
309 _Base::append(__first, __last);
310 this->_M_invalidate_all();
314 // _GLIBCXX_RESOLVE_LIB_DEFECTS
315 // 7. string clause minor problems
317 push_back(_CharT __c)
319 _Base::push_back(__c);
320 this->_M_invalidate_all();
324 assign(const basic_string& __x)
327 this->_M_invalidate_all();
332 assign(const basic_string& __str, size_type __pos, size_type __n)
334 _Base::assign(__str, __pos, __n);
335 this->_M_invalidate_all();
340 assign(const _CharT* __s, size_type __n)
342 __glibcxx_check_string_len(__s, __n);
343 _Base::assign(__s, __n);
344 this->_M_invalidate_all();
349 assign(const _CharT* __s)
351 __glibcxx_check_string(__s);
353 this->_M_invalidate_all();
358 assign(size_type __n, _CharT __c)
360 _Base::assign(__n, __c);
361 this->_M_invalidate_all();
365 template<typename _InputIterator>
367 assign(_InputIterator __first, _InputIterator __last)
369 __glibcxx_check_valid_range(__first, __last);
370 _Base::assign(__first, __last);
371 this->_M_invalidate_all();
376 insert(size_type __pos1, const basic_string& __str)
378 _Base::insert(__pos1, __str);
379 this->_M_invalidate_all();
384 insert(size_type __pos1, const basic_string& __str,
385 size_type __pos2, size_type __n)
387 _Base::insert(__pos1, __str, __pos2, __n);
388 this->_M_invalidate_all();
393 insert(size_type __pos, const _CharT* __s, size_type __n)
395 __glibcxx_check_string(__s);
396 _Base::insert(__pos, __s, __n);
397 this->_M_invalidate_all();
402 insert(size_type __pos, const _CharT* __s)
404 __glibcxx_check_string(__s);
405 _Base::insert(__pos, __s);
406 this->_M_invalidate_all();
411 insert(size_type __pos, size_type __n, _CharT __c)
413 _Base::insert(__pos, __n, __c);
414 this->_M_invalidate_all();
419 insert(iterator __p, _CharT __c)
421 __glibcxx_check_insert(__p);
422 typename _Base::iterator __res = _Base::insert(__p.base(), __c);
423 this->_M_invalidate_all();
424 return iterator(__res, this);
428 insert(iterator __p, size_type __n, _CharT __c)
430 __glibcxx_check_insert(__p);
431 _Base::insert(__p.base(), __n, __c);
432 this->_M_invalidate_all();
435 template<typename _InputIterator>
437 insert(iterator __p, _InputIterator __first, _InputIterator __last)
439 __glibcxx_check_insert_range(__p, __first, __last);
440 _Base::insert(__p.base(), __first, __last);
441 this->_M_invalidate_all();
445 erase(size_type __pos = 0, size_type __n = _Base::npos)
447 _Base::erase(__pos, __n);
448 this->_M_invalidate_all();
453 erase(iterator __position)
455 __glibcxx_check_erase(__position);
456 typename _Base::iterator __res = _Base::erase(__position.base());
457 this->_M_invalidate_all();
458 return iterator(__res, this);
462 erase(iterator __first, iterator __last)
464 // _GLIBCXX_RESOLVE_LIB_DEFECTS
465 // 151. can't currently clear() empty container
466 __glibcxx_check_erase_range(__first, __last);
467 typename _Base::iterator __res = _Base::erase(__first.base(),
469 this->_M_invalidate_all();
470 return iterator(__res, this);
474 replace(size_type __pos1, size_type __n1, const basic_string& __str)
476 _Base::replace(__pos1, __n1, __str);
477 this->_M_invalidate_all();
482 replace(size_type __pos1, size_type __n1, const basic_string& __str,
483 size_type __pos2, size_type __n2)
485 _Base::replace(__pos1, __n1, __str, __pos2, __n2);
486 this->_M_invalidate_all();
491 replace(size_type __pos, size_type __n1, const _CharT* __s,
494 __glibcxx_check_string_len(__s, __n2);
495 _Base::replace(__pos, __n1, __s, __n2);
496 this->_M_invalidate_all();
501 replace(size_type __pos, size_type __n1, const _CharT* __s)
503 __glibcxx_check_string(__s);
504 _Base::replace(__pos, __n1, __s);
505 this->_M_invalidate_all();
510 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
512 _Base::replace(__pos, __n1, __n2, __c);
513 this->_M_invalidate_all();
518 replace(iterator __i1, iterator __i2, const basic_string& __str)
520 __glibcxx_check_erase_range(__i1, __i2);
521 _Base::replace(__i1.base(), __i2.base(), __str);
522 this->_M_invalidate_all();
527 replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
529 __glibcxx_check_erase_range(__i1, __i2);
530 __glibcxx_check_string_len(__s, __n);
531 _Base::replace(__i1.base(), __i2.base(), __s, __n);
532 this->_M_invalidate_all();
537 replace(iterator __i1, iterator __i2, const _CharT* __s)
539 __glibcxx_check_erase_range(__i1, __i2);
540 __glibcxx_check_string(__s);
541 _Base::replace(__i1.base(), __i2.base(), __s);
542 this->_M_invalidate_all();
547 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
549 __glibcxx_check_erase_range(__i1, __i2);
550 _Base::replace(__i1.base(), __i2.base(), __n, __c);
551 this->_M_invalidate_all();
555 template<typename _InputIterator>
557 replace(iterator __i1, iterator __i2,
558 _InputIterator __j1, _InputIterator __j2)
560 __glibcxx_check_erase_range(__i1, __i2);
561 __glibcxx_check_valid_range(__j1, __j2);
562 _Base::replace(__i1.base(), __i2.base(), __j1, __j2);
563 this->_M_invalidate_all();
568 copy(_CharT* __s, size_type __n, size_type __pos = 0) const
570 __glibcxx_check_string_len(__s, __n);
571 return _Base::copy(__s, __n, __pos);
575 swap(basic_string<_CharT,_Traits,_Allocator>& __x)
579 this->_M_invalidate_all();
580 __x._M_invalidate_all();
583 // 21.3.6 string operations:
587 const _CharT* __res = _Base::c_str();
588 this->_M_invalidate_all();
595 const _CharT* __res = _Base::data();
596 this->_M_invalidate_all();
600 using _Base::get_allocator;
603 find(const basic_string& __str, size_type __pos = 0) const
604 { return _Base::find(__str, __pos); }
607 find(const _CharT* __s, size_type __pos, size_type __n) const
609 __glibcxx_check_string(__s);
610 return _Base::find(__s, __pos, __n);
614 find(const _CharT* __s, size_type __pos = 0) const
616 __glibcxx_check_string(__s);
617 return _Base::find(__s, __pos);
621 find(_CharT __c, size_type __pos = 0) const
622 { return _Base::find(__c, __pos); }
625 rfind(const basic_string& __str, size_type __pos = _Base::npos) const
626 { return _Base::rfind(__str, __pos); }
629 rfind(const _CharT* __s, size_type __pos, size_type __n) const
631 __glibcxx_check_string_len(__s, __n);
632 return _Base::rfind(__s, __pos, __n);
636 rfind(const _CharT* __s, size_type __pos = _Base::npos) const
638 __glibcxx_check_string(__s);
639 return _Base::rfind(__s, __pos);
643 rfind(_CharT __c, size_type __pos = _Base::npos) const
644 { return _Base::rfind(__c, __pos); }
647 find_first_of(const basic_string& __str, size_type __pos = 0) const
648 { return _Base::find_first_of(__str, __pos); }
651 find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
653 __glibcxx_check_string(__s);
654 return _Base::find_first_of(__s, __pos, __n);
658 find_first_of(const _CharT* __s, size_type __pos = 0) const
660 __glibcxx_check_string(__s);
661 return _Base::find_first_of(__s, __pos);
665 find_first_of(_CharT __c, size_type __pos = 0) const
666 { return _Base::find_first_of(__c, __pos); }
669 find_last_of(const basic_string& __str,
670 size_type __pos = _Base::npos) const
671 { return _Base::find_last_of(__str, __pos); }
674 find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
676 __glibcxx_check_string(__s);
677 return _Base::find_last_of(__s, __pos, __n);
681 find_last_of(const _CharT* __s, size_type __pos = _Base::npos) const
683 __glibcxx_check_string(__s);
684 return _Base::find_last_of(__s, __pos);
688 find_last_of(_CharT __c, size_type __pos = _Base::npos) const
689 { return _Base::find_last_of(__c, __pos); }
692 find_first_not_of(const basic_string& __str, size_type __pos = 0) const
693 { return _Base::find_first_not_of(__str, __pos); }
696 find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
698 __glibcxx_check_string_len(__s, __n);
699 return _Base::find_first_not_of(__s, __pos, __n);
703 find_first_not_of(const _CharT* __s, size_type __pos = 0) const
705 __glibcxx_check_string(__s);
706 return _Base::find_first_not_of(__s, __pos);
710 find_first_not_of(_CharT __c, size_type __pos = 0) const
711 { return _Base::find_first_not_of(__c, __pos); }
714 find_last_not_of(const basic_string& __str,
715 size_type __pos = _Base::npos) const
716 { return _Base::find_last_not_of(__str, __pos); }
719 find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
721 __glibcxx_check_string(__s);
722 return _Base::find_last_not_of(__s, __pos, __n);
726 find_last_not_of(const _CharT* __s, size_type __pos = _Base::npos) const
728 __glibcxx_check_string(__s);
729 return _Base::find_last_not_of(__s, __pos);
733 find_last_not_of(_CharT __c, size_type __pos = _Base::npos) const
734 { return _Base::find_last_not_of(__c, __pos); }
737 substr(size_type __pos = 0, size_type __n = _Base::npos) const
738 { return basic_string(_Base::substr(__pos, __n)); }
741 compare(const basic_string& __str) const
742 { return _Base::compare(__str); }
745 compare(size_type __pos1, size_type __n1,
746 const basic_string& __str) const
747 { return _Base::compare(__pos1, __n1, __str); }
750 compare(size_type __pos1, size_type __n1, const basic_string& __str,
751 size_type __pos2, size_type __n2) const
752 { return _Base::compare(__pos1, __n1, __str, __pos2, __n2); }
755 compare(const _CharT* __s) const
757 __glibcxx_check_string(__s);
758 return _Base::compare(__s);
761 // _GLIBCXX_RESOLVE_LIB_DEFECTS
762 // 5. string::compare specification questionable
764 compare(size_type __pos1, size_type __n1, const _CharT* __s) const
766 __glibcxx_check_string(__s);
767 return _Base::compare(__pos1, __n1, __s);
770 // _GLIBCXX_RESOLVE_LIB_DEFECTS
771 // 5. string::compare specification questionable
773 compare(size_type __pos1, size_type __n1,const _CharT* __s,
774 size_type __n2) const
776 __glibcxx_check_string_len(__s, __n2);
777 return _Base::compare(__pos1, __n1, __s, __n2);
781 _M_base() { return *this; }
784 _M_base() const { return *this; }
786 using _Safe_base::_M_invalidate_all;
789 template<typename _CharT, typename _Traits, typename _Allocator>
790 inline basic_string<_CharT,_Traits,_Allocator>
791 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
792 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
793 { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
795 template<typename _CharT, typename _Traits, typename _Allocator>
796 inline basic_string<_CharT,_Traits,_Allocator>
797 operator+(const _CharT* __lhs,
798 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
800 __glibcxx_check_string(__lhs);
801 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
804 template<typename _CharT, typename _Traits, typename _Allocator>
805 inline basic_string<_CharT,_Traits,_Allocator>
806 operator+(_CharT __lhs,
807 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
808 { return basic_string<_CharT,_Traits,_Allocator>(1, __lhs) += __rhs; }
810 template<typename _CharT, typename _Traits, typename _Allocator>
811 inline basic_string<_CharT,_Traits,_Allocator>
812 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
815 __glibcxx_check_string(__rhs);
816 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
819 template<typename _CharT, typename _Traits, typename _Allocator>
820 inline basic_string<_CharT,_Traits,_Allocator>
821 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
823 { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
825 template<typename _CharT, typename _Traits, typename _Allocator>
827 operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
828 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
829 { return __lhs._M_base() == __rhs._M_base(); }
831 template<typename _CharT, typename _Traits, typename _Allocator>
833 operator==(const _CharT* __lhs,
834 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
836 __glibcxx_check_string(__lhs);
837 return __lhs == __rhs._M_base();
840 template<typename _CharT, typename _Traits, typename _Allocator>
842 operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
845 __glibcxx_check_string(__rhs);
846 return __lhs._M_base() == __rhs;
849 template<typename _CharT, typename _Traits, typename _Allocator>
851 operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
852 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
853 { return __lhs._M_base() != __rhs._M_base(); }
855 template<typename _CharT, typename _Traits, typename _Allocator>
857 operator!=(const _CharT* __lhs,
858 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
860 __glibcxx_check_string(__lhs);
861 return __lhs != __rhs._M_base();
864 template<typename _CharT, typename _Traits, typename _Allocator>
866 operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
869 __glibcxx_check_string(__rhs);
870 return __lhs._M_base() != __rhs;
873 template<typename _CharT, typename _Traits, typename _Allocator>
875 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
876 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
877 { return __lhs._M_base() < __rhs._M_base(); }
879 template<typename _CharT, typename _Traits, typename _Allocator>
881 operator<(const _CharT* __lhs,
882 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
884 __glibcxx_check_string(__lhs);
885 return __lhs < __rhs._M_base();
888 template<typename _CharT, typename _Traits, typename _Allocator>
890 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
893 __glibcxx_check_string(__rhs);
894 return __lhs._M_base() < __rhs;
897 template<typename _CharT, typename _Traits, typename _Allocator>
899 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
900 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
901 { return __lhs._M_base() <= __rhs._M_base(); }
903 template<typename _CharT, typename _Traits, typename _Allocator>
905 operator<=(const _CharT* __lhs,
906 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
908 __glibcxx_check_string(__lhs);
909 return __lhs <= __rhs._M_base();
912 template<typename _CharT, typename _Traits, typename _Allocator>
914 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
917 __glibcxx_check_string(__rhs);
918 return __lhs._M_base() <= __rhs;
921 template<typename _CharT, typename _Traits, typename _Allocator>
923 operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
924 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
925 { return __lhs._M_base() >= __rhs._M_base(); }
927 template<typename _CharT, typename _Traits, typename _Allocator>
929 operator>=(const _CharT* __lhs,
930 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
932 __glibcxx_check_string(__lhs);
933 return __lhs >= __rhs._M_base();
936 template<typename _CharT, typename _Traits, typename _Allocator>
938 operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
941 __glibcxx_check_string(__rhs);
942 return __lhs._M_base() >= __rhs;
945 template<typename _CharT, typename _Traits, typename _Allocator>
947 operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
948 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
949 { return __lhs._M_base() > __rhs._M_base(); }
951 template<typename _CharT, typename _Traits, typename _Allocator>
953 operator>(const _CharT* __lhs,
954 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
956 __glibcxx_check_string(__lhs);
957 return __lhs > __rhs._M_base();
960 template<typename _CharT, typename _Traits, typename _Allocator>
962 operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
965 __glibcxx_check_string(__rhs);
966 return __lhs._M_base() > __rhs;
970 template<typename _CharT, typename _Traits, typename _Allocator>
972 swap(basic_string<_CharT,_Traits,_Allocator>& __lhs,
973 basic_string<_CharT,_Traits,_Allocator>& __rhs)
974 { __lhs.swap(__rhs); }
976 template<typename _CharT, typename _Traits, typename _Allocator>
977 std::basic_ostream<_CharT, _Traits>&
978 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
979 const basic_string<_CharT, _Traits, _Allocator>& __str)
980 { return __os << __str._M_base(); }
982 template<typename _CharT, typename _Traits, typename _Allocator>
983 std::basic_istream<_CharT,_Traits>&
984 operator>>(std::basic_istream<_CharT,_Traits>& __is,
985 basic_string<_CharT,_Traits,_Allocator>& __str)
987 std::basic_istream<_CharT,_Traits>& __res = __is >> __str._M_base();
988 __str._M_invalidate_all();
992 template<typename _CharT, typename _Traits, typename _Allocator>
993 std::basic_istream<_CharT,_Traits>&
994 getline(std::basic_istream<_CharT,_Traits>& __is,
995 basic_string<_CharT,_Traits,_Allocator>& __str, _CharT __delim)
997 std::basic_istream<_CharT,_Traits>& __res = getline(__is,
1000 __str._M_invalidate_all();
1004 template<typename _CharT, typename _Traits, typename _Allocator>
1005 std::basic_istream<_CharT,_Traits>&
1006 getline(std::basic_istream<_CharT,_Traits>& __is,
1007 basic_string<_CharT,_Traits,_Allocator>& __str)
1009 std::basic_istream<_CharT,_Traits>& __res = getline(__is,
1011 __str._M_invalidate_all();
1015 typedef basic_string<char> string;
1017 #ifdef _GLIBCXX_USE_WCHAR_T
1018 typedef basic_string<wchar_t> wstring;
1021 } // namespace __gnu_debug