1 // Debugging string implementation -*- C++ -*-
3 // Copyright (C) 2003, 2005
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, size_type __pos = _Base::npos) const
666 { return _Base::find_last_of(__str, __pos); }
669 find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
671 __glibcxx_check_string(__s);
672 return _Base::find_last_of(__s, __pos, __n);
676 find_last_of(const _CharT* __s, size_type __pos = _Base::npos) const
678 __glibcxx_check_string(__s);
679 return _Base::find_last_of(__s, __pos);
683 find_last_of(_CharT __c, size_type __pos = _Base::npos) const
684 { return _Base::find_last_of(__c, __pos); }
687 find_first_not_of(const basic_string& __str, size_type __pos = 0) const
688 { return _Base::find_first_not_of(__str, __pos); }
691 find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
693 __glibcxx_check_string_len(__s, __n);
694 return _Base::find_first_not_of(__s, __pos, __n);
698 find_first_not_of(const _CharT* __s, size_type __pos = 0) const
700 __glibcxx_check_string(__s);
701 return _Base::find_first_not_of(__s, __pos);
705 find_first_not_of(_CharT __c, size_type __pos = 0) const
706 { return _Base::find_first_not_of(__c, __pos); }
709 find_last_not_of(const basic_string& __str,
710 size_type __pos = _Base::npos) const
711 { return _Base::find_last_not_of(__str, __pos); }
714 find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
716 __glibcxx_check_string(__s);
717 return _Base::find_last_not_of(__s, __pos, __n);
721 find_last_not_of(const _CharT* __s, size_type __pos = _Base::npos) const
723 __glibcxx_check_string(__s);
724 return _Base::find_last_not_of(__s, __pos);
728 find_last_not_of(_CharT __c, size_type __pos = _Base::npos) const
729 { return _Base::find_last_not_of(__c, __pos); }
732 substr(size_type __pos = 0, size_type __n = _Base::npos) const
733 { return basic_string(_Base::substr(__pos, __n)); }
736 compare(const basic_string& __str) const
737 { return _Base::compare(__str); }
740 compare(size_type __pos1, size_type __n1,
741 const basic_string& __str) const
742 { return _Base::compare(__pos1, __n1, __str); }
745 compare(size_type __pos1, size_type __n1, const basic_string& __str,
746 size_type __pos2, size_type __n2) const
747 { return _Base::compare(__pos1, __n1, __str, __pos2, __n2); }
750 compare(const _CharT* __s) const
752 __glibcxx_check_string(__s);
753 return _Base::compare(__s);
756 // _GLIBCXX_RESOLVE_LIB_DEFECTS
757 // 5. string::compare specification questionable
759 compare(size_type __pos1, size_type __n1, const _CharT* __s) const
761 __glibcxx_check_string(__s);
762 return _Base::compare(__pos1, __n1, __s);
765 // _GLIBCXX_RESOLVE_LIB_DEFECTS
766 // 5. string::compare specification questionable
768 compare(size_type __pos1, size_type __n1,const _CharT* __s,
769 size_type __n2) const
771 __glibcxx_check_string_len(__s, __n2);
772 return _Base::compare(__pos1, __n1, __s, __n2);
776 _M_base() { return *this; }
779 _M_base() const { return *this; }
781 using _Safe_base::_M_invalidate_all;
784 template<typename _CharT, typename _Traits, typename _Allocator>
785 inline basic_string<_CharT,_Traits,_Allocator>
786 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
787 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
788 { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
790 template<typename _CharT, typename _Traits, typename _Allocator>
791 inline basic_string<_CharT,_Traits,_Allocator>
792 operator+(const _CharT* __lhs,
793 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
795 __glibcxx_check_string(__lhs);
796 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
799 template<typename _CharT, typename _Traits, typename _Allocator>
800 inline basic_string<_CharT,_Traits,_Allocator>
801 operator+(_CharT __lhs,
802 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
803 { return basic_string<_CharT,_Traits,_Allocator>(1, __lhs) += __rhs; }
805 template<typename _CharT, typename _Traits, typename _Allocator>
806 inline basic_string<_CharT,_Traits,_Allocator>
807 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
810 __glibcxx_check_string(__rhs);
811 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
814 template<typename _CharT, typename _Traits, typename _Allocator>
815 inline basic_string<_CharT,_Traits,_Allocator>
816 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
818 { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
820 template<typename _CharT, typename _Traits, typename _Allocator>
822 operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
823 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
824 { return __lhs._M_base() == __rhs._M_base(); }
826 template<typename _CharT, typename _Traits, typename _Allocator>
828 operator==(const _CharT* __lhs,
829 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
831 __glibcxx_check_string(__lhs);
832 return __lhs == __rhs._M_base();
835 template<typename _CharT, typename _Traits, typename _Allocator>
837 operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
840 __glibcxx_check_string(__rhs);
841 return __lhs._M_base() == __rhs;
844 template<typename _CharT, typename _Traits, typename _Allocator>
846 operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
847 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
848 { return __lhs._M_base() != __rhs._M_base(); }
850 template<typename _CharT, typename _Traits, typename _Allocator>
852 operator!=(const _CharT* __lhs,
853 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
855 __glibcxx_check_string(__lhs);
856 return __lhs != __rhs._M_base();
859 template<typename _CharT, typename _Traits, typename _Allocator>
861 operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
864 __glibcxx_check_string(__rhs);
865 return __lhs._M_base() != __rhs;
868 template<typename _CharT, typename _Traits, typename _Allocator>
870 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
871 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
872 { return __lhs._M_base() < __rhs._M_base(); }
874 template<typename _CharT, typename _Traits, typename _Allocator>
876 operator<(const _CharT* __lhs,
877 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
879 __glibcxx_check_string(__lhs);
880 return __lhs < __rhs._M_base();
883 template<typename _CharT, typename _Traits, typename _Allocator>
885 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
888 __glibcxx_check_string(__rhs);
889 return __lhs._M_base() < __rhs;
892 template<typename _CharT, typename _Traits, typename _Allocator>
894 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
895 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
896 { return __lhs._M_base() <= __rhs._M_base(); }
898 template<typename _CharT, typename _Traits, typename _Allocator>
900 operator<=(const _CharT* __lhs,
901 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
903 __glibcxx_check_string(__lhs);
904 return __lhs <= __rhs._M_base();
907 template<typename _CharT, typename _Traits, typename _Allocator>
909 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
912 __glibcxx_check_string(__rhs);
913 return __lhs._M_base() <= __rhs;
916 template<typename _CharT, typename _Traits, typename _Allocator>
918 operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
919 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
920 { return __lhs._M_base() >= __rhs._M_base(); }
922 template<typename _CharT, typename _Traits, typename _Allocator>
924 operator>=(const _CharT* __lhs,
925 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
927 __glibcxx_check_string(__lhs);
928 return __lhs >= __rhs._M_base();
931 template<typename _CharT, typename _Traits, typename _Allocator>
933 operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
936 __glibcxx_check_string(__rhs);
937 return __lhs._M_base() >= __rhs;
940 template<typename _CharT, typename _Traits, typename _Allocator>
942 operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
943 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
944 { return __lhs._M_base() > __rhs._M_base(); }
946 template<typename _CharT, typename _Traits, typename _Allocator>
948 operator>(const _CharT* __lhs,
949 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
951 __glibcxx_check_string(__lhs);
952 return __lhs > __rhs._M_base();
955 template<typename _CharT, typename _Traits, typename _Allocator>
957 operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
960 __glibcxx_check_string(__rhs);
961 return __lhs._M_base() > __rhs;
965 template<typename _CharT, typename _Traits, typename _Allocator>
967 swap(basic_string<_CharT,_Traits,_Allocator>& __lhs,
968 basic_string<_CharT,_Traits,_Allocator>& __rhs)
969 { __lhs.swap(__rhs); }
971 template<typename _CharT, typename _Traits, typename _Allocator>
972 std::basic_ostream<_CharT, _Traits>&
973 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
974 const basic_string<_CharT, _Traits, _Allocator>& __str)
975 { return __os << __str._M_base(); }
977 template<typename _CharT, typename _Traits, typename _Allocator>
978 std::basic_istream<_CharT,_Traits>&
979 operator>>(std::basic_istream<_CharT,_Traits>& __is,
980 basic_string<_CharT,_Traits,_Allocator>& __str)
982 std::basic_istream<_CharT,_Traits>& __res = __is >> __str._M_base();
983 __str._M_invalidate_all();
987 template<typename _CharT, typename _Traits, typename _Allocator>
988 std::basic_istream<_CharT,_Traits>&
989 getline(std::basic_istream<_CharT,_Traits>& __is,
990 basic_string<_CharT,_Traits,_Allocator>& __str, _CharT __delim)
992 std::basic_istream<_CharT,_Traits>& __res = getline(__is,
995 __str._M_invalidate_all();
999 template<typename _CharT, typename _Traits, typename _Allocator>
1000 std::basic_istream<_CharT,_Traits>&
1001 getline(std::basic_istream<_CharT,_Traits>& __is,
1002 basic_string<_CharT,_Traits,_Allocator>& __str)
1004 std::basic_istream<_CharT,_Traits>& __res = getline(__is,
1006 __str._M_invalidate_all();
1010 typedef basic_string<char> string;
1012 #ifdef _GLIBCXX_USE_WCHAR_T
1013 typedef basic_string<wchar_t> wstring;
1016 } // namespace __gnu_debug