xref: /netbsd-src/external/gpl3/gcc.old/dist/libstdc++-v3/doc/xml/manual/using.xml (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
11debfc3dSmrg<chapter xmlns="http://docbook.org/ns/docbook" version="5.0"
21debfc3dSmrg	 xml:id="manual.intro.using" xreflabel="Using">
31debfc3dSmrg  <info><title>Using</title></info>
41debfc3dSmrg  <?dbhtml filename="using.html"?>
51debfc3dSmrg
61debfc3dSmrg  <section xml:id="manual.intro.using.flags" xreflabel="Flags"><info><title>Command Options</title></info>
71debfc3dSmrg
81debfc3dSmrg    <para>
91debfc3dSmrg      The set of features available in the GNU C++ library is shaped by
101debfc3dSmrg      several <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/onlinedocs/gcc-4.3.2/gcc/Invoking-GCC.html">GCC
111debfc3dSmrg      Command Options</link>. Options that impact libstdc++ are
121debfc3dSmrg      enumerated and detailed in the table below.
131debfc3dSmrg    </para>
141debfc3dSmrg
151debfc3dSmrg    <para>
161debfc3dSmrg      The standard library conforms to the dialect of C++ specified by the
171debfc3dSmrg      <option>-std</option> option passed to the compiler.
181debfc3dSmrg      By default, <command>g++</command> is equivalent to
191debfc3dSmrg      <command>g++ -std=gnu++14</command> since GCC 6, and
201debfc3dSmrg      <command>g++ -std=gnu++98</command> for older releases.
211debfc3dSmrg    </para>
221debfc3dSmrg
231debfc3dSmrg <table frame="all" xml:id="table.cmd_options">
241debfc3dSmrg<title>C++ Command Options</title>
251debfc3dSmrg
261debfc3dSmrg<tgroup cols="2" align="left" colsep="1" rowsep="1">
271debfc3dSmrg<colspec colname="c1"/>
281debfc3dSmrg<colspec colname="c2"/>
291debfc3dSmrg
301debfc3dSmrg  <thead>
311debfc3dSmrg    <row>
321debfc3dSmrg      <entry>Option Flags</entry>
331debfc3dSmrg      <entry>Description</entry>
341debfc3dSmrg    </row>
351debfc3dSmrg  </thead>
361debfc3dSmrg
371debfc3dSmrg  <tbody>
381debfc3dSmrg    <row>
391debfc3dSmrg      <entry><literal>-std=c++98</literal> or <literal>-std=c++03</literal>
401debfc3dSmrg      </entry>
411debfc3dSmrg      <entry>Use the 1998 ISO C++ standard plus amendments.</entry>
421debfc3dSmrg    </row>
431debfc3dSmrg
441debfc3dSmrg    <row>
451debfc3dSmrg      <entry><literal>-std=gnu++98</literal> or <literal>-std=gnu++03</literal>
461debfc3dSmrg      </entry>
471debfc3dSmrg      <entry>As directly above, with GNU extensions.</entry>
481debfc3dSmrg    </row>
491debfc3dSmrg
501debfc3dSmrg    <row>
511debfc3dSmrg      <entry><literal>-std=c++11</literal></entry>
521debfc3dSmrg      <entry>Use the 2011 ISO C++ standard.</entry>
531debfc3dSmrg    </row>
541debfc3dSmrg
551debfc3dSmrg    <row>
561debfc3dSmrg      <entry><literal>-std=gnu++11</literal></entry>
571debfc3dSmrg      <entry>As directly above, with GNU extensions.</entry>
581debfc3dSmrg    </row>
591debfc3dSmrg
601debfc3dSmrg    <row>
611debfc3dSmrg      <entry><literal>-std=c++14</literal></entry>
621debfc3dSmrg      <entry>Use the 2014 ISO C++ standard.</entry>
631debfc3dSmrg    </row>
641debfc3dSmrg
651debfc3dSmrg    <row>
661debfc3dSmrg      <entry><literal>-std=gnu++14</literal></entry>
671debfc3dSmrg      <entry>As directly above, with GNU extensions.</entry>
681debfc3dSmrg    </row>
691debfc3dSmrg
701debfc3dSmrg    <row>
711debfc3dSmrg      <entry><literal>-fexceptions</literal></entry>
721debfc3dSmrg      <entry>See <link linkend="intro.using.exception.no">exception-free dialect</link></entry>
731debfc3dSmrg    </row>
741debfc3dSmrg
751debfc3dSmrg    <row>
761debfc3dSmrg      <entry><literal>-frtti</literal></entry>
771debfc3dSmrg      <entry>As above, but RTTI-free dialect.</entry>
781debfc3dSmrg    </row>
791debfc3dSmrg
801debfc3dSmrg    <row>
811debfc3dSmrg      <entry><literal>-pthread</literal></entry>
821debfc3dSmrg      <entry>For ISO C++11
831debfc3dSmrg        <filename class="headerfile">&lt;thread&gt;</filename>,
841debfc3dSmrg        <filename class="headerfile">&lt;future&gt;</filename>,
851debfc3dSmrg        <filename class="headerfile">&lt;mutex&gt;</filename>,
861debfc3dSmrg        or <filename class="headerfile">&lt;condition_variable&gt;</filename>.
871debfc3dSmrg      </entry>
881debfc3dSmrg    </row>
891debfc3dSmrg
901debfc3dSmrg    <row>
911debfc3dSmrg      <entry><literal>-latomic</literal></entry>
921debfc3dSmrg      <entry>Linking to <filename class="libraryfile">libatomic</filename>
931debfc3dSmrg        is required for some uses of ISO C++11
941debfc3dSmrg        <filename class="headerfile">&lt;atomic&gt;</filename>.
951debfc3dSmrg      </entry>
961debfc3dSmrg    </row>
971debfc3dSmrg
981debfc3dSmrg    <row>
991debfc3dSmrg      <entry><literal>-lstdc++fs</literal></entry>
1001debfc3dSmrg      <entry>Linking to <filename class="libraryfile">libstdc++fs</filename>
1011debfc3dSmrg        is required for use of the Filesystem library extensions in
102c0a68be4Smrg        <filename class="headerfile">&lt;experimental/filesystem&gt;</filename>.
1031debfc3dSmrg      </entry>
1041debfc3dSmrg    </row>
1051debfc3dSmrg
1061debfc3dSmrg    <row>
1071debfc3dSmrg      <entry><literal>-fopenmp</literal></entry>
1081debfc3dSmrg      <entry>For <link linkend="manual.ext.parallel_mode">parallel</link> mode.</entry>
1091debfc3dSmrg    </row>
110c0a68be4Smrg
111c0a68be4Smrg    <row>
112c0a68be4Smrg      <entry><literal>-ltbb</literal></entry>
113c0a68be4Smrg      <entry>Linking to tbb (Thread Building Blocks) is required for use of the
114c0a68be4Smrg        Parallel Standard Algorithms and execution policies in
115c0a68be4Smrg        <filename class="headerfile">&lt;execution&gt;</filename>.
116c0a68be4Smrg      </entry>
117c0a68be4Smrg    </row>
118c0a68be4Smrg
1191debfc3dSmrg  </tbody>
1201debfc3dSmrg
1211debfc3dSmrg</tgroup>
1221debfc3dSmrg</table>
1231debfc3dSmrg
1241debfc3dSmrg  </section>
1251debfc3dSmrg
1261debfc3dSmrg  <section xml:id="manual.intro.using.headers" xreflabel="Headers"><info><title>Headers</title></info>
1271debfc3dSmrg    <?dbhtml filename="using_headers.html"?>
1281debfc3dSmrg
1291debfc3dSmrg
1301debfc3dSmrg    <section xml:id="manual.intro.using.headers.all" xreflabel="Header Files"><info><title>Header Files</title></info>
1311debfc3dSmrg
1321debfc3dSmrg
1331debfc3dSmrg   <para>
1341debfc3dSmrg     The C++ standard specifies the entire set of header files that
1351debfc3dSmrg     must be available to all hosted implementations.  Actually, the
1361debfc3dSmrg     word "files" is a misnomer, since the contents of the
1371debfc3dSmrg     headers don't necessarily have to be in any kind of external
1381debfc3dSmrg     file.  The only rule is that when one <code>#include</code>s a
1391debfc3dSmrg     header, the contents of that header become available, no matter
1401debfc3dSmrg     how.
1411debfc3dSmrg   </para>
1421debfc3dSmrg
1431debfc3dSmrg   <para>
1441debfc3dSmrg   That said, in practice files are used.
1451debfc3dSmrg   </para>
1461debfc3dSmrg
1471debfc3dSmrg   <para>
1481debfc3dSmrg     There are two main types of include files: header files related
1491debfc3dSmrg     to a specific version of the ISO C++ standard (called Standard
1501debfc3dSmrg     Headers), and all others (TS, TR1, C++ ABI, and Extensions).
1511debfc3dSmrg   </para>
1521debfc3dSmrg
1531debfc3dSmrg   <para>
1541debfc3dSmrg     Multiple dialects of standard headers are supported, corresponding to
1551debfc3dSmrg     the 1998 standard as updated for 2003, the 2011 standard, the 2014
1561debfc3dSmrg     standard, and so on.
1571debfc3dSmrg   </para>
1581debfc3dSmrg
1591debfc3dSmrg   <para>
1601debfc3dSmrg     <xref linkend="table.cxx98_headers"/> and
1611debfc3dSmrg     <xref linkend="table.cxx98_cheaders"/> and
1621debfc3dSmrg     <xref linkend="table.cxx98_deprheaders"/>
1631debfc3dSmrg     show the C++98/03 include files.
1641debfc3dSmrg     These are available in the C++98 compilation mode,
1651debfc3dSmrg     i.e. <code>-std=c++98</code> or <code>-std=gnu++98</code>.
1661debfc3dSmrg     Unless specified otherwise below, they are also available in later modes
1671debfc3dSmrg     (C++11, C++14 etc).
1681debfc3dSmrg   </para>
1691debfc3dSmrg
1701debfc3dSmrg<table frame="all" xml:id="table.cxx98_headers">
1711debfc3dSmrg<title>C++ 1998 Library Headers</title>
1721debfc3dSmrg
1731debfc3dSmrg<tgroup cols="5" align="left" colsep="1" rowsep="1">
1741debfc3dSmrg<colspec colname="c1"/>
1751debfc3dSmrg<colspec colname="c2"/>
1761debfc3dSmrg<colspec colname="c3"/>
1771debfc3dSmrg<colspec colname="c4"/>
1781debfc3dSmrg<colspec colname="c5"/>
1791debfc3dSmrg<tbody>
1801debfc3dSmrg<row>
1811debfc3dSmrg<entry><filename class="headerfile">algorithm</filename></entry>
1821debfc3dSmrg<entry><filename class="headerfile">bitset</filename></entry>
1831debfc3dSmrg<entry><filename class="headerfile">complex</filename></entry>
1841debfc3dSmrg<entry><filename class="headerfile">deque</filename></entry>
1851debfc3dSmrg<entry><filename class="headerfile">exception</filename></entry>
1861debfc3dSmrg</row>
1871debfc3dSmrg<row>
1881debfc3dSmrg<entry><filename class="headerfile">fstream</filename></entry>
1891debfc3dSmrg<entry><filename class="headerfile">functional</filename></entry>
1901debfc3dSmrg<entry><filename class="headerfile">iomanip</filename></entry>
1911debfc3dSmrg<entry><filename class="headerfile">ios</filename></entry>
1921debfc3dSmrg<entry><filename class="headerfile">iosfwd</filename></entry>
1931debfc3dSmrg</row>
1941debfc3dSmrg<row>
1951debfc3dSmrg<entry><filename class="headerfile">iostream</filename></entry>
1961debfc3dSmrg<entry><filename class="headerfile">istream</filename></entry>
1971debfc3dSmrg<entry><filename class="headerfile">iterator</filename></entry>
1981debfc3dSmrg<entry><filename class="headerfile">limits</filename></entry>
1991debfc3dSmrg<entry><filename class="headerfile">list</filename></entry>
2001debfc3dSmrg</row>
2011debfc3dSmrg<row>
2021debfc3dSmrg<entry><filename class="headerfile">locale</filename></entry>
2031debfc3dSmrg<entry><filename class="headerfile">map</filename></entry>
2041debfc3dSmrg<entry><filename class="headerfile">memory</filename></entry>
2051debfc3dSmrg<entry><filename class="headerfile">new</filename></entry>
2061debfc3dSmrg<entry><filename class="headerfile">numeric</filename></entry>
2071debfc3dSmrg</row>
2081debfc3dSmrg<row>
2091debfc3dSmrg<entry><filename class="headerfile">ostream</filename></entry>
2101debfc3dSmrg<entry><filename class="headerfile">queue</filename></entry>
2111debfc3dSmrg<entry><filename class="headerfile">set</filename></entry>
2121debfc3dSmrg<entry><filename class="headerfile">sstream</filename></entry>
2131debfc3dSmrg<entry><filename class="headerfile">stack</filename></entry>
2141debfc3dSmrg</row>
2151debfc3dSmrg<row>
2161debfc3dSmrg<entry><filename class="headerfile">stdexcept</filename></entry>
2171debfc3dSmrg<entry><filename class="headerfile">streambuf</filename></entry>
2181debfc3dSmrg<entry><filename class="headerfile">string</filename></entry>
2191debfc3dSmrg<entry><filename class="headerfile">utility</filename></entry>
2201debfc3dSmrg<entry><filename class="headerfile">typeinfo</filename></entry>
2211debfc3dSmrg</row>
2221debfc3dSmrg<row>
2231debfc3dSmrg<entry><filename class="headerfile">valarray</filename></entry>
2241debfc3dSmrg<entry><filename class="headerfile">vector</filename></entry>
2251debfc3dSmrg<entry namest="c3" nameend="c5"/>
2261debfc3dSmrg</row>
2271debfc3dSmrg</tbody>
2281debfc3dSmrg</tgroup>
2291debfc3dSmrg</table>
2301debfc3dSmrg
2311debfc3dSmrg<para/>
2321debfc3dSmrg<table frame="all" xml:id="table.cxx98_cheaders">
2331debfc3dSmrg<title>C++ 1998 Library Headers for C Library Facilities</title>
2341debfc3dSmrg
2351debfc3dSmrg<tgroup cols="5" align="left" colsep="1" rowsep="1">
2361debfc3dSmrg<colspec colname="c1"/>
2371debfc3dSmrg<colspec colname="c2"/>
2381debfc3dSmrg<colspec colname="c3"/>
2391debfc3dSmrg<colspec colname="c4"/>
2401debfc3dSmrg<colspec colname="c5"/>
2411debfc3dSmrg<tbody>
2421debfc3dSmrg<row>
2431debfc3dSmrg<entry><filename class="headerfile">cassert</filename></entry>
2441debfc3dSmrg<entry><filename class="headerfile">cerrno</filename></entry>
2451debfc3dSmrg<entry><filename class="headerfile">cctype</filename></entry>
2461debfc3dSmrg<entry><filename class="headerfile">cfloat</filename></entry>
2471debfc3dSmrg<entry><filename class="headerfile">ciso646</filename></entry>
2481debfc3dSmrg</row>
2491debfc3dSmrg<row>
2501debfc3dSmrg<entry><filename class="headerfile">climits</filename></entry>
2511debfc3dSmrg<entry><filename class="headerfile">clocale</filename></entry>
2521debfc3dSmrg<entry><filename class="headerfile">cmath</filename></entry>
2531debfc3dSmrg<entry><filename class="headerfile">csetjmp</filename></entry>
2541debfc3dSmrg<entry><filename class="headerfile">csignal</filename></entry>
2551debfc3dSmrg</row>
2561debfc3dSmrg<row>
2571debfc3dSmrg<entry><filename class="headerfile">cstdarg</filename></entry>
2581debfc3dSmrg<entry><filename class="headerfile">cstddef</filename></entry>
2591debfc3dSmrg<entry><filename class="headerfile">cstdio</filename></entry>
2601debfc3dSmrg<entry><filename class="headerfile">cstdlib</filename></entry>
2611debfc3dSmrg<entry><filename class="headerfile">cstring</filename></entry>
2621debfc3dSmrg</row>
2631debfc3dSmrg<row>
2641debfc3dSmrg<entry><filename class="headerfile">ctime</filename></entry>
2651debfc3dSmrg<entry><filename class="headerfile">cwchar</filename></entry>
2661debfc3dSmrg<entry><filename class="headerfile">cwctype</filename></entry>
2671debfc3dSmrg<entry namest="c4" nameend="c5"/>
2681debfc3dSmrg</row>
2691debfc3dSmrg</tbody>
2701debfc3dSmrg</tgroup>
2711debfc3dSmrg</table>
2721debfc3dSmrg
2731debfc3dSmrg<para>
2741debfc3dSmrg  The following header is deprecated
2751debfc3dSmrg  and might be removed from a future C++ standard.
2761debfc3dSmrg</para>
2771debfc3dSmrg
2781debfc3dSmrg<table frame="all" xml:id="table.cxx98_deprheaders">
2791debfc3dSmrg<title>C++ 1998 Deprecated Library Header</title>
2801debfc3dSmrg
2811debfc3dSmrg<tgroup cols="1" align="left" colsep="1" rowsep="1">
2821debfc3dSmrg<colspec colname="c1"/>
2831debfc3dSmrg<tbody>
2841debfc3dSmrg<row>
2851debfc3dSmrg<entry><filename class="headerfile">strstream</filename></entry>
2861debfc3dSmrg</row>
2871debfc3dSmrg</tbody>
2881debfc3dSmrg</tgroup>
2891debfc3dSmrg</table>
2901debfc3dSmrg
2911debfc3dSmrg<para>
2921debfc3dSmrg<xref linkend="table.cxx11_headers"/> and
2931debfc3dSmrg<xref linkend="table.cxx11_cheaders"/> show the C++11 include files.
2941debfc3dSmrgThese are available in C++11 compilation
2951debfc3dSmrgmode, i.e. <literal>-std=c++11</literal> or <literal>-std=gnu++11</literal>.
2961debfc3dSmrgIncluding these headers in C++98/03 mode may result in compilation errors.
2971debfc3dSmrgUnless specified otherwise below, they are also available in later modes
2981debfc3dSmrg(C++14 etc).
2991debfc3dSmrg</para>
3001debfc3dSmrg
3011debfc3dSmrg<para/>
3021debfc3dSmrg<table frame="all" xml:id="table.cxx11_headers">
3031debfc3dSmrg<title>C++ 2011 Library Headers</title>
3041debfc3dSmrg
3051debfc3dSmrg<tgroup cols="5" align="left" colsep="1" rowsep="1">
3061debfc3dSmrg<colspec colname="c1"/>
3071debfc3dSmrg<colspec colname="c2"/>
3081debfc3dSmrg<colspec colname="c3"/>
3091debfc3dSmrg<colspec colname="c4"/>
3101debfc3dSmrg<colspec colname="c5"/>
3111debfc3dSmrg<tbody>
3121debfc3dSmrg
3131debfc3dSmrg<row>
3141debfc3dSmrg<entry><filename class="headerfile">array</filename></entry>
3151debfc3dSmrg<entry><filename class="headerfile">atomic</filename></entry>
3161debfc3dSmrg<entry><filename class="headerfile">chrono</filename></entry>
3171debfc3dSmrg<entry><filename class="headerfile">codecvt</filename></entry>
3181debfc3dSmrg<entry><filename class="headerfile">condition_variable</filename></entry>
3191debfc3dSmrg</row>
3201debfc3dSmrg<row>
3211debfc3dSmrg<entry><filename class="headerfile">forward_list</filename></entry>
3221debfc3dSmrg<entry><filename class="headerfile">future</filename></entry>
3231debfc3dSmrg<entry><filename class="headerfile">initalizer_list</filename></entry>
3241debfc3dSmrg<entry><filename class="headerfile">mutex</filename></entry>
3251debfc3dSmrg<entry><filename class="headerfile">random</filename></entry>
3261debfc3dSmrg</row>
3271debfc3dSmrg<row>
3281debfc3dSmrg<entry><filename class="headerfile">ratio</filename></entry>
3291debfc3dSmrg<entry><filename class="headerfile">regex</filename></entry>
3301debfc3dSmrg<entry><filename class="headerfile">scoped_allocator</filename></entry>
3311debfc3dSmrg<entry><filename class="headerfile">system_error</filename></entry>
3321debfc3dSmrg<entry><filename class="headerfile">thread</filename></entry>
3331debfc3dSmrg</row>
3341debfc3dSmrg<row>
3351debfc3dSmrg<entry><filename class="headerfile">tuple</filename></entry>
3361debfc3dSmrg<entry><filename class="headerfile">typeindex</filename></entry>
3371debfc3dSmrg<entry><filename class="headerfile">type_traits</filename></entry>
3381debfc3dSmrg<entry><filename class="headerfile">unordered_map</filename></entry>
3391debfc3dSmrg<entry><filename class="headerfile">unordered_set</filename></entry>
3401debfc3dSmrg</row>
3411debfc3dSmrg
3421debfc3dSmrg</tbody>
3431debfc3dSmrg</tgroup>
3441debfc3dSmrg</table>
3451debfc3dSmrg
3461debfc3dSmrg<para/>
3471debfc3dSmrg
3481debfc3dSmrg<table frame="all" xml:id="table.cxx11_cheaders">
3491debfc3dSmrg<title>C++ 2011 Library Headers for C Library Facilities</title>
3501debfc3dSmrg
3511debfc3dSmrg<tgroup cols="5" align="left" colsep="1" rowsep="1">
3521debfc3dSmrg<colspec colname="c1"/>
3531debfc3dSmrg<colspec colname="c2"/>
3541debfc3dSmrg<colspec colname="c3"/>
3551debfc3dSmrg<colspec colname="c4"/>
3561debfc3dSmrg<colspec colname="c5"/>
3571debfc3dSmrg<tbody>
3581debfc3dSmrg<row>
3591debfc3dSmrg<entry><filename class="headerfile">ccomplex</filename></entry>
3601debfc3dSmrg<entry><filename class="headerfile">cfenv</filename></entry>
3611debfc3dSmrg<entry><filename class="headerfile">cinttypes</filename></entry>
3621debfc3dSmrg<entry><filename class="headerfile">cstdalign</filename></entry>
3631debfc3dSmrg<entry><filename class="headerfile">cstdbool</filename></entry>
3641debfc3dSmrg</row>
3651debfc3dSmrg<row>
3661debfc3dSmrg<entry><filename class="headerfile">cstdint</filename></entry>
3671debfc3dSmrg<entry><filename class="headerfile">ctgmath</filename></entry>
3681debfc3dSmrg<entry><filename class="headerfile">cuchar</filename></entry>
3691debfc3dSmrg<entry namest="c4" nameend="c5"/>
3701debfc3dSmrg</row>
3711debfc3dSmrg</tbody>
3721debfc3dSmrg</tgroup>
3731debfc3dSmrg</table>
3741debfc3dSmrg
3751debfc3dSmrg<para>
3761debfc3dSmrg<xref linkend="table.cxx14_headers"/> shows the C++14 include file.
3771debfc3dSmrgThis is available in C++14 compilation
3781debfc3dSmrgmode, i.e. <literal>-std=c++14</literal> or <literal>-std=gnu++14</literal>.
3791debfc3dSmrgIncluding this header in C++98/03 mode or C++11 will not result in
3801debfc3dSmrgcompilation errors, but will not define anything.
3811debfc3dSmrgUnless specified otherwise below, it is also available in later modes
3821debfc3dSmrg(C++17 etc).
3831debfc3dSmrg</para>
3841debfc3dSmrg
3851debfc3dSmrg<para/>
3861debfc3dSmrg<table frame="all" xml:id="table.cxx14_headers">
3871debfc3dSmrg<title>C++ 2014 Library Header</title>
3881debfc3dSmrg
3891debfc3dSmrg<tgroup cols="1" align="left" colsep="1" rowsep="1">
3901debfc3dSmrg<colspec colname="c1"/>
3911debfc3dSmrg<tbody>
3921debfc3dSmrg<row>
3931debfc3dSmrg<entry><filename class="headerfile">shared_mutex</filename></entry>
3941debfc3dSmrg</row>
3951debfc3dSmrg</tbody>
3961debfc3dSmrg</tgroup>
3971debfc3dSmrg</table>
3981debfc3dSmrg
3991debfc3dSmrg<para>
4001debfc3dSmrg<xref linkend="table.cxx17_headers"/> shows the C++17 include files.
4011debfc3dSmrgThese are available in C++17 compilation
4021debfc3dSmrgmode, i.e. <literal>-std=c++17</literal> or <literal>-std=gnu++17</literal>.
4031debfc3dSmrgIncluding these headers in earlier modes will not result in
4041debfc3dSmrgcompilation errors, but will not define anything.
4051debfc3dSmrgUnless specified otherwise below, they are also available in later modes
4061debfc3dSmrg(C++20 etc).
4071debfc3dSmrg</para>
4081debfc3dSmrg
4091debfc3dSmrg<para/>
4101debfc3dSmrg<table frame="all" xml:id="table.cxx17_headers">
4111debfc3dSmrg<title>C++ 2017 Library Headers</title>
4121debfc3dSmrg
413a2dc1f3fSmrg<tgroup cols="5" align="left" colsep="1" rowsep="1">
4141debfc3dSmrg<colspec colname="c1"/>
4151debfc3dSmrg<colspec colname="c2"/>
4161debfc3dSmrg<colspec colname="c3"/>
4171debfc3dSmrg<colspec colname="c4"/>
418a2dc1f3fSmrg<colspec colname="c5"/>
4191debfc3dSmrg<tbody>
4201debfc3dSmrg<row>
4211debfc3dSmrg<entry><filename class="headerfile">any</filename></entry>
422a2dc1f3fSmrg<entry><filename class="headerfile">charconv</filename></entry>
423c0a68be4Smrg<entry><filename class="headerfile">execution</filename></entry>
424a2dc1f3fSmrg<entry><filename class="headerfile">filesystem</filename></entry>
425c0a68be4Smrg<entry><filename class="headerfile">memory_resource</filename></entry>
426a2dc1f3fSmrg</row>
427a2dc1f3fSmrg<row>
428c0a68be4Smrg<entry><filename class="headerfile">optional</filename></entry>
429c0a68be4Smrg<entry><filename class="headerfile">string_view</filename></entry>
4301debfc3dSmrg<entry><filename class="headerfile">variant</filename></entry>
431c0a68be4Smrg<entry namest="c4" nameend="c5"/>
4321debfc3dSmrg</row>
4331debfc3dSmrg</tbody>
4341debfc3dSmrg</tgroup>
4351debfc3dSmrg</table>
4361debfc3dSmrg
437c0a68be4Smrg<para>
438c0a68be4Smrg<xref linkend="table.cxx20_headers"/>
439c0a68be4Smrgshows the C++2a include files.
440c0a68be4SmrgThese are available in C++2a compilation
441c0a68be4Smrgmode, i.e. <literal>-std=c++2a</literal> or <literal>-std=gnu++2a</literal>.
442c0a68be4SmrgIncluding these headers in earlier modes will not result in
443c0a68be4Smrgcompilation errors, but will not define anything.
444c0a68be4Smrg<!--
445c0a68be4SmrgUnless specified otherwise below, they are also available in later modes
446c0a68be4Smrg(C++23 etc).
447c0a68be4Smrg-->
448c0a68be4Smrg</para>
449c0a68be4Smrg
450c0a68be4Smrg<para/>
451c0a68be4Smrg<table frame="all" xml:id="table.cxx20_headers">
452c0a68be4Smrg<title>C++ 2020 Library Headers</title>
453c0a68be4Smrg
454c0a68be4Smrg<tgroup cols="2" align="left" colsep="1" rowsep="1">
455c0a68be4Smrg<colspec colname="c1"/>
456c0a68be4Smrg<colspec colname="c2"/>
457c0a68be4Smrg<!--
458c0a68be4Smrg<colspec colname="c3"/>
459c0a68be4Smrg<colspec colname="c4"/>
460c0a68be4Smrg<colspec colname="c5"/>
461c0a68be4Smrg-->
462c0a68be4Smrg<tbody>
463c0a68be4Smrg<row>
464c0a68be4Smrg<entry><filename class="headerfile">bit</filename></entry>
465c0a68be4Smrg<entry><filename class="headerfile">version</filename></entry>
466c0a68be4Smrg</row>
467c0a68be4Smrg<!-- TODO compare, concepts, contract, span, syncstream -->
468c0a68be4Smrg</tbody>
469c0a68be4Smrg</tgroup>
470c0a68be4Smrg</table>
471c0a68be4Smrg
472c0a68be4Smrg<para>
473c0a68be4Smrg  The following headers have been removed in the C++2a working draft.
474c0a68be4Smrg  They are still available when using this implementation, but in future
475c0a68be4Smrg  they might start to produce warnings or errors when included in C++2a mode.
476c0a68be4Smrg  Programs that intend to be portable should not include them.
477c0a68be4Smrg</para>
478c0a68be4Smrg
479c0a68be4Smrg<table frame="all" xml:id="table.cxx20_deprheaders">
480c0a68be4Smrg<title>C++ 2020 Obsolete Headers</title>
481c0a68be4Smrg
482c0a68be4Smrg<tgroup cols="5" align="left" colsep="1" rowsep="1">
483c0a68be4Smrg<colspec colname="c1"/>
484c0a68be4Smrg<colspec colname="c2"/>
485c0a68be4Smrg<colspec colname="c3"/>
486c0a68be4Smrg<colspec colname="c4"/>
487c0a68be4Smrg<colspec colname="c5"/>
488c0a68be4Smrg<tbody>
489c0a68be4Smrg<row>
490c0a68be4Smrg<entry><filename class="headerfile">ccomplex</filename></entry>
491c0a68be4Smrg<entry><filename class="headerfile">ciso646</filename></entry>
492c0a68be4Smrg<entry><filename class="headerfile">cstdalign</filename></entry>
493c0a68be4Smrg<entry><filename class="headerfile">cstdbool</filename></entry>
494c0a68be4Smrg<entry><filename class="headerfile">ctgmath</filename></entry>
495c0a68be4Smrg</row>
496c0a68be4Smrg</tbody>
497c0a68be4Smrg</tgroup>
498c0a68be4Smrg</table>
4991debfc3dSmrg
5001debfc3dSmrg<para>
5011debfc3dSmrg<xref linkend="table.filesystemts_headers"/>,
5021debfc3dSmrgshows the additional include file define by the
5031debfc3dSmrgFile System Technical Specification, ISO/IEC TS 18822.
5041debfc3dSmrgThis is available in C++11 and later compilation modes.
5051debfc3dSmrgIncluding this header in earlier modes will not result in
5061debfc3dSmrgcompilation errors, but will not define anything.
5071debfc3dSmrg</para>
5081debfc3dSmrg
5091debfc3dSmrg<para/>
5101debfc3dSmrg<table frame="all" xml:id="table.filesystemts_headers">
5111debfc3dSmrg<title>File System TS Header</title>
5121debfc3dSmrg
5131debfc3dSmrg<tgroup cols="1" align="left" colsep="1" rowsep="1">
5141debfc3dSmrg<colspec colname="c1"/>
5151debfc3dSmrg<tbody>
5161debfc3dSmrg<row>
5171debfc3dSmrg<entry><filename class="headerfile">experimental/filesystem</filename></entry>
5181debfc3dSmrg</row>
5191debfc3dSmrg</tbody>
5201debfc3dSmrg</tgroup>
5211debfc3dSmrg</table>
5221debfc3dSmrg
5231debfc3dSmrg
5241debfc3dSmrg<para>
5251debfc3dSmrg<xref linkend="table.libfundts_headers"/>,
5261debfc3dSmrgshows the additional include files define by the C++ Extensions for
5271debfc3dSmrgLibrary Fundamentals Technical Specification, ISO/IEC TS 19568.
5281debfc3dSmrgThese are available in C++14 and later compilation modes.
5291debfc3dSmrgIncluding these headers in earlier modes will not result in
5301debfc3dSmrgcompilation errors, but will not define anything.
5311debfc3dSmrg</para>
5321debfc3dSmrg
5331debfc3dSmrg<para/>
5341debfc3dSmrg<table frame="all" xml:id="table.libfundts_headers">
5351debfc3dSmrg<title>Library Fundamentals TS Headers</title>
5361debfc3dSmrg
5371debfc3dSmrg<tgroup cols="5" align="left" colsep="1" rowsep="1">
5381debfc3dSmrg<colspec colname="c1"/>
5391debfc3dSmrg<colspec colname="c2"/>
5401debfc3dSmrg<colspec colname="c3"/>
5411debfc3dSmrg<colspec colname="c4"/>
5421debfc3dSmrg<colspec colname="c5"/>
5431debfc3dSmrg<tbody>
5441debfc3dSmrg<row>
5451debfc3dSmrg<entry><filename class="headerfile">experimental/algorithm</filename></entry>
5461debfc3dSmrg<entry><filename class="headerfile">experimental/any</filename></entry>
5471debfc3dSmrg<entry><filename class="headerfile">experimental/array</filename></entry>
5481debfc3dSmrg<entry><filename class="headerfile">experimental/chrono</filename></entry>
5491debfc3dSmrg<entry><filename class="headerfile">experimental/deque</filename></entry>
5501debfc3dSmrg</row>
5511debfc3dSmrg<row>
5521debfc3dSmrg<entry><filename class="headerfile">experimental/forward_list</filename></entry>
5531debfc3dSmrg<entry><filename class="headerfile">experimental/functional</filename></entry>
5541debfc3dSmrg<entry><filename class="headerfile">experimental/iterator</filename></entry>
5551debfc3dSmrg<entry><filename class="headerfile">experimental/list</filename></entry>
5561debfc3dSmrg<entry><filename class="headerfile">experimental/map</filename></entry>
5571debfc3dSmrg</row>
5581debfc3dSmrg<row>
5591debfc3dSmrg<entry><filename class="headerfile">experimental/memory</filename></entry>
5601debfc3dSmrg<entry><filename class="headerfile">experimental/memory_resource</filename></entry>
5611debfc3dSmrg<entry><filename class="headerfile">experimental/numeric</filename></entry>
5621debfc3dSmrg<entry><filename class="headerfile">experimental/optional</filename></entry>
5631debfc3dSmrg<entry><filename class="headerfile">experimental/propagate_const</filename></entry>
5641debfc3dSmrg</row>
5651debfc3dSmrg<row>
5661debfc3dSmrg<entry><filename class="headerfile">experimental/random</filename></entry>
5671debfc3dSmrg<entry><filename class="headerfile">experimental/ratio</filename></entry>
5681debfc3dSmrg<entry><filename class="headerfile">experimental/regex</filename></entry>
5691debfc3dSmrg<entry><filename class="headerfile">experimental/set</filename></entry>
5701debfc3dSmrg<entry><filename class="headerfile">experimental/source_location</filename></entry>
5711debfc3dSmrg</row>
5721debfc3dSmrg<row>
5731debfc3dSmrg<entry><filename class="headerfile">experimental/string</filename></entry>
5741debfc3dSmrg<entry><filename class="headerfile">experimental/string_view</filename></entry>
5751debfc3dSmrg<entry><filename class="headerfile">experimental/system_error</filename></entry>
5761debfc3dSmrg<entry><filename class="headerfile">experimental/tuple</filename></entry>
5771debfc3dSmrg<entry><filename class="headerfile">experimental/type_traits</filename></entry>
5781debfc3dSmrg</row>
5791debfc3dSmrg<row>
5801debfc3dSmrg<entry><filename class="headerfile">experimental/unordered_map</filename></entry>
5811debfc3dSmrg<entry><filename class="headerfile">experimental/unordered_set</filename></entry>
5821debfc3dSmrg<entry><filename class="headerfile">experimental/utility</filename></entry>
5831debfc3dSmrg<entry><filename class="headerfile">experimental/vector</filename></entry>
5841debfc3dSmrg<entry />
5851debfc3dSmrg</row>
5861debfc3dSmrg</tbody>
5871debfc3dSmrg</tgroup>
5881debfc3dSmrg</table>
5891debfc3dSmrg
5901debfc3dSmrg
5911debfc3dSmrg<para>
5921debfc3dSmrg  In addition, TR1 includes as:
5931debfc3dSmrg</para>
5941debfc3dSmrg
5951debfc3dSmrg<table frame="all" xml:id="table.tr1_headers">
5961debfc3dSmrg<title>C++ TR 1 Library Headers</title>
5971debfc3dSmrg
5981debfc3dSmrg<tgroup cols="5" align="left" colsep="1" rowsep="1">
5991debfc3dSmrg<colspec colname="c1"/>
6001debfc3dSmrg<colspec colname="c2"/>
6011debfc3dSmrg<colspec colname="c3"/>
6021debfc3dSmrg<colspec colname="c4"/>
6031debfc3dSmrg<colspec colname="c5"/>
6041debfc3dSmrg<tbody>
6051debfc3dSmrg
6061debfc3dSmrg<row>
6071debfc3dSmrg<entry><filename class="headerfile">tr1/array</filename></entry>
6081debfc3dSmrg<entry><filename class="headerfile">tr1/complex</filename></entry>
6091debfc3dSmrg<entry><filename class="headerfile">tr1/memory</filename></entry>
6101debfc3dSmrg<entry><filename class="headerfile">tr1/functional</filename></entry>
6111debfc3dSmrg<entry><filename class="headerfile">tr1/random</filename></entry>
6121debfc3dSmrg</row>
6131debfc3dSmrg<row>
6141debfc3dSmrg<entry><filename class="headerfile">tr1/regex</filename></entry>
6151debfc3dSmrg<entry><filename class="headerfile">tr1/tuple</filename></entry>
6161debfc3dSmrg<entry><filename class="headerfile">tr1/type_traits</filename></entry>
6171debfc3dSmrg<entry><filename class="headerfile">tr1/unordered_map</filename></entry>
6181debfc3dSmrg<entry><filename class="headerfile">tr1/unordered_set</filename></entry>
6191debfc3dSmrg</row>
6201debfc3dSmrg<row>
6211debfc3dSmrg<entry><filename class="headerfile">tr1/utility</filename></entry>
6221debfc3dSmrg<entry namest="c2" nameend="c5"/>
6231debfc3dSmrg</row>
6241debfc3dSmrg
6251debfc3dSmrg</tbody>
6261debfc3dSmrg</tgroup>
6271debfc3dSmrg</table>
6281debfc3dSmrg
6291debfc3dSmrg<para/>
6301debfc3dSmrg
6311debfc3dSmrg
6321debfc3dSmrg<table frame="all" xml:id="table.tr1_cheaders">
6331debfc3dSmrg<title>C++ TR 1 Library Headers for C Library Facilities</title>
6341debfc3dSmrg
6351debfc3dSmrg<tgroup cols="5" align="left" colsep="1" rowsep="1">
6361debfc3dSmrg<colspec colname="c1"/>
6371debfc3dSmrg<colspec colname="c2"/>
6381debfc3dSmrg<colspec colname="c3"/>
6391debfc3dSmrg<colspec colname="c4"/>
6401debfc3dSmrg<colspec colname="c5"/>
6411debfc3dSmrg<tbody>
6421debfc3dSmrg
6431debfc3dSmrg<row>
6441debfc3dSmrg<entry><filename class="headerfile">tr1/ccomplex</filename></entry>
6451debfc3dSmrg<entry><filename class="headerfile">tr1/cfenv</filename></entry>
6461debfc3dSmrg<entry><filename class="headerfile">tr1/cfloat</filename></entry>
6471debfc3dSmrg<entry><filename class="headerfile">tr1/cmath</filename></entry>
6481debfc3dSmrg<entry><filename class="headerfile">tr1/cinttypes</filename></entry>
6491debfc3dSmrg</row>
6501debfc3dSmrg<row>
6511debfc3dSmrg<entry><filename class="headerfile">tr1/climits</filename></entry>
6521debfc3dSmrg<entry><filename class="headerfile">tr1/cstdarg</filename></entry>
6531debfc3dSmrg<entry><filename class="headerfile">tr1/cstdbool</filename></entry>
6541debfc3dSmrg<entry><filename class="headerfile">tr1/cstdint</filename></entry>
6551debfc3dSmrg<entry><filename class="headerfile">tr1/cstdio</filename></entry>
6561debfc3dSmrg</row>
6571debfc3dSmrg<row>
6581debfc3dSmrg<entry><filename class="headerfile">tr1/cstdlib</filename></entry>
6591debfc3dSmrg<entry><filename class="headerfile">tr1/ctgmath</filename></entry>
6601debfc3dSmrg<entry><filename class="headerfile">tr1/ctime</filename></entry>
6611debfc3dSmrg<entry><filename class="headerfile">tr1/cwchar</filename></entry>
6621debfc3dSmrg<entry><filename class="headerfile">tr1/cwctype</filename></entry>
6631debfc3dSmrg</row>
6641debfc3dSmrg
6651debfc3dSmrg</tbody>
6661debfc3dSmrg</tgroup>
6671debfc3dSmrg</table>
6681debfc3dSmrg
6691debfc3dSmrg
6701debfc3dSmrg<para>Decimal floating-point arithmetic is available if the C++
6711debfc3dSmrgcompiler supports scalar decimal floating-point types defined via
6721debfc3dSmrg<code>__attribute__((mode(SD|DD|LD)))</code>.
6731debfc3dSmrg</para>
6741debfc3dSmrg
6751debfc3dSmrg<table frame="all" xml:id="table.decfp_headers">
6761debfc3dSmrg<title>C++ TR 24733 Decimal Floating-Point Header</title>
6771debfc3dSmrg
6781debfc3dSmrg<tgroup cols="1" align="left" colsep="1" rowsep="1">
6791debfc3dSmrg<colspec colname="c1"/>
6801debfc3dSmrg<tbody>
6811debfc3dSmrg<row>
6821debfc3dSmrg<entry><filename class="headerfile">decimal/decimal</filename></entry>
6831debfc3dSmrg</row>
6841debfc3dSmrg</tbody>
6851debfc3dSmrg</tgroup>
6861debfc3dSmrg</table>
6871debfc3dSmrg
6881debfc3dSmrg<para>
6891debfc3dSmrg  Also included are files for the C++ ABI interface:
6901debfc3dSmrg</para>
6911debfc3dSmrg
6921debfc3dSmrg<table frame="all" xml:id="table.abi_headers">
6931debfc3dSmrg<title>C++ ABI Headers</title>
6941debfc3dSmrg
6951debfc3dSmrg<tgroup cols="2" align="left" colsep="1" rowsep="1">
6961debfc3dSmrg<colspec colname="c1"/>
6971debfc3dSmrg<colspec colname="c2"/>
6981debfc3dSmrg<tbody>
6991debfc3dSmrg<row><entry><filename class="headerfile">cxxabi.h</filename></entry><entry><filename class="headerfile">cxxabi_forced.h</filename></entry></row>
7001debfc3dSmrg</tbody>
7011debfc3dSmrg</tgroup>
7021debfc3dSmrg</table>
7031debfc3dSmrg
7041debfc3dSmrg<para>
7051debfc3dSmrg  And a large variety of extensions.
7061debfc3dSmrg</para>
7071debfc3dSmrg
7081debfc3dSmrg<table frame="all" xml:id="table.ext_headers">
7091debfc3dSmrg<title>Extension Headers</title>
7101debfc3dSmrg
7111debfc3dSmrg<tgroup cols="5" align="left" colsep="1" rowsep="1">
7121debfc3dSmrg<colspec colname="c1"/>
7131debfc3dSmrg<colspec colname="c2"/>
7141debfc3dSmrg<colspec colname="c3"/>
7151debfc3dSmrg<colspec colname="c4"/>
7161debfc3dSmrg<colspec colname="c5"/>
7171debfc3dSmrg<tbody>
7181debfc3dSmrg
7191debfc3dSmrg<row>
7201debfc3dSmrg<entry><filename class="headerfile">ext/algorithm</filename></entry>
7211debfc3dSmrg<entry><filename class="headerfile">ext/atomicity.h</filename></entry>
7221debfc3dSmrg<entry><filename class="headerfile">ext/bitmap_allocator.h</filename></entry>
7231debfc3dSmrg<entry><filename class="headerfile">ext/cast.h</filename></entry>
7241debfc3dSmrg</row>
7251debfc3dSmrg<row>
7261debfc3dSmrg<entry><filename class="headerfile">ext/codecvt_specializations.h</filename></entry>
7271debfc3dSmrg<entry><filename class="headerfile">ext/concurrence.h</filename></entry>
7281debfc3dSmrg<entry><filename class="headerfile">ext/debug_allocator.h</filename></entry>
7291debfc3dSmrg<entry><filename class="headerfile">ext/enc_filebuf.h</filename></entry>
7301debfc3dSmrg<entry><filename class="headerfile">ext/extptr_allocator.h</filename></entry>
7311debfc3dSmrg</row>
7321debfc3dSmrg<row>
7331debfc3dSmrg<entry><filename class="headerfile">ext/functional</filename></entry>
7341debfc3dSmrg<entry><filename class="headerfile">ext/iterator</filename></entry>
7351debfc3dSmrg<entry><filename class="headerfile">ext/malloc_allocator.h</filename></entry>
7361debfc3dSmrg<entry><filename class="headerfile">ext/memory</filename></entry>
7371debfc3dSmrg<entry><filename class="headerfile">ext/mt_allocator.h</filename></entry>
7381debfc3dSmrg</row>
7391debfc3dSmrg<row>
7401debfc3dSmrg<entry><filename class="headerfile">ext/new_allocator.h</filename></entry>
7411debfc3dSmrg<entry><filename class="headerfile">ext/numeric</filename></entry>
7421debfc3dSmrg<entry><filename class="headerfile">ext/numeric_traits.h</filename></entry>
7431debfc3dSmrg<entry><filename class="headerfile">ext/pb_ds/assoc_container.h</filename></entry>
7441debfc3dSmrg<entry><filename class="headerfile">ext/pb_ds/priority_queue.h</filename></entry>
7451debfc3dSmrg</row>
7461debfc3dSmrg<row>
7471debfc3dSmrg<entry><filename class="headerfile">ext/pod_char_traits.h</filename></entry>
7481debfc3dSmrg<entry><filename class="headerfile">ext/pool_allocator.h</filename></entry>
7491debfc3dSmrg<entry><filename class="headerfile">ext/rb_tree</filename></entry>
7501debfc3dSmrg<entry><filename class="headerfile">ext/rope</filename></entry>
7511debfc3dSmrg<entry><filename class="headerfile">ext/slist</filename></entry>
7521debfc3dSmrg</row>
7531debfc3dSmrg<row>
7541debfc3dSmrg<entry><filename class="headerfile">ext/stdio_filebuf.h</filename></entry>
7551debfc3dSmrg<entry><filename class="headerfile">ext/stdio_sync_filebuf.h</filename></entry>
7561debfc3dSmrg<entry><filename class="headerfile">ext/throw_allocator.h</filename></entry>
7571debfc3dSmrg<entry><filename class="headerfile">ext/typelist.h</filename></entry>
7581debfc3dSmrg<entry><filename class="headerfile">ext/type_traits.h</filename></entry>
7591debfc3dSmrg</row>
7601debfc3dSmrg<row>
7611debfc3dSmrg<entry><filename class="headerfile">ext/vstring.h</filename></entry>
7621debfc3dSmrg<entry namest="c2" nameend="c5"/>
7631debfc3dSmrg</row>
7641debfc3dSmrg
7651debfc3dSmrg</tbody>
7661debfc3dSmrg</tgroup>
7671debfc3dSmrg</table>
7681debfc3dSmrg
7691debfc3dSmrg<para/>
7701debfc3dSmrg
7711debfc3dSmrg<table frame="all" xml:id="table.debug_headers">
7721debfc3dSmrg<title>Extension Debug Headers</title>
7731debfc3dSmrg
7741debfc3dSmrg<tgroup cols="5" align="left" colsep="1" rowsep="1">
7751debfc3dSmrg<colspec colname="c1"/>
7761debfc3dSmrg<colspec colname="c2"/>
7771debfc3dSmrg<colspec colname="c3"/>
7781debfc3dSmrg<colspec colname="c4"/>
7791debfc3dSmrg<colspec colname="c5"/>
7801debfc3dSmrg<tbody>
7811debfc3dSmrg
7821debfc3dSmrg<row>
7831debfc3dSmrg<entry><filename class="headerfile">debug/array</filename></entry>
7841debfc3dSmrg<entry><filename class="headerfile">debug/bitset</filename></entry>
7851debfc3dSmrg<entry><filename class="headerfile">debug/deque</filename></entry>
7861debfc3dSmrg<entry><filename class="headerfile">debug/forward_list</filename></entry>
7871debfc3dSmrg<entry><filename class="headerfile">debug/list</filename></entry>
7881debfc3dSmrg</row>
7891debfc3dSmrg<row>
7901debfc3dSmrg<entry><filename class="headerfile">debug/map</filename></entry>
7911debfc3dSmrg<entry><filename class="headerfile">debug/set</filename></entry>
7921debfc3dSmrg<entry><filename class="headerfile">debug/string</filename></entry>
7931debfc3dSmrg<entry><filename class="headerfile">debug/unordered_map</filename></entry>
7941debfc3dSmrg<entry><filename class="headerfile">debug/unordered_set</filename></entry>
7951debfc3dSmrg</row>
7961debfc3dSmrg<row>
7971debfc3dSmrg<entry><filename class="headerfile">debug/vector</filename></entry>
7981debfc3dSmrg<entry namest="c2" nameend="c5"/>
7991debfc3dSmrg</row>
8001debfc3dSmrg
8011debfc3dSmrg</tbody>
8021debfc3dSmrg</tgroup>
8031debfc3dSmrg</table>
8041debfc3dSmrg
8051debfc3dSmrg<para/>
8061debfc3dSmrg
8071debfc3dSmrg<table frame="all" xml:id="table.parallel_headers">
8081debfc3dSmrg<title>Extension Parallel Headers</title>
8091debfc3dSmrg
8101debfc3dSmrg<tgroup cols="2" align="left" colsep="1" rowsep="1">
8111debfc3dSmrg<colspec colname="c1"/>
8121debfc3dSmrg<colspec colname="c2"/>
8131debfc3dSmrg<tbody>
8141debfc3dSmrg<row>
8151debfc3dSmrg<entry><filename class="headerfile">parallel/algorithm</filename></entry>
8161debfc3dSmrg<entry><filename class="headerfile">parallel/numeric</filename></entry>
8171debfc3dSmrg</row>
8181debfc3dSmrg</tbody>
8191debfc3dSmrg</tgroup>
8201debfc3dSmrg</table>
8211debfc3dSmrg
8221debfc3dSmrg    </section>
8231debfc3dSmrg
8241debfc3dSmrg    <section xml:id="manual.intro.using.headers.mixing" xreflabel="Mixing Headers"><info><title>Mixing Headers</title></info>
8251debfc3dSmrg
8261debfc3dSmrg
8271debfc3dSmrg<para> A few simple rules.
8281debfc3dSmrg</para>
8291debfc3dSmrg
8301debfc3dSmrg<para>First, mixing different dialects of the standard headers is not
8311debfc3dSmrgpossible. It's an all-or-nothing affair. Thus, code like
8321debfc3dSmrg</para>
8331debfc3dSmrg
8341debfc3dSmrg<programlisting>
8351debfc3dSmrg#include &lt;array&gt;
8361debfc3dSmrg#include &lt;functional&gt;
8371debfc3dSmrg</programlisting>
8381debfc3dSmrg
8391debfc3dSmrg<para>Implies C++11 mode. To use the entities in &lt;array&gt;, the C++11
8401debfc3dSmrgcompilation mode must be used, which implies the C++11 functionality
8411debfc3dSmrg(and deprecations) in &lt;functional&gt; will be present.
8421debfc3dSmrg</para>
8431debfc3dSmrg
8441debfc3dSmrg<para>Second, the other headers can be included with either dialect of
8451debfc3dSmrgthe standard headers, although features and types specific to C++11
8461debfc3dSmrgare still only enabled when in C++11 compilation mode. So, to use
8471debfc3dSmrgrvalue references with <code>__gnu_cxx::vstring</code>, or to use the
8481debfc3dSmrgdebug-mode versions of <code>std::unordered_map</code>, one must use
8491debfc3dSmrgthe <code>std=gnu++11</code> compiler flag. (Or <code>std=c++11</code>, of course.)
8501debfc3dSmrg</para>
8511debfc3dSmrg
8521debfc3dSmrg<para>A special case of the second rule is the mixing of TR1 and C++11
8531debfc3dSmrgfacilities. It is possible (although not especially prudent) to
8541debfc3dSmrginclude both the TR1 version and the C++11 version of header in the
8551debfc3dSmrgsame translation unit:
8561debfc3dSmrg</para>
8571debfc3dSmrg
8581debfc3dSmrg<programlisting>
8591debfc3dSmrg#include &lt;tr1/type_traits&gt;
8601debfc3dSmrg#include &lt;type_traits&gt;
8611debfc3dSmrg</programlisting>
8621debfc3dSmrg
8631debfc3dSmrg<para> Several parts of C++11 diverge quite substantially from TR1 predecessors.
8641debfc3dSmrg</para>
8651debfc3dSmrg    </section>
8661debfc3dSmrg
8671debfc3dSmrg    <section xml:id="manual.intro.using.headers.cheaders" xreflabel="C Headers and"><info><title>The C Headers and <code>namespace std</code></title></info>
8681debfc3dSmrg
8691debfc3dSmrg
8701debfc3dSmrg<para>
8711debfc3dSmrg	The standard specifies that if one includes the C-style header
8721debfc3dSmrg	(&lt;math.h&gt; in this case), the symbols will be available
8731debfc3dSmrg	in the global namespace and perhaps in
8741debfc3dSmrg	namespace <code>std::</code> (but this is no longer a firm
8751debfc3dSmrg	requirement.) On the other hand, including the C++-style
8761debfc3dSmrg	header (&lt;cmath&gt;) guarantees that the entities will be
8771debfc3dSmrg	found in namespace std and perhaps in the global namespace.
8781debfc3dSmrg      </para>
8791debfc3dSmrg
8801debfc3dSmrg<para>
8811debfc3dSmrgUsage of C++-style headers is recommended, as then
8821debfc3dSmrgC-linkage names can be disambiguated by explicit qualification, such
8831debfc3dSmrgas by <code>std::abort</code>. In addition, the C++-style headers can
8841debfc3dSmrguse function overloading to provide a simpler interface to certain
8851debfc3dSmrgfamilies of C-functions. For instance in &lt;cmath&gt;, the
8861debfc3dSmrgfunction <code>std::sin</code> has overloads for all the builtin
8871debfc3dSmrgfloating-point types. This means that <code>std::sin</code> can be
8881debfc3dSmrgused uniformly, instead of a combination
8891debfc3dSmrgof <code>std::sinf</code>, <code>std::sin</code>,
8901debfc3dSmrgand <code>std::sinl</code>.
8911debfc3dSmrg</para>
8921debfc3dSmrg    </section>
8931debfc3dSmrg
8941debfc3dSmrg    <section xml:id="manual.intro.using.headers.pre" xreflabel="Precompiled Headers"><info><title>Precompiled Headers</title></info>
8951debfc3dSmrg
8961debfc3dSmrg
8971debfc3dSmrg
8981debfc3dSmrg<para>There are three base header files that are provided. They can be
8991debfc3dSmrgused to precompile the standard headers and extensions into binary
9001debfc3dSmrgfiles that may then be used to speed up compilations that use these headers.
9011debfc3dSmrg</para>
9021debfc3dSmrg
9031debfc3dSmrg
9041debfc3dSmrg<itemizedlist>
9051debfc3dSmrg<listitem>
9061debfc3dSmrg  <para>stdc++.h</para>
9071debfc3dSmrg<para>Includes all standard headers. Actual content varies depending on
9081debfc3dSmrg<link linkend="manual.intro.using.flags">language dialect</link>.
9091debfc3dSmrg</para>
9101debfc3dSmrg</listitem>
9111debfc3dSmrg
9121debfc3dSmrg<listitem>
9131debfc3dSmrg  <para>stdtr1c++.h</para>
9141debfc3dSmrg<para>Includes all of &lt;stdc++.h&gt;, and adds all the TR1 headers.
9151debfc3dSmrg</para>
9161debfc3dSmrg</listitem>
9171debfc3dSmrg
9181debfc3dSmrg<listitem><para>extc++.h</para>
9191debfc3dSmrg<para>Includes all of &lt;stdc++.h&gt;, and adds all the Extension headers
9201debfc3dSmrg(and in C++98 mode also adds all the TR1 headers by including all of
9211debfc3dSmrg&lt;stdtr1c++.h&gt;).
9221debfc3dSmrg</para></listitem>
9231debfc3dSmrg</itemizedlist>
9241debfc3dSmrg
9251debfc3dSmrg<para>To construct a .gch file from one of these base header files,
9261debfc3dSmrgfirst find the include directory for the compiler. One way to do
9271debfc3dSmrgthis is:</para>
9281debfc3dSmrg
9291debfc3dSmrg<programlisting>
9301debfc3dSmrgg++ -v hello.cc
9311debfc3dSmrg
9321debfc3dSmrg#include &lt;...&gt; search starts here:
9331debfc3dSmrg /mnt/share/bld/H-x86-gcc.20071201/include/c++/4.3.0
9341debfc3dSmrg...
9351debfc3dSmrgEnd of search list.
9361debfc3dSmrg</programlisting>
9371debfc3dSmrg
9381debfc3dSmrg
9391debfc3dSmrg<para>Then, create a precompiled header file with the same flags that
9401debfc3dSmrgwill be used to compile other projects.</para>
9411debfc3dSmrg
9421debfc3dSmrg<programlisting>
9431debfc3dSmrgg++ -Winvalid-pch -x c++-header -g -O2 -o ./stdc++.h.gch /mnt/share/bld/H-x86-gcc.20071201/include/c++/4.3.0/x86_64-unknown-linux-gnu/bits/stdc++.h
9441debfc3dSmrg</programlisting>
9451debfc3dSmrg
9461debfc3dSmrg<para>The resulting file will be quite large: the current size is around
9471debfc3dSmrgthirty megabytes. </para>
9481debfc3dSmrg
9491debfc3dSmrg<para>How to use the resulting file.</para>
9501debfc3dSmrg
9511debfc3dSmrg<programlisting>
9521debfc3dSmrgg++ -I. -include stdc++.h  -H -g -O2 hello.cc
9531debfc3dSmrg</programlisting>
9541debfc3dSmrg
9551debfc3dSmrg<para>Verification that the PCH file is being used is easy:</para>
9561debfc3dSmrg
9571debfc3dSmrg<programlisting>
9581debfc3dSmrgg++ -Winvalid-pch -I. -include stdc++.h -H -g -O2 hello.cc -o test.exe
9591debfc3dSmrg! ./stdc++.h.gch
9601debfc3dSmrg. /mnt/share/bld/H-x86-gcc.20071201/include/c++/4.3.0/iostream
9611debfc3dSmrg. /mnt/share/bld/H-x86-gcc.20071201include/c++/4.3.0/string
9621debfc3dSmrg</programlisting>
9631debfc3dSmrg
9641debfc3dSmrg<para>The exclamation point to the left of the <code>stdc++.h.gch</code> listing means that the generated PCH file was used.</para>
9651debfc3dSmrg<para/>
9661debfc3dSmrg
9671debfc3dSmrg<para> Detailed information about creating precompiled header files can be found in the GCC <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html">documentation</link>.
9681debfc3dSmrg</para>
9691debfc3dSmrg
9701debfc3dSmrg    </section>
9711debfc3dSmrg  </section>
9721debfc3dSmrg
9731debfc3dSmrg
9741debfc3dSmrg  <section xml:id="manual.intro.using.macros" xreflabel="Macros"><info><title>Macros</title></info>
9751debfc3dSmrg    <?dbhtml filename="using_macros.html"?>
9761debfc3dSmrg
9771debfc3dSmrg
9781debfc3dSmrg   <para>
9791debfc3dSmrg     All library macros begin with <code>_GLIBCXX_</code>.
9801debfc3dSmrg   </para>
9811debfc3dSmrg
9821debfc3dSmrg   <para>
9831debfc3dSmrg     Furthermore, all pre-processor macros, switches, and
9841debfc3dSmrg      configuration options are gathered in the
9851debfc3dSmrg      file <filename class="headerfile">c++config.h</filename>, which
9861debfc3dSmrg      is generated during the libstdc++ configuration and build
9871debfc3dSmrg      process. This file is then included when needed by files part of
9881debfc3dSmrg      the public libstdc++ API, like
9891debfc3dSmrg      <filename class="headerfile">&lt;ios&gt;</filename>. Most of these
9901debfc3dSmrg      macros should not be used by consumers of libstdc++, and are reserved
9911debfc3dSmrg      for internal implementation use. <emphasis>These macros cannot
9921debfc3dSmrg      be redefined</emphasis>.
9931debfc3dSmrg   </para>
9941debfc3dSmrg
9951debfc3dSmrg   <para>
9961debfc3dSmrg     A select handful of macros control libstdc++ extensions and extra
9971debfc3dSmrg      features, or provide versioning information for the API.  Only
9981debfc3dSmrg      those macros listed below are offered for consideration by the
9991debfc3dSmrg      general public.
10001debfc3dSmrg   </para>
10011debfc3dSmrg
10021debfc3dSmrg   <para>Below are the macros which users may check for library version
10031debfc3dSmrg      information. </para>
10041debfc3dSmrg
10051debfc3dSmrg    <variablelist>
10061debfc3dSmrg    <varlistentry>
10071debfc3dSmrg      <term><code>_GLIBCXX_RELEASE</code></term>
10081debfc3dSmrg      <listitem>
10091debfc3dSmrg	<para>The major release number for libstdc++.  This macro is defined
10101debfc3dSmrg        to the GCC major version that the libstdc++ headers belong to,
10111debfc3dSmrg        as an integer constant.
10121debfc3dSmrg        When compiling with GCC it has the same value as GCC's pre-defined
10131debfc3dSmrg        macro <symbol>__GNUC__</symbol>.
10141debfc3dSmrg        This macro can be used when libstdc++ is used with a non-GNU
10151debfc3dSmrg        compiler where <symbol>__GNUC__</symbol> is not defined, or has a
10161debfc3dSmrg        different value that doesn't correspond to the libstdc++ version.
10171debfc3dSmrg        This macro first appeared in the GCC 7.1 release and is not defined
10181debfc3dSmrg        for GCC 6.x or older releases.
10191debfc3dSmrg      </para>
10201debfc3dSmrg      </listitem>
10211debfc3dSmrg    </varlistentry>
10221debfc3dSmrg    <varlistentry>
10231debfc3dSmrg      <term><code>__GLIBCXX__</code></term>
10241debfc3dSmrg      <listitem>
10251debfc3dSmrg	<para>The revision date of the libstdc++ source code,
10261debfc3dSmrg        in compressed ISO date format, as an unsigned
10271debfc3dSmrg        long. For notes about using this macro and details on the value of
10281debfc3dSmrg        this macro for a particular release, please consult the
10291debfc3dSmrg        <link linkend="abi.versioning.__GLIBCXX__">ABI History</link>
10301debfc3dSmrg        appendix.
10311debfc3dSmrg        </para>
10321debfc3dSmrg      </listitem>
10331debfc3dSmrg    </varlistentry>
10341debfc3dSmrg    </variablelist>
10351debfc3dSmrg
10361debfc3dSmrg   <para>Below are the macros which users may change with #define/#undef or
10371debfc3dSmrg      with -D/-U compiler flags.  The default state of the symbol is
10381debfc3dSmrg      listed.</para>
10391debfc3dSmrg
10401debfc3dSmrg   <para><quote>Configurable</quote> (or <quote>Not configurable</quote>) means
10411debfc3dSmrg      that the symbol is initially chosen (or not) based on
10421debfc3dSmrg      --enable/--disable options at library build and configure time
10431debfc3dSmrg      (documented in
10441debfc3dSmrg      <link linkend="manual.intro.setup.configure">Configure</link>),
10451debfc3dSmrg      with the various --enable/--disable choices being translated to
10461debfc3dSmrg      #define/#undef).
10471debfc3dSmrg   </para>
10481debfc3dSmrg
10491debfc3dSmrg   <para> <acronym>ABI</acronym> means that changing from the default value may
10501debfc3dSmrg  mean changing the <acronym>ABI</acronym> of compiled code. In other words,
10511debfc3dSmrg  these choices control code which has already been compiled (i.e., in a
10521debfc3dSmrg  binary such as libstdc++.a/.so).  If you explicitly #define or
10531debfc3dSmrg  #undef these macros, the <emphasis>headers</emphasis> may see different code
10541debfc3dSmrg  paths, but the <emphasis>libraries</emphasis> which you link against will not.
10551debfc3dSmrg  Experimenting with different values with the expectation of
10561debfc3dSmrg  consistent linkage requires changing the config headers before
10571debfc3dSmrg  building/installing the library.
10581debfc3dSmrg   </para>
10591debfc3dSmrg
10601debfc3dSmrg    <variablelist>
10611debfc3dSmrg    <varlistentry><term><code>_GLIBCXX_USE_DEPRECATED</code></term>
10621debfc3dSmrg    <listitem>
10631debfc3dSmrg      <para>
10641debfc3dSmrg	Defined by default. Not configurable. ABI-changing. Turning this off
10651debfc3dSmrg	removes older ARM-style iostreams code, and other anachronisms
10661debfc3dSmrg	from the API.  This macro is dependent on the version of the
10671debfc3dSmrg	standard being tracked, and as a result may give different results for
10681debfc3dSmrg	<code>-std=c++98</code> and <code>-std=c++11</code>. This may
10691debfc3dSmrg	be useful in updating old C++ code which no longer meet the
10701debfc3dSmrg	requirements of the language, or for checking current code
10711debfc3dSmrg	against new language standards.
10721debfc3dSmrg    </para>
10731debfc3dSmrg    </listitem></varlistentry>
10741debfc3dSmrg
10751debfc3dSmrg    <varlistentry><term><code>_GLIBCXX_USE_CXX11_ABI</code></term>
10761debfc3dSmrg    <listitem>
10771debfc3dSmrg      <para>
10781debfc3dSmrg        Defined to the value <literal>1</literal> by default.
10791debfc3dSmrg        Configurable via  <code>--disable-libstdcxx-dual-abi</code>
10801debfc3dSmrg        and/or <code>--with-default-libstdcxx-abi</code>.
10811debfc3dSmrg        ABI-changing.
10821debfc3dSmrg        When defined to a non-zero value the library headers will use the
10831debfc3dSmrg        new C++11-conforming ABI introduced in GCC 5, rather than the older
10841debfc3dSmrg        ABI introduced in GCC 3.4. This changes the definition of several
10851debfc3dSmrg        class templates, including <classname>std:string</classname>,
10861debfc3dSmrg        <classname>std::list</classname> and some locale facets.
10871debfc3dSmrg        For more details see <xref linkend="manual.intro.using.abi"/>.
10881debfc3dSmrg    </para>
10891debfc3dSmrg    </listitem></varlistentry>
10901debfc3dSmrg
10911debfc3dSmrg    <varlistentry><term><code>_GLIBCXX_CONCEPT_CHECKS</code></term>
10921debfc3dSmrg    <listitem>
10931debfc3dSmrg      <para>
10941debfc3dSmrg	Undefined by default.  Configurable via
10951debfc3dSmrg	<code>--enable-concept-checks</code>.  When defined, performs
10961debfc3dSmrg	compile-time checking on certain template instantiations to
10971debfc3dSmrg	detect violations of the requirements of the standard.  This
10981debfc3dSmrg	macro has no effect for freestanding implementations.
10991debfc3dSmrg	This is described in more detail in
11001debfc3dSmrg	<link linkend="manual.ext.compile_checks">Compile Time Checks</link>.
11011debfc3dSmrg      </para>
11021debfc3dSmrg    </listitem></varlistentry>
11031debfc3dSmrg
11041debfc3dSmrg    <varlistentry><term><code>_GLIBCXX_ASSERTIONS</code></term>
11051debfc3dSmrg    <listitem>
11061debfc3dSmrg      <para>
11071debfc3dSmrg	Undefined by default. When defined, enables extra error checking in
11081debfc3dSmrg        the form of precondition assertions, such as bounds checking in
11091debfc3dSmrg        strings and null pointer checks when dereferencing smart pointers.
11101debfc3dSmrg      </para>
11111debfc3dSmrg    </listitem></varlistentry>
11121debfc3dSmrg    <varlistentry><term><code>_GLIBCXX_DEBUG</code></term>
11131debfc3dSmrg    <listitem>
11141debfc3dSmrg      <para>
11151debfc3dSmrg	Undefined by default. When defined, compiles user code using
11161debfc3dSmrg	the <link linkend="manual.ext.debug_mode">debug mode</link>.
11171debfc3dSmrg        When defined, <code>_GLIBCXX_ASSERTIONS</code> is defined
11181debfc3dSmrg        automatically, so all the assertions enabled by that macro are also
11191debfc3dSmrg        enabled in debug mode.
11201debfc3dSmrg      </para>
11211debfc3dSmrg    </listitem></varlistentry>
11221debfc3dSmrg    <varlistentry><term><code>_GLIBCXX_DEBUG_PEDANTIC</code></term>
11231debfc3dSmrg    <listitem>
11241debfc3dSmrg      <para>
11251debfc3dSmrg	Undefined by default. When defined while compiling with
11261debfc3dSmrg	the <link linkend="manual.ext.debug_mode">debug mode</link>, makes
11271debfc3dSmrg	the debug mode extremely picky by making the use of libstdc++
11281debfc3dSmrg	extensions and libstdc++-specific behavior into errors.
11291debfc3dSmrg      </para>
11301debfc3dSmrg    </listitem></varlistentry>
11311debfc3dSmrg    <varlistentry><term><code>_GLIBCXX_PARALLEL</code></term>
11321debfc3dSmrg    <listitem>
11331debfc3dSmrg      <para>Undefined by default. When defined, compiles user code
11341debfc3dSmrg	using the <link linkend="manual.ext.parallel_mode">parallel
11351debfc3dSmrg	mode</link>.
11361debfc3dSmrg      </para>
11371debfc3dSmrg    </listitem></varlistentry>
11381debfc3dSmrg    <varlistentry><term><code>_GLIBCXX_PARALLEL_ASSERTIONS</code></term>
11391debfc3dSmrg    <listitem>
11401debfc3dSmrg      <para>Undefined by default, but when any parallel mode header is included
11411debfc3dSmrg      this macro will be defined to a non-zero value if
11421debfc3dSmrg      <code>_GLIBCXX_ASSERTIONS</code> has a non-zero value, otherwise to zero.
11431debfc3dSmrg      When defined to a non-zero value, it enables extra error checking and
11441debfc3dSmrg      assertions in the parallel mode.
11451debfc3dSmrg      </para>
11461debfc3dSmrg    </listitem></varlistentry>
11471debfc3dSmrg
11481debfc3dSmrg    <varlistentry><term><code>__STDCPP_WANT_MATH_SPEC_FUNCS__</code></term>
11491debfc3dSmrg    <listitem>
11501debfc3dSmrg      <para>Undefined by default. When defined to a non-zero integer constant,
11511debfc3dSmrg	enables support for ISO/IEC 29124 Special Math Functions.
11521debfc3dSmrg      </para>
11531debfc3dSmrg    </listitem></varlistentry>
1154a2dc1f3fSmrg
1155a2dc1f3fSmrg    <varlistentry><term><code>_GLIBCXX_SANITIZE_VECTOR</code></term>
1156a2dc1f3fSmrg    <listitem>
1157a2dc1f3fSmrg      <para>
1158a2dc1f3fSmrg	Undefined by default. When defined, <classname>std::vector</classname>
1159a2dc1f3fSmrg        operations will be annotated so that AddressSanitizer can detect
1160a2dc1f3fSmrg        invalid accesses to the unused capacity of a
1161a2dc1f3fSmrg        <classname>std::vector</classname>. These annotations are only
1162a2dc1f3fSmrg        enabled for
1163a2dc1f3fSmrg        <classname>std::vector&lt;T, std::allocator&lt;T&gt;&gt;</classname>
1164a2dc1f3fSmrg        and only when <classname>std::allocator</classname> is derived from
1165c0a68be4Smrg        <link linkend="allocator.ext"><classname>new_allocator</classname>
1166a2dc1f3fSmrg        or <classname>malloc_allocator</classname></link>. The annotations
1167a2dc1f3fSmrg        must be present on all vector operations or none, so this macro must
1168a2dc1f3fSmrg        be defined to the same value for all translation units that create,
1169a2dc1f3fSmrg        destroy or modify vectors.
1170a2dc1f3fSmrg      </para>
1171a2dc1f3fSmrg    </listitem></varlistentry>
11721debfc3dSmrg    </variablelist>
11731debfc3dSmrg
11741debfc3dSmrg  </section>
11751debfc3dSmrg
11761debfc3dSmrg<section xml:id="manual.intro.using.abi" xreflabel="Dual ABI">
11771debfc3dSmrg  <info><title>Dual ABI</title></info>
11781debfc3dSmrg  <?dbhtml filename="using_dual_abi.html"?>
11791debfc3dSmrg
11801debfc3dSmrg<para> In the GCC 5.1 release libstdc++ introduced a new library ABI that
11811debfc3dSmrg  includes new implementations of <classname>std::string</classname> and
11821debfc3dSmrg  <classname>std::list</classname>. These changes were necessary to conform
11831debfc3dSmrg  to the 2011 C++ standard which forbids Copy-On-Write strings and requires
11841debfc3dSmrg  lists to keep track of their size.
11851debfc3dSmrg</para>
11861debfc3dSmrg
11871debfc3dSmrg<para> In order to maintain backwards compatibility for existing code linked
11881debfc3dSmrg  to libstdc++ the library's soname has not changed and the old
11891debfc3dSmrg  implementations are still supported in parallel with the new ones.
11901debfc3dSmrg  This is achieved by defining the new implementations in an inline namespace
11911debfc3dSmrg  so they have different names for linkage purposes, e.g. the new version of
11921debfc3dSmrg  <classname>std::list&lt;int&gt;</classname> is actually defined as
11931debfc3dSmrg  <classname>std::__cxx11::list&lt;int&gt;</classname>. Because the symbols
11941debfc3dSmrg  for the new implementations have different names the definitions for both
11951debfc3dSmrg  versions can be present in the same library.
11961debfc3dSmrg</para>
11971debfc3dSmrg
11981debfc3dSmrg<para> The <symbol>_GLIBCXX_USE_CXX11_ABI</symbol> macro (see
11991debfc3dSmrg  <xref linkend="manual.intro.using.macros"/>) controls whether
12001debfc3dSmrg  the declarations in the library headers use the old or new ABI.
12011debfc3dSmrg  So the decision of which ABI to use can be made separately for each
12021debfc3dSmrg  source file being compiled.
12031debfc3dSmrg  Using the default configuration options for GCC the default value
12041debfc3dSmrg  of the macro is <literal>1</literal> which causes the new ABI to be active,
12051debfc3dSmrg  so to use the old ABI you must explicitly define the macro to
12061debfc3dSmrg  <literal>0</literal> before including any library headers.
12071debfc3dSmrg  (Be aware that some GNU/Linux distributions configure GCC 5 differently so
12081debfc3dSmrg  that the default value of the macro is <literal>0</literal> and users must
12091debfc3dSmrg  define it to <literal>1</literal> to enable the new ABI.)
12101debfc3dSmrg</para>
12111debfc3dSmrg
12121debfc3dSmrg<para> Although the changes were made for C++11 conformance, the choice of ABI
12131debfc3dSmrg  to use is independent of the <option>-std</option> option used to compile
12141debfc3dSmrg  your code, i.e. for a given GCC build the default value of the
12151debfc3dSmrg  <symbol>_GLIBCXX_USE_CXX11_ABI</symbol> macro is the same for all dialects.
12161debfc3dSmrg  This ensures that the <option>-std</option> does not change the ABI, so
12171debfc3dSmrg  that it is straightforward to link C++03 and C++11 code together.
12181debfc3dSmrg</para>
12191debfc3dSmrg
12201debfc3dSmrg<para> Because <classname>std::string</classname> is used extensively
12211debfc3dSmrg  throughout the library a number of other types are also defined twice,
12221debfc3dSmrg  including the stringstream classes and several facets used by
12231debfc3dSmrg  <classname>std::locale</classname>. The standard facets which are always
12241debfc3dSmrg  installed in a locale may be present twice, with both ABIs, to ensure that
12251debfc3dSmrg  code like
12261debfc3dSmrg  <code>std::use_facet&lt;std::time_get&lt;char&gt;&gt;(locale);</code>
12271debfc3dSmrg  will work correctly for both <classname>std::time_get</classname> and
12281debfc3dSmrg  <classname>std::__cxx11::time_get</classname> (even if a user-defined
12291debfc3dSmrg  facet that derives from one or other version of
12301debfc3dSmrg  <classname>time_get</classname> is installed in the locale).
12311debfc3dSmrg</para>
12321debfc3dSmrg
12331debfc3dSmrg<para> Although the standard exception types defined in
12341debfc3dSmrg  <filename class="headerfile">&lt;stdexcept&gt;</filename> use strings, most
12351debfc3dSmrg  are not defined twice, so that a <classname>std::out_of_range</classname>
12361debfc3dSmrg  exception thrown in one file can always be caught by a suitable handler in
12371debfc3dSmrg  another file, even if the two files are compiled with different ABIs.
12381debfc3dSmrg</para>
12391debfc3dSmrg
12401debfc3dSmrg<para> One exception type does change when using the new ABI, namely
12411debfc3dSmrg  <classname>std::ios_base::failure</classname>.
12421debfc3dSmrg  This is necessary because the 2011 standard changed its base class from
12431debfc3dSmrg  <classname>std::exception</classname> to
12441debfc3dSmrg  <classname>std::system_error</classname>, which causes its layout to change.
12451debfc3dSmrg  Exceptions due to iostream errors are thrown by a function inside
12461debfc3dSmrg  <filename class="libraryfile">libstdc++.so</filename>, so whether the thrown
12471debfc3dSmrg  exception uses the old <classname>std::ios_base::failure</classname> type
12481debfc3dSmrg  or the new one depends on the ABI that was active when
12491debfc3dSmrg  <filename class="libraryfile">libstdc++.so</filename> was built,
12501debfc3dSmrg  <emphasis>not</emphasis> the ABI active in the user code that is using
12511debfc3dSmrg  iostreams.
12521debfc3dSmrg  This means that for a given build of GCC the type thrown is fixed.
12531debfc3dSmrg  In current releases the library throws a special type that can be caught
12541debfc3dSmrg  by handlers for either the old or new type,
12551debfc3dSmrg  but for GCC 7.1, 7.2 and 7.3 the library throws the new
12561debfc3dSmrg  <classname>std::ios_base::failure</classname> type,
12571debfc3dSmrg  and for GCC 5.x and 6.x the library throws the old type.
12581debfc3dSmrg  Catch handlers of type <classname>std::ios_base::failure</classname>
12591debfc3dSmrg  will only catch the exceptions if using a newer release,
12601debfc3dSmrg  or if the handler is compiled with the same ABI as the type thrown by
12611debfc3dSmrg  the library.
12621debfc3dSmrg  Handlers for <classname>std::exception</classname> will always catch
12631debfc3dSmrg  iostreams exceptions, because the old and new type both inherit from
12641debfc3dSmrg  <classname>std::exception</classname>.
12651debfc3dSmrg</para>
12661debfc3dSmrg
12671debfc3dSmrg<section xml:id="manual.intro.using.abi.trouble" xreflabel="Dual ABI Troubleshooting"><info><title>Troubleshooting</title></info>
12681debfc3dSmrg
12691debfc3dSmrg<para> If you get linker errors about undefined references to symbols
12701debfc3dSmrg  that involve types in the <code>std::__cxx11</code> namespace or the tag
12711debfc3dSmrg  <code>[abi:cxx11]</code> then it probably indicates that you are trying to
12721debfc3dSmrg  link together object files that were compiled with different values for the
12731debfc3dSmrg  <symbol>_GLIBCXX_USE_CXX11_ABI</symbol> macro. This commonly happens when
12741debfc3dSmrg  linking to a third-party library that was compiled with an older version
12751debfc3dSmrg  of GCC. If the third-party library cannot be rebuilt with the new ABI then
12761debfc3dSmrg  you will need to recompile your code with the old ABI.
12771debfc3dSmrg</para>
12781debfc3dSmrg
12791debfc3dSmrg<para> Not all uses of the new ABI will cause changes in symbol names, for
12801debfc3dSmrg  example a class with a <classname>std::string</classname> member variable
12811debfc3dSmrg  will have the same mangled name whether compiled with the old or new ABI.
12821debfc3dSmrg  In order to detect such problems the new types and functions are
12831debfc3dSmrg  annotated with the <property>abi_tag</property> attribute, allowing the
12841debfc3dSmrg  compiler to warn about potential ABI incompatibilities in code using them.
12851debfc3dSmrg  Those warnings can be enabled with the <option>-Wabi-tag</option> option.
12861debfc3dSmrg</para>
12871debfc3dSmrg
12881debfc3dSmrg</section>
12891debfc3dSmrg</section>
12901debfc3dSmrg
12911debfc3dSmrg  <section xml:id="manual.intro.using.namespaces" xreflabel="Namespaces"><info><title>Namespaces</title></info>
12921debfc3dSmrg    <?dbhtml filename="using_namespaces.html"?>
12931debfc3dSmrg
12941debfc3dSmrg
12951debfc3dSmrg    <section xml:id="manual.intro.using.namespaces.all" xreflabel="Available Namespaces"><info><title>Available Namespaces</title></info>
12961debfc3dSmrg
12971debfc3dSmrg
12981debfc3dSmrg
12991debfc3dSmrg
13001debfc3dSmrg<para> There are three main namespaces.
13011debfc3dSmrg</para>
13021debfc3dSmrg
13031debfc3dSmrg<itemizedlist>
13041debfc3dSmrg  <listitem><para>std</para>
13051debfc3dSmrg<para>The ISO C++ standards specify that "all library entities are defined
13061debfc3dSmrgwithin namespace std." This includes namespaces nested
13071debfc3dSmrgwithin namespace <code>std</code>, such as namespace
13081debfc3dSmrg<code>std::chrono</code>.
13091debfc3dSmrg</para>
13101debfc3dSmrg</listitem>
13111debfc3dSmrg<listitem><para>abi</para>
13121debfc3dSmrg<para>Specified by the C++ ABI. This ABI specifies a number of type and
13131debfc3dSmrgfunction APIs supplemental to those required by the ISO C++ Standard,
13141debfc3dSmrgbut necessary for interoperability.
13151debfc3dSmrg</para>
13161debfc3dSmrg</listitem>
13171debfc3dSmrg
13181debfc3dSmrg<listitem><para>__gnu_</para>
13191debfc3dSmrg<para>Indicating one of several GNU extensions. Choices
13201debfc3dSmrginclude <code>__gnu_cxx</code>, <code>__gnu_debug</code>, <code>__gnu_parallel</code>,
13211debfc3dSmrgand <code>__gnu_pbds</code>.
13221debfc3dSmrg</para></listitem>
13231debfc3dSmrg</itemizedlist>
13241debfc3dSmrg
13251debfc3dSmrg<para> The library uses a number of inline namespaces as implementation
13261debfc3dSmrgdetails that are not intended for users to refer to directly, these include
13271debfc3dSmrg<code>std::__detail</code>, <code>std::__cxx11</code> and <code>std::_V2</code>.
13281debfc3dSmrg</para>
13291debfc3dSmrg
13301debfc3dSmrg<para> A complete list of implementation namespaces (including namespace contents) is available in the generated source <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/namespaces.html">documentation</link>.
13311debfc3dSmrg</para>
13321debfc3dSmrg
13331debfc3dSmrg
13341debfc3dSmrg    </section>
13351debfc3dSmrg
13361debfc3dSmrg    <section xml:id="manual.intro.using.namespaces.std" xreflabel="namespace std"><info><title>namespace std</title></info>
13371debfc3dSmrg
13381debfc3dSmrg
13391debfc3dSmrg
13401debfc3dSmrg<para>
13411debfc3dSmrg      One standard requirement is that the library components are defined
13421debfc3dSmrg      in <code>namespace std::</code>. Thus, in order to use these types or
13431debfc3dSmrg      functions, one must do one of two things:
13441debfc3dSmrg</para>
13451debfc3dSmrg
13461debfc3dSmrg<itemizedlist>
13471debfc3dSmrg  <listitem><para>put a kind of <emphasis>using-declaration</emphasis> in your source
13481debfc3dSmrg(either <code>using namespace std;</code> or i.e. <code>using
13491debfc3dSmrgstd::string;</code>) This approach works well for individual source files, but
13501debfc3dSmrgshould not be used in a global context, like header files.
13511debfc3dSmrg	  </para></listitem> <listitem><para>use a <emphasis>fully
13521debfc3dSmrgqualified name</emphasis> for each library symbol
13531debfc3dSmrg(i.e. <code>std::string</code>, <code>std::cout</code>) Always can be
13541debfc3dSmrgused, and usually enhanced, by strategic use of typedefs. (In the
13551debfc3dSmrgcases where the qualified verbiage becomes unwieldy.)
13561debfc3dSmrg	  </para>
13571debfc3dSmrg	</listitem>
13581debfc3dSmrg</itemizedlist>
13591debfc3dSmrg
13601debfc3dSmrg    </section>
13611debfc3dSmrg
13621debfc3dSmrg    <section xml:id="manual.intro.using.namespaces.comp" xreflabel="Using Namespace Composition"><info><title>Using Namespace Composition</title></info>
13631debfc3dSmrg
13641debfc3dSmrg
13651debfc3dSmrg<para>
13661debfc3dSmrgBest practice in programming suggests sequestering new data or
13671debfc3dSmrgfunctionality in a sanely-named, unique namespace whenever
13681debfc3dSmrgpossible. This is considered an advantage over dumping everything in
13691debfc3dSmrgthe global namespace, as then name look-up can be explicitly enabled or
13701debfc3dSmrgdisabled as above, symbols are consistently mangled without repetitive
13711debfc3dSmrgnaming prefixes or macros, etc.
13721debfc3dSmrg</para>
13731debfc3dSmrg
13741debfc3dSmrg<para>For instance, consider a project that defines most of its classes in <code>namespace gtk</code>. It is possible to
13751debfc3dSmrg	adapt <code>namespace gtk</code> to <code>namespace std</code> by using a C++-feature called
13761debfc3dSmrg	<emphasis>namespace composition</emphasis>. This is what happens if
13771debfc3dSmrg	a <emphasis>using</emphasis>-declaration is put into a
13781debfc3dSmrg	namespace-definition: the imported symbol(s) gets imported into the
13791debfc3dSmrg	currently active namespace(s). For example:
13801debfc3dSmrg</para>
13811debfc3dSmrg<programlisting>
13821debfc3dSmrgnamespace gtk
13831debfc3dSmrg{
13841debfc3dSmrg  using std::string;
13851debfc3dSmrg  using std::tr1::array;
13861debfc3dSmrg
13871debfc3dSmrg  class Window { ... };
13881debfc3dSmrg}
13891debfc3dSmrg</programlisting>
13901debfc3dSmrg<para>
13911debfc3dSmrg	In this example, <code>std::string</code> gets imported into
13921debfc3dSmrg	<code>namespace gtk</code>.  The result is that use of
13931debfc3dSmrg	<code>std::string</code> inside namespace gtk can just use <code>string</code>, without the explicit qualification.
13941debfc3dSmrg	As an added bonus,
13951debfc3dSmrg	<code>std::string</code> does not get imported into
13961debfc3dSmrg	the global namespace.  Additionally, a more elaborate arrangement can be made for backwards compatibility and portability, whereby the
13971debfc3dSmrg	<code>using</code>-declarations can wrapped in macros that
13981debfc3dSmrg	are set based on autoconf-tests to either "" or i.e. <code>using
13991debfc3dSmrg	  std::string;</code> (depending on whether the system has
14001debfc3dSmrg	libstdc++ in <code>std::</code> or not).  (ideas from
14011debfc3dSmrg	Llewelly and Karl Nelson)
14021debfc3dSmrg</para>
14031debfc3dSmrg
14041debfc3dSmrg
14051debfc3dSmrg    </section>
14061debfc3dSmrg  </section>
14071debfc3dSmrg
14081debfc3dSmrg  <section xml:id="manual.intro.using.linkage" xreflabel="Linkage"><info><title>Linking</title></info>
14091debfc3dSmrg    <?dbhtml filename="using_dynamic_or_shared.html"?>
14101debfc3dSmrg
14111debfc3dSmrg
14121debfc3dSmrg    <section xml:id="manual.intro.using.linkage.freestanding" xreflabel="Freestanding"><info><title>Almost Nothing</title></info>
14131debfc3dSmrg
14141debfc3dSmrg      <para>
14151debfc3dSmrg	Or as close as it gets: freestanding. This is a minimal
14161debfc3dSmrg	configuration, with only partial support for the standard
14171debfc3dSmrg	library. Assume only the following header files can be used:
14181debfc3dSmrg      </para>
14191debfc3dSmrg
14201debfc3dSmrg      <itemizedlist>
14211debfc3dSmrg	<listitem>
14221debfc3dSmrg	  <para>
14231debfc3dSmrg	    <filename class="headerfile">cstdarg</filename>
14241debfc3dSmrg	  </para>
14251debfc3dSmrg	</listitem>
14261debfc3dSmrg
14271debfc3dSmrg	<listitem>
14281debfc3dSmrg	  <para>
14291debfc3dSmrg	  <filename class="headerfile">cstddef</filename>
14301debfc3dSmrg	  </para>
14311debfc3dSmrg	</listitem>
14321debfc3dSmrg
14331debfc3dSmrg	<listitem>
14341debfc3dSmrg	  <para>
14351debfc3dSmrg	  <filename class="headerfile">cstdlib</filename>
14361debfc3dSmrg	  </para>
14371debfc3dSmrg	</listitem>
14381debfc3dSmrg
14391debfc3dSmrg	<listitem>
14401debfc3dSmrg	  <para>
14411debfc3dSmrg	  <filename class="headerfile">exception</filename>
14421debfc3dSmrg	  </para>
14431debfc3dSmrg	</listitem>
14441debfc3dSmrg
14451debfc3dSmrg	<listitem>
14461debfc3dSmrg	  <para>
14471debfc3dSmrg	  <filename class="headerfile">limits</filename>
14481debfc3dSmrg	  </para>
14491debfc3dSmrg	</listitem>
14501debfc3dSmrg
14511debfc3dSmrg	<listitem>
14521debfc3dSmrg	  <para>
14531debfc3dSmrg	  <filename class="headerfile">new</filename>
14541debfc3dSmrg	  </para>
14551debfc3dSmrg	</listitem>
14561debfc3dSmrg
14571debfc3dSmrg	<listitem>
14581debfc3dSmrg	  <para>
14591debfc3dSmrg	  <filename class="headerfile">exception</filename>
14601debfc3dSmrg	  </para>
14611debfc3dSmrg	</listitem>
14621debfc3dSmrg
14631debfc3dSmrg	<listitem>
14641debfc3dSmrg	  <para>
14651debfc3dSmrg	  <filename class="headerfile">typeinfo</filename>
14661debfc3dSmrg	  </para>
14671debfc3dSmrg	</listitem>
14681debfc3dSmrg      </itemizedlist>
14691debfc3dSmrg
14701debfc3dSmrg      <para>
14711debfc3dSmrg	In addition, throw in
14721debfc3dSmrg      </para>
14731debfc3dSmrg
14741debfc3dSmrg      <itemizedlist>
14751debfc3dSmrg	<listitem>
14761debfc3dSmrg	  <para>
14771debfc3dSmrg	  <filename class="headerfile">cxxabi.h</filename>.
14781debfc3dSmrg	  </para>
14791debfc3dSmrg	</listitem>
14801debfc3dSmrg      </itemizedlist>
14811debfc3dSmrg
14821debfc3dSmrg      <para>
14831debfc3dSmrg	In the
14841debfc3dSmrg	C++11 <link linkend="manual.intro.using.flags">dialect</link> add
14851debfc3dSmrg      </para>
14861debfc3dSmrg
14871debfc3dSmrg      <itemizedlist>
14881debfc3dSmrg	<listitem>
14891debfc3dSmrg	  <para>
14901debfc3dSmrg	  <filename class="headerfile">initializer_list</filename>
14911debfc3dSmrg	  </para>
14921debfc3dSmrg	</listitem>
14931debfc3dSmrg	<listitem>
14941debfc3dSmrg	  <para>
14951debfc3dSmrg	  <filename class="headerfile">type_traits</filename>
14961debfc3dSmrg	  </para>
14971debfc3dSmrg	</listitem>
14981debfc3dSmrg      </itemizedlist>
14991debfc3dSmrg
15001debfc3dSmrg      <para> There exists a library that offers runtime support for
15011debfc3dSmrg	just these headers, and it is called
15021debfc3dSmrg	<filename class="libraryfile">libsupc++.a</filename>. To use it, compile with <command>gcc</command> instead of <command>g++</command>, like so:
15031debfc3dSmrg      </para>
15041debfc3dSmrg
15051debfc3dSmrg      <para>
15061debfc3dSmrg	<command>gcc foo.cc -lsupc++</command>
15071debfc3dSmrg      </para>
15081debfc3dSmrg
15091debfc3dSmrg      <para>
15101debfc3dSmrg	No attempt is made to verify that only the minimal subset
15111debfc3dSmrg	identified above is actually used at compile time. Violations
15121debfc3dSmrg	are diagnosed as undefined symbols at link time.
15131debfc3dSmrg      </para>
15141debfc3dSmrg    </section>
15151debfc3dSmrg
15161debfc3dSmrg    <section xml:id="manual.intro.using.linkage.dynamic" xreflabel="Dynamic and Shared"><info><title>Finding Dynamic or Shared Libraries</title></info>
15171debfc3dSmrg
15181debfc3dSmrg
15191debfc3dSmrg    <para>
15201debfc3dSmrg      If the only library built is the static library
15211debfc3dSmrg      (<filename class="libraryfile">libstdc++.a</filename>), or if
15221debfc3dSmrg      specifying static linking, this section is can be skipped.  But
15231debfc3dSmrg      if building or using a shared library
15241debfc3dSmrg      (<filename class="libraryfile">libstdc++.so</filename>), then
15251debfc3dSmrg      additional location information will need to be provided.
15261debfc3dSmrg    </para>
15271debfc3dSmrg    <para>
15281debfc3dSmrg      But how?
15291debfc3dSmrg    </para>
15301debfc3dSmrg    <para>
15311debfc3dSmrgA quick read of the relevant part of the GCC
15321debfc3dSmrg      manual, <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/onlinedocs/gcc/Invoking-G_002b_002b.html#Invoking-G_002b_002b">Compiling
15331debfc3dSmrg      C++ Programs</link>, specifies linking against a C++
15341debfc3dSmrg      library. More details from the
15351debfc3dSmrg      GCC <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/faq.html#rpath">FAQ</link>,
15361debfc3dSmrg      which states <emphasis>GCC does not, by default, specify a
15371debfc3dSmrg      location so that the dynamic linker can find dynamic libraries at
15381debfc3dSmrg      runtime.</emphasis>
15391debfc3dSmrg    </para>
15401debfc3dSmrg    <para>
15411debfc3dSmrg      Users will have to provide this information.
15421debfc3dSmrg    </para>
15431debfc3dSmrg    <para>
15441debfc3dSmrg      Methods vary for different platforms and different styles, and
15451debfc3dSmrg      are printed to the screen during installation. To summarize:
15461debfc3dSmrg    </para>
15471debfc3dSmrg    <itemizedlist>
15481debfc3dSmrg      <listitem>
15491debfc3dSmrg	<para>
15501debfc3dSmrg	  At runtime set <literal>LD_LIBRARY_PATH</literal> in your
15511debfc3dSmrg	  environment correctly, so that the shared library for
15521debfc3dSmrg	  libstdc++ can be found and loaded.  Be certain that you
15531debfc3dSmrg	  understand all of the other implications and behavior
15541debfc3dSmrg	  of <literal>LD_LIBRARY_PATH</literal> first.
15551debfc3dSmrg	</para>
15561debfc3dSmrg
15571debfc3dSmrg      </listitem>
15581debfc3dSmrg      <listitem>
15591debfc3dSmrg	<para>
15601debfc3dSmrg	  Compile the path to find the library at runtime into the
15611debfc3dSmrg	  program.  This can be done by passing certain options to
15621debfc3dSmrg	  <command>g++</command>, which will in turn pass them on to
15631debfc3dSmrg	  the linker.  The exact format of the options is dependent on
15641debfc3dSmrg	  which linker you use:
15651debfc3dSmrg	</para>
15661debfc3dSmrg	<itemizedlist>
15671debfc3dSmrg	  <listitem>
15681debfc3dSmrg	    <para>
15691debfc3dSmrg	      GNU ld (default on GNU/Linux):
15701debfc3dSmrg              <literal>-Wl,-rpath,</literal><filename class="directory">destdir/lib</filename>
15711debfc3dSmrg	    </para>
15721debfc3dSmrg	  </listitem>
15731debfc3dSmrg	  <listitem>
15741debfc3dSmrg	  <para>
15751debfc3dSmrg	    Solaris ld:
15761debfc3dSmrg            <literal>-Wl,-R</literal><filename class="directory">destdir/lib</filename>
15771debfc3dSmrg	  </para>
15781debfc3dSmrg	  </listitem>
15791debfc3dSmrg	</itemizedlist>
15801debfc3dSmrg      </listitem>
15811debfc3dSmrg      <listitem>
15821debfc3dSmrg	<para>
15831debfc3dSmrg	  Some linkers allow you to specify the path to the library by
15841debfc3dSmrg	  setting <literal>LD_RUN_PATH</literal> in your environment
15851debfc3dSmrg	  when linking.
15861debfc3dSmrg	</para>
15871debfc3dSmrg      </listitem>
15881debfc3dSmrg      <listitem>
15891debfc3dSmrg	<para>
15901debfc3dSmrg	  On some platforms the system administrator can configure the
15911debfc3dSmrg	  dynamic linker to always look for libraries in
15921debfc3dSmrg	  <filename class="directory">destdir/lib</filename>, for example
15931debfc3dSmrg	  by using the <command>ldconfig</command> utility on GNU/Linux
15941debfc3dSmrg	  or the <command>crle</command> utility on Solaris. This is a
15951debfc3dSmrg	  system-wide change which can make the system unusable so if you
15961debfc3dSmrg	  are unsure then use one of the other methods described above.
15971debfc3dSmrg	</para>
15981debfc3dSmrg      </listitem>
15991debfc3dSmrg    </itemizedlist>
16001debfc3dSmrg    <para>
16011debfc3dSmrg      Use the <command>ldd</command> utility on the linked executable
16021debfc3dSmrg      to show
16031debfc3dSmrg      which <filename class="libraryfile">libstdc++.so</filename>
16041debfc3dSmrg      library the system will get at runtime.
16051debfc3dSmrg    </para>
16061debfc3dSmrg    <para>
16071debfc3dSmrg      A <filename class="libraryfile">libstdc++.la</filename> file is
16081debfc3dSmrg      also installed, for use with Libtool.  If you use Libtool to
16091debfc3dSmrg      create your executables, these details are taken care of for
16101debfc3dSmrg      you.
16111debfc3dSmrg    </para>
16121debfc3dSmrg    </section>
16131debfc3dSmrg
16141debfc3dSmrg    <section xml:id="manual.intro.using.linkage.experimental" xreflabel="Library Extensions"><info><title>Experimental Library Extensions</title></info>
16151debfc3dSmrg
16161debfc3dSmrg    <para>
16171debfc3dSmrg      GCC 5.3 includes an implementation of the Filesystem library defined
16181debfc3dSmrg      by the technical specification ISO/IEC TS 18822:2015. Because this is
16191debfc3dSmrg      an experimental library extension, not part of the C++ standard, it
16201debfc3dSmrg      is implemented in a separate library,
16211debfc3dSmrg      <filename class="libraryfile">libstdc++fs.a</filename>, and there is
16221debfc3dSmrg      no shared library for it. To use the library you should include
16231debfc3dSmrg      <filename class="headerfile">&lt;experimental/filesystem&gt;</filename>
16241debfc3dSmrg      and link with <option>-lstdc++fs</option>. The library implementation
16251debfc3dSmrg      is incomplete on non-POSIX platforms, specifically Windows support is
16261debfc3dSmrg      rudimentary.
16271debfc3dSmrg    </para>
16281debfc3dSmrg
16291debfc3dSmrg    <para>
16301debfc3dSmrg      Due to the experimental nature of the Filesystem library the usual
16311debfc3dSmrg      guarantees about ABI stability and backwards compatibility do not apply
16321debfc3dSmrg      to it. There is no guarantee that the components in any
16331debfc3dSmrg      <filename class="headerfile">&lt;experimental/xxx&gt;</filename>
16341debfc3dSmrg      header will remain compatible between different GCC releases.
16351debfc3dSmrg    </para>
16361debfc3dSmrg    </section>
16371debfc3dSmrg  </section>
16381debfc3dSmrg
16391debfc3dSmrg  <section xml:id="manual.intro.using.concurrency" xreflabel="Concurrency"><info><title>Concurrency</title></info>
16401debfc3dSmrg    <?dbhtml filename="using_concurrency.html"?>
16411debfc3dSmrg
16421debfc3dSmrg
16431debfc3dSmrg   <para>This section discusses issues surrounding the proper compilation
16441debfc3dSmrg      of multithreaded applications which use the Standard C++
16451debfc3dSmrg      library.  This information is GCC-specific since the C++
16461debfc3dSmrg      standard does not address matters of multithreaded applications.
16471debfc3dSmrg   </para>
16481debfc3dSmrg
16491debfc3dSmrg    <section xml:id="manual.intro.using.concurrency.prereq" xreflabel="Thread Prereq"><info><title>Prerequisites</title></info>
16501debfc3dSmrg
16511debfc3dSmrg
16521debfc3dSmrg   <para>All normal disclaimers aside, multithreaded C++ application are
16531debfc3dSmrg      only supported when libstdc++ and all user code was built with
16541debfc3dSmrg      compilers which report (via <code> gcc/g++ -v </code>) the same thread
16551debfc3dSmrg      model and that model is not <emphasis>single</emphasis>.  As long as your
16561debfc3dSmrg      final application is actually single-threaded, then it should be
16571debfc3dSmrg      safe to mix user code built with a thread model of
16581debfc3dSmrg      <emphasis>single</emphasis> with a libstdc++ and other C++ libraries built
16591debfc3dSmrg      with another thread model useful on the platform.  Other mixes
16601debfc3dSmrg      may or may not work but are not considered supported.  (Thus, if
16611debfc3dSmrg      you distribute a shared C++ library in binary form only, it may
16621debfc3dSmrg      be best to compile it with a GCC configured with
16631debfc3dSmrg      --enable-threads for maximal interchangeability and usefulness
16641debfc3dSmrg      with a user population that may have built GCC with either
16651debfc3dSmrg      --enable-threads or --disable-threads.)
16661debfc3dSmrg   </para>
16671debfc3dSmrg   <para>When you link a multithreaded application, you will probably
16681debfc3dSmrg      need to add a library or flag to g++.  This is a very
16691debfc3dSmrg      non-standardized area of GCC across ports.  Some ports support a
16701debfc3dSmrg      special flag (the spelling isn't even standardized yet) to add
16711debfc3dSmrg      all required macros to a compilation (if any such flags are
16721debfc3dSmrg      required then you must provide the flag for all compilations not
16731debfc3dSmrg      just linking) and link-library additions and/or replacements at
16741debfc3dSmrg      link time.  The documentation is weak.  On several targets (including
16751debfc3dSmrg      GNU/Linux, Solaris and various BSDs) -pthread is honored.
16761debfc3dSmrg      Some other ports use other switches.
16771debfc3dSmrg      This is not well documented anywhere other than
16781debfc3dSmrg      in "gcc -dumpspecs" (look at the 'lib' and 'cpp' entries).
16791debfc3dSmrg   </para>
16801debfc3dSmrg
16811debfc3dSmrg   <para>
16821debfc3dSmrg     Some uses of <classname>std::atomic</classname> also require linking
16831debfc3dSmrg     to <filename class="libraryfile">libatomic</filename>.
16841debfc3dSmrg   </para>
16851debfc3dSmrg
16861debfc3dSmrg    </section>
16871debfc3dSmrg
16881debfc3dSmrg    <section xml:id="manual.intro.using.concurrency.thread_safety" xreflabel="Thread Safety"><info><title>Thread Safety</title></info>
16891debfc3dSmrg
16901debfc3dSmrg
16911debfc3dSmrg<para>
16921debfc3dSmrgIn the terms of the 2011 C++ standard a thread-safe program is one which
16931debfc3dSmrgdoes not perform any conflicting non-atomic operations on memory locations
16941debfc3dSmrgand so does not contain any data races.
16951debfc3dSmrgThe standard places requirements on the library to ensure that no data
16961debfc3dSmrgraces are caused by the library itself or by programs which use the
16971debfc3dSmrglibrary correctly (as described below).
16981debfc3dSmrgThe C++11 memory model and library requirements are a more formal version
1699a2dc1f3fSmrgof the <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/thread_safety.html">SGI STL</link> definition of thread safety, which the library used
17001debfc3dSmrgprior to the 2011 standard.
17011debfc3dSmrg</para>
17021debfc3dSmrg
17031debfc3dSmrg
17041debfc3dSmrg      <para>The library strives to be thread-safe when all of the following
17051debfc3dSmrg	 conditions are met:
17061debfc3dSmrg      </para>
17071debfc3dSmrg      <itemizedlist>
17081debfc3dSmrg       <listitem>
17091debfc3dSmrg       <para>The system's libc is itself thread-safe,
17101debfc3dSmrg       </para>
17111debfc3dSmrg       </listitem>
17121debfc3dSmrg       <listitem>
17131debfc3dSmrg	 <para>
17141debfc3dSmrg	   The compiler in use reports a thread model other than
17151debfc3dSmrg	   'single'. This can be tested via output from <code>gcc
17161debfc3dSmrg	   -v</code>. Multi-thread capable versions of gcc output
17171debfc3dSmrg	   something like this:
17181debfc3dSmrg	 </para>
17191debfc3dSmrg<programlisting>
17201debfc3dSmrg%gcc -v
17211debfc3dSmrgUsing built-in specs.
17221debfc3dSmrg...
17231debfc3dSmrgThread model: posix
17241debfc3dSmrggcc version 4.1.2 20070925 (Red Hat 4.1.2-33)
17251debfc3dSmrg</programlisting>
17261debfc3dSmrg
17271debfc3dSmrg<para>Look for "Thread model" lines that aren't equal to "single."</para>
17281debfc3dSmrg       </listitem>
17291debfc3dSmrg       <listitem>
17301debfc3dSmrg       <para>
17311debfc3dSmrg	 Requisite command-line flags are used for atomic operations
17321debfc3dSmrg	 and threading. Examples of this include <code>-pthread</code>
17331debfc3dSmrg	 and <code>-march=native</code>, although specifics vary
17341debfc3dSmrg	 depending on the host environment. See
17351debfc3dSmrg	 <link linkend="manual.intro.using.flags">Command Options</link> and
17361debfc3dSmrg	 <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html">Machine
17371debfc3dSmrg	 Dependent Options</link>.
17381debfc3dSmrg       </para>
17391debfc3dSmrg       </listitem>
17401debfc3dSmrg       <listitem>
17411debfc3dSmrg	 <para>
17421debfc3dSmrg	   An implementation of the
17431debfc3dSmrg	   <filename class="headerfile">atomicity.h</filename> functions
17441debfc3dSmrg	   exists for the architecture in question. See the
17451debfc3dSmrg	   <link linkend="internals.thread_safety">internals
17461debfc3dSmrg	   documentation</link> for more details.
17471debfc3dSmrg       </para>
17481debfc3dSmrg       </listitem>
17491debfc3dSmrg
17501debfc3dSmrg      </itemizedlist>
17511debfc3dSmrg
17521debfc3dSmrg      <para>The user code must guard against concurrent function calls which
17531debfc3dSmrg         access any particular library object's state when one or more of
17541debfc3dSmrg         those accesses modifies the state. An object will be modified by
17551debfc3dSmrg         invoking a non-const member function on it or passing it as a
17561debfc3dSmrg         non-const argument to a library function. An object will not be
17571debfc3dSmrg         modified by invoking a const member function on it or passing it to
17581debfc3dSmrg         a function as a pointer- or reference-to-const.
17591debfc3dSmrg         Typically, the application
17601debfc3dSmrg         programmer may infer what object locks must be held based on the
17611debfc3dSmrg         objects referenced in a function call and whether the objects are
17621debfc3dSmrg         accessed as const or non-const.  Without getting
17631debfc3dSmrg	 into great detail, here is an example which requires user-level
17641debfc3dSmrg	 locks:
17651debfc3dSmrg      </para>
17661debfc3dSmrg      <programlisting>
17671debfc3dSmrg     library_class_a shared_object_a;
17681debfc3dSmrg
17691debfc3dSmrg     void thread_main () {
17701debfc3dSmrg       library_class_b *object_b = new library_class_b;
17711debfc3dSmrg       shared_object_a.add_b (object_b);   // must hold lock for shared_object_a
17721debfc3dSmrg       shared_object_a.mutate ();          // must hold lock for shared_object_a
17731debfc3dSmrg     }
17741debfc3dSmrg
17751debfc3dSmrg     // Multiple copies of thread_main() are started in independent threads.</programlisting>
17761debfc3dSmrg      <para>Under the assumption that object_a and object_b are never exposed to
17771debfc3dSmrg	 another thread, here is an example that does not require any
17781debfc3dSmrg	 user-level locks:
17791debfc3dSmrg      </para>
17801debfc3dSmrg      <programlisting>
17811debfc3dSmrg     void thread_main () {
17821debfc3dSmrg       library_class_a object_a;
17831debfc3dSmrg       library_class_b *object_b = new library_class_b;
17841debfc3dSmrg       object_a.add_b (object_b);
17851debfc3dSmrg       object_a.mutate ();
17861debfc3dSmrg     } </programlisting>
17871debfc3dSmrg
17881debfc3dSmrg      <para>All library types are safe to use in a multithreaded program
17891debfc3dSmrg         if objects are not shared between threads or as
17901debfc3dSmrg	 long each thread carefully locks out access by any other
17911debfc3dSmrg	 thread while it modifies any object visible to another thread.
17921debfc3dSmrg	 Unless otherwise documented, the only exceptions to these rules
17931debfc3dSmrg         are atomic operations on the types in
17941debfc3dSmrg         <filename class="headerfile">&lt;atomic&gt;</filename>
17951debfc3dSmrg         and lock/unlock operations on the standard mutex types in
17961debfc3dSmrg         <filename class="headerfile">&lt;mutex&gt;</filename>. These
17971debfc3dSmrg         atomic operations allow concurrent accesses to the same object
17981debfc3dSmrg         without introducing data races.
17991debfc3dSmrg      </para>
18001debfc3dSmrg
18011debfc3dSmrg      <para>The following member functions of standard containers can be
18021debfc3dSmrg         considered to be const for the purposes of avoiding data races:
18031debfc3dSmrg         <code>begin</code>, <code>end</code>, <code>rbegin</code>, <code>rend</code>,
18041debfc3dSmrg         <code>front</code>, <code>back</code>, <code>data</code>,
18051debfc3dSmrg         <code>find</code>, <code>lower_bound</code>, <code>upper_bound</code>,
18061debfc3dSmrg         <code>equal_range</code>, <code>at</code>
18071debfc3dSmrg         and, except in associative or unordered associative containers,
18081debfc3dSmrg         <code>operator[]</code>. In other words, although they are non-const
18091debfc3dSmrg         so that they can return mutable iterators, those member functions
18101debfc3dSmrg         will not modify the container.
18111debfc3dSmrg         Accessing an iterator might cause a non-modifying access to
18121debfc3dSmrg         the container the iterator refers to (for example incrementing a
18131debfc3dSmrg         list iterator must access the pointers between nodes, which are part
18141debfc3dSmrg         of the container and so conflict with other accesses to the container).
18151debfc3dSmrg      </para>
18161debfc3dSmrg
18171debfc3dSmrg      <para>Programs which follow the rules above will not encounter data
18181debfc3dSmrg         races in library code, even when using library types which share
18191debfc3dSmrg         state between distinct objects.  In the example below the
18201debfc3dSmrg         <code>shared_ptr</code> objects share a reference count, but
18211debfc3dSmrg         because the code does not perform any non-const operations on the
18221debfc3dSmrg         globally-visible object, the library ensures that the reference
18231debfc3dSmrg         count updates are atomic and do not introduce data races:
18241debfc3dSmrg      </para>
18251debfc3dSmrg      <programlisting>
18261debfc3dSmrg    std::shared_ptr&lt;int&gt; global_sp;
18271debfc3dSmrg
18281debfc3dSmrg    void thread_main() {
18291debfc3dSmrg      auto local_sp = global_sp;  // OK, copy constructor's parameter is reference-to-const
18301debfc3dSmrg
18311debfc3dSmrg      int i = *global_sp;         // OK, operator* is const
18321debfc3dSmrg      int j = *local_sp;          // OK, does not operate on global_sp
18331debfc3dSmrg
18341debfc3dSmrg      // *global_sp = 2;          // NOT OK, modifies int visible to other threads
18351debfc3dSmrg      // *local_sp = 2;           // NOT OK, modifies int visible to other threads
18361debfc3dSmrg
18371debfc3dSmrg      // global_sp.reset();       // NOT OK, reset is non-const
18381debfc3dSmrg      local_sp.reset();           // OK, does not operate on global_sp
18391debfc3dSmrg    }
18401debfc3dSmrg
18411debfc3dSmrg    int main() {
18421debfc3dSmrg      global_sp.reset(new int(1));
18431debfc3dSmrg      std::thread t1(thread_main);
18441debfc3dSmrg      std::thread t2(thread_main);
18451debfc3dSmrg      t1.join();
18461debfc3dSmrg      t2.join();
18471debfc3dSmrg    }
18481debfc3dSmrg      </programlisting>
18491debfc3dSmrg
18501debfc3dSmrg      <para>For further details of the C++11 memory model see Hans-J. Boehm's
18511debfc3dSmrg      <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://www.hboehm.info/c++mm/">Threads
1852*8feb0f0bSmrg      and memory model for C++</link> pages, particularly the <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://www.hboehm.info/c++mm/threadsintro.html">introduction</link>
18531debfc3dSmrg      and <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://www.hboehm.info/c++mm/user-faq.html">FAQ</link>.
18541debfc3dSmrg      </para>
18551debfc3dSmrg
18561debfc3dSmrg  </section>
18571debfc3dSmrg  <section xml:id="manual.intro.using.concurrency.atomics" xreflabel="Atomics"><info><title>Atomics</title></info>
18581debfc3dSmrg
18591debfc3dSmrg    <para>
18601debfc3dSmrg    </para>
18611debfc3dSmrg  </section>
18621debfc3dSmrg
18631debfc3dSmrg    <section xml:id="manual.intro.using.concurrency.io" xreflabel="IO"><info><title>IO</title></info>
18641debfc3dSmrg
18651debfc3dSmrg     <para>This gets a bit tricky.  Please read carefully, and bear with me.
18661debfc3dSmrg   </para>
18671debfc3dSmrg
18681debfc3dSmrg    <section xml:id="concurrency.io.structure" xreflabel="Structure"><info><title>Structure</title></info>
18691debfc3dSmrg
18701debfc3dSmrg   <para>A wrapper
18711debfc3dSmrg      type called <code>__basic_file</code> provides our abstraction layer
18721debfc3dSmrg      for the <code>std::filebuf</code> classes.  Nearly all decisions dealing
18731debfc3dSmrg      with actual input and output must be made in <code>__basic_file</code>.
18741debfc3dSmrg   </para>
18751debfc3dSmrg   <para>A generic locking mechanism is somewhat in place at the filebuf layer,
18761debfc3dSmrg      but is not used in the current code.  Providing locking at any higher
18771debfc3dSmrg      level is akin to providing locking within containers, and is not done
18781debfc3dSmrg      for the same reasons (see the links above).
18791debfc3dSmrg   </para>
18801debfc3dSmrg    </section>
18811debfc3dSmrg
18821debfc3dSmrg    <section xml:id="concurrency.io.defaults" xreflabel="Defaults"><info><title>Defaults</title></info>
18831debfc3dSmrg
18841debfc3dSmrg   <para>The __basic_file type is simply a collection of small wrappers around
18851debfc3dSmrg      the C stdio layer (again, see the link under Structure).  We do no
18861debfc3dSmrg      locking ourselves, but simply pass through to calls to <code>fopen</code>,
18871debfc3dSmrg      <code>fwrite</code>, and so forth.
18881debfc3dSmrg   </para>
18891debfc3dSmrg   <para>So, for 3.0, the question of "is multithreading safe for I/O"
18901debfc3dSmrg      must be answered with, "is your platform's C library threadsafe
18911debfc3dSmrg      for I/O?"  Some are by default, some are not; many offer multiple
18921debfc3dSmrg      implementations of the C library with varying tradeoffs of threadsafety
18931debfc3dSmrg      and efficiency.  You, the programmer, are always required to take care
18941debfc3dSmrg      with multiple threads.
18951debfc3dSmrg   </para>
18961debfc3dSmrg   <para>(As an example, the POSIX standard requires that C stdio
18971debfc3dSmrg       <code>FILE*</code> operations are atomic.  POSIX-conforming C libraries
18981debfc3dSmrg       (e.g, on Solaris and GNU/Linux) have an internal mutex to serialize
18991debfc3dSmrg       operations on <code>FILE*</code>s.
19001debfc3dSmrg       However, you still need to not do stupid things like calling
19011debfc3dSmrg       <code>fclose(fs)</code> in one thread followed by an access of
19021debfc3dSmrg       <code>fs</code> in another.)
19031debfc3dSmrg   </para>
19041debfc3dSmrg   <para>So, if your platform's C library is threadsafe, then your
19051debfc3dSmrg      <code>fstream</code> I/O operations will be threadsafe at the lowest
19061debfc3dSmrg      level.  For higher-level operations, such as manipulating the data
19071debfc3dSmrg      contained in the stream formatting classes (e.g., setting up callbacks
19081debfc3dSmrg      inside an <code>std::ofstream</code>), you need to guard such accesses
19091debfc3dSmrg      like any other critical shared resource.
19101debfc3dSmrg   </para>
19111debfc3dSmrg    </section>
19121debfc3dSmrg
19131debfc3dSmrg    <section xml:id="concurrency.io.future" xreflabel="Future"><info><title>Future</title></info>
19141debfc3dSmrg
19151debfc3dSmrg   <para> A
19161debfc3dSmrg      second choice may be available for I/O implementations:  libio.  This is
19171debfc3dSmrg      disabled by default, and in fact will not currently work due to other
19181debfc3dSmrg      issues.  It will be revisited, however.
19191debfc3dSmrg   </para>
19201debfc3dSmrg   <para>The libio code is a subset of the guts of the GNU libc (glibc) I/O
19211debfc3dSmrg      implementation.  When libio is in use, the <code>__basic_file</code>
19221debfc3dSmrg      type is basically derived from FILE.  (The real situation is more
19231debfc3dSmrg      complex than that... it's derived from an internal type used to
19241debfc3dSmrg      implement FILE.  See libio/libioP.h to see scary things done with
19251debfc3dSmrg      vtbls.)  The result is that there is no "layer" of C stdio
19261debfc3dSmrg      to go through; the filebuf makes calls directly into the same
19271debfc3dSmrg      functions used to implement <code>fread</code>, <code>fwrite</code>,
19281debfc3dSmrg      and so forth, using internal data structures.  (And when I say
19291debfc3dSmrg      "makes calls directly," I mean the function is literally
19301debfc3dSmrg      replaced by a jump into an internal function.  Fast but frightening.
19311debfc3dSmrg      *grin*)
19321debfc3dSmrg   </para>
19331debfc3dSmrg   <para>Also, the libio internal locks are used.  This requires pulling in
19341debfc3dSmrg      large chunks of glibc, such as a pthreads implementation, and is one
19351debfc3dSmrg      of the issues preventing widespread use of libio as the libstdc++
19361debfc3dSmrg      cstdio implementation.
19371debfc3dSmrg   </para>
19381debfc3dSmrg   <para>But we plan to make this work, at least as an option if not a future
19391debfc3dSmrg      default.  Platforms running a copy of glibc with a recent-enough
19401debfc3dSmrg      version will see calls from libstdc++ directly into the glibc already
19411debfc3dSmrg      installed.  For other platforms, a copy of the libio subsection will
19421debfc3dSmrg      be built and included in libstdc++.
19431debfc3dSmrg   </para>
19441debfc3dSmrg    </section>
19451debfc3dSmrg
19461debfc3dSmrg    <section xml:id="concurrency.io.alt" xreflabel="Alt"><info><title>Alternatives</title></info>
19471debfc3dSmrg
19481debfc3dSmrg   <para>Don't forget that other cstdio implementations are possible.  You could
19491debfc3dSmrg      easily write one to perform your own forms of locking, to solve your
19501debfc3dSmrg      "interesting" problems.
19511debfc3dSmrg   </para>
19521debfc3dSmrg    </section>
19531debfc3dSmrg
19541debfc3dSmrg    </section>
19551debfc3dSmrg
19561debfc3dSmrg    <section xml:id="manual.intro.using.concurrency.containers" xreflabel="Containers"><info><title>Containers</title></info>
19571debfc3dSmrg
19581debfc3dSmrg
19591debfc3dSmrg   <para>This section discusses issues surrounding the design of
19601debfc3dSmrg      multithreaded applications which use Standard C++ containers.
19611debfc3dSmrg      All information in this section is current as of the gcc 3.0
19621debfc3dSmrg      release and all later point releases.  Although earlier gcc
19631debfc3dSmrg      releases had a different approach to threading configuration and
19641debfc3dSmrg      proper compilation, the basic code design rules presented here
19651debfc3dSmrg      were similar.  For information on all other aspects of
19661debfc3dSmrg      multithreading as it relates to libstdc++, including details on
19671debfc3dSmrg      the proper compilation of threaded code (and compatibility between
19681debfc3dSmrg      threaded and non-threaded code), see Chapter 17.
19691debfc3dSmrg   </para>
19701debfc3dSmrg   <para>Two excellent pages to read when working with the Standard C++
19711debfc3dSmrg      containers and threads are
1972a2dc1f3fSmrg      <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/thread_safety.html">SGI's
1973a2dc1f3fSmrg      https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/thread_safety.html</link> and
1974a2dc1f3fSmrg      <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/Allocators.html">SGI's
1975a2dc1f3fSmrg      https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/Allocators.html</link>.
19761debfc3dSmrg   </para>
19771debfc3dSmrg   <para><emphasis>However, please ignore all discussions about the user-level
19781debfc3dSmrg      configuration of the lock implementation inside the STL
19791debfc3dSmrg      container-memory allocator on those pages.  For the sake of this
19801debfc3dSmrg      discussion, libstdc++ configures the SGI STL implementation,
19811debfc3dSmrg      not you.  This is quite different from how gcc pre-3.0 worked.
19821debfc3dSmrg      In particular, past advice was for people using g++ to
19831debfc3dSmrg      explicitly define _PTHREADS or other macros or port-specific
19841debfc3dSmrg      compilation options on the command line to get a thread-safe
19851debfc3dSmrg      STL.  This is no longer required for any port and should no
19861debfc3dSmrg      longer be done unless you really know what you are doing and
19871debfc3dSmrg      assume all responsibility.</emphasis>
19881debfc3dSmrg   </para>
19891debfc3dSmrg   <para>Since the container implementation of libstdc++ uses the SGI
19901debfc3dSmrg      code, we use the same definition of thread safety as SGI when
19911debfc3dSmrg      discussing design.  A key point that beginners may miss is the
19921debfc3dSmrg      fourth major paragraph of the first page mentioned above
19931debfc3dSmrg      (<emphasis>For most clients...</emphasis>), which points out that
19941debfc3dSmrg      locking must nearly always be done outside the container, by
19951debfc3dSmrg      client code (that'd be you, not us).  There is a notable
19961debfc3dSmrg      exceptions to this rule.  Allocators called while a container or
19971debfc3dSmrg      element is constructed uses an internal lock obtained and
19981debfc3dSmrg      released solely within libstdc++ code (in fact, this is the
19991debfc3dSmrg      reason STL requires any knowledge of the thread configuration).
20001debfc3dSmrg   </para>
20011debfc3dSmrg   <para>For implementing a container which does its own locking, it is
20021debfc3dSmrg      trivial to provide a wrapper class which obtains the lock (as
20031debfc3dSmrg      SGI suggests), performs the container operation, and then
20041debfc3dSmrg      releases the lock.  This could be templatized <emphasis>to a certain
20051debfc3dSmrg      extent</emphasis>, on the underlying container and/or a locking
20061debfc3dSmrg      mechanism.  Trying to provide a catch-all general template
20071debfc3dSmrg      solution would probably be more trouble than it's worth.
20081debfc3dSmrg   </para>
20091debfc3dSmrg   <para>The library implementation may be configured to use the
20101debfc3dSmrg      high-speed caching memory allocator, which complicates thread
20111debfc3dSmrg      safety issues. For all details about how to globally override
20121debfc3dSmrg      this at application run-time
20131debfc3dSmrg      see <link linkend="manual.intro.using.macros">here</link>. Also
20141debfc3dSmrg      useful are details
20151debfc3dSmrg      on <link linkend="std.util.memory.allocator">allocator</link>
20161debfc3dSmrg      options and capabilities.
20171debfc3dSmrg   </para>
20181debfc3dSmrg
20191debfc3dSmrg    </section>
20201debfc3dSmrg</section>
20211debfc3dSmrg
20221debfc3dSmrg<!-- Section 0x : Exception policies, expectations, topics -->
20231debfc3dSmrg<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="xml" href="using_exceptions.xml">
20241debfc3dSmrg</xi:include>
20251debfc3dSmrg
20261debfc3dSmrg<!-- Section 0x : Debug -->
20271debfc3dSmrg<xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="xml" href="debug.xml">
20281debfc3dSmrg</xi:include>
20291debfc3dSmrg
20301debfc3dSmrg</chapter>
2031