<td><memory></td>
</tr>
<tr>
- <td>__gnu_cxx::__pool_alloc<bool, int></td>
+ <td>__gnu_cxx::__pool_alloc<T></td>
<td><ext/pool_allocator.h></td>
<td>std::__default_alloc_template<bool,int></td>
<td><memory></td>
</tr>
</table>
- <p>More details on each of these allocators follows. </p>
+ <p> Releases after gcc-3.4 have continued to add to the collection
+ of available allocators. All of these new allocators are
+ standard-style. The following table includes details, along with
+ the first released version of GCC that included the extension allocator.
+ </p>
+
+<table title="more extension allocators" border="1">
+ <tr>
+ <th>Allocator</th>
+ <th>Include</th>
+ <th>Version</th>
+ </tr>
+ <tr>
+ <td>__gnu_cxx::array_allocator<T></td>
+ <td><ext/array_allocator.h></td>
+ <td>4.0.0</td>
+ </tr>
+</table>
+
+ <p>More details on each of these extension allocators follows. </p>
<ul>
<li><code>new_allocator</code>
<p>Simply wraps <code>::operator new</code>
elsewhere).
</p>
</li>
+ <li><code>array_allocator</code>
+ <p>Allows allocations of known and fixed sizes using existing
+ global or external storage allocated via construction of
+ std::tr1::array objects. By using this allocator, fixed size
+ containers (including std::string) can be used without
+ instances calling <code>::operator new</code> and
+ <code>::operator delete</code>. This capability allows the
+ use of STL abstractions without runtime complications or
+ overhead, even in situations such as program startup. For
+ usage examples, please consult the libstdc++ testsuite.
+ </p>
+ </li>
<li><code>debug_allocator</code>
<p> A wrapper around an
arbitrary allocator A. It passes on slightly increased size
and the allocate/deallocate request is passed to
<code>::operator new</code> directly. </p>
- <p> This class take a boolean template parameter, called
- <code>thr</code>, and an integer template parameter, called
- <code>inst</code>.
+ <p> For versions of <code>__pool_alloc</code> after 3.4.0, there is
+ only one template parameter, as per the standard.
+ </p>
+
+ <p> Older versions of this class take a boolean template parameter,
+ called <code>thr</code>, and an integer template parameter,
+ called <code>inst</code>.
</p>
+
<p>The <code>inst</code> number is used to track additional memory
pools. The point of the number is to allow multiple
instantiations of the classes without changing the semantics at
is is threadsafe, while thr=false, and is slightly faster but
unsafe for multiple threads.
</p>
+
+ <p>For thread-enabled configurations, the pool is locked with a
+ single big lock. In some situations, this implementation detail may
+ result in severe performance degredation.
+ </p>
+
<p>(Note that the GCC thread abstraction layer allows us to provide safe
zero-overhead stubs for the threading routines, if threads were
disabled at configuration time.)
--- /dev/null
+// 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.
+
+#include <cassert>
+#include <string>
+#include <ext/array_allocator.h>
+
+typedef char char_type;
+typedef std::char_traits<char_type> traits_type;
+typedef std::tr1::array<char_type, 4> array_type;
+
+array_type extern_array;
+
+void test01()
+{
+ using std::basic_string;
+ typedef __gnu_cxx::array_allocator<char_type, array_type> allocator_type;
+ typedef basic_string<char_type, traits_type, allocator_type> string_type;
+
+ // Construct array_allocator without underlying array.
+ allocator_type a;
+ string_type s(a);
+
+ try
+ {
+ s.reserve(4); // Actually need 4 + 1 + sizeof(std::string::_Rep).
+ }
+ catch(std::bad_alloc& obj)
+ {
+ assert(true);
+ }
+ catch(...)
+ {
+ assert(false);
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}