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::__check_valid_range(__begin, __end), __end, __a)
114 #ifdef __GXX_EXPERIMENTAL_CXX0X__
115 basic_string(basic_string&& __str)
116 : _Base(std::forward<_Base>(__str))
119 basic_string(std::initializer_list<_CharT> __l,
120 const _Allocator& __a = _Allocator())
123 #endif // __GXX_EXPERIMENTAL_CXX0X__
128 operator=(const basic_string& __str)
130 *static_cast<_Base*>(this) = __str;
131 this->_M_invalidate_all();
136 operator=(const _CharT* __s)
138 __glibcxx_check_string(__s);
139 *static_cast<_Base*>(this) = __s;
140 this->_M_invalidate_all();
145 operator=(_CharT __c)
147 *static_cast<_Base*>(this) = __c;
148 this->_M_invalidate_all();
152 #ifdef __GXX_EXPERIMENTAL_CXX0X__
154 operator=(basic_string&& __str)
156 *static_cast<_Base*>(this) = std::forward<_Base>(__str);
157 this->_M_invalidate_all();
162 operator=(std::initializer_list<_CharT> __l)
164 *static_cast<_Base*>(this) = __l;
165 this->_M_invalidate_all();
168 #endif // __GXX_EXPERIMENTAL_CXX0X__
173 { return iterator(_Base::begin(), this); }
177 { return const_iterator(_Base::begin(), this); }
181 { return iterator(_Base::end(), this); }
185 { return const_iterator(_Base::end(), this); }
189 { return reverse_iterator(end()); }
191 const_reverse_iterator
193 { return const_reverse_iterator(end()); }
197 { return reverse_iterator(begin()); }
199 const_reverse_iterator
201 { return const_reverse_iterator(begin()); }
206 using _Base::max_size;
209 resize(size_type __n, _CharT __c)
211 _Base::resize(__n, __c);
212 this->_M_invalidate_all();
216 resize(size_type __n)
217 { this->resize(__n, _CharT()); }
219 #ifdef __GXX_EXPERIMENTAL_CXX0X__
220 using _Base::shrink_to_fit;
223 using _Base::capacity;
224 using _Base::reserve;
230 this->_M_invalidate_all();
235 // 21.3.4 element access:
237 operator[](size_type __pos) const
239 _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(),
240 _M_message(__gnu_debug::__msg_subscript_oob)
241 ._M_sequence(*this, "this")
242 ._M_integer(__pos, "__pos")
243 ._M_integer(this->size(), "size"));
244 return _M_base()[__pos];
248 operator[](size_type __pos)
250 #ifdef _GLIBCXX_DEBUG_PEDANTIC
251 __glibcxx_check_subscript(__pos);
253 // as an extension v3 allows s[s.size()] when s is non-const.
254 _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(),
255 _M_message(__gnu_debug::__msg_subscript_oob)
256 ._M_sequence(*this, "this")
257 ._M_integer(__pos, "__pos")
258 ._M_integer(this->size(), "size"));
260 return _M_base()[__pos];
267 operator+=(const basic_string& __str)
270 this->_M_invalidate_all();
275 operator+=(const _CharT* __s)
277 __glibcxx_check_string(__s);
279 this->_M_invalidate_all();
284 operator+=(_CharT __c)
287 this->_M_invalidate_all();
291 #ifdef __GXX_EXPERIMENTAL_CXX0X__
293 operator+=(std::initializer_list<_CharT> __l)
296 this->_M_invalidate_all();
299 #endif // __GXX_EXPERIMENTAL_CXX0X__
302 append(const basic_string& __str)
304 _Base::append(__str);
305 this->_M_invalidate_all();
310 append(const basic_string& __str, size_type __pos, size_type __n)
312 _Base::append(__str, __pos, __n);
313 this->_M_invalidate_all();
318 append(const _CharT* __s, size_type __n)
320 __glibcxx_check_string_len(__s, __n);
321 _Base::append(__s, __n);
322 this->_M_invalidate_all();
327 append(const _CharT* __s)
329 __glibcxx_check_string(__s);
331 this->_M_invalidate_all();
336 append(size_type __n, _CharT __c)
338 _Base::append(__n, __c);
339 this->_M_invalidate_all();
343 template<typename _InputIterator>
345 append(_InputIterator __first, _InputIterator __last)
347 __glibcxx_check_valid_range(__first, __last);
348 _Base::append(__first, __last);
349 this->_M_invalidate_all();
353 // _GLIBCXX_RESOLVE_LIB_DEFECTS
354 // 7. string clause minor problems
356 push_back(_CharT __c)
358 _Base::push_back(__c);
359 this->_M_invalidate_all();
363 assign(const basic_string& __x)
366 this->_M_invalidate_all();
370 #ifdef __GXX_EXPERIMENTAL_CXX0X__
372 assign(basic_string&& __x)
374 _Base::assign(std::forward<_Base>(__x));
375 this->_M_invalidate_all();
378 #endif // __GXX_EXPERIMENTAL_CXX0X__
381 assign(const basic_string& __str, size_type __pos, size_type __n)
383 _Base::assign(__str, __pos, __n);
384 this->_M_invalidate_all();
389 assign(const _CharT* __s, size_type __n)
391 __glibcxx_check_string_len(__s, __n);
392 _Base::assign(__s, __n);
393 this->_M_invalidate_all();
398 assign(const _CharT* __s)
400 __glibcxx_check_string(__s);
402 this->_M_invalidate_all();
407 assign(size_type __n, _CharT __c)
409 _Base::assign(__n, __c);
410 this->_M_invalidate_all();
414 template<typename _InputIterator>
416 assign(_InputIterator __first, _InputIterator __last)
418 __glibcxx_check_valid_range(__first, __last);
419 _Base::assign(__first, __last);
420 this->_M_invalidate_all();
424 #ifdef __GXX_EXPERIMENTAL_CXX0X__
426 assign(std::initializer_list<_CharT> __l)
429 this->_M_invalidate_all();
432 #endif // __GXX_EXPERIMENTAL_CXX0X__
435 insert(size_type __pos1, const basic_string& __str)
437 _Base::insert(__pos1, __str);
438 this->_M_invalidate_all();
443 insert(size_type __pos1, const basic_string& __str,
444 size_type __pos2, size_type __n)
446 _Base::insert(__pos1, __str, __pos2, __n);
447 this->_M_invalidate_all();
452 insert(size_type __pos, const _CharT* __s, size_type __n)
454 __glibcxx_check_string(__s);
455 _Base::insert(__pos, __s, __n);
456 this->_M_invalidate_all();
461 insert(size_type __pos, const _CharT* __s)
463 __glibcxx_check_string(__s);
464 _Base::insert(__pos, __s);
465 this->_M_invalidate_all();
470 insert(size_type __pos, size_type __n, _CharT __c)
472 _Base::insert(__pos, __n, __c);
473 this->_M_invalidate_all();
478 insert(iterator __p, _CharT __c)
480 __glibcxx_check_insert(__p);
481 typename _Base::iterator __res = _Base::insert(__p.base(), __c);
482 this->_M_invalidate_all();
483 return iterator(__res, this);
487 insert(iterator __p, size_type __n, _CharT __c)
489 __glibcxx_check_insert(__p);
490 _Base::insert(__p.base(), __n, __c);
491 this->_M_invalidate_all();
494 template<typename _InputIterator>
496 insert(iterator __p, _InputIterator __first, _InputIterator __last)
498 __glibcxx_check_insert_range(__p, __first, __last);
499 _Base::insert(__p.base(), __first, __last);
500 this->_M_invalidate_all();
503 #ifdef __GXX_EXPERIMENTAL_CXX0X__
505 insert(iterator __p, std::initializer_list<_CharT> __l)
507 _Base::insert(__p, __l);
508 this->_M_invalidate_all();
510 #endif // __GXX_EXPERIMENTAL_CXX0X__
513 erase(size_type __pos = 0, size_type __n = _Base::npos)
515 _Base::erase(__pos, __n);
516 this->_M_invalidate_all();
521 erase(iterator __position)
523 __glibcxx_check_erase(__position);
524 typename _Base::iterator __res = _Base::erase(__position.base());
525 this->_M_invalidate_all();
526 return iterator(__res, this);
530 erase(iterator __first, iterator __last)
532 // _GLIBCXX_RESOLVE_LIB_DEFECTS
533 // 151. can't currently clear() empty container
534 __glibcxx_check_erase_range(__first, __last);
535 typename _Base::iterator __res = _Base::erase(__first.base(),
537 this->_M_invalidate_all();
538 return iterator(__res, this);
542 replace(size_type __pos1, size_type __n1, const basic_string& __str)
544 _Base::replace(__pos1, __n1, __str);
545 this->_M_invalidate_all();
550 replace(size_type __pos1, size_type __n1, const basic_string& __str,
551 size_type __pos2, size_type __n2)
553 _Base::replace(__pos1, __n1, __str, __pos2, __n2);
554 this->_M_invalidate_all();
559 replace(size_type __pos, size_type __n1, const _CharT* __s,
562 __glibcxx_check_string_len(__s, __n2);
563 _Base::replace(__pos, __n1, __s, __n2);
564 this->_M_invalidate_all();
569 replace(size_type __pos, size_type __n1, const _CharT* __s)
571 __glibcxx_check_string(__s);
572 _Base::replace(__pos, __n1, __s);
573 this->_M_invalidate_all();
578 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
580 _Base::replace(__pos, __n1, __n2, __c);
581 this->_M_invalidate_all();
586 replace(iterator __i1, iterator __i2, const basic_string& __str)
588 __glibcxx_check_erase_range(__i1, __i2);
589 _Base::replace(__i1.base(), __i2.base(), __str);
590 this->_M_invalidate_all();
595 replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
597 __glibcxx_check_erase_range(__i1, __i2);
598 __glibcxx_check_string_len(__s, __n);
599 _Base::replace(__i1.base(), __i2.base(), __s, __n);
600 this->_M_invalidate_all();
605 replace(iterator __i1, iterator __i2, const _CharT* __s)
607 __glibcxx_check_erase_range(__i1, __i2);
608 __glibcxx_check_string(__s);
609 _Base::replace(__i1.base(), __i2.base(), __s);
610 this->_M_invalidate_all();
615 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
617 __glibcxx_check_erase_range(__i1, __i2);
618 _Base::replace(__i1.base(), __i2.base(), __n, __c);
619 this->_M_invalidate_all();
623 template<typename _InputIterator>
625 replace(iterator __i1, iterator __i2,
626 _InputIterator __j1, _InputIterator __j2)
628 __glibcxx_check_erase_range(__i1, __i2);
629 __glibcxx_check_valid_range(__j1, __j2);
630 _Base::replace(__i1.base(), __i2.base(), __j1, __j2);
631 this->_M_invalidate_all();
635 #ifdef __GXX_EXPERIMENTAL_CXX0X__
636 basic_string& replace(iterator __i1, iterator __i2,
637 std::initializer_list<_CharT> __l)
639 __glibcxx_check_erase_range(__i1, __i2);
640 _Base::replace(__i1.base(), __i2.base(), __l);
641 this->_M_invalidate_all();
644 #endif // __GXX_EXPERIMENTAL_CXX0X__
647 copy(_CharT* __s, size_type __n, size_type __pos = 0) const
649 __glibcxx_check_string_len(__s, __n);
650 return _Base::copy(__s, __n, __pos);
654 swap(basic_string<_CharT,_Traits,_Allocator>& __x)
658 this->_M_invalidate_all();
659 __x._M_invalidate_all();
662 // 21.3.6 string operations:
666 const _CharT* __res = _Base::c_str();
667 this->_M_invalidate_all();
674 const _CharT* __res = _Base::data();
675 this->_M_invalidate_all();
679 using _Base::get_allocator;
682 find(const basic_string& __str, size_type __pos = 0) const
683 { return _Base::find(__str, __pos); }
686 find(const _CharT* __s, size_type __pos, size_type __n) const
688 __glibcxx_check_string(__s);
689 return _Base::find(__s, __pos, __n);
693 find(const _CharT* __s, size_type __pos = 0) const
695 __glibcxx_check_string(__s);
696 return _Base::find(__s, __pos);
700 find(_CharT __c, size_type __pos = 0) const
701 { return _Base::find(__c, __pos); }
704 rfind(const basic_string& __str, size_type __pos = _Base::npos) const
705 { return _Base::rfind(__str, __pos); }
708 rfind(const _CharT* __s, size_type __pos, size_type __n) const
710 __glibcxx_check_string_len(__s, __n);
711 return _Base::rfind(__s, __pos, __n);
715 rfind(const _CharT* __s, size_type __pos = _Base::npos) const
717 __glibcxx_check_string(__s);
718 return _Base::rfind(__s, __pos);
722 rfind(_CharT __c, size_type __pos = _Base::npos) const
723 { return _Base::rfind(__c, __pos); }
726 find_first_of(const basic_string& __str, size_type __pos = 0) const
727 { return _Base::find_first_of(__str, __pos); }
730 find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
732 __glibcxx_check_string(__s);
733 return _Base::find_first_of(__s, __pos, __n);
737 find_first_of(const _CharT* __s, size_type __pos = 0) const
739 __glibcxx_check_string(__s);
740 return _Base::find_first_of(__s, __pos);
744 find_first_of(_CharT __c, size_type __pos = 0) const
745 { return _Base::find_first_of(__c, __pos); }
748 find_last_of(const basic_string& __str,
749 size_type __pos = _Base::npos) const
750 { return _Base::find_last_of(__str, __pos); }
753 find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
755 __glibcxx_check_string(__s);
756 return _Base::find_last_of(__s, __pos, __n);
760 find_last_of(const _CharT* __s, size_type __pos = _Base::npos) const
762 __glibcxx_check_string(__s);
763 return _Base::find_last_of(__s, __pos);
767 find_last_of(_CharT __c, size_type __pos = _Base::npos) const
768 { return _Base::find_last_of(__c, __pos); }
771 find_first_not_of(const basic_string& __str, size_type __pos = 0) const
772 { return _Base::find_first_not_of(__str, __pos); }
775 find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
777 __glibcxx_check_string_len(__s, __n);
778 return _Base::find_first_not_of(__s, __pos, __n);
782 find_first_not_of(const _CharT* __s, size_type __pos = 0) const
784 __glibcxx_check_string(__s);
785 return _Base::find_first_not_of(__s, __pos);
789 find_first_not_of(_CharT __c, size_type __pos = 0) const
790 { return _Base::find_first_not_of(__c, __pos); }
793 find_last_not_of(const basic_string& __str,
794 size_type __pos = _Base::npos) const
795 { return _Base::find_last_not_of(__str, __pos); }
798 find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
800 __glibcxx_check_string(__s);
801 return _Base::find_last_not_of(__s, __pos, __n);
805 find_last_not_of(const _CharT* __s, size_type __pos = _Base::npos) const
807 __glibcxx_check_string(__s);
808 return _Base::find_last_not_of(__s, __pos);
812 find_last_not_of(_CharT __c, size_type __pos = _Base::npos) const
813 { return _Base::find_last_not_of(__c, __pos); }
816 substr(size_type __pos = 0, size_type __n = _Base::npos) const
817 { return basic_string(_Base::substr(__pos, __n)); }
820 compare(const basic_string& __str) const
821 { return _Base::compare(__str); }
824 compare(size_type __pos1, size_type __n1,
825 const basic_string& __str) const
826 { return _Base::compare(__pos1, __n1, __str); }
829 compare(size_type __pos1, size_type __n1, const basic_string& __str,
830 size_type __pos2, size_type __n2) const
831 { return _Base::compare(__pos1, __n1, __str, __pos2, __n2); }
834 compare(const _CharT* __s) const
836 __glibcxx_check_string(__s);
837 return _Base::compare(__s);
840 // _GLIBCXX_RESOLVE_LIB_DEFECTS
841 // 5. string::compare specification questionable
843 compare(size_type __pos1, size_type __n1, const _CharT* __s) const
845 __glibcxx_check_string(__s);
846 return _Base::compare(__pos1, __n1, __s);
849 // _GLIBCXX_RESOLVE_LIB_DEFECTS
850 // 5. string::compare specification questionable
852 compare(size_type __pos1, size_type __n1,const _CharT* __s,
853 size_type __n2) const
855 __glibcxx_check_string_len(__s, __n2);
856 return _Base::compare(__pos1, __n1, __s, __n2);
860 _M_base() { return *this; }
863 _M_base() const { return *this; }
865 using _Safe_base::_M_invalidate_all;
868 template<typename _CharT, typename _Traits, typename _Allocator>
869 inline basic_string<_CharT,_Traits,_Allocator>
870 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
871 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
872 { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
874 template<typename _CharT, typename _Traits, typename _Allocator>
875 inline basic_string<_CharT,_Traits,_Allocator>
876 operator+(const _CharT* __lhs,
877 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
879 __glibcxx_check_string(__lhs);
880 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
883 template<typename _CharT, typename _Traits, typename _Allocator>
884 inline basic_string<_CharT,_Traits,_Allocator>
885 operator+(_CharT __lhs,
886 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
887 { return basic_string<_CharT,_Traits,_Allocator>(1, __lhs) += __rhs; }
889 template<typename _CharT, typename _Traits, typename _Allocator>
890 inline basic_string<_CharT,_Traits,_Allocator>
891 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
894 __glibcxx_check_string(__rhs);
895 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
898 template<typename _CharT, typename _Traits, typename _Allocator>
899 inline basic_string<_CharT,_Traits,_Allocator>
900 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
902 { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
904 template<typename _CharT, typename _Traits, typename _Allocator>
906 operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
907 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
908 { return __lhs._M_base() == __rhs._M_base(); }
910 template<typename _CharT, typename _Traits, typename _Allocator>
912 operator==(const _CharT* __lhs,
913 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
915 __glibcxx_check_string(__lhs);
916 return __lhs == __rhs._M_base();
919 template<typename _CharT, typename _Traits, typename _Allocator>
921 operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
924 __glibcxx_check_string(__rhs);
925 return __lhs._M_base() == __rhs;
928 template<typename _CharT, typename _Traits, typename _Allocator>
930 operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
931 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
932 { return __lhs._M_base() != __rhs._M_base(); }
934 template<typename _CharT, typename _Traits, typename _Allocator>
936 operator!=(const _CharT* __lhs,
937 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
939 __glibcxx_check_string(__lhs);
940 return __lhs != __rhs._M_base();
943 template<typename _CharT, typename _Traits, typename _Allocator>
945 operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
948 __glibcxx_check_string(__rhs);
949 return __lhs._M_base() != __rhs;
952 template<typename _CharT, typename _Traits, typename _Allocator>
954 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
955 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
956 { return __lhs._M_base() < __rhs._M_base(); }
958 template<typename _CharT, typename _Traits, typename _Allocator>
960 operator<(const _CharT* __lhs,
961 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
963 __glibcxx_check_string(__lhs);
964 return __lhs < __rhs._M_base();
967 template<typename _CharT, typename _Traits, typename _Allocator>
969 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
972 __glibcxx_check_string(__rhs);
973 return __lhs._M_base() < __rhs;
976 template<typename _CharT, typename _Traits, typename _Allocator>
978 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
979 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
980 { return __lhs._M_base() <= __rhs._M_base(); }
982 template<typename _CharT, typename _Traits, typename _Allocator>
984 operator<=(const _CharT* __lhs,
985 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
987 __glibcxx_check_string(__lhs);
988 return __lhs <= __rhs._M_base();
991 template<typename _CharT, typename _Traits, typename _Allocator>
993 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
996 __glibcxx_check_string(__rhs);
997 return __lhs._M_base() <= __rhs;
1000 template<typename _CharT, typename _Traits, typename _Allocator>
1002 operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1003 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1004 { return __lhs._M_base() >= __rhs._M_base(); }
1006 template<typename _CharT, typename _Traits, typename _Allocator>
1008 operator>=(const _CharT* __lhs,
1009 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1011 __glibcxx_check_string(__lhs);
1012 return __lhs >= __rhs._M_base();
1015 template<typename _CharT, typename _Traits, typename _Allocator>
1017 operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1018 const _CharT* __rhs)
1020 __glibcxx_check_string(__rhs);
1021 return __lhs._M_base() >= __rhs;
1024 template<typename _CharT, typename _Traits, typename _Allocator>
1026 operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1027 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1028 { return __lhs._M_base() > __rhs._M_base(); }
1030 template<typename _CharT, typename _Traits, typename _Allocator>
1032 operator>(const _CharT* __lhs,
1033 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
1035 __glibcxx_check_string(__lhs);
1036 return __lhs > __rhs._M_base();
1039 template<typename _CharT, typename _Traits, typename _Allocator>
1041 operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
1042 const _CharT* __rhs)
1044 __glibcxx_check_string(__rhs);
1045 return __lhs._M_base() > __rhs;
1049 template<typename _CharT, typename _Traits, typename _Allocator>
1051 swap(basic_string<_CharT,_Traits,_Allocator>& __lhs,
1052 basic_string<_CharT,_Traits,_Allocator>& __rhs)
1053 { __lhs.swap(__rhs); }
1055 template<typename _CharT, typename _Traits, typename _Allocator>
1056 std::basic_ostream<_CharT, _Traits>&
1057 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
1058 const basic_string<_CharT, _Traits, _Allocator>& __str)
1059 { return __os << __str._M_base(); }
1061 template<typename _CharT, typename _Traits, typename _Allocator>
1062 std::basic_istream<_CharT,_Traits>&
1063 operator>>(std::basic_istream<_CharT,_Traits>& __is,
1064 basic_string<_CharT,_Traits,_Allocator>& __str)
1066 std::basic_istream<_CharT,_Traits>& __res = __is >> __str._M_base();
1067 __str._M_invalidate_all();
1071 template<typename _CharT, typename _Traits, typename _Allocator>
1072 std::basic_istream<_CharT,_Traits>&
1073 getline(std::basic_istream<_CharT,_Traits>& __is,
1074 basic_string<_CharT,_Traits,_Allocator>& __str, _CharT __delim)
1076 std::basic_istream<_CharT,_Traits>& __res = getline(__is,
1079 __str._M_invalidate_all();
1083 template<typename _CharT, typename _Traits, typename _Allocator>
1084 std::basic_istream<_CharT,_Traits>&
1085 getline(std::basic_istream<_CharT,_Traits>& __is,
1086 basic_string<_CharT,_Traits,_Allocator>& __str)
1088 std::basic_istream<_CharT,_Traits>& __res = getline(__is,
1090 __str._M_invalidate_all();
1094 typedef basic_string<char> string;
1096 #ifdef _GLIBCXX_USE_WCHAR_T
1097 typedef basic_string<wchar_t> wstring;
1100 } // namespace __gnu_debug