porting-howto.xml: Refer to http://www.oasis-open.org for docbookx.dtd.

2002-03-04  Craig Rodrigues  <rodrigc@gcc.gnu.org>

        * docs/html/17_intro/porting-howto.xml: Refer to
        http://www.oasis-open.org for docbookx.dtd.
        * docs/html/17_intro/porting-howto.html: Regenerated.

From-SVN: r50291
This commit is contained in:
Craig Rodrigues 2002-03-04 22:58:50 +00:00
parent 5ad1084650
commit b890704b15
3 changed files with 96 additions and 124 deletions

View File

@ -1,3 +1,9 @@
2002-03-04 Craig Rodrigues <rodrigc@gcc.gnu.org>
* docs/html/17_intro/porting-howto.xml: Refer to
http://www.oasis-open.org for docbookx.dtd.
* docs/html/17_intro/porting-howto.html: Regenerated.
2002-03-03 Phil Edwards <pme@gcc.gnu.org> 2002-03-03 Phil Edwards <pme@gcc.gnu.org>
PR libstdc++/3955 PR libstdc++/3955

View File

@ -3,9 +3,9 @@
<head> <head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type"> <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
<title>Libstdc++-porting-howto</title> <title>Libstdc++-porting-howto</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.29"> <meta name="generator" content="DocBook XSL Stylesheets V1.48">
</head> </head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div id="libstdc++-porting-howto" class="article"> <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="article">
<div class="titlepage"> <div class="titlepage">
<div><h1 class="title"> <div><h1 class="title">
<a name="libstdc++-porting-howto"></a>Libstdc++-porting-howto</h1></div> <a name="libstdc++-porting-howto"></a>Libstdc++-porting-howto</h1></div>
@ -84,9 +84,7 @@
</td></tr> </td></tr>
</table></div></div> </table></div></div>
<div><div class="abstract"> <div><div class="abstract">
<p> <p><b>Abstract</b></p>
<a name="id2697062"></a><b>Abstract</b>
</p>
<p> <p>
Some notes on porting applications from libstdc++-2.90 (or earlier Some notes on porting applications from libstdc++-2.90 (or earlier
versions) to libstdc++-v3. Not speaking in terms of the GNU libstdc++ versions) to libstdc++-v3. Not speaking in terms of the GNU libstdc++
@ -102,8 +100,8 @@
<dt>1. <a href="#sec-nsstd">Namespace std::</a> <dt>1. <a href="#sec-nsstd">Namespace std::</a>
</dt> </dt>
<dd><dl> <dd><dl>
<dt>1.1.1. <a href="#sec-gtkmm-hack">Using <i>namespace <dt>1.1.1. <a href="#sec-gtkmm-hack">Using namespace
composition</i> if the project uses a separate composition if the project uses a separate
namespace</a> namespace</a>
</dt> </dt>
<dt>1.1.2. <a href="#sec-emptyns">Defining an empty namespace std</a> <dt>1.1.2. <a href="#sec-emptyns">Defining an empty namespace std</a>
@ -118,8 +116,8 @@
<dt>2. <a href="#sec-nocreate">there is no ios::nocreate/ios::noreplace <dt>2. <a href="#sec-nocreate">there is no ios::nocreate/ios::noreplace
in ISO 14882</a> in ISO 14882</a>
</dt> </dt>
<dt>3. <a href="#sec-stream::attach"><b>stream::attach(int <dt>3. <a href="#sec-stream::attach">stream::attach(int
fd)</b> is not in the standard any more</a> fd) is not in the standard any more</a>
</dt> </dt>
<dt>4. <a href="#sec-headers">The new headers</a> <dt>4. <a href="#sec-headers">The new headers</a>
</dt> </dt>
@ -127,16 +125,16 @@
<dt>4.4.1. <a href="#sec-cheaders">New headers replacing C-headers</a> <dt>4.4.1. <a href="#sec-cheaders">New headers replacing C-headers</a>
</dt> </dt>
<dt>4.4.2. <a href="#sec-fstream-header"> <dt>4.4.2. <a href="#sec-fstream-header">
<tt>&lt;fstream&gt;</tt> does &lt;fstream&gt; does
not define <b>std::cout</b>, not define std::cout,
<b>std::cin</b> etc.</a> std::cin etc.</a>
</dt> </dt>
</dl></dd> </dl></dd>
<dt>5. <a href="#sec-iterators">Iterators</a> <dt>5. <a href="#sec-iterators">Iterators</a>
</dt> </dt>
<dt>6. <a href="#sec-macros"> <dt>6. <a href="#sec-macros">
Libc-macros (i.e. <b>isspace</b> from Libc-macros (i.e. isspace from
<tt>&lt;cctype&gt;</tt>)</a> &lt;cctype&gt;)</a>
</dt> </dt>
<dt>7. <a href="#sec-stream-state">State of streams</a> <dt>7. <a href="#sec-stream-state">State of streams</a>
</dt> </dt>
@ -161,29 +159,25 @@
libstdc++-implementations&quot;. libstdc++-implementations&quot;.
</p> </p>
<div class="section"> <div class="section">
<a name="sec-nsstd"></a><div class="titlepage"><div><h2 class="title" style="clear: all"> <div class="titlepage"><div><h2 class="title" style="clear: both">
<a name="sec-nsstd"></a><span class="label">1.</span> <span class="title">Namespace std::</span> <a name="sec-nsstd"></a>Namespace std::</h2></div></div>
</h2></div></div>
<p> <p>
The latest C++-standard (ISO-14882) requires that the standard The latest C++-standard (ISO-14882) requires that the standard
C++-library is defined in namespace std::. Thus, in order to use C++-library is defined in namespace std::. Thus, in order to use
classes from the standard C++-library, you can do one of three classes from the standard C++-library, you can do one of three
things: things:
<div class="itemizedlist"><ul> <div class="itemizedlist"><ul type="disc">
<li><p> <li><p>wrap your code in <b>namespace std {
<a name="id2697113"></a>wrap your code in <b>namespace std {
... }</b> =&gt; This is not an option because only symbols ... }</b> =&gt; This is not an option because only symbols
from the standard c++-library are defined in namespace std::. from the standard c++-library are defined in namespace std::.
</p></li> </p></li>
<li><p> <li><p>put a kind of
<a name="id2697126"></a>put a kind of <span class="emphasis"><i>using-declaration</i></span> in your source (either
<i>using-declaration</i> in your source (either
<b>using namespace std;</b> or i.e. <b>using <b>using namespace std;</b> or i.e. <b>using
std::string;</b>) =&gt; works well for source-files, but std::string;</b>) =&gt; works well for source-files, but
cannot be used in header-files. cannot be used in header-files.
</p></li> </p></li>
<li><p> <li><p>use a <span class="emphasis"><i>fully qualified name</i></span> for
<a name="id2697047"></a>use a <i>fully qualified name</i> for
each libstdc++-symbol (i.e. <b>std::string</b>, each libstdc++-symbol (i.e. <b>std::string</b>,
<b>std::cout</b>) =&gt; can always be used <b>std::cout</b>) =&gt; can always be used
</p></li> </p></li>
@ -210,17 +204,16 @@
that cannot ignore std::. that cannot ignore std::.
</p> </p>
<div class="section"> <div class="section">
<a name="sec-gtkmm-hack"></a><div class="titlepage"><div><h3 class="title"> <div class="titlepage"><div><h3 class="title">
<a name="sec-gtkmm-hack"></a><span class="label">1.1.1.</span> <span class="title">Using <i>namespace <a name="sec-gtkmm-hack"></a>Using <span class="emphasis"><i>namespace
composition</i> if the project uses a separate composition</i></span> if the project uses a separate
namespace</span> namespace</h3></div></div>
</h3></div></div>
<p> <p>
<a href="http://gtkmm.sourceforge.net" target="_top">Gtk--</a> defines <a href="http://gtkmm.sourceforge.net" target="_top">Gtk--</a> defines
most of its classes in namespace Gtk::. Thus, it was possible to most of its classes in namespace Gtk::. Thus, it was possible to
adapt Gtk-- to namespace std:: by using a C++-feature called adapt Gtk-- to namespace std:: by using a C++-feature called
<i>namespace composition</i>. This is what happens if <span class="emphasis"><i>namespace composition</i></span>. This is what happens if
you put a <i>using</i>-declaration into a you put a <span class="emphasis"><i>using</i></span>-declaration into a
namespace-definition: the imported symbol(s) gets imported into the namespace-definition: the imported symbol(s) gets imported into the
currently active namespace(s). For example: currently active namespace(s). For example:
<pre class="programlisting"> <pre class="programlisting">
@ -245,9 +238,8 @@
</p> </p>
</div> </div>
<div class="section"> <div class="section">
<a name="sec-emptyns"></a><div class="titlepage"><div><h3 class="title"> <div class="titlepage"><div><h3 class="title">
<a name="sec-emptyns"></a><span class="label">1.1.2.</span> <span class="title">Defining an empty namespace std</span> <a name="sec-emptyns"></a>Defining an empty namespace std</h3></div></div>
</h3></div></div>
<p> <p>
By defining an (empty) namespace <b>std::</b> before By defining an (empty) namespace <b>std::</b> before
using it, you avoid getting errors on systems where no part of the using it, you avoid getting errors on systems where no part of the
@ -259,18 +251,16 @@
</p> </p>
</div> </div>
<div class="section"> <div class="section">
<a name="sec-avoidfqn"></a><div class="titlepage"><div><h3 class="title"> <div class="titlepage"><div><h3 class="title">
<a name="sec-avoidfqn"></a><span class="label">1.1.3.</span> <span class="title">Avoid to use fully qualified names <a name="sec-avoidfqn"></a>Avoid to use fully qualified names
(i.e. std::string)</span> (i.e. std::string)</h3></div></div>
</h3></div></div>
<p> <p>
If some compilers complain about <b>using If some compilers complain about <b>using
std::string;</b>, and if the &quot;hack&quot; for gtk-- mentioned above std::string;</b>, and if the &quot;hack&quot; for gtk-- mentioned above
does not work, then I see two solutions: does not work, then I see two solutions:
<div class="itemizedlist"><ul> <div class="itemizedlist"><ul type="disc">
<li><p> <li><p>
<a name="id2698648"></a>
Define <b>std::</b> as a macro if the compiler Define <b>std::</b> as a macro if the compiler
doesn't know about <b>std::</b>. doesn't know about <b>std::</b>.
<pre class="programlisting"> <pre class="programlisting">
@ -282,7 +272,6 @@
gnu.gcc.help) gnu.gcc.help)
</p></li> </p></li>
<li><p> <li><p>
<a name="id2698680"></a>
Define a macro NS_STD, which is defined to Define a macro NS_STD, which is defined to
either &quot;&quot; or &quot;std&quot; either &quot;&quot; or &quot;std&quot;
based on an autoconf-test. Then you should be able to use based on an autoconf-test. Then you should be able to use
@ -295,18 +284,15 @@
</p> </p>
</div> </div>
<div class="section"> <div class="section">
<a name="sec-osprojects"></a><div class="titlepage"><div><h3 class="title"> <div class="titlepage"><div><h3 class="title">
<a name="sec-osprojects"></a><span class="label">1.1.4.</span> <span class="title">How some open-source-projects deal <a name="sec-osprojects"></a>How some open-source-projects deal
with this</span> with this</h3></div></div>
</h3></div></div>
<p> <p>
This information was gathered around May 2000. It may not be correct This information was gathered around May 2000. It may not be correct
by the time you read this. by the time you read this.
</p> </p>
<div class="table"> <div class="table">
<p> <p><b>Table 1. Namespace std:: in Open-Source programs</b></p>
<a name="id2698746"></a><b>Table 1. Namespace std:: in Open-Source programs</b>
</p>
<table summary="Namespace std:: in Open-Source programs" border="1"> <table summary="Namespace std:: in Open-Source programs" border="1">
<colgroup> <colgroup>
<col> <col>
@ -338,9 +324,7 @@
</table> </table>
</div> </div>
<div class="table"> <div class="table">
<p> <p><b>Table 2. Notations for categories</b></p>
<a name="id2698876"></a><b>Table 2. Notations for categories</b>
</p>
<table summary="Notations for categories" border="1"> <table summary="Notations for categories" border="1">
<colgroup> <colgroup>
<col> <col>
@ -368,15 +352,16 @@
<p> <p>
As you can see, this currently lacks an example of a project As you can see, this currently lacks an example of a project
which uses libstdc++-symbols in headers in a back-portable way which uses libstdc++-symbols in headers in a back-portable way
(except for Gtk--: see the <a href="#sec-gtkmm-hack">section on the gtkmm-hack</a>). (except for Gtk--: see the <a href="#sec-gtkmm-hack" title="Using namespace
composition if the project uses a separate
namespace">section on the gtkmm-hack</a>).
</p> </p>
</div> </div>
</div> </div>
<div class="section"> <div class="section">
<a name="sec-nocreate"></a><div class="titlepage"><div><h2 class="title" style="clear: all"> <div class="titlepage"><div><h2 class="title" style="clear: both">
<a name="sec-nocreate"></a><span class="label">2.</span> <span class="title">there is no ios::nocreate/ios::noreplace <a name="sec-nocreate"></a>there is no ios::nocreate/ios::noreplace
in ISO 14882</span> in ISO 14882</h2></div></div>
</h2></div></div>
<p> <p>
I have seen <b>ios::nocreate</b> being used for I have seen <b>ios::nocreate</b> being used for
input-streams, most probably because the author thought it would be input-streams, most probably because the author thought it would be
@ -394,10 +379,9 @@
</p> </p>
</div> </div>
<div class="section"> <div class="section">
<a name="sec-stream::attach"></a><div class="titlepage"><div><h2 class="title" style="clear: all"> <div class="titlepage"><div><h2 class="title" style="clear: both">
<a name="sec-stream::attach"></a><span class="label">3.</span> <span class="title"><b>stream::attach(int <a name="sec-stream::attach"></a><b>stream::attach(int
fd)</b> is not in the standard any more</span> fd)</b> is not in the standard any more</h2></div></div>
</h2></div></div>
<p> <p>
Phil Edwards <tt>&lt;<a href="mailto:pedwards@disaster.jaj.com">pedwards@disaster.jaj.com</a>&gt;</tt> writes: Phil Edwards <tt>&lt;<a href="mailto:pedwards@disaster.jaj.com">pedwards@disaster.jaj.com</a>&gt;</tt> writes:
It was considered and rejected. Not all environments use file It was considered and rejected. Not all environments use file
@ -406,16 +390,14 @@
</p> </p>
<p> <p>
When using libstdc++-v3, you can use When using libstdc++-v3, you can use
<div class="funcsynopsis" id="id2692860"> <div class="funcsynopsis">
<p> <pre class="funcsynopsisinfo">
<a name="id2692860"></a><pre class="funcsynopsisinfo">
#include &lt;fstream&gt; #include &lt;fstream&gt;
</pre> </pre>
<p><code><code class="funcdef"> <p><code><code class="funcdef">
<b class="fsfunc">basic_filebuf&lt;...&gt;::basic_filebuf&lt;...&gt; <b class="fsfunc">basic_filebuf&lt;...&gt;::basic_filebuf&lt;...&gt;
</b> </b>
</code>(<var class="pdparam">file</var>, <var class="pdparam">mode</var>, <var class="pdparam">size</var>);<br>__c_file_type* <var class="pdparam">file</var>;<br>ios_base::open_mode <var class="pdparam">mode</var>;<br>int <var class="pdparam">size</var>;</code></p> </code>(<var class="pdparam">file</var>, <var class="pdparam">mode</var>, <var class="pdparam">size</var>);<br>__c_file_type* <var class="pdparam">file</var>;<br>ios_base::open_mode <var class="pdparam">mode</var>;<br>int <var class="pdparam">size</var>;</code></p>
<p>
</div> </div>
but the the signature of this constructor has changed often, and but the the signature of this constructor has changed often, and
it might change again. For the current state of this, check it might change again. For the current state of this, check
@ -427,13 +409,14 @@
<b>std::streambuf</b> (or <b>std::streambuf</b> (or
<b>std::basic_streambuf&lt;..&gt;</b>) which opens a file <b>std::basic_streambuf&lt;..&gt;</b>) which opens a file
given a descriptor, and then pass an instance of this to the given a descriptor, and then pass an instance of this to the
stream-constructor (from the Josuttis-book). stream-constructor. For an example of this, refer to
<a href="http://www.josuttis.com/cppcode/fdstream.html" target="_top">fdstream example</a>
by Nicolai Josuttis.
</p> </p>
</div> </div>
<div class="section"> <div class="section">
<a name="sec-headers"></a><div class="titlepage"><div><h2 class="title" style="clear: all"> <div class="titlepage"><div><h2 class="title" style="clear: both">
<a name="sec-headers"></a><span class="label">4.</span> <span class="title">The new headers</span> <a name="sec-headers"></a>The new headers</h2></div></div>
</h2></div></div>
<p> <p>
All new headers can be seen in this <a href="headers_cc.txt" target="_top"> All new headers can be seen in this <a href="headers_cc.txt" target="_top">
source-code</a>. source-code</a>.
@ -443,9 +426,8 @@
a warning that you are using deprecated headers. a warning that you are using deprecated headers.
</p> </p>
<div class="section"> <div class="section">
<a name="sec-cheaders"></a><div class="titlepage"><div><h3 class="title"> <div class="titlepage"><div><h3 class="title">
<a name="sec-cheaders"></a><span class="label">4.4.1.</span> <span class="title">New headers replacing C-headers</span> <a name="sec-cheaders"></a>New headers replacing C-headers</h3></div></div>
</h3></div></div>
<p> <p>
You should not use the C-headers (except for system-level You should not use the C-headers (except for system-level
headers) from C++ programs. Instead, you should use a set of headers) from C++ programs. Instead, you should use a set of
@ -474,12 +456,11 @@
</p> </p>
</div> </div>
<div class="section"> <div class="section">
<a name="sec-fstream-header"></a><div class="titlepage"><div><h3 class="title"> <div class="titlepage"><div><h3 class="title">
<a name="sec-fstream-header"></a><span class="label">4.4.2.</span> <span class="title"> <a name="sec-fstream-header"></a>
<tt>&lt;fstream&gt;</tt> does <tt>&lt;fstream&gt;</tt> does
not define <b>std::cout</b>, not define <b>std::cout</b>,
<b>std::cin</b> etc.</span> <b>std::cin</b> etc.</h3></div></div>
</h3></div></div>
<p> <p>
In earlier versions of the standard, In earlier versions of the standard,
<tt>&lt;fstream.h&gt;</tt>, <tt>&lt;fstream.h&gt;</tt>,
@ -494,42 +475,38 @@
</div> </div>
</div> </div>
<div class="section"> <div class="section">
<a name="sec-iterators"></a><div class="titlepage"><div><h2 class="title" style="clear: all"> <div class="titlepage"><div><h2 class="title" style="clear: both">
<a name="sec-iterators"></a><span class="label">5.</span> <span class="title">Iterators</span> <a name="sec-iterators"></a>Iterators</h2></div></div>
</h2></div></div>
<p> <p>
The following are not proper uses of iterators, but may be working The following are not proper uses of iterators, but may be working
fixes for existing uses of iterators. fixes for existing uses of iterators.
<div class="itemizedlist"><ul> <div class="itemizedlist"><ul type="disc">
<li><p> <li><p>you cannot do
<a name="id2693156"></a>you cannot do
<b>ostream::operator&lt;&lt;(iterator)</b> to <b>ostream::operator&lt;&lt;(iterator)</b> to
print the address of the iterator =&gt; use print the address of the iterator =&gt; use
<b>operator&lt;&lt; &amp;*iterator</b> instead ? <b>operator&lt;&lt; &amp;*iterator</b> instead ?
</p></li> </p></li>
<li><p> <li><p>you cannot clear an iterator's reference
<a name="id2693255"></a>you cannot clear an iterator's reference
(<b>iterator = 0</b>) =&gt; use (<b>iterator = 0</b>) =&gt; use
<b>iterator = iterator_type();</b> ? <b>iterator = iterator_type();</b> ?
</p></li> </p></li>
<li><p> <li><p>
<a name="id2693277"></a><b>if (iterator)</b> won't work any <b>if (iterator)</b> won't work any
more =&gt; use <b>if (iterator != iterator_type())</b> more =&gt; use <b>if (iterator != iterator_type())</b>
?</p></li> ?</p></li>
</ul></div> </ul></div>
</p> </p>
</div> </div>
<div class="section"> <div class="section">
<a name="sec-macros"></a><div class="titlepage"><div><h2 class="title" style="clear: all"> <div class="titlepage"><div><h2 class="title" style="clear: both">
<a name="sec-macros"></a><span class="label">6.</span> <span class="title"> <a name="sec-macros"></a>
Libc-macros (i.e. <b>isspace</b> from Libc-macros (i.e. <b>isspace</b> from
<tt>&lt;cctype&gt;</tt>)</span> <tt>&lt;cctype&gt;</tt>)</h2></div></div>
</h2></div></div>
<p> <p>
Glibc 2.0.x and 2.1.x define the Glibc 2.0.x and 2.1.x define the
<tt>&lt;ctype.h&gt;</tt> <tt>&lt;ctype.h&gt;</tt>
-functionality as macros (isspace, isalpha etc.). Libstdc++-v3 -functionality as macros (isspace, isalpha etc.). Libstdc++-v3
&quot;shadows&quot; these macros as described in the <a href="#sec-cheaders">section about &quot;shadows&quot; these macros as described in the <a href="#sec-cheaders" title="New headers replacing C-headers">section about
c-headers</a>. c-headers</a>.
</p> </p>
<p> <p>
@ -577,18 +554,17 @@
The solution to this problem was posted to the libstdc++-v3 The solution to this problem was posted to the libstdc++-v3
mailing-list: mailing-list:
Benjamin Kosnik <tt>&lt;<a href="mailto:bkoz@redhat.com">bkoz@redhat.com</a>&gt;</tt> writes: Benjamin Kosnik <tt>&lt;<a href="mailto:bkoz@redhat.com">bkoz@redhat.com</a>&gt;</tt> writes:
` &#x2018;
--enable-cshadow-headers is currently broken. As a result, shadow --enable-cshadow-headers is currently broken. As a result, shadow
headers are not being searched.... headers are not being searched....
' &#x2019;
This is now outdated, but gcc 3.0 still does not have fully This is now outdated, but gcc 3.0 still does not have fully
compliant &quot;shadow headers&quot;. compliant &quot;shadow headers&quot;.
</p> </p>
</div> </div>
<div class="section"> <div class="section">
<a name="sec-stream-state"></a><div class="titlepage"><div><h2 class="title" style="clear: all"> <div class="titlepage"><div><h2 class="title" style="clear: both">
<a name="sec-stream-state"></a><span class="label">7.</span> <span class="title">State of streams</span> <a name="sec-stream-state"></a>State of streams</h2></div></div>
</h2></div></div>
<p> <p>
At least some older implementations don't have At least some older implementations don't have
<b>std::ios_base</b>, so you should use <b>std::ios_base</b>, so you should use
@ -598,9 +574,8 @@
</p> </p>
</div> </div>
<div class="section"> <div class="section">
<a name="sec-vector-at"></a><div class="titlepage"><div><h2 class="title" style="clear: all"> <div class="titlepage"><div><h2 class="title" style="clear: both">
<a name="sec-vector-at"></a><span class="label">8.</span> <span class="title">vector::at is missing (i.e. gcc 2.95.x)</span> <a name="sec-vector-at"></a>vector::at is missing (i.e. gcc 2.95.x)</h2></div></div>
</h2></div></div>
<p> <p>
One solution is to add an autoconf-test for this: One solution is to add an autoconf-test for this:
<pre class="programlisting"> <pre class="programlisting">
@ -630,9 +605,8 @@
</p> </p>
</div> </div>
<div class="section"> <div class="section">
<a name="sec-eof"></a><div class="titlepage"><div><h2 class="title" style="clear: all"> <div class="titlepage"><div><h2 class="title" style="clear: both">
<a name="sec-eof"></a><span class="label">9.</span> <span class="title">Using std::char_traits&lt;char&gt;::eof()</span> <a name="sec-eof"></a>Using std::char_traits&lt;char&gt;::eof()</h2></div></div>
</h2></div></div>
<p> <p>
<pre class="programlisting"> <pre class="programlisting">
#ifdef HAVE_CHAR_TRAITS #ifdef HAVE_CHAR_TRAITS
@ -644,9 +618,8 @@
</p> </p>
</div> </div>
<div class="section"> <div class="section">
<a name="sec-string-clear"></a><div class="titlepage"><div><h2 class="title" style="clear: all"> <div class="titlepage"><div><h2 class="title" style="clear: both">
<a name="sec-string-clear"></a><span class="label">10.</span> <span class="title">Using string::clear()/string::erase()</span> <a name="sec-string-clear"></a>Using string::clear()/string::erase()</h2></div></div>
</h2></div></div>
<p> <p>
There are two functions for deleting the contents of a string: There are two functions for deleting the contents of a string:
<b>clear</b> and <b>erase</b> (the latter <b>clear</b> and <b>erase</b> (the latter
@ -671,19 +644,17 @@
</p> </p>
</div> </div>
<div class="section"> <div class="section">
<a name="sec-scan-form"></a><div class="titlepage"><div><h2 class="title" style="clear: all"> <div class="titlepage"><div><h2 class="title" style="clear: both">
<a name="sec-scan-form"></a><span class="label">11.</span> <span class="title">GNU Extensions ostream::form and istream::scan</span> <a name="sec-scan-form"></a>GNU Extensions ostream::form and istream::scan</h2></div></div>
</h2></div></div>
<p> <p>
These are not supported any more - use These are not supported any more - use
<a href="#sec-stringstream"> <a href="#sec-stringstream" title="Using stringstreams">
stringstreams</a> instead. stringstreams</a> instead.
</p> </p>
</div> </div>
<div class="section"> <div class="section">
<a name="sec-stringstream"></a><div class="titlepage"><div><h2 class="title" style="clear: all"> <div class="titlepage"><div><h2 class="title" style="clear: both">
<a name="sec-stringstream"></a><span class="label">12.</span> <span class="title">Using stringstreams</span> <a name="sec-stringstream"></a>Using stringstreams</h2></div></div>
</h2></div></div>
<p> <p>
Libstdc++-v3 provides the new Libstdc++-v3 provides the new
<b>i/ostringstream</b>-classes, (<tt>&lt;sstream&gt;</tt>), but for compatibility <b>i/ostringstream</b>-classes, (<tt>&lt;sstream&gt;</tt>), but for compatibility
@ -696,22 +667,18 @@
#include &lt;strstream&gt; #include &lt;strstream&gt;
#endif #endif
</pre> </pre>
<div class="itemizedlist"><ul> <div class="itemizedlist"><ul type="disc">
<li><p> <li><p> <b>strstream</b> is considered to be
<a name="id2693683"></a> <b>strstream</b> is considered to be
deprecated deprecated
</p></li> </p></li>
<li><p> <li><p> <b>strstream</b> is limited to
<a name="id2693629"></a> <b>strstream</b> is limited to
<b>char</b> <b>char</b>
</p></li> </p></li>
<li><p> <li><p> with <b>ostringstream</b> you don't
<a name="id2693718"></a> with <b>ostringstream</b> you don't
have to take care of terminating the string or freeing its have to take care of terminating the string or freeing its
memory memory
</p></li> </p></li>
<li><p> <li><p> <b>istringstream</b> can be re-filled
<a name="id2693735"></a> <b>istringstream</b> can be re-filled
(clear(); str(input);) (clear(); str(input);)
</p></li> </p></li>
</ul></div> </ul></div>
@ -789,9 +756,8 @@
</p> </p>
</div> </div>
<div class="section"> <div class="section">
<a name="sec-about"></a><div class="titlepage"><div><h2 class="title" style="clear: all"> <div class="titlepage"><div><h2 class="title" style="clear: both">
<a name="sec-about"></a><span class="label">13.</span> <span class="title">About...</span> <a name="sec-about"></a>About...</h2></div></div>
</h2></div></div>
<p> <p>
Please send any experience, additions, corrections or questions to Please send any experience, additions, corrections or questions to
<a href="mailto:fnatter@gmx.net" target="_top">fnatter@gmx.net</a> or for <a href="mailto:fnatter@gmx.net" target="_top">fnatter@gmx.net</a> or for

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1//EN" <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1//EN"
"dtd/docbook-4/docbookx.dtd"> "http://www.oasis-open.org/docbook/xml/4.0/docbookx.dtd">
<?xml-stylesheet type="text/xsl" href="docbook-xslt/docbook/html/docbook.xsl"?> <?xml-stylesheet type="text/xsl" href="docbook-xslt/docbook/html/docbook.xsl"?>