1 // Debugging string implementation -*- C++ -*-
3 // Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 // Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // Under Section 7 of GPL version 3, you are granted additional
18 // permissions described in the GCC Runtime Library Exception, version
19 // 3.1, as published by the Free Software Foundation.
21 // You should have received a copy of the GNU General Public License and
22 // a copy of the GCC Runtime Library Exception along with this program;
23 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 // <http://www.gnu.org/licenses/>.
26 /** @file debug/string
27 * This file is a GNU debug extension to the Standard C++ Library.
30 #ifndef _GLIBCXX_DEBUG_STRING
31 #define _GLIBCXX_DEBUG_STRING 1
34 #include <debug/safe_sequence.h>
35 #include <debug/safe_iterator.h>
39 /// Class std::basic_string with safety/checking/debug instrumentation.
40 template<typename _CharT, typename _Traits = std::char_traits<_CharT>,
41 typename _Allocator = std::allocator<_CharT> >
43 : public std::basic_string<_CharT, _Traits, _Allocator>,
44 public __gnu_debug::_Safe_sequence<basic_string<_CharT, _Traits,
47 typedef std::basic_string<_CharT, _Traits, _Allocator> _Base;
48 typedef __gnu_debug::_Safe_sequence<basic_string> _Safe_base;
52 typedef _Traits traits_type;
53 typedef typename _Traits::char_type value_type;
54 typedef _Allocator allocator_type;
55 typedef typename _Base::size_type size_type;
56 typedef typename _Base::difference_type difference_type;
57 typedef typename _Base::reference reference;
58 typedef typename _Base::const_reference const_reference;
59 typedef typename _Base::pointer pointer;
60 typedef typename _Base::const_pointer const_pointer;
62 typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, basic_string>
64 typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator,
65 basic_string> const_iterator;
67 typedef std::reverse_iterator<iterator> reverse_iterator;
68 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
72 // 21.3.1 construct/copy/destroy:
73 explicit basic_string(const _Allocator& __a = _Allocator())
77 // Provides conversion from a release-mode string to a debug-mode string
78 basic_string(const _Base& __base) : _Base(__base), _Safe_base() { }
80 // _GLIBCXX_RESOLVE_LIB_DEFECTS
81 // 42. string ctors specify wrong default allocator
82 basic_string(const basic_string& __str)
83 : _Base(__str, 0, _Base::npos, __str.get_allocator()), _Safe_base()
86 // _GLIBCXX_RESOLVE_LIB_DEFECTS
87 // 42. string ctors specify wrong default allocator
88 basic_string(const basic_string& __str, size_type __pos,
89 size_type __n = _Base::npos,
90 const _Allocator& __a = _Allocator())
91 : _Base(__str, __pos, __n, __a)
94 basic_string(const _CharT* __s, size_type __n,
95 const _Allocator& __a = _Allocator())
96 : _Base(__gnu_debug::__check_string(__s, __n), __n, __a)
99 basic_string(const _CharT* __s, const _Allocator& __a = _Allocator())
100 : _Base(__gnu_debug::__check_string(__s), __a)
101 { this->assign(__s); }
103 basic_string(size_type __n, _CharT __c,
104 const _Allocator& __a = _Allocator())
105 : _Base(__n, __c, __a)
108 template<typename _InputIterator>
109 basic_string(_InputIterator __begin, _InputIterator __end,
110 const _Allocator& __a = _Allocator())
111 : _Base(__gnu_debug::__base(__gnu_debug::__check_valid_range(__begin,
113 __gnu_debug::__base(__end), __a)
116 #ifdef __GXX_EXPERIMENTAL_CXX0X__
117 basic_string(basic_string&& __str)
118 : _Base(std::move(__str))
121 basic_string(std::initializer_list<_CharT> __l,
122 const _Allocator& __a = _Allocator())
125 #endif // __GXX_EXPERIMENTAL_CXX0X__
130 operator=(const basic_string& __str)
132 *static_cast<_Base*>(this) = __str;
133 this->_M_invalidate_all();
138 operator=(const _CharT* __s)
140 __glibcxx_check_string(__s);
141 *static_cast<_Base*>(this) = __s;
142 this->_M_invalidate_all();
147 operator=(_CharT __c)
149 *static_cast<_Base*>(this) = __c;
150 this->_M_invalidate_all();
154 #ifdef __GXX_EXPERIMENTAL_CXX0X__
156 operator=(basic_string&& __str)
158 *static_cast<_Base*>(this) = std::move(__str);
159 this->_M_invalidate_all();
164 operator=(std::initializer_list<_CharT> __l)
166 *static_cast<_Base*>(this) = __l;
167 this->_M_invalidate_all();
170 #endif // __GXX_EXPERIMENTAL_CXX0X__
175 { return iterator(_Base::begin(), this); }
179 { return const_iterator(_Base::begin(), this); }
183 { return iterator(_Base::end(), this); }
187 { return const_iterator(_Base::end(), this); }
191 { return reverse_iterator(end()); }
193 const_reverse_iterator
195 { return const_reverse_iterator(end()); }
199 { return reverse_iterator(begin()); }
201 const_reverse_iterator
203 { return const_reverse_iterator(begin()); }
208 using _Base::max_size;
211 resize(size_type __n, _CharT __c)
213 _Base::resize(__n, __c);
214 this->_M_invalidate_all();
218 resize(size_type __n)
219 { this->resize(__n, _CharT()); }
221 #ifdef __GXX_EXPERIMENTAL_CXX0X__
222 using _Base::shrink_to_fit;
225 using _Base::capacity;
226 using _Base::reserve;
232 this->_M_invalidate_all();
237 // 21.3.4 element access:
239 operator[](size_type __pos) 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"));
246 return _M_base()[__pos];
250 operator[](size_type __pos)
252 #ifdef _GLIBCXX_DEBUG_PEDANTIC
253 __glibcxx_check_subscript(__pos);
255 // as an extension v3 allows s[s.size()] when s is non-const.
256 _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(),
257 _M_message(__gnu_debug::__msg_subscript_oob)
258 ._M_sequence(*this, "this")
259 ._M_integer(__pos, "__pos")
260 ._M_integer(this->size(), "size"));
262 return _M_base()[__pos];
267 #ifdef __GXX_EXPERIMENTAL_CXX0X__
274 operator+=(const basic_string& __str)
277 this->_M_invalidate_all();
282 operator+=(const _CharT* __s)
284 __glibcxx_check_string(__s);
286 this->_M_invalidate_all();
291 operator+=(_CharT __c)
294 this->_M_invalidate_all();
298 #ifdef __GXX_EXPERIMENTAL_CXX0X__
300 operator+=(std::initializer_list<_CharT> __l)
303 this->_M_invalidate_all();
306 #endif // __GXX_EXPERIMENTAL_CXX0X__
309 append(const basic_string& __str)
311 _Base::append(__str);
312 this->_M_invalidate_all();
317 append(const basic_string& __str, size_type __pos, size_type __n)
319 _Base::append(__str, __pos, __n);
320 this->_M_invalidate_all();
325 append(const _CharT* __s, size_type __n)
327 __glibcxx_check_string_len(__s, __n);
328 _Base::append(__s, __n);
329 this->_M_invalidate_all();
334 append(const _CharT* __s)
336 __glibcxx_check_string(__s);
338 this->_M_invalidate_all();
343 append(size_type __n, _CharT __c)
345 _Base::append(__n, __c);
346 this->_M_invalidate_all();
350 template<typename _InputIterator>
352 append(_InputIterator __first, _InputIterator __last)
354 __glibcxx_check_valid_range(__first, __last);
355 _Base::append(__gnu_debug::__base(__first),
356 __gnu_debug::__base(__last));
357 this->_M_invalidate_all();
361 // _GLIBCXX_RESOLVE_LIB_DEFECTS
362 // 7. string clause minor problems
364 push_back(_CharT __c)
366 _Base::push_back(__c);
367 this->_M_invalidate_all();
371 assign(const basic_string& __x)
374 this->_M_invalidate_all();
378 #ifdef __GXX_EXPERIMENTAL_CXX0X__
380 assign(basic_string&& __x)
382 _Base::assign(std::move(__x));
383 this->_M_invalidate_all();
386 #endif // __GXX_EXPERIMENTAL_CXX0X__
389 assign(const basic_string& __str, size_type __pos, size_type __n)
391 _Base::assign(__str, __pos, __n);
392 this->_M_invalidate_all();
397 assign(const _CharT* __s, size_type __n)
399 __glibcxx_check_string_len(__s, __n);
400 _Base::assign(__s, __n);
401 this->_M_invalidate_all();
406 assign(const _CharT* __s)
408 __glibcxx_check_string(__s);
410 this->_M_invalidate_all();
415 assign(size_type __n, _CharT __c)
417 _Base::assign(__n, __c);
418 this->_M_invalidate_all();
422 template<typename _InputIterator>
424 assign(_InputIterator __first, _InputIterator __last)
426 __glibcxx_check_valid_range(__first, __last);
427 _Base::assign(__gnu_debug::__base(__first),
428 __gnu_debug::__base(__last));
429 this->_M_invalidate_all();
433 #ifdef __GXX_EXPERIMENTAL_CXX0X__
435 assign(std::initializer_list<_CharT> __l)
438 this->_M_invalidate_all();
441 #endif // __GXX_EXPERIMENTAL_CXX0X__
444 insert(size_type __pos1, const basic_string& __str)
446 _Base::insert(__pos1, __str);
447 this->_M_invalidate_all();
452 insert(size_type __pos1, const basic_string& __str,
453 size_type __pos2, size_type __n)
455 _Base::insert(__pos1, __str, __pos2, __n);
456 this->_M_invalidate_all();
461 insert(size_type __pos, const _CharT* __s, size_type __n)
463 __glibcxx_check_string(__s);
464 _Base::insert(__pos, __s, __n);
465 this->_M_invalidate_all();
470 insert(size_type __pos, const _CharT* __s)
472 __glibcxx_check_string(__s);
473 _Base::insert(__pos, __s);
474 this->_M_invalidate_all();
479 insert(size_type __pos, size_type __n, _CharT __c)
481 _Base::insert(__pos, __n, __c);
482 this->_M_invalidate_all();
487 insert(iterator __p, _CharT __c)
489 __glibcxx_check_insert(__p);
490 typename _Base::iterator __res = _Base::insert(__p.base(), __c);
491 this->_M_invalidate_all();
492 return iterator(__res, this);
496 insert(iterator __p, size_type __n, _CharT __c)
498 __glibcxx_check_insert(__p);
499 _Base::insert(__p.base(), __n, __c);
500 this->_M_invalidate_all();
503 template<typename _InputIterator>
505 insert(iterator __p, _InputIterator __first, _InputIterator __last)
507 __glibcxx_check_insert_range(__p, __first, __last);
508 _Base::insert(__p.base(), __gnu_debug::__base(__first),
509 __gnu_debug::__base(__last));
510 this->_M_invalidate_all();
513 #ifdef __GXX_EXPERIMENTAL_CXX0X__
515 insert(iterator __p, std::initializer_list<_CharT> __l)
517 __glibcxx_check_insert(__p);
518 _Base::insert(__p.base(), __l);
519 this->_M_invalidate_all();
521 #endif // __GXX_EXPERIMENTAL_CXX0X__
524 erase(size_type __pos = 0, size_type __n = _Base::npos)
526 _Base::erase(__pos, __n);
527 this->_M_invalidate_all();
532 erase(iterator __position)
534 __glibcxx_check_erase(__position);
535 typename _Base::iterator __res = _Base::erase(__position.base());
536 this->_M_invalidate_all();
537 return iterator(__res, this);
541 erase(iterator __first, iterator __last)
543 // _GLIBCXX_RESOLVE_LIB_DEFECTS
544 // 151. can't currently clear() empty container
545 __glibcxx_check_erase_range(__first, __last);
546 typename _Base::iterator __res = _Base::erase(__first.base(),
548 this->_M_invalidate_all();
549 return iterator(__res, this);
553 replace(size_type __pos1, size_type __n1, const basic_string& __str)
555 _Base::replace(__pos1, __n1, __str);
556 this->_M_invalidate_all();
561 replace(size_type __pos1, size_type __n1, const basic_string& __str,
562 size_type __pos2, size_type __n2)
564 _Base::replace(__pos1, __n1, __str, __pos2, __n2);
565 this->_M_invalidate_all();
570 replace(size_type __pos, size_type __n1, const _CharT* __s,
573 __glibcxx_check_string_len(__s, __n2);
574 _Base::replace(__pos, __n1, __s, __n2);
575 this->_M_invalidate_all();
580 replace(size_type __pos, size_type __n1, const _CharT* __s)
582 __glibcxx_check_string(__s);
583 _Base::replace(__pos, __n1, __s);
584 this->_M_invalidate_all();
589 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
591 _Base::replace(__pos, __n1, __n2, __c);
592 this->_M_invalidate_all();
597 replace(iterator __i1, iterator __i2, const basic_string& __str)
599 __glibcxx_check_erase_range(__i1, __i2);
600 _Base::replace(__i1.base(), __i2.base(), __str);
601 this->_M_invalidate_all();
606 replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
608 __glibcxx_check_erase_range(__i1, __i2);
609 __glibcxx_check_string_len(__s, __n);
610 _Base::replace(__i1.base(), __i2.base(), __s, __n);
611 this->_M_invalidate_all();
616 replace(iterator __i1, iterator __i2, const _CharT* __s)
618 __glibcxx_check_erase_range(__i1, __i2);
619 __glibcxx_check_string(__s);
620 _Base::replace(__i1.base(), __i2.base(), __s);
621 this->_M_invalidate_all();
626 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
628 __glibcxx_check_erase_range(__i1, __i2);
629 _Base::replace(__i1.base(), __i2.base(), __n, __c);
630 this->_M_invalidate_all();
634 template<typename _InputIterator>
636 replace(iterator __i1, iterator __i2,
637 _InputIterator __j1, _InputIterator __j2)
639 __glibcxx_check_erase_range(__i1, __i2);
640 __glibcxx_check_valid_range(__j1, __j2);
641 _Base::replace(__i1.base(), __i2.base(), __j1, __j2);
642 this->_M_invalidate_all();
646 #ifdef __GXX_EXPERIMENTAL_CXX0X__
647 basic_string& replace(iterator __i1, iterator __i2,
648 std::initializer_list<_CharT> __l)
650 __glibcxx_check_erase_range(__i1, __i2);
651 _Base::replace(__i1.base(), __i2.base(), __l);
652 this->_M_invalidate_all();
655 #endif // __GXX_EXPERIMENTAL_CXX0X__
658 copy(_CharT* __s, size_type __n, size_type __pos = 0) const
660 __glibcxx_check_string_len(__s, __n);
661 return _Base::copy(__s, __n, __pos);
665 swap(basic_string<_CharT,_Traits,_Allocator>& __x)
669 this->_M_invalidate_all();
670 __x._M_invalidate_all();
673 // 21.3.6 string operations:
677 const _CharT* __res = _Base::c_str();
678 this->_M_invalidate_all();
685 const _CharT* __res = _Base::data();
686 this->_M_invalidate_all();
690 using _Base::get_allocator;
693 find(const basic_string& __str, size_type __pos = 0) const
694 { return _Base::find(__str, __pos); }
697 find(const _CharT* __s, size_type __pos, size_type __n) const
699 __glibcxx_check_string(__s);
700 return _Base::find(__s, __pos, __n);
704 find(const _CharT* __s, size_type __pos = 0) const
706 __glibcxx_check_string(__s);
707 return _Base::find(__s, __pos);
711 find(_CharT __c, size_type __pos = 0) const
712 { return _Base::find(__c, __pos); }
715 rfind(const basic_string& __str, size_type __pos = _Base::npos) const
716 { return _Base::rfind(__str, __pos); }
719 rfind(const _CharT* __s, size_type __pos, size_type __n) const
721 __glibcxx_check_string_len(__s, __n);
722 return _Base::rfind(__s, __pos, __n);
726 rfind(const _CharT* __s, size_type __pos = _Base::npos) const
728 __glibcxx_check_string(__s);
729 return _Base::rfind(__s, __pos);
733 rfind(_CharT __c, size_type __pos = _Base::npos) const
734 { return _Base::rfind(__c, __pos); }
737 find_first_of(const basic_string& __str, size_type __pos = 0) const
738 { return _Base::find_first_of(__str, __pos); }
741 find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
743 __glibcxx_check_string(__s);
744 return _Base::find_first_of(__s, __pos, __n);
748 find_first_of(const _CharT* __s, size_type __pos = 0) const
750 __glibcxx_check_string(__s);
751 return _Base::find_first_of(__s, __pos);
755 find_first_of(_CharT __c, size_type __pos = 0) const
756 { return _Base::find_first_of(__c, __pos); }
759 find_last_of(const basic_string& __str,
760 size_type __pos = _Base::npos) const
761 { return _Base::find_last_of(__str, __pos); }
764 find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
766 __glibcxx_check_string(__s);
767 return _Base::find_last_of(__s, __pos, __n);
771 find_last_of(const _CharT* __s, size_type __pos = _Base::npos) const
773 __glibcxx_check_string(__s);
774 return _Base::find_last_of(__s, __pos);
778 find_last_of(_CharT __c, size_type __pos = _Base::npos) const
779 { return _Base::find_last_of(__c, __pos); }
782 find_first_not_of(const basic_string& __str, size_type __pos = 0) const
783 { return _Base::find_first_not_of(__str, __pos); }
786 find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
788 __glibcxx_check_string_len(__s, __n);
789 return _Base::find_first_not_of(__s, __pos, __n);
793 find_first_not_of(const _CharT* __s, size_type __pos = 0) const
795 __glibcxx_check_string(__s);
796 return _Base::find_first_not_of(__s, __pos);
800 find_first_not_of(_CharT __c, size_type __pos = 0) const
801 { return _Base::find_first_not_of(__c, __pos); }
804 find_last_not_of(const basic_string& __str,
805 size_type __pos = _Base::npos) const
806 { return _Base::find_last_not_of(__str, __pos); }
809 find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
811 __glibcxx_check_string(__s);
812 return _Base::find_last_not_of(__s, __pos, __n);
816 find_last_not_of(const _CharT* __s, size_type __pos = _Base::npos) const
818 __glibcxx_check_string(__s);
819 return _Base::find_last_not_of(__s, __pos);
823 find_last_not_of(_CharT __c, size_type __pos = _Base::npos) const
824 { return _Base::find_last_not_of(__c, __pos); }
827 substr(size_type __pos = 0, size_type __n = _Base::npos) const
828 { return basic_string(_Base::substr(__pos, __n)); }
831 compare(const basic_string& __str) const
832 { return _Base::compare(__str); }
835 compare(size_type __pos1, size_type __n1,
836 const basic_string& __str) const
837 { return _Base::compare(__pos1, __n1, __str); }
840 compare(size_type __pos1, size_type __n1, const basic_string& __str,
841 size_type __pos2, size_type __n2) const
842 { return _Base::compare(__pos1, __n1, __str, __pos2, __n2); }
845 compare(const _CharT* __s) const
847 __glibcxx_check_string(__s);
848 return _Base::compare(__s);
851 // _GLIBCXX_RESOLVE_LIB_DEFECTS
852 // 5. string::compare specification questionable
854 compare(size_type __pos1, size_type __n1, const _CharT* __s) const
856 __glibcxx_check_string(__s);
857 return _Base::compare(__pos1, __n1, __s);
860 // _GLIBCXX_RESOLVE_LIB_DEFECTS
861 // 5. string::compare specification questionable
863 compare(size_type __pos1, size_type __n1,const _CharT* __s,
864 size_type __n2) const
866 __glibcxx_check_string_len(__s, __n2);
867 return _Base::compare(__pos1, __n1, __s, __n2);
871 _M_base() { return *this; }
874 _M_base() const { return *this; }
876 using _Safe_base::_M_invalidate_all;
879 template<typename _CharT, typename _Traits, typename _Allocator>
880 inline basic_string<_CharT,_Traits,_Allocator>
881 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
882 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
883 { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
885 template<typename _CharT, typename _Traits, typename _Allocator>
886 inline basic_string<_CharT,_Traits,_Allocator>
887 operator+(const _CharT* __lhs,
888 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
890 __glibcxx_check_string(__lhs);
891 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
894 template<typename _CharT, typename _Traits, typename _Allocator>
895 inline basic_string<_CharT,_Traits,_Allocator>
896 operator+(_CharT __lhs,
897 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
898 { return basic_string<_CharT,_Traits,_Allocator>(1, __lhs) += __rhs; }
900 template<typename _CharT, typename _Traits, typename _Allocator>
901 inline basic_string<_CharT,_Traits,_Allocator>
902 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
905 __glibcxx_check_string(__rhs);
906 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
909 template<typename _CharT, typename _Traits, typename _Allocator>
910 inline basic_string<_CharT,_Traits,_Allocator>
911 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
913 { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
915 template<typename _CharT, typename _Traits, typename _Allocator>
917 operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
918 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
919 { return __lhs._M_base() == __rhs._M_base(); }
921 template<typename _CharT, typename _Traits, typename _Allocator>
923 operator==(const _CharT* __lhs,
924 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
926 __glibcxx_check_string(__lhs);
927 return __lhs == __rhs._M_base();
930 template<typename _CharT, typename _Traits, typename _Allocator>
932 operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
935 __glibcxx_check_string(__rhs);
936 return __lhs._M_base() == __rhs;
939 template<typename _CharT, typename _Traits, typename _Allocator>
941 operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
942 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
943 { return __lhs._M_base() != __rhs._M_base(); }
945 template<typename _CharT, typename _Traits, typename _Allocator>
947 operator!=(const _CharT* __lhs,
948 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
950 __glibcxx_check_string(__lhs);
951 return __lhs != __rhs._M_base();
954 template<typename _CharT, typename _Traits, typename _Allocator>
956 operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
959 __glibcxx_check_string(__rhs);
960 return __lhs._M_base() != __rhs;
963 template<typename _CharT, typename _Traits, typename _Allocator>
965 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
966 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
967 { return __lhs._M_base() < __rhs._M_base(); }
969 template<typename _CharT, typename _Traits, typename _Allocator>
971 operator<(const _CharT* __lhs,
972 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
974 __glibcxx_check_string(__lhs);
975 return __lhs < __rhs._M_base();
978 template<typename _CharT, typename _Traits, typename _Allocator>
980 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
983 __glibcxx_check_string(__rhs);
984 return __lhs._M_base() < __rhs;
987 template<typename _CharT, typename _Traits, typename _Allocator>
989 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
990 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
991 { return __lhs._M_base() <= __rhs._M_base(); }
993 template<typename _CharT, typename _Traits, typename _Allocator>
995 operator<=(const _CharT* __lhs,
996 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
998 __glibcxx_check_string(__lhs);
999 return __lhs <= __rhs._M_base();
1002 template<typename _CharT, typename _Traits, typename _Allocator>
1004 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1005 const _CharT* __rhs)
1007 __glibcxx_check_string(__rhs);
1008 return __lhs._M_base() <= __rhs;
1011 template<typename _CharT, typename _Traits, typename _Allocator>
1013 operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1014 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1015 { return __lhs._M_base() >= __rhs._M_base(); }
1017 template<typename _CharT, typename _Traits, typename _Allocator>
1019 operator>=(const _CharT* __lhs,
1020 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1022 __glibcxx_check_string(__lhs);
1023 return __lhs >= __rhs._M_base();
1026 template<typename _CharT, typename _Traits, typename _Allocator>
1028 operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1029 const _CharT* __rhs)
1031 __glibcxx_check_string(__rhs);
1032 return __lhs._M_base() >= __rhs;
1035 template<typename _CharT, typename _Traits, typename _Allocator>
1037 operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1038 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1039 { return __lhs._M_base() > __rhs._M_base(); }
1041 template<typename _CharT, typename _Traits, typename _Allocator>
1043 operator>(const _CharT* __lhs,
1044 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1046 __glibcxx_check_string(__lhs);
1047 return __lhs > __rhs._M_base();
1050 template<typename _CharT, typename _Traits, typename _Allocator>
1052 operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1053 const _CharT* __rhs)
1055 __glibcxx_check_string(__rhs);
1056 return __lhs._M_base() > __rhs;
1060 template<typename _CharT, typename _Traits, typename _Allocator>
1062 swap(basic_string<_CharT,_Traits,_Allocator>& __lhs,
1063 basic_string<_CharT,_Traits,_Allocator>& __rhs)
1064 { __lhs.swap(__rhs); }
1066 template<typename _CharT, typename _Traits, typename _Allocator>
1067 std::basic_ostream<_CharT, _Traits>&
1068 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
1069 const basic_string<_CharT, _Traits, _Allocator>& __str)
1070 { return __os << __str._M_base(); }
1072 template<typename _CharT, typename _Traits, typename _Allocator>
1073 std::basic_istream<_CharT,_Traits>&
1074 operator>>(std::basic_istream<_CharT,_Traits>& __is,
1075 basic_string<_CharT,_Traits,_Allocator>& __str)
1077 std::basic_istream<_CharT,_Traits>& __res = __is >> __str._M_base();
1078 __str._M_invalidate_all();
1082 template<typename _CharT, typename _Traits, typename _Allocator>
1083 std::basic_istream<_CharT,_Traits>&
1084 getline(std::basic_istream<_CharT,_Traits>& __is,
1085 basic_string<_CharT,_Traits,_Allocator>& __str, _CharT __delim)
1087 std::basic_istream<_CharT,_Traits>& __res = getline(__is,
1090 __str._M_invalidate_all();
1094 template<typename _CharT, typename _Traits, typename _Allocator>
1095 std::basic_istream<_CharT,_Traits>&
1096 getline(std::basic_istream<_CharT,_Traits>& __is,
1097 basic_string<_CharT,_Traits,_Allocator>& __str)
1099 std::basic_istream<_CharT,_Traits>& __res = getline(__is,
1101 __str._M_invalidate_all();
1105 typedef basic_string<char> string;
1107 #ifdef _GLIBCXX_USE_WCHAR_T
1108 typedef basic_string<wchar_t> wstring;
1111 } // namespace __gnu_debug