vstring.h

Go to the documentation of this file.
00001 // Versatile string -*- C++ -*-
00002 
00003 // Copyright (C) 2005, 2006 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 2, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // You should have received a copy of the GNU General Public License along
00017 // with this library; see the file COPYING.  If not, write to the Free
00018 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
00019 // USA.
00020 
00021 // As a special exception, you may use this file as part of a free software
00022 // library without restriction.  Specifically, if other files instantiate
00023 // templates or use macros or inline functions from this file, or you compile
00024 // this file and link it with other files to produce an executable, this
00025 // file does not by itself cause the resulting executable to be covered by
00026 // the GNU General Public License.  This exception does not however
00027 // invalidate any other reasons why the executable file might be covered by
00028 // the GNU General Public License.
00029 
00030 /** @file ext/vstring.h
00031  *  This file is a GNU extension to the Standard C++ Library.
00032  */
00033 
00034 #ifndef _VSTRING_H
00035 #define _VSTRING_H 1
00036 
00037 #pragma GCC system_header
00038 
00039 #include <ext/vstring_util.h>
00040 #include <ext/rc_string_base.h>
00041 #include <ext/sso_string_base.h>
00042 
00043 namespace __gnu_cxx
00044 {
00045   /**
00046    *  @class __versa_string vstring.h
00047    *  @brief  Managing sequences of characters and character-like objects.
00048    */
00049 
00050   // Template class __versa_string
00051   template<typename _CharT, typename _Traits, typename _Alloc,
00052        template <typename, typename, typename> class _Base>
00053     class __versa_string
00054     : private _Base<_CharT, _Traits, _Alloc>
00055     {
00056       typedef _Base<_CharT, _Traits, _Alloc>                __vstring_base;      
00057       typedef typename __vstring_base::_CharT_alloc_type    _CharT_alloc_type;
00058 
00059       // Types:
00060     public:
00061       typedef _Traits                       traits_type;
00062       typedef typename _Traits::char_type           value_type;
00063       typedef _Alloc                        allocator_type;
00064       typedef typename _CharT_alloc_type::size_type     size_type;
00065       typedef typename _CharT_alloc_type::difference_type   difference_type;
00066       typedef typename _CharT_alloc_type::reference     reference;
00067       typedef typename _CharT_alloc_type::const_reference   const_reference;
00068       typedef typename _CharT_alloc_type::pointer       pointer;
00069       typedef typename _CharT_alloc_type::const_pointer     const_pointer;
00070       typedef __gnu_cxx::__normal_iterator<pointer, __versa_string>  iterator;
00071       typedef __gnu_cxx::__normal_iterator<const_pointer, __versa_string>
00072                                                             const_iterator;
00073       typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
00074       typedef std::reverse_iterator<iterator>           reverse_iterator;
00075 
00076       // Data Member (public):
00077       // NB: This is an unsigned type, and thus represents the maximum
00078       // size that the allocator can hold.
00079       ///  Value returned by various member functions when they fail.
00080       static const size_type    npos = static_cast<size_type>(-1);
00081 
00082     private:
00083       size_type
00084       _M_check(size_type __pos, const char* __s) const
00085       {
00086     if (__pos > this->size())
00087       std::__throw_out_of_range(__N(__s));
00088     return __pos;
00089       }
00090 
00091       void
00092       _M_check_length(size_type __n1, size_type __n2, const char* __s) const
00093       {
00094     if (this->max_size() - (this->size() - __n1) < __n2)
00095       std::__throw_length_error(__N(__s));
00096       }
00097 
00098       // NB: _M_limit doesn't check for a bad __pos value.
00099       size_type
00100       _M_limit(size_type __pos, size_type __off) const
00101       {
00102     const bool __testoff =  __off < this->size() - __pos;
00103     return __testoff ? __off : this->size() - __pos;
00104       }
00105 
00106       // True if _Rep and source do not overlap.
00107       bool
00108       _M_disjunct(const _CharT* __s) const
00109       {
00110     return (std::less<const _CharT*>()(__s, this->_M_data())
00111         || std::less<const _CharT*>()(this->_M_data()
00112                           + this->size(), __s));
00113       }
00114 
00115       // For the internal use we have functions similar to `begin'/`end'
00116       // but they do not call _M_leak.
00117       iterator
00118       _M_ibegin() const
00119       { return iterator(this->_M_data()); }
00120 
00121       iterator
00122       _M_iend() const
00123       { return iterator(this->_M_data() + this->_M_length()); }
00124 
00125     public:
00126       // Construct/copy/destroy:
00127       // NB: We overload ctors in some cases instead of using default
00128       // arguments, per 17.4.4.4 para. 2 item 2.
00129 
00130       /**
00131        *  @brief  Default constructor creates an empty string.
00132        */
00133       __versa_string()
00134       : __vstring_base() { }
00135       
00136       /**
00137        *  @brief  Construct an empty string using allocator @a a.
00138        */
00139       explicit
00140       __versa_string(const _Alloc& __a)
00141       : __vstring_base(__a) { }
00142 
00143       // NB: per LWG issue 42, semantics different from IS:
00144       /**
00145        *  @brief  Construct string with copy of value of @a str.
00146        *  @param  str  Source string.
00147        */
00148       __versa_string(const __versa_string& __str)
00149       : __vstring_base(__str) { }
00150 
00151       /**
00152        *  @brief  Construct string as copy of a substring.
00153        *  @param  str  Source string.
00154        *  @param  pos  Index of first character to copy from.
00155        *  @param  n  Number of characters to copy (default remainder).
00156        */
00157       __versa_string(const __versa_string& __str, size_type __pos,
00158              size_type __n = npos)
00159       : __vstring_base(__str._M_data()
00160                + __str._M_check(__pos,
00161                     "__versa_string::__versa_string"),
00162                __str._M_data() + __str._M_limit(__pos, __n)
00163                + __pos, _Alloc()) { }
00164 
00165       /**
00166        *  @brief  Construct string as copy of a substring.
00167        *  @param  str  Source string.
00168        *  @param  pos  Index of first character to copy from.
00169        *  @param  n  Number of characters to copy.
00170        *  @param  a  Allocator to use.
00171        */
00172       __versa_string(const __versa_string& __str, size_type __pos,
00173              size_type __n, const _Alloc& __a)
00174       : __vstring_base(__str._M_data()
00175                + __str._M_check(__pos,
00176                     "__versa_string::__versa_string"),
00177                __str._M_data() + __str._M_limit(__pos, __n)
00178                + __pos, __a) { }
00179 
00180       /**
00181        *  @brief  Construct string initialized by a character array.
00182        *  @param  s  Source character array.
00183        *  @param  n  Number of characters to copy.
00184        *  @param  a  Allocator to use (default is default allocator).
00185        *
00186        *  NB: @a s must have at least @a n characters, '\0' has no special
00187        *  meaning.
00188        */
00189       __versa_string(const _CharT* __s, size_type __n,
00190              const _Alloc& __a = _Alloc())
00191       : __vstring_base(__s, __s + __n, __a) { }
00192 
00193       /**
00194        *  @brief  Construct string as copy of a C string.
00195        *  @param  s  Source C string.
00196        *  @param  a  Allocator to use (default is default allocator).
00197        */
00198       __versa_string(const _CharT* __s, const _Alloc& __a = _Alloc())
00199       : __vstring_base(__s, __s ? __s + traits_type::length(__s) :
00200                __s + npos, __a) { }
00201 
00202       /**
00203        *  @brief  Construct string as multiple characters.
00204        *  @param  n  Number of characters.
00205        *  @param  c  Character to use.
00206        *  @param  a  Allocator to use (default is default allocator).
00207        */
00208       __versa_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc())
00209       : __vstring_base(__n, __c, __a) { }
00210 
00211       /**
00212        *  @brief  Construct string as copy of a range.
00213        *  @param  beg  Start of range.
00214        *  @param  end  End of range.
00215        *  @param  a  Allocator to use (default is default allocator).
00216        */
00217       template<class _InputIterator>
00218         __versa_string(_InputIterator __beg, _InputIterator __end,
00219                const _Alloc& __a = _Alloc())
00220     : __vstring_base(__beg, __end, __a) { }
00221 
00222       /**
00223        *  @brief  Destroy the string instance.
00224        */
00225       ~__versa_string() { } 
00226 
00227       /**
00228        *  @brief  Assign the value of @a str to this string.
00229        *  @param  str  Source string.
00230        */
00231       __versa_string&
00232       operator=(const __versa_string& __str) 
00233       { return this->assign(__str); }
00234 
00235       /**
00236        *  @brief  Copy contents of @a s into this string.
00237        *  @param  s  Source null-terminated string.
00238        */
00239       __versa_string&
00240       operator=(const _CharT* __s) 
00241       { return this->assign(__s); }
00242 
00243       /**
00244        *  @brief  Set value to string of length 1.
00245        *  @param  c  Source character.
00246        *
00247        *  Assigning to a character makes this string length 1 and
00248        *  (*this)[0] == @a c.
00249        */
00250       __versa_string&
00251       operator=(_CharT __c) 
00252       { 
00253     this->assign(1, __c); 
00254     return *this;
00255       }
00256 
00257       // Iterators:
00258       /**
00259        *  Returns a read/write iterator that points to the first character in
00260        *  the %string.  Unshares the string.
00261        */
00262       iterator
00263       begin()
00264       {
00265     this->_M_leak();
00266     return iterator(this->_M_data());
00267       }
00268 
00269       /**
00270        *  Returns a read-only (constant) iterator that points to the first
00271        *  character in the %string.
00272        */
00273       const_iterator
00274       begin() const
00275       { return const_iterator(this->_M_data()); }
00276 
00277       /**
00278        *  Returns a read/write iterator that points one past the last
00279        *  character in the %string.  Unshares the string.
00280        */
00281       iterator
00282       end()
00283       {
00284     this->_M_leak();
00285     return iterator(this->_M_data() + this->size());
00286       }
00287 
00288       /**
00289        *  Returns a read-only (constant) iterator that points one past the
00290        *  last character in the %string.
00291        */
00292       const_iterator
00293       end() const
00294       { return const_iterator(this->_M_data() + this->size()); }
00295 
00296       /**
00297        *  Returns a read/write reverse iterator that points to the last
00298        *  character in the %string.  Iteration is done in reverse element
00299        *  order.  Unshares the string.
00300        */
00301       reverse_iterator
00302       rbegin()
00303       { return reverse_iterator(this->end()); }
00304 
00305       /**
00306        *  Returns a read-only (constant) reverse iterator that points
00307        *  to the last character in the %string.  Iteration is done in
00308        *  reverse element order.
00309        */
00310       const_reverse_iterator
00311       rbegin() const
00312       { return const_reverse_iterator(this->end()); }
00313 
00314       /**
00315        *  Returns a read/write reverse iterator that points to one before the
00316        *  first character in the %string.  Iteration is done in reverse
00317        *  element order.  Unshares the string.
00318        */
00319       reverse_iterator
00320       rend()
00321       { return reverse_iterator(this->begin()); }
00322 
00323       /**
00324        *  Returns a read-only (constant) reverse iterator that points
00325        *  to one before the first character in the %string.  Iteration
00326        *  is done in reverse element order.
00327        */
00328       const_reverse_iterator
00329       rend() const
00330       { return const_reverse_iterator(this->begin()); }
00331 
00332     public:
00333       // Capacity:
00334       ///  Returns the number of characters in the string, not including any
00335       ///  null-termination.
00336       size_type
00337       size() const
00338       { return this->_M_length(); }
00339 
00340       ///  Returns the number of characters in the string, not including any
00341       ///  null-termination.
00342       size_type
00343       length() const
00344       { return this->_M_length(); }
00345 
00346       /// Returns the size() of the largest possible %string.
00347       size_type
00348       max_size() const
00349       { return this->_M_max_size(); }
00350 
00351       /**
00352        *  @brief  Resizes the %string to the specified number of characters.
00353        *  @param  n  Number of characters the %string should contain.
00354        *  @param  c  Character to fill any new elements.
00355        *
00356        *  This function will %resize the %string to the specified
00357        *  number of characters.  If the number is smaller than the
00358        *  %string's current size the %string is truncated, otherwise
00359        *  the %string is extended and new elements are set to @a c.
00360        */
00361       void
00362       resize(size_type __n, _CharT __c);
00363 
00364       /**
00365        *  @brief  Resizes the %string to the specified number of characters.
00366        *  @param  n  Number of characters the %string should contain.
00367        *
00368        *  This function will resize the %string to the specified length.  If
00369        *  the new size is smaller than the %string's current size the %string
00370        *  is truncated, otherwise the %string is extended and new characters
00371        *  are default-constructed.  For basic types such as char, this means
00372        *  setting them to 0.
00373        */
00374       void
00375       resize(size_type __n)
00376       { this->resize(__n, _CharT()); }
00377 
00378       /**
00379        *  Returns the total number of characters that the %string can hold
00380        *  before needing to allocate more memory.
00381        */
00382       size_type
00383       capacity() const
00384       { return this->_M_capacity(); }
00385 
00386       /**
00387        *  @brief  Attempt to preallocate enough memory for specified number of
00388        *          characters.
00389        *  @param  res_arg  Number of characters required.
00390        *  @throw  std::length_error  If @a res_arg exceeds @c max_size().
00391        *
00392        *  This function attempts to reserve enough memory for the
00393        *  %string to hold the specified number of characters.  If the
00394        *  number requested is more than max_size(), length_error is
00395        *  thrown.
00396        *
00397        *  The advantage of this function is that if optimal code is a
00398        *  necessity and the user can determine the string length that will be
00399        *  required, the user can reserve the memory in %advance, and thus
00400        *  prevent a possible reallocation of memory and copying of %string
00401        *  data.
00402        */
00403       void
00404       reserve(size_type __res_arg = 0)
00405       { this->_M_reserve(__res_arg); }
00406 
00407       /**
00408        *  Erases the string, making it empty.
00409        */
00410       void
00411       clear()
00412       { this->_M_clear(); }
00413 
00414       /**
00415        *  Returns true if the %string is empty.  Equivalent to *this == "".
00416        */
00417       bool
00418       empty() const
00419       { return this->size() == 0; }
00420 
00421       // Element access:
00422       /**
00423        *  @brief  Subscript access to the data contained in the %string.
00424        *  @param  pos  The index of the character to access.
00425        *  @return  Read-only (constant) reference to the character.
00426        *
00427        *  This operator allows for easy, array-style, data access.
00428        *  Note that data access with this operator is unchecked and
00429        *  out_of_range lookups are not defined. (For checked lookups
00430        *  see at().)
00431        */
00432       const_reference
00433       operator[] (size_type __pos) const
00434       {
00435     _GLIBCXX_DEBUG_ASSERT(__pos <= this->size());
00436     return this->_M_data()[__pos];
00437       }
00438 
00439       /**
00440        *  @brief  Subscript access to the data contained in the %string.
00441        *  @param  pos  The index of the character to access.
00442        *  @return  Read/write reference to the character.
00443        *
00444        *  This operator allows for easy, array-style, data access.
00445        *  Note that data access with this operator is unchecked and
00446        *  out_of_range lookups are not defined. (For checked lookups
00447        *  see at().)  Unshares the string.
00448        */
00449       reference
00450       operator[](size_type __pos)
00451       {
00452         // allow pos == size() as v3 extension:
00453     _GLIBCXX_DEBUG_ASSERT(__pos <= this->size());
00454         // but be strict in pedantic mode:
00455     _GLIBCXX_DEBUG_PEDASSERT(__pos < this->size());
00456     this->_M_leak();
00457     return this->_M_data()[__pos];
00458       }
00459 
00460       /**
00461        *  @brief  Provides access to the data contained in the %string.
00462        *  @param n The index of the character to access.
00463        *  @return  Read-only (const) reference to the character.
00464        *  @throw  std::out_of_range  If @a n is an invalid index.
00465        *
00466        *  This function provides for safer data access.  The parameter is
00467        *  first checked that it is in the range of the string.  The function
00468        *  throws out_of_range if the check fails.
00469        */
00470       const_reference
00471       at(size_type __n) const
00472       {
00473     if (__n >= this->size())
00474       std::__throw_out_of_range(__N("__versa_string::at"));
00475     return this->_M_data()[__n];
00476       }
00477 
00478       /**
00479        *  @brief  Provides access to the data contained in the %string.
00480        *  @param n The index of the character to access.
00481        *  @return  Read/write reference to the character.
00482        *  @throw  std::out_of_range  If @a n is an invalid index.
00483        *
00484        *  This function provides for safer data access.  The parameter is
00485        *  first checked that it is in the range of the string.  The function
00486        *  throws out_of_range if the check fails.  Success results in
00487        *  unsharing the string.
00488        */
00489       reference
00490       at(size_type __n)
00491       {
00492     if (__n >= this->size())
00493       std::__throw_out_of_range(__N("__versa_string::at"));
00494     this->_M_leak();
00495     return this->_M_data()[__n];
00496       }
00497 
00498       // Modifiers:
00499       /**
00500        *  @brief  Append a string to this string.
00501        *  @param str  The string to append.
00502        *  @return  Reference to this string.
00503        */
00504       __versa_string&
00505       operator+=(const __versa_string& __str)
00506       { return this->append(__str); }
00507 
00508       /**
00509        *  @brief  Append a C string.
00510        *  @param s  The C string to append.
00511        *  @return  Reference to this string.
00512        */
00513       __versa_string&
00514       operator+=(const _CharT* __s)
00515       { return this->append(__s); }
00516 
00517       /**
00518        *  @brief  Append a character.
00519        *  @param c  The character to append.
00520        *  @return  Reference to this string.
00521        */
00522       __versa_string&
00523       operator+=(_CharT __c)
00524       { 
00525     this->push_back(__c);
00526     return *this;
00527       }
00528 
00529       /**
00530        *  @brief  Append a string to this string.
00531        *  @param str  The string to append.
00532        *  @return  Reference to this string.
00533        */
00534       __versa_string&
00535       append(const __versa_string& __str)
00536       { return _M_append(__str._M_data(), __str.size()); }
00537 
00538       /**
00539        *  @brief  Append a substring.
00540        *  @param str  The string to append.
00541        *  @param pos  Index of the first character of str to append.
00542        *  @param n  The number of characters to append.
00543        *  @return  Reference to this string.
00544        *  @throw  std::out_of_range if @a pos is not a valid index.
00545        *
00546        *  This function appends @a n characters from @a str starting at @a pos
00547        *  to this string.  If @a n is is larger than the number of available
00548        *  characters in @a str, the remainder of @a str is appended.
00549        */
00550       __versa_string&
00551       append(const __versa_string& __str, size_type __pos, size_type __n)
00552       { return _M_append(__str._M_data()
00553              + __str._M_check(__pos, "__versa_string::append"),
00554              __str._M_limit(__pos, __n)); }
00555 
00556       /**
00557        *  @brief  Append a C substring.
00558        *  @param s  The C string to append.
00559        *  @param n  The number of characters to append.
00560        *  @return  Reference to this string.
00561        */
00562       __versa_string&
00563       append(const _CharT* __s, size_type __n)
00564       {
00565     __glibcxx_requires_string_len(__s, __n);
00566     _M_check_length(size_type(0), __n, "__versa_string::append");
00567     return _M_append(__s, __n);
00568       }
00569 
00570       /**
00571        *  @brief  Append a C string.
00572        *  @param s  The C string to append.
00573        *  @return  Reference to this string.
00574        */
00575       __versa_string&
00576       append(const _CharT* __s)
00577       {
00578     __glibcxx_requires_string(__s);
00579     const size_type __n = traits_type::length(__s);
00580     _M_check_length(size_type(0), __n, "__versa_string::append");
00581     return _M_append(__s, __n);
00582       }
00583 
00584       /**
00585        *  @brief  Append multiple characters.
00586        *  @param n  The number of characters to append.
00587        *  @param c  The character to use.
00588        *  @return  Reference to this string.
00589        *
00590        *  Appends n copies of c to this string.
00591        */
00592       __versa_string&
00593       append(size_type __n, _CharT __c)
00594       { return _M_replace_aux(this->size(), size_type(0), __n, __c); }
00595 
00596       /**
00597        *  @brief  Append a range of characters.
00598        *  @param first  Iterator referencing the first character to append.
00599        *  @param last  Iterator marking the end of the range.
00600        *  @return  Reference to this string.
00601        *
00602        *  Appends characters in the range [first,last) to this string.
00603        */
00604       template<class _InputIterator>
00605         __versa_string&
00606         append(_InputIterator __first, _InputIterator __last)
00607         { return this->replace(_M_iend(), _M_iend(), __first, __last); }
00608 
00609       /**
00610        *  @brief  Append a single character.
00611        *  @param c  Character to append.
00612        */
00613       void
00614       push_back(_CharT __c)
00615       { 
00616     const size_type __size = this->size();
00617     if (__size + 1 > this->capacity() || this->_M_is_shared())
00618       this->_M_mutate(__size, size_type(0), 0, size_type(1));
00619     traits_type::assign(this->_M_data()[__size], __c);
00620     this->_M_set_length(__size + 1);
00621       }
00622 
00623       /**
00624        *  @brief  Set value to contents of another string.
00625        *  @param  str  Source string to use.
00626        *  @return  Reference to this string.
00627        */
00628       __versa_string&
00629       assign(const __versa_string& __str)
00630       {
00631     this->_M_assign(__str);
00632     return *this;
00633       }
00634 
00635       /**
00636        *  @brief  Set value to a substring of a string.
00637        *  @param str  The string to use.
00638        *  @param pos  Index of the first character of str.
00639        *  @param n  Number of characters to use.
00640        *  @return  Reference to this string.
00641        *  @throw  std::out_of_range if @a pos is not a valid index.
00642        *
00643        *  This function sets this string to the substring of @a str consisting
00644        *  of @a n characters at @a pos.  If @a n is is larger than the number
00645        *  of available characters in @a str, the remainder of @a str is used.
00646        */
00647       __versa_string&
00648       assign(const __versa_string& __str, size_type __pos, size_type __n)
00649       { return _M_replace(size_type(0), this->size(), __str._M_data()
00650               + __str._M_check(__pos, "__versa_string::assign"),
00651               __str._M_limit(__pos, __n)); }
00652 
00653       /**
00654        *  @brief  Set value to a C substring.
00655        *  @param s  The C string to use.
00656        *  @param n  Number of characters to use.
00657        *  @return  Reference to this string.
00658        *
00659        *  This function sets the value of this string to the first @a n
00660        *  characters of @a s.  If @a n is is larger than the number of
00661        *  available characters in @a s, the remainder of @a s is used.
00662        */
00663       __versa_string&
00664       assign(const _CharT* __s, size_type __n)
00665       {
00666     __glibcxx_requires_string_len(__s, __n);
00667     return _M_replace(size_type(0), this->size(), __s, __n);
00668       }
00669 
00670       /**
00671        *  @brief  Set value to contents of a C string.
00672        *  @param s  The C string to use.
00673        *  @return  Reference to this string.
00674        *
00675        *  This function sets the value of this string to the value of @a s.
00676        *  The data is copied, so there is no dependence on @a s once the
00677        *  function returns.
00678        */
00679       __versa_string&
00680       assign(const _CharT* __s)
00681       {
00682     __glibcxx_requires_string(__s);
00683     return _M_replace(size_type(0), this->size(), __s,
00684               traits_type::length(__s));
00685       }
00686 
00687       /**
00688        *  @brief  Set value to multiple characters.
00689        *  @param n  Length of the resulting string.
00690        *  @param c  The character to use.
00691        *  @return  Reference to this string.
00692        *
00693        *  This function sets the value of this string to @a n copies of
00694        *  character @a c.
00695        */
00696       __versa_string&
00697       assign(size_type __n, _CharT __c)
00698       { return _M_replace_aux(size_type(0), this->size(), __n, __c); }
00699 
00700       /**
00701        *  @brief  Set value to a range of characters.
00702        *  @param first  Iterator referencing the first character to append.
00703        *  @param last  Iterator marking the end of the range.
00704        *  @return  Reference to this string.
00705        *
00706        *  Sets value of string to characters in the range [first,last).
00707       */
00708       template<class _InputIterator>
00709         __versa_string&
00710         assign(_InputIterator __first, _InputIterator __last)
00711         { return this->replace(_M_ibegin(), _M_iend(), __first, __last); }
00712 
00713       /**
00714        *  @brief  Insert multiple characters.
00715        *  @param p  Iterator referencing location in string to insert at.
00716        *  @param n  Number of characters to insert
00717        *  @param c  The character to insert.
00718        *  @throw  std::length_error  If new length exceeds @c max_size().
00719        *
00720        *  Inserts @a n copies of character @a c starting at the position
00721        *  referenced by iterator @a p.  If adding characters causes the length
00722        *  to exceed max_size(), length_error is thrown.  The value of the
00723        *  string doesn't change if an error is thrown.
00724       */
00725       void
00726       insert(iterator __p, size_type __n, _CharT __c)
00727       { this->replace(__p, __p, __n, __c);  }
00728 
00729       /**
00730        *  @brief  Insert a range of characters.
00731        *  @param p  Iterator referencing location in string to insert at.
00732        *  @param beg  Start of range.
00733        *  @param end  End of range.
00734        *  @throw  std::length_error  If new length exceeds @c max_size().
00735        *
00736        *  Inserts characters in range [beg,end).  If adding characters causes
00737        *  the length to exceed max_size(), length_error is thrown.  The value
00738        *  of the string doesn't change if an error is thrown.
00739       */
00740       template<class _InputIterator>
00741         void
00742         insert(iterator __p, _InputIterator __beg, _InputIterator __end)
00743         { this->replace(__p, __p, __beg, __end); }
00744 
00745       /**
00746        *  @brief  Insert value of a string.
00747        *  @param pos1  Iterator referencing location in string to insert at.
00748        *  @param str  The string to insert.
00749        *  @return  Reference to this string.
00750        *  @throw  std::length_error  If new length exceeds @c max_size().
00751        *
00752        *  Inserts value of @a str starting at @a pos1.  If adding characters
00753        *  causes the length to exceed max_size(), length_error is thrown.  The
00754        *  value of the string doesn't change if an error is thrown.
00755       */
00756       __versa_string&
00757       insert(size_type __pos1, const __versa_string& __str)
00758       { return this->replace(__pos1, size_type(0),
00759                  __str._M_data(), __str.size()); }
00760 
00761       /**
00762        *  @brief  Insert a substring.
00763        *  @param pos1  Iterator referencing location in string to insert at.
00764        *  @param str  The string to insert.
00765        *  @param pos2  Start of characters in str to insert.
00766        *  @param n  Number of characters to insert.
00767        *  @return  Reference to this string.
00768        *  @throw  std::length_error  If new length exceeds @c max_size().
00769        *  @throw  std::out_of_range  If @a pos1 > size() or
00770        *  @a pos2 > @a str.size().
00771        *
00772        *  Starting at @a pos1, insert @a n character of @a str beginning with
00773        *  @a pos2.  If adding characters causes the length to exceed
00774        *  max_size(), length_error is thrown.  If @a pos1 is beyond the end of
00775        *  this string or @a pos2 is beyond the end of @a str, out_of_range is
00776        *  thrown.  The value of the string doesn't change if an error is
00777        *  thrown.
00778       */
00779       __versa_string&
00780       insert(size_type __pos1, const __versa_string& __str,
00781          size_type __pos2, size_type __n)
00782       { return this->replace(__pos1, size_type(0), __str._M_data()
00783                  + __str._M_check(__pos2, "__versa_string::insert"),
00784                  __str._M_limit(__pos2, __n)); }
00785 
00786       /**
00787        *  @brief  Insert a C substring.
00788        *  @param pos  Iterator referencing location in string to insert at.
00789        *  @param s  The C string to insert.
00790        *  @param n  The number of characters to insert.
00791        *  @return  Reference to this string.
00792        *  @throw  std::length_error  If new length exceeds @c max_size().
00793        *  @throw  std::out_of_range  If @a pos is beyond the end of this
00794        *  string.
00795        *
00796        *  Inserts the first @a n characters of @a s starting at @a pos.  If
00797        *  adding characters causes the length to exceed max_size(),
00798        *  length_error is thrown.  If @a pos is beyond end(), out_of_range is
00799        *  thrown.  The value of the string doesn't change if an error is
00800        *  thrown.
00801       */
00802       __versa_string&
00803       insert(size_type __pos, const _CharT* __s, size_type __n)
00804       { return this->replace(__pos, size_type(0), __s, __n); }
00805 
00806       /**
00807        *  @brief  Insert a C string.
00808        *  @param pos  Iterator referencing location in string to insert at.
00809        *  @param s  The C string to insert.
00810        *  @return  Reference to this string.
00811        *  @throw  std::length_error  If new length exceeds @c max_size().
00812        *  @throw  std::out_of_range  If @a pos is beyond the end of this
00813        *  string.
00814        *
00815        *  Inserts the first @a n characters of @a s starting at @a pos.  If
00816        *  adding characters causes the length to exceed max_size(),
00817        *  length_error is thrown.  If @a pos is beyond end(), out_of_range is
00818        *  thrown.  The value of the string doesn't change if an error is
00819        *  thrown.
00820       */
00821       __versa_string&
00822       insert(size_type __pos, const _CharT* __s)
00823       {
00824     __glibcxx_requires_string(__s);
00825     return this->replace(__pos, size_type(0), __s,
00826                  traits_type::length(__s));
00827       }
00828 
00829       /**
00830        *  @brief  Insert multiple characters.
00831        *  @param pos  Index in string to insert at.
00832        *  @param n  Number of characters to insert
00833        *  @param c  The character to insert.
00834        *  @return  Reference to this string.
00835        *  @throw  std::length_error  If new length exceeds @c max_size().
00836        *  @throw  std::out_of_range  If @a pos is beyond the end of this
00837        *  string.
00838        *
00839        *  Inserts @a n copies of character @a c starting at index @a pos.  If
00840        *  adding characters causes the length to exceed max_size(),
00841        *  length_error is thrown.  If @a pos > length(), out_of_range is
00842        *  thrown.  The value of the string doesn't change if an error is
00843        *  thrown.
00844       */
00845       __versa_string&
00846       insert(size_type __pos, size_type __n, _CharT __c)
00847       { return _M_replace_aux(_M_check(__pos, "__versa_string::insert"),
00848                   size_type(0), __n, __c); }
00849 
00850       /**
00851        *  @brief  Insert one character.
00852        *  @param p  Iterator referencing position in string to insert at.
00853        *  @param c  The character to insert.
00854        *  @return  Iterator referencing newly inserted char.
00855        *  @throw  std::length_error  If new length exceeds @c max_size().
00856        *
00857        *  Inserts character @a c at position referenced by @a p.  If adding
00858        *  character causes the length to exceed max_size(), length_error is
00859        *  thrown.  If @a p is beyond end of string, out_of_range is thrown.
00860        *  The value of the string doesn't change if an error is thrown.
00861       */
00862       iterator
00863       insert(iterator __p, _CharT __c)
00864       {
00865     _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend());
00866     const size_type __pos = __p - _M_ibegin();
00867     _M_replace_aux(__pos, size_type(0), size_type(1), __c);
00868     this->_M_set_leaked();
00869     return iterator(this->_M_data() + __pos);
00870       }
00871 
00872       /**
00873        *  @brief  Remove characters.
00874        *  @param pos  Index of first character to remove (default 0).
00875        *  @param n  Number of characters to remove (default remainder).
00876        *  @return  Reference to this string.
00877        *  @throw  std::out_of_range  If @a pos is beyond the end of this
00878        *  string.
00879        *
00880        *  Removes @a n characters from this string starting at @a pos.  The
00881        *  length of the string is reduced by @a n.  If there are < @a n
00882        *  characters to remove, the remainder of the string is truncated.  If
00883        *  @a p is beyond end of string, out_of_range is thrown.  The value of
00884        *  the string doesn't change if an error is thrown.
00885       */
00886       __versa_string&
00887       erase(size_type __pos = 0, size_type __n = npos)
00888       { 
00889     this->_M_erase(_M_check(__pos, "__versa_string::erase"),
00890                _M_limit(__pos, __n));
00891     return *this;
00892       }
00893 
00894       /**
00895        *  @brief  Remove one character.
00896        *  @param position  Iterator referencing the character to remove.
00897        *  @return  iterator referencing same location after removal.
00898        *
00899        *  Removes the character at @a position from this string. The value
00900        *  of the string doesn't change if an error is thrown.
00901       */
00902       iterator
00903       erase(iterator __position)
00904       {
00905     _GLIBCXX_DEBUG_PEDASSERT(__position >= _M_ibegin()
00906                  && __position < _M_iend());
00907     const size_type __pos = __position - _M_ibegin();
00908     this->_M_erase(__pos, size_type(1));
00909     this->_M_set_leaked();
00910     return iterator(this->_M_data() + __pos);
00911       }
00912 
00913       /**
00914        *  @brief  Remove a range of characters.
00915        *  @param first  Iterator referencing the first character to remove.
00916        *  @param last  Iterator referencing the end of the range.
00917        *  @return  Iterator referencing location of first after removal.
00918        *
00919        *  Removes the characters in the range [first,last) from this string.
00920        *  The value of the string doesn't change if an error is thrown.
00921       */
00922       iterator
00923       erase(iterator __first, iterator __last)
00924       {
00925     _GLIBCXX_DEBUG_PEDASSERT(__first >= _M_ibegin() && __first <= __last
00926                  && __last <= _M_iend());
00927         const size_type __pos = __first - _M_ibegin();
00928     this->_M_erase(__pos, __last - __first);
00929     this->_M_set_leaked();
00930     return iterator(this->_M_data() + __pos);
00931       }
00932 
00933       /**
00934        *  @brief  Replace characters with value from another string.
00935        *  @param pos  Index of first character to replace.
00936        *  @param n  Number of characters to be replaced.
00937        *  @param str  String to insert.
00938        *  @return  Reference to this string.
00939        *  @throw  std::out_of_range  If @a pos is beyond the end of this
00940        *  string.
00941        *  @throw  std::length_error  If new length exceeds @c max_size().
00942        *
00943        *  Removes the characters in the range [pos,pos+n) from this string.
00944        *  In place, the value of @a str is inserted.  If @a pos is beyond end
00945        *  of string, out_of_range is thrown.  If the length of the result
00946        *  exceeds max_size(), length_error is thrown.  The value of the string
00947        *  doesn't change if an error is thrown.
00948       */
00949       __versa_string&
00950       replace(size_type __pos, size_type __n, const __versa_string& __str)
00951       { return this->replace(__pos, __n, __str._M_data(), __str.size()); }
00952 
00953       /**
00954        *  @brief  Replace characters with value from another string.
00955        *  @param pos1  Index of first character to replace.
00956        *  @param n1  Number of characters to be replaced.
00957        *  @param str  String to insert.
00958        *  @param pos2  Index of first character of str to use.
00959        *  @param n2  Number of characters from str to use.
00960        *  @return  Reference to this string.
00961        *  @throw  std::out_of_range  If @a pos1 > size() or @a pos2 >
00962        *  str.size().
00963        *  @throw  std::length_error  If new length exceeds @c max_size().
00964        *
00965        *  Removes the characters in the range [pos1,pos1 + n) from this
00966        *  string.  In place, the value of @a str is inserted.  If @a pos is
00967        *  beyond end of string, out_of_range is thrown.  If the length of the
00968        *  result exceeds max_size(), length_error is thrown.  The value of the
00969        *  string doesn't change if an error is thrown.
00970       */
00971       __versa_string&
00972       replace(size_type __pos1, size_type __n1, const __versa_string& __str,
00973           size_type __pos2, size_type __n2)
00974       {
00975     return this->replace(__pos1, __n1, __str._M_data()
00976                  + __str._M_check(__pos2,
00977                           "__versa_string::replace"),
00978                  __str._M_limit(__pos2, __n2));
00979       }
00980 
00981       /**
00982        *  @brief  Replace characters with value of a C substring.
00983        *  @param pos  Index of first character to replace.
00984        *  @param n1  Number of characters to be replaced.
00985        *  @param s  C string to insert.
00986        *  @param n2  Number of characters from @a s to use.
00987        *  @return  Reference to this string.
00988        *  @throw  std::out_of_range  If @a pos1 > size().
00989        *  @throw  std::length_error  If new length exceeds @c max_size().
00990        *
00991        *  Removes the characters in the range [pos,pos + n1) from this string.
00992        *  In place, the first @a n2 characters of @a s are inserted, or all
00993        *  of @a s if @a n2 is too large.  If @a pos is beyond end of string,
00994        *  out_of_range is thrown.  If the length of result exceeds max_size(),
00995        *  length_error is thrown.  The value of the string doesn't change if
00996        *  an error is thrown.
00997       */
00998       __versa_string&
00999       replace(size_type __pos, size_type __n1, const _CharT* __s,
01000           size_type __n2)
01001       {
01002     __glibcxx_requires_string_len(__s, __n2);
01003     return _M_replace(_M_check(__pos, "__versa_string::replace"),
01004               _M_limit(__pos, __n1), __s, __n2);
01005       }
01006 
01007       /**
01008        *  @brief  Replace characters with value of a C string.
01009        *  @param pos  Index of first character to replace.
01010        *  @param n1  Number of characters to be replaced.
01011        *  @param s  C string to insert.
01012        *  @return  Reference to this string.
01013        *  @throw  std::out_of_range  If @a pos > size().
01014        *  @throw  std::length_error  If new length exceeds @c max_size().
01015        *
01016        *  Removes the characters in the range [pos,pos + n1) from this string.
01017        *  In place, the first @a n characters of @a s are inserted.  If @a
01018        *  pos is beyond end of string, out_of_range is thrown.  If the length
01019        *  of result exceeds max_size(), length_error is thrown.  The value of
01020        *  the string doesn't change if an error is thrown.
01021       */
01022       __versa_string&
01023       replace(size_type __pos, size_type __n1, const _CharT* __s)
01024       {
01025     __glibcxx_requires_string(__s);
01026     return this->replace(__pos, __n1, __s, traits_type::length(__s));
01027       }
01028 
01029       /**
01030        *  @brief  Replace characters with multiple characters.
01031        *  @param pos  Index of first character to replace.
01032        *  @param n1  Number of characters to be replaced.
01033        *  @param n2  Number of characters to insert.
01034        *  @param c  Character to insert.
01035        *  @return  Reference to this string.
01036        *  @throw  std::out_of_range  If @a pos > size().
01037        *  @throw  std::length_error  If new length exceeds @c max_size().
01038        *
01039        *  Removes the characters in the range [pos,pos + n1) from this string.
01040        *  In place, @a n2 copies of @a c are inserted.  If @a pos is beyond
01041        *  end of string, out_of_range is thrown.  If the length of result
01042        *  exceeds max_size(), length_error is thrown.  The value of the string
01043        *  doesn't change if an error is thrown.
01044       */
01045       __versa_string&
01046       replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
01047       { return _M_replace_aux(_M_check(__pos, "__versa_string::replace"),
01048                   _M_limit(__pos, __n1), __n2, __c); }
01049 
01050       /**
01051        *  @brief  Replace range of characters with string.
01052        *  @param i1  Iterator referencing start of range to replace.
01053        *  @param i2  Iterator referencing end of range to replace.
01054        *  @param str  String value to insert.
01055        *  @return  Reference to this string.
01056        *  @throw  std::length_error  If new length exceeds @c max_size().
01057        *
01058        *  Removes the characters in the range [i1,i2).  In place, the value of
01059        *  @a str is inserted.  If the length of result exceeds max_size(),
01060        *  length_error is thrown.  The value of the string doesn't change if
01061        *  an error is thrown.
01062       */
01063       __versa_string&
01064       replace(iterator __i1, iterator __i2, const __versa_string& __str)
01065       { return this->replace(__i1, __i2, __str._M_data(), __str.size()); }
01066 
01067       /**
01068        *  @brief  Replace range of characters with C substring.
01069        *  @param i1  Iterator referencing start of range to replace.
01070        *  @param i2  Iterator referencing end of range to replace.
01071        *  @param s  C string value to insert.
01072        *  @param n  Number of characters from s to insert.
01073        *  @return  Reference to this string.
01074        *  @throw  std::length_error  If new length exceeds @c max_size().
01075        *
01076        *  Removes the characters in the range [i1,i2).  In place, the first @a
01077        *  n characters of @a s are inserted.  If the length of result exceeds
01078        *  max_size(), length_error is thrown.  The value of the string doesn't
01079        *  change if an error is thrown.
01080       */
01081       __versa_string&
01082       replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n)
01083       {
01084     _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
01085                  && __i2 <= _M_iend());
01086     return this->replace(__i1 - _M_ibegin(), __i2 - __i1, __s, __n);
01087       }
01088 
01089       /**
01090        *  @brief  Replace range of characters with C string.
01091        *  @param i1  Iterator referencing start of range to replace.
01092        *  @param i2  Iterator referencing end of range to replace.
01093        *  @param s  C string value to insert.
01094        *  @return  Reference to this string.
01095        *  @throw  std::length_error  If new length exceeds @c max_size().
01096        *
01097        *  Removes the characters in the range [i1,i2).  In place, the
01098        *  characters of @a s are inserted.  If the length of result exceeds
01099        *  max_size(), length_error is thrown.  The value of the string doesn't
01100        *  change if an error is thrown.
01101       */
01102       __versa_string&
01103       replace(iterator __i1, iterator __i2, const _CharT* __s)
01104       {
01105     __glibcxx_requires_string(__s);
01106     return this->replace(__i1, __i2, __s, traits_type::length(__s));
01107       }
01108 
01109       /**
01110        *  @brief  Replace range of characters with multiple characters
01111        *  @param i1  Iterator referencing start of range to replace.
01112        *  @param i2  Iterator referencing end of range to replace.
01113        *  @param n  Number of characters to insert.
01114        *  @param c  Character to insert.
01115        *  @return  Reference to this string.
01116        *  @throw  std::length_error  If new length exceeds @c max_size().
01117        *
01118        *  Removes the characters in the range [i1,i2).  In place, @a n copies
01119        *  of @a c are inserted.  If the length of result exceeds max_size(),
01120        *  length_error is thrown.  The value of the string doesn't change if
01121        *  an error is thrown.
01122       */
01123       __versa_string&
01124       replace(iterator __i1, iterator __i2, size_type __n, _CharT __c)
01125       {
01126     _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
01127                  && __i2 <= _M_iend());
01128     return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __c);
01129       }
01130 
01131       /**
01132        *  @brief  Replace range of characters with range.
01133        *  @param i1  Iterator referencing start of range to replace.
01134        *  @param i2  Iterator referencing end of range to replace.
01135        *  @param k1  Iterator referencing start of range to insert.
01136        *  @param k2  Iterator referencing end of range to insert.
01137        *  @return  Reference to this string.
01138        *  @throw  std::length_error  If new length exceeds @c max_size().
01139        *
01140        *  Removes the characters in the range [i1,i2).  In place, characters
01141        *  in the range [k1,k2) are inserted.  If the length of result exceeds
01142        *  max_size(), length_error is thrown.  The value of the string doesn't
01143        *  change if an error is thrown.
01144       */
01145       template<class _InputIterator>
01146         __versa_string&
01147         replace(iterator __i1, iterator __i2,
01148         _InputIterator __k1, _InputIterator __k2)
01149         {
01150       _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
01151                    && __i2 <= _M_iend());
01152       __glibcxx_requires_valid_range(__k1, __k2);
01153       typedef typename std::__is_integer<_InputIterator>::__type _Integral;
01154       return _M_replace_dispatch(__i1, __i2, __k1, __k2, _Integral());
01155     }
01156 
01157       // Specializations for the common case of pointer and iterator:
01158       // useful to avoid the overhead of temporary buffering in _M_replace.
01159       __versa_string&
01160       replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
01161       {
01162     _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
01163                  && __i2 <= _M_iend());
01164     __glibcxx_requires_valid_range(__k1, __k2);
01165     return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
01166                  __k1, __k2 - __k1);
01167       }
01168 
01169       __versa_string&
01170       replace(iterator __i1, iterator __i2,
01171           const _CharT* __k1, const _CharT* __k2)
01172       {
01173     _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
01174                  && __i2 <= _M_iend());
01175     __glibcxx_requires_valid_range(__k1, __k2);
01176     return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
01177                  __k1, __k2 - __k1);
01178       }
01179 
01180       __versa_string&
01181       replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
01182       {
01183     _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
01184                  && __i2 <= _M_iend());
01185     __glibcxx_requires_valid_range(__k1, __k2);
01186     return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
01187                  __k1.base(), __k2 - __k1);
01188       }
01189 
01190       __versa_string&
01191       replace(iterator __i1, iterator __i2,
01192           const_iterator __k1, const_iterator __k2)
01193       {
01194     _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
01195                  && __i2 <= _M_iend());
01196     __glibcxx_requires_valid_range(__k1, __k2);
01197     return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
01198                  __k1.base(), __k2 - __k1);
01199       }
01200       
01201     private:
01202       template<class _Integer>
01203     __versa_string&
01204     _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n,
01205                 _Integer __val, __true_type)
01206         { return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); }
01207 
01208       template<class _InputIterator>
01209     __versa_string&
01210     _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1,
01211                 _InputIterator __k2, __false_type);
01212 
01213       __versa_string&
01214       _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2,
01215              _CharT __c);
01216 
01217       __versa_string&
01218       _M_replace(size_type __pos, size_type __len1, const _CharT* __s,
01219          const size_type __len2);
01220 
01221       __versa_string&
01222       _M_append(const _CharT* __s, size_type __n);
01223 
01224     public:
01225 
01226       /**
01227        *  @brief  Copy substring into C string.
01228        *  @param s  C string to copy value into.
01229        *  @param n  Number of characters to copy.
01230        *  @param pos  Index of first character to copy.
01231        *  @return  Number of characters actually copied
01232        *  @throw  std::out_of_range  If pos > size().
01233        *
01234        *  Copies up to @a n characters starting at @a pos into the C string @a
01235        *  s.  If @a pos is greater than size(), out_of_range is thrown.
01236       */
01237       size_type
01238       copy(_CharT* __s, size_type __n, size_type __pos = 0) const;
01239 
01240       /**
01241        *  @brief  Swap contents with another string.
01242        *  @param s  String to swap with.
01243        *
01244        *  Exchanges the contents of this string with that of @a s in constant
01245        *  time.
01246       */
01247       void
01248       swap(__versa_string& __s)
01249       { this->_M_swap(__s); }
01250 
01251       // String operations:
01252       /**
01253        *  @brief  Return const pointer to null-terminated contents.
01254        *
01255        *  This is a handle to internal data.  Do not modify or dire things may
01256        *  happen.
01257       */
01258       const _CharT*
01259       c_str() const
01260       { return this->_M_data(); }
01261 
01262       /**
01263        *  @brief  Return const pointer to contents.
01264        *
01265        *  This is a handle to internal data.  Do not modify or dire things may
01266        *  happen.
01267       */
01268       const _CharT*
01269       data() const
01270       { return this->_M_data(); }
01271 
01272       /**
01273        *  @brief  Return copy of allocator used to construct this string.
01274       */
01275       allocator_type
01276       get_allocator() const
01277       { return this->_M_get_allocator(); }
01278 
01279       /**
01280        *  @brief  Find position of a C substring.
01281        *  @param s  C string to locate.
01282        *  @param pos  Index of character to search from.
01283        *  @param n  Number of characters from @a s to search for.
01284        *  @return  Index of start of first occurrence.
01285        *
01286        *  Starting from @a pos, searches forward for the first @a n characters
01287        *  in @a s within this string.  If found, returns the index where it
01288        *  begins.  If not found, returns npos.
01289       */
01290       size_type
01291       find(const _CharT* __s, size_type __pos, size_type __n) const;
01292 
01293       /**
01294        *  @brief  Find position of a string.
01295        *  @param str  String to locate.
01296        *  @param pos  Index of character to search from (default 0).
01297        *  @return  Index of start of first occurrence.
01298        *
01299        *  Starting from @a pos, searches forward for value of @a str within
01300        *  this string.  If found, returns the index where it begins.  If not
01301        *  found, returns npos.
01302       */
01303       size_type
01304       find(const __versa_string& __str, size_type __pos = 0) const
01305       { return this->find(__str.data(), __pos, __str.size()); }
01306 
01307       /**
01308        *  @brief  Find position of a C string.
01309        *  @param s  C string to locate.
01310        *  @param pos  Index of character to search from (default 0).
01311        *  @return  Index of start of first occurrence.
01312        *
01313        *  Starting from @a pos, searches forward for the value of @a s within
01314        *  this string.  If found, returns the index where it begins.  If not
01315        *  found, returns npos.
01316       */
01317       size_type
01318       find(const _CharT* __s, size_type __pos = 0) const
01319       {
01320     __glibcxx_requires_string(__s);
01321     return this->find(__s, __pos, traits_type::length(__s));
01322       }
01323 
01324       /**
01325        *  @brief  Find position of a character.
01326        *  @param c  Character to locate.
01327        *  @param pos  Index of character to search from (default 0).
01328        *  @return  Index of first occurrence.
01329        *
01330        *  Starting from @a pos, searches forward for @a c within this string.
01331        *  If found, returns the index where it was found.  If not found,
01332        *  returns npos.
01333       */
01334       size_type
01335       find(_CharT __c, size_type __pos = 0) const;
01336 
01337       /**
01338        *  @brief  Find last position of a string.
01339        *  @param str  String to locate.
01340        *  @param pos  Index of character to search back from (default end).
01341        *  @return  Index of start of last occurrence.
01342        *
01343        *  Starting from @a pos, searches backward for value of @a str within
01344        *  this string.  If found, returns the index where it begins.  If not
01345        *  found, returns npos.
01346       */
01347       size_type
01348       rfind(const __versa_string& __str, size_type __pos = npos) const
01349       { return this->rfind(__str.data(), __pos, __str.size()); }
01350 
01351       /**
01352        *  @brief  Find last position of a C substring.
01353        *  @param s  C string to locate.
01354        *  @param pos  Index of character to search back from.
01355        *  @param n  Number of characters from s to search for.
01356        *  @return  Index of start of last occurrence.
01357        *
01358        *  Starting from @a pos, searches backward for the first @a n
01359        *  characters in @a s within this string.  If found, returns the index
01360        *  where it begins.  If not found, returns npos.
01361       */
01362       size_type
01363       rfind(const _CharT* __s, size_type __pos, size_type __n) const;
01364 
01365       /**
01366        *  @brief  Find last position of a C string.
01367        *  @param s  C string to locate.
01368        *  @param pos  Index of character to start search at (default end).
01369        *  @return  Index of start of  last occurrence.
01370        *
01371        *  Starting from @a pos, searches backward for the value of @a s within
01372        *  this string.  If found, returns the index where it begins.  If not
01373        *  found, returns npos.
01374       */
01375       size_type
01376       rfind(const _CharT* __s, size_type __pos = npos) const
01377       {
01378     __glibcxx_requires_string(__s);
01379     return this->rfind(__s, __pos, traits_type::length(__s));
01380       }
01381 
01382       /**
01383        *  @brief  Find last position of a character.
01384        *  @param c  Character to locate.
01385        *  @param pos  Index of character to search back from (default end).
01386        *  @return  Index of last occurrence.
01387        *
01388        *  Starting from @a pos, searches backward for @a c within this string.
01389        *  If found, returns the index where it was found.  If not found,
01390        *  returns npos.
01391       */
01392       size_type
01393       rfind(_CharT __c, size_type __pos = npos) const;
01394 
01395       /**
01396        *  @brief  Find position of a character of string.
01397        *  @param str  String containing characters to locate.
01398        *  @param pos  Index of character to search from (default 0).
01399        *  @return  Index of first occurrence.
01400        *
01401        *  Starting from @a pos, searches forward for one of the characters of
01402        *  @a str within this string.  If found, returns the index where it was
01403        *  found.  If not found, returns npos.
01404       */
01405       size_type
01406       find_first_of(const __versa_string& __str, size_type __pos = 0) const
01407       { return this->find_first_of(__str.data(), __pos, __str.size()); }
01408 
01409       /**
01410        *  @brief  Find position of a character of C substring.
01411        *  @param s  String containing characters to locate.
01412        *  @param pos  Index of character to search from (default 0).
01413        *  @param n  Number of characters from s to search for.
01414        *  @return  Index of first occurrence.
01415        *
01416        *  Starting from @a pos, searches forward for one of the first @a n
01417        *  characters of @a s within this string.  If found, returns the index
01418        *  where it was found.  If not found, returns npos.
01419       */
01420       size_type
01421       find_first_of(const _CharT* __s, size_type __pos, size_type __n) const;
01422 
01423       /**
01424        *  @brief  Find position of a character of C string.
01425        *  @param s  String containing characters to locate.
01426        *  @param pos  Index of character to search from (default 0).
01427        *  @return  Index of first occurrence.
01428        *
01429        *  Starting from @a pos, searches forward for one of the characters of
01430        *  @a s within this string.  If found, returns the index where it was
01431        *  found.  If not found, returns npos.
01432       */
01433       size_type
01434       find_first_of(const _CharT* __s, size_type __pos = 0) const
01435       {
01436     __glibcxx_requires_string(__s);
01437     return this->find_first_of(__s, __pos, traits_type::length(__s));
01438       }
01439 
01440       /**
01441        *  @brief  Find position of a character.
01442        *  @param c  Character to locate.
01443        *  @param pos  Index of character to search from (default 0).
01444        *  @return  Index of first occurrence.
01445        *
01446        *  Starting from @a pos, searches forward for the character @a c within
01447        *  this string.  If found, returns the index where it was found.  If
01448        *  not found, returns npos.
01449        *
01450        *  Note: equivalent to find(c, pos).
01451       */
01452       size_type
01453       find_first_of(_CharT __c, size_type __pos = 0) const
01454       { return this->find(__c, __pos); }
01455 
01456       /**
01457        *  @brief  Find last position of a character of string.
01458        *  @param str  String containing characters to locate.
01459        *  @param pos  Index of character to search back from (default end).
01460        *  @return  Index of last occurrence.
01461        *
01462        *  Starting from @a pos, searches backward for one of the characters of
01463        *  @a str within this string.  If found, returns the index where it was
01464        *  found.  If not found, returns npos.
01465       */
01466       size_type
01467       find_last_of(const __versa_string& __str, size_type __pos = npos) const
01468       { return this->find_last_of(__str.data(), __pos, __str.size()); }
01469 
01470       /**
01471        *  @brief  Find last position of a character of C substring.
01472        *  @param s  C string containing characters to locate.
01473        *  @param pos  Index of character to search back from (default end).
01474        *  @param n  Number of characters from s to search for.
01475        *  @return  Index of last occurrence.
01476        *
01477        *  Starting from @a pos, searches backward for one of the first @a n
01478        *  characters of @a s within this string.  If found, returns the index
01479        *  where it was found.  If not found, returns npos.
01480       */
01481       size_type
01482       find_last_of(const _CharT* __s, size_type __pos, size_type __n) const;
01483 
01484       /**
01485        *  @brief  Find last position of a character of C string.
01486        *  @param s  C string containing characters to locate.
01487        *  @param pos  Index of character to search back from (default end).
01488        *  @return  Index of last occurrence.
01489        *
01490        *  Starting from @a pos, searches backward for one of the characters of
01491        *  @a s within this string.  If found, returns the index where it was
01492        *  found.  If not found, returns npos.
01493       */
01494       size_type
01495       find_last_of(const _CharT* __s, size_type __pos = npos) const
01496       {
01497     __glibcxx_requires_string(__s);
01498     return this->find_last_of(__s, __pos, traits_type::length(__s));
01499       }
01500 
01501       /**
01502        *  @brief  Find last position of a character.
01503        *  @param c  Character to locate.
01504        *  @param pos  Index of character to search back from (default 0).
01505        *  @return  Index of last occurrence.
01506        *
01507        *  Starting from @a pos, searches backward for @a c within this string.
01508        *  If found, returns the index where it was found.  If not found,
01509        *  returns npos.
01510        *
01511        *  Note: equivalent to rfind(c, pos).
01512       */
01513       size_type
01514       find_last_of(_CharT __c, size_type __pos = npos) const
01515       { return this->rfind(__c, __pos); }
01516 
01517       /**
01518        *  @brief  Find position of a character not in string.
01519        *  @param str  String containing characters to avoid.
01520        *  @param pos  Index of character to search from (default 0).
01521        *  @return  Index of first occurrence.
01522        *
01523        *  Starting from @a pos, searches forward for a character not contained
01524        *  in @a str within this string.  If found, returns the index where it
01525        *  was found.  If not found, returns npos.
01526       */
01527       size_type
01528       find_first_not_of(const __versa_string& __str, size_type __pos = 0) const
01529       { return this->find_first_not_of(__str.data(), __pos, __str.size()); }
01530 
01531       /**
01532        *  @brief  Find position of a character not in C substring.
01533        *  @param s  C string containing characters to avoid.
01534        *  @param pos  Index of character to search from (default 0).
01535        *  @param n  Number of characters from s to consider.
01536        *  @return  Index of first occurrence.
01537        *
01538        *  Starting from @a pos, searches forward for a character not contained
01539        *  in the first @a n characters of @a s within this string.  If found,
01540        *  returns the index where it was found.  If not found, returns npos.
01541       */
01542       size_type
01543       find_first_not_of(const _CharT* __s, size_type __pos,
01544             size_type __n) const;
01545 
01546       /**
01547        *  @brief  Find position of a character not in C string.
01548        *  @param s  C string containing characters to avoid.
01549        *  @param pos  Index of character to search from (default 0).
01550        *  @return  Index of first occurrence.
01551        *
01552        *  Starting from @a pos, searches forward for a character not contained
01553        *  in @a s within this string.  If found, returns the index where it
01554        *  was found.  If not found, returns npos.
01555       */
01556       size_type
01557       find_first_not_of(const _CharT* __s, size_type __pos = 0) const
01558       {
01559     __glibcxx_requires_string(__s);
01560     return this->find_first_not_of(__s, __pos, traits_type::length(__s));
01561       }
01562 
01563       /**
01564        *  @brief  Find position of a different character.
01565        *  @param c  Character to avoid.
01566        *  @param pos  Index of character to search from (default 0).
01567        *  @return  Index of first occurrence.
01568        *
01569        *  Starting from @a pos, searches forward for a character other than @a c
01570        *  within this string.  If found, returns the index where it was found.
01571        *  If not found, returns npos.
01572       */
01573       size_type
01574       find_first_not_of(_CharT __c, size_type __pos = 0) const;
01575 
01576       /**
01577        *  @brief  Find last position of a character not in string.
01578        *  @param str  String containing characters to avoid.
01579        *  @param pos  Index of character to search from (default 0).
01580        *  @return  Index of first occurrence.
01581        *
01582        *  Starting from @a pos, searches backward for a character not
01583        *  contained in @a str within this string.  If found, returns the index
01584        *  where it was found.  If not found, returns npos.
01585       */
01586       size_type
01587       find_last_not_of(const __versa_string& __str,
01588                size_type __pos = npos) const
01589       { return this->find_last_not_of(__str.data(), __pos, __str.size()); }
01590 
01591       /**
01592        *  @brief  Find last position of a character not in C substring.
01593        *  @param s  C string containing characters to avoid.
01594        *  @param pos  Index of character to search from (default 0).
01595        *  @param n  Number of characters from s to consider.
01596        *  @return  Index of first occurrence.
01597        *
01598        *  Starting from @a pos, searches backward for a character not
01599        *  contained in the first @a n characters of @a s within this string.
01600        *  If found, returns the index where it was found.  If not found,
01601        *  returns npos.
01602       */
01603       size_type
01604       find_last_not_of(const _CharT* __s, size_type __pos,
01605                size_type __n) const;
01606       /**
01607        *  @brief  Find position of a character not in C string.
01608        *  @param s  C string containing characters to avoid.
01609        *  @param pos  Index of character to search from (default 0).
01610        *  @return  Index of first occurrence.
01611        *
01612        *  Starting from @a pos, searches backward for a character not
01613        *  contained in @a s within this string.  If found, returns the index
01614        *  where it was found.  If not found, returns npos.
01615       */
01616       size_type
01617       find_last_not_of(const _CharT* __s, size_type __pos = npos) const
01618       {
01619     __glibcxx_requires_string(__s);
01620     return this->find_last_not_of(__s, __pos, traits_type::length(__s));
01621       }
01622 
01623       /**
01624        *  @brief  Find last position of a different character.
01625        *  @param c  Character to avoid.
01626        *  @param pos  Index of character to search from (default 0).
01627        *  @return  Index of first occurrence.
01628        *
01629        *  Starting from @a pos, searches backward for a character other than
01630        *  @a c within this string.  If found, returns the index where it was
01631        *  found.  If not found, returns npos.
01632       */
01633       size_type
01634       find_last_not_of(_CharT __c, size_type __pos = npos) const;
01635 
01636       /**
01637        *  @brief  Get a substring.
01638        *  @param pos  Index of first character (default 0).
01639        *  @param n  Number of characters in substring (default remainder).
01640        *  @return  The new string.
01641        *  @throw  std::out_of_range  If pos > size().
01642        *
01643        *  Construct and return a new string using the @a n characters starting
01644        *  at @a pos.  If the string is too short, use the remainder of the
01645        *  characters.  If @a pos is beyond the end of the string, out_of_range
01646        *  is thrown.
01647       */
01648       __versa_string
01649       substr(size_type __pos = 0, size_type __n = npos) const
01650       {
01651     return __versa_string(*this, _M_check(__pos, "__versa_string::substr"),
01652                   __n);
01653       }
01654 
01655       /**
01656        *  @brief  Compare to a string.
01657        *  @param str  String to compare against.
01658        *  @return  Integer < 0, 0, or > 0.
01659        *
01660        *  Returns an integer < 0 if this string is ordered before @a str, 0 if
01661        *  their values are equivalent, or > 0 if this string is ordered after
01662        *  @a str.  Determines the effective length rlen of the strings to
01663        *  compare as the smallest of size() and str.size().  The function
01664        *  then compares the two strings by calling traits::compare(data(),
01665        *  str.data(),rlen).  If the result of the comparison is nonzero returns
01666        *  it, otherwise the shorter one is ordered first.
01667       */
01668       int
01669       compare(const __versa_string& __str) const
01670       {
01671     if (this->_M_compare(__str))
01672       return 0;
01673 
01674     const size_type __size = this->size();
01675     const size_type __osize = __str.size();
01676     const size_type __len = std::min(__size, __osize);
01677 
01678     int __r = traits_type::compare(this->_M_data(), __str.data(), __len);
01679     if (!__r)
01680       __r =  __size - __osize;
01681     return __r;
01682       }
01683 
01684       /**
01685        *  @brief  Compare substring to a string.
01686        *  @param pos  Index of first character of substring.
01687        *  @param n  Number of characters in substring.
01688        *  @param str  String to compare against.
01689        *  @return  Integer < 0, 0, or > 0.
01690        *
01691        *  Form the substring of this string from the @a n characters starting
01692        *  at @a pos.  Returns an integer < 0 if the substring is ordered
01693        *  before @a str, 0 if their values are equivalent, or > 0 if the
01694        *  substring is ordered after @a str.  Determines the effective length
01695        *  rlen of the strings to compare as the smallest of the length of the
01696        *  substring and @a str.size().  The function then compares the two
01697        *  strings by calling traits::compare(substring.data(),str.data(),rlen).
01698        *  If the result of the comparison is nonzero returns it, otherwise the
01699        *  shorter one is ordered first.
01700       */
01701       int
01702       compare(size_type __pos, size_type __n,
01703           const __versa_string& __str) const;
01704 
01705       /**
01706        *  @brief  Compare substring to a substring.
01707        *  @param pos1  Index of first character of substring.
01708        *  @param n1  Number of characters in substring.
01709        *  @param str  String to compare against.
01710        *  @param pos2  Index of first character of substring of str.
01711        *  @param n2  Number of characters in substring of str.
01712        *  @return  Integer < 0, 0, or > 0.
01713        *
01714        *  Form the substring of this string from the @a n1 characters starting
01715        *  at @a pos1.  Form the substring of @a str from the @a n2 characters
01716        *  starting at @a pos2.  Returns an integer < 0 if this substring is
01717        *  ordered before the substring of @a str, 0 if their values are
01718        *  equivalent, or > 0 if this substring is ordered after the substring
01719        *  of @a str.  Determines the effective length rlen of the strings
01720        *  to compare as the smallest of the lengths of the substrings.  The
01721        *  function then compares the two strings by calling
01722        *  traits::compare(substring.data(),str.substr(pos2,n2).data(),rlen).
01723        *  If the result of the comparison is nonzero returns it, otherwise the
01724        *  shorter one is ordered first.
01725       */
01726       int
01727       compare(size_type __pos1, size_type __n1, const __versa_string& __str,
01728           size_type __pos2, size_type __n2) const;
01729 
01730       /**
01731        *  @brief  Compare to a C string.
01732        *  @param s  C string to compare against.
01733        *  @return  Integer < 0, 0, or > 0.
01734        *
01735        *  Returns an integer < 0 if this string is ordered before @a s, 0 if
01736        *  their values are equivalent, or > 0 if this string is ordered after
01737        *  @a s.  Determines the effective length rlen of the strings to
01738        *  compare as the smallest of size() and the length of a string
01739        *  constructed from @a s.  The function then compares the two strings
01740        *  by calling traits::compare(data(),s,rlen).  If the result of the
01741        *  comparison is nonzero returns it, otherwise the shorter one is
01742        *  ordered first.
01743       */
01744       int
01745       compare(const _CharT* __s) const;
01746 
01747       // _GLIBCXX_RESOLVE_LIB_DEFECTS
01748       // 5 String::compare specification questionable
01749       /**
01750        *  @brief  Compare substring to a C string.
01751        *  @param pos  Index of first character of substring.
01752        *  @param n1  Number of characters in substring.
01753        *  @param s  C string to compare against.
01754        *  @return  Integer < 0, 0, or > 0.
01755        *
01756        *  Form the substring of this string from the @a n1 characters starting
01757        *  at @a pos.  Returns an integer < 0 if the substring is ordered
01758        *  before @a s, 0 if their values are equivalent, or > 0 if the
01759        *  substring is ordered after @a s.  Determines the effective length
01760        *  rlen of the strings to compare as the smallest of the length of the 
01761        *  substring and the length of a string constructed from @a s.  The
01762        *  function then compares the two string by calling
01763        *  traits::compare(substring.data(),s,rlen).  If the result of the
01764        *  comparison is nonzero returns it, otherwise the shorter one is
01765        *  ordered first.
01766       */
01767       int
01768       compare(size_type __pos, size_type __n1, const _CharT* __s) const;
01769 
01770       /**
01771        *  @brief  Compare substring against a character array.
01772        *  @param pos1  Index of first character of substring.
01773        *  @param n1  Number of characters in substring.
01774        *  @param s  character array to compare against.
01775        *  @param n2  Number of characters of s.
01776        *  @return  Integer < 0, 0, or > 0.
01777        *
01778        *  Form the substring of this string from the @a n1 characters starting
01779        *  at @a pos1.  Form a string from the first @a n2 characters of @a s.
01780        *  Returns an integer < 0 if this substring is ordered before the string
01781        *  from @a s, 0 if their values are equivalent, or > 0 if this substring
01782        *  is ordered after the string from @a s.   Determines the effective
01783        *  length rlen of the strings to compare as the smallest of the length
01784        *  of the substring and @a n2.  The function then compares the two
01785        *  strings by calling traits::compare(substring.data(),s,rlen).  If the
01786        *  result of the comparison is nonzero returns it, otherwise the shorter
01787        *  one is ordered first.
01788        *
01789        *  NB: s must have at least n2 characters, '\0' has no special
01790        *  meaning.
01791       */
01792       int
01793       compare(size_type __pos, size_type __n1, const _CharT* __s,
01794           size_type __n2) const;
01795     };
01796 
01797   // operator+
01798   /**
01799    *  @brief  Concatenate two strings.
01800    *  @param lhs  First string.
01801    *  @param rhs  Last string.
01802    *  @return  New string with value of @a lhs followed by @a rhs.
01803    */
01804   template<typename _CharT, typename _Traits, typename _Alloc,
01805        template <typename, typename, typename> class _Base>
01806     __versa_string<_CharT, _Traits, _Alloc, _Base>
01807     operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
01808           const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs);
01809 
01810   /**
01811    *  @brief  Concatenate C string and string.
01812    *  @param lhs  First string.
01813    *  @param rhs  Last string.
01814    *  @return  New string with value of @a lhs followed by @a rhs.
01815    */
01816   template<typename _CharT, typename _Traits, typename _Alloc,
01817        template <typename, typename, typename> class _Base>
01818     __versa_string<_CharT, _Traits, _Alloc, _Base>
01819     operator+(const _CharT* __lhs,
01820           const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs);
01821 
01822   /**
01823    *  @brief  Concatenate character and string.
01824    *  @param lhs  First string.
01825    *  @param rhs  Last string.
01826    *  @return  New string with @a lhs followed by @a rhs.
01827    */
01828   template<typename _CharT, typename _Traits, typename _Alloc,
01829        template <typename, typename, typename> class _Base>
01830     __versa_string<_CharT, _Traits, _Alloc, _Base>
01831     operator+(_CharT __lhs,
01832           const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs);
01833 
01834   /**
01835    *  @brief  Concatenate string and C string.
01836    *  @param lhs  First string.
01837    *  @param rhs  Last string.
01838    *  @return  New string with @a lhs followed by @a rhs.
01839    */
01840   template<typename _CharT, typename _Traits, typename _Alloc,
01841        template <typename, typename, typename> class _Base>
01842     __versa_string<_CharT, _Traits, _Alloc, _Base>
01843     operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
01844           const _CharT* __rhs);
01845 
01846   /**
01847    *  @brief  Concatenate string and character.
01848    *  @param lhs  First string.
01849    *  @param rhs  Last string.
01850    *  @return  New string with @a lhs followed by @a rhs.
01851    */
01852   template<typename _CharT, typename _Traits, typename _Alloc,
01853        template <typename, typename, typename> class _Base>
01854     __versa_string<_CharT, _Traits, _Alloc, _Base>
01855     operator+(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
01856           _CharT __rhs);
01857 
01858   // operator ==
01859   /**
01860    *  @brief  Test equivalence of two strings.
01861    *  @param lhs  First string.
01862    *  @param rhs  Second string.
01863    *  @return  True if @a lhs.compare(@a rhs) == 0.  False otherwise.
01864    */
01865   template<typename _CharT, typename _Traits, typename _Alloc,
01866        template <typename, typename, typename> class _Base>
01867     inline bool
01868     operator==(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
01869            const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
01870     { return __lhs.compare(__rhs) == 0; }
01871 
01872   /**
01873    *  @brief  Test equivalence of C string and string.
01874    *  @param lhs  C string.
01875    *  @param rhs  String.
01876    *  @return  True if @a rhs.compare(@a lhs) == 0.  False otherwise.
01877    */
01878   template<typename _CharT, typename _Traits, typename _Alloc,
01879        template <typename, typename, typename> class _Base>
01880     inline bool
01881     operator==(const _CharT* __lhs,
01882            const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
01883     { return __rhs.compare(__lhs) == 0; }
01884 
01885   /**
01886    *  @brief  Test equivalence of string and C string.
01887    *  @param lhs  String.
01888    *  @param rhs  C string.
01889    *  @return  True if @a lhs.compare(@a rhs) == 0.  False otherwise.
01890    */
01891   template<typename _CharT, typename _Traits, typename _Alloc,
01892        template <typename, typename, typename> class _Base>
01893     inline bool
01894     operator==(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
01895            const _CharT* __rhs)
01896     { return __lhs.compare(__rhs) == 0; }
01897 
01898   // operator !=
01899   /**
01900    *  @brief  Test difference of two strings.
01901    *  @param lhs  First string.
01902    *  @param rhs  Second string.
01903    *  @return  True if @a lhs.compare(@a rhs) != 0.  False otherwise.
01904    */
01905   template<typename _CharT, typename _Traits, typename _Alloc,
01906        template <typename, typename, typename> class _Base>
01907     inline bool
01908     operator!=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
01909            const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
01910     { return __rhs.compare(__lhs) != 0; }
01911 
01912   /**
01913    *  @brief  Test difference of C string and string.
01914    *  @param lhs  C string.
01915    *  @param rhs  String.
01916    *  @return  True if @a rhs.compare(@a lhs) != 0.  False otherwise.
01917    */
01918   template<typename _CharT, typename _Traits, typename _Alloc,
01919        template <typename, typename, typename> class _Base>
01920     inline bool
01921     operator!=(const _CharT* __lhs,
01922            const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
01923     { return __rhs.compare(__lhs) != 0; }
01924 
01925   /**
01926    *  @brief  Test difference of string and C string.
01927    *  @param lhs  String.
01928    *  @param rhs  C string.
01929    *  @return  True if @a lhs.compare(@a rhs) != 0.  False otherwise.
01930    */
01931   template<typename _CharT, typename _Traits, typename _Alloc,
01932        template <typename, typename, typename> class _Base>
01933     inline bool
01934     operator!=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
01935            const _CharT* __rhs)
01936     { return __lhs.compare(__rhs) != 0; }
01937 
01938   // operator <
01939   /**
01940    *  @brief  Test if string precedes string.
01941    *  @param lhs  First string.
01942    *  @param rhs  Second string.
01943    *  @return  True if @a lhs precedes @a rhs.  False otherwise.
01944    */
01945   template<typename _CharT, typename _Traits, typename _Alloc,
01946        template <typename, typename, typename> class _Base>
01947     inline bool
01948     operator<(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
01949           const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
01950     { return __lhs.compare(__rhs) < 0; }
01951 
01952   /**
01953    *  @brief  Test if string precedes C string.
01954    *  @param lhs  String.
01955    *  @param rhs  C string.
01956    *  @return  True if @a lhs precedes @a rhs.  False otherwise.
01957    */
01958   template<typename _CharT, typename _Traits, typename _Alloc,
01959        template <typename, typename, typename> class _Base>
01960     inline bool
01961     operator<(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
01962           const _CharT* __rhs)
01963     { return __lhs.compare(__rhs) < 0; }
01964 
01965   /**
01966    *  @brief  Test if C string precedes string.
01967    *  @param lhs  C string.
01968    *  @param rhs  String.
01969    *  @return  True if @a lhs precedes @a rhs.  False otherwise.
01970    */
01971   template<typename _CharT, typename _Traits, typename _Alloc,
01972        template <typename, typename, typename> class _Base>
01973     inline bool
01974     operator<(const _CharT* __lhs,
01975           const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
01976     { return __rhs.compare(__lhs) > 0; }
01977 
01978   // operator >
01979   /**
01980    *  @brief  Test if string follows string.
01981    *  @param lhs  First string.
01982    *  @param rhs  Second string.
01983    *  @return  True if @a lhs follows @a rhs.  False otherwise.
01984    */
01985   template<typename _CharT, typename _Traits, typename _Alloc,
01986        template <typename, typename, typename> class _Base>
01987     inline bool
01988     operator>(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
01989           const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
01990     { return __lhs.compare(__rhs) > 0; }
01991 
01992   /**
01993    *  @brief  Test if string follows C string.
01994    *  @param lhs  String.
01995    *  @param rhs  C string.
01996    *  @return  True if @a lhs follows @a rhs.  False otherwise.
01997    */
01998   template<typename _CharT, typename _Traits, typename _Alloc,
01999        template <typename, typename, typename> class _Base>
02000     inline bool
02001     operator>(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02002           const _CharT* __rhs)
02003     { return __lhs.compare(__rhs) > 0; }
02004 
02005   /**
02006    *  @brief  Test if C string follows string.
02007    *  @param lhs  C string.
02008    *  @param rhs  String.
02009    *  @return  True if @a lhs follows @a rhs.  False otherwise.
02010    */
02011   template<typename _CharT, typename _Traits, typename _Alloc,
02012        template <typename, typename, typename> class _Base>
02013     inline bool
02014     operator>(const _CharT* __lhs,
02015           const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02016     { return __rhs.compare(__lhs) < 0; }
02017 
02018   // operator <=
02019   /**
02020    *  @brief  Test if string doesn't follow string.
02021    *  @param lhs  First string.
02022    *  @param rhs  Second string.
02023    *  @return  True if @a lhs doesn't follow @a rhs.  False otherwise.
02024    */
02025   template<typename _CharT, typename _Traits, typename _Alloc,
02026        template <typename, typename, typename> class _Base>
02027     inline bool
02028     operator<=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02029            const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02030     { return __lhs.compare(__rhs) <= 0; }
02031 
02032   /**
02033    *  @brief  Test if string doesn't follow C string.
02034    *  @param lhs  String.
02035    *  @param rhs  C string.
02036    *  @return  True if @a lhs doesn't follow @a rhs.  False otherwise.
02037    */
02038   template<typename _CharT, typename _Traits, typename _Alloc,
02039        template <typename, typename, typename> class _Base>
02040     inline bool
02041     operator<=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02042            const _CharT* __rhs)
02043     { return __lhs.compare(__rhs) <= 0; }
02044 
02045   /**
02046    *  @brief  Test if C string doesn't follow string.
02047    *  @param lhs  C string.
02048    *  @param rhs  String.
02049    *  @return  True if @a lhs doesn't follow @a rhs.  False otherwise.
02050    */
02051   template<typename _CharT, typename _Traits, typename _Alloc,
02052        template <typename, typename, typename> class _Base>
02053     inline bool
02054     operator<=(const _CharT* __lhs,
02055            const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02056     { return __rhs.compare(__lhs) >= 0; }
02057 
02058   // operator >=
02059   /**
02060    *  @brief  Test if string doesn't precede string.
02061    *  @param lhs  First string.
02062    *  @param rhs  Second string.
02063    *  @return  True if @a lhs doesn't precede @a rhs.  False otherwise.
02064    */
02065   template<typename _CharT, typename _Traits, typename _Alloc,
02066        template <typename, typename, typename> class _Base>
02067     inline bool
02068     operator>=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02069            const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02070     { return __lhs.compare(__rhs) >= 0; }
02071 
02072   /**
02073    *  @brief  Test if string doesn't precede C string.
02074    *  @param lhs  String.
02075    *  @param rhs  C string.
02076    *  @return  True if @a lhs doesn't precede @a rhs.  False otherwise.
02077    */
02078   template<typename _CharT, typename _Traits, typename _Alloc,
02079        template <typename, typename, typename> class _Base>
02080     inline bool
02081     operator>=(const __versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02082            const _CharT* __rhs)
02083     { return __lhs.compare(__rhs) >= 0; }
02084 
02085   /**
02086    *  @brief  Test if C string doesn't precede string.
02087    *  @param lhs  C string.
02088    *  @param rhs  String.
02089    *  @return  True if @a lhs doesn't precede @a rhs.  False otherwise.
02090    */
02091   template<typename _CharT, typename _Traits, typename _Alloc,
02092        template <typename, typename, typename> class _Base>
02093     inline bool
02094     operator>=(const _CharT* __lhs,
02095            const __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02096     { return __rhs.compare(__lhs) <= 0; }
02097 
02098   /**
02099    *  @brief  Swap contents of two strings.
02100    *  @param lhs  First string.
02101    *  @param rhs  Second string.
02102    *
02103    *  Exchanges the contents of @a lhs and @a rhs in constant time.
02104    */
02105   template<typename _CharT, typename _Traits, typename _Alloc,
02106        template <typename, typename, typename> class _Base>
02107     inline void
02108     swap(__versa_string<_CharT, _Traits, _Alloc, _Base>& __lhs,
02109      __versa_string<_CharT, _Traits, _Alloc, _Base>& __rhs)
02110     { __lhs.swap(__rhs); }
02111 
02112 } // namespace __gnu_cxx
02113 
02114 namespace std
02115 {
02116   /**
02117    *  @brief  Read stream into a string.
02118    *  @param is  Input stream.
02119    *  @param str  Buffer to store into.
02120    *  @return  Reference to the input stream.
02121    *
02122    *  Stores characters from @a is into @a str until whitespace is found, the
02123    *  end of the stream is encountered, or str.max_size() is reached.  If
02124    *  is.width() is non-zero, that is the limit on the number of characters
02125    *  stored into @a str.  Any previous contents of @a str are erased.
02126    */
02127   template<typename _CharT, typename _Traits, typename _Alloc,
02128            template <typename, typename, typename> class _Base>
02129     basic_istream<_CharT, _Traits>&
02130     operator>>(basic_istream<_CharT, _Traits>& __is,
02131            __gnu_cxx::__versa_string<_CharT, _Traits,
02132                                      _Alloc, _Base>& __str);
02133 
02134   /**
02135    *  @brief  Write string to a stream.
02136    *  @param os  Output stream.
02137    *  @param str  String to write out.
02138    *  @return  Reference to the output stream.
02139    *
02140    *  Output characters of @a str into os following the same rules as for
02141    *  writing a C string.
02142    */
02143   template<typename _CharT, typename _Traits, typename _Alloc,
02144            template <typename, typename, typename> class _Base>
02145     basic_ostream<_CharT, _Traits>&
02146     operator<<(basic_ostream<_CharT, _Traits>& __os,
02147            const __gnu_cxx::__versa_string<_CharT, _Traits,
02148                                            _Alloc, _Base>& __str);
02149 
02150   /**
02151    *  @brief  Read a line from stream into a string.
02152    *  @param is  Input stream.
02153    *  @param str  Buffer to store into.
02154    *  @param delim  Character marking end of line.
02155    *  @return  Reference to the input stream.
02156    *
02157    *  Stores characters from @a is into @a str until @a delim is found, the
02158    *  end of the stream is encountered, or str.max_size() is reached.  If
02159    *  is.width() is non-zero, that is the limit on the number of characters
02160    *  stored into @a str.  Any previous contents of @a str are erased.  If @a
02161    *  delim was encountered, it is extracted but not stored into @a str.
02162    */
02163   template<typename _CharT, typename _Traits, typename _Alloc,
02164            template <typename, typename, typename> class _Base>
02165     basic_istream<_CharT, _Traits>&
02166     getline(basic_istream<_CharT, _Traits>& __is,
02167         __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str,
02168         _CharT __delim);
02169 
02170   /**
02171    *  @brief  Read a line from stream into a string.
02172    *  @param is  Input stream.
02173    *  @param str  Buffer to store into.
02174    *  @return  Reference to the input stream.
02175    *
02176    *  Stores characters from is into @a str until '\n' is found, the end of
02177    *  the stream is encountered, or str.max_size() is reached.  If is.width()
02178    *  is non-zero, that is the limit on the number of characters stored into
02179    *  @a str.  Any previous contents of @a str are erased.  If end of line was
02180    *  encountered, it is extracted but not stored into @a str.
02181    */
02182   template<typename _CharT, typename _Traits, typename _Alloc,
02183            template <typename, typename, typename> class _Base>
02184     inline basic_istream<_CharT, _Traits>&
02185     getline(basic_istream<_CharT, _Traits>& __is,
02186         __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>& __str)
02187     { return getline(__is, __str, __is.widen('\n')); }      
02188 
02189 } // namespace std
02190 
02191 #ifndef _GLIBCXX_EXPORT_TEMPLATE
02192 # include "vstring.tcc" 
02193 #endif
02194 
02195 #endif /* _VSTRING_H */

Generated on Thu Nov 1 17:36:05 2007 for libstdc++ by  doxygen 1.5.1