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 #ifndef _GLIBCXX_DEBUG_STRING
32 #define _GLIBCXX_DEBUG_STRING 1
35 #include <debug/safe_sequence.h>
36 #include <debug/safe_iterator.h>
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)
117 operator=(const basic_string& __str)
119 *static_cast<_Base*>(this) = __str;
120 this->_M_invalidate_all();
125 operator=(const _CharT* __s)
127 __glibcxx_check_string(__s);
128 *static_cast<_Base*>(this) = __s;
129 this->_M_invalidate_all();
134 operator=(_CharT __c)
136 *static_cast<_Base*>(this) = __c;
137 this->_M_invalidate_all();
144 { return iterator(_Base::begin(), this); }
148 { return const_iterator(_Base::begin(), this); }
152 { return iterator(_Base::end(), this); }
156 { return const_iterator(_Base::end(), this); }
160 { return reverse_iterator(end()); }
162 const_reverse_iterator
164 { return const_reverse_iterator(end()); }
168 { return reverse_iterator(begin()); }
170 const_reverse_iterator
172 { return const_reverse_iterator(begin()); }
177 using _Base::max_size;
180 resize(size_type __n, _CharT __c)
182 _Base::resize(__n, __c);
183 this->_M_invalidate_all();
187 resize(size_type __n)
188 { this->resize(__n, _CharT()); }
190 using _Base::capacity;
191 using _Base::reserve;
197 this->_M_invalidate_all();
202 // 21.3.4 element access:
204 operator[](size_type __pos) const
206 _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(),
207 _M_message(__gnu_debug::__msg_subscript_oob)
208 ._M_sequence(*this, "this")
209 ._M_integer(__pos, "__pos")
210 ._M_integer(this->size(), "size"));
211 return _M_base()[__pos];
215 operator[](size_type __pos)
217 #ifdef _GLIBCXX_DEBUG_PEDANTIC
218 __glibcxx_check_subscript(__pos);
220 // as an extension v3 allows s[s.size()] when s is non-const.
221 _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(),
222 _M_message(__gnu_debug::__msg_subscript_oob)
223 ._M_sequence(*this, "this")
224 ._M_integer(__pos, "__pos")
225 ._M_integer(this->size(), "size"));
227 return _M_base()[__pos];
234 operator+=(const basic_string& __str)
237 this->_M_invalidate_all();
242 operator+=(const _CharT* __s)
244 __glibcxx_check_string(__s);
246 this->_M_invalidate_all();
251 operator+=(_CharT __c)
254 this->_M_invalidate_all();
259 append(const basic_string& __str)
261 _Base::append(__str);
262 this->_M_invalidate_all();
267 append(const basic_string& __str, size_type __pos, size_type __n)
269 _Base::append(__str, __pos, __n);
270 this->_M_invalidate_all();
275 append(const _CharT* __s, size_type __n)
277 __glibcxx_check_string_len(__s, __n);
278 _Base::append(__s, __n);
279 this->_M_invalidate_all();
284 append(const _CharT* __s)
286 __glibcxx_check_string(__s);
288 this->_M_invalidate_all();
293 append(size_type __n, _CharT __c)
295 _Base::append(__n, __c);
296 this->_M_invalidate_all();
300 template<typename _InputIterator>
302 append(_InputIterator __first, _InputIterator __last)
304 __glibcxx_check_valid_range(__first, __last);
305 _Base::append(__first, __last);
306 this->_M_invalidate_all();
310 // _GLIBCXX_RESOLVE_LIB_DEFECTS
311 // 7. string clause minor problems
313 push_back(_CharT __c)
315 _Base::push_back(__c);
316 this->_M_invalidate_all();
320 assign(const basic_string& __x)
323 this->_M_invalidate_all();
328 assign(const basic_string& __str, size_type __pos, size_type __n)
330 _Base::assign(__str, __pos, __n);
331 this->_M_invalidate_all();
336 assign(const _CharT* __s, size_type __n)
338 __glibcxx_check_string_len(__s, __n);
339 _Base::assign(__s, __n);
340 this->_M_invalidate_all();
345 assign(const _CharT* __s)
347 __glibcxx_check_string(__s);
349 this->_M_invalidate_all();
354 assign(size_type __n, _CharT __c)
356 _Base::assign(__n, __c);
357 this->_M_invalidate_all();
361 template<typename _InputIterator>
363 assign(_InputIterator __first, _InputIterator __last)
365 __glibcxx_check_valid_range(__first, __last);
366 _Base::assign(__first, __last);
367 this->_M_invalidate_all();
372 insert(size_type __pos1, const basic_string& __str)
374 _Base::insert(__pos1, __str);
375 this->_M_invalidate_all();
380 insert(size_type __pos1, const basic_string& __str,
381 size_type __pos2, size_type __n)
383 _Base::insert(__pos1, __str, __pos2, __n);
384 this->_M_invalidate_all();
389 insert(size_type __pos, const _CharT* __s, size_type __n)
391 __glibcxx_check_string(__s);
392 _Base::insert(__pos, __s, __n);
393 this->_M_invalidate_all();
398 insert(size_type __pos, const _CharT* __s)
400 __glibcxx_check_string(__s);
401 _Base::insert(__pos, __s);
402 this->_M_invalidate_all();
407 insert(size_type __pos, size_type __n, _CharT __c)
409 _Base::insert(__pos, __n, __c);
410 this->_M_invalidate_all();
415 insert(iterator __p, _CharT __c)
417 __glibcxx_check_insert(__p);
418 typename _Base::iterator __res = _Base::insert(__p.base(), __c);
419 this->_M_invalidate_all();
420 return iterator(__res, this);
424 insert(iterator __p, size_type __n, _CharT __c)
426 __glibcxx_check_insert(__p);
427 _Base::insert(__p.base(), __n, __c);
428 this->_M_invalidate_all();
431 template<typename _InputIterator>
433 insert(iterator __p, _InputIterator __first, _InputIterator __last)
435 __glibcxx_check_insert_range(__p, __first, __last);
436 _Base::insert(__p.base(), __first, __last);
437 this->_M_invalidate_all();
441 erase(size_type __pos = 0, size_type __n = _Base::npos)
443 _Base::erase(__pos, __n);
444 this->_M_invalidate_all();
449 erase(iterator __position)
451 __glibcxx_check_erase(__position);
452 typename _Base::iterator __res = _Base::erase(__position.base());
453 this->_M_invalidate_all();
454 return iterator(__res, this);
458 erase(iterator __first, iterator __last)
460 // _GLIBCXX_RESOLVE_LIB_DEFECTS
461 // 151. can't currently clear() empty container
462 __glibcxx_check_erase_range(__first, __last);
463 typename _Base::iterator __res = _Base::erase(__first.base(),
465 this->_M_invalidate_all();
466 return iterator(__res, this);
470 replace(size_type __pos1, size_type __n1, const basic_string& __str)
472 _Base::replace(__pos1, __n1, __str);
473 this->_M_invalidate_all();
478 replace(size_type __pos1, size_type __n1, const basic_string& __str,
479 size_type __pos2, size_type __n2)
481 _Base::replace(__pos1, __n1, __str, __pos2, __n2);
482 this->_M_invalidate_all();
487 replace(size_type __pos, size_type __n1, const _CharT* __s,
490 __glibcxx_check_string_len(__s, __n2);
491 _Base::replace(__pos, __n1, __s, __n2);
492 this->_M_invalidate_all();
497 replace(size_type __pos, size_type __n1, const _CharT* __s)
499 __glibcxx_check_string(__s);
500 _Base::replace(__pos, __n1, __s);
501 this->_M_invalidate_all();
506 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
508 _Base::replace(__pos, __n1, __n2, __c);
509 this->_M_invalidate_all();
514 replace(iterator __i1, iterator __i2, const basic_string& __str)
516 __glibcxx_check_erase_range(__i1, __i2);
517 _Base::replace(__i1.base(), __i2.base(), __str);
518 this->_M_invalidate_all();
523 replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
525 __glibcxx_check_erase_range(__i1, __i2);
526 __glibcxx_check_string_len(__s, __n);
527 _Base::replace(__i1.base(), __i2.base(), __s, __n);
528 this->_M_invalidate_all();
533 replace(iterator __i1, iterator __i2, const _CharT* __s)
535 __glibcxx_check_erase_range(__i1, __i2);
536 __glibcxx_check_string(__s);
537 _Base::replace(__i1.base(), __i2.base(), __s);
538 this->_M_invalidate_all();
543 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
545 __glibcxx_check_erase_range(__i1, __i2);
546 _Base::replace(__i1.base(), __i2.base(), __n, __c);
547 this->_M_invalidate_all();
551 template<typename _InputIterator>
553 replace(iterator __i1, iterator __i2,
554 _InputIterator __j1, _InputIterator __j2)
556 __glibcxx_check_erase_range(__i1, __i2);
557 __glibcxx_check_valid_range(__j1, __j2);
558 _Base::replace(__i1.base(), __i2.base(), __j1, __j2);
559 this->_M_invalidate_all();
564 copy(_CharT* __s, size_type __n, size_type __pos = 0) const
566 __glibcxx_check_string_len(__s, __n);
567 return _Base::copy(__s, __n, __pos);
571 swap(basic_string<_CharT,_Traits,_Allocator>& __x)
575 this->_M_invalidate_all();
576 __x._M_invalidate_all();
579 // 21.3.6 string operations:
583 const _CharT* __res = _Base::c_str();
584 this->_M_invalidate_all();
591 const _CharT* __res = _Base::data();
592 this->_M_invalidate_all();
596 using _Base::get_allocator;
599 find(const basic_string& __str, size_type __pos = 0) const
600 { return _Base::find(__str, __pos); }
603 find(const _CharT* __s, size_type __pos, size_type __n) const
605 __glibcxx_check_string(__s);
606 return _Base::find(__s, __pos, __n);
610 find(const _CharT* __s, size_type __pos = 0) const
612 __glibcxx_check_string(__s);
613 return _Base::find(__s, __pos);
617 find(_CharT __c, size_type __pos = 0) const
618 { return _Base::find(__c, __pos); }
621 rfind(const basic_string& __str, size_type __pos = _Base::npos) const
622 { return _Base::rfind(__str, __pos); }
625 rfind(const _CharT* __s, size_type __pos, size_type __n) const
627 __glibcxx_check_string_len(__s, __n);
628 return _Base::rfind(__s, __pos, __n);
632 rfind(const _CharT* __s, size_type __pos = _Base::npos) const
634 __glibcxx_check_string(__s);
635 return _Base::rfind(__s, __pos);
639 rfind(_CharT __c, size_type __pos = _Base::npos) const
640 { return _Base::rfind(__c, __pos); }
643 find_first_of(const basic_string& __str, size_type __pos = 0) const
644 { return _Base::find_first_of(__str, __pos); }
647 find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
649 __glibcxx_check_string(__s);
650 return _Base::find_first_of(__s, __pos, __n);
654 find_first_of(const _CharT* __s, size_type __pos = 0) const
656 __glibcxx_check_string(__s);
657 return _Base::find_first_of(__s, __pos);
661 find_first_of(_CharT __c, size_type __pos = 0) const
662 { return _Base::find_first_of(__c, __pos); }
665 find_last_of(const basic_string& __str,
666 size_type __pos = _Base::npos) const
667 { return _Base::find_last_of(__str, __pos); }
670 find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
672 __glibcxx_check_string(__s);
673 return _Base::find_last_of(__s, __pos, __n);
677 find_last_of(const _CharT* __s, size_type __pos = _Base::npos) const
679 __glibcxx_check_string(__s);
680 return _Base::find_last_of(__s, __pos);
684 find_last_of(_CharT __c, size_type __pos = _Base::npos) const
685 { return _Base::find_last_of(__c, __pos); }
688 find_first_not_of(const basic_string& __str, size_type __pos = 0) const
689 { return _Base::find_first_not_of(__str, __pos); }
692 find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
694 __glibcxx_check_string_len(__s, __n);
695 return _Base::find_first_not_of(__s, __pos, __n);
699 find_first_not_of(const _CharT* __s, size_type __pos = 0) const
701 __glibcxx_check_string(__s);
702 return _Base::find_first_not_of(__s, __pos);
706 find_first_not_of(_CharT __c, size_type __pos = 0) const
707 { return _Base::find_first_not_of(__c, __pos); }
710 find_last_not_of(const basic_string& __str,
711 size_type __pos = _Base::npos) const
712 { return _Base::find_last_not_of(__str, __pos); }
715 find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
717 __glibcxx_check_string(__s);
718 return _Base::find_last_not_of(__s, __pos, __n);
722 find_last_not_of(const _CharT* __s, size_type __pos = _Base::npos) const
724 __glibcxx_check_string(__s);
725 return _Base::find_last_not_of(__s, __pos);
729 find_last_not_of(_CharT __c, size_type __pos = _Base::npos) const
730 { return _Base::find_last_not_of(__c, __pos); }
733 substr(size_type __pos = 0, size_type __n = _Base::npos) const
734 { return basic_string(_Base::substr(__pos, __n)); }
737 compare(const basic_string& __str) const
738 { return _Base::compare(__str); }
741 compare(size_type __pos1, size_type __n1,
742 const basic_string& __str) const
743 { return _Base::compare(__pos1, __n1, __str); }
746 compare(size_type __pos1, size_type __n1, const basic_string& __str,
747 size_type __pos2, size_type __n2) const
748 { return _Base::compare(__pos1, __n1, __str, __pos2, __n2); }
751 compare(const _CharT* __s) const
753 __glibcxx_check_string(__s);
754 return _Base::compare(__s);
757 // _GLIBCXX_RESOLVE_LIB_DEFECTS
758 // 5. string::compare specification questionable
760 compare(size_type __pos1, size_type __n1, const _CharT* __s) const
762 __glibcxx_check_string(__s);
763 return _Base::compare(__pos1, __n1, __s);
766 // _GLIBCXX_RESOLVE_LIB_DEFECTS
767 // 5. string::compare specification questionable
769 compare(size_type __pos1, size_type __n1,const _CharT* __s,
770 size_type __n2) const
772 __glibcxx_check_string_len(__s, __n2);
773 return _Base::compare(__pos1, __n1, __s, __n2);
777 _M_base() { return *this; }
780 _M_base() const { return *this; }
782 using _Safe_base::_M_invalidate_all;
785 template<typename _CharT, typename _Traits, typename _Allocator>
786 inline basic_string<_CharT,_Traits,_Allocator>
787 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
788 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
789 { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
791 template<typename _CharT, typename _Traits, typename _Allocator>
792 inline basic_string<_CharT,_Traits,_Allocator>
793 operator+(const _CharT* __lhs,
794 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
796 __glibcxx_check_string(__lhs);
797 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
800 template<typename _CharT, typename _Traits, typename _Allocator>
801 inline basic_string<_CharT,_Traits,_Allocator>
802 operator+(_CharT __lhs,
803 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
804 { return basic_string<_CharT,_Traits,_Allocator>(1, __lhs) += __rhs; }
806 template<typename _CharT, typename _Traits, typename _Allocator>
807 inline basic_string<_CharT,_Traits,_Allocator>
808 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
811 __glibcxx_check_string(__rhs);
812 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
815 template<typename _CharT, typename _Traits, typename _Allocator>
816 inline basic_string<_CharT,_Traits,_Allocator>
817 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
819 { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
821 template<typename _CharT, typename _Traits, typename _Allocator>
823 operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
824 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
825 { return __lhs._M_base() == __rhs._M_base(); }
827 template<typename _CharT, typename _Traits, typename _Allocator>
829 operator==(const _CharT* __lhs,
830 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
832 __glibcxx_check_string(__lhs);
833 return __lhs == __rhs._M_base();
836 template<typename _CharT, typename _Traits, typename _Allocator>
838 operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
841 __glibcxx_check_string(__rhs);
842 return __lhs._M_base() == __rhs;
845 template<typename _CharT, typename _Traits, typename _Allocator>
847 operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
848 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
849 { return __lhs._M_base() != __rhs._M_base(); }
851 template<typename _CharT, typename _Traits, typename _Allocator>
853 operator!=(const _CharT* __lhs,
854 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
856 __glibcxx_check_string(__lhs);
857 return __lhs != __rhs._M_base();
860 template<typename _CharT, typename _Traits, typename _Allocator>
862 operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
865 __glibcxx_check_string(__rhs);
866 return __lhs._M_base() != __rhs;
869 template<typename _CharT, typename _Traits, typename _Allocator>
871 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
872 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
873 { return __lhs._M_base() < __rhs._M_base(); }
875 template<typename _CharT, typename _Traits, typename _Allocator>
877 operator<(const _CharT* __lhs,
878 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
880 __glibcxx_check_string(__lhs);
881 return __lhs < __rhs._M_base();
884 template<typename _CharT, typename _Traits, typename _Allocator>
886 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
889 __glibcxx_check_string(__rhs);
890 return __lhs._M_base() < __rhs;
893 template<typename _CharT, typename _Traits, typename _Allocator>
895 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
896 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
897 { return __lhs._M_base() <= __rhs._M_base(); }
899 template<typename _CharT, typename _Traits, typename _Allocator>
901 operator<=(const _CharT* __lhs,
902 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
904 __glibcxx_check_string(__lhs);
905 return __lhs <= __rhs._M_base();
908 template<typename _CharT, typename _Traits, typename _Allocator>
910 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
913 __glibcxx_check_string(__rhs);
914 return __lhs._M_base() <= __rhs;
917 template<typename _CharT, typename _Traits, typename _Allocator>
919 operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
920 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
921 { return __lhs._M_base() >= __rhs._M_base(); }
923 template<typename _CharT, typename _Traits, typename _Allocator>
925 operator>=(const _CharT* __lhs,
926 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
928 __glibcxx_check_string(__lhs);
929 return __lhs >= __rhs._M_base();
932 template<typename _CharT, typename _Traits, typename _Allocator>
934 operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
937 __glibcxx_check_string(__rhs);
938 return __lhs._M_base() >= __rhs;
941 template<typename _CharT, typename _Traits, typename _Allocator>
943 operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
944 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
945 { return __lhs._M_base() > __rhs._M_base(); }
947 template<typename _CharT, typename _Traits, typename _Allocator>
949 operator>(const _CharT* __lhs,
950 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
952 __glibcxx_check_string(__lhs);
953 return __lhs > __rhs._M_base();
956 template<typename _CharT, typename _Traits, typename _Allocator>
958 operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
961 __glibcxx_check_string(__rhs);
962 return __lhs._M_base() > __rhs;
966 template<typename _CharT, typename _Traits, typename _Allocator>
968 swap(basic_string<_CharT,_Traits,_Allocator>& __lhs,
969 basic_string<_CharT,_Traits,_Allocator>& __rhs)
970 { __lhs.swap(__rhs); }
972 template<typename _CharT, typename _Traits, typename _Allocator>
973 std::basic_ostream<_CharT, _Traits>&
974 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
975 const basic_string<_CharT, _Traits, _Allocator>& __str)
976 { return __os << __str._M_base(); }
978 template<typename _CharT, typename _Traits, typename _Allocator>
979 std::basic_istream<_CharT,_Traits>&
980 operator>>(std::basic_istream<_CharT,_Traits>& __is,
981 basic_string<_CharT,_Traits,_Allocator>& __str)
983 std::basic_istream<_CharT,_Traits>& __res = __is >> __str._M_base();
984 __str._M_invalidate_all();
988 template<typename _CharT, typename _Traits, typename _Allocator>
989 std::basic_istream<_CharT,_Traits>&
990 getline(std::basic_istream<_CharT,_Traits>& __is,
991 basic_string<_CharT,_Traits,_Allocator>& __str, _CharT __delim)
993 std::basic_istream<_CharT,_Traits>& __res = getline(__is,
996 __str._M_invalidate_all();
1000 template<typename _CharT, typename _Traits, typename _Allocator>
1001 std::basic_istream<_CharT,_Traits>&
1002 getline(std::basic_istream<_CharT,_Traits>& __is,
1003 basic_string<_CharT,_Traits,_Allocator>& __str)
1005 std::basic_istream<_CharT,_Traits>& __res = getline(__is,
1007 __str._M_invalidate_all();
1011 typedef basic_string<char> string;
1013 #ifdef _GLIBCXX_USE_WCHAR_T
1014 typedef basic_string<wchar_t> wstring;
1017 } // namespace __gnu_debug