OSDN Git Service

2004-01-28 Benjamin Kosnik <bkoz@redhat.com>
authorbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 29 Jan 2004 00:18:40 +0000 (00:18 +0000)
committerbkoz <bkoz@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 29 Jan 2004 00:18:40 +0000 (00:18 +0000)
* include/Makefile.am (bits_headers): Remove allocator_traits.h.
* include/Makefile.in: Regenerate.
* include/bits/allocator_traits.h: Remove.
* include/bits/allocator.h: Remove allocator_traits.h include, and
relevant comments.
(allocator): Empty base class, inherit from the underlying allocator.
* src/allocator-inst.cc: Move __pool_alloc instantiation to...
* src/allocator.cc: ...here. New. For the underlying allocators.
Add __mt_alloc, __pool_alloc, new_allocator, malloc_allocator bits.
* config/linker-map.gnu: Remove __pool_alloc bits.
* src/Makefile.am (sources): Add allocator.cc.
* src/Makefile.in: Regenerate.
* testsuite/20_util/allocator/1.cc: Split second test into...
* testsuite/20_util/allocator/8230.cc: ...this.
* include/bits/stl_bvector.h (__gnu_norm): Change bit_vector
typedef to use std::allocatore. Format.
* include/ext/pool_allocator.h: Remove allocator_traits.h include,
_Alloc_traits.
* include/ext/mt_allocator.h (__gnu_cxx): Qualify
__throw_bad_alloc calls. Don't include <memory>.
* include/ext/malloc_allocator.h: Remove <memory> include.
* include/ext/new_allocator.h (new_allocator): Same.
* include/ext/ropeimpl.h (__gnu_cxx): Remove __alloc using
declaration. Switch __alloc to _Alloc.
* include/ext/hashtable.h: Remove __alloc.
* include/backward/alloc.h: Only inject allocator, not
implementation details.

* include/ext/mt_allocator.h: Replace free with delete.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@76821 138bc75d-0d04-0410-961f-82ee72b054a4

22 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/config/linker-map.gnu
libstdc++-v3/include/Makefile.am
libstdc++-v3/include/Makefile.in
libstdc++-v3/include/backward/alloc.h
libstdc++-v3/include/backward/bvector.h
libstdc++-v3/include/bits/allocator.h
libstdc++-v3/include/bits/allocator_traits.h [deleted file]
libstdc++-v3/include/bits/stl_bvector.h
libstdc++-v3/include/bits/stl_vector.h
libstdc++-v3/include/ext/hashtable.h
libstdc++-v3/include/ext/malloc_allocator.h
libstdc++-v3/include/ext/mt_allocator.h
libstdc++-v3/include/ext/new_allocator.h
libstdc++-v3/include/ext/pool_allocator.h
libstdc++-v3/include/ext/ropeimpl.h
libstdc++-v3/src/Makefile.am
libstdc++-v3/src/Makefile.in
libstdc++-v3/src/allocator-inst.cc
libstdc++-v3/src/allocator.cc [new file with mode: 0644]
libstdc++-v3/testsuite/20_util/allocator/1.cc
libstdc++-v3/testsuite/20_util/allocator/8230.cc [new file with mode: 0644]

index 3742dcb..fd632dd 100644 (file)
@@ -1,5 +1,37 @@
 2004-01-28  Benjamin Kosnik  <bkoz@redhat.com>
 
+       * include/Makefile.am (bits_headers): Remove allocator_traits.h.
+       * include/Makefile.in: Regenerate.
+       * include/bits/allocator_traits.h: Remove.
+       * include/bits/allocator.h: Remove allocator_traits.h include, and
+       relevant comments.
+       (allocator): Empty base class, inherit from the underlying allocator.
+       * src/allocator-inst.cc: Move __pool_alloc instantiation to...
+       * src/allocator.cc: ...here. New. For the underlying allocators.
+       Add __mt_alloc, __pool_alloc, new_allocator, malloc_allocator bits.
+       * config/linker-map.gnu: Remove __pool_alloc bits.
+       * src/Makefile.am (sources): Add allocator.cc.
+       * src/Makefile.in: Regenerate.
+       * testsuite/20_util/allocator/1.cc: Split second test into...
+       * testsuite/20_util/allocator/8230.cc: ...this. 
+       * include/bits/stl_bvector.h (__gnu_norm): Change bit_vector
+       typedef to use std::allocatore. Format.
+       * include/ext/pool_allocator.h: Remove allocator_traits.h include,
+       _Alloc_traits.
+       * include/ext/mt_allocator.h (__gnu_cxx): Qualify
+       __throw_bad_alloc calls. Don't include <memory>.
+       * include/ext/malloc_allocator.h: Remove <memory> include.
+       * include/ext/new_allocator.h (new_allocator): Same.
+       * include/ext/ropeimpl.h (__gnu_cxx): Remove __alloc using
+       declaration. Switch __alloc to _Alloc.
+       * include/ext/hashtable.h: Remove __alloc.
+       * include/backward/alloc.h: Only inject allocator, not
+       implementation details.
+
+       * include/ext/mt_allocator.h: Replace free with delete.
+       
+2004-01-28  Benjamin Kosnik  <bkoz@redhat.com>
+
        * src/globals_io.cc: Change to __gnu_internal namespace.
        * src/globals_locale.cc: Same.
        * src/locale_init.cc: Same.
index 9dc4e91..c6acb2a 100644 (file)
@@ -1,6 +1,6 @@
 ## Linker script for GNU ld 2.13.91+ only.
 ##
-## Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+## Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
 ##
 ## This file is part of the libstdc++ version 3 distribution.
 ##
@@ -207,10 +207,6 @@ GLIBCXX_3.4 {
     __signbitf;
     __signbitl;
 
-    # __gnu_cxx::__pool_alloc
-    _ZN9__gnu_cxx12__pool_allocILb1ELi0EE8allocateE[jm];
-    _ZN9__gnu_cxx12__pool_allocILb1ELi0EE10deallocateEPv[jm];
-
     # __gnu_cxx::stdio_sync_filebuf
     _ZTVN9__gnu_cxx18stdio_sync_filebufI[cw]St11char_traitsI[cw]EEE;
 
index b97267b..f95c1a0 100644 (file)
@@ -1,6 +1,6 @@
 ## Makefile for the include subdirectory of the GNU C++ Standard library.
 ##
-## Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+## Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
 ##
 ## This file is part of the libstdc++ version 3 distribution.
 ## Process this file with automake to produce Makefile.in.
@@ -92,7 +92,6 @@ bits_srcdir = ${glibcxx_srcdir}/include/bits
 bits_builddir = ./bits
 bits_headers = \
        ${bits_srcdir}/allocator.h \
-       ${bits_srcdir}/allocator_traits.h \
        ${bits_srcdir}/basic_ios.h \
        ${bits_srcdir}/basic_ios.tcc \
        ${bits_srcdir}/basic_string.h \
index 8c266e8..8ab2f7b 100644 (file)
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.7.9 from Makefile.am.
+# Makefile.in generated by automake 1.7.8 from Makefile.am.
 # @configure_input@
 
 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
@@ -287,7 +287,6 @@ bits_srcdir = ${glibcxx_srcdir}/include/bits
 bits_builddir = ./bits
 bits_headers = \
        ${bits_srcdir}/allocator.h \
-       ${bits_srcdir}/allocator_traits.h \
        ${bits_srcdir}/basic_ios.h \
        ${bits_srcdir}/basic_ios.tcc \
        ${bits_srcdir}/basic_string.h \
@@ -519,15 +518,15 @@ debug_headers = \
        ${debug_srcdir}/string \
        ${debug_srcdir}/vector
 
-@GLIBCXX_C_HEADERS_C_STD_FALSE@c_base_headers_extra = 
 
 # Some of the different "C" header models need extra files.
 # Some "C" header schemes require the "C" compatibility headers.
 # For --enable-cheaders=c_std
 @GLIBCXX_C_HEADERS_C_STD_TRUE@c_base_headers_extra = ${c_base_srcdir}/cmath.tcc
-@GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE@c_compatibility_headers_extra = 
+@GLIBCXX_C_HEADERS_C_STD_FALSE@c_base_headers_extra = 
 
 @GLIBCXX_C_HEADERS_COMPATIBILITY_TRUE@c_compatibility_headers_extra = ${c_compatibility_headers}
+@GLIBCXX_C_HEADERS_COMPATIBILITY_FALSE@c_compatibility_headers_extra = 
 
 host_srcdir = ${glibcxx_srcdir}/$(OS_INC_SRCDIR)
 host_builddir = ./${host_alias}/bits
@@ -566,10 +565,10 @@ pch_input = ${host_builddir}/stdc++.h
 pch_output_builddir = ${host_builddir}/stdc++.h.gch
 pch_source = ${glibcxx_srcdir}/include/stdc++.h
 PCHFLAGS = -Winvalid-pch -Wno-deprecated -x c++-header $(CXXFLAGS)
-@GLIBCXX_BUILD_PCH_TRUE@pch_build = ${pch_input}
 @GLIBCXX_BUILD_PCH_FALSE@pch_build = 
-@GLIBCXX_BUILD_PCH_TRUE@pch_install = install-pch
+@GLIBCXX_BUILD_PCH_TRUE@pch_build = ${pch_input}
 @GLIBCXX_BUILD_PCH_FALSE@pch_install = 
+@GLIBCXX_BUILD_PCH_TRUE@pch_install = install-pch
 
 # List of all timestamp files.  By keeping only one copy of this list, both
 # CLEANFILES and all-local are kept up-to-date.
@@ -673,7 +672,7 @@ install-am: all-am
 installcheck: installcheck-am
 install-strip:
        $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-         install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+         INSTALL_STRIP_FLAG=-s \
          `test -z '$(STRIP)' || \
            echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
 mostlyclean-generic:
index ad9e4e5..d3c3c73 100644 (file)
@@ -1,6 +1,6 @@
 // Backward-compat support -*- C++ -*-
 
-// Copyright (C) 2001, 2003 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2003, 2004 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
@@ -47,9 +47,6 @@
 #include <bits/c++config.h>
 #include <bits/allocator.h>
 
-using __gnu_cxx::__pool_alloc;
-using std::__alloc;
-using std::__simple_alloc;
 using std::allocator;
 
 #endif
index 5d12914..e54dbc8 100644 (file)
@@ -1,6 +1,6 @@
 // Backward-compat support -*- C++ -*-
 
-// Copyright (C) 2001 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2004 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
@@ -59,7 +59,7 @@
 #include "backward_warning.h"
 #include <vector>
 
-using std::bit_vector;
+typedef std::vector<bool, allocator<bool> > bit_vector;
 
 #endif /* _BACKWARD_BVECTOR_H */
 
index 53d1d35..a8e40e2 100644 (file)
@@ -1,6 +1,6 @@
 // Allocators -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004 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
  *  You should not attempt to use it directly.
  */
 
-/**
- *  @defgroup Allocators Memory Allocators
- *  @if maint
- *  allocator.h implements some node allocators.  These are NOT the same as
- *  allocators in the C++ standard, nor in the original H-P STL.  They do not
- *  encapsulate different pointer types; we assume that there is only one
- *  pointer type.  The C++ standard allocators are intended to allocate
- *  individual objects, not pools or arenas.
- *
- *  In this file allocators are of two different styles:  "standard" and
- *  "SGI" (quotes included).  "Standard" allocators conform to 20.4.  "SGI"
- *  allocators differ in AT LEAST the following ways (add to this list as you
- *  discover them):
- *
- *   - "Standard" allocate() takes two parameters (n_count,hint=0) but "SGI"
- *     allocate() takes one paramter (n_size).
- *   - Likewise, "standard" deallocate()'s argument is a count, but in "SGI"
- *     is a byte size.
- *   - max_size(), construct(), and destroy() are missing in "SGI" allocators.
- *   - reallocate(p,oldsz,newsz) is added in "SGI", and behaves as
- *     if p=realloc(p,newsz).
- *
- *  "SGI" allocators may be wrapped in __allocator to convert the interface
- *  into a "standard" one.
- *  @endif
- *
- *  The canonical description of these classes is in docs/html/ext/howto.html
- *  or online at http://gcc.gnu.org/onlinedocs/libstdc++/ext/howto.html#3
-*/
-
 #ifndef _ALLOCATOR_H
 #define _ALLOCATOR_H 1
 
-#include <bits/functexcept.h>   // For __throw_bad_alloc
-#include <bits/allocator_traits.h>
+#if 1
+# include <ext/mt_allocator.h>
+# define __glibcxx_default_allocator  __gnu_cxx::__mt_alloc
+#endif
 
-// Pick a default underlying allocator.
-#include <ext/pool_allocator.h>
+#if 0
+# include <ext/pool_allocator.h>
+# define __glibcxx_default_allocator  __gnu_cxx::__pool_alloc
+#endif
 
 namespace std
 {
-  typedef __gnu_cxx::__pool_alloc<true, 0>    __alloc;
+  template<typename _Tp>
+    class allocator;
 
-  /// The version for the default allocator.
-  template<typename _Tp, typename _Tp1>
-    struct _Alloc_traits<_Tp, allocator<_Tp1> >
+  template<>
+    class allocator<void>
     {
-      static const bool _S_instanceless = true;
-      typedef __simple_alloc<_Tp, __alloc> _Alloc_type;
-      typedef allocator<_Tp> allocator_type;
+    public:
+      typedef size_t      size_type;
+      typedef ptrdiff_t   difference_type;
+      typedef void*       pointer;
+      typedef const void* const_pointer;
+      typedef void        value_type;
+
+      template<typename _Tp1>
+        struct rebind
+        { typedef allocator<_Tp1> other; };
     };
-  //@}
-}
 
-namespace std
-{
   /**
    *  @brief  The "standard" allocator, as per [20.4].
    *
-   *  The private _Alloc is "SGI" style.  (See comments at the top
-   *  of allocator.h.)
-   *
-   *  The underlying allocator behaves as follows.
-   *    - __pool_alloc is used via two typedefs
-   *    - "__alloc" typedef is threadsafe via the locks
-   *    - __new_alloc is used for memory requests
-   *
    *  (See @link Allocators allocators info @endlink for more.)
    */
   template<typename _Tp>
-    class allocator
+    class allocator: public __glibcxx_default_allocator<_Tp>  
     {
-      // The underlying allocator.
-      typedef __alloc _Alloc;     
-     
-    public:
+   public:
       typedef size_t     size_type;
       typedef ptrdiff_t  difference_type;
       typedef _Tp*       pointer;
@@ -135,68 +101,17 @@ namespace std
 
       allocator() throw() { }
 
-      allocator(const allocator&) throw() { }
+      allocator(const allocator& a) throw() 
+      : __glibcxx_default_allocator<_Tp>(a) { }
 
       template<typename _Tp1>
         allocator(const allocator<_Tp1>&) throw() { }
 
       ~allocator() throw() { }
 
-      pointer
-      address(reference __x) const { return &__x; }
-
-      const_pointer
-      address(const_reference __x) const { return &__x; }
-
-      // NB: __n is permitted to be 0.  The C++ standard says nothing
-      // about what the return value is when __n == 0.
-      _Tp*
-      allocate(size_type __n, const void* = 0)
-      {
-       _Tp* __ret = 0;
-       if (__n)
-         {
-           if (__n <= this->max_size())
-             __ret = static_cast<_Tp*>(_Alloc::allocate(__n * sizeof(_Tp)));
-           else
-             __throw_bad_alloc();
-         }
-       return __ret;
-      }
-
-      // __p is not permitted to be a null pointer.
-      void
-      deallocate(pointer __p, size_type __n)
-      { _Alloc::deallocate(__p, __n * sizeof(_Tp)); }
-
-      size_type
-      max_size() const throw() { return size_t(-1) / sizeof(_Tp); }
-
-      // _GLIBCXX_RESOLVE_LIB_DEFECTS
-      // 402. wrong new expression in [some_]allocator::construct
-      void 
-      construct(pointer __p, const _Tp& __val) { ::new(__p) _Tp(__val); }
-
-      void 
-      destroy(pointer __p) { __p->~_Tp(); }
+      // Inherit everything else.
     };
 
-  template<>
-    class allocator<void>
-    {
-    public:
-      typedef size_t      size_type;
-      typedef ptrdiff_t   difference_type;
-      typedef void*       pointer;
-      typedef const void* const_pointer;
-      typedef void        value_type;
-
-      template<typename _Tp1>
-        struct rebind
-        { typedef allocator<_Tp1> other; };
-    };
-
-
   template<typename _T1, typename _T2>
     inline bool
     operator==(const allocator<_T1>&, const allocator<_T2>&)
@@ -214,6 +129,9 @@ namespace std
   extern template class allocator<char>;
   extern template class allocator<wchar_t>;
 #endif
+
+  // Undefine.
+#undef __glibcxx_default_allocator
 } // namespace std
 
 #endif
diff --git a/libstdc++-v3/include/bits/allocator_traits.h b/libstdc++-v3/include/bits/allocator_traits.h
deleted file mode 100644 (file)
index 93bae7a..0000000
+++ /dev/null
@@ -1,237 +0,0 @@
-// Allocators -*- C++ -*-
-
-// Copyright (C) 2001, 2002, 2003 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.
-
-/*
- * Copyright (c) 1996-1997
- * Silicon Graphics Computer Systems, Inc.
- *
- * Permission to use, copy, modify, distribute and sell this software
- * and its documentation for any purpose is hereby granted without fee,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear
- * in supporting documentation.  Silicon Graphics makes no
- * representations about the suitability of this software for any
- * purpose.  It is provided "as is" without express or implied warranty.
- */
-
-#ifndef _ALLOCATOR_TRAITS_H
-#define _ALLOCATOR_TRAITS_H 1
-
-#include <cstddef>
-
-namespace std
-{
-  /**
-   *  @if maint
-   *  This is used primarily (only?) in _Alloc_traits and other places to
-   *  help provide the _Alloc_type typedef.  All it does is forward the
-   *  requests after some minimal checking.
-   *
-   *  This is neither "standard"-conforming nor "SGI".  The _Alloc parameter
-   *  must be "SGI" style.
-   *  @endif
-   *  (See @link Allocators allocators info @endlink for more.)
-   */
-  template<typename _Tp, typename _Alloc>
-    class __simple_alloc
-    {
-    public:
-      static _Tp*
-      allocate(size_t __n)
-      {
-       _Tp* __ret = 0;
-       if (__n)
-         __ret = static_cast<_Tp*>(_Alloc::allocate(__n * sizeof(_Tp)));
-       return __ret;
-      }
-  
-      static _Tp*
-      allocate()
-      { return (_Tp*) _Alloc::allocate(sizeof (_Tp)); }
-  
-      static void
-      deallocate(_Tp* __p, size_t __n)
-      { if (0 != __n) _Alloc::deallocate(__p, __n * sizeof (_Tp)); }
-  
-      static void
-      deallocate(_Tp* __p)
-      { _Alloc::deallocate(__p, sizeof (_Tp)); }
-    };
-
-
-  /**
-   *  @if maint
-   *  Allocator adaptor to turn an "SGI" style allocator (e.g.,
-   *  __alloc, __malloc_alloc) into a "standard" conforming
-   *  allocator.  Note that this adaptor does *not* assume that all
-   *  objects of the underlying alloc class are identical, nor does it
-   *  assume that all of the underlying alloc's member functions are
-   *  static member functions.  Note, also, that __allocator<_Tp,
-   *  __alloc> is essentially the same thing as allocator<_Tp>.
-   *  @endif
-   *  (See @link Allocators allocators info @endlink for more.)
-   */
-  template<typename _Tp, typename _Alloc>
-    struct __allocator
-    {
-      _Alloc __underlying_alloc;
-      
-      typedef size_t    size_type;
-      typedef ptrdiff_t difference_type;
-      typedef _Tp*       pointer;
-      typedef const _Tp* const_pointer;
-      typedef _Tp&       reference;
-      typedef const _Tp& const_reference;
-      typedef _Tp        value_type;
-
-      template<typename _Tp1>
-        struct rebind
-        { typedef __allocator<_Tp1, _Alloc> other; };
-
-      __allocator() throw() { }
-
-      __allocator(const __allocator& __a) throw()
-      : __underlying_alloc(__a.__underlying_alloc) { }
-
-      template<typename _Tp1>
-        __allocator(const __allocator<_Tp1, _Alloc>& __a) throw()
-        : __underlying_alloc(__a.__underlying_alloc) { }
-
-      ~__allocator() throw() { }
-
-      pointer
-      address(reference __x) const { return &__x; }
-
-      const_pointer
-      address(const_reference __x) const { return &__x; }
-
-      // NB: __n is permitted to be 0.  The C++ standard says nothing
-      // about what the return value is when __n == 0.
-      _Tp*
-      allocate(size_type __n, const void* = 0)
-      {
-       _Tp* __ret = 0;
-       if (__n)
-         __ret = static_cast<_Tp*>(_Alloc::allocate(__n * sizeof(_Tp)));
-       return __ret;
-      }
-
-      // __p is not permitted to be a null pointer.
-      void
-      deallocate(pointer __p, size_type __n)
-      { __underlying_alloc.deallocate(__p, __n * sizeof(_Tp)); }
-      
-      size_type
-      max_size() const throw() { return size_t(-1) / sizeof(_Tp); }
-
-      // _GLIBCXX_RESOLVE_LIB_DEFECTS
-      // 402. wrong new expression in [some_]allocator::construct
-      void
-      construct(pointer __p, const _Tp& __val) { ::new(__p) _Tp(__val); }
-      
-      void
-      destroy(pointer __p) { __p->~_Tp(); }
-    };
-
-  template<typename _Alloc>
-    struct __allocator<void, _Alloc>
-    {
-      typedef size_t      size_type;
-      typedef ptrdiff_t   difference_type;
-      typedef void*       pointer;
-      typedef const void* const_pointer;
-      typedef void        value_type;
-
-      template<typename _Tp1>
-        struct rebind
-        { typedef __allocator<_Tp1, _Alloc> other; };
-    };
-
-  template<typename _Tp, typename _Alloc>
-    inline bool
-    operator==(const __allocator<_Tp,_Alloc>& __a1, 
-              const __allocator<_Tp,_Alloc>& __a2)
-    { return __a1.__underlying_alloc == __a2.__underlying_alloc; }
-
-  template<typename _Tp, typename _Alloc>
-    inline bool
-    operator!=(const __allocator<_Tp, _Alloc>& __a1,
-               const __allocator<_Tp, _Alloc>& __a2)
-    { return __a1.__underlying_alloc != __a2.__underlying_alloc; }
-
-
-  /**
-   *  @if maint
-   *  Another allocator adaptor:  _Alloc_traits.  This serves two purposes.
-   *  First, make it possible to write containers that can use either "SGI"
-   *  style allocators or "standard" allocators.  Second, provide a mechanism
-   *  so that containers can query whether or not the allocator has distinct
-   *  instances.  If not, the container can avoid wasting a word of memory to
-   *  store an empty object.  For examples of use, see stl_vector.h, etc, or
-   *  any of the other classes derived from this one.
-   *
-   *  This adaptor uses partial specialization.  The general case of
-   *  _Alloc_traits<_Tp, _Alloc> assumes that _Alloc is a
-   *  standard-conforming allocator, possibly with non-equal instances and
-   *  non-static members.  (It still behaves correctly even if _Alloc has
-   *  static member and if all instances are equal.  Refinements affect
-   *  performance, not correctness.)
-   *
-   *  There are always two members:  allocator_type, which is a standard-
-   *  conforming allocator type for allocating objects of type _Tp, and
-   *  _S_instanceless, a static const member of type bool.  If
-   *  _S_instanceless is true, this means that there is no difference
-   *  between any two instances of type allocator_type.  Furthermore, if
-   *  _S_instanceless is true, then _Alloc_traits has one additional
-   *  member:  _Alloc_type.  This type encapsulates allocation and
-   *  deallocation of objects of type _Tp through a static interface; it
-   *  has two member functions, whose signatures are
-   *
-   *  -  static _Tp* allocate(size_t)
-   *  -  static void deallocate(_Tp*, size_t)
-   *
-   *  The size_t parameters are "standard" style (see top of
-   *  allocator.h) in that they take counts, not sizes.
-   *
-   *  @endif
-   *  (See @link Allocators allocators info @endlink for more.)
-   */
-  // The fully general version.
-  template<typename _Tp, typename _Allocator>
-    struct _Alloc_traits
-    {
-      static const bool _S_instanceless = false;
-      typedef typename _Allocator::template rebind<_Tp>::other allocator_type;
-    };
-
-  template<typename _Tp, typename _Allocator>
-    const bool _Alloc_traits<_Tp, _Allocator>::_S_instanceless;
-} // namespace std
-
-#endif
index 34b1a87..4087de4 100644 (file)
@@ -66,237 +66,325 @@ namespace __gnu_norm
   typedef unsigned long _Bit_type;
   enum { _S_word_bit = int(CHAR_BIT * sizeof(_Bit_type)) };
 
-struct _Bit_reference {
+  struct _Bit_reference 
+  {
+    _Bit_type * _M_p;
+    _Bit_type _M_mask;
 
-  _Bit_type * _M_p;
-  _Bit_type _M_mask;
-  _Bit_reference(_Bit_type * __x, _Bit_type __y) 
-    : _M_p(__x), _M_mask(__y) {}
+    _Bit_reference(_Bit_type * __x, _Bit_type __y) 
+    : _M_p(__x), _M_mask(__y) { }
 
-public:
-  _Bit_reference() : _M_p(0), _M_mask(0) {}
-  operator bool() const { return !!(*_M_p & _M_mask); }
-  _Bit_reference& operator=(bool __x)
-  {
-    if (__x)  *_M_p |= _M_mask;
-    else      *_M_p &= ~_M_mask;
-    return *this;
-  }
-  _Bit_reference& operator=(const _Bit_reference& __x) 
+    _Bit_reference() : _M_p(0), _M_mask(0) { }
+
+    operator bool() const { return !!(*_M_p & _M_mask); }
+
+    _Bit_reference& 
+    operator=(bool __x)
+    {
+      if (__x)  
+       *_M_p |= _M_mask;
+      else      
+       *_M_p &= ~_M_mask;
+      return *this;
+    }
+
+    _Bit_reference& 
+    operator=(const _Bit_reference& __x) 
     { return *this = bool(__x); }
-  bool operator==(const _Bit_reference& __x) const
+
+    bool 
+    operator==(const _Bit_reference& __x) const
     { return bool(*this) == bool(__x); }
-  bool operator<(const _Bit_reference& __x) const
+
+    bool 
+    operator<(const _Bit_reference& __x) const
     { return !bool(*this) && bool(__x); }
-  void flip() { *_M_p ^= _M_mask; }
-};
 
-struct _Bit_iterator_base : public iterator<random_access_iterator_tag, bool>
-{
-  _Bit_type * _M_p;
-  unsigned int _M_offset;
+    void 
+    flip() { *_M_p ^= _M_mask; }
+  };
+
+  struct _Bit_iterator_base : public iterator<random_access_iterator_tag, bool>
+  {
+    _Bit_type * _M_p;
+    unsigned int _M_offset;
 
-  _Bit_iterator_base(_Bit_type * __x, unsigned int __y)
-    : _M_p(__x), _M_offset(__y) {}
+    _Bit_iterator_base(_Bit_type * __x, unsigned int __y)
+    : _M_p(__x), _M_offset(__y) { }
 
-  void _M_bump_up() {
-    if (_M_offset++ == _S_word_bit - 1) {
-      _M_offset = 0;
-      ++_M_p;
+    void 
+    _M_bump_up() 
+    {
+      if (_M_offset++ == _S_word_bit - 1) 
+       {
+         _M_offset = 0;
+         ++_M_p;
+       }
     }
-  }
-  void _M_bump_down() {
-    if (_M_offset-- == 0) {
-      _M_offset = _S_word_bit - 1;
-      --_M_p;
+
+    void 
+    _M_bump_down() 
+    {
+      if (_M_offset-- == 0) 
+       {
+         _M_offset = _S_word_bit - 1;
+         --_M_p;
+       }
+    }
+    
+    void 
+    _M_incr(ptrdiff_t __i) 
+    {
+      difference_type __n = __i + _M_offset;
+      _M_p += __n / _S_word_bit;
+      __n = __n % _S_word_bit;
+      if (__n < 0) 
+       {
+         _M_offset = static_cast<unsigned int>(__n + _S_word_bit);
+         --_M_p;
+       } 
+      else
+       _M_offset = static_cast<unsigned int>(__n);
+    }
+    
+    bool 
+    operator==(const _Bit_iterator_base& __i) const 
+    { return _M_p == __i._M_p && _M_offset == __i._M_offset; }
+    
+    bool 
+    operator<(const _Bit_iterator_base& __i) const 
+    {
+      return _M_p < __i._M_p 
+       || (_M_p == __i._M_p && _M_offset < __i._M_offset);
     }
-  }
 
-  void _M_incr(ptrdiff_t __i) {
-    difference_type __n = __i + _M_offset;
-    _M_p += __n / _S_word_bit;
-    __n = __n % _S_word_bit;
-    if (__n < 0) {
-      _M_offset = (unsigned int) __n + _S_word_bit;
-      --_M_p;
-    } else
-      _M_offset = (unsigned int) __n;
-  }
+    bool 
+    operator!=(const _Bit_iterator_base& __i) const 
+    { return !(*this == __i); }
+    
+    bool 
+    operator>(const _Bit_iterator_base& __i) const 
+    { return __i < *this; }
 
-  bool operator==(const _Bit_iterator_base& __i) const {
-    return _M_p == __i._M_p && _M_offset == __i._M_offset;
-  }
-  bool operator<(const _Bit_iterator_base& __i) const {
-    return _M_p < __i._M_p || (_M_p == __i._M_p && _M_offset < __i._M_offset);
-  }
-  bool operator!=(const _Bit_iterator_base& __i) const {
-    return !(*this == __i);
-  }
-  bool operator>(const _Bit_iterator_base& __i) const {
-    return __i < *this;
-  }
-  bool operator<=(const _Bit_iterator_base& __i) const {
-    return !(__i < *this); 
-  }
-  bool operator>=(const _Bit_iterator_base& __i) const {
-    return !(*this < __i);
+    bool 
+    operator<=(const _Bit_iterator_base& __i) const 
+    { return !(__i < *this); }
+
+    bool 
+    operator>=(const _Bit_iterator_base& __i) const 
+    { return !(*this < __i); }
+  };
+
+  inline ptrdiff_t
+  operator-(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) 
+  {
+    return _S_word_bit * (__x._M_p - __y._M_p) + __x._M_offset - __y._M_offset;
   }
-};
 
-inline ptrdiff_t
-operator-(const _Bit_iterator_base& __x, const _Bit_iterator_base& __y) {
-  return _S_word_bit * (__x._M_p - __y._M_p) + __x._M_offset - __y._M_offset;
-}
 
+  struct _Bit_iterator : public _Bit_iterator_base
+  {
+    typedef _Bit_reference  reference;
+    typedef _Bit_reference* pointer;
+    typedef _Bit_iterator   iterator;
 
-struct _Bit_iterator : public _Bit_iterator_base
-{
-  typedef _Bit_reference  reference;
-  typedef _Bit_reference* pointer;
-  typedef _Bit_iterator   iterator;
-
-  _Bit_iterator() : _Bit_iterator_base(0, 0) {}
-  _Bit_iterator(_Bit_type * __x, unsigned int __y) 
-    : _Bit_iterator_base(__x, __y) {}
-
-  reference operator*() const { return reference(_M_p, 1UL << _M_offset); }
-  iterator& operator++() {
-    _M_bump_up();
-    return *this;
-  }
-  iterator operator++(int) {
-    iterator __tmp = *this;
-    _M_bump_up();
-    return __tmp;
-  }
-  iterator& operator--() {
-    _M_bump_down();
-    return *this;
-  }
-  iterator operator--(int) {
-    iterator __tmp = *this;
-    _M_bump_down();
-    return __tmp;
-  }
-  iterator& operator+=(difference_type __i) {
-    _M_incr(__i);
-    return *this;
-  }
-  iterator& operator-=(difference_type __i) {
-    *this += -__i;
-    return *this;
-  }
-  iterator operator+(difference_type __i) const {
-    iterator __tmp = *this;
-    return __tmp += __i;
-  }
-  iterator operator-(difference_type __i) const {
-    iterator __tmp = *this;
-    return __tmp -= __i;
-  }
+    _Bit_iterator() : _Bit_iterator_base(0, 0) { }
+    _Bit_iterator(_Bit_type * __x, unsigned int __y) 
+    : _Bit_iterator_base(__x, __y) { }
+    
+    reference 
+    operator*() const { return reference(_M_p, 1UL << _M_offset); }
 
-  reference operator[](difference_type __i) { return *(*this + __i); }
-};
+    iterator& 
+    operator++() 
+    {
+      _M_bump_up();
+      return *this;
+    }
+    
+    iterator 
+    operator++(int) 
+    {
+      iterator __tmp = *this;
+      _M_bump_up();
+      return __tmp;
+    }
 
-inline _Bit_iterator 
-operator+(ptrdiff_t __n, const _Bit_iterator& __x) { return __x + __n; }
+    iterator& 
+    operator--() 
+    {
+      _M_bump_down();
+      return *this;
+    }
 
+    iterator 
+    operator--(int) 
+    {
+      iterator __tmp = *this;
+      _M_bump_down();
+      return __tmp;
+    }
 
-struct _Bit_const_iterator : public _Bit_iterator_base
-{
-  typedef bool                 reference;
-  typedef bool                 const_reference;
-  typedef const bool*          pointer;
-  typedef _Bit_const_iterator  const_iterator;
-
-  _Bit_const_iterator() : _Bit_iterator_base(0, 0) {}
-  _Bit_const_iterator(_Bit_type * __x, unsigned int __y) 
-    : _Bit_iterator_base(__x, __y) {}
-  _Bit_const_iterator(const _Bit_iterator& __x) 
-    : _Bit_iterator_base(__x._M_p, __x._M_offset) {}
-
-  const_reference operator*() const {
-    return _Bit_reference(_M_p, 1UL << _M_offset);
-  }
-  const_iterator& operator++() {
-    _M_bump_up();
-    return *this;
-  }
-  const_iterator operator++(int) {
-    const_iterator __tmp = *this;
-    _M_bump_up();
-    return __tmp;
-  }
-  const_iterator& operator--() {
-    _M_bump_down();
-    return *this;
-  }
-  const_iterator operator--(int) {
-    const_iterator __tmp = *this;
-    _M_bump_down();
-    return __tmp;
-  }
-  const_iterator& operator+=(difference_type __i) {
-    _M_incr(__i);
-    return *this;
-  }
-  const_iterator& operator-=(difference_type __i) {
-    *this += -__i;
-    return *this;
-  }
-  const_iterator operator+(difference_type __i) const {
-    const_iterator __tmp = *this;
-    return __tmp += __i;
-  }
-  const_iterator operator-(difference_type __i) const {
-    const_iterator __tmp = *this;
-    return __tmp -= __i;
-  }
-  const_reference operator[](difference_type __i) { 
-    return *(*this + __i); 
-  }
-};
+    iterator& 
+    operator+=(difference_type __i) 
+    {
+      _M_incr(__i);
+      return *this;
+    }
 
-inline _Bit_const_iterator 
-operator+(ptrdiff_t __n, const _Bit_const_iterator& __x) { return __x + __n; }
+    iterator&
+    operator-=(difference_type __i) 
+    {
+      *this += -__i;
+      return *this;
+    }
 
+    iterator 
+    operator+(difference_type __i) const 
+    {
+      iterator __tmp = *this;
+      return __tmp += __i;
+    }
+    
+    iterator 
+    operator-(difference_type __i) const 
+    {
+      iterator __tmp = *this;
+      return __tmp -= __i;
+    }
+    
+    reference 
+    operator[](difference_type __i) { return *(*this + __i); }
+  };
+  
+  inline _Bit_iterator 
+  operator+(ptrdiff_t __n, const _Bit_iterator& __x) { return __x + __n; }
 
-template <class _Alloc>
-class _Bvector_base
-  : public _Alloc::template rebind<_Bit_type>::other
-{
-  typedef typename _Alloc::template rebind<_Bit_type>::other _Bit_alloc_type;
-public:
-  typedef _Alloc allocator_type;
-  allocator_type get_allocator() const {
-    return *static_cast<const _Bit_alloc_type*>(this);
-  }
 
-  _Bvector_base(const allocator_type& __a)
-    : _Bit_alloc_type(__a), _M_start(), _M_finish(), _M_end_of_storage(0) { }
-  ~_Bvector_base() { this->_M_deallocate(); }
+  struct _Bit_const_iterator : public _Bit_iterator_base
+  {
+    typedef bool                 reference;
+    typedef bool                 const_reference;
+    typedef const bool*          pointer;
+    typedef _Bit_const_iterator  const_iterator;
+    
+    _Bit_const_iterator() : _Bit_iterator_base(0, 0) { }
+    _Bit_const_iterator(_Bit_type * __x, unsigned int __y) 
+    : _Bit_iterator_base(__x, __y) { }
+    _Bit_const_iterator(const _Bit_iterator& __x) 
+    : _Bit_iterator_base(__x._M_p, __x._M_offset) { }
+
+    const_reference 
+    operator*() const 
+    { return _Bit_reference(_M_p, 1UL << _M_offset); }
+    
+    const_iterator& 
+    operator++() 
+    {
+      _M_bump_up();
+      return *this;
+    }
+
+    const_iterator 
+    operator++(int) 
+    {
+      const_iterator __tmp = *this;
+      _M_bump_up();
+      return __tmp;
+    }
 
-protected:
-  _Bit_type* _M_bit_alloc(size_t __n) {
-    return _Bit_alloc_type::allocate((__n + _S_word_bit - 1)/_S_word_bit);
-  }
-  void _M_deallocate() {
-    if (_M_start._M_p)
-      _Bit_alloc_type::deallocate(_M_start._M_p, _M_end_of_storage - _M_start._M_p);
-  }  
+    const_iterator& 
+    operator--() 
+    {
+      _M_bump_down();
+      return *this;
+    }
+
+    const_iterator 
+    operator--(int) 
+    {
+      const_iterator __tmp = *this;
+      _M_bump_down();
+      return __tmp;
+    }
 
-  _Bit_iterator _M_start;
-  _Bit_iterator _M_finish;
-  _Bit_type * _M_end_of_storage;
-};
+    const_iterator& 
+    operator+=(difference_type __i) 
+    {
+      _M_incr(__i);
+      return *this;
+    }
+
+    const_iterator& 
+    operator-=(difference_type __i) 
+    {
+      *this += -__i;
+      return *this;
+    }
+
+    const_iterator operator+(difference_type __i) const {
+      const_iterator __tmp = *this;
+      return __tmp += __i;
+    }
 
+    const_iterator 
+    operator-(difference_type __i) const 
+    {
+      const_iterator __tmp = *this;
+      return __tmp -= __i;
+    }
+
+    const_reference 
+    operator[](difference_type __i) 
+    { return *(*this + __i); }
+  };
+  
+  inline _Bit_const_iterator 
+  operator+(ptrdiff_t __n, const _Bit_const_iterator& __x) 
+  { return __x + __n; }
+
+  template<class _Alloc>
+    class _Bvector_base
+    : public _Alloc::template rebind<_Bit_type>::other
+    {
+      typedef typename _Alloc::template rebind<_Bit_type>::other _Bit_alloc_type;
+
+    public:
+      typedef _Alloc allocator_type;
+      
+      allocator_type 
+      get_allocator() const 
+      { return *static_cast<const _Bit_alloc_type*>(this); }
+      
+      _Bvector_base(const allocator_type& __a)
+      : _Bit_alloc_type(__a), _M_start(), _M_finish(), _M_end_of_storage(0) { }
+
+      ~_Bvector_base() { this->_M_deallocate(); }
+
+    protected:
+      _Bit_type* 
+      _M_bit_alloc(size_t __n) 
+      { return _Bit_alloc_type::allocate((__n + _S_word_bit - 1)/_S_word_bit);}
+
+      void 
+      _M_deallocate() 
+      {
+       if (_M_start._M_p)
+         _Bit_alloc_type::deallocate(_M_start._M_p, 
+                                     _M_end_of_storage - _M_start._M_p);
+      }  
+      
+      _Bit_iterator _M_start;
+      _Bit_iterator _M_finish;
+      _Bit_type* _M_end_of_storage;
+    };
 } // namespace __gnu_norm
 
 // Declare a partial specialization of vector<T, Alloc>.
 #include <bits/stl_vector.h>
+
 namespace __gnu_norm
 {
-
   /**
    *  @brief  A specialization of vector for booleans which offers fixed time
    *  access to individual elements in any order.
@@ -309,12 +397,13 @@ namespace __gnu_norm
    *  @ingroup Containers
    *  @ingroup Sequences
    *
-   *  In some terminology a %vector can be described as a dynamic C-style array,
-   *  it offers fast and efficient access to individual elements in any order
-   *  and saves the user from worrying about memory and size allocation.
-   *  Subscripting ( @c [] ) access is also provided as with C-style arrays.
+   *  In some terminology a %vector can be described as a dynamic
+   *  C-style array, it offers fast and efficient access to individual
+   *  elements in any order and saves the user from worrying about
+   *  memory and size allocation.  Subscripting ( @c [] ) access is
+   *  also provided as with C-style arrays.
   */
-template <typename _Alloc> 
+template<typename _Alloc> 
   class vector<bool, _Alloc> : public _Bvector_base<_Alloc> 
   {
   public:
@@ -370,7 +459,7 @@ template <typename _Alloc>
       }
     }
   
-    template <class _InputIterator>
+    template<class _InputIterator>
     void _M_initialize_range(_InputIterator __first, _InputIterator __last,
                              input_iterator_tag) {
       this->_M_start = iterator();
@@ -380,7 +469,7 @@ template <typename _Alloc>
         push_back(*__first);
     }
   
-    template <class _ForwardIterator>
+    template<class _ForwardIterator>
     void _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last,
                              forward_iterator_tag) {
       size_type __n = std::distance(__first, __last);
@@ -388,7 +477,7 @@ template <typename _Alloc>
       std::copy(__first, __last, this->_M_start);
     }
   
-    template <class _InputIterator>
+    template<class _InputIterator>
     void _M_insert_range(iterator __pos,
                          _InputIterator __first, _InputIterator __last,
                          input_iterator_tag) {
@@ -398,7 +487,7 @@ template <typename _Alloc>
       }
     }
   
-    template <class _ForwardIterator>
+    template<class _ForwardIterator>
     void _M_insert_range(iterator __position,
                          _ForwardIterator __first, _ForwardIterator __last,
                          forward_iterator_tag) {
@@ -462,7 +551,7 @@ template <typename _Alloc>
       { _M_range_check(__n); return (*this)[__n]; }
   
     explicit vector(const allocator_type& __a = allocator_type())
-      : _Bvector_base<_Alloc>(__a) {}
+      : _Bvector_base<_Alloc>(__a) { }
   
     vector(size_type __n, bool __value,
               const allocator_type& __a = allocator_type())
@@ -486,19 +575,19 @@ template <typename _Alloc>
   
     // Check whether it's an integral type.  If so, it's not an iterator.
   
-    template <class _Integer>
+    template<class _Integer>
     void _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) {
       _M_initialize(__n);
       std::fill(this->_M_start._M_p, this->_M_end_of_storage, __x ? ~0 : 0);
     }
   
-    template <class _InputIterator>
+    template<class _InputIterator>
     void _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
                                 __false_type) {
       _M_initialize_range(__first, __last, std::__iterator_category(__first));
     }
   
-    template <class _InputIterator>
+    template<class _InputIterator>
     vector(_InputIterator __first, _InputIterator __last,
              const allocator_type& __a = allocator_type())
       : _Bvector_base<_Alloc>(__a)
@@ -538,21 +627,21 @@ template <typename _Alloc>
   
     void assign(size_t __n, bool __x) { _M_fill_assign(__n, __x); }
   
-    template <class _InputIterator>
+    template<class _InputIterator>
     void assign(_InputIterator __first, _InputIterator __last) {
       typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
       _M_assign_dispatch(__first, __last, _Integral());
     }
   
-    template <class _Integer>
+    template<class _Integer>
     void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
       { _M_fill_assign((size_t) __n, (bool) __val); }
   
-    template <class _InputIterator>
+    template<class _InputIterator>
     void _M_assign_dispatch(_InputIterator __first, _InputIterator __last, __false_type)
       { _M_assign_aux(__first, __last, std::__iterator_category(__first)); }
   
-    template <class _InputIterator>
+    template<class _InputIterator>
     void _M_assign_aux(_InputIterator __first, _InputIterator __last,
                        input_iterator_tag) {
       iterator __cur = begin();
@@ -564,7 +653,7 @@ template <typename _Alloc>
         insert(end(), __first, __last);
     }
   
-    template <class _ForwardIterator>
+    template<class _ForwardIterator>
     void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
                        forward_iterator_tag) {
       size_type __len = std::distance(__first, __last);
@@ -625,20 +714,20 @@ template <typename _Alloc>
   
     // Check whether it's an integral type.  If so, it's not an iterator.
   
-    template <class _Integer>
+    template<class _Integer>
     void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
                             __true_type) {
       _M_fill_insert(__pos, __n, __x);
     }
   
-    template <class _InputIterator>
+    template<class _InputIterator>
     void _M_insert_dispatch(iterator __pos,
                             _InputIterator __first, _InputIterator __last,
                             __false_type) {
       _M_insert_range(__pos, __first, __last, std::__iterator_category(__first));
     }
   
-    template <class _InputIterator>
+    template<class _InputIterator>
     void insert(iterator __position,
                 _InputIterator __first, _InputIterator __last) {
       typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
@@ -695,9 +784,6 @@ template <typename _Alloc>
   
     void clear() { erase(begin(), end()); }
   };
-
-  // This typedef is non-standard.  It is provided for backward compatibility.
-  typedef vector<bool, __alloc> bit_vector;
 } // namespace __gnu_norm
 
-#endif /* _BVECTOR_H */
+#endif 
index 83d13ad..fd9f6a9 100644 (file)
@@ -94,7 +94,7 @@ namespace __gnu_norm
       }
       
       ~_Vector_base() 
-      { _M_deallocate(this->_M_start,
+      { _M_deallocate(this->_M_start, 
                      this->_M_end_of_storage - this->_M_start); }
 
     public:
index 54540c4..f81a858 100644 (file)
@@ -1,6 +1,6 @@
 // Hashtable implementation used by containers -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004 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
@@ -91,8 +91,8 @@ struct _Hashtable_node
   _Val _M_val;
 };
 
-template <class _Val, class _Key, class _HashFcn,
-          class _ExtractKey, class _EqualKey, class _Alloc = std::__alloc>
+template <class _Val, class _Key, class _HashFcn, class _ExtractKey, 
+         class _EqualKey, class _Alloc = std::allocator<_Val> >
 class hashtable;
 
 template <class _Val, class _Key, class _HashFcn,
index 5545a58..c8533b8 100644 (file)
@@ -1,6 +1,6 @@
 // Allocator that wraps "C" malloc -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004 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
@@ -31,7 +31,6 @@
 #define _MALLOC_ALLOCATOR_H 1
 
 #include <new>
-#include <memory>
 
 namespace __gnu_cxx
 {
@@ -78,7 +77,7 @@ namespace __gnu_cxx
       // NB: __n is permitted to be 0.  The C++ standard says nothing
       // about what the return value is when __n == 0.
       pointer
-      allocate(size_type __n, std::allocator<void>::const_pointer __h = 0)
+      allocate(size_type __n, const void* __h = 0)
       { return static_cast<_Tp*>(malloc(__n * sizeof(_Tp))); }
 
       // __p is not permitted to be a null pointer.
index bd0945a..9bb7bf4 100644 (file)
@@ -36,8 +36,6 @@
 #define _MT_ALLOCATOR_H 1
 
 #include <new>
-#include <memory>
-#include <cstdlib>
 #include <bits/functexcept.h>
 #include <bits/gthr.h>
 #include <bits/atomicity.h>
@@ -230,7 +228,7 @@ namespace __gnu_cxx
 
     public:
       pointer
-      allocate(size_t __n, std::allocator<void>::const_pointer __h = 0)
+      allocate(size_t __n, const void* __h = 0)
       {
         /*
          * Although the test in __gthread_once() would suffice, we
@@ -260,7 +258,7 @@ namespace __gnu_cxx
           {
             void* __ret = ::operator new(__n * sizeof(_Tp));
             if (!__ret)
-              __throw_bad_alloc();
+              std::__throw_bad_alloc();
             return static_cast<_Tp*>(__ret);
           }
 
@@ -314,10 +312,10 @@ namespace __gnu_cxx
                     __gthread_mutex_unlock(_S_bin[bin].mutex);
 
                     _S_bin[bin].first[thread_id] =
-                      static_cast<block_record*>(::operator new(_S_chunk_size));
+                     static_cast<block_record*>(::operator new(_S_chunk_size));
 
                     if (!_S_bin[bin].first[thread_id])
-                      __throw_bad_alloc();
+                      std::__throw_bad_alloc();
 
                     _S_bin[bin].free[thread_id] = block_count;
 
@@ -385,7 +383,7 @@ namespace __gnu_cxx
                   static_cast<block_record*>(::operator new(_S_chunk_size));
 
                 if (!_S_bin[bin].first[0])
-                  __throw_bad_alloc();
+                  std::__throw_bad_alloc();
 
                 size_t bin_t = 1 << bin;
                 size_t block_count = 
@@ -441,11 +439,11 @@ namespace __gnu_cxx
       {
         /*
          * Requests larger than _S_max_bytes are handled by
-         * malloc/free directly
+         * operators new/delete directly
          */
         if (__n * sizeof(_Tp) > _S_max_bytes || _S_force_new)
           {
-            free(__p);
+            ::operator delete(__p);
             return;
           }
 
@@ -584,10 +582,10 @@ namespace __gnu_cxx
        * Setup the bin map for quick lookup of the relevant bin
        */
       _S_binmap = (binmap_type*)
-        malloc ((_S_max_bytes + 1) * sizeof(binmap_type));
+        ::operator new ((_S_max_bytes + 1) * sizeof(binmap_type));
 
       if (!_S_binmap)
-        __throw_bad_alloc();
+        std::__throw_bad_alloc();
 
       binmap_type* bp_t = _S_binmap;
       binmap_type bin_max_t = 1;
@@ -615,7 +613,7 @@ namespace __gnu_cxx
               new(sizeof(thread_record) * _S_max_threads));
 
           if (!_S_thread_freelist_first)
-            __throw_bad_alloc();
+            std::__throw_bad_alloc();
 
           /*
            * NOTE! The first assignable thread id is 1 since the global
@@ -651,7 +649,7 @@ namespace __gnu_cxx
         new(sizeof(bin_record) * _S_no_of_bins));
 
       if (!_S_bin)
-        __throw_bad_alloc();
+        std::__throw_bad_alloc();
 
       std::size_t __n = 1;
 
@@ -666,13 +664,13 @@ namespace __gnu_cxx
             new(sizeof(block_record*) * __n));
 
           if (!_S_bin[bin].first)
-            __throw_bad_alloc();
+            std::__throw_bad_alloc();
 
           _S_bin[bin].last = static_cast<block_record**>(::operator 
             new(sizeof(block_record*) * __n));
 
           if (!_S_bin[bin].last)
-            __throw_bad_alloc();
+            std::__throw_bad_alloc();
 
 #ifdef __GTHREADS
           if (__gthread_active_p())
@@ -681,13 +679,13 @@ namespace __gnu_cxx
                 new(sizeof(size_t) * __n));
 
               if (!_S_bin[bin].free)
-                __throw_bad_alloc();
+                std::__throw_bad_alloc();
 
               _S_bin[bin].used = static_cast<size_t*>(::operator 
                 new(sizeof(size_t) * __n));
 
               if (!_S_bin[bin].used)
-                __throw_bad_alloc();
+                std::__throw_bad_alloc();
 
               _S_bin[bin].mutex = static_cast<__gthread_mutex_t*>(::operator 
                 new(sizeof(__gthread_mutex_t)));
@@ -781,8 +779,8 @@ namespace __gnu_cxx
   __mt_alloc<_Tp>::_S_once_mt = __GTHREAD_ONCE_INIT;
 #endif
 
-  template<typename _Tp> bool
-  volatile __mt_alloc<_Tp>::_S_initialized = false;
+  template<typename _Tp> 
+  bool volatile __mt_alloc<_Tp>::_S_initialized = false;
 
   template<typename _Tp> bool
   __mt_alloc<_Tp>::_S_force_new = false;
@@ -792,7 +790,7 @@ namespace __gnu_cxx
 
   /*
    * Allocation requests (after round-up to power of 2) below this
-   * value will be handled by the allocator. A raw malloc/free() call
+   * value will be handled by the allocator. A raw new/ call
    * will be used for requests larger than this value.
    */
   template<typename _Tp> size_t
@@ -853,14 +851,12 @@ namespace __gnu_cxx
 
   template<typename _Tp>
     inline bool
-    operator==(const __mt_alloc<_Tp>&,
-               const __mt_alloc<_Tp>&)
+    operator==(const __mt_alloc<_Tp>&, const __mt_alloc<_Tp>&)
     { return true; }
   
   template<typename _Tp>
     inline bool
-    operator!=(const __mt_alloc<_Tp>&,
-               const __mt_alloc<_Tp>&)
+    operator!=(const __mt_alloc<_Tp>&, const __mt_alloc<_Tp>&)
     { return false; }
 } // namespace __gnu_cxx
 
index 6c8ca63..e52c82e 100644 (file)
@@ -1,6 +1,6 @@
 // Allocator that wraps operator new -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004 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
@@ -77,7 +77,7 @@ namespace __gnu_cxx
       // NB: __n is permitted to be 0.  The C++ standard says nothing
       // about what the return value is when __n == 0.
       pointer
-      allocate(size_type __n, allocator<void>::const_pointer __h = 0)
+      allocate(size_type __n, const void* __h = 0)
       { return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp))); }
 
       // __p is not permitted to be a null pointer.
index 02303de..2893890 100644 (file)
@@ -1,6 +1,6 @@
 // Allocators -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004 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
@@ -51,7 +51,6 @@
 #include <bits/functexcept.h>
 #include <bits/stl_threads.h>
 #include <bits/atomicity.h>
-#include <bits/allocator_traits.h>
 
 namespace __gnu_cxx
 {
@@ -360,33 +359,4 @@ namespace __gnu_cxx
 #endif
 } // namespace __gnu_cxx
 
-namespace std
-{
-  //@{
-  /// Versions for the predefined "SGI" style allocators.
-  template<typename _Tp, bool __thr, int __inst>
-    struct _Alloc_traits<_Tp, __gnu_cxx::__pool_alloc<__thr, __inst> >
-    {
-      static const bool _S_instanceless = true;
-      typedef __gnu_cxx::__pool_alloc<__thr, __inst>   base_alloc_type;
-      typedef __simple_alloc<_Tp, base_alloc_type>     _Alloc_type;
-      typedef __allocator<_Tp, base_alloc_type>                allocator_type;
-    };
-  //@}
-
-  //@{
-  /// Versions for the __allocator adaptor used with the predefined
-  /// "SGI" style allocators.
-  template<typename _Tp, typename _Tp1, bool __thr, int __inst>
-    struct _Alloc_traits<_Tp, __allocator<_Tp1,
-                                    __gnu_cxx::__pool_alloc<__thr, __inst> > >
-    {
-      static const bool _S_instanceless = true;
-      typedef __gnu_cxx::__pool_alloc<__thr, __inst>   base_alloc_type;
-      typedef __simple_alloc<_Tp, base_alloc_type>     _Alloc_type;
-      typedef __allocator<_Tp, base_alloc_type>                allocator_type;
-    };
-  //@}
-} // namespace std
-
 #endif
index 0c92de4..0e545fe 100644 (file)
@@ -1,6 +1,6 @@
 // SGI's rope class implementation -*- C++ -*-
 
-// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004 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
@@ -59,7 +59,6 @@ namespace __gnu_cxx
   using std::printf;
   using std::basic_ostream;
   using std::__throw_length_error;
-  using std::__alloc;
   using std::_Destroy;
   using std::uninitialized_fill_n;
 
@@ -875,15 +874,15 @@ bool rope<_CharT, _Alloc>::_S_apply_to_pieces(
                size_t __len = __end - __begin;
                bool __result;
                _CharT* __buffer =
-                 (_CharT*)__alloc::allocate(__len * sizeof(_CharT));
+                 (_CharT*)_Alloc::allocate(__len * sizeof(_CharT));
                try {
                  (*(__f->_M_fn))(__begin, __len, __buffer);
                  __result = __c(__buffer, __len);
-                  __alloc::deallocate(__buffer, __len * sizeof(_CharT));
+                  _Alloc::deallocate(__buffer, __len * sizeof(_CharT));
                 }
                catch(...)
                  {
-                   __alloc::deallocate(__buffer, __len * sizeof(_CharT));
+                   _Alloc::deallocate(__buffer, __len * sizeof(_CharT));
                    __throw_exception_again;
                  }
                return __result;
index 3b4f675..f51ea39 100644 (file)
@@ -91,6 +91,7 @@ basic_file.cc: ${glibcxx_srcdir}/$(BASIC_FILE_CC)
 
 # Sources present in the src directory.
 sources = \
+       allocator.cc \
        codecvt.cc \
        complex_io.cc \
        ctype.cc \
index d6cc47c..ff570f9 100644 (file)
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.7.9 from Makefile.am.
+# Makefile.in generated by automake 1.7.8 from Makefile.am.
 # @configure_input@
 
 # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
@@ -247,6 +247,7 @@ host_sources_extra = \
 
 # Sources present in the src directory.
 sources = \
+       allocator.cc \
        codecvt.cc \
        complex_io.cc \
        ctype.cc \
@@ -360,10 +361,10 @@ am__objects_1 = codecvt_members.lo collate_members.lo ctype_members.lo \
        messages_members.lo monetary_members.lo numeric_members.lo \
        time_members.lo
 am__objects_2 = basic_file.lo c++locale.lo
-am__objects_3 = codecvt.lo complex_io.lo ctype.lo debug.lo demangle.lo \
-       functexcept.lo globals_locale.lo globals_io.lo ios.lo \
-       ios_failure.lo ios_init.lo ios_locale.lo limits.lo list.lo \
-       locale.lo locale_init.lo locale_facets.lo localename.lo \
+am__objects_3 = allocator.lo codecvt.lo complex_io.lo ctype.lo debug.lo \
+       demangle.lo functexcept.lo globals_locale.lo globals_io.lo \
+       ios.lo ios_failure.lo ios_init.lo ios_locale.lo limits.lo \
+       list.lo locale.lo locale_init.lo locale_facets.lo localename.lo \
        stdexcept.lo strstream.lo tree.lo allocator-inst.lo \
        concept-inst.lo fstream-inst.lo ext-inst.lo io-inst.lo \
        istream-inst.lo locale-inst.lo locale-misc-inst.lo misc-inst.lo \
@@ -552,7 +553,7 @@ install-am: all-am
 installcheck: installcheck-am
 install-strip:
        $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-         install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+         INSTALL_STRIP_FLAG=-s \
          `test -z '$(STRIP)' || \
            echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
 mostlyclean-generic:
index 24a7b41..3fcbb60 100644 (file)
@@ -1,6 +1,6 @@
 // Explicit instantiation file.
 
-// Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 1999, 2001, 2002, 2003, 2004 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
@@ -39,8 +39,3 @@ namespace std
   template class allocator<char>;
   template class allocator<wchar_t>;
 } // namespace std
-
-namespace __gnu_cxx
-{
-  template class __pool_alloc<true, 0>;
-} // namespace __gnu_cxx
diff --git a/libstdc++-v3/src/allocator.cc b/libstdc++-v3/src/allocator.cc
new file mode 100644 (file)
index 0000000..c2f0847
--- /dev/null
@@ -0,0 +1,57 @@
+// Allocator details.
+
+// Copyright (C) 2004 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:
+//
+
+#include <bits/c++config.h>
+#include <memory>
+#include <ext/mt_allocator.h>
+#include <ext/pool_allocator.h>
+
+// Explicitly instantiate the static data members of the underlying
+// allocator.
+namespace __gnu_cxx
+{
+  // Static data members and member functions of __mt_alloc.
+  static template class __mt_alloc<char>;
+
+  template
+    void __mt_alloc<char>::_S_init();
+
+   template
+    size_t __mt_alloc<char>::_S_get_thread_id();
+
+   template
+    void __mt_alloc<char>::_S_thread_key_destr(void*);
+
+  // Static members of __pool_alloc.
+  template class __pool_alloc<true, 0>;
+} // namespace __gnu_cxx
index 4170a9d..8d35be3 100644 (file)
@@ -1,6 +1,6 @@
 // 2001-06-14  Benjamin Kosnik  <bkoz@redhat.com>
 
-// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2004 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
@@ -58,32 +58,8 @@ void test01()
   VERIFY( check_delete );
 }
 
-// libstdc++/8230
-void test02()
-{
-  bool test __attribute__((unused)) = true;
-  try 
-    {
-      std::allocator<int> alloc;
-      const std::allocator<int>::size_type n = alloc.max_size();
-      int* p = alloc.allocate(n + 1);
-      p[n] = 2002;
-    } 
-  catch(const std::bad_alloc& e) 
-    {
-      // Allowed.
-      test = true;
-    }
-  catch(...) 
-    {
-      test = false;
-    }
-  VERIFY( test );
-}
-
 int main()
 {
   test01();
-  test02();
   return 0;
 }
diff --git a/libstdc++-v3/testsuite/20_util/allocator/8230.cc b/libstdc++-v3/testsuite/20_util/allocator/8230.cc
new file mode 100644 (file)
index 0000000..7747dd7
--- /dev/null
@@ -0,0 +1,54 @@
+// 2001-06-14  Benjamin Kosnik  <bkoz@redhat.com>
+
+// Copyright (C) 2001, 2002, 2004 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.
+
+// 20.4.1.1 allocator members
+
+#include <memory>
+#include <stdexcept>
+#include <testsuite_hooks.h>
+
+// libstdc++/8230
+void test02()
+{
+  bool test __attribute__((unused)) = true;
+  try 
+    {
+      std::allocator<int> alloc;
+      const std::allocator<int>::size_type n = alloc.max_size();
+      int* p = alloc.allocate(n + 1);
+      p[n] = 2002;
+    } 
+  catch(const std::bad_alloc& e) 
+    {
+      // Allowed.
+      test = true;
+    }
+  catch(...) 
+    {
+      test = false;
+    }
+  VERIFY( test );
+}
+
+int main()
+{
+  test02();
+  return 0;
+}