1 // Debugging string implementation -*- C++ -*-
3 // Copyright (C) 2003, 2005, 2006, 2009
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 template<typename _CharT, typename _Traits = std::char_traits<_CharT>,
40 typename _Allocator = std::allocator<_CharT> >
42 : public std::basic_string<_CharT, _Traits, _Allocator>,
43 public __gnu_debug::_Safe_sequence<basic_string<_CharT, _Traits,
46 typedef std::basic_string<_CharT, _Traits, _Allocator> _Base;
47 typedef __gnu_debug::_Safe_sequence<basic_string> _Safe_base;
51 typedef _Traits traits_type;
52 typedef typename _Traits::char_type value_type;
53 typedef _Allocator allocator_type;
54 typedef typename _Base::size_type size_type;
55 typedef typename _Base::difference_type difference_type;
56 typedef typename _Base::reference reference;
57 typedef typename _Base::const_reference const_reference;
58 typedef typename _Base::pointer pointer;
59 typedef typename _Base::const_pointer const_pointer;
61 typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, basic_string>
63 typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator,
64 basic_string> const_iterator;
66 typedef std::reverse_iterator<iterator> reverse_iterator;
67 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
71 // 21.3.1 construct/copy/destroy:
72 explicit basic_string(const _Allocator& __a = _Allocator())
76 // Provides conversion from a release-mode string to a debug-mode string
77 basic_string(const _Base& __base) : _Base(__base), _Safe_base() { }
79 // _GLIBCXX_RESOLVE_LIB_DEFECTS
80 // 42. string ctors specify wrong default allocator
81 basic_string(const basic_string& __str)
82 : _Base(__str, 0, _Base::npos, __str.get_allocator()), _Safe_base()
85 // _GLIBCXX_RESOLVE_LIB_DEFECTS
86 // 42. string ctors specify wrong default allocator
87 basic_string(const basic_string& __str, size_type __pos,
88 size_type __n = _Base::npos,
89 const _Allocator& __a = _Allocator())
90 : _Base(__str, __pos, __n, __a)
93 basic_string(const _CharT* __s, size_type __n,
94 const _Allocator& __a = _Allocator())
95 : _Base(__gnu_debug::__check_string(__s, __n), __n, __a)
98 basic_string(const _CharT* __s, const _Allocator& __a = _Allocator())
99 : _Base(__gnu_debug::__check_string(__s), __a)
100 { this->assign(__s); }
102 basic_string(size_type __n, _CharT __c,
103 const _Allocator& __a = _Allocator())
104 : _Base(__n, __c, __a)
107 template<typename _InputIterator>
108 basic_string(_InputIterator __begin, _InputIterator __end,
109 const _Allocator& __a = _Allocator())
110 : _Base(__gnu_debug::__check_valid_range(__begin, __end), __end, __a)
113 #ifdef __GXX_EXPERIMENTAL_CXX0X__
114 basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc())
117 #endif // __GXX_EXPERIMENTAL_CXX0X__
122 operator=(const basic_string& __str)
124 *static_cast<_Base*>(this) = __str;
125 this->_M_invalidate_all();
130 operator=(const _CharT* __s)
132 __glibcxx_check_string(__s);
133 *static_cast<_Base*>(this) = __s;
134 this->_M_invalidate_all();
139 operator=(_CharT __c)
141 *static_cast<_Base*>(this) = __c;
142 this->_M_invalidate_all();
146 #ifdef __GXX_EXPERIMENTAL_CXX0X__
148 operator=(initializer_list<_CharT> __l)
150 *static_cast<_Base*>(this) = __l;
151 this->_M_invalidate_all();
154 #endif // __GXX_EXPERIMENTAL_CXX0X__
159 { return iterator(_Base::begin(), this); }
163 { return const_iterator(_Base::begin(), this); }
167 { return iterator(_Base::end(), this); }
171 { return const_iterator(_Base::end(), this); }
175 { return reverse_iterator(end()); }
177 const_reverse_iterator
179 { return const_reverse_iterator(end()); }
183 { return reverse_iterator(begin()); }
185 const_reverse_iterator
187 { return const_reverse_iterator(begin()); }
192 using _Base::max_size;
195 resize(size_type __n, _CharT __c)
197 _Base::resize(__n, __c);
198 this->_M_invalidate_all();
202 resize(size_type __n)
203 { this->resize(__n, _CharT()); }
205 using _Base::capacity;
206 using _Base::reserve;
212 this->_M_invalidate_all();
217 // 21.3.4 element access:
219 operator[](size_type __pos) 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"));
226 return _M_base()[__pos];
230 operator[](size_type __pos)
232 #ifdef _GLIBCXX_DEBUG_PEDANTIC
233 __glibcxx_check_subscript(__pos);
235 // as an extension v3 allows s[s.size()] when s is non-const.
236 _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(),
237 _M_message(__gnu_debug::__msg_subscript_oob)
238 ._M_sequence(*this, "this")
239 ._M_integer(__pos, "__pos")
240 ._M_integer(this->size(), "size"));
242 return _M_base()[__pos];
249 operator+=(const basic_string& __str)
252 this->_M_invalidate_all();
257 operator+=(const _CharT* __s)
259 __glibcxx_check_string(__s);
261 this->_M_invalidate_all();
266 operator+=(_CharT __c)
269 this->_M_invalidate_all();
273 #ifdef __GXX_EXPERIMENTAL_CXX0X__
275 operator+=(initializer_list<_CharT> __l)
278 this->_M_invalidate_all();
281 #endif // __GXX_EXPERIMENTAL_CXX0X__
284 append(const basic_string& __str)
286 _Base::append(__str);
287 this->_M_invalidate_all();
292 append(const basic_string& __str, size_type __pos, size_type __n)
294 _Base::append(__str, __pos, __n);
295 this->_M_invalidate_all();
300 append(const _CharT* __s, size_type __n)
302 __glibcxx_check_string_len(__s, __n);
303 _Base::append(__s, __n);
304 this->_M_invalidate_all();
309 append(const _CharT* __s)
311 __glibcxx_check_string(__s);
313 this->_M_invalidate_all();
318 append(size_type __n, _CharT __c)
320 _Base::append(__n, __c);
321 this->_M_invalidate_all();
325 template<typename _InputIterator>
327 append(_InputIterator __first, _InputIterator __last)
329 __glibcxx_check_valid_range(__first, __last);
330 _Base::append(__first, __last);
331 this->_M_invalidate_all();
335 // _GLIBCXX_RESOLVE_LIB_DEFECTS
336 // 7. string clause minor problems
338 push_back(_CharT __c)
340 _Base::push_back(__c);
341 this->_M_invalidate_all();
345 assign(const basic_string& __x)
348 this->_M_invalidate_all();
353 assign(const basic_string& __str, size_type __pos, size_type __n)
355 _Base::assign(__str, __pos, __n);
356 this->_M_invalidate_all();
361 assign(const _CharT* __s, size_type __n)
363 __glibcxx_check_string_len(__s, __n);
364 _Base::assign(__s, __n);
365 this->_M_invalidate_all();
370 assign(const _CharT* __s)
372 __glibcxx_check_string(__s);
374 this->_M_invalidate_all();
379 assign(size_type __n, _CharT __c)
381 _Base::assign(__n, __c);
382 this->_M_invalidate_all();
386 template<typename _InputIterator>
388 assign(_InputIterator __first, _InputIterator __last)
390 __glibcxx_check_valid_range(__first, __last);
391 _Base::assign(__first, __last);
392 this->_M_invalidate_all();
396 #ifdef __GXX_EXPERIMENTAL_CXX0X__
398 assign(initializer_list<_CharT> __l)
401 this->_M_invalidate_all();
404 #endif // __GXX_EXPERIMENTAL_CXX0X__
407 insert(size_type __pos1, const basic_string& __str)
409 _Base::insert(__pos1, __str);
410 this->_M_invalidate_all();
415 insert(size_type __pos1, const basic_string& __str,
416 size_type __pos2, size_type __n)
418 _Base::insert(__pos1, __str, __pos2, __n);
419 this->_M_invalidate_all();
424 insert(size_type __pos, const _CharT* __s, size_type __n)
426 __glibcxx_check_string(__s);
427 _Base::insert(__pos, __s, __n);
428 this->_M_invalidate_all();
433 insert(size_type __pos, const _CharT* __s)
435 __glibcxx_check_string(__s);
436 _Base::insert(__pos, __s);
437 this->_M_invalidate_all();
442 insert(size_type __pos, size_type __n, _CharT __c)
444 _Base::insert(__pos, __n, __c);
445 this->_M_invalidate_all();
450 insert(iterator __p, _CharT __c)
452 __glibcxx_check_insert(__p);
453 typename _Base::iterator __res = _Base::insert(__p.base(), __c);
454 this->_M_invalidate_all();
455 return iterator(__res, this);
459 insert(iterator __p, size_type __n, _CharT __c)
461 __glibcxx_check_insert(__p);
462 _Base::insert(__p.base(), __n, __c);
463 this->_M_invalidate_all();
466 template<typename _InputIterator>
468 insert(iterator __p, _InputIterator __first, _InputIterator __last)
470 __glibcxx_check_insert_range(__p, __first, __last);
471 _Base::insert(__p.base(), __first, __last);
472 this->_M_invalidate_all();
475 #ifdef __GXX_EXPERIMENTAL_CXX0X__
477 insert(iterator __p, initializer_list<_CharT> __l)
479 _Base::insert(__p, __l);
480 this->_M_invalidate_all();
482 #endif // __GXX_EXPERIMENTAL_CXX0X__
485 erase(size_type __pos = 0, size_type __n = _Base::npos)
487 _Base::erase(__pos, __n);
488 this->_M_invalidate_all();
493 erase(iterator __position)
495 __glibcxx_check_erase(__position);
496 typename _Base::iterator __res = _Base::erase(__position.base());
497 this->_M_invalidate_all();
498 return iterator(__res, this);
502 erase(iterator __first, iterator __last)
504 // _GLIBCXX_RESOLVE_LIB_DEFECTS
505 // 151. can't currently clear() empty container
506 __glibcxx_check_erase_range(__first, __last);
507 typename _Base::iterator __res = _Base::erase(__first.base(),
509 this->_M_invalidate_all();
510 return iterator(__res, this);
514 replace(size_type __pos1, size_type __n1, const basic_string& __str)
516 _Base::replace(__pos1, __n1, __str);
517 this->_M_invalidate_all();
522 replace(size_type __pos1, size_type __n1, const basic_string& __str,
523 size_type __pos2, size_type __n2)
525 _Base::replace(__pos1, __n1, __str, __pos2, __n2);
526 this->_M_invalidate_all();
531 replace(size_type __pos, size_type __n1, const _CharT* __s,
534 __glibcxx_check_string_len(__s, __n2);
535 _Base::replace(__pos, __n1, __s, __n2);
536 this->_M_invalidate_all();
541 replace(size_type __pos, size_type __n1, const _CharT* __s)
543 __glibcxx_check_string(__s);
544 _Base::replace(__pos, __n1, __s);
545 this->_M_invalidate_all();
550 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
552 _Base::replace(__pos, __n1, __n2, __c);
553 this->_M_invalidate_all();
558 replace(iterator __i1, iterator __i2, const basic_string& __str)
560 __glibcxx_check_erase_range(__i1, __i2);
561 _Base::replace(__i1.base(), __i2.base(), __str);
562 this->_M_invalidate_all();
567 replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
569 __glibcxx_check_erase_range(__i1, __i2);
570 __glibcxx_check_string_len(__s, __n);
571 _Base::replace(__i1.base(), __i2.base(), __s, __n);
572 this->_M_invalidate_all();
577 replace(iterator __i1, iterator __i2, const _CharT* __s)
579 __glibcxx_check_erase_range(__i1, __i2);
580 __glibcxx_check_string(__s);
581 _Base::replace(__i1.base(), __i2.base(), __s);
582 this->_M_invalidate_all();
587 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
589 __glibcxx_check_erase_range(__i1, __i2);
590 _Base::replace(__i1.base(), __i2.base(), __n, __c);
591 this->_M_invalidate_all();
595 template<typename _InputIterator>
597 replace(iterator __i1, iterator __i2,
598 _InputIterator __j1, _InputIterator __j2)
600 __glibcxx_check_erase_range(__i1, __i2);
601 __glibcxx_check_valid_range(__j1, __j2);
602 _Base::replace(__i1.base(), __i2.base(), __j1, __j2);
603 this->_M_invalidate_all();
607 #ifdef __GXX_EXPERIMENTAL_CXX0X__
608 basic_string& replace(iterator __i1, iterator __i2,
609 initializer_list<_CharT> __l)
611 __glibcxx_check_erase_range(__i1, __i2);
612 _Base::replace(__i1.base(), __i2.base(), __l);
613 this->_M_invalidate_all();
616 #endif // __GXX_EXPERIMENTAL_CXX0X__
619 copy(_CharT* __s, size_type __n, size_type __pos = 0) const
621 __glibcxx_check_string_len(__s, __n);
622 return _Base::copy(__s, __n, __pos);
626 swap(basic_string<_CharT,_Traits,_Allocator>& __x)
630 this->_M_invalidate_all();
631 __x._M_invalidate_all();
634 // 21.3.6 string operations:
638 const _CharT* __res = _Base::c_str();
639 this->_M_invalidate_all();
646 const _CharT* __res = _Base::data();
647 this->_M_invalidate_all();
651 using _Base::get_allocator;
654 find(const basic_string& __str, size_type __pos = 0) const
655 { return _Base::find(__str, __pos); }
658 find(const _CharT* __s, size_type __pos, size_type __n) const
660 __glibcxx_check_string(__s);
661 return _Base::find(__s, __pos, __n);
665 find(const _CharT* __s, size_type __pos = 0) const
667 __glibcxx_check_string(__s);
668 return _Base::find(__s, __pos);
672 find(_CharT __c, size_type __pos = 0) const
673 { return _Base::find(__c, __pos); }
676 rfind(const basic_string& __str, size_type __pos = _Base::npos) const
677 { return _Base::rfind(__str, __pos); }
680 rfind(const _CharT* __s, size_type __pos, size_type __n) const
682 __glibcxx_check_string_len(__s, __n);
683 return _Base::rfind(__s, __pos, __n);
687 rfind(const _CharT* __s, size_type __pos = _Base::npos) const
689 __glibcxx_check_string(__s);
690 return _Base::rfind(__s, __pos);
694 rfind(_CharT __c, size_type __pos = _Base::npos) const
695 { return _Base::rfind(__c, __pos); }
698 find_first_of(const basic_string& __str, size_type __pos = 0) const
699 { return _Base::find_first_of(__str, __pos); }
702 find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
704 __glibcxx_check_string(__s);
705 return _Base::find_first_of(__s, __pos, __n);
709 find_first_of(const _CharT* __s, size_type __pos = 0) const
711 __glibcxx_check_string(__s);
712 return _Base::find_first_of(__s, __pos);
716 find_first_of(_CharT __c, size_type __pos = 0) const
717 { return _Base::find_first_of(__c, __pos); }
720 find_last_of(const basic_string& __str,
721 size_type __pos = _Base::npos) const
722 { return _Base::find_last_of(__str, __pos); }
725 find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
727 __glibcxx_check_string(__s);
728 return _Base::find_last_of(__s, __pos, __n);
732 find_last_of(const _CharT* __s, size_type __pos = _Base::npos) const
734 __glibcxx_check_string(__s);
735 return _Base::find_last_of(__s, __pos);
739 find_last_of(_CharT __c, size_type __pos = _Base::npos) const
740 { return _Base::find_last_of(__c, __pos); }
743 find_first_not_of(const basic_string& __str, size_type __pos = 0) const
744 { return _Base::find_first_not_of(__str, __pos); }
747 find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
749 __glibcxx_check_string_len(__s, __n);
750 return _Base::find_first_not_of(__s, __pos, __n);
754 find_first_not_of(const _CharT* __s, size_type __pos = 0) const
756 __glibcxx_check_string(__s);
757 return _Base::find_first_not_of(__s, __pos);
761 find_first_not_of(_CharT __c, size_type __pos = 0) const
762 { return _Base::find_first_not_of(__c, __pos); }
765 find_last_not_of(const basic_string& __str,
766 size_type __pos = _Base::npos) const
767 { return _Base::find_last_not_of(__str, __pos); }
770 find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
772 __glibcxx_check_string(__s);
773 return _Base::find_last_not_of(__s, __pos, __n);
777 find_last_not_of(const _CharT* __s, size_type __pos = _Base::npos) const
779 __glibcxx_check_string(__s);
780 return _Base::find_last_not_of(__s, __pos);
784 find_last_not_of(_CharT __c, size_type __pos = _Base::npos) const
785 { return _Base::find_last_not_of(__c, __pos); }
788 substr(size_type __pos = 0, size_type __n = _Base::npos) const
789 { return basic_string(_Base::substr(__pos, __n)); }
792 compare(const basic_string& __str) const
793 { return _Base::compare(__str); }
796 compare(size_type __pos1, size_type __n1,
797 const basic_string& __str) const
798 { return _Base::compare(__pos1, __n1, __str); }
801 compare(size_type __pos1, size_type __n1, const basic_string& __str,
802 size_type __pos2, size_type __n2) const
803 { return _Base::compare(__pos1, __n1, __str, __pos2, __n2); }
806 compare(const _CharT* __s) const
808 __glibcxx_check_string(__s);
809 return _Base::compare(__s);
812 // _GLIBCXX_RESOLVE_LIB_DEFECTS
813 // 5. string::compare specification questionable
815 compare(size_type __pos1, size_type __n1, const _CharT* __s) const
817 __glibcxx_check_string(__s);
818 return _Base::compare(__pos1, __n1, __s);
821 // _GLIBCXX_RESOLVE_LIB_DEFECTS
822 // 5. string::compare specification questionable
824 compare(size_type __pos1, size_type __n1,const _CharT* __s,
825 size_type __n2) const
827 __glibcxx_check_string_len(__s, __n2);
828 return _Base::compare(__pos1, __n1, __s, __n2);
832 _M_base() { return *this; }
835 _M_base() const { return *this; }
837 using _Safe_base::_M_invalidate_all;
840 template<typename _CharT, typename _Traits, typename _Allocator>
841 inline basic_string<_CharT,_Traits,_Allocator>
842 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
843 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
844 { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
846 template<typename _CharT, typename _Traits, typename _Allocator>
847 inline basic_string<_CharT,_Traits,_Allocator>
848 operator+(const _CharT* __lhs,
849 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
851 __glibcxx_check_string(__lhs);
852 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
855 template<typename _CharT, typename _Traits, typename _Allocator>
856 inline basic_string<_CharT,_Traits,_Allocator>
857 operator+(_CharT __lhs,
858 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
859 { return basic_string<_CharT,_Traits,_Allocator>(1, __lhs) += __rhs; }
861 template<typename _CharT, typename _Traits, typename _Allocator>
862 inline basic_string<_CharT,_Traits,_Allocator>
863 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
866 __glibcxx_check_string(__rhs);
867 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
870 template<typename _CharT, typename _Traits, typename _Allocator>
871 inline basic_string<_CharT,_Traits,_Allocator>
872 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
874 { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
876 template<typename _CharT, typename _Traits, typename _Allocator>
878 operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
879 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
880 { return __lhs._M_base() == __rhs._M_base(); }
882 template<typename _CharT, typename _Traits, typename _Allocator>
884 operator==(const _CharT* __lhs,
885 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
887 __glibcxx_check_string(__lhs);
888 return __lhs == __rhs._M_base();
891 template<typename _CharT, typename _Traits, typename _Allocator>
893 operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
896 __glibcxx_check_string(__rhs);
897 return __lhs._M_base() == __rhs;
900 template<typename _CharT, typename _Traits, typename _Allocator>
902 operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
903 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
904 { return __lhs._M_base() != __rhs._M_base(); }
906 template<typename _CharT, typename _Traits, typename _Allocator>
908 operator!=(const _CharT* __lhs,
909 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
911 __glibcxx_check_string(__lhs);
912 return __lhs != __rhs._M_base();
915 template<typename _CharT, typename _Traits, typename _Allocator>
917 operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
920 __glibcxx_check_string(__rhs);
921 return __lhs._M_base() != __rhs;
924 template<typename _CharT, typename _Traits, typename _Allocator>
926 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
927 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
928 { return __lhs._M_base() < __rhs._M_base(); }
930 template<typename _CharT, typename _Traits, typename _Allocator>
932 operator<(const _CharT* __lhs,
933 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
935 __glibcxx_check_string(__lhs);
936 return __lhs < __rhs._M_base();
939 template<typename _CharT, typename _Traits, typename _Allocator>
941 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
944 __glibcxx_check_string(__rhs);
945 return __lhs._M_base() < __rhs;
948 template<typename _CharT, typename _Traits, typename _Allocator>
950 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
951 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
952 { return __lhs._M_base() <= __rhs._M_base(); }
954 template<typename _CharT, typename _Traits, typename _Allocator>
956 operator<=(const _CharT* __lhs,
957 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
959 __glibcxx_check_string(__lhs);
960 return __lhs <= __rhs._M_base();
963 template<typename _CharT, typename _Traits, typename _Allocator>
965 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
968 __glibcxx_check_string(__rhs);
969 return __lhs._M_base() <= __rhs;
972 template<typename _CharT, typename _Traits, typename _Allocator>
974 operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
975 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
976 { return __lhs._M_base() >= __rhs._M_base(); }
978 template<typename _CharT, typename _Traits, typename _Allocator>
980 operator>=(const _CharT* __lhs,
981 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
983 __glibcxx_check_string(__lhs);
984 return __lhs >= __rhs._M_base();
987 template<typename _CharT, typename _Traits, typename _Allocator>
989 operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
992 __glibcxx_check_string(__rhs);
993 return __lhs._M_base() >= __rhs;
996 template<typename _CharT, typename _Traits, typename _Allocator>
998 operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
999 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1000 { return __lhs._M_base() > __rhs._M_base(); }
1002 template<typename _CharT, typename _Traits, typename _Allocator>
1004 operator>(const _CharT* __lhs,
1005 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1007 __glibcxx_check_string(__lhs);
1008 return __lhs > __rhs._M_base();
1011 template<typename _CharT, typename _Traits, typename _Allocator>
1013 operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1014 const _CharT* __rhs)
1016 __glibcxx_check_string(__rhs);
1017 return __lhs._M_base() > __rhs;
1021 template<typename _CharT, typename _Traits, typename _Allocator>
1023 swap(basic_string<_CharT,_Traits,_Allocator>& __lhs,
1024 basic_string<_CharT,_Traits,_Allocator>& __rhs)
1025 { __lhs.swap(__rhs); }
1027 template<typename _CharT, typename _Traits, typename _Allocator>
1028 std::basic_ostream<_CharT, _Traits>&
1029 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
1030 const basic_string<_CharT, _Traits, _Allocator>& __str)
1031 { return __os << __str._M_base(); }
1033 template<typename _CharT, typename _Traits, typename _Allocator>
1034 std::basic_istream<_CharT,_Traits>&
1035 operator>>(std::basic_istream<_CharT,_Traits>& __is,
1036 basic_string<_CharT,_Traits,_Allocator>& __str)
1038 std::basic_istream<_CharT,_Traits>& __res = __is >> __str._M_base();
1039 __str._M_invalidate_all();
1043 template<typename _CharT, typename _Traits, typename _Allocator>
1044 std::basic_istream<_CharT,_Traits>&
1045 getline(std::basic_istream<_CharT,_Traits>& __is,
1046 basic_string<_CharT,_Traits,_Allocator>& __str, _CharT __delim)
1048 std::basic_istream<_CharT,_Traits>& __res = getline(__is,
1051 __str._M_invalidate_all();
1055 template<typename _CharT, typename _Traits, typename _Allocator>
1056 std::basic_istream<_CharT,_Traits>&
1057 getline(std::basic_istream<_CharT,_Traits>& __is,
1058 basic_string<_CharT,_Traits,_Allocator>& __str)
1060 std::basic_istream<_CharT,_Traits>& __res = getline(__is,
1062 __str._M_invalidate_all();
1066 typedef basic_string<char> string;
1068 #ifdef _GLIBCXX_USE_WCHAR_T
1069 typedef basic_string<wchar_t> wstring;
1072 } // namespace __gnu_debug