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