# debug/string

Go to the documentation of this file.

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