bb04e0f76c9bb4e1d8c75b8d0f80b912798df107
[platform/upstream/gcc.git] / libstdc++-v3 / doc / xml / manual / using.xml
1 <chapter xmlns="http://docbook.org/ns/docbook" version="5.0" 
2          xml:id="manual.intro.using" xreflabel="Using">
3   <info><title>Using</title></info>
4   <?dbhtml filename="using.html"?>
5
6   <section xml:id="manual.intro.using.flags" xreflabel="Flags"><info><title>Command Options</title></info>
7     
8     <para>
9       The set of features available in the GNU C++ library is shaped by
10       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
11       Command Options</link>. Options that impact libstdc++ are
12       enumerated and detailed in the table below.
13     </para>
14
15     <para>
16       The standard library conforms to the dialect of C++ specified by the
17       <option>-std</option> option passed to the compiler.
18       By default, <command>g++</command> is equivalent to
19       <command>g++ -std=gnu++14</command> since GCC 6, and
20       <command>g++ -std=gnu++98</command> for older releases.
21     </para>
22
23  <table frame="all" xml:id="table.cmd_options">
24 <title>C++ Command Options</title>
25
26 <tgroup cols="2" align="left" colsep="1" rowsep="1">
27 <colspec colname="c1"/>
28 <colspec colname="c2"/>
29
30   <thead>
31     <row>
32       <entry>Option Flags</entry>
33       <entry>Description</entry>
34     </row>
35   </thead>
36
37   <tbody>
38     <row>
39       <entry><literal>-std=c++98</literal> or <literal>-std=c++03</literal>
40       </entry>
41       <entry>Use the 1998 ISO C++ standard plus amendments.</entry>
42     </row>
43
44     <row>
45       <entry><literal>-std=gnu++98</literal> or <literal>-std=gnu++03</literal>
46       </entry>
47       <entry>As directly above, with GNU extensions.</entry>
48     </row>
49
50     <row>
51       <entry><literal>-std=c++11</literal></entry>
52       <entry>Use the 2011 ISO C++ standard.</entry>
53     </row>
54
55     <row>
56       <entry><literal>-std=gnu++11</literal></entry>
57       <entry>As directly above, with GNU extensions.</entry>
58     </row>
59
60     <row>
61       <entry><literal>-std=c++14</literal></entry>
62       <entry>Use the 2014 ISO C++ standard.</entry>
63     </row>
64
65     <row>
66       <entry><literal>-std=gnu++14</literal></entry>
67       <entry>As directly above, with GNU extensions.</entry>
68     </row>
69
70     <row>
71       <entry><literal>-fexceptions</literal></entry>
72       <entry>See <link linkend="intro.using.exception.no">exception-free dialect</link></entry>
73     </row>
74
75     <row>
76       <entry><literal>-frtti</literal></entry>
77       <entry>As above, but RTTI-free dialect.</entry>
78     </row>
79
80     <row>
81       <entry><literal>-pthread</literal></entry>
82       <entry>For ISO C++11
83         <filename class="headerfile">&lt;thread&gt;</filename>,
84         <filename class="headerfile">&lt;future&gt;</filename>,
85         <filename class="headerfile">&lt;mutex&gt;</filename>,
86         or <filename class="headerfile">&lt;condition_variable&gt;</filename>.
87       </entry>
88     </row>
89
90     <row>
91       <entry><literal>-latomic</literal></entry>
92       <entry>Linking to <filename class="libraryfile">libatomic</filename>
93         is required for some uses of ISO C++11
94         <filename class="headerfile">&lt;atomic&gt;</filename>.
95       </entry>
96     </row>
97
98     <row>
99       <entry><literal>-lstdc++fs</literal></entry>
100       <entry>Linking to <filename class="libraryfile">libstdc++fs</filename>
101         is required for use of the Filesystem library extensions in
102         <filename class="headerfile">&lt;experimental/filesystem&gt;</filename>.
103       </entry>
104     </row>
105
106     <row>
107       <entry><literal>-fopenmp</literal></entry>
108       <entry>For <link linkend="manual.ext.parallel_mode">parallel</link> mode.</entry>
109     </row>
110   </tbody>
111
112 </tgroup>
113 </table>
114
115   </section>
116
117   <section xml:id="manual.intro.using.headers" xreflabel="Headers"><info><title>Headers</title></info>
118     <?dbhtml filename="using_headers.html"?>
119     
120
121     <section xml:id="manual.intro.using.headers.all" xreflabel="Header Files"><info><title>Header Files</title></info>
122       
123
124    <para>
125      The C++ standard specifies the entire set of header files that
126      must be available to all hosted implementations.  Actually, the
127      word "files" is a misnomer, since the contents of the
128      headers don't necessarily have to be in any kind of external
129      file.  The only rule is that when one <code>#include</code>'s a
130      header, the contents of that header become available, no matter
131      how.
132    </para>
133
134    <para>
135    That said, in practice files are used.
136    </para>
137
138    <para>
139      There are two main types of include files: header files related
140      to a specific version of the ISO C++ standard (called Standard
141      Headers), and all others (TR1, C++ ABI, and Extensions).
142    </para>
143
144    <para>
145      Two dialects of standard headers are supported, corresponding to
146      the 1998 standard as updated for 2003, and the current 2011 standard.
147    </para>
148
149    <para>
150      C++98/03 include files. These are available in the default compilation mode, i.e. <code>-std=c++98</code> or <code>-std=gnu++98</code>.
151    </para>
152
153 <table frame="all" xml:id="table.cxx98_headers">
154 <title>C++ 1998 Library Headers</title>
155
156 <tgroup cols="5" align="left" colsep="1" rowsep="1">
157 <colspec colname="c1"/>
158 <colspec colname="c2"/>
159 <colspec colname="c3"/>
160 <colspec colname="c4"/>
161 <colspec colname="c5"/>
162 <tbody>
163 <row>
164 <entry><filename class="headerfile">algorithm</filename></entry>
165 <entry><filename class="headerfile">bitset</filename></entry>
166 <entry><filename class="headerfile">complex</filename></entry>
167 <entry><filename class="headerfile">deque</filename></entry>
168 <entry><filename class="headerfile">exception</filename></entry>
169 </row>
170 <row>
171 <entry><filename class="headerfile">fstream</filename></entry>
172 <entry><filename class="headerfile">functional</filename></entry>
173 <entry><filename class="headerfile">iomanip</filename></entry>
174 <entry><filename class="headerfile">ios</filename></entry>
175 <entry><filename class="headerfile">iosfwd</filename></entry>
176 </row>
177 <row>
178 <entry><filename class="headerfile">iostream</filename></entry>
179 <entry><filename class="headerfile">istream</filename></entry>
180 <entry><filename class="headerfile">iterator</filename></entry>
181 <entry><filename class="headerfile">limits</filename></entry>
182 <entry><filename class="headerfile">list</filename></entry>
183 </row>
184 <row>
185 <entry><filename class="headerfile">locale</filename></entry>
186 <entry><filename class="headerfile">map</filename></entry>
187 <entry><filename class="headerfile">memory</filename></entry>
188 <entry><filename class="headerfile">new</filename></entry>
189 <entry><filename class="headerfile">numeric</filename></entry>
190 </row>
191 <row>
192 <entry><filename class="headerfile">ostream</filename></entry>
193 <entry><filename class="headerfile">queue</filename></entry>
194 <entry><filename class="headerfile">set</filename></entry>
195 <entry><filename class="headerfile">sstream</filename></entry>
196 <entry><filename class="headerfile">stack</filename></entry>
197 </row>
198 <row>
199 <entry><filename class="headerfile">stdexcept</filename></entry>
200 <entry><filename class="headerfile">streambuf</filename></entry>
201 <entry><filename class="headerfile">string</filename></entry>
202 <entry><filename class="headerfile">utility</filename></entry>
203 <entry><filename class="headerfile">typeinfo</filename></entry>
204 </row>
205 <row>
206 <entry><filename class="headerfile">valarray</filename></entry>
207 <entry><filename class="headerfile">vector</filename></entry>
208 </row>
209 </tbody>
210 </tgroup>
211 </table>
212
213 <para/>
214 <table frame="all" xml:id="table.cxx98_cheaders">
215 <title>C++ 1998 Library Headers for C Library Facilities</title>
216
217 <tgroup cols="5" align="left" colsep="1" rowsep="1">
218 <colspec colname="c1"/>
219 <colspec colname="c2"/>
220 <colspec colname="c3"/>
221 <colspec colname="c4"/>
222 <colspec colname="c5"/>
223 <tbody>
224 <row>
225 <entry><filename class="headerfile">cassert</filename></entry>
226 <entry><filename class="headerfile">cerrno</filename></entry>
227 <entry><filename class="headerfile">cctype</filename></entry>
228 <entry><filename class="headerfile">cfloat</filename></entry>
229 <entry><filename class="headerfile">ciso646</filename></entry>
230 </row>
231 <row>
232 <entry><filename class="headerfile">climits</filename></entry>
233 <entry><filename class="headerfile">clocale</filename></entry>
234 <entry><filename class="headerfile">cmath</filename></entry>
235 <entry><filename class="headerfile">csetjmp</filename></entry>
236 <entry><filename class="headerfile">csignal</filename></entry>
237 </row>
238 <row>
239 <entry><filename class="headerfile">cstdarg</filename></entry>
240 <entry><filename class="headerfile">cstddef</filename></entry>
241 <entry><filename class="headerfile">cstdio</filename></entry>
242 <entry><filename class="headerfile">cstdlib</filename></entry>
243 <entry><filename class="headerfile">cstring</filename></entry>
244 </row>
245 <row>
246 <entry><filename class="headerfile">ctime</filename></entry>
247 <entry><filename class="headerfile">cwchar</filename></entry>
248 <entry><filename class="headerfile">cwctype</filename></entry>
249 </row>
250 </tbody>
251 </tgroup>
252 </table>
253
254 <para>
255 C++11 include files. These are only available in C++11 compilation
256 mode, i.e. <literal>-std=c++11</literal> or <literal>-std=gnu++11</literal>.
257 </para>
258
259 <para/>
260 <table frame="all" xml:id="table.cxx11_headers">
261 <title>C++ 2011 Library Headers</title>
262
263 <tgroup cols="5" align="left" colsep="1" rowsep="1">
264 <colspec colname="c1"/>
265 <colspec colname="c2"/>
266 <colspec colname="c3"/>
267 <colspec colname="c4"/>
268 <colspec colname="c5"/>
269 <tbody>
270
271 <row>
272 <entry><filename class="headerfile">algorithm</filename></entry>
273 <entry><filename class="headerfile">array</filename></entry>
274 <entry><filename class="headerfile">bitset</filename></entry>
275 <entry><filename class="headerfile">chrono</filename></entry>
276 <entry><filename class="headerfile">complex</filename></entry>
277 </row>
278 <row>
279 <entry><filename class="headerfile">condition_variable</filename></entry>
280 <entry><filename class="headerfile">deque</filename></entry>
281 <entry><filename class="headerfile">exception</filename></entry>
282 <entry><filename class="headerfile">forward_list</filename></entry>
283 <entry><filename class="headerfile">fstream</filename></entry>
284 </row>
285 <row>
286 <entry><filename class="headerfile">functional</filename></entry>
287 <entry><filename class="headerfile">future</filename></entry>
288 <entry><filename class="headerfile">initalizer_list</filename></entry>
289 <entry><filename class="headerfile">iomanip</filename></entry>
290 <entry><filename class="headerfile">ios</filename></entry>
291 </row>
292 <row>
293 <entry><filename class="headerfile">iosfwd</filename></entry>
294 <entry><filename class="headerfile">iostream</filename></entry>
295 <entry><filename class="headerfile">istream</filename></entry>
296 <entry><filename class="headerfile">iterator</filename></entry>
297 <entry><filename class="headerfile">limits</filename></entry>
298 </row>
299 <row>
300 <entry><filename class="headerfile">list</filename></entry>
301 <entry><filename class="headerfile">locale</filename></entry>
302 <entry><filename class="headerfile">map</filename></entry>
303 <entry><filename class="headerfile">memory</filename></entry>
304 <entry><filename class="headerfile">mutex</filename></entry>
305 </row>
306 <row>
307 <entry><filename class="headerfile">new</filename></entry>
308 <entry><filename class="headerfile">numeric</filename></entry>
309 <entry><filename class="headerfile">ostream</filename></entry>
310 <entry><filename class="headerfile">queue</filename></entry>
311 <entry><filename class="headerfile">random</filename></entry>
312 </row>
313 <row>
314 <entry><filename class="headerfile">ratio</filename></entry>
315 <entry><filename class="headerfile">regex</filename></entry>
316 <entry><filename class="headerfile">set</filename></entry>
317 <entry><filename class="headerfile">sstream</filename></entry>
318 <entry><filename class="headerfile">stack</filename></entry>
319 </row>
320 <row>
321 <entry><filename class="headerfile">stdexcept</filename></entry>
322 <entry><filename class="headerfile">streambuf</filename></entry>
323 <entry><filename class="headerfile">string</filename></entry>
324 <entry><filename class="headerfile">system_error</filename></entry>
325 <entry><filename class="headerfile">thread</filename></entry>
326 </row>
327 <row>
328 <entry><filename class="headerfile">tuple</filename></entry>
329 <entry><filename class="headerfile">type_traits</filename></entry>
330 <entry><filename class="headerfile">typeinfo</filename></entry>
331 <entry><filename class="headerfile">unordered_map</filename></entry>
332 <entry><filename class="headerfile">unordered_set</filename></entry>
333 </row>
334 <row>
335 <entry><filename class="headerfile">utility</filename></entry>
336 <entry><filename class="headerfile">valarray</filename></entry>
337 <entry><filename class="headerfile">vector</filename></entry>
338 </row>
339
340 </tbody>
341 </tgroup>
342 </table>
343
344 <para/>
345
346 <table frame="all" xml:id="table.cxx11_cheaders">
347 <title>C++ 2011 Library Headers for C Library Facilities</title>
348
349 <tgroup cols="5" align="left" colsep="1" rowsep="1">
350 <colspec colname="c1"/>
351 <colspec colname="c2"/>
352 <colspec colname="c3"/>
353 <colspec colname="c4"/>
354 <colspec colname="c5"/>
355 <tbody>
356 <row>
357 <entry><filename class="headerfile">cassert</filename></entry>
358 <entry><filename class="headerfile">ccomplex</filename></entry>
359 <entry><filename class="headerfile">cctype</filename></entry>
360 <entry><filename class="headerfile">cerrno</filename></entry>
361 <entry><filename class="headerfile">cfenv</filename></entry>
362 </row>
363 <row>
364 <entry><filename class="headerfile">cfloat</filename></entry>
365 <entry><filename class="headerfile">cinttypes</filename></entry>
366 <entry><filename class="headerfile">ciso646</filename></entry>
367 <entry><filename class="headerfile">climits</filename></entry>
368 <entry><filename class="headerfile">clocale</filename></entry>
369 </row>
370 <row>
371 <entry><filename class="headerfile">cmath</filename></entry>
372 <entry><filename class="headerfile">csetjmp</filename></entry>
373 <entry><filename class="headerfile">csignal</filename></entry>
374 <entry><filename class="headerfile">cstdarg</filename></entry>
375 <entry><filename class="headerfile">cstdbool</filename></entry>
376 </row>
377 <row>
378 <entry><filename class="headerfile">cstddef</filename></entry>
379 <entry><filename class="headerfile">cstdint</filename></entry>
380 <entry><filename class="headerfile">cstdlib</filename></entry>
381 <entry><filename class="headerfile">cstdio</filename></entry>
382 <entry><filename class="headerfile">cstring</filename></entry>
383 </row>
384 <row>
385 <entry><filename class="headerfile">ctgmath</filename></entry>
386 <entry><filename class="headerfile">ctime</filename></entry>
387 <entry><filename class="headerfile">cuchar</filename></entry>
388 <entry><filename class="headerfile">cwchar</filename></entry>
389 <entry><filename class="headerfile">cwctype</filename></entry>
390 </row>
391 </tbody>
392 </tgroup>
393 </table>
394
395
396 <para>
397   In addition, TR1 includes as:
398 </para>
399
400 <table frame="all" xml:id="table.tr1_headers">
401 <title>C++ TR 1 Library Headers</title>
402
403 <tgroup cols="5" align="left" colsep="1" rowsep="1">
404 <colspec colname="c1"/>
405 <colspec colname="c2"/>
406 <colspec colname="c3"/>
407 <colspec colname="c4"/>
408 <colspec colname="c5"/>
409 <tbody>
410
411 <row>
412 <entry><filename class="headerfile">tr1/array</filename></entry>
413 <entry><filename class="headerfile">tr1/complex</filename></entry>
414 <entry><filename class="headerfile">tr1/memory</filename></entry>
415 <entry><filename class="headerfile">tr1/functional</filename></entry>
416 <entry><filename class="headerfile">tr1/random</filename></entry>
417 </row>
418 <row>
419 <entry><filename class="headerfile">tr1/regex</filename></entry>
420 <entry><filename class="headerfile">tr1/tuple</filename></entry>
421 <entry><filename class="headerfile">tr1/type_traits</filename></entry>
422 <entry><filename class="headerfile">tr1/unordered_map</filename></entry>
423 <entry><filename class="headerfile">tr1/unordered_set</filename></entry>
424 </row>
425 <row>
426 <entry><filename class="headerfile">tr1/utility</filename></entry>
427 </row>
428
429 </tbody>
430 </tgroup>
431 </table>
432
433 <para/>
434
435
436 <table frame="all" xml:id="table.tr1_cheaders">
437 <title>C++ TR 1 Library Headers for C Library Facilities</title>
438
439 <tgroup cols="5" align="left" colsep="1" rowsep="1">
440 <colspec colname="c1"/>
441 <colspec colname="c2"/>
442 <colspec colname="c3"/>
443 <colspec colname="c4"/>
444 <colspec colname="c5"/>
445 <tbody>
446
447 <row>
448 <entry><filename class="headerfile">tr1/ccomplex</filename></entry>
449 <entry><filename class="headerfile">tr1/cfenv</filename></entry>
450 <entry><filename class="headerfile">tr1/cfloat</filename></entry>
451 <entry><filename class="headerfile">tr1/cmath</filename></entry>
452 <entry><filename class="headerfile">tr1/cinttypes</filename></entry>
453 </row>
454 <row>
455 <entry><filename class="headerfile">tr1/climits</filename></entry>
456 <entry><filename class="headerfile">tr1/cstdarg</filename></entry>
457 <entry><filename class="headerfile">tr1/cstdbool</filename></entry>
458 <entry><filename class="headerfile">tr1/cstdint</filename></entry>
459 <entry><filename class="headerfile">tr1/cstdio</filename></entry>
460 </row>
461 <row>
462 <entry><filename class="headerfile">tr1/cstdlib</filename></entry>
463 <entry><filename class="headerfile">tr1/ctgmath</filename></entry>
464 <entry><filename class="headerfile">tr1/ctime</filename></entry>
465 <entry><filename class="headerfile">tr1/cwchar</filename></entry>
466 <entry><filename class="headerfile">tr1/cwctype</filename></entry>
467 </row>
468
469 </tbody>
470 </tgroup>
471 </table>
472
473
474 <para>Decimal floating-point arithmetic is available if the C++
475 compiler supports scalar decimal floating-point types defined via
476 <code>__attribute__((mode(SD|DD|LD)))</code>.
477 </para>
478
479 <table frame="all" xml:id="table.decfp_headers">
480 <title>C++ TR 24733 Decimal Floating-Point Header</title>
481
482 <tgroup cols="1" align="left" colsep="1" rowsep="1">
483 <colspec colname="c1"/>
484 <tbody>
485 <row>
486 <entry><filename class="headerfile">decimal/decimal</filename></entry>
487 </row>
488 </tbody>
489 </tgroup>
490 </table>
491
492 <para>
493   Also included are files for the C++ ABI interface:
494 </para>
495
496 <table frame="all" xml:id="table.abi_headers">
497 <title>C++ ABI Headers</title>
498
499 <tgroup cols="2" align="left" colsep="1" rowsep="1">
500 <colspec colname="c1"/>
501 <colspec colname="c2"/>
502 <tbody>
503 <row><entry><filename class="headerfile">cxxabi.h</filename></entry><entry><filename class="headerfile">cxxabi_forced.h</filename></entry></row>
504 </tbody>
505 </tgroup>
506 </table>
507
508 <para>
509   And a large variety of extensions.
510 </para>
511
512 <table frame="all" xml:id="table.ext_headers">
513 <title>Extension Headers</title>
514
515 <tgroup cols="5" align="left" colsep="1" rowsep="1">
516 <colspec colname="c1"/>
517 <colspec colname="c2"/>
518 <colspec colname="c3"/>
519 <colspec colname="c4"/>
520 <colspec colname="c5"/>
521 <tbody>
522
523 <row>
524 <entry><filename class="headerfile">ext/algorithm</filename></entry>
525 <entry><filename class="headerfile">ext/atomicity.h</filename></entry>
526 <entry><filename class="headerfile">ext/array_allocator.h</filename></entry>
527 <entry><filename class="headerfile">ext/bitmap_allocator.h</filename></entry>
528 <entry><filename class="headerfile">ext/cast.h</filename></entry>
529 </row>
530 <row>
531 <entry><filename class="headerfile">ext/codecvt_specializations.h</filename></entry>
532 <entry><filename class="headerfile">ext/concurrence.h</filename></entry>
533 <entry><filename class="headerfile">ext/debug_allocator.h</filename></entry>
534 <entry><filename class="headerfile">ext/enc_filebuf.h</filename></entry>
535 <entry><filename class="headerfile">ext/extptr_allocator.h</filename></entry>
536 </row>
537 <row>
538 <entry><filename class="headerfile">ext/functional</filename></entry>
539 <entry><filename class="headerfile">ext/iterator</filename></entry>
540 <entry><filename class="headerfile">ext/malloc_allocator.h</filename></entry>
541 <entry><filename class="headerfile">ext/memory</filename></entry>
542 <entry><filename class="headerfile">ext/mt_allocator.h</filename></entry>
543 </row>
544 <row>
545 <entry><filename class="headerfile">ext/new_allocator.h</filename></entry>
546 <entry><filename class="headerfile">ext/numeric</filename></entry>
547 <entry><filename class="headerfile">ext/numeric_traits.h</filename></entry>
548 <entry><filename class="headerfile">ext/pb_ds/assoc_container.h</filename></entry>
549 <entry><filename class="headerfile">ext/pb_ds/priority_queue.h</filename></entry>
550 </row>
551 <row>
552 <entry><filename class="headerfile">ext/pod_char_traits.h</filename></entry>
553 <entry><filename class="headerfile">ext/pool_allocator.h</filename></entry>
554 <entry><filename class="headerfile">ext/rb_tree</filename></entry>
555 <entry><filename class="headerfile">ext/rope</filename></entry>
556 <entry><filename class="headerfile">ext/slist</filename></entry>
557 </row>
558 <row>
559 <entry><filename class="headerfile">ext/stdio_filebuf.h</filename></entry>
560 <entry><filename class="headerfile">ext/stdio_sync_filebuf.h</filename></entry>
561 <entry><filename class="headerfile">ext/throw_allocator.h</filename></entry>
562 <entry><filename class="headerfile">ext/typelist.h</filename></entry>
563 <entry><filename class="headerfile">ext/type_traits.h</filename></entry>
564 </row>
565 <row>
566 <entry><filename class="headerfile">ext/vstring.h</filename></entry>
567 </row>
568
569 </tbody>
570 </tgroup>
571 </table>
572
573 <para/>
574
575 <table frame="all" xml:id="table.debug_headers">
576 <title>Extension Debug Headers</title>
577
578 <tgroup cols="5" align="left" colsep="1" rowsep="1">
579 <colspec colname="c1"/>
580 <colspec colname="c2"/>
581 <colspec colname="c3"/>
582 <colspec colname="c4"/>
583 <colspec colname="c5"/>
584 <tbody>
585
586 <row>
587 <entry><filename class="headerfile">debug/bitset</filename></entry>
588 <entry><filename class="headerfile">debug/deque</filename></entry>
589 <entry><filename class="headerfile">debug/list</filename></entry>
590 <entry><filename class="headerfile">debug/map</filename></entry>
591 <entry><filename class="headerfile">debug/set</filename></entry>
592 </row>
593
594 <row>
595 <entry><filename class="headerfile">debug/string</filename></entry>
596 <entry><filename class="headerfile">debug/unordered_map</filename></entry>
597 <entry><filename class="headerfile">debug/unordered_set</filename></entry>
598 <entry><filename class="headerfile">debug/vector</filename></entry>
599 </row>
600
601 </tbody>
602 </tgroup>
603 </table>
604
605 <para/>
606
607 <table frame="all" xml:id="table.profile_headers">
608 <title>Extension Profile Headers</title>
609
610 <tgroup cols="4" align="left" colsep="1" rowsep="1">
611 <colspec colname="c1"/>
612 <colspec colname="c2"/>
613 <colspec colname="c3"/>
614 <colspec colname="c4"/>
615 <tbody>
616
617 <row>
618 <entry><filename class="headerfile">profile/bitset</filename></entry>
619 <entry><filename class="headerfile">profile/deque</filename></entry>
620 <entry><filename class="headerfile">profile/list</filename></entry>
621 <entry><filename class="headerfile">profile/map</filename></entry>
622 </row>
623
624 <row>
625 <entry><filename class="headerfile">profile/set</filename></entry>
626 <entry><filename class="headerfile">profile/unordered_map</filename></entry>
627 <entry><filename class="headerfile">profile/unordered_set</filename></entry>
628 <entry><filename class="headerfile">profile/vector</filename></entry>
629 </row>
630
631 </tbody>
632 </tgroup>
633 </table>
634
635 <para/>
636
637 <table frame="all" xml:id="table.parallel_headers">
638 <title>Extension Parallel Headers</title>
639
640 <tgroup cols="2" align="left" colsep="1" rowsep="1">
641 <colspec colname="c1"/>
642 <colspec colname="c2"/>
643 <tbody>
644 <row>
645 <entry><filename class="headerfile">parallel/algorithm</filename></entry>
646 <entry><filename class="headerfile">parallel/numeric</filename></entry>
647 </row>
648 </tbody>
649 </tgroup>
650 </table>
651
652     </section>
653
654     <section xml:id="manual.intro.using.headers.mixing" xreflabel="Mixing Headers"><info><title>Mixing Headers</title></info>
655       
656
657 <para> A few simple rules.
658 </para>
659
660 <para>First, mixing different dialects of the standard headers is not
661 possible. It's an all-or-nothing affair. Thus, code like
662 </para>
663
664 <programlisting>
665 #include &lt;array&gt;
666 #include &lt;functional&gt;
667 </programlisting>
668
669 <para>Implies C++11 mode. To use the entities in &lt;array&gt;, the C++11
670 compilation mode must be used, which implies the C++11 functionality
671 (and deprecations) in &lt;functional&gt; will be present.
672 </para>
673
674 <para>Second, the other headers can be included with either dialect of
675 the standard headers, although features and types specific to C++11
676 are still only enabled when in C++11 compilation mode. So, to use
677 rvalue references with <code>__gnu_cxx::vstring</code>, or to use the
678 debug-mode versions of <code>std::unordered_map</code>, one must use
679 the <code>std=gnu++11</code> compiler flag. (Or <code>std=c++11</code>, of course.)
680 </para>
681
682 <para>A special case of the second rule is the mixing of TR1 and C++11
683 facilities. It is possible (although not especially prudent) to
684 include both the TR1 version and the C++11 version of header in the
685 same translation unit:
686 </para>
687
688 <programlisting>
689 #include &lt;tr1/type_traits&gt;
690 #include &lt;type_traits&gt;
691 </programlisting>
692
693 <para> Several parts of C++11 diverge quite substantially from TR1 predecessors.
694 </para>
695     </section>
696
697     <section xml:id="manual.intro.using.headers.cheaders" xreflabel="C Headers and"><info><title>The C Headers and <code>namespace std</code></title></info>
698       
699
700 <para>
701         The standard specifies that if one includes the C-style header
702         (&lt;math.h&gt; in this case), the symbols will be available
703         in the global namespace and perhaps in
704         namespace <code>std::</code> (but this is no longer a firm
705         requirement.) On the other hand, including the C++-style
706         header (&lt;cmath&gt;) guarantees that the entities will be
707         found in namespace std and perhaps in the global namespace.
708       </para>
709
710 <para>
711 Usage of C++-style headers is recommended, as then
712 C-linkage names can be disambiguated by explicit qualification, such
713 as by <code>std::abort</code>. In addition, the C++-style headers can
714 use function overloading to provide a simpler interface to certain
715 families of C-functions. For instance in &lt;cmath&gt;, the
716 function <code>std::sin</code> has overloads for all the builtin
717 floating-point types. This means that <code>std::sin</code> can be
718 used uniformly, instead of a combination
719 of <code>std::sinf</code>, <code>std::sin</code>,
720 and <code>std::sinl</code>.
721 </para>
722     </section>
723
724     <section xml:id="manual.intro.using.headers.pre" xreflabel="Precompiled Headers"><info><title>Precompiled Headers</title></info>
725       
726
727
728 <para>There are three base header files that are provided. They can be
729 used to precompile the standard headers and extensions into binary
730 files that may then be used to speed up compilations that use these headers.
731 </para>
732
733
734 <itemizedlist>
735 <listitem>
736   <para>stdc++.h</para>
737 <para>Includes all standard headers. Actual content varies depending on
738 <link linkend="manual.intro.using.flags">language dialect</link>.
739 </para>
740 </listitem>
741
742 <listitem>
743   <para>stdtr1c++.h</para>
744 <para>Includes all of &lt;stdc++.h&gt;, and adds all the TR1 headers.
745 </para>
746 </listitem>
747
748 <listitem><para>extc++.h</para>
749 <para>Includes all of &lt;stdc++.h&gt;, and adds all the Extension headers
750 (and in C++98 mode also adds all the TR1 headers by including all of
751 &lt;stdtr1c++.h&gt;).
752 </para></listitem>
753 </itemizedlist>
754
755 <para>To construct a .gch file from one of these base header files,
756 first find the include directory for the compiler. One way to do
757 this is:</para>
758
759 <programlisting>
760 g++ -v hello.cc
761
762 #include &lt;...&gt; search starts here:
763  /mnt/share/bld/H-x86-gcc.20071201/include/c++/4.3.0
764 ...
765 End of search list.
766 </programlisting>
767
768
769 <para>Then, create a precompiled header file with the same flags that
770 will be used to compile other projects.</para>
771
772 <programlisting>
773 g++ -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
774 </programlisting>
775
776 <para>The resulting file will be quite large: the current size is around
777 thirty megabytes. </para>
778
779 <para>How to use the resulting file.</para>
780
781 <programlisting>
782 g++ -I. -include stdc++.h  -H -g -O2 hello.cc
783 </programlisting>
784
785 <para>Verification that the PCH file is being used is easy:</para>
786
787 <programlisting>
788 g++ -Winvalid-pch -I. -include stdc++.h -H -g -O2 hello.cc -o test.exe
789 ! ./stdc++.h.gch
790 . /mnt/share/bld/H-x86-gcc.20071201/include/c++/4.3.0/iostream
791 . /mnt/share/bld/H-x86-gcc.20071201include/c++/4.3.0/string
792 </programlisting>
793
794 <para>The exclamation point to the left of the <code>stdc++.h.gch</code> listing means that the generated PCH file was used.</para>
795 <para/>
796
797 <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>.
798 </para>
799
800     </section>
801   </section>
802
803
804   <section xml:id="manual.intro.using.macros" xreflabel="Macros"><info><title>Macros</title></info>
805     <?dbhtml filename="using_macros.html"?>
806     
807
808    <para>
809      All library macros begin with <code>_GLIBCXX_</code>.
810    </para>
811
812    <para>
813      Furthermore, all pre-processor macros, switches, and
814       configuration options are gathered in the
815       file <filename class="headerfile">c++config.h</filename>, which
816       is generated during the libstdc++ configuration and build
817       process. This file is then included when needed by files part of
818       the public libstdc++ API, like
819       <filename class="headerfile">&lt;ios&gt;</filename>. Most of these
820       macros should not be used by consumers of libstdc++, and are reserved
821       for internal implementation use. <emphasis>These macros cannot
822       be redefined</emphasis>.
823    </para>
824
825    <para>
826      A select handful of macros control libstdc++ extensions and extra
827       features, or provide versioning information for the API.  Only
828       those macros listed below are offered for consideration by the
829       general public.
830    </para>
831
832    <para>Below are the macros which users may check for library version
833       information. </para>
834
835     <variablelist>
836     <varlistentry>
837       <term><code>_GLIBCXX_RELEASE</code></term>
838       <listitem>
839         <para>The major release number for libstdc++.  This macro is defined
840         to the GCC major version that the libstdc++ headers belong to,
841         as an integer constant.
842         When compiling with GCC it has the same value as GCC's pre-defined
843         macro <symbol>__GNUC__</symbol>.
844         This macro can be used when libstdc++ is used with a non-GNU
845         compiler where <symbol>__GNUC__</symbol> is not defined, or has a
846         different value that doesn't correspond to the libstdc++ version.
847         This macro first appeared in the GCC 7.1 release and is not defined
848         for GCC 6.x or older releases.
849       </para>
850       </listitem>
851     </varlistentry>
852     <varlistentry>
853       <term><code>__GLIBCXX__</code></term>
854       <listitem>
855         <para>The revision date of the libstdc++ source code,
856         in compressed ISO date format, as an unsigned
857         long. For notes about using this macro and details on the value of
858         this macro for a particular release, please consult the
859         <link linkend="abi.versioning.__GLIBCXX__">ABI History</link>
860         appendix.
861         </para>
862       </listitem>
863     </varlistentry>
864     </variablelist>
865
866    <para>Below are the macros which users may change with #define/#undef or
867       with -D/-U compiler flags.  The default state of the symbol is
868       listed.</para>
869
870    <para><quote>Configurable</quote> (or <quote>Not configurable</quote>) means
871       that the symbol is initially chosen (or not) based on
872       --enable/--disable options at library build and configure time
873       (documented in
874       <link linkend="manual.intro.setup.configure">Configure</link>),
875       with the various --enable/--disable choices being translated to
876       #define/#undef).
877    </para>
878
879    <para> <acronym>ABI</acronym> means that changing from the default value may
880   mean changing the <acronym>ABI</acronym> of compiled code. In other words,
881   these choices control code which has already been compiled (i.e., in a
882   binary such as libstdc++.a/.so).  If you explicitly #define or
883   #undef these macros, the <emphasis>headers</emphasis> may see different code
884   paths, but the <emphasis>libraries</emphasis> which you link against will not.
885   Experimenting with different values with the expectation of
886   consistent linkage requires changing the config headers before
887   building/installing the library.
888    </para>
889
890     <variablelist>
891     <varlistentry><term><code>_GLIBCXX_USE_DEPRECATED</code></term>
892     <listitem>
893       <para>
894         Defined by default. Not configurable. ABI-changing. Turning this off
895         removes older ARM-style iostreams code, and other anachronisms
896         from the API.  This macro is dependent on the version of the
897         standard being tracked, and as a result may give different results for
898         <code>-std=c++98</code> and <code>-std=c++11</code>. This may
899         be useful in updating old C++ code which no longer meet the
900         requirements of the language, or for checking current code
901         against new language standards.
902     </para>
903     </listitem></varlistentry>
904
905     <varlistentry><term><code>_GLIBCXX_USE_CXX11_ABI</code></term>
906     <listitem>
907       <para>
908         Defined to the value <literal>1</literal> by default.
909         Configurable via  <code>--disable-libstdcxx-dual-abi</code>
910         and/or <code>--with-default-libstdcxx-abi</code>.
911         ABI-changing.
912         When defined to a non-zero value the library headers will use the
913         new C++11-conforming ABI introduced in GCC 5, rather than the older
914         ABI introduced in GCC 3.4. This changes the definition of several
915         class templates, including <classname>std:string</classname>,
916         <classname>std::list</classname> and some locale facets.
917         For more details see <xref linkend="manual.intro.using.abi"/>.
918     </para>
919     </listitem></varlistentry>
920
921     <varlistentry><term><code>_GLIBCXX_CONCEPT_CHECKS</code></term>
922     <listitem>
923       <para>
924         Undefined by default.  Configurable via
925         <code>--enable-concept-checks</code>.  When defined, performs
926         compile-time checking on certain template instantiations to
927         detect violations of the requirements of the standard.  This
928         macro has no effect for freestanding implementations.
929         This is described in more detail in
930         <link linkend="manual.ext.compile_checks">Compile Time Checks</link>.
931       </para>
932     </listitem></varlistentry>
933
934     <varlistentry><term><code>_GLIBCXX_ASSERTIONS</code></term>
935     <listitem>
936       <para>
937         Undefined by default. When defined, enables extra error checking in
938         the form of precondition assertions, such as bounds checking in
939         strings and null pointer checks when dereferencing smart pointers.
940       </para>
941     </listitem></varlistentry>
942     <varlistentry><term><code>_GLIBCXX_DEBUG</code></term>
943     <listitem>
944       <para>
945         Undefined by default. When defined, compiles user code using
946         the <link linkend="manual.ext.debug_mode">debug mode</link>.
947         When defined, <code>_GLIBCXX_ASSERTIONS</code> is defined
948         automatically, so all the assertions enabled by that macro are also
949         enabled in debug mode.
950       </para>
951     </listitem></varlistentry>
952     <varlistentry><term><code>_GLIBCXX_DEBUG_PEDANTIC</code></term>
953     <listitem>
954       <para>
955         Undefined by default. When defined while compiling with
956         the <link linkend="manual.ext.debug_mode">debug mode</link>, makes
957         the debug mode extremely picky by making the use of libstdc++
958         extensions and libstdc++-specific behavior into errors.
959       </para>
960     </listitem></varlistentry>
961     <varlistentry><term><code>_GLIBCXX_PARALLEL</code></term>
962     <listitem>
963       <para>Undefined by default. When defined, compiles user code
964         using the <link linkend="manual.ext.parallel_mode">parallel
965         mode</link>.
966       </para>
967     </listitem></varlistentry>
968     <varlistentry><term><code>_GLIBCXX_PARALLEL_ASSERTIONS</code></term>
969     <listitem>
970       <para>Undefined by default, but when any parallel mode header is included
971       this macro will be defined to a non-zero value if
972       <code>_GLIBCXX_ASSERTIONS</code> has a non-zero value, otherwise to zero.
973       When defined to a non-zero value, it enables extra error checking and
974       assertions in the parallel mode.
975       </para>
976     </listitem></varlistentry>
977
978     <varlistentry><term><code>_GLIBCXX_PROFILE</code></term>
979     <listitem>
980       <para>Undefined by default. When defined, compiles user code
981         using the <link linkend="manual.ext.profile_mode">profile
982         mode</link>.
983       </para>
984     </listitem></varlistentry>
985
986     <varlistentry><term><code>__STDCPP_WANT_MATH_SPEC_FUNCS__</code></term>
987     <listitem>
988       <para>Undefined by default. When defined to a non-zero integer constant,
989         enables support for ISO/IEC 29124 Special Math Functions.
990       </para>
991     </listitem></varlistentry>
992
993     <varlistentry><term><code>_GLIBCXX_SANITIZE_VECTOR</code></term>
994     <listitem>
995       <para>
996         Undefined by default. When defined, <classname>std::vector</classname>
997         operations will be annotated so that AddressSanitizer can detect
998         invalid accesses to the unused capacity of a
999         <classname>std::vector</classname>. These annotations are only
1000         enabled for
1001         <classname>std::vector&lt;T, std::allocator&lt;T&gt;&gt;</classname>
1002         and only when <classname>std::allocator</classname> is derived from
1003         <xref linkend="allocator.impl"><classname>new_allocator</classname>
1004         or <classname>malloc_allocator</classname></xref>. The annotations
1005         must be present on all vector operations or none, so this macro must
1006         be defined to the same value for all translation units that create,
1007         destroy or modify vectors.
1008       </para>
1009     </listitem></varlistentry>
1010     </variablelist>
1011
1012   </section>
1013
1014 <section xml:id="manual.intro.using.abi" xreflabel="Dual ABI">
1015   <info><title>Dual ABI</title></info>
1016   <?dbhtml filename="using_dual_abi.html"?>
1017
1018 <para> In the GCC 5.1 release libstdc++ introduced a new library ABI that
1019   includes new implementations of <classname>std::string</classname> and
1020   <classname>std::list</classname>. These changes were necessary to conform
1021   to the 2011 C++ standard which forbids Copy-On-Write strings and requires
1022   lists to keep track of their size.
1023 </para>
1024
1025 <para> In order to maintain backwards compatibility for existing code linked
1026   to libstdc++ the library's soname has not changed and the old
1027   implementations are still supported in parallel with the new ones.
1028   This is achieved by defining the new implementations in an inline namespace
1029   so they have different names for linkage purposes, e.g. the new version of
1030   <classname>std::list&lt;int&gt;</classname> is actually defined as
1031   <classname>std::__cxx11::list&lt;int&gt;</classname>. Because the symbols
1032   for the new implementations have different names the definitions for both
1033   versions can be present in the same library.
1034 </para>
1035
1036 <para> The <symbol>_GLIBCXX_USE_CXX11_ABI</symbol> macro (see
1037 <xref linkend="manual.intro.using.macros"/>) controls whether
1038   the declarations in the library headers use the old or new ABI.
1039   So the decision of which ABI to use can be made separately for each
1040   source file being compiled.
1041   Using the default configuration options for GCC the default value
1042   of the macro is <literal>1</literal> which causes the new ABI to be active,
1043   so to use the old ABI you must explicitly define the macro to
1044   <literal>0</literal> before including any library headers.
1045   (Be aware that some GNU/Linux distributions configure GCC 5 differently so
1046   that the default value of the macro is <literal>0</literal> and users must
1047   define it to <literal>1</literal> to enable the new ABI.)
1048 </para>
1049
1050 <para> Although the changes were made for C++11 conformance, the choice of ABI
1051   to use is independent of the <option>-std</option> option used to compile
1052   your code, i.e. for a given GCC build the default value of the
1053   <symbol>_GLIBCXX_USE_CXX11_ABI</symbol> macro is the same for all dialects.
1054   This ensures that the <option>-std</option> does not change the ABI, so
1055   that it is straightforward to link C++03 and C++11 code together.
1056 </para>
1057
1058 <para> Because <classname>std::string</classname> is used extensively
1059   throughout the library a number of other types are also defined twice,
1060   including the stringstream classes and several facets used by
1061   <classname>std::locale</classname>. The standard facets which are always
1062   installed in a locale may be present twice, with both ABIs, to ensure that
1063   code like
1064   <code>std::use_facet&lt;std::time_get&lt;char&gt;&gt;(locale);</code>
1065   will work correctly for both <classname>std::time_get</classname> and
1066   <classname>std::__cxx11::time_get</classname> (even if a user-defined
1067   facet that derives from one or other version of
1068   <classname>time_get</classname> is installed in the locale).
1069 </para>
1070
1071 <para> Although the standard exception types defined in
1072   <filename class="headerfile">&lt;stdexcept&gt;</filename> use strings, they
1073   are not defined twice, so that a <classname>std::out_of_range</classname>
1074   exception thrown in one file can always be caught by a suitable handler in
1075   another file, even if the two files are compiled with different ABIs.
1076 </para>
1077
1078 <section xml:id="manual.intro.using.abi.trouble" xreflabel="Dual ABI Troubleshooting"><info><title>Troubleshooting</title></info>
1079
1080 <para> If you get linker errors about undefined references to symbols
1081   that involve types in the <code>std::__cxx11</code> namespace or the tag
1082   <code>[abi:cxx11]</code> then it probably indicates that you are trying to
1083   link together object files that were compiled with different values for the
1084   <symbol>_GLIBCXX_USE_CXX11_ABI</symbol> macro. This commonly happens when
1085   linking to a third-party library that was compiled with an older version
1086   of GCC. If the third-party library cannot be rebuilt with the new ABI then
1087   you will need to recompile your code with the old ABI.
1088 </para>
1089
1090 <para> Not all uses of the new ABI will cause changes in symbol names, for
1091   example a class with a <classname>std::string</classname> member variable
1092   will have the same mangled name whether compiled with the old or new ABI.
1093   In order to detect such problems the new types and functions are
1094   annotated with the <property>abi_tag</property> attribute, allowing the
1095   compiler to warn about potential ABI incompatibilities in code using them.
1096   Those warnings can be enabled with the <option>-Wabi-tag</option> option.
1097 </para>
1098
1099 </section>
1100 </section>
1101
1102   <section xml:id="manual.intro.using.namespaces" xreflabel="Namespaces"><info><title>Namespaces</title></info>
1103     <?dbhtml filename="using_namespaces.html"?>
1104     
1105
1106     <section xml:id="manual.intro.using.namespaces.all" xreflabel="Available Namespaces"><info><title>Available Namespaces</title></info>
1107       
1108
1109
1110
1111 <para> There are three main namespaces.
1112 </para>
1113
1114 <itemizedlist>
1115   <listitem><para>std</para>
1116 <para>The ISO C++ standards specify that "all library entities are defined
1117 within namespace std." This includes namespaces nested
1118 within namespace <code>std</code>, such as namespace
1119 <code>std::chrono</code>.
1120 </para>
1121 </listitem>
1122 <listitem><para>abi</para>
1123 <para>Specified by the C++ ABI. This ABI specifies a number of type and
1124 function APIs supplemental to those required by the ISO C++ Standard,
1125 but necessary for interoperability.
1126 </para>
1127 </listitem>
1128
1129 <listitem><para>__gnu_</para>
1130 <para>Indicating one of several GNU extensions. Choices
1131 include <code>__gnu_cxx</code>, <code>__gnu_debug</code>, <code>__gnu_parallel</code>,
1132 and <code>__gnu_pbds</code>.
1133 </para></listitem>
1134 </itemizedlist>
1135
1136 <para> The library uses a number of inline namespaces as implementation
1137 details that are not intended for users to refer to directly, these include
1138 <code>std::__detail</code>, <code>std::__cxx11</code> and <code>std::_V2</code>.
1139 </para>
1140
1141 <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>.
1142 </para>
1143
1144
1145     </section>
1146
1147     <section xml:id="manual.intro.using.namespaces.std" xreflabel="namespace std"><info><title>namespace std</title></info>
1148       
1149
1150
1151 <para>
1152       One standard requirement is that the library components are defined
1153       in <code>namespace std::</code>. Thus, in order to use these types or
1154       functions, one must do one of two things:
1155 </para>
1156
1157 <itemizedlist>
1158   <listitem><para>put a kind of <emphasis>using-declaration</emphasis> in your source
1159 (either <code>using namespace std;</code> or i.e. <code>using
1160 std::string;</code>) This approach works well for individual source files, but
1161 should not be used in a global context, like header files.
1162           </para></listitem> <listitem><para>use a <emphasis>fully
1163 qualified name</emphasis> for each library symbol
1164 (i.e. <code>std::string</code>, <code>std::cout</code>) Always can be
1165 used, and usually enhanced, by strategic use of typedefs. (In the
1166 cases where the qualified verbiage becomes unwieldy.)
1167           </para>
1168         </listitem>
1169 </itemizedlist>
1170
1171     </section>
1172
1173     <section xml:id="manual.intro.using.namespaces.comp" xreflabel="Using Namespace Composition"><info><title>Using Namespace Composition</title></info>
1174       
1175
1176 <para>
1177 Best practice in programming suggests sequestering new data or
1178 functionality in a sanely-named, unique namespace whenever
1179 possible. This is considered an advantage over dumping everything in
1180 the global namespace, as then name look-up can be explicitly enabled or
1181 disabled as above, symbols are consistently mangled without repetitive
1182 naming prefixes or macros, etc.
1183 </para>
1184
1185 <para>For instance, consider a project that defines most of its classes in <code>namespace gtk</code>. It is possible to
1186         adapt <code>namespace gtk</code> to <code>namespace std</code> by using a C++-feature called
1187         <emphasis>namespace composition</emphasis>. This is what happens if
1188         a <emphasis>using</emphasis>-declaration is put into a
1189         namespace-definition: the imported symbol(s) gets imported into the
1190         currently active namespace(s). For example:
1191 </para>
1192 <programlisting>
1193 namespace gtk
1194 {
1195   using std::string;
1196   using std::tr1::array;
1197
1198   class Window { ... };
1199 }
1200 </programlisting>
1201 <para>
1202         In this example, <code>std::string</code> gets imported into
1203         <code>namespace gtk</code>.  The result is that use of
1204         <code>std::string</code> inside namespace gtk can just use <code>string</code>, without the explicit qualification.
1205         As an added bonus,
1206         <code>std::string</code> does not get imported into
1207         the global namespace.  Additionally, a more elaborate arrangement can be made for backwards compatibility and portability, whereby the
1208         <code>using</code>-declarations can wrapped in macros that
1209         are set based on autoconf-tests to either "" or i.e. <code>using
1210           std::string;</code> (depending on whether the system has
1211         libstdc++ in <code>std::</code> or not).  (ideas from
1212         Llewelly and Karl Nelson)
1213 </para>
1214
1215
1216     </section>
1217   </section>
1218
1219   <section xml:id="manual.intro.using.linkage" xreflabel="Linkage"><info><title>Linking</title></info>
1220     <?dbhtml filename="using_dynamic_or_shared.html"?>
1221     
1222
1223     <section xml:id="manual.intro.using.linkage.freestanding" xreflabel="Freestanding"><info><title>Almost Nothing</title></info>
1224       
1225       <para>
1226         Or as close as it gets: freestanding. This is a minimal
1227         configuration, with only partial support for the standard
1228         library. Assume only the following header files can be used:
1229       </para>
1230
1231       <itemizedlist>
1232         <listitem>
1233           <para>
1234             <filename class="headerfile">cstdarg</filename>
1235           </para>
1236         </listitem>
1237
1238         <listitem>
1239           <para>
1240           <filename class="headerfile">cstddef</filename>
1241           </para>
1242         </listitem>
1243
1244         <listitem>
1245           <para>
1246           <filename class="headerfile">cstdlib</filename>
1247           </para>
1248         </listitem>
1249
1250         <listitem>
1251           <para>
1252           <filename class="headerfile">exception</filename>
1253           </para>
1254         </listitem>
1255
1256         <listitem>
1257           <para>
1258           <filename class="headerfile">limits</filename>
1259           </para>
1260         </listitem>
1261
1262         <listitem>
1263           <para>
1264           <filename class="headerfile">new</filename>
1265           </para>
1266         </listitem>
1267
1268         <listitem>
1269           <para>
1270           <filename class="headerfile">exception</filename>
1271           </para>
1272         </listitem>
1273
1274         <listitem>
1275           <para>
1276           <filename class="headerfile">typeinfo</filename>
1277           </para>
1278         </listitem>
1279       </itemizedlist>
1280
1281       <para>
1282         In addition, throw in
1283       </para>
1284
1285       <itemizedlist>
1286         <listitem>
1287           <para>
1288           <filename class="headerfile">cxxabi.h</filename>.
1289           </para>
1290         </listitem>
1291       </itemizedlist>
1292
1293       <para>
1294         In the
1295         C++11 <link linkend="manual.intro.using.flags">dialect</link> add
1296       </para>
1297
1298       <itemizedlist>
1299         <listitem>
1300           <para>
1301           <filename class="headerfile">initializer_list</filename>
1302           </para>
1303         </listitem>
1304         <listitem>
1305           <para>
1306           <filename class="headerfile">type_traits</filename>
1307           </para>
1308         </listitem>
1309       </itemizedlist>
1310
1311       <para> There exists a library that offers runtime support for
1312         just these headers, and it is called
1313         <filename class="libraryfile">libsupc++.a</filename>. To use it, compile with <command>gcc</command> instead of <command>g++</command>, like so:
1314       </para>
1315
1316       <para>
1317         <command>gcc foo.cc -lsupc++</command>
1318       </para>
1319
1320       <para>
1321         No attempt is made to verify that only the minimal subset
1322         identified above is actually used at compile time. Violations
1323         are diagnosed as undefined symbols at link time.
1324       </para>
1325     </section>
1326
1327     <section xml:id="manual.intro.using.linkage.dynamic" xreflabel="Dynamic and Shared"><info><title>Finding Dynamic or Shared Libraries</title></info>
1328       
1329
1330     <para>
1331       If the only library built is the static library
1332       (<filename class="libraryfile">libstdc++.a</filename>), or if
1333       specifying static linking, this section is can be skipped.  But
1334       if building or using a shared library
1335       (<filename class="libraryfile">libstdc++.so</filename>), then
1336       additional location information will need to be provided.
1337     </para>
1338     <para>
1339       But how?
1340     </para>
1341     <para>
1342 A quick read of the relevant part of the GCC
1343       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
1344       C++ Programs</link>, specifies linking against a C++
1345       library. More details from the
1346       GCC <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/faq.html#rpath">FAQ</link>,
1347       which states <emphasis>GCC does not, by default, specify a
1348       location so that the dynamic linker can find dynamic libraries at
1349       runtime.</emphasis>
1350     </para>
1351     <para>
1352       Users will have to provide this information.
1353     </para>
1354     <para>
1355       Methods vary for different platforms and different styles, and
1356       are printed to the screen during installation. To summarize:
1357     </para>
1358     <itemizedlist>
1359       <listitem>
1360         <para>
1361           At runtime set <literal>LD_LIBRARY_PATH</literal> in your
1362           environment correctly, so that the shared library for
1363           libstdc++ can be found and loaded.  Be certain that you
1364           understand all of the other implications and behavior
1365           of <literal>LD_LIBRARY_PATH</literal> first.
1366         </para>
1367
1368       </listitem>
1369       <listitem>
1370         <para>
1371           Compile the path to find the library at runtime into the
1372           program.  This can be done by passing certain options to
1373           <command>g++</command>, which will in turn pass them on to
1374           the linker.  The exact format of the options is dependent on
1375           which linker you use:
1376         </para>
1377         <itemizedlist>
1378           <listitem>
1379             <para>
1380               GNU ld (default on GNU/Linux):
1381               <literal>-Wl,-rpath,</literal><filename class="directory">destdir/lib</filename>
1382             </para>
1383           </listitem>
1384           <listitem>
1385           <para>
1386             Solaris ld:
1387             <literal>-Wl,-R</literal><filename class="directory">destdir/lib</filename>
1388           </para>
1389           </listitem>
1390         </itemizedlist>
1391       </listitem>
1392       <listitem>
1393         <para>
1394           Some linkers allow you to specify the path to the library by
1395           setting <literal>LD_RUN_PATH</literal> in your environment
1396           when linking.
1397         </para>
1398       </listitem>
1399       <listitem>
1400         <para>
1401           On some platforms the system administrator can configure the
1402           dynamic linker to always look for libraries in
1403           <filename class="directory">destdir/lib</filename>, for example
1404           by using the <command>ldconfig</command> utility on GNU/Linux
1405           or the <command>crle</command> utility on Solaris. This is a
1406           system-wide change which can make the system unusable so if you
1407           are unsure then use one of the other methods described above.
1408         </para>
1409       </listitem>
1410     </itemizedlist>
1411     <para>
1412       Use the <command>ldd</command> utility on the linked executable
1413       to show
1414       which <filename class="libraryfile">libstdc++.so</filename>
1415       library the system will get at runtime.
1416     </para>
1417     <para>
1418       A <filename class="libraryfile">libstdc++.la</filename> file is
1419       also installed, for use with Libtool.  If you use Libtool to
1420       create your executables, these details are taken care of for
1421       you.
1422     </para>
1423     </section>
1424
1425     <section xml:id="manual.intro.using.linkage.experimental" xreflabel="Library Extensions"><info><title>Experimental Library Extensions</title></info>
1426
1427     <para>
1428       GCC 5.3 includes an implementation of the Filesystem library defined
1429       by the technical specification ISO/IEC TS 18822:2015. Because this is
1430       an experimental library extension, not part of the C++ standard, it
1431       is implemented in a separate library,
1432       <filename class="libraryfile">libstdc++fs.a</filename>, and there is
1433       no shared library for it. To use the library you should include
1434       <filename class="headerfile">&lt;experimental/filesystem&gt;</filename>
1435       and link with <option>-lstdc++fs</option>. The library implementation
1436       is incomplete on non-POSIX platforms, specifically Windows support is
1437       rudimentary.
1438     </para>
1439
1440     <para>
1441       Due to the experimental nature of the Filesystem library the usual
1442       guarantees about ABI stability and backwards compatibility do not apply
1443       to it. There is no guarantee that the components in any
1444       <filename class="headerfile">&lt;experimental/xxx&gt;</filename>
1445       header will remain compatible between different GCC releases.
1446     </para>
1447     </section>
1448   </section>
1449
1450   <section xml:id="manual.intro.using.concurrency" xreflabel="Concurrency"><info><title>Concurrency</title></info>
1451     <?dbhtml filename="using_concurrency.html"?>
1452     
1453
1454    <para>This section discusses issues surrounding the proper compilation
1455       of multithreaded applications which use the Standard C++
1456       library.  This information is GCC-specific since the C++
1457       standard does not address matters of multithreaded applications.
1458    </para>
1459
1460     <section xml:id="manual.intro.using.concurrency.prereq" xreflabel="Thread Prereq"><info><title>Prerequisites</title></info>
1461       
1462
1463    <para>All normal disclaimers aside, multithreaded C++ application are
1464       only supported when libstdc++ and all user code was built with
1465       compilers which report (via <code> gcc/g++ -v </code>) the same thread
1466       model and that model is not <emphasis>single</emphasis>.  As long as your
1467       final application is actually single-threaded, then it should be
1468       safe to mix user code built with a thread model of
1469       <emphasis>single</emphasis> with a libstdc++ and other C++ libraries built
1470       with another thread model useful on the platform.  Other mixes
1471       may or may not work but are not considered supported.  (Thus, if
1472       you distribute a shared C++ library in binary form only, it may
1473       be best to compile it with a GCC configured with
1474       --enable-threads for maximal interchangeability and usefulness
1475       with a user population that may have built GCC with either
1476       --enable-threads or --disable-threads.)
1477    </para>
1478    <para>When you link a multithreaded application, you will probably
1479       need to add a library or flag to g++.  This is a very
1480       non-standardized area of GCC across ports.  Some ports support a
1481       special flag (the spelling isn't even standardized yet) to add
1482       all required macros to a compilation (if any such flags are
1483       required then you must provide the flag for all compilations not
1484       just linking) and link-library additions and/or replacements at
1485       link time.  The documentation is weak.  On several targets (including
1486       GNU/Linux, Solaris and various BSDs) -pthread is honored.
1487       Some other ports use other switches.
1488       This is not well documented anywhere other than
1489       in "gcc -dumpspecs" (look at the 'lib' and 'cpp' entries).
1490    </para>
1491
1492    <para>
1493      Some uses of <classname>std::atomic</classname> also require linking
1494      to <filename class="libraryfile">libatomic</filename>.
1495    </para>
1496
1497     </section>
1498
1499     <section xml:id="manual.intro.using.concurrency.thread_safety" xreflabel="Thread Safety"><info><title>Thread Safety</title></info>
1500       
1501
1502 <para>
1503 In the terms of the 2011 C++ standard a thread-safe program is one which
1504 does not perform any conflicting non-atomic operations on memory locations
1505 and so does not contain any data races.
1506 The standard places requirements on the library to ensure that no data
1507 races are caused by the library itself or by programs which use the
1508 library correctly (as described below).
1509 The C++11 memory model and library requirements are a more formal version
1510 of 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
1511 prior to the 2011 standard.
1512 </para>
1513
1514
1515       <para>The library strives to be thread-safe when all of the following
1516          conditions are met:
1517       </para>
1518       <itemizedlist>
1519        <listitem>
1520        <para>The system's libc is itself thread-safe,
1521        </para>
1522        </listitem>
1523        <listitem>
1524          <para>
1525            The compiler in use reports a thread model other than
1526            'single'. This can be tested via output from <code>gcc
1527            -v</code>. Multi-thread capable versions of gcc output
1528            something like this:
1529          </para>
1530 <programlisting>
1531 %gcc -v
1532 Using built-in specs.
1533 ...
1534 Thread model: posix
1535 gcc version 4.1.2 20070925 (Red Hat 4.1.2-33)
1536 </programlisting>
1537
1538 <para>Look for "Thread model" lines that aren't equal to "single."</para>
1539        </listitem>
1540        <listitem>
1541        <para>
1542          Requisite command-line flags are used for atomic operations
1543          and threading. Examples of this include <code>-pthread</code>
1544          and <code>-march=native</code>, although specifics vary
1545          depending on the host environment. See
1546          <link linkend="manual.intro.using.flags">Command Options</link> and
1547          <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html">Machine
1548          Dependent Options</link>.
1549        </para>
1550        </listitem>
1551        <listitem>
1552          <para>
1553            An implementation of the
1554            <filename class="headerfile">atomicity.h</filename> functions
1555            exists for the architecture in question. See the
1556            <link linkend="internals.thread_safety">internals
1557            documentation</link> for more details.
1558        </para>
1559        </listitem>
1560
1561       </itemizedlist>
1562
1563       <para>The user code must guard against concurrent function calls which
1564          access any particular library object's state when one or more of
1565          those accesses modifies the state. An object will be modified by
1566          invoking a non-const member function on it or passing it as a
1567          non-const argument to a library function. An object will not be
1568          modified by invoking a const member function on it or passing it to
1569          a function as a pointer- or reference-to-const.
1570          Typically, the application
1571          programmer may infer what object locks must be held based on the
1572          objects referenced in a function call and whether the objects are
1573          accessed as const or non-const.  Without getting
1574          into great detail, here is an example which requires user-level
1575          locks:
1576       </para>
1577       <programlisting>
1578      library_class_a shared_object_a;
1579
1580      void thread_main () {
1581        library_class_b *object_b = new library_class_b;
1582        shared_object_a.add_b (object_b);   // must hold lock for shared_object_a
1583        shared_object_a.mutate ();          // must hold lock for shared_object_a
1584      }
1585
1586      // Multiple copies of thread_main() are started in independent threads.</programlisting>
1587       <para>Under the assumption that object_a and object_b are never exposed to
1588          another thread, here is an example that does not require any
1589          user-level locks:
1590       </para>
1591       <programlisting>
1592      void thread_main () {
1593        library_class_a object_a;
1594        library_class_b *object_b = new library_class_b;
1595        object_a.add_b (object_b);
1596        object_a.mutate ();
1597      } </programlisting>
1598
1599       <para>All library types are safe to use in a multithreaded program
1600          if objects are not shared between threads or as
1601          long each thread carefully locks out access by any other
1602          thread while it modifies any object visible to another thread.
1603          Unless otherwise documented, the only exceptions to these rules
1604          are atomic operations on the types in
1605          <filename class="headerfile">&lt;atomic&gt;</filename>
1606          and lock/unlock operations on the standard mutex types in
1607          <filename class="headerfile">&lt;mutex&gt;</filename>. These
1608          atomic operations allow concurrent accesses to the same object
1609          without introducing data races.
1610       </para>
1611
1612       <para>The following member functions of standard containers can be
1613          considered to be const for the purposes of avoiding data races:
1614          <code>begin</code>, <code>end</code>, <code>rbegin</code>, <code>rend</code>,
1615          <code>front</code>, <code>back</code>, <code>data</code>,
1616          <code>find</code>, <code>lower_bound</code>, <code>upper_bound</code>,
1617          <code>equal_range</code>, <code>at</code> 
1618          and, except in associative or unordered associative containers,
1619          <code>operator[]</code>. In other words, although they are non-const
1620          so that they can return mutable iterators, those member functions
1621          will not modify the container.
1622          Accessing an iterator might cause a non-modifying access to
1623          the container the iterator refers to (for example incrementing a
1624          list iterator must access the pointers between nodes, which are part
1625          of the container and so conflict with other accesses to the container).
1626       </para>
1627
1628       <para>Programs which follow the rules above will not encounter data
1629          races in library code, even when using library types which share
1630          state between distinct objects.  In the example below the
1631          <code>shared_ptr</code> objects share a reference count, but
1632          because the code does not perform any non-const operations on the
1633          globally-visible object, the library ensures that the reference
1634          count updates are atomic and do not introduce data races:
1635       </para>
1636       <programlisting>
1637     std::shared_ptr&lt;int&gt; global_sp;
1638
1639     void thread_main() {
1640       auto local_sp = global_sp;  // OK, copy constructor's parameter is reference-to-const
1641
1642       int i = *global_sp;         // OK, operator* is const
1643       int j = *local_sp;          // OK, does not operate on global_sp
1644
1645       // *global_sp = 2;          // NOT OK, modifies int visible to other threads      
1646       // *local_sp = 2;           // NOT OK, modifies int visible to other threads      
1647
1648       // global_sp.reset();       // NOT OK, reset is non-const
1649       local_sp.reset();           // OK, does not operate on global_sp
1650     }
1651
1652     int main() {
1653       global_sp.reset(new int(1));
1654       std::thread t1(thread_main);
1655       std::thread t2(thread_main);
1656       t1.join();
1657       t2.join();
1658     }
1659       </programlisting>
1660
1661       <para>For further details of the C++11 memory model see Hans-J. Boehm's
1662       <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://www.hboehm.info/c++mm/">Threads
1663       and memory model for C++</link> pages, particularly the <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.hboehm.info/c++mm/threadsintro.html">introduction</link> 
1664       and <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://www.hboehm.info/c++mm/user-faq.html">FAQ</link>.
1665       </para>
1666
1667   </section>
1668   <section xml:id="manual.intro.using.concurrency.atomics" xreflabel="Atomics"><info><title>Atomics</title></info>
1669     
1670     <para>
1671     </para>
1672   </section>
1673
1674     <section xml:id="manual.intro.using.concurrency.io" xreflabel="IO"><info><title>IO</title></info>
1675       
1676      <para>This gets a bit tricky.  Please read carefully, and bear with me.
1677    </para>
1678
1679     <section xml:id="concurrency.io.structure" xreflabel="Structure"><info><title>Structure</title></info>
1680       
1681    <para>A wrapper
1682       type called <code>__basic_file</code> provides our abstraction layer
1683       for the <code>std::filebuf</code> classes.  Nearly all decisions dealing
1684       with actual input and output must be made in <code>__basic_file</code>.
1685    </para>
1686    <para>A generic locking mechanism is somewhat in place at the filebuf layer,
1687       but is not used in the current code.  Providing locking at any higher
1688       level is akin to providing locking within containers, and is not done
1689       for the same reasons (see the links above).
1690    </para>
1691     </section>
1692
1693     <section xml:id="concurrency.io.defaults" xreflabel="Defaults"><info><title>Defaults</title></info>
1694       
1695    <para>The __basic_file type is simply a collection of small wrappers around
1696       the C stdio layer (again, see the link under Structure).  We do no
1697       locking ourselves, but simply pass through to calls to <code>fopen</code>,
1698       <code>fwrite</code>, and so forth.
1699    </para>
1700    <para>So, for 3.0, the question of "is multithreading safe for I/O"
1701       must be answered with, "is your platform's C library threadsafe
1702       for I/O?"  Some are by default, some are not; many offer multiple
1703       implementations of the C library with varying tradeoffs of threadsafety
1704       and efficiency.  You, the programmer, are always required to take care
1705       with multiple threads.
1706    </para>
1707    <para>(As an example, the POSIX standard requires that C stdio
1708        <code>FILE*</code> operations are atomic.  POSIX-conforming C libraries
1709        (e.g, on Solaris and GNU/Linux) have an internal mutex to serialize
1710        operations on <code>FILE*</code>s.
1711        However, you still need to not do stupid things like calling
1712        <code>fclose(fs)</code> in one thread followed by an access of
1713        <code>fs</code> in another.)
1714    </para>
1715    <para>So, if your platform's C library is threadsafe, then your
1716       <code>fstream</code> I/O operations will be threadsafe at the lowest
1717       level.  For higher-level operations, such as manipulating the data
1718       contained in the stream formatting classes (e.g., setting up callbacks
1719       inside an <code>std::ofstream</code>), you need to guard such accesses
1720       like any other critical shared resource.
1721    </para>
1722     </section>
1723
1724     <section xml:id="concurrency.io.future" xreflabel="Future"><info><title>Future</title></info>
1725       
1726    <para> A
1727       second choice may be available for I/O implementations:  libio.  This is
1728       disabled by default, and in fact will not currently work due to other
1729       issues.  It will be revisited, however.
1730    </para>
1731    <para>The libio code is a subset of the guts of the GNU libc (glibc) I/O
1732       implementation.  When libio is in use, the <code>__basic_file</code>
1733       type is basically derived from FILE.  (The real situation is more
1734       complex than that... it's derived from an internal type used to
1735       implement FILE.  See libio/libioP.h to see scary things done with
1736       vtbls.)  The result is that there is no "layer" of C stdio
1737       to go through; the filebuf makes calls directly into the same
1738       functions used to implement <code>fread</code>, <code>fwrite</code>,
1739       and so forth, using internal data structures.  (And when I say
1740       "makes calls directly," I mean the function is literally
1741       replaced by a jump into an internal function.  Fast but frightening.
1742       *grin*)
1743    </para>
1744    <para>Also, the libio internal locks are used.  This requires pulling in
1745       large chunks of glibc, such as a pthreads implementation, and is one
1746       of the issues preventing widespread use of libio as the libstdc++
1747       cstdio implementation.
1748    </para>
1749    <para>But we plan to make this work, at least as an option if not a future
1750       default.  Platforms running a copy of glibc with a recent-enough
1751       version will see calls from libstdc++ directly into the glibc already
1752       installed.  For other platforms, a copy of the libio subsection will
1753       be built and included in libstdc++.
1754    </para>
1755     </section>
1756
1757     <section xml:id="concurrency.io.alt" xreflabel="Alt"><info><title>Alternatives</title></info>
1758       
1759    <para>Don't forget that other cstdio implementations are possible.  You could
1760       easily write one to perform your own forms of locking, to solve your
1761       "interesting" problems.
1762    </para>
1763     </section>
1764
1765     </section>
1766
1767     <section xml:id="manual.intro.using.concurrency.containers" xreflabel="Containers"><info><title>Containers</title></info>
1768       
1769
1770    <para>This section discusses issues surrounding the design of
1771       multithreaded applications which use Standard C++ containers.
1772       All information in this section is current as of the gcc 3.0
1773       release and all later point releases.  Although earlier gcc
1774       releases had a different approach to threading configuration and
1775       proper compilation, the basic code design rules presented here
1776       were similar.  For information on all other aspects of
1777       multithreading as it relates to libstdc++, including details on
1778       the proper compilation of threaded code (and compatibility between
1779       threaded and non-threaded code), see Chapter 17.
1780    </para>
1781    <para>Two excellent pages to read when working with the Standard C++
1782       containers and threads are
1783       <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
1784       https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/thread_safety.html</link> and
1785       <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
1786       https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/Allocators.html</link>.
1787    </para>
1788    <para><emphasis>However, please ignore all discussions about the user-level
1789       configuration of the lock implementation inside the STL
1790       container-memory allocator on those pages.  For the sake of this
1791       discussion, libstdc++ configures the SGI STL implementation,
1792       not you.  This is quite different from how gcc pre-3.0 worked.
1793       In particular, past advice was for people using g++ to
1794       explicitly define _PTHREADS or other macros or port-specific
1795       compilation options on the command line to get a thread-safe
1796       STL.  This is no longer required for any port and should no
1797       longer be done unless you really know what you are doing and
1798       assume all responsibility.</emphasis>
1799    </para>
1800    <para>Since the container implementation of libstdc++ uses the SGI
1801       code, we use the same definition of thread safety as SGI when
1802       discussing design.  A key point that beginners may miss is the
1803       fourth major paragraph of the first page mentioned above
1804       (<emphasis>For most clients...</emphasis>), which points out that
1805       locking must nearly always be done outside the container, by
1806       client code (that'd be you, not us).  There is a notable
1807       exceptions to this rule.  Allocators called while a container or
1808       element is constructed uses an internal lock obtained and
1809       released solely within libstdc++ code (in fact, this is the
1810       reason STL requires any knowledge of the thread configuration).
1811    </para>
1812    <para>For implementing a container which does its own locking, it is
1813       trivial to provide a wrapper class which obtains the lock (as
1814       SGI suggests), performs the container operation, and then
1815       releases the lock.  This could be templatized <emphasis>to a certain
1816       extent</emphasis>, on the underlying container and/or a locking
1817       mechanism.  Trying to provide a catch-all general template
1818       solution would probably be more trouble than it's worth.
1819    </para>
1820    <para>The library implementation may be configured to use the
1821       high-speed caching memory allocator, which complicates thread
1822       safety issues. For all details about how to globally override
1823       this at application run-time
1824       see <link linkend="manual.intro.using.macros">here</link>. Also
1825       useful are details
1826       on <link linkend="std.util.memory.allocator">allocator</link>
1827       options and capabilities.
1828    </para>
1829
1830     </section>
1831 </section>
1832
1833 <!-- Section 0x : Exception policies, expectations, topics -->
1834 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="xml" href="using_exceptions.xml">
1835 </xi:include>
1836
1837 <!-- Section 0x : Debug -->
1838 <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="xml" href="debug.xml">
1839 </xi:include>
1840
1841 </chapter>