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 _Base::insert(__p, __l);
518 this->_M_invalidate_all();
520 #endif // __GXX_EXPERIMENTAL_CXX0X__
523 erase(size_type __pos = 0, size_type __n = _Base::npos)
525 _Base::erase(__pos, __n);
526 this->_M_invalidate_all();
531 erase(iterator __position)
533 __glibcxx_check_erase(__position);
534 typename _Base::iterator __res = _Base::erase(__position.base());
535 this->_M_invalidate_all();
536 return iterator(__res, this);
540 erase(iterator __first, iterator __last)
542 // _GLIBCXX_RESOLVE_LIB_DEFECTS
543 // 151. can't currently clear() empty container
544 __glibcxx_check_erase_range(__first, __last);
545 typename _Base::iterator __res = _Base::erase(__first.base(),
547 this->_M_invalidate_all();
548 return iterator(__res, this);
552 replace(size_type __pos1, size_type __n1, const basic_string& __str)
554 _Base::replace(__pos1, __n1, __str);
555 this->_M_invalidate_all();
560 replace(size_type __pos1, size_type __n1, const basic_string& __str,
561 size_type __pos2, size_type __n2)
563 _Base::replace(__pos1, __n1, __str, __pos2, __n2);
564 this->_M_invalidate_all();
569 replace(size_type __pos, size_type __n1, const _CharT* __s,
572 __glibcxx_check_string_len(__s, __n2);
573 _Base::replace(__pos, __n1, __s, __n2);
574 this->_M_invalidate_all();
579 replace(size_type __pos, size_type __n1, const _CharT* __s)
581 __glibcxx_check_string(__s);
582 _Base::replace(__pos, __n1, __s);
583 this->_M_invalidate_all();
588 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
590 _Base::replace(__pos, __n1, __n2, __c);
591 this->_M_invalidate_all();
596 replace(iterator __i1, iterator __i2, const basic_string& __str)
598 __glibcxx_check_erase_range(__i1, __i2);
599 _Base::replace(__i1.base(), __i2.base(), __str);
600 this->_M_invalidate_all();
605 replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
607 __glibcxx_check_erase_range(__i1, __i2);
608 __glibcxx_check_string_len(__s, __n);
609 _Base::replace(__i1.base(), __i2.base(), __s, __n);
610 this->_M_invalidate_all();
615 replace(iterator __i1, iterator __i2, const _CharT* __s)
617 __glibcxx_check_erase_range(__i1, __i2);
618 __glibcxx_check_string(__s);
619 _Base::replace(__i1.base(), __i2.base(), __s);
620 this->_M_invalidate_all();
625 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
627 __glibcxx_check_erase_range(__i1, __i2);
628 _Base::replace(__i1.base(), __i2.base(), __n, __c);
629 this->_M_invalidate_all();
633 template<typename _InputIterator>
635 replace(iterator __i1, iterator __i2,
636 _InputIterator __j1, _InputIterator __j2)
638 __glibcxx_check_erase_range(__i1, __i2);
639 __glibcxx_check_valid_range(__j1, __j2);
640 _Base::replace(__i1.base(), __i2.base(), __j1, __j2);
641 this->_M_invalidate_all();
645 #ifdef __GXX_EXPERIMENTAL_CXX0X__
646 basic_string& replace(iterator __i1, iterator __i2,
647 std::initializer_list<_CharT> __l)
649 __glibcxx_check_erase_range(__i1, __i2);
650 _Base::replace(__i1.base(), __i2.base(), __l);
651 this->_M_invalidate_all();
654 #endif // __GXX_EXPERIMENTAL_CXX0X__
657 copy(_CharT* __s, size_type __n, size_type __pos = 0) const
659 __glibcxx_check_string_len(__s, __n);
660 return _Base::copy(__s, __n, __pos);
664 swap(basic_string<_CharT,_Traits,_Allocator>& __x)
668 this->_M_invalidate_all();
669 __x._M_invalidate_all();
672 // 21.3.6 string operations:
676 const _CharT* __res = _Base::c_str();
677 this->_M_invalidate_all();
684 const _CharT* __res = _Base::data();
685 this->_M_invalidate_all();
689 using _Base::get_allocator;
692 find(const basic_string& __str, size_type __pos = 0) const
693 { return _Base::find(__str, __pos); }
696 find(const _CharT* __s, size_type __pos, size_type __n) const
698 __glibcxx_check_string(__s);
699 return _Base::find(__s, __pos, __n);
703 find(const _CharT* __s, size_type __pos = 0) const
705 __glibcxx_check_string(__s);
706 return _Base::find(__s, __pos);
710 find(_CharT __c, size_type __pos = 0) const
711 { return _Base::find(__c, __pos); }
714 rfind(const basic_string& __str, size_type __pos = _Base::npos) const
715 { return _Base::rfind(__str, __pos); }
718 rfind(const _CharT* __s, size_type __pos, size_type __n) const
720 __glibcxx_check_string_len(__s, __n);
721 return _Base::rfind(__s, __pos, __n);
725 rfind(const _CharT* __s, size_type __pos = _Base::npos) const
727 __glibcxx_check_string(__s);
728 return _Base::rfind(__s, __pos);
732 rfind(_CharT __c, size_type __pos = _Base::npos) const
733 { return _Base::rfind(__c, __pos); }
736 find_first_of(const basic_string& __str, size_type __pos = 0) const
737 { return _Base::find_first_of(__str, __pos); }
740 find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
742 __glibcxx_check_string(__s);
743 return _Base::find_first_of(__s, __pos, __n);
747 find_first_of(const _CharT* __s, size_type __pos = 0) const
749 __glibcxx_check_string(__s);
750 return _Base::find_first_of(__s, __pos);
754 find_first_of(_CharT __c, size_type __pos = 0) const
755 { return _Base::find_first_of(__c, __pos); }
758 find_last_of(const basic_string& __str,
759 size_type __pos = _Base::npos) const
760 { return _Base::find_last_of(__str, __pos); }
763 find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
765 __glibcxx_check_string(__s);
766 return _Base::find_last_of(__s, __pos, __n);
770 find_last_of(const _CharT* __s, size_type __pos = _Base::npos) const
772 __glibcxx_check_string(__s);
773 return _Base::find_last_of(__s, __pos);
777 find_last_of(_CharT __c, size_type __pos = _Base::npos) const
778 { return _Base::find_last_of(__c, __pos); }
781 find_first_not_of(const basic_string& __str, size_type __pos = 0) const
782 { return _Base::find_first_not_of(__str, __pos); }
785 find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
787 __glibcxx_check_string_len(__s, __n);
788 return _Base::find_first_not_of(__s, __pos, __n);
792 find_first_not_of(const _CharT* __s, size_type __pos = 0) const
794 __glibcxx_check_string(__s);
795 return _Base::find_first_not_of(__s, __pos);
799 find_first_not_of(_CharT __c, size_type __pos = 0) const
800 { return _Base::find_first_not_of(__c, __pos); }
803 find_last_not_of(const basic_string& __str,
804 size_type __pos = _Base::npos) const
805 { return _Base::find_last_not_of(__str, __pos); }
808 find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
810 __glibcxx_check_string(__s);
811 return _Base::find_last_not_of(__s, __pos, __n);
815 find_last_not_of(const _CharT* __s, size_type __pos = _Base::npos) const
817 __glibcxx_check_string(__s);
818 return _Base::find_last_not_of(__s, __pos);
822 find_last_not_of(_CharT __c, size_type __pos = _Base::npos) const
823 { return _Base::find_last_not_of(__c, __pos); }
826 substr(size_type __pos = 0, size_type __n = _Base::npos) const
827 { return basic_string(_Base::substr(__pos, __n)); }
830 compare(const basic_string& __str) const
831 { return _Base::compare(__str); }
834 compare(size_type __pos1, size_type __n1,
835 const basic_string& __str) const
836 { return _Base::compare(__pos1, __n1, __str); }
839 compare(size_type __pos1, size_type __n1, const basic_string& __str,
840 size_type __pos2, size_type __n2) const
841 { return _Base::compare(__pos1, __n1, __str, __pos2, __n2); }
844 compare(const _CharT* __s) const
846 __glibcxx_check_string(__s);
847 return _Base::compare(__s);
850 // _GLIBCXX_RESOLVE_LIB_DEFECTS
851 // 5. string::compare specification questionable
853 compare(size_type __pos1, size_type __n1, const _CharT* __s) const
855 __glibcxx_check_string(__s);
856 return _Base::compare(__pos1, __n1, __s);
859 // _GLIBCXX_RESOLVE_LIB_DEFECTS
860 // 5. string::compare specification questionable
862 compare(size_type __pos1, size_type __n1,const _CharT* __s,
863 size_type __n2) const
865 __glibcxx_check_string_len(__s, __n2);
866 return _Base::compare(__pos1, __n1, __s, __n2);
870 _M_base() { return *this; }
873 _M_base() const { return *this; }
875 using _Safe_base::_M_invalidate_all;
878 template<typename _CharT, typename _Traits, typename _Allocator>
879 inline basic_string<_CharT,_Traits,_Allocator>
880 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
881 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
882 { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
884 template<typename _CharT, typename _Traits, typename _Allocator>
885 inline basic_string<_CharT,_Traits,_Allocator>
886 operator+(const _CharT* __lhs,
887 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
889 __glibcxx_check_string(__lhs);
890 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
893 template<typename _CharT, typename _Traits, typename _Allocator>
894 inline basic_string<_CharT,_Traits,_Allocator>
895 operator+(_CharT __lhs,
896 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
897 { return basic_string<_CharT,_Traits,_Allocator>(1, __lhs) += __rhs; }
899 template<typename _CharT, typename _Traits, typename _Allocator>
900 inline basic_string<_CharT,_Traits,_Allocator>
901 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
904 __glibcxx_check_string(__rhs);
905 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
908 template<typename _CharT, typename _Traits, typename _Allocator>
909 inline basic_string<_CharT,_Traits,_Allocator>
910 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
912 { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
914 template<typename _CharT, typename _Traits, typename _Allocator>
916 operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
917 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
918 { return __lhs._M_base() == __rhs._M_base(); }
920 template<typename _CharT, typename _Traits, typename _Allocator>
922 operator==(const _CharT* __lhs,
923 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
925 __glibcxx_check_string(__lhs);
926 return __lhs == __rhs._M_base();
929 template<typename _CharT, typename _Traits, typename _Allocator>
931 operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
934 __glibcxx_check_string(__rhs);
935 return __lhs._M_base() == __rhs;
938 template<typename _CharT, typename _Traits, typename _Allocator>
940 operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
941 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
942 { return __lhs._M_base() != __rhs._M_base(); }
944 template<typename _CharT, typename _Traits, typename _Allocator>
946 operator!=(const _CharT* __lhs,
947 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
949 __glibcxx_check_string(__lhs);
950 return __lhs != __rhs._M_base();
953 template<typename _CharT, typename _Traits, typename _Allocator>
955 operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
958 __glibcxx_check_string(__rhs);
959 return __lhs._M_base() != __rhs;
962 template<typename _CharT, typename _Traits, typename _Allocator>
964 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
965 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
966 { return __lhs._M_base() < __rhs._M_base(); }
968 template<typename _CharT, typename _Traits, typename _Allocator>
970 operator<(const _CharT* __lhs,
971 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
973 __glibcxx_check_string(__lhs);
974 return __lhs < __rhs._M_base();
977 template<typename _CharT, typename _Traits, typename _Allocator>
979 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
982 __glibcxx_check_string(__rhs);
983 return __lhs._M_base() < __rhs;
986 template<typename _CharT, typename _Traits, typename _Allocator>
988 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
989 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
990 { return __lhs._M_base() <= __rhs._M_base(); }
992 template<typename _CharT, typename _Traits, typename _Allocator>
994 operator<=(const _CharT* __lhs,
995 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
997 __glibcxx_check_string(__lhs);
998 return __lhs <= __rhs._M_base();
1001 template<typename _CharT, typename _Traits, typename _Allocator>
1003 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1004 const _CharT* __rhs)
1006 __glibcxx_check_string(__rhs);
1007 return __lhs._M_base() <= __rhs;
1010 template<typename _CharT, typename _Traits, typename _Allocator>
1012 operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1013 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1014 { return __lhs._M_base() >= __rhs._M_base(); }
1016 template<typename _CharT, typename _Traits, typename _Allocator>
1018 operator>=(const _CharT* __lhs,
1019 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1021 __glibcxx_check_string(__lhs);
1022 return __lhs >= __rhs._M_base();
1025 template<typename _CharT, typename _Traits, typename _Allocator>
1027 operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1028 const _CharT* __rhs)
1030 __glibcxx_check_string(__rhs);
1031 return __lhs._M_base() >= __rhs;
1034 template<typename _CharT, typename _Traits, typename _Allocator>
1036 operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1037 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1038 { return __lhs._M_base() > __rhs._M_base(); }
1040 template<typename _CharT, typename _Traits, typename _Allocator>
1042 operator>(const _CharT* __lhs,
1043 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1045 __glibcxx_check_string(__lhs);
1046 return __lhs > __rhs._M_base();
1049 template<typename _CharT, typename _Traits, typename _Allocator>
1051 operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1052 const _CharT* __rhs)
1054 __glibcxx_check_string(__rhs);
1055 return __lhs._M_base() > __rhs;
1059 template<typename _CharT, typename _Traits, typename _Allocator>
1061 swap(basic_string<_CharT,_Traits,_Allocator>& __lhs,
1062 basic_string<_CharT,_Traits,_Allocator>& __rhs)
1063 { __lhs.swap(__rhs); }
1065 template<typename _CharT, typename _Traits, typename _Allocator>
1066 std::basic_ostream<_CharT, _Traits>&
1067 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
1068 const basic_string<_CharT, _Traits, _Allocator>& __str)
1069 { return __os << __str._M_base(); }
1071 template<typename _CharT, typename _Traits, typename _Allocator>
1072 std::basic_istream<_CharT,_Traits>&
1073 operator>>(std::basic_istream<_CharT,_Traits>& __is,
1074 basic_string<_CharT,_Traits,_Allocator>& __str)
1076 std::basic_istream<_CharT,_Traits>& __res = __is >> __str._M_base();
1077 __str._M_invalidate_all();
1081 template<typename _CharT, typename _Traits, typename _Allocator>
1082 std::basic_istream<_CharT,_Traits>&
1083 getline(std::basic_istream<_CharT,_Traits>& __is,
1084 basic_string<_CharT,_Traits,_Allocator>& __str, _CharT __delim)
1086 std::basic_istream<_CharT,_Traits>& __res = getline(__is,
1089 __str._M_invalidate_all();
1093 template<typename _CharT, typename _Traits, typename _Allocator>
1094 std::basic_istream<_CharT,_Traits>&
1095 getline(std::basic_istream<_CharT,_Traits>& __is,
1096 basic_string<_CharT,_Traits,_Allocator>& __str)
1098 std::basic_istream<_CharT,_Traits>& __res = getline(__is,
1100 __str._M_invalidate_all();
1104 typedef basic_string<char> string;
1106 #ifdef _GLIBCXX_USE_WCHAR_T
1107 typedef basic_string<wchar_t> wstring;
1110 } // namespace __gnu_debug