Commit 0435269a by Phil Edwards

configopts.html: More HTML->XHTML and lowercasing of tags.

2001-10-09  Phil Edwards  <pme@gcc.gnu.org>

	* docs/html/configopts.html:  More HTML->XHTML and lowercasing of 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/17_intro/license.html:  Likewise.  Tighten up language.
	* 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/howto.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/ext/sgiexts.html:  Likewise.
	* docs/html/faq/index.html:  Likewise.  Not so many absolute links.
	* docs/html/faq/index.txt:  Regenerate.

From-SVN: r46128
parent 0d47f086
2001-10-09 Phil Edwards <pme@gcc.gnu.org>
* docs/html/configopts.html: More HTML->XHTML and lowercasing of 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/17_intro/license.html: Likewise. Tighten up language.
* 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/howto.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/ext/sgiexts.html: Likewise.
* docs/html/faq/index.html: Likewise. Not so many absolute links.
* docs/html/faq/index.txt: Regenerate.
2001-10-07 Joseph S. Myers <jsm28@cam.ac.uk> 2001-10-07 Joseph S. Myers <jsm28@cam.ac.uk>
* docs/html/22_locale/locale.html, docs/html/faq/index.html: Fix * docs/html/22_locale/locale.html, docs/html/faq/index.html: Fix
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html> <html>
<head> <head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta NAME="AUTHOR" CONTENT="pme@gcc.gnu.org (Phil Edwards)"> <meta name="AUTHOR" content="pme@gcc.gnu.org (Phil Edwards)">
<meta NAME="KEYWORDS" CONTENT="HOWTO, libstdc++, gcc, g++, libg++, STL"> <meta name="KEYWORDS" content="HOWTO, libstdc++, gcc, g++, libg++, STL">
<meta NAME="DESCRIPTION" CONTENT="HOWTO for libstdc++ chapter 17."> <meta name="DESCRIPTION" content="HOWTO for libstdc++ chapter 17.">
<meta NAME="GENERATOR" CONTENT="vi and eight fingers"> <meta name="GENERATOR" content="vi and eight fingers">
<title>libstdc++-v3 HOWTO: Chapter 17</title> <title>libstdc++-v3 HOWTO: Chapter 17</title>
<link REL=StyleSheet HREF="../lib3styles.css"> <link rel=StyleSheet href="../lib3styles.css">
</head> </head>
<body> <body>
<h1 CLASS="centered"><a name="top">Chapter 17: Library Introduction</a></h1> <h1 class="centered"><a name="top">Chapter 17: Library Introduction</a></h1>
<p>Chapter 17 is actually a list of definitions and descriptions used <p>Chapter 17 is actually a list of definitions and descriptions used
in the following chapters of the Standard when describing the actual in the following chapters of the Standard when describing the actual
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<li><a href="#2">The Standard C++ header files</a> <li><a href="#2">The Standard C++ header files</a>
<li><a href="#3">Thread-safety</a> <li><a href="#3">Thread-safety</a>
<li><a href="#4"><code>&lt;foo&gt;</code> vs <code>&lt;foo.h&gt;</code></a> <li><a href="#4"><code>&lt;foo&gt;</code> vs <code>&lt;foo.h&gt;</code></a>
<li><a href="porting-howto.html">Porting-howto</a> <li><a href="porting-howto.html">Porting HOWTO</a>
</ul> </ul>
<hr> <hr>
...@@ -92,9 +92,9 @@ ...@@ -92,9 +92,9 @@
an application for high-speed using this implementation of the STL. an application for high-speed using this implementation of the STL.
Here is one possible example displaying the forcing of the malloc-based Here is one possible example displaying the forcing of the malloc-based
allocator over the typically higher-speed default allocator: allocator over the typically higher-speed default allocator:
<PRE> <pre>
std::list &lt;void*, std::malloc_alloc&gt; my_malloc_based_list; std::list &lt;void*, std::malloc_alloc&gt; my_malloc_based_list;
</PRE> </pre>
</p> </p>
<p>A recent journal article has described &quot;atomic integer <p>A recent journal article has described &quot;atomic integer
operations,&quot; which would allow us to, well, perform updates operations,&quot; which would allow us to, well, perform updates
...@@ -177,10 +177,10 @@ ...@@ -177,10 +177,10 @@
<!-- ####################################################### --> <!-- ####################################################### -->
<hr> <hr>
<P CLASS="fineprint"><em> <p class="fineprint"><em>
See <a href="license.html">license.html</a> for copying conditions. See <a href="license.html">license.html</a> for copying conditions.
Comments and suggestions are welcome, and may be sent to Comments and suggestions are welcome, and may be sent to
<a href="mailto:libstdc++@gcc.gnu.org">the mailing list</a>. <a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.
</em></p> </em></p>
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html> <html>
<head> <head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta NAME="AUTHOR" CONTENT="pme@gcc.gnu.org (Phil Edwards)"> <meta name="AUTHOR" content="pme@gcc.gnu.org (Phil Edwards)">
<meta NAME="KEYWORDS" CONTENT="libstdc++, license, licence"> <meta name="KEYWORDS" content="libstdc++, license, licence">
<meta NAME="DESCRIPTION" CONTENT="Copying restrictions for libstdc++."> <meta name="DESCRIPTION" content="Copying restrictions for libstdc++.">
<meta NAME="GENERATOR" CONTENT="vi and eight fingers"> <meta name="GENERATOR" content="vi and eight fingers">
<title>libstdc++-v3 copying</title> <title>libstdc++-v3 copying</title>
<link REL=StyleSheet HREF="../lib3styles.css"> <link rel=StyleSheet href="../lib3styles.css">
</head> </head>
<body> <body>
<h1 CLASS="centered"><a name="top">Licenses for the Library</a></h1> <h1 class="centered"><a name="top">Licenses for the Library</a></h1>
<p><strong>As long as this sentence is in place, this page isn't <p><strong>As long as this sentence is in place, this page isn't
official. It is still experimental if you are reading this.</strong></p> official. It is still experimental if you are reading this.</strong></p>
<p>There are two licenses affecting GNU libstdc++-v3: one for the code, and <p>There are two licenses affecting GNU libstdc++-v3: one for the code, and
one for the documentation. Here we will describe both of them, and try one for the documentation. Here we will describe both of them, and try
to answer some of the common questions. If you have more questions, ask the to answer some of the widespread questions. If you have more questions,
FSF or the gcc-help mailing list; the person writing this page is a ask the FSF or the
programmer, not a lawyer. <a href="http://gcc.gnu.org/lists.html">gcc mailing list</a>; the person
writing this page is a programmer, not a lawyer.
</p> </p>
<hr> <hr>
...@@ -44,8 +45,7 @@ official. It is still experimental if you are reading this.</strong></p> ...@@ -44,8 +45,7 @@ official. It is still experimental if you are reading this.</strong></p>
</p> </p>
<p>Hopefully that text is self-explanatory. If it isn't, you need to speak <p>Hopefully that text is self-explanatory. If it isn't, you need to speak
to your lawyer, or the Free Software Foundation. I am not a legal expert. to your lawyer, or the Free Software Foundation.
I do not even play one on television.
</p> </p>
<!-- Most of the Q&A's are based on, paraphrased from, and outright stolen <!-- Most of the Q&A's are based on, paraphrased from, and outright stolen
...@@ -75,15 +75,6 @@ official. It is still experimental if you are reading this.</strong></p> ...@@ -75,15 +75,6 @@ official. It is still experimental if you are reading this.</strong></p>
but we won't punish you or sue you if you choose otherwise. but we won't punish you or sue you if you choose otherwise.
</p> </p>
<!-- Someone would probably shoot me if I uncommented this.
<p><strong>Q: I heard that the startup code for libstdc++-v3 detects
what license the program uses, and makes my program crash if it isn't
an open source license! Is that true?</strong>
<br>A: You are paranoid and insane. Please calm down and try switching
to decaf.
</p>
-->
<hr> <hr>
<h2>The Docs: FDL</h2> <h2>The Docs: FDL</h2>
...@@ -105,9 +96,11 @@ official. It is still experimental if you are reading this.</strong></p> ...@@ -105,9 +96,11 @@ official. It is still experimental if you are reading this.</strong></p>
<!-- ####################################################### --> <!-- ####################################################### -->
<hr> <hr>
<P CLASS="fineprint"><em> <p class="fineprint"><em>
Comments and suggestions are welcome, and may be sent to Comments and suggestions about this page are welcome, and may be sent to
<a href="mailto:libstdc++@gcc.gnu.org">the mailing list</a>. <a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.
Comments or questions about the licenses themselves are also welcome, and
should be directed to the GCC list as descibed above.
</em></p> </em></p>
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html> <html>
<head> <head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta NAME="AUTHOR" CONTENT="pme@gcc.gnu.org (Phil Edwards)"> <meta name="AUTHOR" content="pme@gcc.gnu.org (Phil Edwards)">
<meta NAME="KEYWORDS" CONTENT="HOWTO, libstdc++, GCC, g++, libg++, STL"> <meta name="KEYWORDS" content="HOWTO, libstdc++, GCC, g++, libg++, STL">
<meta NAME="DESCRIPTION" CONTENT="HOWTO for the libstdc++ chapter 18."> <meta name="DESCRIPTION" content="HOWTO for the libstdc++ chapter 18.">
<meta NAME="GENERATOR" CONTENT="vi and eight fingers"> <meta name="GENERATOR" content="vi and eight fingers">
<title>libstdc++-v3 HOWTO: Chapter 18</title> <title>libstdc++-v3 HOWTO: Chapter 18</title>
<link REL=StyleSheet HREF="../lib3styles.css"> <link rel=StyleSheet href="../lib3styles.css">
</head> </head>
<body> <body>
<h1 CLASS="centered"><a name="top">Chapter 18: Library Support</a></h1> <h1 class="centered"><a name="top">Chapter 18: Library Support</a></h1>
<p>Chapter 18 deals with the functions called and objects created <p>Chapter 18 deals with the functions called and objects created
automatically during the course of a program's existence. automatically during the course of a program's existence.
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
not overload on pointer-vs-integer types to begin with. He also not overload on pointer-vs-integer types to begin with. He also
offers a way to make your own magic NULL that will match pointers offers a way to make your own magic NULL that will match pointers
before it matches integers: before it matches integers:
<PRE> <pre>
const // this is a const object... const // this is a const object...
class { class {
public: public:
...@@ -76,7 +76,7 @@ ...@@ -76,7 +76,7 @@
// taken (see Item 27)... // taken (see Item 27)...
} NULL; // and whose name is NULL } NULL; // and whose name is NULL
</PRE>(Cribbed from the published version of </pre>(Cribbed from the published version of
<a href="http://www.awlonline.com/cseng/meyerscddemo/">the <a href="http://www.awlonline.com/cseng/meyerscddemo/">the
Effective C++ CD</a>, reproduced here with permission.) Effective C++ CD</a>, reproduced here with permission.)
</p> </p>
...@@ -87,7 +87,8 @@ ...@@ -87,7 +87,8 @@
<code>foo(0);</code> instead of <code>foo(NULL);</code>, then you're back <code>foo(0);</code> instead of <code>foo(NULL);</code>, then you're back
where you started. where you started.
</p> </p>
<p><B>Added Note:</B> When we contacted Dr. Meyers to ask permission to <p><strong>Added Note:</strong> When we contacted Dr. Meyers to ask
permission to
print this stuff, it prompted him to run this code through current print this stuff, it prompted him to run this code through current
compilers to see what the state of the art is with respect to member compilers to see what the state of the art is with respect to member
template functions. He posted template functions. He posted
...@@ -106,12 +107,12 @@ ...@@ -106,12 +107,12 @@
<hr> <hr>
<h2><a name="2">Implementation properties</a></h2> <h2><a name="2">Implementation properties</a></h2>
<p> <p>
<h3><CODE>&lt;limits&gt;</CODE></h3> <h3><code>&lt;limits&gt;</code></h3>
This header mainly defines traits classes to give access to various This header mainly defines traits classes to give access to various
implementation defined-aspects of the fundamental types. The implementation defined-aspects of the fundamental types. The
traits classes -- fourteen in total -- are all specilizations of the traits classes -- fourteen in total -- are all specilizations of the
template class <CODE>numeric_limits</CODE> defined as follows: template class <code>numeric_limits</code> defined as follows:
<PRE> <pre>
template&lt;typename T&gt; struct class { template&lt;typename T&gt; struct class {
static const bool is_specialized; static const bool is_specialized;
static T max() throw(); static T max() throw();
...@@ -147,7 +148,7 @@ ...@@ -147,7 +148,7 @@
static const bool traps; static const bool traps;
static const bool tinyness_before; static const bool tinyness_before;
static const float_round_style round_style; static const float_round_style round_style;
};</PRE> };</pre>
</p> </p>
<p>Return <a href="#top">to top of page</a> or <p>Return <a href="#top">to top of page</a> or
<a href="../faq/index.html">to the FAQ</a>. <a href="../faq/index.html">to the FAQ</a>.
...@@ -171,7 +172,7 @@ ...@@ -171,7 +172,7 @@
(This isn't actually new.) (This isn't actually new.)
<li>The previous two actions are &quot;interleaved,&quot; that is, <li>The previous two actions are &quot;interleaved,&quot; that is,
given this pseudocode: given this pseudocode:
<PRE> <pre>
extern "C or C++" void f1 (void); extern "C or C++" void f1 (void);
extern "C or C++" void f2 (void); extern "C or C++" void f2 (void);
...@@ -179,7 +180,7 @@ ...@@ -179,7 +180,7 @@
atexit(f1); atexit(f1);
static Thing obj2; static Thing obj2;
atexit(f2); atexit(f2);
</PRE>then at a call of <code>exit()</code>, f2 will be called, then </pre>then at a call of <code>exit()</code>, f2 will be called, then
obj2 will be destroyed, then f1 will be called, and finally obj1 obj2 will be destroyed, then f1 will be called, and finally obj1
will be destroyed. If f1 or f2 allow an exception to propogate will be destroyed. If f1 or f2 allow an exception to propogate
out of them, Bad Things happen. out of them, Bad Things happen.
...@@ -221,9 +222,9 @@ ...@@ -221,9 +222,9 @@
<p>By default, if one of the &quot;throwing <code>new</code>s&quot; can't <p>By default, if one of the &quot;throwing <code>new</code>s&quot; can't
allocate the memory requested, it tosses an instance of a allocate the memory requested, it tosses an instance of a
<code>bad_alloc</code> exception (or, technically, some class derived <code>bad_alloc</code> exception (or, technically, some class derived
from it). You can change this by writing your own function (called from it). You can change this by writing your own function (called a
a new-handler) and then registering it with <code>set_new_handler()</code>: new-handler) and then registering it with <code>set_new_handler()</code>:
<PRE> <pre>
typedef void (*PFV)(void); typedef void (*PFV)(void);
static char* safety; static char* safety;
...@@ -242,10 +243,10 @@ ...@@ -242,10 +243,10 @@
int main () int main ()
{ {
safety = new char[500000]; safety = new char[500000];
old_handler = set_new_handler (&my_new_handler); old_handler = set_new_handler (&amp;my_new_handler);
... ...
} }
</PRE> </pre>
</p> </p>
<p><code>bad_alloc</code> is derived from the base <code>exception</code> <p><code>bad_alloc</code> is derived from the base <code>exception</code>
class defined in Chapter 19. class defined in Chapter 19.
...@@ -256,15 +257,13 @@ ...@@ -256,15 +257,13 @@
<!-- ####################################################### --> <!-- ####################################################### -->
<hr> <hr>
<P CLASS="fineprint"><em> <p class="fineprint"><em>
See <a href="../17_intro/license.html">license.html</a> for copying conditions. See <a href="../17_intro/license.html">license.html</a> for copying conditions.
Comments and suggestions are welcome, and may be sent to Comments and suggestions are welcome, and may be sent to
<a href="mailto:libstdc++@gcc.gnu.org">the mailing list</a>. <a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.
</em></p> </em></p>
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html> <html>
<head> <head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta NAME="AUTHOR" CONTENT="pme@gcc.gnu.org (Phil Edwards)"> <meta name="AUTHOR" content="pme@gcc.gnu.org (Phil Edwards)">
<meta NAME="KEYWORDS" CONTENT="HOWTO, libstdc++, GCC, g++, libg++, STL"> <meta name="KEYWORDS" content="HOWTO, libstdc++, GCC, g++, libg++, STL">
<meta NAME="DESCRIPTION" CONTENT="HOWTO for the libstdc++ chapter 19."> <meta name="DESCRIPTION" content="HOWTO for the libstdc++ chapter 19.">
<meta NAME="GENERATOR" CONTENT="vi and eight fingers"> <meta name="GENERATOR" content="vi and eight fingers">
<title>libstdc++-v3 HOWTO: Chapter 19</title> <title>libstdc++-v3 HOWTO: Chapter 19</title>
<link REL=StyleSheet HREF="../lib3styles.css"> <link rel=StyleSheet href="../lib3styles.css">
</head> </head>
<body> <body>
<h1 CLASS="centered"><a name="top">Chapter 19: Diagnostics</a></h1> <h1 class="centered"><a name="top">Chapter 19: Diagnostics</a></h1>
<p>Chapter 19 deals with program diagnostics, such as exceptions <p>Chapter 19 deals with program diagnostics, such as exceptions
and assertions. You know, all the things we wish weren't even and assertions. You know, all the things we wish weren't even
...@@ -38,20 +38,19 @@ ...@@ -38,20 +38,19 @@
place). It's good to remember that you can add your own data to place). It's good to remember that you can add your own data to
these exceptions when extending the heirarchy: these exceptions when extending the heirarchy:
</p> </p>
<PRE> <pre>
using std::runtime_error; struct My_Exception : public std::runtime_error
struct My_Exception : public runtime_error
{ {
public: public:
My_Exception (const string&amp; whatarg) My_Exception (const string&amp; whatarg)
: runtime_error(whatarg), e(errno), id(GetDataBaseID()) { } : std::runtime_error(whatarg), e(errno), id(GetDataBaseID()) { }
int errno_at_time_of_throw() const { return e; } int errno_at_time_of_throw() const { return e; }
DBID id_of_thing_that_threw() const { return id; } DBID id_of_thing_that_threw() const { return id; }
protected: protected:
int e; int e;
DBID id; // some user-defined type DBID id; // some user-defined type
}; };
</PRE> </pre>
<p>Return <a href="#top">to top of page</a> or <p>Return <a href="#top">to top of page</a> or
<a href="../faq/index.html">to the FAQ</a>. <a href="../faq/index.html">to the FAQ</a>.
</p> </p>
...@@ -111,10 +110,10 @@ ...@@ -111,10 +110,10 @@
<!-- ####################################################### --> <!-- ####################################################### -->
<hr> <hr>
<P CLASS="fineprint"><em> <p class="fineprint"><em>
See <a href="../17_intro/license.html">license.html</a> for copying conditions. See <a href="../17_intro/license.html">license.html</a> for copying conditions.
Comments and suggestions are welcome, and may be sent to Comments and suggestions are welcome, and may be sent to
<a href="mailto:libstdc++@gcc.gnu.org">the mailing list</a>. <a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.
</em></p> </em></p>
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html> <html>
<head> <head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta NAME="AUTHOR" CONTENT="pme@gcc.gnu.org (Phil Edwards)"> <meta name="AUTHOR" content="pme@gcc.gnu.org (Phil Edwards)">
<meta NAME="KEYWORDS" CONTENT="HOWTO, libstdc++, GCC, g++, libg++, STL"> <meta name="KEYWORDS" content="HOWTO, libstdc++, GCC, g++, libg++, STL">
<meta NAME="DESCRIPTION" CONTENT="HOWTO for the libstdc++ chapter 20."> <meta name="DESCRIPTION" content="HOWTO for the libstdc++ chapter 20.">
<meta NAME="GENERATOR" CONTENT="vi and eight fingers"> <meta name="GENERATOR" content="vi and eight fingers">
<title>libstdc++-v3 HOWTO: Chapter 20</title> <title>libstdc++-v3 HOWTO: Chapter 20</title>
<link REL=StyleSheet HREF="../lib3styles.css"> <link rel=StyleSheet href="../lib3styles.css">
</head> </head>
<body> <body>
<h1 CLASS="centered"><a name="top">Chapter 20: General Utilities</a></h1> <h1 class="centered"><a name="top">Chapter 20: General Utilities</a></h1>
<p>Chapter 20 deals with utility classes and functions, such as <p>Chapter 20 deals with utility classes and functions, such as
the oft-debated <code>auto_ptr&lt;&gt;</code>. the oft-debated <code>auto_ptr&lt;&gt;</code>.
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
</p> </p>
<p>AP <em>is</em> meant to prevent nasty leaks in the presence of <p>AP <em>is</em> meant to prevent nasty leaks in the presence of
exceptions. That's <em>all</em>. This code is AP-friendly: exceptions. That's <em>all</em>. This code is AP-friendly:
<PRE> <pre>
// not a recommend naming scheme, but good for web-based FAQs // not a recommend naming scheme, but good for web-based FAQs
typedef std::auto_ptr&lt;MyClass&gt; APMC; typedef std::auto_ptr&lt;MyClass&gt; APMC;
...@@ -62,20 +62,20 @@ ...@@ -62,20 +62,20 @@
function_taking_MyClass_pointer (ap.get()); function_taking_MyClass_pointer (ap.get());
} }
</PRE>When an exception gets thrown, the instance of MyClass that's </pre>When an exception gets thrown, the instance of MyClass that's
been created on the heap will be <code>delete</code>'d as the stack is been created on the heap will be <code>delete</code>'d as the stack is
unwound past <code>func()</code>. unwound past <code>func()</code>.
</p> </p>
<p>Changing that code as follows is <em>not</em> AP-friendly: <p>Changing that code as follows is <em>not</em> AP-friendly:
<PRE> <pre>
APMC ap (new MyClass[22]); APMC ap (new MyClass[22]);
</PRE>You will get the same problems as you would without the use </pre>You will get the same problems as you would without the use
of AP: of AP:
<PRE> <pre>
char* array = new char[10]; // array new... char* array = new char[10]; // array new...
... ...
delete array; // ...but single-object delete delete array; // ...but single-object delete
</PRE> </pre>
</p> </p>
<p>AP cannot tell whether the pointer you've passed at creation points <p>AP cannot tell whether the pointer you've passed at creation points
to one or many things. If it points to many things, you are about to one or many things. If it points to many things, you are about
...@@ -92,12 +92,12 @@ ...@@ -92,12 +92,12 @@
<p>All of the <a href="../23_containers/howto.html">containers</a> <p>All of the <a href="../23_containers/howto.html">containers</a>
described in the standard library require their contained types described in the standard library require their contained types
to have, among other things, a copy contructor like this: to have, among other things, a copy contructor like this:
<PRE> <pre>
struct My_Type struct My_Type
{ {
My_Type (My_Type const&amp;); My_Type (My_Type const&amp;);
}; };
</PRE> </pre>
Note the const keyword; the object being copied shouldn't change. Note the const keyword; the object being copied shouldn't change.
The template class <code>auto_ptr</code> (called AP here) does not The template class <code>auto_ptr</code> (called AP here) does not
meet this requirement. Creating a new AP by copying an existing meet this requirement. Creating a new AP by copying an existing
...@@ -106,14 +106,14 @@ ...@@ -106,14 +106,14 @@
copy ctors of AP do not take const objects. copy ctors of AP do not take const objects.
</p> </p>
<p>The resulting rule is simple: <em>Never ever use a container of <p>The resulting rule is simple: <em>Never ever use a container of
auto_ptr objects.</em> The standard says that undefined behavior auto_ptr objects.</em> The standard says that &quot;undefined&quot;
is the result, but it is guaranteed to be messy. behavior is the result, but it is guaranteed to be messy.
</p> </p>
<p>To prevent you from doing this to yourself, the <p>To prevent you from doing this to yourself, the
<a href="../19_diagnostics/howto.html#3">concept checks</a> built <a href="../19_diagnostics/howto.html#3">concept checks</a> built
in to this implementation will issue an error if you try to in to this implementation will issue an error if you try to
compile code like this: compile code like this:
<PRE> <pre>
#include &lt;vector&gt; #include &lt;vector&gt;
#include &lt;memory&gt; #include &lt;memory&gt;
...@@ -121,7 +121,7 @@ ...@@ -121,7 +121,7 @@
{ {
std::vector&lt; std::auto_ptr&lt;int&gt; &gt; vec_ap_int; std::vector&lt; std::auto_ptr&lt;int&gt; &gt; vec_ap_int;
} }
</PRE> </pre>
Should you try this with the checks enabled, you will see an error. Should you try this with the checks enabled, you will see an error.
</p> </p>
<p>Return <a href="#top">to top of page</a> or <p>Return <a href="#top">to top of page</a> or
...@@ -151,16 +151,16 @@ ...@@ -151,16 +151,16 @@
</p> </p>
<p>Construction is simple. The default ctor initializes each member <p>Construction is simple. The default ctor initializes each member
with its respective default ctor. The other simple ctor, with its respective default ctor. The other simple ctor,
<PRE> <pre>
pair (const T1&amp; x, const T2&amp; y); pair (const T1&amp; x, const T2&amp; y);
</PRE>does what you think it does, <code>first</code> getting <code>x</code> </pre>does what you think it does, <code>first</code> getting <code>x</code>
and <code>second</code> getting <code>y</code>. and <code>second</code> getting <code>y</code>.
</p> </p>
<p>There is a copy constructor, but it requires that your compiler <p>There is a copy constructor, but it requires that your compiler
handle member function templates: handle member function templates:
<PRE> <pre>
template &lt;class U, class V&gt; pain (const pair&lt;U,V&gt;&amp; p); template &lt;class U, class V&gt; pain (const pair&lt;U,V&gt;&amp; p);
</PRE>The compiler will convert as necessary from U to T1 and from </pre>The compiler will convert as necessary from U to T1 and from
V to T2 in order to perform the respective initializations. V to T2 in order to perform the respective initializations.
</p> </p>
<p>The comparison operators are done for you. Equality <p>The comparison operators are done for you. Equality
...@@ -173,10 +173,10 @@ ...@@ -173,10 +173,10 @@
<a name="pairlt"> <a name="pairlt">
<p>The less-than operator is a bit odd the first time you see it. It <p>The less-than operator is a bit odd the first time you see it. It
is defined as evaluating to: is defined as evaluating to:
<PRE> <pre>
x.first &lt; y.first || x.first &lt; y.first ||
( !(y.first &lt; x.first) &amp;&amp; x.second &lt; y.second ) ( !(y.first &lt; x.first) &amp;&amp; x.second &lt; y.second )
</PRE> </pre>
The other operators are not defined using the <code>rel_ops</code> The other operators are not defined using the <code>rel_ops</code>
functions above, but their semantics are the same. functions above, but their semantics are the same.
</p> </p>
...@@ -184,9 +184,9 @@ ...@@ -184,9 +184,9 @@
<p>Finally, there is a template function called <code>make_pair</code> <p>Finally, there is a template function called <code>make_pair</code>
that takes two references-to-const objects and returns an that takes two references-to-const objects and returns an
instance of a pair instantiated on their respective types: instance of a pair instantiated on their respective types:
<PRE> <pre>
pair&lt;int,MyClass&gt; p = make_pair(4,myobject); pair&lt;int,MyClass&gt; p = make_pair(4,myobject);
</PRE> </pre>
</p> </p>
<p>Return <a href="#top">to top of page</a> or <p>Return <a href="#top">to top of page</a> or
<a href="../faq/index.html">to the FAQ</a>. <a href="../faq/index.html">to the FAQ</a>.
...@@ -198,10 +198,10 @@ ...@@ -198,10 +198,10 @@
<!-- ####################################################### --> <!-- ####################################################### -->
<hr> <hr>
<P CLASS="fineprint"><em> <p class="fineprint"><em>
See <a href="../17_intro/license.html">license.html</a> for copying conditions. See <a href="../17_intro/license.html">license.html</a> for copying conditions.
Comments and suggestions are welcome, and may be sent to Comments and suggestions are welcome, and may be sent to
<a href="mailto:libstdc++@gcc.gnu.org">the mailing list</a>. <a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.
</em></p> </em></p>
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html> <html>
<head> <head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta NAME="AUTHOR" CONTENT="pme@gcc.gnu.org (Phil Edwards)"> <meta name="AUTHOR" content="pme@gcc.gnu.org (Phil Edwards)">
<meta NAME="KEYWORDS" CONTENT="HOWTO, libstdc++, GCC, g++, libg++, STL"> <meta name="KEYWORDS" content="HOWTO, libstdc++, GCC, g++, libg++, STL">
<meta NAME="DESCRIPTION" CONTENT="HOWTO for the libstdc++ chapter 21."> <meta name="DESCRIPTION" content="HOWTO for the libstdc++ chapter 21.">
<meta NAME="GENERATOR" CONTENT="vi and eight fingers"> <meta name="GENERATOR" content="vi and eight fingers">
<title>libstdc++-v3 HOWTO: Chapter 21</title> <title>libstdc++-v3 HOWTO: Chapter 21</title>
<link REL=StyleSheet HREF="../lib3styles.css"> <link rel=StyleSheet href="../lib3styles.css">
</head> </head>
<body> <body>
<h1 CLASS="centered"><a name="top">Chapter 21: Strings</a></h1> <h1 class="centered"><a name="top">Chapter 21: Strings</a></h1>
<p>Chapter 21 deals with the C++ strings library (a welcome relief). <p>Chapter 21 deals with the C++ strings library (a welcome relief).
</p> </p>
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
hierarchy and the string class, and they operate with regular hierarchy and the string class, and they operate with regular
streams seamlessly because they inherit from the iostream streams seamlessly because they inherit from the iostream
heirarchy. An quick example: heirarchy. An quick example:
<PRE> <pre>
#include &lt;iostream&gt; #include &lt;iostream&gt;
#include &lt;string&gt; #include &lt;string&gt;
#include &lt;sstream&gt; #include &lt;sstream&gt;
...@@ -78,11 +78,11 @@ ...@@ -78,11 +78,11 @@
&lt;&lt; " and 3*N was " &lt;&lt; (3*the_number); &lt;&lt; " and 3*N was " &lt;&lt; (3*the_number);
return output_stream.str(); return output_stream.str();
} </PRE> } </pre>
</p></a> </p></a>
<p>A serious problem with CString is a design bug in its memory <p>A serious problem with CString is a design bug in its memory
allocation. Specifically, quoting from that same message: allocation. Specifically, quoting from that same message:
<PRE> <pre>
CString suffers from a common programming error that results in CString suffers from a common programming error that results in
poor performance. Consider the following code: poor performance. Consider the following code:
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
If you replace CString with string in the above function, the If you replace CString with string in the above function, the
performance is O(n). performance is O(n).
</PRE> </pre>
</p> </p>
<p>Joe Buck also pointed out some other things to keep in mind when <p>Joe Buck also pointed out some other things to keep in mind when
comparing CString and the Standard string class: comparing CString and the Standard string class:
...@@ -143,7 +143,7 @@ ...@@ -143,7 +143,7 @@
is identical to the standard 'string' class, but is is identical to the standard 'string' class, but is
case-insensitive in the same way as the (common but nonstandard) case-insensitive in the same way as the (common but nonstandard)
C function stricmp():&quot; C function stricmp():&quot;
<PRE> <pre>
ci_string s( "AbCdE" ); ci_string s( "AbCdE" );
// case insensitive // case insensitive
...@@ -152,7 +152,7 @@ ...@@ -152,7 +152,7 @@
// still case-preserving, of course // still case-preserving, of course
assert( strcmp( s.c_str(), "AbCdE" ) == 0 ); assert( strcmp( s.c_str(), "AbCdE" ) == 0 );
assert( strcmp( s.c_str(), "abcde" ) != 0 ); </PRE> assert( strcmp( s.c_str(), "abcde" ) != 0 ); </pre>
</p> </p>
<p>The solution is surprisingly easy. The original answer pages <p>The solution is surprisingly easy. The original answer pages
...@@ -165,7 +165,8 @@ ...@@ -165,7 +165,8 @@
here</a>. here</a>.
</p> </p>
<p>See? Told you it was easy!</p> <p>See? Told you it was easy!</p>
<p><B>Added June 2000:</B> The May issue of <U>C++ Report</U> contains <p><strong>Added June 2000:</strong> The May issue of <u>C++ Report</u>
contains
a fascinating article by Matt Austern (yes, <em>the</em> Matt Austern) a fascinating article by Matt Austern (yes, <em>the</em> Matt Austern)
on why case-insensitive comparisons are not as easy as they seem, on why case-insensitive comparisons are not as easy as they seem,
and why creating a class is the <em>wrong</em> way to go about it in and why creating a class is the <em>wrong</em> way to go about it in
...@@ -178,7 +179,7 @@ ...@@ -178,7 +179,7 @@
that nobody ever called me on it...) The GotW question and answer that nobody ever called me on it...) The GotW question and answer
remain useful instructional tools, however. remain useful instructional tools, however.
</p> </p>
<p><B>Added September 2000:</B> James Kanze provided a link to a <p><strong>Added September 2000:</strong> James Kanze provided a link to a
<a href="http://www.unicode.org/unicode/reports/tr21/">Unicode <a href="http://www.unicode.org/unicode/reports/tr21/">Unicode
Technical Report discussing case handling</a>, which provides some Technical Report discussing case handling</a>, which provides some
very good information. very good information.
...@@ -208,20 +209,20 @@ ...@@ -208,20 +209,20 @@
comments on what kind of string it will accept). The author uses comments on what kind of string it will accept). The author uses
a more general (but less readable) form of it for parsing command a more general (but less readable) form of it for parsing command
strings and the like. If you compiled and ran this code using it: strings and the like. If you compiled and ran this code using it:
<PRE> <pre>
std::list&lt;string&gt; ls; std::list&lt;string&gt; ls;
stringtok (ls, " this \t is\t\n a test "); stringtok (ls, " this \t is\t\n a test ");
for (std::list&lt;string&gt;const_iterator i = ls.begin(); for (std::list&lt;string&gt;const_iterator i = ls.begin();
i != ls.end(); ++i) i != ls.end(); ++i)
{ {
std::cerr &lt;&lt; ':' &lt;&lt; (*i) &lt;&lt; ":\n"; std::cerr &lt;&lt; ':' &lt;&lt; (*i) &lt;&lt; ":\n";
}</PRE> }</pre>
You would see this as output: You would see this as output:
<PRE> <pre>
:this: :this:
:is: :is:
:a: :a:
:test:</PRE> :test:</pre>
with all the whitespace removed. The original <code>s</code> is still with all the whitespace removed. The original <code>s</code> is still
available for use, <code>ls</code> will clean up after itself, and available for use, <code>ls</code> will clean up after itself, and
<code>ls.size()</code> will return how many tokens there were. <code>ls.size()</code> will return how many tokens there were.
...@@ -235,7 +236,7 @@ ...@@ -235,7 +236,7 @@
with reading the new function names, this version is recommended with reading the new function names, this version is recommended
as an example. as an example.
</p> </p>
<p><B>Added February 2001:</B> Mark Wilden pointed out that the <p><strong>Added February 2001:</strong> Mark Wilden pointed out that the
standard <code>std::getline()</code> function can be used with standard standard <code>std::getline()</code> function can be used with standard
<a href="../27_io/howto.html">istringstreams</a> to perform <a href="../27_io/howto.html">istringstreams</a> to perform
tokenizing as well. Build an istringstream from the input text, tokenizing as well. Build an istringstream from the input text,
...@@ -256,7 +257,7 @@ ...@@ -256,7 +257,7 @@
</p> </p>
<p>This code will go through some iterations (no pun). Here's the <p>This code will go through some iterations (no pun). Here's the
simplistic version usually seen on Usenet: simplistic version usually seen on Usenet:
<PRE> <pre>
#include &lt;string&gt; #include &lt;string&gt;
#include &lt;algorithm&gt; #include &lt;algorithm&gt;
#include &lt;cctype&gt; // old &lt;ctype.h&gt; #include &lt;cctype&gt; // old &lt;ctype.h&gt;
...@@ -273,9 +274,9 @@ ...@@ -273,9 +274,9 @@
// result in a different string // result in a different string
std::string capital_s; std::string capital_s;
capital_s.reserve(s.size()); capital_s.reserve(s.size());
std::transform (s.begin(), s.end(), capital_s.begin(), tolower); </PRE> std::transform (s.begin(), s.end(), capital_s.begin(), tolower); </pre>
<SPAN CLASS="larger"><B>Note</B></SPAN> that these calls all involve <span class="larger"><strong>Note</strong></span> that these calls all
the global C locale through the use of the C functions involve the global C locale through the use of the C functions
<code>toupper/tolower</code>. This is absolutely guaranteed to work -- <code>toupper/tolower</code>. This is absolutely guaranteed to work --
but <em>only</em> if the string contains <em>only</em> characters but <em>only</em> if the string contains <em>only</em> characters
from the basic source character set, and there are <em>only</em> from the basic source character set, and there are <em>only</em>
...@@ -285,11 +286,11 @@ ...@@ -285,11 +286,11 @@
characters (hahahahahaha), then you're done. characters (hahahahahaha), then you're done.
</p> </p>
<p>At minimum, you can write short wrappers like <p>At minimum, you can write short wrappers like
<PRE> <pre>
char toLower (char c) char toLower (char c)
{ {
return tolower(static_cast&lt;unsigned char&gt;(c)); return tolower(static_cast&lt;unsigned char&gt;(c));
}</PRE> }</pre>
</p> </p>
<p>The correct method is to use a facet for a particular locale <p>The correct method is to use a facet for a particular locale
and call its conversion functions. These are discussed more in and call its conversion functions. These are discussed more in
...@@ -302,7 +303,7 @@ ...@@ -302,7 +303,7 @@
like transformations, this task is trivial with the use of string's like transformations, this task is trivial with the use of string's
<code>find</code> family. These examples are broken into multiple <code>find</code> family. These examples are broken into multiple
statements for readability: statements for readability:
<PRE> <pre>
std::string str (" \t blah blah blah \n "); std::string str (" \t blah blah blah \n ");
// trim leading whitespace // trim leading whitespace
...@@ -311,7 +312,7 @@ ...@@ -311,7 +312,7 @@
// trim trailing whitespace // trim trailing whitespace
notwhite = str.find_last_not_of(" \t\n"); notwhite = str.find_last_not_of(" \t\n");
str.erase(notwhite+1); </PRE> str.erase(notwhite+1); </pre>
Obviously, the calls to <code>find</code> could be inserted directly Obviously, the calls to <code>find</code> could be inserted directly
into the calls to <code>erase</code>, in case your compiler does not into the calls to <code>erase</code>, in case your compiler does not
optimize named temporaries out of existance. optimize named temporaries out of existance.
...@@ -322,14 +323,13 @@ ...@@ -322,14 +323,13 @@
<!-- ####################################################### --> <!-- ####################################################### -->
<hr> <hr>
<P CLASS="fineprint"><em> <p class="fineprint"><em>
See <a href="../17_intro/license.html">license.html</a> for copying conditions. See <a href="../17_intro/license.html">license.html</a> for copying conditions.
Comments and suggestions are welcome, and may be sent to Comments and suggestions are welcome, and may be sent to
<a href="mailto:libstdc++@gcc.gnu.org">the mailing list</a>. <a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.
</em></p> </em></p>
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html> <html>
<head> <head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta NAME="AUTHOR" CONTENT="pme@gcc.gnu.org (Phil Edwards)"> <meta name="AUTHOR" content="pme@gcc.gnu.org (Phil Edwards)">
<meta NAME="KEYWORDS" CONTENT="HOWTO, libstdc++, GCC, g++, libg++, STL"> <meta name="KEYWORDS" content="HOWTO, libstdc++, GCC, g++, libg++, STL">
<meta NAME="DESCRIPTION" CONTENT="HOWTO for the libstdc++ chapter 22."> <meta name="DESCRIPTION" content="HOWTO for the libstdc++ chapter 22.">
<meta NAME="GENERATOR" CONTENT="vi and eight fingers"> <meta name="GENERATOR" content="vi and eight fingers">
<title>libstdc++-v3 HOWTO: Chapter 22</title> <title>libstdc++-v3 HOWTO: Chapter 22</title>
<link REL=StyleSheet HREF="../lib3styles.css"> <link rel=StyleSheet href="../lib3styles.css">
</head> </head>
<body> <body>
<h1 CLASS="centered"><a name="top">Chapter 22: Localization</a></h1> <h1 class="centered"><a name="top">Chapter 22: Localization</a></h1>
<p>Chapter 22 deals with the C++ localization facilities. <p>Chapter 22 deals with the C++ localization facilities.
</p> </p>
...@@ -38,18 +38,18 @@ ...@@ -38,18 +38,18 @@
<hr> <hr>
<h2><a name="1">class locale</a></h2> <h2><a name="1">class locale</a></h2>
<p> Notes made during the implementation of locales can be found <p>Notes made during the implementation of locales can be found
<a href="locale.html">here</a>. <a href="locale.html">here</a>.
</p> </p>
<hr> <hr>
<h2><a name="2">class codecvt</a></h2> <h2><a name="2">class codecvt</a></h2>
<p> Notes made during the implementation of codecvt can be found <p>Notes made during the implementation of codecvt can be found
<a href="codecvt.html">here</a>. <a href="codecvt.html">here</a>.
</p> </p>
<p> The following is the abstract from the implementation notes: <p>The following is the abstract from the implementation notes:
<BLOCKQUOTE> <blockquote>
The standard class codecvt attempts to address conversions between The standard class codecvt attempts to address conversions between
different character encoding schemes. In particular, the standard different character encoding schemes. In particular, the standard
attempts to detail conversions between the implementation-defined attempts to detail conversions between the implementation-defined
...@@ -63,18 +63,19 @@ ...@@ -63,18 +63,19 @@
requirements are addressed, and examples of correct usage for both requirements are addressed, and examples of correct usage for both
the required specializations for wide and narrow characters and the the required specializations for wide and narrow characters and the
implementation-provided extended functionality are given. implementation-provided extended functionality are given.
</BLOCKQUOTE> </blockquote>
</p>
<hr> <hr>
<h2><a name="3">class ctype</a></h2> <h2><a name="3">class ctype</a></h2>
<p> Notes made during the implementation of ctype can be found <p>Notes made during the implementation of ctype can be found
<a href="ctype.html">here</a>. <a href="ctype.html">here</a>.
</p> </p>
<hr> <hr>
<h2><a name="4">class messages</a></h2> <h2><a name="4">class messages</a></h2>
<p> Notes made during the implementation of messages can be found <p>Notes made during the implementation of messages can be found
<a href="messages.html">here</a>. <a href="messages.html">here</a>.
</p> </p>
<hr> <hr>
...@@ -87,24 +88,24 @@ ...@@ -87,24 +88,24 @@
description of locales and how to use them. description of locales and how to use them.
</p> </p>
<p>He also writes: <p>He also writes:
<BLOCKQUOTE><em> <blockquote><em>
Please note that I still consider this detailed description of Please note that I still consider this detailed description of
locales beyond the needs of most C++ programmers. It is written locales beyond the needs of most C++ programmers. It is written
with experienced programmers in mind and novices will do best to with experienced programmers in mind and novices will do best to
avoid it. avoid it.
</em></BLOCKQUOTE> </em></blockquote>
</p> </p>
<hr> <hr>
<h2><a name="6">Nathan Myers on Locales</a></h2> <h2><a name="6">Nathan Myers on Locales</a></h2>
<p> An article entitled &quot;The Standard C++ Locale&quot; was <p>An article entitled &quot;The Standard C++ Locale&quot; was
published in Dr. Dobb's Journal and can be found published in Dr. Dobb's Journal and can be found
<a href="http://www.cantrip.org/locale.html">here</a>. <a href="http://www.cantrip.org/locale.html">here</a>.
</p> </p>
<hr> <hr>
<h2><a name="7">Correct Transformations</a></h2> <h2><a name="7">Correct Transformations</a></h2>
<!-- Jumping directly here from chapter 21. --> <!-- Jumping directly to here from chapter 21. -->
<p>A very common question on newsgroups and mailing lists is, &quot;How <p>A very common question on newsgroups and mailing lists is, &quot;How
do I do &lt;foo&gt; to a character string?&quot; where &lt;foo&gt; is do I do &lt;foo&gt; to a character string?&quot; where &lt;foo&gt; is
a task such as changing all the letters to uppercase, to lowercase, a task such as changing all the letters to uppercase, to lowercase,
...@@ -130,7 +131,7 @@ ...@@ -130,7 +131,7 @@
is created. Then member functions of that locale are called to is created. Then member functions of that locale are called to
perform minor tasks. Continuing the example from Chapter 21, we wish perform minor tasks. Continuing the example from Chapter 21, we wish
to use the following convenience functions: to use the following convenience functions:
<PRE> <pre>
namespace std { namespace std {
template &lt;class charT&gt; template &lt;class charT&gt;
charT charT
...@@ -138,7 +139,7 @@ ...@@ -138,7 +139,7 @@
template &lt;class charT&gt; template &lt;class charT&gt;
charT charT
tolower (charT c, const locale&amp; loc) const; tolower (charT c, const locale&amp; loc) const;
}</PRE> }</pre>
This function extracts the appropriate &quot;facet&quot; from the This function extracts the appropriate &quot;facet&quot; from the
locale <em>loc</em> and calls the appropriate member function of that locale <em>loc</em> and calls the appropriate member function of that
facet, passing <em>c</em> as its argument. The resulting character facet, passing <em>c</em> as its argument. The resulting character
...@@ -153,7 +154,7 @@ ...@@ -153,7 +154,7 @@
parameter. So we write simple wrapper structs to handle that. parameter. So we write simple wrapper structs to handle that.
</p> </p>
<p>The next-to-final version of the code started in Chapter 21 looks like: <p>The next-to-final version of the code started in Chapter 21 looks like:
<PRE> <pre>
#include &lt;iterator&gt; // for back_inserter #include &lt;iterator&gt; // for back_inserter
#include &lt;locale&gt; #include &lt;locale&gt;
#include &lt;string&gt; #include &lt;string&gt;
...@@ -198,7 +199,7 @@ ...@@ -198,7 +199,7 @@
std::transform (s.begin(), s.end(), std::back_inserter(capital_s), std::transform (s.begin(), s.end(), std::back_inserter(capital_s),
up up
); );
}</PRE> }</pre>
</p> </p>
<p>The final version of the code uses <code>bind2nd</code> to eliminate <p>The final version of the code uses <code>bind2nd</code> to eliminate
the wrapper structs, but the resulting code is tricky. I have not the wrapper structs, but the resulting code is tricky. I have not
...@@ -210,10 +211,10 @@ ...@@ -210,10 +211,10 @@
<!-- ####################################################### --> <!-- ####################################################### -->
<hr> <hr>
<P CLASS="fineprint"><em> <p class="fineprint"><em>
See <a href="../17_intro/license.html">license.html</a> for copying conditions. See <a href="../17_intro/license.html">license.html</a> for copying conditions.
Comments and suggestions are welcome, and may be sent to Comments and suggestions are welcome, and may be sent to
<a href="mailto:libstdc++@gcc.gnu.org">the mailing list</a>. <a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.
</em></p> </em></p>
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html> <html>
<head> <head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta NAME="AUTHOR" CONTENT="pme@gcc.gnu.org (Phil Edwards)"> <meta name="AUTHOR" content="pme@gcc.gnu.org (Phil Edwards)">
<meta NAME="KEYWORDS" CONTENT="HOWTO, libstdc++, GCC, g++, libg++, STL"> <meta name="KEYWORDS" content="HOWTO, libstdc++, GCC, g++, libg++, STL">
<meta NAME="DESCRIPTION" CONTENT="HOWTO for the libstdc++ chapter 23."> <meta name="DESCRIPTION" content="HOWTO for the libstdc++ chapter 23.">
<meta NAME="GENERATOR" CONTENT="vi and eight fingers"> <meta name="GENERATOR" content="vi and eight fingers">
<title>libstdc++-v3 HOWTO: Chapter 23</title> <title>libstdc++-v3 HOWTO: Chapter 23</title>
<link REL=StyleSheet HREF="../lib3styles.css"> <link rel=StyleSheet href="../lib3styles.css">
</head> </head>
<body> <body>
<h1 CLASS="centered"><a name="top">Chapter 23: Containers</a></h1> <h1 class="centered"><a name="top">Chapter 23: Containers</a></h1>
<p>Chapter 23 deals with container classes and what they offer. <p>Chapter 23 deals with container classes and what they offer.
</p> </p>
...@@ -63,8 +63,8 @@ ...@@ -63,8 +63,8 @@
code size or execution time. code size or execution time.
</p> </p>
<p>The result is that if all your algorithm calls look like <p>The result is that if all your algorithm calls look like
<PRE> <pre>
std::transform(beginof(foo), endof(foo), beginof(foo), SomeFunction);</PRE> std::transform(beginof(foo), endof(foo), beginof(foo), SomeFunction);</pre>
then the type of foo can change from an array of ints to a vector then the type of foo can change from an array of ints to a vector
of ints to a deque of ints and back again, without ever changing any of ints to a deque of ints and back again, without ever changing any
client code. client code.
...@@ -84,8 +84,8 @@ ...@@ -84,8 +84,8 @@
give the extra three lines and avoid confusion. give the extra three lines and avoid confusion.
</p> </p>
<p>Second, the line <p>Second, the line
<PRE> <pre>
inline unsigned int lengthof (T (&amp;)[sz]) { return sz; } </PRE> inline unsigned int lengthof (T (&amp;)[sz]) { return sz; } </pre>
looks just weird! Hint: unused parameters can be left nameless. looks just weird! Hint: unused parameters can be left nameless.
</p> </p>
<p>Return <a href="#top">to top of page</a> or <p>Return <a href="#top">to top of page</a> or
...@@ -96,14 +96,14 @@ ...@@ -96,14 +96,14 @@
<h2><a name="2">Variable-sized bitmasks</a></h2> <h2><a name="2">Variable-sized bitmasks</a></h2>
<p>No, you cannot write code of the form <p>No, you cannot write code of the form
<!-- Careful, the leading spaces in PRE show up directly. --> <!-- Careful, the leading spaces in PRE show up directly. -->
<PRE> <pre>
#include &lt;bitset&gt; #include &lt;bitset&gt;
void foo (size_t n) void foo (size_t n)
{ {
std::bitset&lt;n&gt; bits; std::bitset&lt;n&gt; bits;
.... ....
} </PRE> } </pre>
because <code>n</code> must be known at compile time. Your compiler is because <code>n</code> must be known at compile time. Your compiler is
correct; it is not a bug. That's the way templates work. (Yes, it correct; it is not a bug. That's the way templates work. (Yes, it
<em>is</em> a feature.) <em>is</em> a feature.)
...@@ -117,7 +117,8 @@ ...@@ -117,7 +117,8 @@
<li>Extremely weird solutions. <li>Extremely weird solutions.
</ul> </ul>
</p> </p>
<p><B>A very large N in <code>bitset&lt;N&gt;</code>.&nbsp;&nbsp;</B> It has <p><strong>A very large N in
<code>bitset&lt;N&gt;</code>.&nbsp;&nbsp;</strong> It has
been pointed out a few times in newsgroups that N bits only takes up been pointed out a few times in newsgroups that N bits only takes up
(N/8) bytes on most systems, and division by a factor of eight is pretty (N/8) bytes on most systems, and division by a factor of eight is pretty
impressive when speaking of memory. Half a megabyte given over to a impressive when speaking of memory. Half a megabyte given over to a
...@@ -136,7 +137,8 @@ ...@@ -136,7 +137,8 @@
there may be zero space overhead, but it's all allocated inside the there may be zero space overhead, but it's all allocated inside the
object.) object.)
</p> </p>
<p><B>A container&lt;bool&gt;.&nbsp;&nbsp;</B> The Committee made provision <p><strong>A container&lt;bool&gt;.&nbsp;&nbsp;</strong> The Committee
made provision
for the space savings possible with that (N/8) usage previously mentioned, for the space savings possible with that (N/8) usage previously mentioned,
so that you don't have to do wasteful things like so that you don't have to do wasteful things like
<code>Container&lt;char&gt;</code> or <code>Container&lt;char&gt;</code> or
...@@ -148,14 +150,15 @@ ...@@ -148,14 +150,15 @@
normal vector anymore. There have been recent journal articles which normal vector anymore. There have been recent journal articles which
discuss the problems (the ones by Herb Sutter in the May and discuss the problems (the ones by Herb Sutter in the May and
July/August 1999 issues of July/August 1999 issues of
<em>C++ Report</em> cover it well). Future revisions of the ISO C++ <u>C++ Report</u> cover it well). Future revisions of the ISO C++
Standard will change the requirement for <code>vector&lt;bool&gt;</code> Standard will change the requirement for <code>vector&lt;bool&gt;</code>
specialization. In the meantime, <code>deque&lt;bool&gt;</code> is specialization. In the meantime, <code>deque&lt;bool&gt;</code> is
recommended (although its behavior is sane, you probably will not get recommended (although its behavior is sane, you probably will not get
the space savings, but the allocation scheme is different than that the space savings, but the allocation scheme is different than that
of vector). of vector).
</p> </p>
<p><B>Extremely weird solutions.&nbsp;&nbsp;</B> If you have access to <p><strong>Extremely weird solutions.&nbsp;&nbsp;</strong> If you have
access to
the compiler and linker at runtime, you can do something insane, like the compiler and linker at runtime, you can do something insane, like
figuring out just how many bits you need, then writing a temporary figuring out just how many bits you need, then writing a temporary
source code file. That file contains an instantiation of source code file. That file contains an instantiation of
...@@ -260,8 +263,8 @@ ...@@ -260,8 +263,8 @@
<h2><a name="4">&quot;Hinting&quot; during insertion</a></h2> <h2><a name="4">&quot;Hinting&quot; during insertion</a></h2>
<p>Section [23.1.2], Table 69, of the C++ standard lists this function <p>Section [23.1.2], Table 69, of the C++ standard lists this function
for all of the associative containers (map, set, etc): for all of the associative containers (map, set, etc):
<PRE> <pre>
a.insert(p,t);</PRE> a.insert(p,t);</pre>
where 'p' is an iterator into the container 'a', and 't' is the item where 'p' is an iterator into the container 'a', and 't' is the item
to insert. The standard says that &quot;iterator p is a hint to insert. The standard says that &quot;iterator p is a hint
pointing to where the insert should start to search,&quot; but pointing to where the insert should start to search,&quot; but
...@@ -349,13 +352,13 @@ ...@@ -349,13 +352,13 @@
</p> </p>
<p>For now you can simply make a temporary string object using the <p>For now you can simply make a temporary string object using the
constructor expression: constructor expression:
<PRE> <pre>
std::bitset&lt;5&gt; b ( std::string(&quot;10110&quot;) ); std::bitset&lt;5&gt; b ( std::string(&quot;10110&quot;) );
</PRE> </pre>
instead of instead of
<PRE> <pre>
std::bitset&lt;5&gt; b ( &quot;10110&quot; ); // invalid std::bitset&lt;5&gt; b ( &quot;10110&quot; ); // invalid
</PRE> </pre>
</p> </p>
<p>Return <a href="#top">to top of page</a> or <p>Return <a href="#top">to top of page</a> or
<a href="../faq/index.html">to the FAQ</a>. <a href="../faq/index.html">to the FAQ</a>.
...@@ -365,10 +368,10 @@ ...@@ -365,10 +368,10 @@
<!-- ####################################################### --> <!-- ####################################################### -->
<hr> <hr>
<P CLASS="fineprint"><em> <p class="fineprint"><em>
See <a href="../17_intro/license.html">license.html</a> for copying conditions. See <a href="../17_intro/license.html">license.html</a> for copying conditions.
Comments and suggestions are welcome, and may be sent to Comments and suggestions are welcome, and may be sent to
<a href="mailto:libstdc++@gcc.gnu.org">the mailing list</a>. <a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.
</em></p> </em></p>
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html> <html>
<head> <head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta NAME="AUTHOR" CONTENT="pme@gcc.gnu.org (Phil Edwards)"> <meta name="AUTHOR" content="pme@gcc.gnu.org (Phil Edwards)">
<meta NAME="KEYWORDS" CONTENT="HOWTO, libstdc++, GCC, g++, libg++, STL"> <meta name="KEYWORDS" content="HOWTO, libstdc++, GCC, g++, libg++, STL">
<meta NAME="DESCRIPTION" CONTENT="HOWTO for the libstdc++ chapter 24."> <meta name="DESCRIPTION" content="HOWTO for the libstdc++ chapter 24.">
<meta NAME="GENERATOR" CONTENT="vi and eight fingers"> <meta name="GENERATOR" content="vi and eight fingers">
<title>libstdc++-v3 HOWTO: Chapter 24</title> <title>libstdc++-v3 HOWTO: Chapter 24</title>
<link REL=StyleSheet HREF="../lib3styles.css"> <link rel=StyleSheet href="../lib3styles.css">
</head> </head>
<body> <body>
<h1 CLASS="centered"><a name="top">Chapter 24: Iterators</a></h1> <h1 class="centered"><a name="top">Chapter 24: Iterators</a></h1>
<p>Chapter 24 deals with the FORTRAN subroutines for automatically <p>Chapter 24 deals with the FORTRAN subroutines for automatically
transforming lemmings into gold. transforming lemmings into gold.
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
of overhead. (If you think that's the case anywhere, you don't of overhead. (If you think that's the case anywhere, you don't
understand templates to begin with...) Oh, no; if you pass understand templates to begin with...) Oh, no; if you pass
in a pointer, then the compiler will instantiate that template in a pointer, then the compiler will instantiate that template
using T* as a type and good old high-speed pointer arithmetic as using T* as a type, and good old high-speed pointer arithmetic as
its operations, so the resulting code will be doing exactly the same its operations, so the resulting code will be doing exactly the same
things as it would be doing if you had hand-coded it yourself (for things as it would be doing if you had hand-coded it yourself (for
the 273rd time). the 273rd time).
...@@ -101,7 +101,7 @@ ...@@ -101,7 +101,7 @@
<p>So, when you think of two pointers delimiting an array, don't think <p>So, when you think of two pointers delimiting an array, don't think
of them as indexing 0 through n-1. Think of them as <em>boundary of them as indexing 0 through n-1. Think of them as <em>boundary
markers</em>: markers</em>:
<PRE> <pre>
beginning end beginning end
| | | |
...@@ -121,7 +121,7 @@ ...@@ -121,7 +121,7 @@
| | dereference 'end'. | | dereference 'end'.
beginning end beginning end
</PRE> </pre>
See? Everything between the boundary markers is part of the array. See? Everything between the boundary markers is part of the array.
Simple. Simple.
</p> </p>
...@@ -172,10 +172,10 @@ ...@@ -172,10 +172,10 @@
<!-- ####################################################### --> <!-- ####################################################### -->
<hr> <hr>
<P CLASS="fineprint"><em> <p class="fineprint"><em>
See <a href="../17_intro/license.html">license.html</a> for copying conditions. See <a href="../17_intro/license.html">license.html</a> for copying conditions.
Comments and suggestions are welcome, and may be sent to Comments and suggestions are welcome, and may be sent to
<a href="mailto:libstdc++@gcc.gnu.org">the mailing list</a>. <a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.
</em></p> </em></p>
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html> <html>
<head> <head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta NAME="AUTHOR" CONTENT="pme@gcc.gnu.org (Phil Edwards)"> <meta name="AUTHOR" content="pme@gcc.gnu.org (Phil Edwards)">
<meta NAME="KEYWORDS" CONTENT="HOWTO, libstdc++, GCC, g++, libg++, STL"> <meta name="KEYWORDS" content="HOWTO, libstdc++, GCC, g++, libg++, STL">
<meta NAME="DESCRIPTION" CONTENT="HOWTO for the libstdc++ chapter 25."> <meta name="DESCRIPTION" content="HOWTO for the libstdc++ chapter 25.">
<meta NAME="GENERATOR" CONTENT="vi and eight fingers"> <meta name="GENERATOR" content="vi and eight fingers">
<title>libstdc++-v3 HOWTO: Chapter 25</title> <title>libstdc++-v3 HOWTO: Chapter 25</title>
<link REL=StyleSheet HREF="../lib3styles.css"> <link rel=StyleSheet href="../lib3styles.css">
</head> </head>
<body> <body>
<h1 CLASS="centered"><a name="top">Chapter 25: Algorithms</a></h1> <h1 class="centered"><a name="top">Chapter 25: Algorithms</a></h1>
<p>Chapter 25 deals with the generalized subroutines for automatically <p>Chapter 25 deals with the generalized subroutines for automatically
transforming lemmings into gold. transforming lemmings into gold.
...@@ -49,9 +49,9 @@ ...@@ -49,9 +49,9 @@
example, <code>string::find()</code>). Most of the examples on this example, <code>string::find()</code>). Most of the examples on this
page will use simple arrays of integers as a playground for page will use simple arrays of integers as a playground for
algorithms, just to keep things simple. algorithms, just to keep things simple.
<a name="Nsize">The use of <B>N</B></a> as a size in the examples is <a name="Nsize">The use of <strong>N</strong></a> as a size in the
to keep things easy to read but probably won't be legal code. You can examples is to keep things easy to read but probably won't be valid
use wrappers such as those described in the code. You can use wrappers such as those described in the
<a href="../23_containers/howto.html">containers chapter</a> to keep <a href="../23_containers/howto.html">containers chapter</a> to keep
real code readable. real code readable.
</p> </p>
...@@ -63,8 +63,6 @@ ...@@ -63,8 +63,6 @@
cause so much confusion. Once you get <em>range</em> into your head cause so much confusion. Once you get <em>range</em> into your head
(it's not that hard, honest!), then the algorithms are a cakewalk. (it's not that hard, honest!), then the algorithms are a cakewalk.
</p> </p>
<p>
</p>
<p>Return <a href="#top">to top of page</a> or <p>Return <a href="#top">to top of page</a> or
<a href="../faq/index.html">to the FAQ</a>. <a href="../faq/index.html">to the FAQ</a>.
</p> </p>
...@@ -93,10 +91,10 @@ ...@@ -93,10 +91,10 @@
<!-- ####################################################### --> <!-- ####################################################### -->
<hr> <hr>
<P CLASS="fineprint"><em> <p class="fineprint"><em>
See <a href="../17_intro/license.html">license.html</a> for copying conditions. See <a href="../17_intro/license.html">license.html</a> for copying conditions.
Comments and suggestions are welcome, and may be sent to Comments and suggestions are welcome, and may be sent to
<a href="mailto:libstdc++@gcc.gnu.org">the mailing list</a>. <a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.
</em></p> </em></p>
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html> <html>
<head> <head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta NAME="AUTHOR" CONTENT="pme@gcc.gnu.org (Phil Edwards)"> <meta name="AUTHOR" content="pme@gcc.gnu.org (Phil Edwards)">
<meta NAME="KEYWORDS" CONTENT="HOWTO, libstdc++, GCC, g++, libg++, STL"> <meta name="KEYWORDS" content="HOWTO, libstdc++, GCC, g++, libg++, STL">
<meta NAME="DESCRIPTION" CONTENT="HOWTO for the libstdc++ chapter 26."> <meta name="DESCRIPTION" content="HOWTO for the libstdc++ chapter 26.">
<meta NAME="GENERATOR" CONTENT="vi and eight fingers"> <meta name="GENERATOR" content="vi and eight fingers">
<title>libstdc++-v3 HOWTO: Chapter 26</title> <title>libstdc++-v3 HOWTO: Chapter 26</title>
<link REL=StyleSheet HREF="../lib3styles.css"> <link rel=StyleSheet href="../lib3styles.css">
</head> </head>
<body> <body>
<h1 CLASS="centered"><a name="top">Chapter 26: Numerics</a></h1> <h1 class="centered"><a name="top">Chapter 26: Numerics</a></h1>
<p>Chapter 26 deals with building block abstractions to aid in <p>Chapter 26 deals with building block abstractions to aid in
numerical computing: numerical computing:
<ul> <ul>
<li>Template data structures such as <code>valarray&lt;&gt;</code> <li>Template data structures such as <code>valarray&lt;&gt;</code>
and <code>complex&lt;&gt;</code>. and <code>complex&lt;&gt;</code>.
<li>Template numerical functions such as <code>accumulate</code>; <li>Template numerical functions such as <code>accumulate</code>,
<code>inner_product</code>; <code>partial_sum</code> and <code>inner_product</code>, <code>partial_sum</code>, and
<code>adjacent_difference</code>. <code>adjacent_difference</code>.
</ul> </ul>
All of the Standard C math functions are of course included in C++, All of the Standard C math functions are of course included in C++,
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
compiled a list of C++98 and C99 conflict points; his description of compiled a list of C++98 and C99 conflict points; his description of
C's new type versus those of C++ and how to get them playing together C's new type versus those of C++ and how to get them playing together
nicely is nicely is
<a href="http://home.flash.net/~dtribble/text/cdiffs.htm#C99.complex">here</a>. <a href="http://david.tribble.com/text/cdiffs.htm#C99-complex">here</a>.
</p> </p>
<p><code>complex&lt;&gt;</code> is intended to be instantiated with a <p><code>complex&lt;&gt;</code> is intended to be instantiated with a
floating-point type. As long as you meet that and some other basic floating-point type. As long as you meet that and some other basic
...@@ -66,9 +66,9 @@ ...@@ -66,9 +66,9 @@
<h2><a name="2">Array Processing</a></h2> <h2><a name="2">Array Processing</a></h2>
<p>One of the major reasons why FORTRAN can chew through numbers so well <p>One of the major reasons why FORTRAN can chew through numbers so well
is that it is defined to be free of pointer aliasing, an assumption is that it is defined to be free of pointer aliasing, an assumption
that C89 is not allowed to make, and neither is C++. C99 adds a new that C89 is not allowed to make, and neither is C++98. C99 adds a new
keyword, <code>restrict</code>, to apply to individual pointers. The C++ keyword, <code>restrict</code>, to apply to individual pointers. The
solution is contained in the library rather than the language C++ solution is contained in the library rather than the language
(although many vendors can be expected to add this to their compilers (although many vendors can be expected to add this to their compilers
as an extension). as an extension).
</p> </p>
...@@ -102,7 +102,7 @@ ...@@ -102,7 +102,7 @@
</ul> </ul>
</p> </p>
<p>Here is a simple example of the two forms of <code>accumulate</code>. <p>Here is a simple example of the two forms of <code>accumulate</code>.
<PRE> <pre>
int ar[50]; int ar[50];
int someval = somefunction(); int someval = somefunction();
...@@ -111,7 +111,7 @@ ...@@ -111,7 +111,7 @@
int sum = std::accumulate(ar,ar+50,0); int sum = std::accumulate(ar,ar+50,0);
int sum_stuff = std::accumulate(ar,ar+50,someval); int sum_stuff = std::accumulate(ar,ar+50,someval);
int product = std::accumulate(ar,ar+50,1,std::multiplies&lt;int&gt;()); int product = std::accumulate(ar,ar+50,1,std::multiplies&lt;int&gt;());
</PRE> </pre>
The first call adds all the members of the array, using zero as an The first call adds all the members of the array, using zero as an
initial value for <code>sum</code>. The second does the same, but uses initial value for <code>sum</code>. The second does the same, but uses
<code>someval</code> as the starting value (thus, <code>sum_stuff == sum + <code>someval</code> as the starting value (thus, <code>sum_stuff == sum +
...@@ -136,7 +136,8 @@ ...@@ -136,7 +136,8 @@
neccessary support for C99 (e.g., header files) cannot be found. neccessary support for C99 (e.g., header files) cannot be found.
</p> </p>
<p>As of GCC 3.0, C99 support includes classification functions <p>As of GCC 3.0, C99 support includes classification functions
such as <code>isnormal</code>, <code>isgreater</code>, <code>isnan</code>, etc. such as <code>isnormal</code>, <code>isgreater</code>,
<code>isnan</code>, etc.
The functions used for 'long long' support such as <code>strtoll</code> The functions used for 'long long' support such as <code>strtoll</code>
are supported, as is the <code>lldiv_t</code> typedef. Also supported are supported, as is the <code>lldiv_t</code> typedef. Also supported
are the wide character functions using 'long long', like are the wide character functions using 'long long', like
...@@ -151,10 +152,10 @@ ...@@ -151,10 +152,10 @@
<!-- ####################################################### --> <!-- ####################################################### -->
<hr> <hr>
<P CLASS="fineprint"><em> <p class="fineprint"><em>
See <a href="../17_intro/license.html">license.html</a> for copying conditions. See <a href="../17_intro/license.html">license.html</a> for copying conditions.
Comments and suggestions are welcome, and may be sent to Comments and suggestions are welcome, and may be sent to
<a href="mailto:libstdc++@gcc.gnu.org">the mailing list</a>. <a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.
</em></p> </em></p>
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html> <html>
<head> <head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta NAME="AUTHOR" CONTENT="pme@gcc.gnu.org (Phil Edwards)"> <meta name="AUTHOR" content="pme@gcc.gnu.org (Phil Edwards)">
<meta NAME="KEYWORDS" CONTENT="HOWTO, libstdc++, GCC, g++, libg++, STL"> <meta name="KEYWORDS" content="HOWTO, libstdc++, GCC, g++, libg++, STL">
<meta NAME="DESCRIPTION" CONTENT="HOWTO for the libstdc++ chapter 27."> <meta name="DESCRIPTION" content="HOWTO for the libstdc++ chapter 27.">
<meta NAME="GENERATOR" CONTENT="vi and eight fingers"> <meta name="GENERATOR" content="vi and eight fingers">
<title>libstdc++-v3 HOWTO: Chapter 27</title> <title>libstdc++-v3 HOWTO: Chapter 27</title>
<link REL=StyleSheet HREF="../lib3styles.css"> <link rel=StyleSheet href="../lib3styles.css">
</head> </head>
<body> <body>
<h1 CLASS="centered"><a name="top">Chapter 27: Input/Output</a></h1> <h1 class="centered"><a name="top">Chapter 27: Input/Output</a></h1>
<p>Chapter 27 deals with iostreams and all their subcomponents <p>Chapter 27 deals with iostreams and all their subcomponents
and extensions. All <em>kinds</em> of fun stuff. and extensions. All <em>kinds</em> of fun stuff.
...@@ -39,21 +39,21 @@ ...@@ -39,21 +39,21 @@
<p>So you want to copy a file quickly and easily, and most important, <p>So you want to copy a file quickly and easily, and most important,
completely portably. And since this is C++, you have an open completely portably. And since this is C++, you have an open
ifstream (call it IN) and an open ofstream (call it OUT): ifstream (call it IN) and an open ofstream (call it OUT):
<PRE> <pre>
#include &lt;fstream&gt; #include &lt;fstream&gt;
std::ifstream IN ("input_file"); std::ifstream IN ("input_file");
std::ofstream OUT ("output_file"); </PRE> std::ofstream OUT ("output_file"); </pre>
</p> </p>
<p>Here's the easiest way to get it completely wrong: <p>Here's the easiest way to get it completely wrong:
<PRE> <pre>
OUT &lt;&lt; IN;</PRE> OUT &lt;&lt; IN;</pre>
For those of you who don't already know why this doesn't work For those of you who don't already know why this doesn't work
(probably from having done it before), I invite you to quickly (probably from having done it before), I invite you to quickly
create a simple text file called &quot;input_file&quot; containing create a simple text file called &quot;input_file&quot; containing
the sentence the sentence
<PRE> <pre>
The quick brown fox jumped over the lazy dog.</PRE> The quick brown fox jumped over the lazy dog.</pre>
surrounded by blank lines. Code it up and try it. The contents surrounded by blank lines. Code it up and try it. The contents
of &quot;output_file&quot; may surprise you. of &quot;output_file&quot; may surprise you.
</p> </p>
...@@ -75,8 +75,8 @@ ...@@ -75,8 +75,8 @@
as well as the streams themselves. The pointer is easily retrieved as well as the streams themselves. The pointer is easily retrieved
using the <code>rdbuf()</code> member function. Therefore, the easiest using the <code>rdbuf()</code> member function. Therefore, the easiest
way to copy the file is: way to copy the file is:
<PRE> <pre>
OUT &lt;&lt; IN.rdbuf();</PRE> OUT &lt;&lt; IN.rdbuf();</pre>
</p> </p>
<p>So what <em>was</em> happening with OUT&lt;&lt;IN? Undefined <p>So what <em>was</em> happening with OUT&lt;&lt;IN? Undefined
behavior, since that particular &lt;&lt; isn't defined by the Standard. behavior, since that particular &lt;&lt; isn't defined by the Standard.
...@@ -121,17 +121,17 @@ ...@@ -121,17 +121,17 @@
is the effect you want when writing to a screen -- get the text is the effect you want when writing to a screen -- get the text
out as soon as possible, etc -- but the buffering is largely out as soon as possible, etc -- but the buffering is largely
wasted when doing this to a file: wasted when doing this to a file:
<PRE> <pre>
output &lt;&lt; &quot;a line of text&quot; &lt;&lt; endl; output &lt;&lt; &quot;a line of text&quot; &lt;&lt; endl;
output &lt;&lt; some_data_variable &lt;&lt; endl; output &lt;&lt; some_data_variable &lt;&lt; endl;
output &lt;&lt; &quot;another line of text&quot; &lt;&lt; endl; </PRE> output &lt;&lt; &quot;another line of text&quot; &lt;&lt; endl; </pre>
The proper thing to do in this case to just write the data out The proper thing to do in this case to just write the data out
and let the libraries and the system worry about the buffering. and let the libraries and the system worry about the buffering.
If you need a newline, just write a newline: If you need a newline, just write a newline:
<PRE> <pre>
output &lt;&lt; &quot;a line of text\n&quot; output &lt;&lt; &quot;a line of text\n&quot;
&lt;&lt; some_data_variable &lt;&lt; '\n' &lt;&lt; some_data_variable &lt;&lt; '\n'
&lt;&lt; &quot;another line of text\n&quot;; </PRE> &lt;&lt; &quot;another line of text\n&quot;; </pre>
I have also joined the output statements into a single statement. I have also joined the output statements into a single statement.
You could make the code prettier by moving the single newline to You could make the code prettier by moving the single newline to
the start of the quoted text on the thing line, for example. the start of the quoted text on the thing line, for example.
...@@ -139,9 +139,9 @@ ...@@ -139,9 +139,9 @@
<p>If you do need to flush the buffer above, you can send an <p>If you do need to flush the buffer above, you can send an
<code>endl</code> if you also need a newline, or just flush the buffer <code>endl</code> if you also need a newline, or just flush the buffer
yourself: yourself:
<PRE> <pre>
output &lt;&lt; ...... &lt;&lt; flush; // can use std::flush manipulator output &lt;&lt; ...... &lt;&lt; flush; // can use std::flush manipulator
output.flush(); // or call a member fn </PRE> output.flush(); // or call a member fn </pre>
</p> </p>
<p>On the other hand, there are times when writing to a file should <p>On the other hand, there are times when writing to a file should
be like writing to standard error; no buffering should be done be like writing to standard error; no buffering should be done
...@@ -149,7 +149,7 @@ ...@@ -149,7 +149,7 @@
log file for security-related information). The way to do this is log file for security-related information). The way to do this is
just to turn off the buffering <em>before any I/O operations at just to turn off the buffering <em>before any I/O operations at
all</em> have been done, i.e., as soon as possible after opening: all</em> have been done, i.e., as soon as possible after opening:
<PRE> <pre>
std::ofstream os (&quot;/foo/bar/baz&quot;); std::ofstream os (&quot;/foo/bar/baz&quot;);
std::ifstream is (&quot;/qux/quux/quuux&quot;); std::ifstream is (&quot;/qux/quux/quuux&quot;);
int i; int i;
...@@ -158,7 +158,7 @@ ...@@ -158,7 +158,7 @@
is.rdbuf()-&gt;pubsetbuf(0,0); is.rdbuf()-&gt;pubsetbuf(0,0);
... ...
os &lt;&lt; &quot;this data is written immediately\n&quot;; os &lt;&lt; &quot;this data is written immediately\n&quot;;
is &gt;&gt; i; // and this will probably cause a disk read </PRE> is &gt;&gt; i; // and this will probably cause a disk read </pre>
</p> </p>
<p>Since all aspects of buffering are handled by a streambuf-derived <p>Since all aspects of buffering are handled by a streambuf-derived
member, it is necessary to get at that member with <code>rdbuf()</code>. member, it is necessary to get at that member with <code>rdbuf()</code>.
...@@ -334,7 +334,7 @@ ...@@ -334,7 +334,7 @@
transforms everything sent through it to uppercase. This version transforms everything sent through it to uppercase. This version
assumes many things about the nature of the character type being assumes many things about the nature of the character type being
used (for more information, read the books or the newsgroups): used (for more information, read the books or the newsgroups):
<PRE> <pre>
#include &lt;iostream&gt; #include &lt;iostream&gt;
#include &lt;streambuf&gt; #include &lt;streambuf&gt;
#include &lt;locale&gt; #include &lt;locale&gt;
...@@ -365,13 +365,13 @@ ...@@ -365,13 +365,13 @@
// create special output buffer // create special output buffer
outbuf ob; outbuf ob;
// initialize output stream with that output buffer // initialize output stream with that output buffer
std::ostream out(&ob); std::ostream out(&amp;ob);
out &lt;&lt; "31 hexadecimal: " out &lt;&lt; "31 hexadecimal: "
&lt;&lt; std::hex &lt;&lt; 31 &lt;&lt; std::endl; &lt;&lt; std::hex &lt;&lt; 31 &lt;&lt; std::endl;
return 0; return 0;
} }
</PRE> </pre>
Try it yourself! Try it yourself!
</p> </p>
...@@ -407,14 +407,14 @@ ...@@ -407,14 +407,14 @@
</p> </p>
<p>Because the C++ library includes the C library, both C-style and <p>Because the C++ library includes the C library, both C-style and
C++-style I/O have to work at the same time. For example: C++-style I/O have to work at the same time. For example:
<PRE> <pre>
#include &lt;iostream&gt; #include &lt;iostream&gt;
#include &lt;cstdio&gt; #include &lt;cstdio&gt;
std::cout &lt;&lt; &quot;Hel&quot;; std::cout &lt;&lt; &quot;Hel&quot;;
std::printf (&quot;lo, worl&quot;); std::printf (&quot;lo, worl&quot;);
std::cout &lt;&lt; &quot;d!\n&quot;; std::cout &lt;&lt; &quot;d!\n&quot;;
</PRE> </pre>
This must do what you think it does. This must do what you think it does.
</p> </p>
<p>Alert members of the audience will immediately notice that buffering <p>Alert members of the audience will immediately notice that buffering
...@@ -434,11 +434,11 @@ ...@@ -434,11 +434,11 @@
when both libraries' facilities are in use. If your program only uses when both libraries' facilities are in use. If your program only uses
C++ I/O, then there's no need to sync with the C streams. The right C++ I/O, then there's no need to sync with the C streams. The right
thing to do in this case is to call thing to do in this case is to call
<PRE> <pre>
#include <em>any of the I/O headers such as ios, iostream, etc</em> #include <em>any of the I/O headers such as ios, iostream, etc</em>
std::ios::sync_with_stdio(false); std::ios::sync_with_stdio(false);
</PRE> </pre>
</p> </p>
<p>You must do this before performing any I/O via the C++ stream objects. <p>You must do this before performing any I/O via the C++ stream objects.
Once you call this, the C++ streams will operate independantly of the Once you call this, the C++ streams will operate independantly of the
...@@ -446,9 +446,10 @@ ...@@ -446,9 +446,10 @@
company will become fully buffered on their own. company will become fully buffered on their own.
</p> </p>
<p>Note, by the way, that the synchronization requirement only applies to <p>Note, by the way, that the synchronization requirement only applies to
the standard streams (<code>cin</code>, <code>cout</code>, <code>cerr</code>, the standard streams (<code>cin</code>, <code>cout</code>,
<code>cerr</code>,
<code>clog</code>, and their wide-character counterparts). File stream <code>clog</code>, and their wide-character counterparts). File stream
objects that you create yourself have no such requirement and are fully objects that you declare yourself have no such requirement and are fully
buffered. buffered.
</p> </p>
...@@ -456,10 +457,10 @@ ...@@ -456,10 +457,10 @@
<!-- ####################################################### --> <!-- ####################################################### -->
<hr><br><br><br><br><br><br><br><br> <hr><br><br><br><br><br><br><br><br>
<P CLASS="fineprint"><em> <p class="fineprint"><em>
See <a href="../17_intro/license.html">license.html</a> for copying conditions. See <a href="../17_intro/license.html">license.html</a> for copying conditions.
Comments and suggestions are welcome, and may be sent to Comments and suggestions are welcome, and may be sent to
<a href="mailto:libstdc++@gcc.gnu.org">the mailing list</a>. <a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.
</em></p> </em></p>
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html> <html>
<head> <head>
<meta NAME="AUTHOR" CONTENT="pme@gcc.gnu.org (Phil Edwards)"> <meta name="AUTHOR" content="pme@gcc.gnu.org (Phil Edwards)">
<meta NAME="KEYWORDS" CONTENT="libstdc++, libstdc++-v3, GCC, g++"> <meta name="KEYWORDS" content="libstdc++, libstdc++-v3, GCC, g++">
<meta NAME="DESCRIPTION" CONTENT="Configuration options for libstdc++-v3."> <meta name="DESCRIPTION" content="Configuration options for libstdc++-v3.">
<meta NAME="GENERATOR" CONTENT="vi and eight fingers"> <meta name="GENERATOR" content="vi and eight fingers">
<title>libstdc++-v3 configure options</title> <title>libstdc++-v3 configure options</title>
<link REL=StyleSheet HREF="lib3styles.css"> <link rel=StyleSheet href="lib3styles.css">
</head> </head>
<body> <body>
<h1 CLASS="centered"><a name="top">Interesting <code>configure</code> <h1 class="centered"><a name="top">Interesting <code>configure</code>
options</a></h1> options</a></h1>
<p>The latest version of this document is always available at <p>The latest version of this document is always available at
...@@ -89,7 +89,7 @@ options</a></h1> ...@@ -89,7 +89,7 @@ options</a></h1>
(IEEE Std. 1003.1-200x) model based on langinfo/iconv/catgets, (IEEE Std. 1003.1-200x) model based on langinfo/iconv/catgets,
'gnu' to specify a model based on functionality from the GNU C 'gnu' to specify a model based on functionality from the GNU C
library (langinfo/iconv/gettext) (from <A library (langinfo/iconv/gettext) (from <A
HREF="http://sources.redhat.com/glibc/">glibc</a>, the GNU C href="http://sources.redhat.com/glibc/">glibc</a>, the GNU C
library), or 'generic' to use a generic &quot;C&quot; library), or 'generic' to use a generic &quot;C&quot;
abstraction which consists of &quot;C&quot; locale info. The abstraction which consists of &quot;C&quot; locale info. The
default is 'generic'. default is 'generic'.
...@@ -167,16 +167,16 @@ options</a></h1> ...@@ -167,16 +167,16 @@ options</a></h1>
the following puts all the libstdc++ headers into a directory the following puts all the libstdc++ headers into a directory
called &quot;2.97-20001008&quot; instead of the usual called &quot;2.97-20001008&quot; instead of the usual
&quot;g++-v3&quot;. &quot;g++-v3&quot;.
<PRE> <pre>
--with-gxx-include-dir=/foo/H-x86-gcc-3-c-gxx-inc/include/2.97-20001008</PRE> --with-gxx-include-dir=/foo/H-x86-gcc-3-c-gxx-inc/include/2.97-20001008</pre>
</p> </p>
<dt><code>--enable-cxx-flags=FLAGS</code> <dt><code>--enable-cxx-flags=FLAGS</code>
<dd><p>With this option, you can pass a string of -f (functionality) <dd><p>With this option, you can pass a string of -f (functionality)
flags to the compiler to use when building libstdc++. FLAGS flags to the compiler to use when building libstdc++. FLAGS
is a quoted string of options, like is a quoted string of options, like
<PRE> <pre>
--enable-cxx-flags='-fvtable-gc -fomit-frame-pointer -ansi'</PRE> --enable-cxx-flags='-fvtable-gc -fomit-frame-pointer -ansi'</pre>
Note that the flags don't necessarily have to all be -f flags, Note that the flags don't necessarily have to all be -f flags,
as shown, but usually those are the ones that will make sense as shown, but usually those are the ones that will make sense
for experimentation and configure-time overriding. for experimentation and configure-time overriding.
...@@ -187,13 +187,13 @@ options</a></h1> ...@@ -187,13 +187,13 @@ options</a></h1>
as well, so that everything matches. as well, so that everything matches.
</p> </p>
<p>Fun flags to try might include combinations of <p>Fun flags to try might include combinations of
<PRE> <pre>
-fstrict-aliasing -fstrict-aliasing
-fno-exceptions -fno-exceptions
-ffunction-sections -ffunction-sections
-fvtable-gc</PRE> -fvtable-gc</pre>
and opposite forms (-fno-) of the same. Tell us (the mailing and opposite forms (-fno-) of the same. Tell us (the libstdc++
list) if you discover more! mailing list) if you discover more!
</p> </p>
<dt><code>--enable-c-mbchar </code>[default] <dt><code>--enable-c-mbchar </code>[default]
...@@ -207,17 +207,17 @@ options</a></h1> ...@@ -207,17 +207,17 @@ options</a></h1>
</dl> </dl>
</p> </p>
<p>Return <a href="#top">to the top of the page</a> or <p>Return <a href="#top">to the top of the page</a> or
<a href="http://gcc.gnu.org/libstdc++/">to the homepage</a>. <a href="http://gcc.gnu.org/libstdc++/">to the libstdc++ homepage</a>.
</p> </p>
<!-- ####################################################### --> <!-- ####################################################### -->
<hr> <hr>
<P CLASS="fineprint"><em> <p class="fineprint"><em>
See <a href="17_intro/license.html">license.html</a> for copying conditions. See <a href="17_intro/license.html">license.html</a> for copying conditions.
Comments and suggestions are welcome, and may be sent to Comments and suggestions are welcome, and may be sent to
<a href="mailto:libstdc++@gcc.gnu.org">the mailing list</a>. <a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.
</em></p> </em></p>
......
<html> <html>
<head> <head>
<meta NAME="KEYWORDS" CONTENT="libstdc++, homepage, home, g++, libg++, STL"> <meta name="KEYWORDS" content="libstdc++, homepage, home, g++, libg++, STL">
<title>Standard C++ Library v3</title> <title>Standard C++ Library v3</title>
<link REL=StyleSheet HREF="lib3styles.css"> <link rel=StyleSheet href="lib3styles.css">
</head> </head>
<body> <body>
...@@ -96,13 +96,13 @@ ...@@ -96,13 +96,13 @@
<!-- ####################################################### --> <!-- ####################################################### -->
<p>Return <a href="http://gcc.gnu.org/libstdc++/">to the homepage</a>.</p> <p>Return <a href="http://gcc.gnu.org/libstdc++/">to the libstdc++ homepage</a>.</p>
<hr> <hr>
<P CLASS="fineprint"><em> <p class="fineprint"><em>
See <a href="17_intro/license.html">license.html</a> for copying conditions. See <a href="17_intro/license.html">license.html</a> for copying conditions.
Comments and suggestions are welcome, and may be sent to Comments and suggestions are welcome, and may be sent to
<a href="mailto:libstdc++@gcc.gnu.org">the mailing list</a>. <a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.
</em></p> </em></p>
</body> </body>
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html> <html>
<head> <head>
<meta NAME="AUTHOR" CONTENT="pme@gcc.gnu.org (Phil Edwards)"> <meta name="AUTHOR" content="pme@gcc.gnu.org (Phil Edwards)">
<meta NAME="KEYWORDS" CONTENT="libstdc++, libstdc++-v3, GCC, g++"> <meta name="KEYWORDS" content="libstdc++, libstdc++-v3, GCC, g++">
<meta NAME="DESCRIPTION" CONTENT="Explanatory notes about libstdc++-v3."> <meta name="DESCRIPTION" content="Explanatory notes about libstdc++-v3.">
<meta NAME="GENERATOR" CONTENT="vi and eight fingers"> <meta name="GENERATOR" content="vi and eight fingers">
<title>Explanatory notes about libstdc++-v3 design</title> <title>Explanatory notes about libstdc++-v3 design</title>
<link REL=StyleSheet HREF="lib3styles.css"> <link rel=StyleSheet href="lib3styles.css">
</head> </head>
<body> <body>
<h1 CLASS="centered"><a name="top">Explanatory notes about libstdc++-v3 <h1 class="centered"><a name="top">Explanatory notes about libstdc++-v3
design</a></h1> design</a></h1>
<p>The latest version of this document is always available at <p>The latest version of this document is always available at
...@@ -64,10 +64,10 @@ design</a></h1> ...@@ -64,10 +64,10 @@ design</a></h1>
<!-- ####################################################### --> <!-- ####################################################### -->
<hr> <hr>
<P CLASS="fineprint"><em> <p class="fineprint"><em>
See <a href="17_intro/license.html">license.html</a> for copying conditions. See <a href="17_intro/license.html">license.html</a> for copying conditions.
Comments and suggestions are welcome, and may be sent to Comments and suggestions are welcome, and may be sent to
<a href="mailto:libstdc++@gcc.gnu.org">the mailing list</a>. <a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.
</em></p> </em></p>
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html> <html>
<head> <head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta NAME="AUTHOR" CONTENT="pme@gcc.gnu.org (Phil Edwards)"> <meta name="AUTHOR" content="pme@gcc.gnu.org (Phil Edwards)">
<meta NAME="KEYWORDS" CONTENT="HOWTO, libstdc++, GCC, g++, libg++, STL"> <meta name="KEYWORDS" content="HOWTO, libstdc++, GCC, g++, libg++, STL">
<meta NAME="DESCRIPTION" CONTENT="Notes for the libstdc++ extensions."> <meta name="DESCRIPTION" content="Notes for the libstdc++ extensions.">
<meta NAME="GENERATOR" CONTENT="vi and eight fingers"> <meta name="GENERATOR" content="vi and eight fingers">
<title>libstdc++-v3 HOWTO: Extensions</title> <title>libstdc++-v3 HOWTO: Extensions</title>
<link REL=StyleSheet HREF="../lib3styles.css"> <link rel=StyleSheet href="../lib3styles.css">
</head> </head>
<body> <body>
<h1 CLASS="centered"><a name="top">Extensions</a></h1> <h1 class="centered"><a name="top">Extensions</a></h1>
<p>Here we will make an attempt at describing the non-Standard extensions to <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, 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. and some just seemed to appear on the doorstep.
</p> </p>
<p><B>Before you leap in and use these</B>, be aware of two things: <p><strong>Before you leap in and use these</strong>, be aware of two things:
<ol> <ol>
<li>Non-Standard means exactly that. The behavior, and the very <li>Non-Standard means exactly that. The behavior, and the very
existence, of these extensions may change with little or no existence, of these extensions may change with little or no
...@@ -48,14 +48,14 @@ ...@@ -48,14 +48,14 @@
<h2><a name="1">Ropes and trees and hashes, oh my!</a></h2> <h2><a name="1">Ropes and trees and hashes, oh my!</a></h2>
<p>The SGI headers <p>The SGI headers
<PRE> <pre>
&lt;bvector&gt; &lt;bvector&gt;
&lt;hash_map&gt; &lt;hash_map&gt;
&lt;hash_set&gt; &lt;hash_set&gt;
&lt;rope&gt; &lt;rope&gt;
&lt;slist&gt; &lt;slist&gt;
&lt;tree&gt; &lt;tree&gt;
</PRE> are all here; <code>&lt;bvector&gt;</code> exposes the old bit_vector </pre> are all here; <code>&lt;bvector&gt;</code> exposes the old bit_vector
class that was used before specialization of vector&lt;bool&gt; was class that was used before specialization of vector&lt;bool&gt; was
available (it's actually a typedef for the specialization now). available (it's actually a typedef for the specialization now).
<code>&lt;hash_map&gt;</code> and <code>&lt;hash_set&gt;</code> <code>&lt;hash_map&gt;</code> and <code>&lt;hash_set&gt;</code>
...@@ -87,17 +87,17 @@ ...@@ -87,17 +87,17 @@
</p> </p>
<p>Why would you want to use a hashing class instead of the <p>Why would you want to use a hashing class instead of the
&quot;normal&quot; implementations? Matt Austern writes: &quot;normal&quot; implementations? Matt Austern writes:
<BLOCKQUOTE><em>[W]ith a well chosen hash function, hash tables <blockquote><em>[W]ith a well chosen hash function, hash tables
generally provide much better average-case performance than binary generally provide much better average-case performance than binary
search trees, and much worse worst-case performance. So if your search trees, and much worse worst-case performance. So if your
implementation has hash_map, if you don't mind using nonstandard implementation has hash_map, if you don't mind using nonstandard
components, and if you aren't scared about the possibility of components, and if you aren't scared about the possibility of
pathological cases, you'll probably get better performance from pathological cases, you'll probably get better performance from
hash_map.</em></BLOCKQUOTE> hash_map.</em></blockquote>
</p> </p>
<p>(Side note: for those of you wondering, <B>&quot;Why wasn't a hash <p>(Side note: for those of you wondering, <strong>&quot;Why wasn't a hash
table included in the Standard in the first #!$@ place?&quot;</B> I'll table included in the Standard in the first #!$@ place?&quot;</strong>
give a quick answer: it was proposed, but too late and in too 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 unorganized a fashion. Some sort of hashing will undoubtedly be
included in a future Standard. included in a future Standard.
</p> </p>
...@@ -309,10 +309,10 @@ ...@@ -309,10 +309,10 @@
<!-- ####################################################### --> <!-- ####################################################### -->
<hr> <hr>
<P CLASS="fineprint"><em> <p class="fineprint"><em>
See <a href="../17_intro/license.html">license.html</a> for copying conditions. See <a href="../17_intro/license.html">license.html</a> for copying conditions.
Comments and suggestions are welcome, and may be sent to Comments and suggestions are welcome, and may be sent to
<a href="mailto:libstdc++@gcc.gnu.org">the mailing list</a>. <a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.
</em></p> </em></p>
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html> <html>
<head> <head>
<meta NAME="AUTHOR" CONTENT="pme@gcc.gnu.org (Phil Edwards)"> <meta name="AUTHOR" content="pme@gcc.gnu.org (Phil Edwards)">
<meta NAME="KEYWORDS" CONTENT="libstdc++, libstdc++-v3, GCC, g++, STL, SGI"> <meta name="KEYWORDS" content="libstdc++, libstdc++-v3, GCC, g++, STL, SGI">
<meta NAME="DESCRIPTION" CONTENT="SGI extensions preserved in libstdc++-v3."> <meta name="DESCRIPTION" content="SGI extensions preserved in libstdc++-v3.">
<meta NAME="GENERATOR" CONTENT="vi and eight fingers"> <meta name="GENERATOR" content="vi and eight fingers">
<title>SGI extensions to the library in libstdc++-v3</title> <title>SGI extensions to the library in libstdc++-v3</title>
<link REL=StyleSheet HREF="lib3styles.css"> <link rel=StyleSheet href="lib3styles.css">
</head> </head>
<body> <body>
<h1 CLASS="centered"><a name="top">SGI extensions to the library in <h1 class="centered"><a name="top">SGI extensions to the library in
libstdc++-v3</a></h1> libstdc++-v3</a></h1>
<p>This page describes the extensions that SGI made to their version of the <p>This page describes the extensions that SGI made to their version of the
...@@ -25,7 +25,7 @@ libstdc++-v3</a></h1> ...@@ -25,7 +25,7 @@ libstdc++-v3</a></h1>
for a description). Not every chapter may have extensions, and the for a description). Not every chapter may have extensions, and the
extensions may come and go. Also, this page is incomplete because the extensions may come and go. Also, this page is incomplete because the
author is pressed for time. Check back often; the latest change was on author is pressed for time. Check back often; the latest change was on
$Date: 2001/09/27 00:48:00 $ (UTC). $Date: 2001/10/04 20:03:22 $ (UTC).
</p> </p>
<p>Descriptions range from the scanty to the verbose. You should also check <p>Descriptions range from the scanty to the verbose. You should also check
...@@ -223,10 +223,10 @@ libstdc++-v3</a></h1> ...@@ -223,10 +223,10 @@ libstdc++-v3</a></h1>
<!-- ####################################################### --> <!-- ####################################################### -->
<hr> <hr>
<P CLASS="fineprint"><em> <p class="fineprint"><em>
See <a href="../17_intro/license.html">license.html</a> for copying conditions. See <a href="../17_intro/license.html">license.html</a> for copying conditions.
Comments and suggestions are welcome, and may be sent to Comments and suggestions are welcome, and may be sent to
<a href="mailto:libstdc++@gcc.gnu.org">the mailing list</a>. <a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.
</em></p> </em></p>
......
...@@ -105,14 +105,14 @@ ...@@ -105,14 +105,14 @@
1.4 How do I get libstdc++? 1.4 How do I get libstdc++?
The eleventh (and latest) snapshot of libstdc++-v3 is [47]available The eleventh (and latest) snapshot of libstdc++-v3 is [47]available
via ftp. via ftp. The filename is libstdc++-2.92.tar.gz.
The [48]homepage has instructions for retrieving the latest CVS The [48]homepage has instructions for retrieving the latest CVS
sources, and for browsing the CVS sources over the web. sources, and for browsing the CVS sources over the web.
The subset commonly known as the Standard Template Library (chapters The subset commonly known as the Standard Template Library (chapters
23 through 25, mostly) is adapted from the SGI STL, which is also an 23 through 25, mostly) is adapted from the final release of the SGI
ongoing work. STL.
_________________________________________________________________ _________________________________________________________________
1.5 When is libstdc++ going to be finished? 1.5 When is libstdc++ going to be finished?
...@@ -555,7 +555,8 @@ http://clisp.cons.org/~haible/gccinclude-glibc-2.2-compat.diff ...@@ -555,7 +555,8 @@ http://clisp.cons.org/~haible/gccinclude-glibc-2.2-compat.diff
ours... The general question of multithreading and libstdc++-v3 is ours... The general question of multithreading and libstdc++-v3 is
addressed in the chapter-specific advice for [80]Library Introduction. addressed in the chapter-specific advice for [80]Library Introduction.
Threadsafe containers are covered in more detail in [81]the Received Threadsafe containers are covered in more detail in [81]the Received
Wisdom section on containers. Wisdom section on containers. Threading and I/O are discussed in
[82]the I/O chapter.
_________________________________________________________________ _________________________________________________________________
5.7 How do I get a copy of the ISO C++ Standard? 5.7 How do I get a copy of the ISO C++ Standard?
...@@ -566,16 +567,16 @@ http://clisp.cons.org/~haible/gccinclude-glibc-2.2-compat.diff ...@@ -566,16 +567,16 @@ http://clisp.cons.org/~haible/gccinclude-glibc-2.2-compat.diff
their two-meeting commitment for voting rights, may get a copy of the their two-meeting commitment for voting rights, may get a copy of the
standard from their respective national standards organization. In the standard from their respective national standards organization. In the
USA, this national standards organization is ANSI and their website is USA, this national standards organization is ANSI and their website is
right [82]here. (And if you've already registered with them, clicking right [83]here. (And if you've already registered with them, clicking
this link will take you to directly to the place where you can [83]buy this link will take you to directly to the place where you can [84]buy
the standard on-line. the standard on-line.
Who is your country's member body? Visit the [84]ISO homepage and find Who is your country's member body? Visit the [85]ISO homepage and find
out! out!
_________________________________________________________________ _________________________________________________________________
See [85]license.html for copying conditions. Comments and suggestions See [86]license.html for copying conditions. Comments and suggestions
are welcome, and may be sent to [86]the mailing list. are welcome, and may be sent to [87]the libstdc++ mailing list.
References References
...@@ -620,12 +621,12 @@ References ...@@ -620,12 +621,12 @@ References
39. ../faq/index.html#5_5 39. ../faq/index.html#5_5
40. ../faq/index.html#5_6 40. ../faq/index.html#5_6
41. ../faq/index.html#5_7 41. ../faq/index.html#5_7
42. ftp://gcc.gnu.org/pub/libstdc++/libstdc++-2.92.tar.gz 42. http://gcc.gnu.org/libstdc++/download.html
43. ../17_intro/DESIGN 43. ../17_intro/DESIGN
44. http://gcc.gnu.org/ 44. http://gcc.gnu.org/
45. http://gcc.gnu.org/gcc-2.95/buildstat.html 45. http://gcc.gnu.org/gcc-2.95/buildstat.html
46. http://gcc.gnu.org/libstdc++/ 46. http://gcc.gnu.org/libstdc++/
47. ftp://gcc.gnu.org/pub/libstdc++/libstdc++-2.92.tar.gz 47. http://gcc.gnu.org/libstdc++/download.html
48. http://gcc.gnu.org/libstdc++/ 48. http://gcc.gnu.org/libstdc++/
49. ../17_intro/contribute.html 49. ../17_intro/contribute.html
50. http://www.boost.org/ 50. http://www.boost.org/
...@@ -658,10 +659,11 @@ References ...@@ -658,10 +659,11 @@ References
77. http://gcc.gnu.org/ml/libstdc++/1999/msg00084.html 77. http://gcc.gnu.org/ml/libstdc++/1999/msg00084.html
78. http://www.sgi.com/Technology/STL/ 78. http://www.sgi.com/Technology/STL/
79. ../ext/howto.html 79. ../ext/howto.html
80. http://gcc.gnu.org/onlinedocs/libstdc++/17_intro/howto.html#3 80. ../17_intro/howto.html#3
81. http://gcc.gnu.org/onlinedocs/libstdc++/23_containers/howto.html 81. ../23_containers/howto.html
82. http://www.ansi.org/ 82. ../27_io/howto.html
83. http://webstore.ansi.org/ansidocstore/product.asp?sku=ISO%2FIEC+14882%2D1998 83. http://www.ansi.org/
84. http://www.iso.ch/ 84. http://webstore.ansi.org/ansidocstore/product.asp?sku=ISO%2FIEC+14882%2D1998
85. ../17_intro/license.html 85. http://www.iso.ch/
86. mailto:libstdc++@gcc.gnu.org 86. ../17_intro/license.html
87. mailto:libstdc++@gcc.gnu.org
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html> <html>
<head> <head>
<meta NAME="AUTHOR" CONTENT="pme@gcc.gnu.org (Phil Edwards)"> <meta name="AUTHOR" content="pme@gcc.gnu.org (Phil Edwards)">
<meta NAME="KEYWORDS" CONTENT="libstdc++, libstdc++-v3, GCC, g++"> <meta name="KEYWORDS" content="libstdc++, libstdc++-v3, GCC, g++">
<meta NAME="DESCRIPTION" CONTENT="README for the GNU libstdc++ effort."> <meta name="DESCRIPTION" content="README for the GNU libstdc++ effort.">
<meta NAME="GENERATOR" CONTENT="vi and eight fingers"> <meta name="GENERATOR" content="vi and eight fingers">
<title>libstdc++-v3 Installation Instructions</title> <title>libstdc++-v3 Installation Instructions</title>
<link REL=StyleSheet HREF="lib3styles.css"> <link rel=StyleSheet href="lib3styles.css">
</head> </head>
<body> <body>
<h1 CLASS="centered"><a name="top">libstdc++-v3 INSTALL</a></h1> <h1 class="centered"><a name="top">libstdc++-v3 INSTALL</a></h1>
<p>The latest version of this document is always available at <p>The latest version of this document is always available at
<a href="http://gcc.gnu.org/onlinedocs/libstdc++/install.html"> <a href="http://gcc.gnu.org/onlinedocs/libstdc++/install.html">
...@@ -124,20 +124,20 @@ ...@@ -124,20 +124,20 @@
(<code>gcc</code> or <code>gcc-3.0</code>, for example) is <em>gccsrcdir</em>. (<code>gcc</code> or <code>gcc-3.0</code>, for example) is <em>gccsrcdir</em>.
Once in <em>gccsrcdir</em>, you'll need to rename or delete the Once in <em>gccsrcdir</em>, you'll need to rename or delete the
libstdc++-v3 directory which comes with that snapshot: libstdc++-v3 directory which comes with that snapshot:
<PRE> <pre>
mv libstdc++-v3 libstdc++-v3-previous <strong>[OR]</strong> mv libstdc++-v3 libstdc++-v3-previous <strong>[OR]</strong>
rm -r libstdc++-v3</PRE> rm -r libstdc++-v3</pre>
</p> </p>
<p>Next, unpack the libstdc++-v3 library tarball into this <p>Next, unpack the libstdc++-v3 library tarball into this
<em>gccsrcdir</em> directory; it will create a <em>gccsrcdir</em> directory; it will create a
<em>libsrcdir</em> called <code>libstdc++-<em>version</em></code>: <em>libsrcdir</em> called <code>libstdc++-<em>version</em></code>:
<PRE> <pre>
gzip -dc libstdc++-version.tar.gz | tar xf -</PRE> gzip -dc libstdc++-version.tar.gz | tar xf -</pre>
</p> </p>
<p>Finally, rename <em>libsrcdir</em> to <code>libstdc++-v3</code> so that <p>Finally, rename <em>libsrcdir</em> to <code>libstdc++-v3</code> so that
gcc's configure flags will be able to deal with the new library. gcc's configure flags will be able to deal with the new library.
<PRE> <pre>
mv <em>libsrcdir</em> libstdc++-v3</PRE> mv <em>libsrcdir</em> libstdc++-v3</pre>
</p> </p>
...@@ -156,9 +156,9 @@ ...@@ -156,9 +156,9 @@
building the C++ language parts. building the C++ language parts.
</p> </p>
<p><PRE> <p><pre>
cd <em>gccbuilddir</em> cd <em>gccbuilddir</em>
<em>gccsrcdir</em>/configure --prefix=<em>destdir</em> --other-opts...</PRE> <em>gccsrcdir</em>/configure --prefix=<em>destdir</em> --other-opts...</pre>
</p> </p>
...@@ -178,8 +178,8 @@ ...@@ -178,8 +178,8 @@
<h3>[re]building only libstdc++</h3> <h3>[re]building only libstdc++</h3>
<p>To rebuild just libstdc++, use: <p>To rebuild just libstdc++, use:
<PRE> <pre>
make all-target-<em>libstdc++-v3</em></PRE> make all-target-<em>libstdc++-v3</em></pre>
This will configure and build the C++ library in the This will configure and build the C++ library in the
<em>gccbuilddir/cpu-vendor-os/</em>libstdc++ directory. <em>gccbuilddir/cpu-vendor-os/</em>libstdc++ directory.
</p> </p>
...@@ -193,12 +193,12 @@ ...@@ -193,12 +193,12 @@
simply edit it and remove lines. simply edit it and remove lines.
</p> </p>
<p>You're done. Now install the rebuilt pieces with <p>You're done. Now install the rebuilt pieces with
<PRE> <pre>
make install</PRE> make install</pre>
or or
<PRE> <pre>
make install-gcc make install-gcc
make install-target-libstdc++-v3</PRE> make install-target-libstdc++-v3</pre>
</p> </p>
...@@ -206,20 +206,20 @@ ...@@ -206,20 +206,20 @@
<h2><a name="postinstall">Post-installation</a></h2> <h2><a name="postinstall">Post-installation</a></h2>
<p>Installation will create the <em>destdir</em> directory and <p>Installation will create the <em>destdir</em> directory and
populate it with subdirectories: populate it with subdirectories:
<PRE> <pre>
lib/ lib/
include/g++-v3/ include/g++-v3/
backward/ backward/
bits/ bits/
<em>cpu-vendor-os</em>/bits/ <em>cpu-vendor-os</em>/bits/
ext/</PRE> ext/</pre>
</p> </p>
<p>You can check the status of the build without installing it using <p>You can check the status of the build without installing it using
<PRE> <pre>
make check</PRE> make check</pre>
or you can check the status of the installed library using or you can check the status of the installed library using
<PRE> <pre>
make check-install</PRE> make check-install</pre>
in the <em>libbuilddir</em> directory. in the <em>libbuilddir</em> directory.
These commands will create a 'testsuite' directory underneath These commands will create a 'testsuite' directory underneath
<em>libbuilddir</em> containing the results of the tests. We are <em>libbuilddir</em> containing the results of the tests. We are
...@@ -280,10 +280,10 @@ ...@@ -280,10 +280,10 @@
<!-- ####################################################### --> <!-- ####################################################### -->
<hr> <hr>
<P CLASS="fineprint"><em> <p class="fineprint"><em>
See <a href="17_intro/license.html">license.html</a> for copying conditions. See <a href="17_intro/license.html">license.html</a> for copying conditions.
Comments and suggestions are welcome, and may be sent to Comments and suggestions are welcome, and may be sent to
<a href="mailto:libstdc++@gcc.gnu.org">the mailing list</a>. <a href="mailto:libstdc++@gcc.gnu.org">the libstdc++ mailing list</a>.
</em></p> </em></p>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment