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)
118 #ifdef __GXX_EXPERIMENTAL_CXX0X__
119 basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc())
122 #endif // __GXX_EXPERIMENTAL_CXX0X__
127 operator=(const basic_string& __str)
129 *static_cast<_Base*>(this) = __str;
130 this->_M_invalidate_all();
135 operator=(const _CharT* __s)
137 __glibcxx_check_string(__s);
138 *static_cast<_Base*>(this) = __s;
139 this->_M_invalidate_all();
144 operator=(_CharT __c)
146 *static_cast<_Base*>(this) = __c;
147 this->_M_invalidate_all();
151 #ifdef __GXX_EXPERIMENTAL_CXX0X__
153 operator=(initializer_list<_CharT> __l)
155 *static_cast<_Base*>(this) = __l;
156 this->_M_invalidate_all();
159 #endif // __GXX_EXPERIMENTAL_CXX0X__
164 { return iterator(_Base::begin(), this); }
168 { return const_iterator(_Base::begin(), this); }
172 { return iterator(_Base::end(), this); }
176 { return const_iterator(_Base::end(), this); }
180 { return reverse_iterator(end()); }
182 const_reverse_iterator
184 { return const_reverse_iterator(end()); }
188 { return reverse_iterator(begin()); }
190 const_reverse_iterator
192 { return const_reverse_iterator(begin()); }
197 using _Base::max_size;
200 resize(size_type __n, _CharT __c)
202 _Base::resize(__n, __c);
203 this->_M_invalidate_all();
207 resize(size_type __n)
208 { this->resize(__n, _CharT()); }
210 using _Base::capacity;
211 using _Base::reserve;
217 this->_M_invalidate_all();
222 // 21.3.4 element access:
224 operator[](size_type __pos) const
226 _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(),
227 _M_message(__gnu_debug::__msg_subscript_oob)
228 ._M_sequence(*this, "this")
229 ._M_integer(__pos, "__pos")
230 ._M_integer(this->size(), "size"));
231 return _M_base()[__pos];
235 operator[](size_type __pos)
237 #ifdef _GLIBCXX_DEBUG_PEDANTIC
238 __glibcxx_check_subscript(__pos);
240 // as an extension v3 allows s[s.size()] when s is non-const.
241 _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(),
242 _M_message(__gnu_debug::__msg_subscript_oob)
243 ._M_sequence(*this, "this")
244 ._M_integer(__pos, "__pos")
245 ._M_integer(this->size(), "size"));
247 return _M_base()[__pos];
254 operator+=(const basic_string& __str)
257 this->_M_invalidate_all();
262 operator+=(const _CharT* __s)
264 __glibcxx_check_string(__s);
266 this->_M_invalidate_all();
271 operator+=(_CharT __c)
274 this->_M_invalidate_all();
278 #ifdef __GXX_EXPERIMENTAL_CXX0X__
280 operator+=(initializer_list<_CharT> __l)
283 this->_M_invalidate_all();
286 #endif // __GXX_EXPERIMENTAL_CXX0X__
289 append(const basic_string& __str)
291 _Base::append(__str);
292 this->_M_invalidate_all();
297 append(const basic_string& __str, size_type __pos, size_type __n)
299 _Base::append(__str, __pos, __n);
300 this->_M_invalidate_all();
305 append(const _CharT* __s, size_type __n)
307 __glibcxx_check_string_len(__s, __n);
308 _Base::append(__s, __n);
309 this->_M_invalidate_all();
314 append(const _CharT* __s)
316 __glibcxx_check_string(__s);
318 this->_M_invalidate_all();
323 append(size_type __n, _CharT __c)
325 _Base::append(__n, __c);
326 this->_M_invalidate_all();
330 template<typename _InputIterator>
332 append(_InputIterator __first, _InputIterator __last)
334 __glibcxx_check_valid_range(__first, __last);
335 _Base::append(__first, __last);
336 this->_M_invalidate_all();
340 // _GLIBCXX_RESOLVE_LIB_DEFECTS
341 // 7. string clause minor problems
343 push_back(_CharT __c)
345 _Base::push_back(__c);
346 this->_M_invalidate_all();
350 assign(const basic_string& __x)
353 this->_M_invalidate_all();
358 assign(const basic_string& __str, size_type __pos, size_type __n)
360 _Base::assign(__str, __pos, __n);
361 this->_M_invalidate_all();
366 assign(const _CharT* __s, size_type __n)
368 __glibcxx_check_string_len(__s, __n);
369 _Base::assign(__s, __n);
370 this->_M_invalidate_all();
375 assign(const _CharT* __s)
377 __glibcxx_check_string(__s);
379 this->_M_invalidate_all();
384 assign(size_type __n, _CharT __c)
386 _Base::assign(__n, __c);
387 this->_M_invalidate_all();
391 template<typename _InputIterator>
393 assign(_InputIterator __first, _InputIterator __last)
395 __glibcxx_check_valid_range(__first, __last);
396 _Base::assign(__first, __last);
397 this->_M_invalidate_all();
401 #ifdef __GXX_EXPERIMENTAL_CXX0X__
403 assign(initializer_list<_CharT> __l)
406 this->_M_invalidate_all();
409 #endif // __GXX_EXPERIMENTAL_CXX0X__
412 insert(size_type __pos1, const basic_string& __str)
414 _Base::insert(__pos1, __str);
415 this->_M_invalidate_all();
420 insert(size_type __pos1, const basic_string& __str,
421 size_type __pos2, size_type __n)
423 _Base::insert(__pos1, __str, __pos2, __n);
424 this->_M_invalidate_all();
429 insert(size_type __pos, const _CharT* __s, size_type __n)
431 __glibcxx_check_string(__s);
432 _Base::insert(__pos, __s, __n);
433 this->_M_invalidate_all();
438 insert(size_type __pos, const _CharT* __s)
440 __glibcxx_check_string(__s);
441 _Base::insert(__pos, __s);
442 this->_M_invalidate_all();
447 insert(size_type __pos, size_type __n, _CharT __c)
449 _Base::insert(__pos, __n, __c);
450 this->_M_invalidate_all();
455 insert(iterator __p, _CharT __c)
457 __glibcxx_check_insert(__p);
458 typename _Base::iterator __res = _Base::insert(__p.base(), __c);
459 this->_M_invalidate_all();
460 return iterator(__res, this);
464 insert(iterator __p, size_type __n, _CharT __c)
466 __glibcxx_check_insert(__p);
467 _Base::insert(__p.base(), __n, __c);
468 this->_M_invalidate_all();
471 template<typename _InputIterator>
473 insert(iterator __p, _InputIterator __first, _InputIterator __last)
475 __glibcxx_check_insert_range(__p, __first, __last);
476 _Base::insert(__p.base(), __first, __last);
477 this->_M_invalidate_all();
480 #ifdef __GXX_EXPERIMENTAL_CXX0X__
482 insert(iterator __p, initializer_list<_CharT> __l)
484 _Base::insert(__p, __l);
485 this->_M_invalidate_all();
487 #endif // __GXX_EXPERIMENTAL_CXX0X__
490 erase(size_type __pos = 0, size_type __n = _Base::npos)
492 _Base::erase(__pos, __n);
493 this->_M_invalidate_all();
498 erase(iterator __position)
500 __glibcxx_check_erase(__position);
501 typename _Base::iterator __res = _Base::erase(__position.base());
502 this->_M_invalidate_all();
503 return iterator(__res, this);
507 erase(iterator __first, iterator __last)
509 // _GLIBCXX_RESOLVE_LIB_DEFECTS
510 // 151. can't currently clear() empty container
511 __glibcxx_check_erase_range(__first, __last);
512 typename _Base::iterator __res = _Base::erase(__first.base(),
514 this->_M_invalidate_all();
515 return iterator(__res, this);
519 replace(size_type __pos1, size_type __n1, const basic_string& __str)
521 _Base::replace(__pos1, __n1, __str);
522 this->_M_invalidate_all();
527 replace(size_type __pos1, size_type __n1, const basic_string& __str,
528 size_type __pos2, size_type __n2)
530 _Base::replace(__pos1, __n1, __str, __pos2, __n2);
531 this->_M_invalidate_all();
536 replace(size_type __pos, size_type __n1, const _CharT* __s,
539 __glibcxx_check_string_len(__s, __n2);
540 _Base::replace(__pos, __n1, __s, __n2);
541 this->_M_invalidate_all();
546 replace(size_type __pos, size_type __n1, const _CharT* __s)
548 __glibcxx_check_string(__s);
549 _Base::replace(__pos, __n1, __s);
550 this->_M_invalidate_all();
555 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
557 _Base::replace(__pos, __n1, __n2, __c);
558 this->_M_invalidate_all();
563 replace(iterator __i1, iterator __i2, const basic_string& __str)
565 __glibcxx_check_erase_range(__i1, __i2);
566 _Base::replace(__i1.base(), __i2.base(), __str);
567 this->_M_invalidate_all();
572 replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
574 __glibcxx_check_erase_range(__i1, __i2);
575 __glibcxx_check_string_len(__s, __n);
576 _Base::replace(__i1.base(), __i2.base(), __s, __n);
577 this->_M_invalidate_all();
582 replace(iterator __i1, iterator __i2, const _CharT* __s)
584 __glibcxx_check_erase_range(__i1, __i2);
585 __glibcxx_check_string(__s);
586 _Base::replace(__i1.base(), __i2.base(), __s);
587 this->_M_invalidate_all();
592 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
594 __glibcxx_check_erase_range(__i1, __i2);
595 _Base::replace(__i1.base(), __i2.base(), __n, __c);
596 this->_M_invalidate_all();
600 template<typename _InputIterator>
602 replace(iterator __i1, iterator __i2,
603 _InputIterator __j1, _InputIterator __j2)
605 __glibcxx_check_erase_range(__i1, __i2);
606 __glibcxx_check_valid_range(__j1, __j2);
607 _Base::replace(__i1.base(), __i2.base(), __j1, __j2);
608 this->_M_invalidate_all();
612 #ifdef __GXX_EXPERIMENTAL_CXX0X__
613 basic_string& replace(iterator __i1, iterator __i2,
614 initializer_list<_CharT> __l)
616 __glibcxx_check_erase_range(__i1, __i2);
617 _Base::replace(__i1.base(), __i2.base(), __l);
618 this->_M_invalidate_all();
621 #endif // __GXX_EXPERIMENTAL_CXX0X__
624 copy(_CharT* __s, size_type __n, size_type __pos = 0) const
626 __glibcxx_check_string_len(__s, __n);
627 return _Base::copy(__s, __n, __pos);
631 swap(basic_string<_CharT,_Traits,_Allocator>& __x)
635 this->_M_invalidate_all();
636 __x._M_invalidate_all();
639 // 21.3.6 string operations:
643 const _CharT* __res = _Base::c_str();
644 this->_M_invalidate_all();
651 const _CharT* __res = _Base::data();
652 this->_M_invalidate_all();
656 using _Base::get_allocator;
659 find(const basic_string& __str, size_type __pos = 0) const
660 { return _Base::find(__str, __pos); }
663 find(const _CharT* __s, size_type __pos, size_type __n) const
665 __glibcxx_check_string(__s);
666 return _Base::find(__s, __pos, __n);
670 find(const _CharT* __s, size_type __pos = 0) const
672 __glibcxx_check_string(__s);
673 return _Base::find(__s, __pos);
677 find(_CharT __c, size_type __pos = 0) const
678 { return _Base::find(__c, __pos); }
681 rfind(const basic_string& __str, size_type __pos = _Base::npos) const
682 { return _Base::rfind(__str, __pos); }
685 rfind(const _CharT* __s, size_type __pos, size_type __n) const
687 __glibcxx_check_string_len(__s, __n);
688 return _Base::rfind(__s, __pos, __n);
692 rfind(const _CharT* __s, size_type __pos = _Base::npos) const
694 __glibcxx_check_string(__s);
695 return _Base::rfind(__s, __pos);
699 rfind(_CharT __c, size_type __pos = _Base::npos) const
700 { return _Base::rfind(__c, __pos); }
703 find_first_of(const basic_string& __str, size_type __pos = 0) const
704 { return _Base::find_first_of(__str, __pos); }
707 find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
709 __glibcxx_check_string(__s);
710 return _Base::find_first_of(__s, __pos, __n);
714 find_first_of(const _CharT* __s, size_type __pos = 0) const
716 __glibcxx_check_string(__s);
717 return _Base::find_first_of(__s, __pos);
721 find_first_of(_CharT __c, size_type __pos = 0) const
722 { return _Base::find_first_of(__c, __pos); }
725 find_last_of(const basic_string& __str,
726 size_type __pos = _Base::npos) const
727 { return _Base::find_last_of(__str, __pos); }
730 find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
732 __glibcxx_check_string(__s);
733 return _Base::find_last_of(__s, __pos, __n);
737 find_last_of(const _CharT* __s, size_type __pos = _Base::npos) const
739 __glibcxx_check_string(__s);
740 return _Base::find_last_of(__s, __pos);
744 find_last_of(_CharT __c, size_type __pos = _Base::npos) const
745 { return _Base::find_last_of(__c, __pos); }
748 find_first_not_of(const basic_string& __str, size_type __pos = 0) const
749 { return _Base::find_first_not_of(__str, __pos); }
752 find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
754 __glibcxx_check_string_len(__s, __n);
755 return _Base::find_first_not_of(__s, __pos, __n);
759 find_first_not_of(const _CharT* __s, size_type __pos = 0) const
761 __glibcxx_check_string(__s);
762 return _Base::find_first_not_of(__s, __pos);
766 find_first_not_of(_CharT __c, size_type __pos = 0) const
767 { return _Base::find_first_not_of(__c, __pos); }
770 find_last_not_of(const basic_string& __str,
771 size_type __pos = _Base::npos) const
772 { return _Base::find_last_not_of(__str, __pos); }
775 find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
777 __glibcxx_check_string(__s);
778 return _Base::find_last_not_of(__s, __pos, __n);
782 find_last_not_of(const _CharT* __s, size_type __pos = _Base::npos) const
784 __glibcxx_check_string(__s);
785 return _Base::find_last_not_of(__s, __pos);
789 find_last_not_of(_CharT __c, size_type __pos = _Base::npos) const
790 { return _Base::find_last_not_of(__c, __pos); }
793 substr(size_type __pos = 0, size_type __n = _Base::npos) const
794 { return basic_string(_Base::substr(__pos, __n)); }
797 compare(const basic_string& __str) const
798 { return _Base::compare(__str); }
801 compare(size_type __pos1, size_type __n1,
802 const basic_string& __str) const
803 { return _Base::compare(__pos1, __n1, __str); }
806 compare(size_type __pos1, size_type __n1, const basic_string& __str,
807 size_type __pos2, size_type __n2) const
808 { return _Base::compare(__pos1, __n1, __str, __pos2, __n2); }
811 compare(const _CharT* __s) const
813 __glibcxx_check_string(__s);
814 return _Base::compare(__s);
817 // _GLIBCXX_RESOLVE_LIB_DEFECTS
818 // 5. string::compare specification questionable
820 compare(size_type __pos1, size_type __n1, const _CharT* __s) const
822 __glibcxx_check_string(__s);
823 return _Base::compare(__pos1, __n1, __s);
826 // _GLIBCXX_RESOLVE_LIB_DEFECTS
827 // 5. string::compare specification questionable
829 compare(size_type __pos1, size_type __n1,const _CharT* __s,
830 size_type __n2) const
832 __glibcxx_check_string_len(__s, __n2);
833 return _Base::compare(__pos1, __n1, __s, __n2);
837 _M_base() { return *this; }
840 _M_base() const { return *this; }
842 using _Safe_base::_M_invalidate_all;
845 template<typename _CharT, typename _Traits, typename _Allocator>
846 inline basic_string<_CharT,_Traits,_Allocator>
847 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
848 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
849 { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
851 template<typename _CharT, typename _Traits, typename _Allocator>
852 inline basic_string<_CharT,_Traits,_Allocator>
853 operator+(const _CharT* __lhs,
854 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
856 __glibcxx_check_string(__lhs);
857 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
860 template<typename _CharT, typename _Traits, typename _Allocator>
861 inline basic_string<_CharT,_Traits,_Allocator>
862 operator+(_CharT __lhs,
863 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
864 { return basic_string<_CharT,_Traits,_Allocator>(1, __lhs) += __rhs; }
866 template<typename _CharT, typename _Traits, typename _Allocator>
867 inline basic_string<_CharT,_Traits,_Allocator>
868 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
871 __glibcxx_check_string(__rhs);
872 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
875 template<typename _CharT, typename _Traits, typename _Allocator>
876 inline basic_string<_CharT,_Traits,_Allocator>
877 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
879 { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
881 template<typename _CharT, typename _Traits, typename _Allocator>
883 operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
884 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
885 { return __lhs._M_base() == __rhs._M_base(); }
887 template<typename _CharT, typename _Traits, typename _Allocator>
889 operator==(const _CharT* __lhs,
890 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
892 __glibcxx_check_string(__lhs);
893 return __lhs == __rhs._M_base();
896 template<typename _CharT, typename _Traits, typename _Allocator>
898 operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
901 __glibcxx_check_string(__rhs);
902 return __lhs._M_base() == __rhs;
905 template<typename _CharT, typename _Traits, typename _Allocator>
907 operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
908 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
909 { return __lhs._M_base() != __rhs._M_base(); }
911 template<typename _CharT, typename _Traits, typename _Allocator>
913 operator!=(const _CharT* __lhs,
914 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
916 __glibcxx_check_string(__lhs);
917 return __lhs != __rhs._M_base();
920 template<typename _CharT, typename _Traits, typename _Allocator>
922 operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
925 __glibcxx_check_string(__rhs);
926 return __lhs._M_base() != __rhs;
929 template<typename _CharT, typename _Traits, typename _Allocator>
931 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
932 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
933 { return __lhs._M_base() < __rhs._M_base(); }
935 template<typename _CharT, typename _Traits, typename _Allocator>
937 operator<(const _CharT* __lhs,
938 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
940 __glibcxx_check_string(__lhs);
941 return __lhs < __rhs._M_base();
944 template<typename _CharT, typename _Traits, typename _Allocator>
946 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
949 __glibcxx_check_string(__rhs);
950 return __lhs._M_base() < __rhs;
953 template<typename _CharT, typename _Traits, typename _Allocator>
955 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
956 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
957 { return __lhs._M_base() <= __rhs._M_base(); }
959 template<typename _CharT, typename _Traits, typename _Allocator>
961 operator<=(const _CharT* __lhs,
962 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
964 __glibcxx_check_string(__lhs);
965 return __lhs <= __rhs._M_base();
968 template<typename _CharT, typename _Traits, typename _Allocator>
970 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
973 __glibcxx_check_string(__rhs);
974 return __lhs._M_base() <= __rhs;
977 template<typename _CharT, typename _Traits, typename _Allocator>
979 operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
980 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
981 { return __lhs._M_base() >= __rhs._M_base(); }
983 template<typename _CharT, typename _Traits, typename _Allocator>
985 operator>=(const _CharT* __lhs,
986 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
988 __glibcxx_check_string(__lhs);
989 return __lhs >= __rhs._M_base();
992 template<typename _CharT, typename _Traits, typename _Allocator>
994 operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
997 __glibcxx_check_string(__rhs);
998 return __lhs._M_base() >= __rhs;
1001 template<typename _CharT, typename _Traits, typename _Allocator>
1003 operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1004 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1005 { return __lhs._M_base() > __rhs._M_base(); }
1007 template<typename _CharT, typename _Traits, typename _Allocator>
1009 operator>(const _CharT* __lhs,
1010 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1012 __glibcxx_check_string(__lhs);
1013 return __lhs > __rhs._M_base();
1016 template<typename _CharT, typename _Traits, typename _Allocator>
1018 operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1019 const _CharT* __rhs)
1021 __glibcxx_check_string(__rhs);
1022 return __lhs._M_base() > __rhs;
1026 template<typename _CharT, typename _Traits, typename _Allocator>
1028 swap(basic_string<_CharT,_Traits,_Allocator>& __lhs,
1029 basic_string<_CharT,_Traits,_Allocator>& __rhs)
1030 { __lhs.swap(__rhs); }
1032 template<typename _CharT, typename _Traits, typename _Allocator>
1033 std::basic_ostream<_CharT, _Traits>&
1034 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
1035 const basic_string<_CharT, _Traits, _Allocator>& __str)
1036 { return __os << __str._M_base(); }
1038 template<typename _CharT, typename _Traits, typename _Allocator>
1039 std::basic_istream<_CharT,_Traits>&
1040 operator>>(std::basic_istream<_CharT,_Traits>& __is,
1041 basic_string<_CharT,_Traits,_Allocator>& __str)
1043 std::basic_istream<_CharT,_Traits>& __res = __is >> __str._M_base();
1044 __str._M_invalidate_all();
1048 template<typename _CharT, typename _Traits, typename _Allocator>
1049 std::basic_istream<_CharT,_Traits>&
1050 getline(std::basic_istream<_CharT,_Traits>& __is,
1051 basic_string<_CharT,_Traits,_Allocator>& __str, _CharT __delim)
1053 std::basic_istream<_CharT,_Traits>& __res = getline(__is,
1056 __str._M_invalidate_all();
1060 template<typename _CharT, typename _Traits, typename _Allocator>
1061 std::basic_istream<_CharT,_Traits>&
1062 getline(std::basic_istream<_CharT,_Traits>& __is,
1063 basic_string<_CharT,_Traits,_Allocator>& __str)
1065 std::basic_istream<_CharT,_Traits>& __res = getline(__is,
1067 __str._M_invalidate_all();
1071 typedef basic_string<char> string;
1073 #ifdef _GLIBCXX_USE_WCHAR_T
1074 typedef basic_string<wchar_t> wstring;
1077 } // namespace __gnu_debug