std_cwctype.h: Include std_cwchar.h for wint_t.
authorBenjamin Kosnik <bkoz@redhat.com>
Thu, 4 Jan 2001 04:21:42 +0000 (04:21 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Thu, 4 Jan 2001 04:21:42 +0000 (04:21 +0000)
2001-01-03  Benjamin Kosnik  <bkoz@redhat.com>

* include/c_std/bits/std_cwctype.h: Include std_cwchar.h for wint_t.
* testsuite/17_intro/header_cwctype.cc (main): New file.

* src/Makefile.am (base_headers): Change.
* include/bits/std_string.h: And here.
* include/bits/string.tcc: Tweaks, move to...
* include/bits/basic_string.tcc: ...Here.
* src/string-inst.cc: Simplify, just instantiate the whole class,
not member-by-member.

From-SVN: r38679

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/basic_string.tcc [new file with mode: 0644]
libstdc++-v3/include/bits/std_string.h
libstdc++-v3/include/bits/string.tcc [deleted file]
libstdc++-v3/include/c_std/bits/std_cwctype.h
libstdc++-v3/src/Makefile.am
libstdc++-v3/src/Makefile.in
libstdc++-v3/src/string-inst.cc

index 44adda75873f47b8c5fb00c380f0ec328eaf5c15..7c644aff638d74b83e6e024fb251d71e14e94499 100644 (file)
@@ -1,3 +1,15 @@
+2001-01-03  Benjamin Kosnik  <bkoz@redhat.com>
+
+       * include/c_std/bits/std_cwctype.h: Include std_cwchar.h for wint_t.
+       * testsuite/17_intro/header_cwctype.cc (main): New file.
+
+       * src/Makefile.am (base_headers): Change.
+       * include/bits/std_string.h: And here.
+       * include/bits/string.tcc: Tweaks, move to...
+       * include/bits/basic_string.tcc: ...Here.
+       * src/string-inst.cc: Simplify, just instantiate the whole class,
+       not member-by-member.
+
 2001-01-02  Benjamin Kosnik  <bkoz@redhat.com>
 
        * acinclude.m4 (GLIBCPP_ENABLD_CSTDIO): Add in default value.
diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc
new file mode 100644 (file)
index 0000000..a9ac2c9
--- /dev/null
@@ -0,0 +1,841 @@
+// Components for manipulating sequences of characters -*- C++ -*-
+
+// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+//
+// ISO C++ 14882: 21  Strings library
+//
+
+// This file is included by <string>.  It is not meant to be included
+// separately.
+
+// Written by Jason Merrill based upon the specification by Takanori Adachi
+// in ANSI X3J16/94-0013R2.  Rewritten by Nathan Myers to ISO-14882.
+
+#ifndef _CPP_BITS_STRING_TCC
+#define _CPP_BITS_STRING_TCC 1
+
+namespace std
+{
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    const _CharT 
+    basic_string<_CharT, _Traits, _Alloc>::
+    _Rep::_S_terminal = _CharT();
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    const typename basic_string<_CharT, _Traits, _Alloc>::size_type 
+    basic_string<_CharT, _Traits, _Alloc>::
+    _Rep::_S_max_size = (((npos - sizeof(_Rep))/sizeof(_CharT)) - 1) / 4;
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    const typename basic_string<_CharT, _Traits, _Alloc>::size_type
+    basic_string<_CharT, _Traits, _Alloc>::npos;
+
+  // Linker sets _S_empty_rep_storage to all 0s (one reference, empty string)
+  // at static init time (before static ctors are run).
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    typename basic_string<_CharT, _Traits, _Alloc>::size_type
+    basic_string<_CharT, _Traits, _Alloc>::_S_empty_rep_storage[
+    (sizeof(_Rep) + sizeof(_CharT) + sizeof(size_type) - 1)/sizeof(size_type)];
+
+  // NB: This is the special case for Input Iterators, used in
+  // istreambuf_iterators, etc.
+  // Input Iterators have a cost structure very different from
+  // pointers, calling for a different coding style.
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    template<typename _InIter>
+      _CharT*
+      basic_string<_CharT, _Traits, _Alloc>::
+      _S_construct(_InIter __beg, _InIter __end, const _Alloc& __a,
+                  input_iterator_tag)
+      {
+       if (__beg == __end && __a == _Alloc())
+         return _S_empty_rep()._M_refcopy();
+       // Avoid reallocation for common case.
+       _CharT __buf[100];
+       size_type __i = 0;
+       while (__beg != __end && __i < sizeof(__buf) / sizeof(_CharT))
+         { 
+           __buf[__i++] = *__beg; 
+           ++__beg; 
+         }
+       _Rep* __r = _Rep::_S_create(__i, __a);
+       traits_type::copy(__r->_M_refdata(), __buf, __i);
+       __r->_M_length = __i;
+       try {
+         // NB: this loop looks precisely this way because
+         // it avoids comparing __beg != __end any more
+         // than strictly necessary; != might be expensive!
+         for (;;)
+           {
+             _CharT* __p = __r->_M_refdata() + __r->_M_length;
+             _CharT* __last = __r->_M_refdata() + __r->_M_capacity;
+             for (;;)
+               {
+                 if (__beg == __end)
+                   {
+                     __r->_M_length = __p - __r->_M_refdata();
+                     *__p = _Rep::_S_terminal;       // grrr.
+                     return __r->_M_refdata();
+                   }
+                 if (__p == __last)
+                   break;
+                 *__p++ = *__beg; 
+                 ++__beg;
+               }
+             // Allocate more space.
+             size_type __len = __p - __r->_M_refdata();
+             _Rep* __another = _Rep::_S_create(__len + 1, __a);
+             traits_type::copy(__another->_M_refdata(), 
+                               __r->_M_refdata(), __len);
+             __r->_M_destroy(__a);
+             __r = __another;
+             __r->_M_length = __len;
+           }
+       }
+       catch (...) {
+           __r->_M_destroy(__a); 
+           throw;
+       }
+       return 0;
+      }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    template <class _InIter>
+      _CharT*
+      basic_string<_CharT,_Traits,_Alloc>::
+      _S_construct(_InIter __beg, _InIter __end, const _Alloc& __a, 
+                  forward_iterator_tag)
+      {
+       size_type __dnew = static_cast<size_type>(distance(__beg, __end));
+
+       if (__beg == __end && __a == _Alloc())
+         return _S_empty_rep()._M_refcopy();
+
+       // Check for out_of_range and length_error exceptions.
+       _Rep* __r = _Rep::_S_create(__dnew, __a);
+       try { 
+         _S_copy_chars(__r->_M_refdata(), __beg, __end); 
+       }
+       catch (...) { 
+         __r->_M_destroy(__a); 
+         throw; 
+       }
+       __r->_M_length = __dnew;
+
+       __r->_M_refdata()[__dnew] = _Rep::_S_terminal;  // grrr.
+       return __r->_M_refdata();
+      }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    _CharT*
+    basic_string<_CharT,_Traits, _Alloc>::
+    _S_construct(size_type __n, _CharT __c, const _Alloc& __a)
+    {
+      if (__n == 0 && __a == _Alloc())
+       return _S_empty_rep()._M_refcopy();
+
+      // Check for out_of_range and length_error exceptions.
+      _Rep* __r = _Rep::_S_create(__n, __a);
+      try { 
+       if (__n) 
+         traits_type::assign(__r->_M_refdata(), __n, __c); 
+      }
+      catch (...) { 
+       __r->_M_destroy(__a); 
+       throw; 
+      }
+      __r->_M_length = __n;
+      __r->_M_refdata()[__n] = _Rep::_S_terminal;  // grrr
+      return __r->_M_refdata();
+    }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>::
+    basic_string(const basic_string& __str)
+    : _M_dataplus(__str._M_rep()->_M_grab(_Alloc(), __str.get_allocator()),
+                __str.get_allocator())
+    { }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>::
+    basic_string(const _Alloc& __a)
+    : _M_dataplus(_S_construct(size_type(), _CharT(), __a), __a)
+    { }
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>::
+    basic_string(const basic_string& __str, size_type __pos, size_type __n)
+    : _M_dataplus(_S_construct(__str._M_check(__pos), 
+                              __str._M_fold(__pos, __n), _Alloc()), _Alloc())
+    { }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>::
+    basic_string(const basic_string& __str, size_type __pos,
+                size_type __n, const _Alloc& __a)
+    : _M_dataplus(_S_construct(__str._M_check(__pos), 
+                              __str._M_fold(__pos, __n), __a), __a)
+    { }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>::
+    basic_string(const _CharT* __s, size_type __n, const _Alloc& __a)
+    : _M_dataplus(_S_construct(__s, __s + __n, __a), __a)
+    { }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>::
+    basic_string(const _CharT* __s, const _Alloc& __a)
+    : _M_dataplus(_S_construct(__s, __s + traits_type::length(__s), __a), __a)
+    { }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>::
+    basic_string(size_type __n, _CharT __c, const _Alloc& __a)
+    : _M_dataplus(_S_construct(__n, __c, __a), __a)
+    { }
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    template<typename _InputIter>
+    basic_string<_CharT, _Traits, _Alloc>::
+    basic_string(_InputIter __beg, _InputIter __end, const _Alloc& __a)
+    : _M_dataplus(_S_construct(__beg, __end, __a), __a)
+    { }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>&
+    basic_string<_CharT, _Traits, _Alloc>::assign(const basic_string& __str)
+    {
+      if (_M_rep() != __str._M_rep())
+       {
+         // XXX MT
+         allocator_type __a = this->get_allocator();
+         _CharT* __tmp = __str._M_rep()->_M_grab(__a, __str.get_allocator());
+         _M_rep()->_M_dispose(__a);
+         _M_data(__tmp);
+       }
+      return *this;
+    }
+  
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    void
+    basic_string<_CharT, _Traits, _Alloc>::_Rep::
+    _M_destroy(const _Alloc& __a) throw ()
+    {
+      size_type __size = sizeof(_Rep) + (_M_capacity + 1) * sizeof(_CharT);
+      _Raw_bytes_alloc(__a).deallocate(reinterpret_cast<char*>(this), __size);
+    }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    void
+    basic_string<_CharT, _Traits, _Alloc>::_M_leak_hard()
+    {
+      if (_M_rep()->_M_is_shared()) 
+       _M_mutate(0, 0, 0);
+      _M_rep()->_M_set_leaked();
+    }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    void
+    basic_string<_CharT, _Traits, _Alloc>::
+    _M_mutate(size_type __pos, size_type __len1, size_type __len2)
+    {
+      size_type       __old_size = this->size();
+      const size_type __new_size = __old_size + __len2 - __len1;
+      const _CharT*        __src = _M_data()  + __pos + __len1;
+      const size_type __how_much = __old_size - __pos - __len1;
+      
+      if (_M_rep()->_M_is_shared() || __new_size > capacity())
+       {
+         // Must reallocate.
+         allocator_type __a = get_allocator();
+         _Rep* __r = _Rep::_S_create(__new_size, __a);
+         try {
+           if (__pos)
+             traits_type::copy(__r->_M_refdata(), _M_data(), __pos);
+           if (__how_much)
+             traits_type::copy(__r->_M_refdata() + __pos + __len2, 
+                               __src, __how_much);
+         }
+         catch (...) { 
+           __r->_M_dispose(get_allocator()); 
+           throw; 
+         }
+         _M_rep()->_M_dispose(__a);
+         _M_data(__r->_M_refdata());
+      }
+      else if (__how_much && __len1 != __len2)
+       {
+         // Work in-place
+         traits_type::move(_M_data() + __pos + __len2, __src, __how_much);
+       }
+      _M_rep()->_M_set_sharable();
+      _M_rep()->_M_length = __new_size;
+      _M_data()[__new_size] = _Rep::_S_terminal; // grrr. (per 21.3.4)
+    // You cannot leave those LWG people alone for a second.
+    }
+  
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    void
+    basic_string<_CharT, _Traits, _Alloc>::reserve(size_type __res)
+    {
+      if (__res > this->capacity() || _M_rep()->_M_is_shared())
+        {
+         __LENGTHERROR(__res > this->max_size());
+         allocator_type __a = get_allocator();
+         _CharT* __tmp = _M_rep()->_M_clone(__a, __res - this->size());
+         _M_rep()->_M_dispose(__a);
+         _M_data(__tmp);
+        }
+    }
+  
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    void basic_string<_CharT, _Traits, _Alloc>::swap(basic_string& __s)
+    {
+      if (_M_rep()->_M_is_leaked()) 
+       _M_rep()->_M_set_sharable();
+      if (__s._M_rep()->_M_is_leaked()) 
+       __s._M_rep()->_M_set_sharable();
+      if (this->get_allocator() == __s.get_allocator())
+       {
+         _CharT* __tmp = _M_data();
+         _M_data(__s._M_data());
+         __s._M_data(__tmp);
+       }
+      // The code below can usually be optimized away.
+      else 
+       {
+         basic_string __tmp1(_M_ibegin(), _M_iend(), __s.get_allocator());
+         basic_string __tmp2(__s._M_ibegin(), __s._M_iend(), 
+                             this->get_allocator());
+         *this = __tmp2;
+         __s = __tmp1;
+       }
+    }
+
+#ifdef _GLIBCPP_ALLOC_CONTROL
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    bool (*basic_string<_CharT, _Traits, _Alloc>::_Rep::_S_excess_slop) 
+    (size_t, size_t) = 
+    basic_string<_CharT, _Traits, _Alloc>::_Rep::_S_default_excess;
+#endif
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>::_Rep*
+    basic_string<_CharT, _Traits, _Alloc>::_Rep::
+    _S_create(size_t __capacity, const _Alloc& __alloc)
+    {
+#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
+      // 83.  String::npos vs. string::max_size()
+      typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
+      __LENGTHERROR(__capacity > _S_max_size);
+#else
+      __LENGTHERROR(__capacity == npos);
+#endif
+
+      // NB: Need an array of char_type[__capacity], plus a
+      // terminating null char_type() element, plus enough for the
+      // _Rep data structure. Whew. Seemingly so needy, yet so elemental.
+      size_t __size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep);
+      // NB: Might throw, but no worries about a leak, mate: _Rep()
+      // does not throw.
+      void* __place = _Raw_bytes_alloc(__alloc).allocate(__size);
+      _Rep *__p = new (__place) _Rep;
+      __p->_M_capacity = __capacity;
+      __p->_M_set_sharable();  // one reference
+      __p->_M_length = 0;
+      return __p;
+    }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    _CharT*
+    basic_string<_CharT, _Traits, _Alloc>::_Rep::
+    _M_clone(const _Alloc& __alloc, size_type __res)
+    {
+      _Rep* __r = _Rep::_S_create(_M_length + __res, __alloc);
+      if (_M_length)
+       {
+         try { 
+           traits_type::copy(__r->_M_refdata(), _M_refdata(), _M_length); 
+         }
+         catch (...)  { 
+           __r->_M_destroy(__alloc); 
+           throw; 
+         }
+       }
+      __r->_M_length = _M_length;
+      return __r->_M_refdata();
+    }
+  
+  template<typename _CharT, typename _Traits, typename _Alloc>
+  inline bool
+#ifdef _GLIBCPP_ALLOC_CONTROL
+    basic_string<_CharT, _Traits, _Alloc>::_Rep::
+    _S_default_excess(size_t __s, size_t __r)
+#else
+    basic_string<_CharT, _Traits, _Alloc>::_Rep::
+    _S_excess_slop(size_t __s, size_t __r)
+#endif
+    {
+      return 2 * (__s <= 16 ? 16 : __s) < __r;
+    }
+  
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    void
+    basic_string<_CharT, _Traits, _Alloc>::resize(size_type __n, _CharT __c)
+    {
+      __LENGTHERROR(__n > max_size());
+      size_type __size = this->size();
+      if (__size < __n)
+       this->append(__n - __size, __c);
+      else if (__n < __size)
+       this->erase(__n);
+      // else nothing (in particular, avoid calling _M_mutate() unnecessarily.)
+    }
+  
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    template<typename _InputIter>
+      basic_string<_CharT, _Traits, _Alloc>&
+      basic_string<_CharT, _Traits, _Alloc>::
+      _M_replace(iterator __i1, iterator __i2, _InputIter __k1, 
+                _InputIter __k2, input_iterator_tag)
+      {
+       basic_string __s(__k1, __k2);
+       return this->replace(__i1, __i2, __s._M_ibegin(), __s._M_iend());
+      }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    template<typename _ForwardIter>
+      basic_string<_CharT, _Traits, _Alloc>&
+      basic_string<_CharT, _Traits, _Alloc>::
+      _M_replace(iterator __i1, iterator __i2, _ForwardIter __k1, 
+                _ForwardIter __k2, forward_iterator_tag)
+      {
+       size_type __dold = __i2 - __i1;
+       size_type __dmax = this->max_size();
+       size_type __dnew = static_cast<size_type>(distance(__k1, __k2));
+
+       __LENGTHERROR(__dmax <= __dnew);
+       size_type __off = __i1 - _M_ibegin();
+       _M_mutate(__off, __dold, __dnew);
+       // Invalidated __i1, __i2
+       if (__dnew)
+         _S_copy_chars(_M_data() + __off, __k1, __k2);
+       
+       return *this;
+      }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>&
+    basic_string<_CharT, _Traits, _Alloc>::
+    replace(size_type __pos1, size_type __n1, const basic_string& __str,
+           size_type __pos2, size_type __n2)
+    {
+      return this->replace(_M_check(__pos1), _M_fold(__pos1, __n1),
+                          __str._M_check(__pos2), 
+                          __str._M_fold(__pos2, __n2));
+    }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT,_Traits,_Alloc>&
+    basic_string<_CharT,_Traits,_Alloc>::
+    append(const basic_string& __str)
+    {
+      // Iff appending itself, string needs to pre-reserve the
+      // correct size so that _M_mutate does not clobber the
+      // iterators formed here.
+      size_type __size = __str.size();
+      size_type __len = __size + this->size();
+      if (__len > this->capacity())
+       this->reserve(__len);
+      return this->replace(_M_iend(), _M_iend(), __str._M_ibegin(),
+                          __str._M_iend());
+    }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT,_Traits,_Alloc>&
+    basic_string<_CharT,_Traits,_Alloc>::
+    append(const basic_string& __str, size_type __pos, size_type __n)
+    {
+      // Iff appending itself, string needs to pre-reserve the
+      // correct size so that _M_mutate does not clobber the
+      // iterators formed here.
+      size_type __len = min(__str.size() - __pos, __n) + this->size();
+      if (__len > this->capacity())
+       this->reserve(__len);
+      return this->replace(_M_iend(), _M_iend(), __str._M_check(__pos),
+                          __str._M_fold(__pos, __n));
+    }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT,_Traits,_Alloc>&
+    basic_string<_CharT,_Traits,_Alloc>::
+    append(const _CharT* __s, size_type __n)
+    {
+      size_type __len = __n + this->size();
+      if (__len > this->capacity())
+       this->reserve(__len);
+      return this->replace(_M_iend(), _M_iend(), __s, __s + __n);
+    }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT,_Traits,_Alloc>&
+    basic_string<_CharT,_Traits,_Alloc>::
+    append(size_type __n, _CharT __c)
+    {
+      size_type __len = __n + this->size();
+      if (__len > this->capacity())
+       this->reserve(__len);
+       return this->replace(_M_iend(), _M_iend(), __n, __c);
+    }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT,_Traits,_Alloc>
+    operator+(const _CharT* __lhs,
+             const basic_string<_CharT,_Traits,_Alloc>& __rhs)
+    {
+      typedef basic_string<_CharT,_Traits,_Alloc> __string_type;
+      typedef typename __string_type::size_type          __size_type;
+      __size_type __len = _Traits::length(__lhs);
+      __string_type __str;
+      __str.reserve(__len + __rhs.size());
+      __str.append(__lhs, __lhs + __len);
+      __str.append(__rhs);
+      return __str;
+    }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT,_Traits,_Alloc>
+    operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs)
+    {
+      typedef basic_string<_CharT,_Traits,_Alloc> __string_type;
+      typedef typename __string_type::size_type          __size_type;
+      __string_type __str;
+      __size_type __len = __rhs.size();
+      __str.reserve(__len + 1);
+      __str.append(__string_type::size_type(1), __lhs);
+      __str.append(__rhs);
+      return __str;
+    }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>&
+    basic_string<_CharT, _Traits, _Alloc>::
+    replace(iterator __i1, iterator __i2, size_type __n2, _CharT __c)
+    {
+      size_type __n1 = __i2 - __i1;
+      size_type __off1 = __i1 - _M_ibegin();
+      __LENGTHERROR(max_size() - (this->size() - __n1) <= __n2);
+      _M_mutate (__off1, __n1, __n2);
+      // Invalidated __i1, __i2
+      if (__n2)
+       traits_type::assign(_M_data() + __off1, __n2, __c);
+      return *this;
+    }
+  
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>::size_type
+    basic_string<_CharT, _Traits, _Alloc>::
+    copy(_CharT* __s, size_type __n, size_type __pos) const
+    {
+      __OUTOFRANGE(__pos > this->size());
+      
+      if (__n > this->size() - __pos)
+       __n = this->size() - __pos;
+      
+      traits_type::copy(__s, _M_data() + __pos, __n);
+      // 21.3.5.7 par 3: do not append null.  (good.)
+      return __n;
+    }
+
+  // String operations
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    const _CharT*
+    basic_string<_CharT, _Traits, _Alloc>::
+    _S_find(const _CharT* __beg, const _CharT* __end, _CharT __c)
+    {
+      return find_if(__beg, __end, _Char_traits_match<_CharT, _Traits>(__c));
+    }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>::size_type
+    basic_string<_CharT, _Traits, _Alloc>::
+    find(const _CharT* __s, size_type __pos, size_type __n) const
+    {
+      size_t __xpos = __pos;
+      const _CharT* __data = _M_data();
+      for (; __xpos + __n <= this->size(); ++__xpos)
+       if (traits_type::compare(__data + __xpos, __s, __n) == 0)
+         return __xpos;
+      return npos;
+    }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>::size_type
+    basic_string<_CharT, _Traits, _Alloc>::
+    find(_CharT __c, size_type __pos) const
+    {
+      size_type __size = this->size();
+      size_type __ret = npos;
+      if (__pos < __size)
+       {
+         const _CharT* __data = _M_data();
+         const _CharT* __end = __data + __size;
+         const _CharT* __p = _S_find(__data + __pos, __end, __c);
+         if (__p != __end)
+           __ret = __p - __data;
+       }
+      return __ret;
+    }
+
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>::size_type
+    basic_string<_CharT, _Traits, _Alloc>::
+    rfind(const _CharT* __s, size_type __pos, size_type __n) const
+    {
+      size_type __size = this->size();
+      if (__n <= __size)
+       {
+         __pos = std::min(__size - __n ,__pos);
+         const _CharT* __data = _M_data();
+         do 
+           {
+             if (traits_type::compare(__data + __pos, __s, __n) == 0)
+               return __pos;
+           } 
+         while (__pos-- > 0);
+       }
+      return npos;
+    }
+  
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>::size_type
+    basic_string<_CharT, _Traits, _Alloc>::
+    rfind(_CharT __c, size_type __pos) const
+    {
+      size_type __size = this->size();
+      if (__size)
+       {
+         size_t __xpos = __size - 1;
+         if (__xpos > __pos)
+           __xpos = __pos;
+      
+         for (++__xpos; __xpos-- > 0; )
+           if (traits_type::eq(_M_data()[__xpos], __c))
+             return __xpos;
+       }
+      return npos;
+    }
+  
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>::size_type
+    basic_string<_CharT, _Traits, _Alloc>::
+    find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
+    {
+      const _CharT* __end = __s + __n;
+      for (; __n && __pos < this->size(); ++__pos)
+       {
+         const _CharT* __p = _S_find(__s, __end, _M_data()[__pos]);
+         if (__p != __end)
+           return __pos;
+       }
+      return npos;
+    }
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>::size_type
+    basic_string<_CharT, _Traits, _Alloc>::
+    find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
+    {
+      size_type __size = this->size();
+      if (__size && __n)
+       { 
+         if (--__size > __pos) 
+           __size = __pos;
+         do
+           {
+             const _CharT* __p = _S_find(__s, __s + __n, _M_data()[__size]);
+             if (__p  != __s + __n)
+               return __size;
+           } 
+         while (__size-- != 0);
+       }
+      return npos;
+    }
+  
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>::size_type
+    basic_string<_CharT, _Traits, _Alloc>::
+    find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
+    {
+      size_t __xpos = __pos;
+      for (; __n && __xpos < this->size(); ++__xpos)
+       if (_S_find(__s, __s + __n, _M_data()[__xpos]) == __s + __n)
+         return __xpos;
+      return npos;
+    }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>::size_type
+    basic_string<_CharT, _Traits, _Alloc>::
+    find_first_not_of(_CharT __c, size_type __pos) const
+    {
+      size_t __xpos = __pos;
+      for (; __xpos < size(); ++__xpos)
+       if (!traits_type::eq(_M_data()[__xpos], __c))
+         return __xpos;
+      return npos;
+    }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>::size_type
+    basic_string<_CharT, _Traits, _Alloc>::
+    find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
+    {
+      size_type __size = this->size();
+      if (__size && __n)
+       { 
+         if (--__size > __pos) 
+           __size = __pos;
+         do
+           {
+             if (_S_find(__s, __s + __n, _M_data()[__size]) == __s + __n)
+               return __size;
+           } 
+         while (__size--);
+       }
+      return npos;
+    }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    basic_string<_CharT, _Traits, _Alloc>::size_type
+    basic_string<_CharT, _Traits, _Alloc>::
+    find_last_not_of(_CharT __c, size_type __pos) const
+    {
+      size_type __size = this->size();
+      if (__size)
+       { 
+         if (--__size > __pos) 
+           __size = __pos;
+         do
+           {
+             if (!traits_type::eq(_M_data()[__size], __c))
+               return __size;
+           } 
+         while (__size--);
+       }
+      return npos;
+    }
+  
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    int
+    basic_string<_CharT, _Traits, _Alloc>::
+    compare(size_type __pos, size_type __n, const basic_string& __str) const
+    {
+      size_type __size = this->size();
+      size_type __osize = __str.size();
+      __OUTOFRANGE(__pos > __size);
+      
+      size_type __rsize= min(__size - __pos, __n);
+      size_type __len = min(__rsize, __osize);
+      int __r = traits_type::compare(_M_data() + __pos, __str.data(), __len);
+      if (!__r)
+       __r = __rsize - __osize;
+      return __r;
+    }
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    int
+    basic_string<_CharT, _Traits, _Alloc>::
+    compare(size_type __pos1, size_type __n1, const basic_string& __str,
+           size_type __pos2, size_type __n2) const
+    {
+      size_type __size = this->size();
+      size_type __osize = __str.size();
+      __OUTOFRANGE(__pos1 > __size);
+      __OUTOFRANGE(__pos2 > __osize);
+      
+      size_type __rsize = min(__size - __pos1, __n1);
+      size_type __rosize = min(__osize - __pos2, __n2);
+      size_type __len = min(__rsize, __rosize);
+      int __r = traits_type::compare(_M_data() + __pos1, 
+                                    __str.data() + __pos2, __len);
+      if (!__r)
+       __r = __rsize - __rosize;
+      return __r;
+    }
+
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    int
+    basic_string<_CharT, _Traits, _Alloc>::
+    compare(const _CharT* __s) const
+    {
+      size_type __size = this->size();
+      int __r = traits_type::compare(_M_data(), __s, __size);
+      if (!__r)
+       __r = __size - traits_type::length(__s);
+      return __r;
+    }
+
+
+  template<typename _CharT, typename _Traits, typename _Alloc>
+    int
+    basic_string <_CharT,_Traits,_Alloc>::
+    compare(size_type __pos, size_type __n1, const _CharT* __s, 
+           size_type __n2) const
+    {
+      size_type __size = this->size();
+      __OUTOFRANGE(__pos > __size);
+      
+      size_type __osize = min(traits_type::length(__s), __n2);
+      size_type __rsize = min(__size - __pos, __n1);
+      size_type __len = min(__rsize, __osize);
+      int __r = traits_type::compare(_M_data() + __pos, __s, __len);
+      if (!__r)
+       __r = __rsize - __osize;
+      return __r;
+    }
+
+  template <class _CharT, class _Traits, class _Alloc>
+    void
+    _S_string_copy(const basic_string<_CharT, _Traits, _Alloc>& __str,
+                  _CharT* __buf, typename _Alloc::size_type __bufsiz)
+    {
+      typedef typename _Alloc::size_type size_type;
+      size_type __strsize = __str.size();
+      size_type __bytes = min(__strsize, __bufsiz - 1);
+      _Traits::copy(__buf, __str.data(), __bytes);
+      __buf[__bytes] = _CharT();
+    }
+
+} // std::
+
+#endif /* _CPP_BITS_STRING_TCC */
index 6008eca2862b6a71bcca26a7d2d7b62798211b29..eb023df718e0face7748f41b497e074d4bbd317f 100644 (file)
@@ -1,6 +1,6 @@
 // Components for manipulating sequences of characters -*- C++ -*-
 
-// Copyright (C) 1997-1999 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -44,7 +44,7 @@
 
 #ifdef _GLIBCPP_NO_TEMPLATE_EXPORT
 # include <bits/std_algorithm.h> // for find_if
-# include <bits/string.tcc> 
+# include <bits/basic_string.tcc> 
 #endif
 
 #endif /* _CPP_STRING */
diff --git a/libstdc++-v3/include/bits/string.tcc b/libstdc++-v3/include/bits/string.tcc
deleted file mode 100644 (file)
index da43ae1..0000000
+++ /dev/null
@@ -1,842 +0,0 @@
-// Components for manipulating sequences of characters -*- C++ -*-
-
-// Copyright (C) 2000, 1999, 1998, 1997 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library.  This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 2, or (at your option)
-// any later version.
-
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING.  If not, write to the Free
-// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-// USA.
-
-// As a special exception, you may use this file as part of a free software
-// library without restriction.  Specifically, if other files instantiate
-// templates or use macros or inline functions from this file, or you compile
-// this file and link it with other files to produce an executable, this
-// file does not by itself cause the resulting executable to be covered by
-// the GNU General Public License.  This exception does not however
-// invalidate any other reasons why the executable file might be covered by
-// the GNU General Public License.
-
-//
-// ISO C++ 14882: 21  Strings library
-//
-
-// This file is included by <string>.  It is not meant to be included
-// separately.
-
-// Written by Jason Merrill based upon the specification by Takanori Adachi
-// in ANSI X3J16/94-0013R2.  Rewritten by Nathan Myers to ISO-14882.
-
-#ifndef _CPP_BITS_STRING_TCC
-#define _CPP_BITS_STRING_TCC 1
-
-namespace std
-{
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    const _CharT 
-    basic_string<_CharT, _Traits, _Alloc>::
-    _Rep::_S_terminal = _CharT();
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    const typename basic_string<_CharT, _Traits, _Alloc>::size_type 
-    basic_string<_CharT, _Traits, _Alloc>::
-    _Rep::_S_max_size = (((npos - sizeof(_Rep))/sizeof(_CharT)) - 1) / 4;
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    const typename basic_string<_CharT, _Traits, _Alloc>::size_type
-    basic_string<_CharT, _Traits, _Alloc>::npos;
-
-  // Linker sets _S_empty_rep_storage to all 0s (one reference, empty string)
-  // at static init time (before static ctors are run).
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    typename basic_string<_CharT, _Traits, _Alloc>::size_type
-    basic_string<_CharT, _Traits, _Alloc>::_S_empty_rep_storage[
-    (sizeof(_Rep) + sizeof(_CharT) + sizeof(size_type) - 1)/sizeof(size_type)];
-
-  // NB: This is the special case for Input Iterators, used in
-  // istreambuf_iterators, etc.
-  // Input Iterators have a cost structure very different from
-  // pointers, calling for a different coding style.
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    template<typename _InIter>
-      _CharT*
-      basic_string<_CharT, _Traits, _Alloc>::
-      _S_construct(_InIter __beg, _InIter __end, const _Alloc& __a,
-                  input_iterator_tag)
-      {
-       if (__beg == __end && __a == _Alloc())
-         return _S_empty_rep()._M_refcopy();
-       // Avoid reallocation for common case.
-       _CharT __buf[100];
-       size_type __i = 0;
-       while (__beg != __end && __i < sizeof(__buf) / sizeof(_CharT))
-         { 
-           __buf[__i++] = *__beg; 
-           ++__beg; 
-         }
-       _Rep* __r = _Rep::_S_create(__i, __a);
-       traits_type::copy(__r->_M_refdata(), __buf, __i);
-       __r->_M_length = __i;
-       try {
-         // NB: this loop looks precisely this way because
-         // it avoids comparing __beg != __end any more
-         // than strictly necessary; != might be expensive!
-         for (;;)
-           {
-             _CharT* __p = __r->_M_refdata() + __r->_M_length;
-             _CharT* __last = __r->_M_refdata() + __r->_M_capacity;
-             for (;;)
-               {
-                 if (__beg == __end)
-                   {
-                     __r->_M_length = __p - __r->_M_refdata();
-                     *__p = _Rep::_S_terminal;       // grrr.
-                     return __r->_M_refdata();
-                   }
-                 if (__p == __last)
-                   break;
-                 *__p++ = *__beg; 
-                 ++__beg;
-               }
-             // Allocate more space.
-             size_type __len = __p - __r->_M_refdata();
-             _Rep* __another = _Rep::_S_create(__len + 1, __a);
-             traits_type::copy(__another->_M_refdata(), 
-                               __r->_M_refdata(), __len);
-             __r->_M_destroy(__a);
-             __r = __another;
-             __r->_M_length = __len;
-           }
-       }
-       catch (...) {
-           __r->_M_destroy(__a); 
-           throw;
-       }
-       return 0;
-      }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    template <class _InIter>
-      _CharT*
-      basic_string<_CharT,_Traits,_Alloc>::
-      _S_construct(_InIter __beg, _InIter __end, const _Alloc& __a, 
-                  forward_iterator_tag)
-      {
-       size_type __dnew = static_cast<size_type>(distance(__beg, __end));
-
-       if (__beg == __end && __a == _Alloc())
-         return _S_empty_rep()._M_refcopy();
-
-       // Check for out_of_range and length_error exceptions.
-       _Rep* __r = _Rep::_S_create(__dnew, __a);
-       try { 
-         _S_copy_chars(__r->_M_refdata(), __beg, __end); 
-       }
-       catch (...) { 
-         __r->_M_destroy(__a); 
-         throw; 
-       }
-       __r->_M_length = __dnew;
-
-       __r->_M_refdata()[__dnew] = _Rep::_S_terminal;  // grrr.
-       return __r->_M_refdata();
-      }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    _CharT*
-    basic_string<_CharT,_Traits, _Alloc>::
-    _S_construct(size_type __n, _CharT __c, const _Alloc& __a)
-    {
-      if (__n == 0 && __a == _Alloc())
-       return _S_empty_rep()._M_refcopy();
-
-      // Check for out_of_range and length_error exceptions.
-      _Rep* __r = _Rep::_S_create(__n, __a);
-      try { 
-       if (__n) 
-         traits_type::assign(__r->_M_refdata(), __n, __c); 
-      }
-      catch (...) { 
-       __r->_M_destroy(__a); 
-       throw; 
-      }
-      __r->_M_length = __n;
-      __r->_M_refdata()[__n] = _Rep::_S_terminal;  // grrr
-      return __r->_M_refdata();
-    }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>::
-    basic_string(const basic_string& __str)
-    : _M_dataplus(__str._M_rep()->_M_grab(_Alloc(), __str.get_allocator()),
-                __str.get_allocator())
-    { }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>::
-    basic_string(const _Alloc& __a)
-    : _M_dataplus(_S_construct(size_type(), _CharT(), __a), __a)
-    { }
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>::
-    basic_string(const basic_string& __str, size_type __pos, size_type __n)
-    : _M_dataplus(_S_construct(__str._M_check(__pos), 
-                              __str._M_fold(__pos, __n), _Alloc()), _Alloc())
-    { }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>::
-    basic_string(const basic_string& __str, size_type __pos,
-                size_type __n, const _Alloc& __a)
-    : _M_dataplus(_S_construct(__str._M_check(__pos), 
-                              __str._M_fold(__pos, __n), __a), __a)
-    { }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>::
-    basic_string(const _CharT* __s, size_type __n, const _Alloc& __a)
-    : _M_dataplus(_S_construct(__s, __s + __n, __a), __a)
-    { }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>::
-    basic_string(const _CharT* __s, const _Alloc& __a)
-    : _M_dataplus(_S_construct(__s, __s + traits_type::length(__s), __a), __a)
-    { }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>::
-    basic_string(size_type __n, _CharT __c, const _Alloc& __a)
-    : _M_dataplus(_S_construct(__n, __c, __a), __a)
-    { }
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    template<typename _InputIter>
-    basic_string<_CharT, _Traits, _Alloc>::
-    basic_string(_InputIter __beg, _InputIter __end, const _Alloc& __a)
-    : _M_dataplus(_S_construct(__beg, __end, __a), __a)
-    { }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>&
-    basic_string<_CharT, _Traits, _Alloc>::assign(const basic_string& __str)
-    {
-      if (_M_rep() != __str._M_rep())
-       {
-         // XXX MT
-         allocator_type __a = this->get_allocator();
-         _CharT* __tmp = __str._M_rep()->_M_grab(__a, __str.get_allocator());
-         _M_rep()->_M_dispose(__a);
-         _M_data(__tmp);
-       }
-      return *this;
-    }
-  
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    void
-    basic_string<_CharT, _Traits, _Alloc>::_Rep::
-    _M_destroy(const _Alloc& __a) throw ()
-    {
-      size_type __size = sizeof(_Rep) + (_M_capacity + 1) * sizeof(_CharT);
-      _Raw_bytes_alloc(__a).deallocate(reinterpret_cast<char*>(this), __size);
-    }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    void
-    basic_string<_CharT, _Traits, _Alloc>::_M_leak_hard()
-    {
-      if (_M_rep()->_M_is_shared()) 
-       _M_mutate(0, 0, 0);
-      _M_rep()->_M_set_leaked();
-    }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    void
-    basic_string<_CharT, _Traits, _Alloc>::
-    _M_mutate(size_type __pos, size_type __len1, size_type __len2)
-    {
-      size_type       __old_size = this->size();
-      const size_type __new_size = __old_size + __len2 - __len1;
-      const _CharT*        __src = _M_data()  + __pos + __len1;
-      const size_type __how_much = __old_size - __pos - __len1;
-      
-      if (_M_rep()->_M_is_shared() || __new_size > capacity())
-       {
-         // Must reallocate.
-         allocator_type __a = get_allocator();
-         _Rep* __r = _Rep::_S_create(__new_size, __a);
-         try {
-           if (__pos)
-             traits_type::copy(__r->_M_refdata(), _M_data(), __pos);
-           if (__how_much)
-             traits_type::copy(__r->_M_refdata() + __pos + __len2, 
-                               __src, __how_much);
-         }
-         catch (...) { 
-           __r->_M_dispose(get_allocator()); 
-           throw; 
-         }
-         _M_rep()->_M_dispose(__a);
-         _M_data(__r->_M_refdata());
-      }
-      else if (__how_much && __len1 != __len2)
-       {
-         // Work in-place
-         traits_type::move(_M_data() + __pos + __len2, __src, __how_much);
-       }
-      _M_rep()->_M_set_sharable();
-      _M_rep()->_M_length = __new_size;
-      _M_data()[__new_size] = _Rep::_S_terminal; // grrr. (per 21.3.4)
-    // You cannot leave those LWG people alone for a second.
-    }
-  
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    void
-    basic_string<_CharT, _Traits, _Alloc>::reserve(size_type __res)
-    {
-      if (__res > this->capacity() || _M_rep()->_M_is_shared())
-        {
-         __LENGTHERROR(__res > this->max_size());
-         allocator_type __a = get_allocator();
-         _CharT* __tmp = _M_rep()->_M_clone(__a, __res - this->size());
-         _M_rep()->_M_dispose(__a);
-         _M_data(__tmp);
-        }
-    }
-  
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    void basic_string<_CharT, _Traits, _Alloc>::swap(basic_string& __s)
-    {
-      if (_M_rep()->_M_is_leaked()) 
-       _M_rep()->_M_set_sharable();
-      if (__s._M_rep()->_M_is_leaked()) 
-       __s._M_rep()->_M_set_sharable();
-      if (this->get_allocator() == __s.get_allocator())
-       {
-         _CharT* __tmp = _M_data();
-         _M_data(__s._M_data());
-         __s._M_data(__tmp);
-       }
-      // The code below can usually be optimized away.
-      else 
-       {
-         basic_string __tmp1(_M_ibegin(), _M_iend(), __s.get_allocator());
-         basic_string __tmp2(__s._M_ibegin(), __s._M_iend(), 
-                             this->get_allocator());
-         *this = __tmp2;
-         __s = __tmp1;
-       }
-    }
-
-#ifdef _GLIBCPP_ALLOC_CONTROL
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    bool (*basic_string<_CharT, _Traits, _Alloc>::_Rep::_S_excess_slop) 
-    (size_t, size_t) = 
-    basic_string<_CharT, _Traits, _Alloc>::_Rep::_S_default_excess;
-#endif
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>::_Rep*
-    basic_string<_CharT, _Traits, _Alloc>::_Rep::
-    _S_create(size_t __capacity, const _Alloc& __alloc)
-    {
-#ifdef _GLIBCPP_RESOLVE_LIB_DEFECTS
-      // 83.  String::npos vs. string::max_size()
-      typedef basic_string<_CharT, _Traits, _Alloc> __string_type;
-      __LENGTHERROR(__capacity > _S_max_size);
-#else
-      __LENGTHERROR(__capacity == npos);
-#endif
-
-      // NB: Need an array of char_type[__capacity], plus a
-      // terminating null char_type() element, plus enough for the
-      // _Rep data structure. Whew. Seemingly so needy, yet so elemental.
-      size_t __size = (__capacity + 1) * sizeof(_CharT) + sizeof(_Rep);
-      // NB: Might throw, but no worries about a leak, mate: _Rep()
-      // does not throw.
-      void* __place = _Raw_bytes_alloc(__alloc).allocate(__size);
-      _Rep *__p = new (__place) _Rep;
-      __p->_M_capacity = __capacity;
-      __p->_M_set_sharable();  // one reference
-      __p->_M_length = 0;
-      return __p;
-    }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    _CharT*
-    basic_string<_CharT, _Traits, _Alloc>::_Rep::
-    _M_clone(const _Alloc& __alloc, size_type __res)
-    {
-      _Rep* __r = _Rep::_S_create(_M_length + __res, __alloc);
-      if (_M_length)
-       {
-         try { 
-           traits_type::copy(__r->_M_refdata(), _M_refdata(), _M_length); 
-         }
-         catch (...)  { 
-           __r->_M_destroy(__alloc); 
-           throw; 
-         }
-       }
-      __r->_M_length = _M_length;
-      return __r->_M_refdata();
-    }
-  
-  template<typename _CharT, typename _Traits, typename _Alloc>
-  inline bool
-#ifdef _GLIBCPP_ALLOC_CONTROL
-    basic_string<_CharT, _Traits, _Alloc>::_Rep::
-    _S_default_excess(size_t __s, size_t __r)
-#else
-    basic_string<_CharT, _Traits, _Alloc>::_Rep::
-    _S_excess_slop(size_t __s, size_t __r)
-#endif
-    {
-      return 2 * (__s <= 16 ? 16 : __s) < __r;
-    }
-  
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    void
-    basic_string<_CharT, _Traits, _Alloc>::resize(size_type __n, _CharT __c)
-    {
-      __LENGTHERROR(__n > max_size());
-      size_type __size = this->size();
-      if (__size < __n)
-       this->append(__n - __size, __c);
-      else if (__n < __size)
-       this->erase(__n);
-      // else nothing (in particular, avoid calling _M_mutate() unnecessarily.)
-    }
-  
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    template<typename _InputIter>
-      basic_string<_CharT, _Traits, _Alloc>&
-      basic_string<_CharT, _Traits, _Alloc>::
-      _M_replace(iterator __i1, iterator __i2, _InputIter __k1, 
-                _InputIter __k2, input_iterator_tag)
-      {
-       basic_string __s(__k1, __k2);
-       return this->replace(__i1, __i2, __s._M_ibegin(), __s._M_iend());
-      }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    template<typename _ForwardIter>
-      basic_string<_CharT, _Traits, _Alloc>&
-      basic_string<_CharT, _Traits, _Alloc>::
-      _M_replace(iterator __i1, iterator __i2, _ForwardIter __k1, 
-                _ForwardIter __k2, forward_iterator_tag)
-      {
-       size_type __dold = __i2 - __i1;
-       size_type __dmax = this->max_size();
-       size_type __dnew = static_cast<size_type>(distance(__k1, __k2));
-
-       __LENGTHERROR(__dmax <= __dnew);
-       size_type __off = __i1 - _M_ibegin();
-       _M_mutate(__off, __dold, __dnew);
-       // Invalidated __i1, __i2
-       if (__dnew)
-         _S_copy_chars(_M_data() + __off, __k1, __k2);
-       
-       return *this;
-      }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>&
-    basic_string<_CharT, _Traits, _Alloc>::
-    replace(size_type __pos1, size_type __n1, const basic_string& __str,
-           size_type __pos2, size_type __n2)
-    {
-      return this->replace(_M_check(__pos1), _M_fold(__pos1, __n1),
-                          __str._M_check(__pos2), 
-                          __str._M_fold(__pos2, __n2));
-    }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT,_Traits,_Alloc>&
-    basic_string<_CharT,_Traits,_Alloc>::
-    append(const basic_string& __str)
-    {
-      // Iff appending itself, string needs to pre-reserve the
-      // correct size so that _M_mutate does not clobber the
-      // iterators formed here.
-      size_type __size = __str.size();
-      size_type __len = __size + this->size();
-      if (__len > this->capacity())
-       this->reserve(__len);
-      return this->replace(_M_iend(), _M_iend(), __str._M_ibegin(),
-                          __str._M_iend());
-    }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT,_Traits,_Alloc>&
-    basic_string<_CharT,_Traits,_Alloc>::
-    append(const basic_string& __str, size_type __pos, size_type __n)
-    {
-      // Iff appending itself, string needs to pre-reserve the
-      // correct size so that _M_mutate does not clobber the
-      // iterators formed here.
-      size_type __len = min(__str.size() - __pos, __n) + this->size();
-      if (__len > this->capacity())
-       this->reserve(__len);
-      return this->replace(_M_iend(), _M_iend(), __str._M_check(__pos),
-                          __str._M_fold(__pos, __n));
-    }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT,_Traits,_Alloc>&
-    basic_string<_CharT,_Traits,_Alloc>::
-    append(const _CharT* __s, size_type __n)
-    {
-      size_type __len = __n + this->size();
-      if (__len > this->capacity())
-       this->reserve(__len);
-      return this->replace(_M_iend(), _M_iend(), __s, __s + __n);
-    }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT,_Traits,_Alloc>&
-    basic_string<_CharT,_Traits,_Alloc>::
-    append(size_type __n, _CharT __c)
-    {
-      size_type __len = __n + this->size();
-      if (__len > this->capacity())
-       this->reserve(__len);
-       return this->replace(_M_iend(), _M_iend(), __n, __c);
-    }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT,_Traits,_Alloc>
-    operator+(const _CharT* __lhs,
-             const basic_string<_CharT,_Traits,_Alloc>& __rhs)
-    {
-      typedef basic_string<_CharT,_Traits,_Alloc> __string_type;
-      typedef typename __string_type::size_type          __size_type;
-      __size_type __len = _Traits::length(__lhs);
-      __string_type __str;
-      __str.reserve(__len + __rhs.size());
-      __str.append(__lhs, __lhs + __len);
-      __str.append(__rhs);
-      return __str;
-    }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT,_Traits,_Alloc>
-    operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs)
-    {
-      typedef basic_string<_CharT,_Traits,_Alloc> __string_type;
-      typedef typename __string_type::size_type          __size_type;
-      __string_type __str;
-      __size_type __len = __rhs.size();
-      __str.reserve(__len + 1);
-      __str.append(__string_type::size_type(1), __lhs);
-      __str.append(__rhs);
-      return __str;
-    }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>&
-    basic_string<_CharT, _Traits, _Alloc>::
-    replace(iterator __i1, iterator __i2, size_type __n2, _CharT __c)
-    {
-      size_type __n1 = __i2 - __i1;
-      size_type __off1 = __i1 - _M_ibegin();
-      __LENGTHERROR(max_size() - (this->size() - __n1) <= __n2);
-      _M_mutate (__off1, __n1, __n2);
-      // Invalidated __i1, __i2
-      if (__n2)
-       traits_type::assign(_M_data() + __off1, __n2, __c);
-      return *this;
-    }
-  
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>::size_type
-    basic_string<_CharT, _Traits, _Alloc>::
-    copy(_CharT* __s, size_type __n, size_type __pos) const
-    {
-      __OUTOFRANGE(__pos > this->size());
-      
-      if (__n > this->size() - __pos)
-       __n = this->size() - __pos;
-      
-      traits_type::copy(__s, _M_data() + __pos, __n);
-      // 21.3.5.7 par 3: do not append null.  (good.)
-      return __n;
-    }
-
-  // String operations
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    const _CharT*
-    basic_string<_CharT, _Traits, _Alloc>::
-    _S_find(const _CharT* __beg, const _CharT* __end, _CharT __c)
-    {
-      return find_if(__beg, __end, _Char_traits_match<_CharT, _Traits>(__c));
-    }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>::size_type
-    basic_string<_CharT, _Traits, _Alloc>::
-    find(const _CharT* __s, size_type __pos, size_type __n) const
-    {
-      size_t __xpos = __pos;
-      const _CharT* __data = _M_data();
-      for (; __xpos + __n <= this->size(); ++__xpos)
-       if (traits_type::compare(__data + __xpos, __s, __n) == 0)
-         return __xpos;
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>::size_type
-    basic_string<_CharT, _Traits, _Alloc>::
-    find(_CharT __c, size_type __pos) const
-    {
-      size_type __size = this->size();
-      size_type __ret = npos;
-      if (__pos < __size)
-       {
-         const _CharT* __data = _M_data();
-         const _CharT* __end = __data + __size;
-         const _CharT* __p = _S_find(__data + __pos, __end, __c);
-         if (__p != __end)
-           __ret = __p - __data;
-       }
-      return __ret;
-    }
-
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>::size_type
-    basic_string<_CharT, _Traits, _Alloc>::
-    rfind(const _CharT* __s, size_type __pos, size_type __n) const
-    {
-      size_type __size = this->size();
-      if (__n <= __size)
-       {
-         __pos = std::min(__size - __n ,__pos);
-         const _CharT* __data = _M_data();
-         do 
-           {
-             if (traits_type::compare(__data + __pos, __s, __n) == 0)
-               return __pos;
-           } 
-         while (__pos-- > 0);
-       }
-      return npos;
-    }
-  
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>::size_type
-    basic_string<_CharT, _Traits, _Alloc>::
-    rfind(_CharT __c, size_type __pos) const
-    {
-      size_type __size = this->size();
-      if (__size)
-       {
-         size_t __xpos = __size - 1;
-         if (__xpos > __pos)
-           __xpos = __pos;
-      
-         for (++__xpos; __xpos-- > 0; )
-           if (traits_type::eq(_M_data()[__xpos], __c))
-             return __xpos;
-       }
-      return npos;
-    }
-  
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>::size_type
-    basic_string<_CharT, _Traits, _Alloc>::
-    find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
-    {
-      const _CharT* __end = __s + __n;
-      for (; __n && __pos < this->size(); ++__pos)
-       {
-         const _CharT* __p = _S_find(__s, __end, _M_data()[__pos]);
-         if (__p != __end)
-           return __pos;
-       }
-      return npos;
-    }
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>::size_type
-    basic_string<_CharT, _Traits, _Alloc>::
-    find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
-    {
-      size_type __size = this->size();
-      if (__size && __n)
-       { 
-         if (--__size > __pos) 
-           __size = __pos;
-         do
-           {
-             const _CharT* __p = _S_find(__s, __s + __n, _M_data()[__size]);
-             if (__p  != __s + __n)
-               return __size;
-           } 
-         while (__size-- != 0);
-       }
-      return npos;
-    }
-  
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>::size_type
-    basic_string<_CharT, _Traits, _Alloc>::
-    find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
-    {
-      size_t __xpos = __pos;
-      for (; __n && __xpos < this->size(); ++__xpos)
-       if (_S_find(__s, __s + __n, _M_data()[__xpos]) == __s + __n)
-         return __xpos;
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>::size_type
-    basic_string<_CharT, _Traits, _Alloc>::
-    find_first_not_of(_CharT __c, size_type __pos) const
-    {
-      size_t __xpos = __pos;
-      for (; __xpos < size(); ++__xpos)
-       if (!traits_type::eq(_M_data()[__xpos], __c))
-         return __xpos;
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>::size_type
-    basic_string<_CharT, _Traits, _Alloc>::
-    find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
-    {
-      size_type __size = this->size();
-      if (__size && __n)
-       { 
-         if (--__size > __pos) 
-           __size = __pos;
-         do
-           {
-             if (_S_find(__s, __s + __n, _M_data()[__size]) == __s + __n)
-               return __size;
-           } 
-         while (__size--);
-       }
-      return npos;
-    }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    basic_string<_CharT, _Traits, _Alloc>::size_type
-    basic_string<_CharT, _Traits, _Alloc>::
-    find_last_not_of(_CharT __c, size_type __pos) const
-    {
-      size_type __size = this->size();
-      if (__size)
-       { 
-         if (--__size > __pos) 
-           __size = __pos;
-         do
-           {
-             if (!traits_type::eq(_M_data()[__size], __c))
-               return __size;
-           } 
-         while (__size--);
-       }
-      return npos;
-    }
-  
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    int
-    basic_string<_CharT, _Traits, _Alloc>::
-    compare(size_type __pos, size_type __n, const basic_string& __str) const
-    {
-      size_type __size = this->size();
-      size_type __osize = __str.size();
-      __OUTOFRANGE(__pos > __size);
-      
-      size_type __rsize= min(__size - __pos, __n);
-      size_type __len = min(__rsize, __osize);
-      int __r = traits_type::compare(_M_data() + __pos, __str.data(), __len);
-      if (!__r)
-       __r = __rsize - __osize;
-      return __r;
-    }
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    int
-    basic_string<_CharT, _Traits, _Alloc>::
-    compare(size_type __pos1, size_type __n1, const basic_string& __str,
-           size_type __pos2, size_type __n2) const
-    {
-      size_type __size = this->size();
-      size_type __osize = __str.size();
-      __OUTOFRANGE(__pos1 > __size);
-      __OUTOFRANGE(__pos2 > __osize);
-      
-      size_type __rsize = min(__size - __pos1, __n1);
-      size_type __rosize = min(__osize - __pos2, __n2);
-      size_type __len = min(__rsize, __rosize);
-      int __r = traits_type::compare(_M_data() + __pos1, 
-                                    __str.data() + __pos2, __len);
-      if (!__r)
-       __r = __rsize - __rosize;
-      return __r;
-    }
-
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    int
-    basic_string<_CharT, _Traits, _Alloc>::
-    compare(const _CharT* __s) const
-    {
-      size_type __size = this->size();
-      int __r = traits_type::compare(_M_data(), __s, __size);
-      if (!__r)
-       __r = __size - traits_type::length(__s);
-      return __r;
-    }
-
-
-  template<typename _CharT, typename _Traits, typename _Alloc>
-    int
-    basic_string <_CharT,_Traits,_Alloc>::
-    compare(size_type __pos, size_type __n1, const _CharT* __s, 
-           size_type __n2) const
-    {
-      size_type __size = this->size();
-      __OUTOFRANGE(__pos > __size);
-      
-      size_type __osize = min(traits_type::length(__s), __n2);
-      size_type __rsize = min(__size - __pos, __n1);
-      size_type __len = min(__rsize, __osize);
-      int __r = traits_type::compare(_M_data() + __pos, __s, __len);
-      if (!__r)
-       __r = __rsize - __osize;
-      return __r;
-    }
-
-  template <class _CharT, class _Traits, class _Alloc>
-    void
-    _S_string_copy(const basic_string<_CharT, _Traits, _Alloc>& __str,
-                  _CharT* __buf, typename _Alloc::size_type __bufsiz)
-    {
-      typedef typename _Alloc::size_type size_type;
-      size_type __strsize = __str.size();
-      size_type __bytes = min(__strsize, __bufsiz - 1);
-      _Traits::copy(__buf, __str.data(), __bytes);
-      __buf[__bytes] = _CharT();
-    }
-
-} // std::
-
-#endif /* _CPP_BITS_STRING_TCC */
index fda9f45940278d6282d2e20021e13dfc688cf2c6..9544a824fe9ef576862eb826cdb0ccdc8bf0c8a0 100644 (file)
@@ -1,6 +1,6 @@
 // -*- C++ -*- forwarding header.
 
-// Copyright (C) 1997-1999, 2000 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -36,6 +36,8 @@
 #ifndef _CPP_CWCTYPE
 #define _CPP_CWCTYPE 1
 
+#include <bits/std_cwchar.h>
+
 #pragma GCC system_header
 #include <wctype.h>
 
index 9809dd6a201c73eb2cba8c4f54d483464578e9c6..18acebe09519c9af01cff18cb1bc09e734f4b09d 100644 (file)
@@ -21,7 +21,7 @@
 ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 ## USA.
 
-## $Id: Makefile.am,v 1.60 2000/12/21 01:28:57 gdr Exp $
+## $Id: Makefile.am,v 1.61 2000/12/23 07:13:57 bkoz Exp $
 
 AUTOMAKE_OPTIONS = 1.3 gnits
 MAINT_CHARSET = latin1
@@ -76,7 +76,7 @@ INCLUDES = \
 
 base_headers = \
        bits/cpp_type_traits.h bits/char_traits.h bits/codecvt.h \
-       bits/basic_string.h bits/std_string.h  bits/string.tcc \
+       bits/std_string.h bits/basic_string.h bits/basic_string.tcc \
        bits/generic_shadow.h bits/std_utility.h \
        bits/std_complex.h \
        bits/valarray_array.h bits/valarray_array.tcc bits/valarray_meta.h \
index 6b9cc03882d944fbab11c22157639f554ba1b2af..cdb547cebc132875f581461254d74f18d6d831e1 100644 (file)
@@ -148,7 +148,7 @@ TOPLEVEL_INCLUDES = @TOPLEVEL_INCLUDES@
 INCLUDES =     -nostdinc++     -I$(GLIBCPP_INCLUDE_DIR) $(CSTD_INCLUDES) -I$(top_builddir)/include     $(LIBSUPCXX_INCLUDES) $(LIBIO_INCLUDES) $(LIBMATH_INCLUDES)     $(TOPLEVEL_INCLUDES)    
 
 
-base_headers =         bits/cpp_type_traits.h bits/char_traits.h bits/codecvt.h        bits/basic_string.h bits/std_string.h  bits/string.tcc  bits/generic_shadow.h bits/std_utility.h        bits/std_complex.h      bits/valarray_array.h bits/valarray_array.tcc bits/valarray_meta.h      bits/std_valarray.h bits/mask_array.h bits/slice.h bits/slice_array.h   bits/gslice.h bits/gslice_array.h bits/indirect_array.h         bits/exception_support.h        bits/std_fstream.h bits/std_iomanip.h   bits/ios_base.h bits/fpos.h bits/basic_ios.h bits/basic_ios.tcc         bits/std_ios.h bits/std_iosfwd.h bits/std_iostream.h    bits/std_istream.h bits/istream.tcc bits/std_locale.h   bits/fstream.tcc bits/ostream.tcc bits/sbuf_iter.h bits/sstream.tcc     bits/std_ostream.h bits/std_sstream.h bits/std_streambuf.h      bits/streambuf.tcc bits/basic_file.h    bits/locale_facets.h bits/locale_facets.tcc bits/localefwd.h    bits/stl_pthread_alloc.h bits/pthread_allocimpl.h       bits/stl_threads.h bits/stl_iterator_base.h     bits/std_bitset.h bits/std_deque.h bits/std_functional.h        bits/std_iterator.h bits/std_list.h     bits/std_map.h bits/std_memory.h bits/std_numeric.h     bits/std_queue.h bits/std_set.h bits/std_stack.h        bits/std_stdexcept.h bits/std_vector.h  bits/stl_algo.h bits/stl_algobase.h bits/stl_alloc.h    bits/stl_deque.h bits/stl_function.h    bits/stl_heap.h bits/stl_iterator.h bits/stl_list.h bits/stl_map.h      bits/stl_multimap.h bits/stl_multiset.h bits/stl_numeric.h      bits/stl_pair.h bits/stl_queue.h bits/stl_raw_storage_iter.h    bits/stl_relops.h bits/stl_set.h        bits/stl_stack.h bits/stl_string_fwd.h bits/stl_tempbuf.h       bits/stl_tree.h bits/stl_uninitialized.h bits/stl_vector.h      bits/type_traits.h bits/stl_range_errors.h bits/std_algorithm.h         bits/concept_checks.h bits/container_concepts.h         bits/sequence_concepts.h bits/stl_config.h bits/stl_construct.h
+base_headers =         bits/cpp_type_traits.h bits/char_traits.h bits/codecvt.h        bits/std_string.h bits/basic_string.h bits/basic_string.tcc     bits/generic_shadow.h bits/std_utility.h        bits/std_complex.h      bits/valarray_array.h bits/valarray_array.tcc bits/valarray_meta.h      bits/std_valarray.h bits/mask_array.h bits/slice.h bits/slice_array.h   bits/gslice.h bits/gslice_array.h bits/indirect_array.h         bits/exception_support.h        bits/std_fstream.h bits/std_iomanip.h   bits/ios_base.h bits/fpos.h bits/basic_ios.h bits/basic_ios.tcc         bits/std_ios.h bits/std_iosfwd.h bits/std_iostream.h    bits/std_istream.h bits/istream.tcc bits/std_locale.h   bits/fstream.tcc bits/ostream.tcc bits/sbuf_iter.h bits/sstream.tcc     bits/std_ostream.h bits/std_sstream.h bits/std_streambuf.h      bits/streambuf.tcc bits/basic_file.h    bits/locale_facets.h bits/locale_facets.tcc bits/localefwd.h    bits/stl_pthread_alloc.h bits/pthread_allocimpl.h       bits/stl_threads.h bits/stl_iterator_base.h     bits/std_bitset.h bits/std_deque.h bits/std_functional.h        bits/std_iterator.h bits/std_list.h     bits/std_map.h bits/std_memory.h bits/std_numeric.h     bits/std_queue.h bits/std_set.h bits/std_stack.h        bits/std_stdexcept.h bits/std_vector.h  bits/stl_algo.h bits/stl_algobase.h bits/stl_alloc.h    bits/stl_deque.h bits/stl_function.h    bits/stl_heap.h bits/stl_iterator.h bits/stl_list.h bits/stl_map.h      bits/stl_multimap.h bits/stl_multiset.h bits/stl_numeric.h      bits/stl_pair.h bits/stl_queue.h bits/stl_raw_storage_iter.h    bits/stl_relops.h bits/stl_set.h        bits/stl_stack.h bits/stl_string_fwd.h bits/stl_tempbuf.h       bits/stl_tree.h bits/stl_uninitialized.h bits/stl_vector.h      bits/type_traits.h bits/stl_range_errors.h bits/std_algorithm.h         bits/concept_checks.h bits/container_concepts.h         bits/sequence_concepts.h bits/stl_config.h bits/stl_construct.h
 
 
 backward_headers =     backward/complex.h backward/iomanip.h backward/istream.h        backward/ostream.h backward/stream.h backward/streambuf.h       backward/algo.h backward/algobase.h backward/alloc.h    backward/bvector.h backward/defalloc.h backward/deque.h         backward/function.h backward/hash_map.h backward/hash_set.h     backward/hashtable.h backward/heap.h backward/iterator.h        backward/list.h backward/map.h backward/multimap.h backward/new.h       backward/multiset.h backward/pair.h backward/iostream.h         backward/rope.h backward/set.h backward/slist.h backward/stack.h        backward/tempbuf.h backward/tree.h backward/vector.h    backward/fstream.h backward/strstream.h backward/strstream
index 25550113ad9d7fc8b0906c5807ca895e71d8ce11..54e5f4a509187214d7eb4353dba1796b3749befd 100644 (file)
@@ -1,6 +1,6 @@
 // Components for manipulating sequences of characters -*- C++ -*-
 
-// Copyright (C) 2000, 1999, 1998, 1997 Free Software Foundation, Inc.
+// Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
 // in ANSI X3J16/94-0013R2.  Rewritten by Nathan Myers.
 
 #include <bits/std_string.h>
-#include <bits/std_algorithm.h>
 
 // Instantiation configuration.
 #ifndef C
 # define C char
-# define _GLIBCPP_INSTANTIATING_CHAR 1
 #endif
 
 namespace std 
 {
   typedef basic_string<C> S;
 
-  template C S::_Rep::_S_terminal;
-  template const S::size_type S::npos;
-  template S::size_type S::_Rep::_S_max_size;
-  template S::size_type S::_S_empty_rep_storage[];
-  template S::_Rep* S::_Rep::_S_create(size_t, S::allocator_type const&);
-  template void S::_Rep::_M_destroy(const S::allocator_type&) throw();
-  template void __destroy_aux(S*, S*, __false_type);
+  template class basic_string<C>;
 
-  template S::basic_string(S const&);
-
-  template 
-    S::basic_string(S::size_type, C, const S::allocator_type&);
-
-  template 
-    S::basic_string(const S::allocator_type&);
-
-  template 
-    S::basic_string(const S&, S::size_type, S::size_type);
-
-  template 
-    S::basic_string(const S&, S::size_type, S::size_type, 
-                   const S::allocator_type&);
-
-  template 
-    S::basic_string(C const*, S::size_type, const S::allocator_type&);
-
-  template 
-    S::basic_string(C const*, S::allocator_type const&);
-
-  template 
-    S::basic_string(C*, C*, const allocator<C>&);
-
-  template 
-    S::basic_string(S::iterator, S::iterator, const allocator<C>&);
-
-  template
-    void S::_M_leak_hard();
-
-  template
-    void S::_M_mutate(S::size_type, S::size_type, S::size_type);
-
-  template
-    C* S::_Rep::_M_clone(S::allocator_type const&, S::size_type);
-
-  template
-    void S::reserve(S::size_type);
-
-  template
-    void S::swap(S&);
-
-# ifdef _GLIBCPP_ALLOC_CONTROL
-    template
-      bool (* S::_Rep::_S_excess_slop)(size_t, size_t); 
-
-    template
-      bool S::_Rep::_S_default_excess(size_t, size_t); 
-# endif
-
-  template
-    void S::resize(S::size_type, C);
-
-  template
-    S& S::append(S const&);
-
-  template
-    S& S::append(S const&, S::size_type, S::size_type);
-
-  template
-    S& S::append(C const*, S::size_type);
-
-  template
-    S& S::append(S::size_type, C);
-
-  template 
-    S& 
-    S::append<S::iterator>(S::iterator, S::iterator);
-
-  template
-    S& 
-    S::assign(S const&);
-
-  template 
-    S& 
-    S::assign<S::iterator>(S::iterator, S::iterator);
-
-  template 
-    void
-    S::insert<S::iterator> //c*
-    (S::iterator, S::iterator, S::iterator); //it, c+, c+ and temptype = char*
-
-  template
-    S& S::replace(S::size_type, S::size_type, S const&, 
-                 S::size_type, S::size_type);
-
-  template 
-    S& S::replace(S::iterator, S::iterator, S::size_type, C);
-
-  template 
-    S&
-    S::replace<S::iterator> // c*
-    (S::iterator, S::iterator, S::iterator, S::iterator); //it, it, c+, c+ 
+  template S operator+(const C*, const S&);
+  template S operator+(C, const S&);
+  template bool operator==(const S::iterator&, const S::iterator&);
+  template bool operator==(const S::const_iterator&, const S::const_iterator&);
 
+  // Only one template keyword allowed here. 
+  // See core issue #46 (NAD)
+  // http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_closed.html#46
   template 
     S& 
     S::_M_replace<S::iterator>
     (S::iterator, S::iterator, S::iterator, S::iterator, forward_iterator_tag);
 
-  // Only one template keyword allowed here. 
-  // See core issue #46 (NAD)
-  // http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_closed.html#46
   template 
     S& 
     S::_M_replace<S::const_iterator>
@@ -164,88 +67,13 @@ namespace std
      S::const_iterator, S::const_iterator, forward_iterator_tag);
 
   template 
-    S& 
-    S::_M_replace<C*>
-    (S::iterator, S::iterator, C*, C*, forward_iterator_tag);
+    C* 
+    S::_S_construct<S::iterator>
+    (S::iterator, S::iterator, const allocator<C>&, forward_iterator_tag);
 
   template 
-    S& 
-    S::_M_replace<const C*>
-    (S::iterator, S::iterator, const C*, const C*, forward_iterator_tag);
-
-  template
-    S::size_type S::copy(C*, S::size_type, S::size_type) const;
-
-  template 
-    C* S::_S_construct<S::iterator>(S::iterator, S::iterator, 
-                                   const allocator<C>&);
-
-  template 
-    C* S::_S_construct<S::iterator>(S::iterator, S::iterator, 
-                                   const allocator<C>&, forward_iterator_tag);
-
-  template 
-    C* S::_S_construct<C*>(C*, C*, const allocator<C>&, forward_iterator_tag);
-
-  template 
-    C* S::_S_construct<const C*>(const C*, const C*, const allocator<C>&, 
-                                forward_iterator_tag);
-
-  template 
-    C* S::_S_construct(S::size_type, C, S::allocator_type const&);
-
-  template
-    const C* S::_S_find(const C* __beg, const C* __end, C __c);
-
-  template
-    S::size_type S::find(C, S::size_type) const;
-
-  template
-    S::size_type S::rfind(C const*, S::size_type, S::size_type) const;
-
-  template
-    S::size_type S::rfind(C, S::size_type) const;
-
-  template
-    S::size_type S::find_first_of(C const*, S::size_type, S::size_type) const;
-
-  template
-    S::size_type S::find_last_of(C const*, S::size_type, S::size_type) const;
-
-  template
-    S::size_type 
-    S::find_first_not_of(C const*, S::size_type, S::size_type) const;
-
-  template
-    S::size_type 
-    S::find_last_not_of(C const*, S::size_type, S::size_type) const;
-
-  template
-    S::size_type S::find_last_not_of(C, S::size_type) const;
-
-  template
-    int S::compare(S::size_type, S::size_type, S const&) const;
-
-  template
-    int S::compare(S::size_type, S::size_type, S const&, S::size_type, 
-                  S::size_type) const;
-
-  template
-    int S::compare(C const*) const;
-
-  template
-    int S::compare(S::size_type, S::size_type, C const*, S::size_type) const;
-
-  template S operator+(const C*, const S&);
-
-  template S operator+(C, const S&);
-
-  template bool operator==(const S::iterator&, const S::iterator&);
-  template bool operator==(const S::const_iterator&, const S::const_iterator&);
-
-  template void _S_string_copy(const S&, C*, allocator<C>::size_type);
-
-} // std
+    S::basic_string(S::iterator, S::iterator, const allocator<C>&);
+} // namespace std