00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef _GLIBCXX_DEBUG_STRING
00032 #define _GLIBCXX_DEBUG_STRING 1
00033
00034 #include <string>
00035 #include <debug/safe_sequence.h>
00036 #include <debug/safe_iterator.h>
00037
00038 namespace __gnu_debug
00039 {
00040 template<typename _CharT, typename _Traits = std::char_traits<_CharT>,
00041 typename _Allocator = std::allocator<_CharT> >
00042 class basic_string
00043 : public std::basic_string<_CharT, _Traits, _Allocator>,
00044 public __gnu_debug::_Safe_sequence<basic_string<_CharT, _Traits,
00045 _Allocator> >
00046 {
00047 typedef std::basic_string<_CharT, _Traits, _Allocator> _Base;
00048 typedef __gnu_debug::_Safe_sequence<basic_string> _Safe_base;
00049
00050 public:
00051
00052 typedef _Traits traits_type;
00053 typedef typename _Traits::char_type value_type;
00054 typedef _Allocator allocator_type;
00055 typedef typename _Base::size_type size_type;
00056 typedef typename _Base::difference_type difference_type;
00057 typedef typename _Base::reference reference;
00058 typedef typename _Base::const_reference const_reference;
00059 typedef typename _Base::pointer pointer;
00060 typedef typename _Base::const_pointer const_pointer;
00061
00062 typedef __gnu_debug::_Safe_iterator<typename _Base::iterator, basic_string>
00063 iterator;
00064 typedef __gnu_debug::_Safe_iterator<typename _Base::const_iterator,
00065 basic_string> const_iterator;
00066
00067 typedef std::reverse_iterator<iterator> reverse_iterator;
00068 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
00069
00070 using _Base::npos;
00071
00072
00073 explicit basic_string(const _Allocator& __a = _Allocator())
00074 : _Base(__a)
00075 { }
00076
00077
00078 basic_string(const _Base& __base) : _Base(__base), _Safe_base() { }
00079
00080
00081
00082 basic_string(const basic_string& __str)
00083 : _Base(__str, 0, _Base::npos, __str.get_allocator()), _Safe_base()
00084 { }
00085
00086
00087
00088 basic_string(const basic_string& __str, size_type __pos,
00089 size_type __n = _Base::npos,
00090 const _Allocator& __a = _Allocator())
00091 : _Base(__str, __pos, __n, __a)
00092 { }
00093
00094 basic_string(const _CharT* __s, size_type __n,
00095 const _Allocator& __a = _Allocator())
00096 : _Base(__gnu_debug::__check_string(__s, __n), __n, __a)
00097 { }
00098
00099 basic_string(const _CharT* __s, const _Allocator& __a = _Allocator())
00100 : _Base(__gnu_debug::__check_string(__s), __a)
00101 { this->assign(__s); }
00102
00103 basic_string(size_type __n, _CharT __c,
00104 const _Allocator& __a = _Allocator())
00105 : _Base(__n, __c, __a)
00106 { }
00107
00108 template<typename _InputIterator>
00109 basic_string(_InputIterator __begin, _InputIterator __end,
00110 const _Allocator& __a = _Allocator())
00111 : _Base(__gnu_debug::__check_valid_range(__begin, __end), __end, __a)
00112 { }
00113
00114 ~basic_string() { }
00115
00116 basic_string&
00117 operator=(const basic_string& __str)
00118 {
00119 *static_cast<_Base*>(this) = __str;
00120 this->_M_invalidate_all();
00121 return *this;
00122 }
00123
00124 basic_string&
00125 operator=(const _CharT* __s)
00126 {
00127 __glibcxx_check_string(__s);
00128 *static_cast<_Base*>(this) = __s;
00129 this->_M_invalidate_all();
00130 return *this;
00131 }
00132
00133 basic_string&
00134 operator=(_CharT __c)
00135 {
00136 *static_cast<_Base*>(this) = __c;
00137 this->_M_invalidate_all();
00138 return *this;
00139 }
00140
00141
00142 iterator
00143 begin()
00144 { return iterator(_Base::begin(), this); }
00145
00146 const_iterator
00147 begin() const
00148 { return const_iterator(_Base::begin(), this); }
00149
00150 iterator
00151 end()
00152 { return iterator(_Base::end(), this); }
00153
00154 const_iterator
00155 end() const
00156 { return const_iterator(_Base::end(), this); }
00157
00158 reverse_iterator
00159 rbegin()
00160 { return reverse_iterator(end()); }
00161
00162 const_reverse_iterator
00163 rbegin() const
00164 { return const_reverse_iterator(end()); }
00165
00166 reverse_iterator
00167 rend()
00168 { return reverse_iterator(begin()); }
00169
00170 const_reverse_iterator
00171 rend() const
00172 { return const_reverse_iterator(begin()); }
00173
00174
00175 using _Base::size;
00176 using _Base::length;
00177 using _Base::max_size;
00178
00179 void
00180 resize(size_type __n, _CharT __c)
00181 {
00182 _Base::resize(__n, __c);
00183 this->_M_invalidate_all();
00184 }
00185
00186 void
00187 resize(size_type __n)
00188 { this->resize(__n, _CharT()); }
00189
00190 using _Base::capacity;
00191 using _Base::reserve;
00192
00193 void
00194 clear()
00195 {
00196 _Base::clear();
00197 this->_M_invalidate_all();
00198 }
00199
00200 using _Base::empty;
00201
00202
00203 const_reference
00204 operator[](size_type __pos) const
00205 {
00206 _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(),
00207 _M_message(::__gnu_debug::__msg_subscript_oob)
00208 ._M_sequence(*this, "this")
00209 ._M_integer(__pos, "__pos")
00210 ._M_integer(this->size(), "size"));
00211 return _M_base()[__pos];
00212 }
00213
00214 reference
00215 operator[](size_type __pos)
00216 {
00217 #ifdef _GLIBCXX_DEBUG_PEDANTIC
00218 __glibcxx_check_subscript(__pos);
00219 #else
00220
00221 _GLIBCXX_DEBUG_VERIFY(__pos <= this->size(),
00222 _M_message(::__gnu_debug::__msg_subscript_oob)
00223 ._M_sequence(*this, "this")
00224 ._M_integer(__pos, "__pos")
00225 ._M_integer(this->size(), "size"));
00226 #endif
00227 return _M_base()[__pos];
00228 }
00229
00230 using _Base::at;
00231
00232
00233 basic_string&
00234 operator+=(const basic_string& __str)
00235 {
00236 _M_base() += __str;
00237 this->_M_invalidate_all();
00238 return *this;
00239 }
00240
00241 basic_string&
00242 operator+=(const _CharT* __s)
00243 {
00244 __glibcxx_check_string(__s);
00245 _M_base() += __s;
00246 this->_M_invalidate_all();
00247 return *this;
00248 }
00249
00250 basic_string&
00251 operator+=(_CharT __c)
00252 {
00253 _M_base() += __c;
00254 this->_M_invalidate_all();
00255 return *this;
00256 }
00257
00258 basic_string&
00259 append(const basic_string& __str)
00260 {
00261 _Base::append(__str);
00262 this->_M_invalidate_all();
00263 return *this;
00264 }
00265
00266 basic_string&
00267 append(const basic_string& __str, size_type __pos, size_type __n)
00268 {
00269 _Base::append(__str, __pos, __n);
00270 this->_M_invalidate_all();
00271 return *this;
00272 }
00273
00274 basic_string&
00275 append(const _CharT* __s, size_type __n)
00276 {
00277 __glibcxx_check_string_len(__s, __n);
00278 _Base::append(__s, __n);
00279 this->_M_invalidate_all();
00280 return *this;
00281 }
00282
00283 basic_string&
00284 append(const _CharT* __s)
00285 {
00286 __glibcxx_check_string(__s);
00287 _Base::append(__s);
00288 this->_M_invalidate_all();
00289 return *this;
00290 }
00291
00292 basic_string&
00293 append(size_type __n, _CharT __c)
00294 {
00295 _Base::append(__n, __c);
00296 this->_M_invalidate_all();
00297 return *this;
00298 }
00299
00300 template<typename _InputIterator>
00301 basic_string&
00302 append(_InputIterator __first, _InputIterator __last)
00303 {
00304 __glibcxx_check_valid_range(__first, __last);
00305 _Base::append(__first, __last);
00306 this->_M_invalidate_all();
00307 return *this;
00308 }
00309
00310
00311
00312 void
00313 push_back(_CharT __c)
00314 {
00315 _Base::push_back(__c);
00316 this->_M_invalidate_all();
00317 }
00318
00319 basic_string&
00320 assign(const basic_string& __x)
00321 {
00322 _Base::assign(__x);
00323 this->_M_invalidate_all();
00324 return *this;
00325 }
00326
00327 basic_string&
00328 assign(const basic_string& __str, size_type __pos, size_type __n)
00329 {
00330 _Base::assign(__str, __pos, __n);
00331 this->_M_invalidate_all();
00332 return *this;
00333 }
00334
00335 basic_string&
00336 assign(const _CharT* __s, size_type __n)
00337 {
00338 __glibcxx_check_string_len(__s, __n);
00339 _Base::assign(__s, __n);
00340 this->_M_invalidate_all();
00341 return *this;
00342 }
00343
00344 basic_string&
00345 assign(const _CharT* __s)
00346 {
00347 __glibcxx_check_string(__s);
00348 _Base::assign(__s);
00349 this->_M_invalidate_all();
00350 return *this;
00351 }
00352
00353 basic_string&
00354 assign(size_type __n, _CharT __c)
00355 {
00356 _Base::assign(__n, __c);
00357 this->_M_invalidate_all();
00358 return *this;
00359 }
00360
00361 template<typename _InputIterator>
00362 basic_string&
00363 assign(_InputIterator __first, _InputIterator __last)
00364 {
00365 __glibcxx_check_valid_range(__first, __last);
00366 _Base::assign(__first, __last);
00367 this->_M_invalidate_all();
00368 return *this;
00369 }
00370
00371 basic_string&
00372 insert(size_type __pos1, const basic_string& __str)
00373 {
00374 _Base::insert(__pos1, __str);
00375 this->_M_invalidate_all();
00376 return *this;
00377 }
00378
00379 basic_string&
00380 insert(size_type __pos1, const basic_string& __str,
00381 size_type __pos2, size_type __n)
00382 {
00383 _Base::insert(__pos1, __str, __pos2, __n);
00384 this->_M_invalidate_all();
00385 return *this;
00386 }
00387
00388 basic_string&
00389 insert(size_type __pos, const _CharT* __s, size_type __n)
00390 {
00391 __glibcxx_check_string(__s);
00392 _Base::insert(__pos, __s, __n);
00393 this->_M_invalidate_all();
00394 return *this;
00395 }
00396
00397 basic_string&
00398 insert(size_type __pos, const _CharT* __s)
00399 {
00400 __glibcxx_check_string(__s);
00401 _Base::insert(__pos, __s);
00402 this->_M_invalidate_all();
00403 return *this;
00404 }
00405
00406 basic_string&
00407 insert(size_type __pos, size_type __n, _CharT __c)
00408 {
00409 _Base::insert(__pos, __n, __c);
00410 this->_M_invalidate_all();
00411 return *this;
00412 }
00413
00414 iterator
00415 insert(iterator __p, _CharT __c)
00416 {
00417 __glibcxx_check_insert(__p);
00418 typename _Base::iterator __res = _Base::insert(__p.base(), __c);
00419 this->_M_invalidate_all();
00420 return iterator(__res, this);
00421 }
00422
00423 void
00424 insert(iterator __p, size_type __n, _CharT __c)
00425 {
00426 __glibcxx_check_insert(__p);
00427 _Base::insert(__p.base(), __n, __c);
00428 this->_M_invalidate_all();
00429 }
00430
00431 template<typename _InputIterator>
00432 void
00433 insert(iterator __p, _InputIterator __first, _InputIterator __last)
00434 {
00435 __glibcxx_check_insert_range(__p, __first, __last);
00436 _Base::insert(__p.base(), __first, __last);
00437 this->_M_invalidate_all();
00438 }
00439
00440 basic_string&
00441 erase(size_type __pos = 0, size_type __n = _Base::npos)
00442 {
00443 _Base::erase(__pos, __n);
00444 this->_M_invalidate_all();
00445 return *this;
00446 }
00447
00448 iterator
00449 erase(iterator __position)
00450 {
00451 __glibcxx_check_erase(__position);
00452 typename _Base::iterator __res = _Base::erase(__position.base());
00453 this->_M_invalidate_all();
00454 return iterator(__res, this);
00455 }
00456
00457 iterator
00458 erase(iterator __first, iterator __last)
00459 {
00460
00461
00462 __glibcxx_check_erase_range(__first, __last);
00463 typename _Base::iterator __res = _Base::erase(__first.base(),
00464 __last.base());
00465 this->_M_invalidate_all();
00466 return iterator(__res, this);
00467 }
00468
00469 basic_string&
00470 replace(size_type __pos1, size_type __n1, const basic_string& __str)
00471 {
00472 _Base::replace(__pos1, __n1, __str);
00473 this->_M_invalidate_all();
00474 return *this;
00475 }
00476
00477 basic_string&
00478 replace(size_type __pos1, size_type __n1, const basic_string& __str,
00479 size_type __pos2, size_type __n2)
00480 {
00481 _Base::replace(__pos1, __n1, __str, __pos2, __n2);
00482 this->_M_invalidate_all();
00483 return *this;
00484 }
00485
00486 basic_string&
00487 replace(size_type __pos, size_type __n1, const _CharT* __s,
00488 size_type __n2)
00489 {
00490 __glibcxx_check_string_len(__s, __n2);
00491 _Base::replace(__pos, __n1, __s, __n2);
00492 this->_M_invalidate_all();
00493 return *this;
00494 }
00495
00496 basic_string&
00497 replace(size_type __pos, size_type __n1, const _CharT* __s)
00498 {
00499 __glibcxx_check_string(__s);
00500 _Base::replace(__pos, __n1, __s);
00501 this->_M_invalidate_all();
00502 return *this;
00503 }
00504
00505 basic_string&
00506 replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
00507 {
00508 _Base::replace(__pos, __n1, __n2, __c);
00509 this->_M_invalidate_all();
00510 return *this;
00511 }
00512
00513 basic_string&
00514 replace(iterator __i1, iterator __i2, const basic_string& __str)
00515 {
00516 __glibcxx_check_erase_range(__i1, __i2);
00517 _Base::replace(__i1.base(), __i2.base(), __str);
00518 this->_M_invalidate_all();
00519 return *this;
00520 }
00521
00522 basic_string&
00523 replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
00524 {
00525 __glibcxx_check_erase_range(__i1, __i2);
00526 __glibcxx_check_string_len(__s, __n);
00527 _Base::replace(__i1.base(), __i2.base(), __s, __n);
00528 this->_M_invalidate_all();
00529 return *this;
00530 }
00531
00532 basic_string&
00533 replace(iterator __i1, iterator __i2, const _CharT* __s)
00534 {
00535 __glibcxx_check_erase_range(__i1, __i2);
00536 __glibcxx_check_string(__s);
00537 _Base::replace(__i1.base(), __i2.base(), __s);
00538 this->_M_invalidate_all();
00539 return *this;
00540 }
00541
00542 basic_string&
00543 replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
00544 {
00545 __glibcxx_check_erase_range(__i1, __i2);
00546 _Base::replace(__i1.base(), __i2.base(), __n, __c);
00547 this->_M_invalidate_all();
00548 return *this;
00549 }
00550
00551 template<typename _InputIterator>
00552 basic_string&
00553 replace(iterator __i1, iterator __i2,
00554 _InputIterator __j1, _InputIterator __j2)
00555 {
00556 __glibcxx_check_erase_range(__i1, __i2);
00557 __glibcxx_check_valid_range(__j1, __j2);
00558 _Base::replace(__i1.base(), __i2.base(), __j1, __j2);
00559 this->_M_invalidate_all();
00560 return *this;
00561 }
00562
00563 size_type
00564 copy(_CharT* __s, size_type __n, size_type __pos = 0) const
00565 {
00566 __glibcxx_check_string_len(__s, __n);
00567 return _Base::copy(__s, __n, __pos);
00568 }
00569
00570 void
00571 swap(basic_string<_CharT,_Traits,_Allocator>& __x)
00572 {
00573 _Base::swap(__x);
00574 this->_M_swap(__x);
00575 this->_M_invalidate_all();
00576 __x._M_invalidate_all();
00577 }
00578
00579
00580 const _CharT*
00581 c_str() const
00582 {
00583 const _CharT* __res = _Base::c_str();
00584 this->_M_invalidate_all();
00585 return __res;
00586 }
00587
00588 const _CharT*
00589 data() const
00590 {
00591 const _CharT* __res = _Base::data();
00592 this->_M_invalidate_all();
00593 return __res;
00594 }
00595
00596 using _Base::get_allocator;
00597
00598 size_type
00599 find(const basic_string& __str, size_type __pos = 0) const
00600 { return _Base::find(__str, __pos); }
00601
00602 size_type
00603 find(const _CharT* __s, size_type __pos, size_type __n) const
00604 {
00605 __glibcxx_check_string(__s);
00606 return _Base::find(__s, __pos, __n);
00607 }
00608
00609 size_type
00610 find(const _CharT* __s, size_type __pos = 0) const
00611 {
00612 __glibcxx_check_string(__s);
00613 return _Base::find(__s, __pos);
00614 }
00615
00616 size_type
00617 find(_CharT __c, size_type __pos = 0) const
00618 { return _Base::find(__c, __pos); }
00619
00620 size_type
00621 rfind(const basic_string& __str, size_type __pos = _Base::npos) const
00622 { return _Base::rfind(__str, __pos); }
00623
00624 size_type
00625 rfind(const _CharT* __s, size_type __pos, size_type __n) const
00626 {
00627 __glibcxx_check_string_len(__s, __n);
00628 return _Base::rfind(__s, __pos, __n);
00629 }
00630
00631 size_type
00632 rfind(const _CharT* __s, size_type __pos = _Base::npos) const
00633 {
00634 __glibcxx_check_string(__s);
00635 return _Base::rfind(__s, __pos);
00636 }
00637
00638 size_type
00639 rfind(_CharT __c, size_type __pos = _Base::npos) const
00640 { return _Base::rfind(__c, __pos); }
00641
00642 size_type
00643 find_first_of(const basic_string& __str, size_type __pos = 0) const
00644 { return _Base::find_first_of(__str, __pos); }
00645
00646 size_type
00647 find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
00648 {
00649 __glibcxx_check_string(__s);
00650 return _Base::find_first_of(__s, __pos, __n);
00651 }
00652
00653 size_type
00654 find_first_of(const _CharT* __s, size_type __pos = 0) const
00655 {
00656 __glibcxx_check_string(__s);
00657 return _Base::find_first_of(__s, __pos);
00658 }
00659
00660 size_type
00661 find_first_of(_CharT __c, size_type __pos = 0) const
00662 { return _Base::find_first_of(__c, __pos); }
00663
00664 size_type
00665 find_last_of(const basic_string& __str, size_type __pos = _Base::npos) const
00666 { return _Base::find_last_of(__str, __pos); }
00667
00668 size_type
00669 find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
00670 {
00671 __glibcxx_check_string(__s);
00672 return _Base::find_last_of(__s, __pos, __n);
00673 }
00674
00675 size_type
00676 find_last_of(const _CharT* __s, size_type __pos = _Base::npos) const
00677 {
00678 __glibcxx_check_string(__s);
00679 return _Base::find_last_of(__s, __pos);
00680 }
00681
00682 size_type
00683 find_last_of(_CharT __c, size_type __pos = _Base::npos) const
00684 { return _Base::find_last_of(__c, __pos); }
00685
00686 size_type
00687 find_first_not_of(const basic_string& __str, size_type __pos = 0) const
00688 { return _Base::find_first_not_of(__str, __pos); }
00689
00690 size_type
00691 find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
00692 {
00693 __glibcxx_check_string_len(__s, __n);
00694 return _Base::find_first_not_of(__s, __pos, __n);
00695 }
00696
00697 size_type
00698 find_first_not_of(const _CharT* __s, size_type __pos = 0) const
00699 {
00700 __glibcxx_check_string(__s);
00701 return _Base::find_first_not_of(__s, __pos);
00702 }
00703
00704 size_type
00705 find_first_not_of(_CharT __c, size_type __pos = 0) const
00706 { return _Base::find_first_not_of(__c, __pos); }
00707
00708 size_type
00709 find_last_not_of(const basic_string& __str,
00710 size_type __pos = _Base::npos) const
00711 { return _Base::find_last_not_of(__str, __pos); }
00712
00713 size_type
00714 find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
00715 {
00716 __glibcxx_check_string(__s);
00717 return _Base::find_last_not_of(__s, __pos, __n);
00718 }
00719
00720 size_type
00721 find_last_not_of(const _CharT* __s, size_type __pos = _Base::npos) const
00722 {
00723 __glibcxx_check_string(__s);
00724 return _Base::find_last_not_of(__s, __pos);
00725 }
00726
00727 size_type
00728 find_last_not_of(_CharT __c, size_type __pos = _Base::npos) const
00729 { return _Base::find_last_not_of(__c, __pos); }
00730
00731 basic_string
00732 substr(size_type __pos = 0, size_type __n = _Base::npos) const
00733 { return basic_string(_Base::substr(__pos, __n)); }
00734
00735 int
00736 compare(const basic_string& __str) const
00737 { return _Base::compare(__str); }
00738
00739 int
00740 compare(size_type __pos1, size_type __n1,
00741 const basic_string& __str) const
00742 { return _Base::compare(__pos1, __n1, __str); }
00743
00744 int
00745 compare(size_type __pos1, size_type __n1, const basic_string& __str,
00746 size_type __pos2, size_type __n2) const
00747 { return _Base::compare(__pos1, __n1, __str, __pos2, __n2); }
00748
00749 int
00750 compare(const _CharT* __s) const
00751 {
00752 __glibcxx_check_string(__s);
00753 return _Base::compare(__s);
00754 }
00755
00756
00757
00758 int
00759 compare(size_type __pos1, size_type __n1, const _CharT* __s) const
00760 {
00761 __glibcxx_check_string(__s);
00762 return _Base::compare(__pos1, __n1, __s);
00763 }
00764
00765
00766
00767 int
00768 compare(size_type __pos1, size_type __n1,const _CharT* __s,
00769 size_type __n2) const
00770 {
00771 __glibcxx_check_string_len(__s, __n2);
00772 return _Base::compare(__pos1, __n1, __s, __n2);
00773 }
00774
00775 _Base&
00776 _M_base() { return *this; }
00777
00778 const _Base&
00779 _M_base() const { return *this; }
00780
00781 using _Safe_base::_M_invalidate_all;
00782 };
00783
00784 template<typename _CharT, typename _Traits, typename _Allocator>
00785 inline basic_string<_CharT,_Traits,_Allocator>
00786 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
00787 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
00788 { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
00789
00790 template<typename _CharT, typename _Traits, typename _Allocator>
00791 inline basic_string<_CharT,_Traits,_Allocator>
00792 operator+(const _CharT* __lhs,
00793 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
00794 {
00795 __glibcxx_check_string(__lhs);
00796 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
00797 }
00798
00799 template<typename _CharT, typename _Traits, typename _Allocator>
00800 inline basic_string<_CharT,_Traits,_Allocator>
00801 operator+(_CharT __lhs,
00802 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
00803 { return basic_string<_CharT,_Traits,_Allocator>(1, __lhs) += __rhs; }
00804
00805 template<typename _CharT, typename _Traits, typename _Allocator>
00806 inline basic_string<_CharT,_Traits,_Allocator>
00807 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
00808 const _CharT* __rhs)
00809 {
00810 __glibcxx_check_string(__rhs);
00811 return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs;
00812 }
00813
00814 template<typename _CharT, typename _Traits, typename _Allocator>
00815 inline basic_string<_CharT,_Traits,_Allocator>
00816 operator+(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
00817 _CharT __rhs)
00818 { return basic_string<_CharT,_Traits,_Allocator>(__lhs) += __rhs; }
00819
00820 template<typename _CharT, typename _Traits, typename _Allocator>
00821 inline bool
00822 operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
00823 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
00824 { return __lhs._M_base() == __rhs._M_base(); }
00825
00826 template<typename _CharT, typename _Traits, typename _Allocator>
00827 inline bool
00828 operator==(const _CharT* __lhs,
00829 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
00830 {
00831 __glibcxx_check_string(__lhs);
00832 return __lhs == __rhs._M_base();
00833 }
00834
00835 template<typename _CharT, typename _Traits, typename _Allocator>
00836 inline bool
00837 operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
00838 const _CharT* __rhs)
00839 {
00840 __glibcxx_check_string(__rhs);
00841 return __lhs._M_base() == __rhs;
00842 }
00843
00844 template<typename _CharT, typename _Traits, typename _Allocator>
00845 inline bool
00846 operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
00847 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
00848 { return __lhs._M_base() != __rhs._M_base(); }
00849
00850 template<typename _CharT, typename _Traits, typename _Allocator>
00851 inline bool
00852 operator!=(const _CharT* __lhs,
00853 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
00854 {
00855 __glibcxx_check_string(__lhs);
00856 return __lhs != __rhs._M_base();
00857 }
00858
00859 template<typename _CharT, typename _Traits, typename _Allocator>
00860 inline bool
00861 operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
00862 const _CharT* __rhs)
00863 {
00864 __glibcxx_check_string(__rhs);
00865 return __lhs._M_base() != __rhs;
00866 }
00867
00868 template<typename _CharT, typename _Traits, typename _Allocator>
00869 inline bool
00870 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
00871 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
00872 { return __lhs._M_base() < __rhs._M_base(); }
00873
00874 template<typename _CharT, typename _Traits, typename _Allocator>
00875 inline bool
00876 operator<(const _CharT* __lhs,
00877 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
00878 {
00879 __glibcxx_check_string(__lhs);
00880 return __lhs < __rhs._M_base();
00881 }
00882
00883 template<typename _CharT, typename _Traits, typename _Allocator>
00884 inline bool
00885 operator<(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
00886 const _CharT* __rhs)
00887 {
00888 __glibcxx_check_string(__rhs);
00889 return __lhs._M_base() < __rhs;
00890 }
00891
00892 template<typename _CharT, typename _Traits, typename _Allocator>
00893 inline bool
00894 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
00895 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
00896 { return __lhs._M_base() <= __rhs._M_base(); }
00897
00898 template<typename _CharT, typename _Traits, typename _Allocator>
00899 inline bool
00900 operator<=(const _CharT* __lhs,
00901 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
00902 {
00903 __glibcxx_check_string(__lhs);
00904 return __lhs <= __rhs._M_base();
00905 }
00906
00907 template<typename _CharT, typename _Traits, typename _Allocator>
00908 inline bool
00909 operator<=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
00910 const _CharT* __rhs)
00911 {
00912 __glibcxx_check_string(__rhs);
00913 return __lhs._M_base() <= __rhs;
00914 }
00915
00916 template<typename _CharT, typename _Traits, typename _Allocator>
00917 inline bool
00918 operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
00919 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
00920 { return __lhs._M_base() >= __rhs._M_base(); }
00921
00922 template<typename _CharT, typename _Traits, typename _Allocator>
00923 inline bool
00924 operator>=(const _CharT* __lhs,
00925 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
00926 {
00927 __glibcxx_check_string(__lhs);
00928 return __lhs >= __rhs._M_base();
00929 }
00930
00931 template<typename _CharT, typename _Traits, typename _Allocator>
00932 inline bool
00933 operator>=(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
00934 const _CharT* __rhs)
00935 {
00936 __glibcxx_check_string(__rhs);
00937 return __lhs._M_base() >= __rhs;
00938 }
00939
00940 template<typename _CharT, typename _Traits, typename _Allocator>
00941 inline bool
00942 operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
00943 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
00944 { return __lhs._M_base() > __rhs._M_base(); }
00945
00946 template<typename _CharT, typename _Traits, typename _Allocator>
00947 inline bool
00948 operator>(const _CharT* __lhs,
00949 const basic_string<_CharT,_Traits,_Allocator>& __rhs)
00950 {
00951 __glibcxx_check_string(__lhs);
00952 return __lhs > __rhs._M_base();
00953 }
00954
00955 template<typename _CharT, typename _Traits, typename _Allocator>
00956 inline bool
00957 operator>(const basic_string<_CharT,_Traits,_Allocator>& __lhs,
00958 const _CharT* __rhs)
00959 {
00960 __glibcxx_check_string(__rhs);
00961 return __lhs._M_base() > __rhs;
00962 }
00963
00964
00965 template<typename _CharT, typename _Traits, typename _Allocator>
00966 inline void
00967 swap(basic_string<_CharT,_Traits,_Allocator>& __lhs,
00968 basic_string<_CharT,_Traits,_Allocator>& __rhs)
00969 { __lhs.swap(__rhs); }
00970
00971 template<typename _CharT, typename _Traits, typename _Allocator>
00972 std::basic_ostream<_CharT, _Traits>&
00973 operator<<(std::basic_ostream<_CharT, _Traits>& __os,
00974 const basic_string<_CharT, _Traits, _Allocator>& __str)
00975 { return __os << __str._M_base(); }
00976
00977 template<typename _CharT, typename _Traits, typename _Allocator>
00978 std::basic_istream<_CharT,_Traits>&
00979 operator>>(std::basic_istream<_CharT,_Traits>& __is,
00980 basic_string<_CharT,_Traits,_Allocator>& __str)
00981 {
00982 std::basic_istream<_CharT,_Traits>& __res = __is >> __str._M_base();
00983 __str._M_invalidate_all();
00984 return __res;
00985 }
00986
00987 template<typename _CharT, typename _Traits, typename _Allocator>
00988 std::basic_istream<_CharT,_Traits>&
00989 getline(std::basic_istream<_CharT,_Traits>& __is,
00990 basic_string<_CharT,_Traits,_Allocator>& __str, _CharT __delim)
00991 {
00992 std::basic_istream<_CharT,_Traits>& __res = getline(__is,
00993 __str._M_base(),
00994 __delim);
00995 __str._M_invalidate_all();
00996 return __res;
00997 }
00998
00999 template<typename _CharT, typename _Traits, typename _Allocator>
01000 std::basic_istream<_CharT,_Traits>&
01001 getline(std::basic_istream<_CharT,_Traits>& __is,
01002 basic_string<_CharT,_Traits,_Allocator>& __str)
01003 {
01004 std::basic_istream<_CharT,_Traits>& __res = getline(__is,
01005 __str._M_base());
01006 __str._M_invalidate_all();
01007 return __res;
01008 }
01009
01010 typedef basic_string<char> string;
01011
01012 #ifdef _GLIBCXX_USE_WCHAR_T
01013 typedef basic_string<wchar_t> wstring;
01014 #endif
01015
01016 }
01017
01018 #endif