
2001-09-17 Phil Edwards <pme@gcc.gnu.org> * docs/html/configopts.html: HTML to XHTML change. Lowercase tags. * docs/html/documentation.html: Likewise. * docs/html/explanations.html: Likewise. * docs/html/install.html: Likewise. * docs/html/17_intro/howto.html: Likewise. * docs/html/18_support/howto.html: Likewise. * docs/html/19_diagnostics/howto.html: Likewise. * docs/html/20_util/howto.html: Likewise. * docs/html/21_strings/howto.html: Likewise. * docs/html/22_locale/codecvt.html: Likewise. * docs/html/22_locale/ctype.html: Likewise. * docs/html/22_locale/howto.html: Likewise. * docs/html/22_locale/locale.html: Likewise. * docs/html/22_locale/messages.html: Likewise. * docs/html/23_containers/howto.html: Likewise. * docs/html/24_iterators/howto.html: Likewise. * docs/html/25_algorithms/howto.html: Likewise. * docs/html/26_numerics/howto.html: Likewise. * docs/html/27_io/howto.html: Likewise. * docs/html/ext/howto.html: Likewise. * docs/html/faq/index.html: Likewise. * docs/html/faq/index.txt: Regenerated. From-SVN: r45668
174 lines
7.1 KiB
HTML
174 lines
7.1 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
|
<html>
|
|
<head>
|
|
<meta HcodeP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
|
|
<meta NAME="AUTHOR" CONTENT="pme@gcc.gnu.org (Phil Edwards)">
|
|
<meta NAME="KEYWORDS" CONTENT="HOWTO, libstdc++, GCC, g++, libg++, STL">
|
|
<meta NAME="DESCRIPTION" CONTENT="Notes for the libstdc++ extensions.">
|
|
<meta NAME="GENERATOR" CONTENT="vi and eight fingers">
|
|
<title>libstdc++-v3 HOWTO: Extensions</title>
|
|
<link REL=StyleSheet HREF="../lib3styles.css">
|
|
<!-- $Id: howto.html,v 1.5 2001/05/30 21:55:04 pme Exp $ -->
|
|
</head>
|
|
<body>
|
|
|
|
<h1 CLASS="centered"><a name="top">Extensions</a></h1>
|
|
|
|
<p>Here we will make an attempt at describing the non-Standard extensions to
|
|
the library. Some of these are from SGI's STL, some of these are GNU's,
|
|
and some just seemed to appear on the doorstep.
|
|
</p>
|
|
<p><B>Before you leap in and use these</B>, be aware of two things:
|
|
<ol>
|
|
<li>Non-Standard means exactly that. The behavior, and the very
|
|
existence, of these extensions may change with little or no
|
|
warning. (Ideally, the really good ones will appear in the next
|
|
revision of C++.) Also, other platforms, other compilers, other
|
|
versions of g++ or libstdc++-v3 may not recognize these names, or
|
|
treat them differently, or...
|
|
<li>You should know how to <a href="../faq/index.html#5_4">access
|
|
these headers properly</a>.
|
|
</ol>
|
|
</p>
|
|
|
|
|
|
<!-- ####################################################### -->
|
|
<hr>
|
|
<h1>Contents</h1>
|
|
<ul>
|
|
<li><a href="#1">Ropes and trees and hashes, oh my!</a>
|
|
<li><a href="#2">Added members</a>
|
|
<li><a href="#3">Allocators</a>
|
|
<li><a href="#4">Compile-time checks</a>
|
|
</ul>
|
|
|
|
<hr>
|
|
|
|
<!-- ####################################################### -->
|
|
|
|
<h2><a name="1">Ropes and trees and hashes, oh my!</a></h2>
|
|
<p>The SGI headers
|
|
<PRE>
|
|
<bvector>
|
|
<hash_map>
|
|
<hash_set>
|
|
<rope>
|
|
<slist>
|
|
<tree>
|
|
</PRE> are all here; <code><bvector></code> exposes the old bit_vector
|
|
class that was used before specialization of vector<bool> was
|
|
available (it's actually a typedef for the specialization now).
|
|
<code><hash_map></code> and <code><hash_set></code>
|
|
are discussed further below. <code><rope></code> is the SGI
|
|
specialization for large strings ("rope," "large
|
|
strings," get it? love those SGI folks).
|
|
<code><slist></code> is a singly-linked list, for when the
|
|
doubly-linked <code>list<></code> is too much space overhead, and
|
|
<code><tree></code> exposes the red-black tree classes used in the
|
|
implementation of the standard maps and sets.
|
|
</p>
|
|
<p>Okay, about those hashing classes... I'm going to foist most of the
|
|
work off onto SGI's own site.
|
|
</p>
|
|
<p>Each of the associative containers map, multimap, set, and multiset
|
|
have a counterpart which uses a
|
|
<a href="http://www.sgi.com/Technology/STL/HashFunction.html">hashing
|
|
function</a> to do the arranging, instead of a strict weak ordering
|
|
function. The classes take as one of their template parameters a
|
|
function object that will return the hash value; by default, an
|
|
instantiation of
|
|
<a href="http://www.sgi.com/Technology/STL/hash.html">hash</a>.
|
|
You should specialize this functor for your class, or define your own,
|
|
before trying to use one of the hashing classes.
|
|
</p>
|
|
<p>The hashing classes support all the usual associative container
|
|
functions, as well as some extra constructors specifying the number
|
|
of buckets, etc.
|
|
</p>
|
|
<p>Why would you want to use a hashing class instead of the
|
|
"normal" implementations? Matt Austern writes:
|
|
<BLOCKQUOTE><em>[W]ith a well chosen hash function, hash tables
|
|
generally provide much better average-case performance than binary
|
|
search trees, and much worse worst-case performance. So if your
|
|
implementation has hash_map, if you don't mind using nonstandard
|
|
components, and if you aren't scared about the possibility of
|
|
pathological cases, you'll probably get better performance from
|
|
hash_map.</em></BLOCKQUOTE>
|
|
</p>
|
|
<p>(Side note: for those of you wondering, <B>"Why wasn't a hash
|
|
table included in the Standard in the first #!$@ place?"</B> I'll
|
|
give a quick answer: it was proposed, but too late and in too
|
|
unorganized a fashion. Some sort of hashing will undoubtedly be
|
|
included in a future Standard.
|
|
</p>
|
|
<p>Return <a href="#top">to top of page</a> or
|
|
<a href="../faq/index.html">to the FAQ</a>.
|
|
</p>
|
|
|
|
<hr>
|
|
<h2><a name="2">Added members</a></h2>
|
|
<p>Some of the classes in the Standard Library have additional
|
|
publicly-available members. Of those, some are intended purely for
|
|
the implementors, for example, additional typedefs. Those won't be
|
|
described here (or anywhere else). This list will grow slowly, since
|
|
we expect it to be rare -- most extensions will be self-contained.
|
|
</p>
|
|
<p>
|
|
<ul>
|
|
<li><code>filebuf</code>s have another ctor with this signature:<br>
|
|
<code>basic_filebuf(__c_file_type*, ios_base::openmode, int_type);</code>
|
|
<br>This comes in very handy in a number of places, such as
|
|
attaching Unix sockets, pipes, and anything else which uses file
|
|
descriptors, into the IOStream buffering classes. The three
|
|
arguments are as follows:
|
|
<ul>
|
|
<li><code>__c_file_type* F </code>
|
|
// the __c_file_type typedef usually boils down to stdio's FILE
|
|
<li><code>ios_base::openmode M </code>
|
|
// same as all the other uses of openmode
|
|
<li><code>int_type B </code>
|
|
// buffer size, defaults to BUFSIZ
|
|
</ul>
|
|
For those wanting to use file descriptors instead of FILE*'s, I
|
|
invite you to contemplate the mysteries of C's <code>fdopen()</code>.
|
|
</ul>
|
|
</p>
|
|
<p>Return <a href="#top">to top of page</a> or
|
|
<a href="../faq/index.html">to the FAQ</a>.
|
|
</p>
|
|
|
|
<hr>
|
|
<h2><a name="3">Allocators</a></h2>
|
|
<p>This will be blank for a while. It will describe all of the different
|
|
memory allocators, most inherited from SGI's code. Input is solicited.
|
|
</p>
|
|
<p>Return <a href="#top">to top of page</a> or
|
|
<a href="../faq/index.html">to the FAQ</a>.
|
|
</p>
|
|
|
|
<hr>
|
|
<h2><a name="4">Compile-time checks</a></h2>
|
|
<p>Currently libstdc++-v3 uses the concept checkers from the Boost
|
|
library to perform <a href="../19_diagnostics/howto.html#3">optional
|
|
compile-time checking</a> of template instantiations of the standard
|
|
containers. They are described in the linked-to page.
|
|
</p>
|
|
<p>Return <a href="#top">to top of page</a> or
|
|
<a href="../faq/index.html">to the FAQ</a>.
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<!-- ####################################################### -->
|
|
|
|
<hr>
|
|
<P CLASS="fineprint"><em>
|
|
Comments and suggestions are welcome, and may be sent to
|
|
<a href="mailto:libstdc++@gcc.gnu.org">the mailing list</a>.
|
|
<br> $Id: howto.html,v 1.5 2001/05/30 21:55:04 pme Exp $
|
|
</em></p>
|
|
|
|
|
|
</body>
|
|
</html>
|