* doc/xml/api.xml: www.fsf.org has moved to https. Also omit
[official-gcc.git] / libstdc++-v3 / doc / xml / faq.xml
blob3e315e2d5ba6719faf3bc4c8f6c83100ae852951
1 <book xmlns="http://docbook.org/ns/docbook" version="5.0">
3 <article xml:id="faq" xreflabel="Frequently Asked Questions">
4 <?dbhtml filename="faq.html"?>
5  
6 <info><title>Frequently Asked Questions</title>
7   
8   <copyright>
9     <year>
10       2008-2018
11     </year>
12     <holder>
13       <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://www.fsf.org">FSF</link>
14     </holder>
15   </copyright>
16 </info>
18 <!-- FAQ starts here -->
19 <qandaset xml:id="faq.faq">
21 <!-- General Information -->
22 <qandadiv xml:id="faq.info" xreflabel="General Information">
24 <qandaentry xml:id="faq.what">
25   <question xml:id="faq.what.q">
26     <para>
27       What is libstdc++?
28     </para>
29   </question>
30   <answer xml:id="faq.what.a">
31     <para>
32      The GNU Standard C++ Library v3 is an ongoing project to
33      implement the ISO 14882 C++ Standard Library as described in
34      clauses 20 through 33 and annex D (prior to the 2017 standard
35      the library clauses started with 17).  For those who want to see
36      exactly how far the project has come, or just want the latest
37      bleeding-edge code, the up-to-date source is available over
38      anonymous SVN, and can be browsed over the
39      <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://gcc.gnu.org/svn.html">web</link>.
40     </para> 
42     <para>
43     N.B. The library is called libstdc++ <emphasis>not</emphasis> stdlibc++.
44     </para>
45   </answer>
46 </qandaentry>
48 <qandaentry xml:id="faq.why">
49   <question xml:id="q-why">
50     <para>
51       Why should I use libstdc++?
52     </para>
53   </question>
54   <answer xml:id="a-why">
55     <para>
56     The completion of the initial ISO C++ standardization effort gave the C++
57     community a powerful set of reuseable tools in the form of the C++
58     Standard Library.  However, for several years C++ implementations were
59     (as the Draft Standard used to say) <quote>incomplet and
60     incorrekt</quote>, and many suffered from limitations of the compilers
61     that used them.
62     </para> 
63     <para>
64     The GNU compiler collection
65     (<command>gcc</command>, <command>g++</command>, etc) is widely
66     considered to be one of the leading compilers in the world.  Its
67     development is overseen by the
68     <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://gcc.gnu.org/">GCC team</link>.  All of
69     the rapid development and near-legendary
70     <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://gcc.gnu.org/buildstat.html">portability</link>
71     that are the hallmarks of an open-source project are applied to libstdc++.
72     </para> 
73     <para>
74     All of the standard classes and functions from C++98/C++03, C++11 and C++14
75     (such as <classname>string</classname>,
76     <classname>vector&lt;&gt;</classname>, iostreams, algorithms etc.)
77     are freely available and attempt to be fully compliant.
78     Work is ongoing to complete support for the current revision of the
79     ISO C++ Standard.
80     </para>
81   </answer>
82 </qandaentry>
84 <qandaentry xml:id="faq.who">
85   <question xml:id="q-who">
86     <para>
87       Who's in charge of it?
88     </para>
89   </question>
90   <answer xml:id="a-who">
91     <para>
92      The libstdc++ project is contributed to by several developers
93      all over the world, in the same way as GCC or the Linux kernel.
94      The current maintainers are listed in the
95      <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://gcc.gnu.org/viewcvs/gcc/trunk/MAINTAINERS?view=co"><filename>MAINTAINERS</filename></link>
96      file (look for "c++ runtime libs").
97     </para>
98     <para>
99     Development and discussion is held on the libstdc++ mailing
100     list.  Subscribing to the list, or searching the list
101     archives, is open to everyone.  You can read instructions for
102     doing so on the <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://gcc.gnu.org/lists.html">GCC mailing lists</link> page.
103     If you have questions, ideas, code, or are just curious, sign up!
104     </para> 
105   </answer>
106 </qandaentry>
108 <qandaentry xml:id="faq.when">
109   <question xml:id="q-when">
110     <para>
111       When is libstdc++ going to be finished?
112     </para>
113   </question>
114   <answer xml:id="a-when">
115     <para>
116     Nathan Myers gave the best of all possible answers, responding to
117     a Usenet article asking this question: <emphasis>Sooner, if you
118     help.</emphasis>
119     </para> 
120   </answer>
121 </qandaentry>
123 <qandaentry xml:id="faq.how">
124   <question xml:id="q-how">
125     <para>
126       How do I contribute to the effort?
127     </para>
128   </question>
129   <answer xml:id="a-how">
130     <para>
131     See the <link linkend="appendix.contrib">Contributing</link> section in
132     the manual. Subscribing to the mailing list (see above, or
133     the homepage) is a very good idea if you have something to
134     contribute, or if you have spare time and want to
135     help. Contributions don't have to be in the form of source code;
136     anybody who is willing to help write documentation, for example,
137     or has found a bug in code that we all thought was working and is
138     willing to provide details, is more than welcome!
139     </para> 
140   </answer>
141 </qandaentry>
143 <qandaentry xml:id="faq.whereis_old">
144   <question xml:id="q-whereis_old">
145     <para>
146       What happened to the older libg++? I need that!
147     </para>
148   </question>
149   <answer xml:id="a-whereis_old">
150     <para>
151     The last libg++ README states
152     <quote>This package is considered obsolete and is no longer
153     being developed.</quote>
154     It should not be used for new projects, and won't even compile with
155     recent releases of GCC (or most other C++ compilers).
156     </para> 
157     <para>
158     More information can be found in the
159     <link linkend="manual.appendix.porting.backwards">Backwards
160     Compatibility</link> section of the libstdc++ manual.
161     </para>
162   </answer>
163 </qandaentry>
165 <qandaentry xml:id="faq.more_questions">
166   <question xml:id="q-more_questions">
167     <para>
168       What if I have more questions?
169     </para>
170   </question>
171   <answer xml:id="a-more_questions">
172     <para>
173     If you have read the documentation, and your question remains
174     unanswered, then just ask the mailing list. At present, you do not
175     need to be subscribed to the list to send a message to it.  More
176     information is available on the homepage (including how to browse
177     the list archives); to send a message to the list,
178     use <email>libstdc++@gcc.gnu.org</email>.
179     </para> 
181     <para> 
182     If you have a question that you think should be included
183     here, or if you have a question <emphasis>about</emphasis> a question/answer
184     here, please send email to the libstdc++ mailing list, as above.
185     </para> 
186   </answer>
187 </qandaentry>
189 </qandadiv>
191 <!-- License -->
192 <qandadiv xml:id="faq.license" xreflabel="License QA">
195 <qandaentry xml:id="faq.license.what">
196   <question xml:id="q-license.what">
197     <para>
198       What are the license terms for libstdc++?
199     </para>
200   </question>
201   <answer xml:id="a-license.what">
202     <para>
203     See <link linkend="manual.intro.status.license">our license description</link>
204     for these and related questions.
205     </para> 
206   </answer>
207 </qandaentry>
209 <qandaentry xml:id="faq.license.any_program">
210   <question xml:id="q-license.any_program">
211     <para>
212       So any program which uses libstdc++ falls under the GPL?
213     </para>
214   </question>
215   <answer xml:id="a-license.any_program">
216     <para>
217      No. The special exception permits use of the library in
218      proprietary applications.
219     </para> 
220   </answer>
221 </qandaentry>
224 <qandaentry xml:id="faq.license.lgpl">
225   <question xml:id="q-license.lgpl">
226     <para>
227       How is that different from the GNU {Lesser,Library} GPL?
228     </para>
229   </question>
230   <answer xml:id="a-license.lgpl">
231     <para>
232       The LGPL requires that users be able to replace the LGPL code with a
233      modified version; this is trivial if the library in question is a C
234      shared library.  But there's no way to make that work with C++, where
235      much of the library consists of inline functions and templates, which
236      are expanded inside the code that uses the library.  So to allow people
237      to replace the library code, someone using the library would have to
238      distribute their own source, rendering the LGPL equivalent to the GPL.
239     </para> 
240   </answer>
241 </qandaentry>
243 <qandaentry xml:id="faq.license.what_restrictions">
244   <question xml:id="q-license.what_restrictions">
245     <para>
246       I see. So, what restrictions are there on programs that use the library?
247     </para>
248   </question>
249   <answer xml:id="a-license.what_restrictions">
250     <para>
251       None.  We encourage such programs to be released as free software,
252      but we won't punish you or sue you if you choose otherwise.
253     </para> 
254   </answer>
255 </qandaentry>
257 </qandadiv>
259 <!-- Installation -->
260 <qandadiv xml:id="faq.installation" xreflabel="Installation">
263 <qandaentry xml:id="faq.how_to_install">
264   <question xml:id="q-how_to_install">
265     <para>How do I install libstdc++?
266     </para>
267   </question>
268   <answer xml:id="a-how_to_install">
269     <para>
270     Often libstdc++ comes pre-installed as an integral part of many
271     existing GNU/Linux and Unix systems, as well as many embedded
272     development tools. It may be necessary to install extra
273     development packages to get the headers, or the documentation, or
274     the source: please consult your vendor for details.
275     </para> 
276     <para> 
277     To build and install from the GNU GCC sources, please consult the 
278     <link linkend="manual.intro.setup">setup
279     documentation</link> for detailed
280     instructions. You may wish to browse those files ahead
281     of time to get a feel for what's required.
282     </para> 
283   </answer>
284 </qandaentry>
286 <qandaentry xml:id="faq.how_to_get_sources">
287   <question xml:id="q-how_to_get_sources">
288     <para>How does one get current libstdc++ sources?
289     </para>
290   </question>
291   <answer xml:id="a-how_to_get_sources">
292     <para>
293     Libstdc++ sources for all official releases can be obtained as
294     part of the GCC sources, available from various sites and
295     mirrors. A full <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://gcc.gnu.org/mirrors.html">list of
296     download sites</link> is provided on the main GCC site.
297     </para>
298     <para>
299     Current libstdc++ sources can always be checked out of the main
300     GCC source repository using the appropriate version control
301     tool. At this time, that tool
302     is <application>Subversion</application>.
303     </para>
304     <para>
305     <application>Subversion</application>, or <acronym>SVN</acronym>, is
306     one of several revision control packages.  It was selected for GNU
307     projects because it's free (speech), free (beer), and very high
308     quality.  The <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://subversion.tigris.org"> Subversion
309     home page</link> has a better description.
310     </para>
311     <para>
312     The <quote>anonymous client checkout</quote> feature of SVN is
313     similar to anonymous FTP in that it allows anyone to retrieve
314     the latest libstdc++ sources.
315     </para> 
316     <para>
317     For more information
318     see <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://gcc.gnu.org/svn.html"><acronym>SVN</acronym>
319     details</link>.
320     </para>
321   </answer>
322 </qandaentry>
324 <qandaentry xml:id="faq.how_to_test">
325   <question xml:id="q-how_to_test">
326     <para>How do I know if it works?
327     </para>
328   </question>
329   <answer xml:id="a-how_to_test">
330     <para>
331     Libstdc++ comes with its own validation testsuite, which includes
332     conformance testing, regression testing, ABI testing, and
333     performance testing. Please consult the 
334     <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/install/test.html">testing
335     documentation</link> for GCC and
336     <link linkend="manual.intro.setup.test">Testing</link> in the libstdc++
337     manual for more details.
338     </para> 
339     <para>
340     If you find bugs in the testsuite programs themselves, or if you
341     think of a new test program that should be added to the suite,
342     <emphasis>please</emphasis> write up your idea and send it to the list!
343     </para>
344   </answer>
345 </qandaentry>
347 <qandaentry xml:id="faq.how_to_set_paths">
348   <question xml:id="q-how_to_set_paths">
349     <para>How do I insure that the dynamically linked library will be found?
350     </para>
351   </question>
352   <answer xml:id="a-how_to_set_paths">
353     <para>
354     Depending on your platform and library version, the error message might
355     be similar to one of the following:
356     </para>
358     <screen>
359     ./a.out: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
361     /usr/libexec/ld-elf.so.1: Shared object "libstdc++.so.6" not found
362     </screen>
364     <para>
365     This doesn't mean that the shared library isn't installed, only
366     that the dynamic linker can't find it. When a dynamically-linked
367     executable is run the linker finds and loads the required shared
368     libraries by searching a pre-configured list of directories. If
369     the directory where you've installed libstdc++ is not in this list
370     then the libraries won't be found.
371     </para>
373     <para>
374     If you already have an older version of libstdc++ installed then the
375     error might look like one of the following instead:
376     </para>
378     <screen>
379     ./a.out: /usr/lib/libstdc++.so.6: version `GLIBCXX_3.4.20' not found
380     ./a.out: /usr/lib/libstdc++.so.6: version `CXXABI_1.3.8' not found
381     </screen>
383     <para>
384     This means the linker found <filename>/usr/lib/libstdc++.so.6</filename>
385     but that library belongs to an older version of GCC than was used to
386     compile and link the program <filename>a.out</filename> (or some part
387     of it). The program depends on code defined in the newer libstdc++
388     that belongs to the newer version of GCC, so the linker must be told
389     how to find the newer libstdc++ shared library.
390     </para>
392     <para>
393     The simplest way to fix this is
394     to use the <envar>LD_LIBRARY_PATH</envar> environment variable,
395     which is a colon-separated list of directories in which the linker
396     will search for shared libraries:
397     </para>
399     <screen><command>
400     export LD_LIBRARY_PATH=${prefix}/lib:$LD_LIBRARY_PATH
401     </command></screen>
403     <para>
404     Here the shell variable <varname>${prefix}</varname> is assumed to contain
405     the directory prefix where GCC was installed to. The directory containing
406     the library might depend on whether you want the 32-bit or 64-bit copy
407     of the library, so for example would be
408     <filename class="directory">${prefix}/lib64</filename> on some systems.
409     The exact environment variable to use will depend on your
410     platform, e.g. <envar>DYLD_LIBRARY_PATH</envar> for Darwin,
411     <envar>LD_LIBRARY_PATH_32</envar>/<envar>LD_LIBRARY_PATH_64</envar>
412     for Solaris 32-/64-bit,
413     and <envar>SHLIB_PATH</envar> for HP-UX.
414     </para>
415     <para>
416     See the man pages for <command>ld</command>, <command>ldd</command>
417     and <command>ldconfig</command> for more information. The dynamic
418     linker has different names on different platforms but the man page
419     is usually called something such as <filename>ld.so</filename>,
420     <filename>rtld</filename> or <filename>dld.so</filename>.
421     </para>
422     <para>
423     Using <envar>LD_LIBRARY_PATH</envar> is not always the best solution,
424     <link linkend="manual.intro.using.linkage.dynamic">Finding Dynamic or Shared
425     Libraries</link> in the manual gives some alternatives.
426     </para>
427   </answer>
428 </qandaentry>
430 <qandaentry xml:id="faq.what_is_libsupcxx">
431   <question xml:id="q-what_is_libsupcxx">
432     <para>
433       What's libsupc++?
434     </para>
435   </question>
436   <answer xml:id="a-what_is_libsupcxx">
437     <para>
438       If the only functions from <filename class="libraryfile">libstdc++.a</filename>
439       which you need are language support functions (those listed in
440       <link linkend="std.support">clause 18</link> of the
441       standard, e.g., <function>new</function> and
442       <function>delete</function>), then try linking against
443       <filename class="libraryfile">libsupc++.a</filename>, which is a subset of
444       <filename class="libraryfile">libstdc++.a</filename>.  (Using <command>gcc</command>
445       instead of <command>g++</command> and explicitly linking in
446       <filename class="libraryfile">libsupc++.a</filename> via <option>-lsupc++</option>
447       for the final link step will do it).  This library contains only
448       those support routines, one per object file.  But if you are
449       using anything from the rest of the library, such as IOStreams
450       or vectors, then you'll still need pieces from
451       <filename class="libraryfile">libstdc++.a</filename>.
452     </para> 
453   </answer>
454 </qandaentry>
456 <qandaentry xml:id="faq.size">
457   <question xml:id="q-size">
458     <para>
459       This library is HUGE!
460     </para>
461   </question>
462   <answer xml:id="a-size">
463     <para>
464     Usually the size of libraries on disk isn't noticeable.  When a
465     link editor (or simply <quote>linker</quote>) pulls things from a
466     static archive library, only the necessary object files are copied
467     into your executable, not the entire library.  Unfortunately, even
468     if you only need a single function or variable from an object file,
469     the entire object file is extracted.  (There's nothing unique to C++
470     or libstdc++ about this; it's just common behavior, given here
471     for background reasons.)
472     </para>
473     <para>
474     Some of the object files which make up
475     <filename class="libraryfile">libstdc++.a</filename> are rather large.
476     If you create a statically-linked executable with
477     <option>-static</option>, those large object files are suddenly part
478     of your executable.  Historically the best way around this was to
479     only place a very few functions (often only a single one) in each
480     source/object file; then extracting a single function is the same
481     as extracting a single <filename>.o</filename> file.  For libstdc++ this
482     is only possible to a certain extent; the object files in question contain
483     template classes and template functions, pre-instantiated, and
484     splitting those up causes severe maintenance headaches.
485     </para> 
486     <para>
487     On supported platforms, libstdc++ takes advantage of garbage
488     collection in the GNU linker to get a result similar to separating
489     each symbol into a separate source and object files. On these platforms,
490     GNU ld can place each function and variable into its own
491     section in a <filename>.o</filename> file.  The GNU linker can then perform
492     garbage collection on unused sections; this reduces the situation to only
493     copying needed functions into the executable, as before, but all
494     happens automatically.
495     </para>
496   </answer>
497 </qandaentry>
499 </qandadiv>
502 <!-- Platform-Specific Issues -->
503 <qandadiv xml:id="faq.platform-specific" xreflabel="Platform-Specific Issues">
506 <qandaentry xml:id="faq.other_compilers">
507   <question xml:id="q-other_compilers">
508     <para>
509       Can libstdc++ be used with non-GNU compilers?
510     </para>
511   </question>
512   <answer xml:id="a-other_compilers">
513     <para>
514     Perhaps.
515     </para> 
516     <para>
517     Since the goal of ISO Standardization is for all C++
518     implementations to be able to share code, libstdc++ should be
519     usable under any ISO-compliant compiler, at least in theory.
520     </para> 
521     <para>
522     However, the reality is that libstdc++ is targeted and optimized
523     for GCC/G++. This means that often libstdc++ uses specific,
524     non-standard features of G++ that are not present in older
525     versions of proprietary compilers. It may take as much as a year or two
526     after an official release of GCC that contains these features for
527     proprietary tools to support these constructs.
528     </para>
529     <para>
530     Recent versions of libstdc++ are known to work with the Clang compiler.
531     In the near past, specific released versions of libstdc++ have
532     been known to work with versions of the EDG C++ compiler, and
533     vendor-specific proprietary C++ compilers such as the Intel ICC
534     C++ compiler.
535     </para> 
537   </answer>
538 </qandaentry>
540 <qandaentry xml:id="faq.solaris_long_long">
541   <question xml:id="q-solaris_long_long">
542     <para>
543       No '<type>long long</type>' type on Solaris?
544     </para>
545   </question>
546   <answer xml:id="a-solaris_long_long">
547     <note>
548        <para>This answer is old and probably no longer be relevant.</para>
549     </note>
550     <para>
551     By default we try to support the C99 <type>long long</type> type.
552     This requires that certain functions from your C library be present.
553     </para> 
554     <para> 
555     Up through release 3.0.2 the platform-specific tests performed by
556     libstdc++ were too general, resulting in a conservative approach
557     to enabling the <type>long long</type> code paths. The most
558     commonly reported platform affected was Solaris.
559     </para> 
560     <para> 
561     This has been fixed for libstdc++ releases greater than 3.0.3.
562     </para> 
563   </answer>
564 </qandaentry>
566 <qandaentry xml:id="faq.predefined">
567   <question xml:id="q-predefined">
568     <para>
569       <constant>_XOPEN_SOURCE</constant> and <constant>_GNU_SOURCE</constant> are always defined?
570     </para>
571   </question>
572   <answer xml:id="a-predefined">
573       <para>On Solaris, <command>g++</command> (but not <command>gcc</command>)
574          always defines the preprocessor macro
575          <constant>_XOPEN_SOURCE</constant>.  On GNU/Linux, the same happens
576          with <constant>_GNU_SOURCE</constant>.  (This is not an exhaustive list;
577          other macros and other platforms are also affected.)
578       </para>
579       <para>These macros are typically used in C library headers, guarding new
580          versions of functions from their older versions.  The C++98 standard
581          library includes the C standard library, but it requires the C90
582          version, which for backwards-compatibility reasons is often not the
583          default for many vendors.
584       </para>
585       <para>More to the point, the C++ standard requires behavior which is only
586          available on certain platforms after certain symbols are defined.
587          Usually the issue involves I/O-related typedefs.  In order to
588          ensure correctness, the compiler simply predefines those symbols.
589       </para>
590       <para>Note that it's not enough to <literal>#define</literal> them only when the library is
591          being built (during installation).  Since we don't have an 'export'
592          keyword, much of the library exists as headers, which means that
593          the symbols must also be defined as your programs are parsed and
594          compiled.
595       </para>
596       <para>To see which symbols are defined, look for
597          <varname>CPLUSPLUS_CPP_SPEC</varname> in
598          the gcc config headers for your target (and try changing them to
599          see what happens when building complicated code).  You can also run
600          <command>g++ -E -dM - &lt; /dev/null"</command> to display
601          a list of predefined macros for any particular installation.
602       </para>
603       <para>This has been discussed on the mailing lists
604          <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/cgi-bin/htsearch?method=and&amp;format=builtin-long&amp;sort=score&amp;words=_XOPEN_SOURCE+Solaris">quite a bit</link>.
605       </para>
606       <para>This method is something of a wart.  We'd like to find a cleaner
607          solution, but nobody yet has contributed the time.
608       </para>
610   </answer>
611 </qandaentry>
613 <qandaentry xml:id="faq.darwin_ctype">
614   <question xml:id="q-darwin_ctype">
615     <para>
616       Mac OS X <filename class="headerfile">ctype.h</filename> is broken! How can I fix it?
617     </para>
618   </question>
619   <answer xml:id="a-darwin_ctype">
620       <note>
621          <para>This answer is old and probably no longer be relevant.</para>
622       </note>
623       <para>
624          This was a long-standing bug in the OS X support.  Fortunately, the
625          <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/ml/gcc/2002-03/msg00817.html">patch</link>
626          was quite simple, and well-known.
627       </para>
629   </answer>
630 </qandaentry>
632 <qandaentry xml:id="faq.threads_i386">
633   <question xml:id="q-threads_i386">
634     <para>
635       Threading is broken on i386?
636     </para>
637   </question>
638   <answer xml:id="a-threads_i386">
639       <note>
640          <para>This answer is old and probably no longer be relevant.</para>
641       </note>
642       <para>Support for atomic integer operations was broken on i386
643          platforms.  The assembly code accidentally used opcodes that are
644          only available on the i486 and later.  So if you configured GCC
645          to target, for example, i386-linux, but actually used the programs
646          on an i686, then you would encounter no problems.  Only when
647          actually running the code on a i386 will the problem appear.
648       </para>
649       <para>This is fixed in 3.2.2.
650       </para>
652   </answer>
653 </qandaentry>
655 <qandaentry xml:id="faq.atomic_mips">
656   <question xml:id="q-atomic_mips">
657     <para>
658       MIPS atomic operations
659     </para>
660   </question>
661   <answer xml:id="a-atomic_mips">
662     <note>
663       <para>This answer is old and probably no longer be relevant.</para>
664     </note>
665     <para>
666     The atomic locking routines for MIPS targets requires MIPS II
667     and later.  A patch went in just after the 3.3 release to
668     make mips* use the generic implementation instead.  You can also
669     configure for mipsel-elf as a workaround.
670     </para>
671     <para>    
672     The mips*-*-linux* port continues to use the MIPS II routines, and more
673     work in this area is expected.
674     </para> 
675   </answer>
676 </qandaentry>
678 <qandaentry xml:id="faq.linux_glibc">
679   <question xml:id="q-linux_glibc">
680     <para>
681       Recent GNU/Linux glibc required?
682     </para>
683   </question>
684   <answer xml:id="a-linux_glibc">
685       <para>When running on GNU/Linux, libstdc++ 3.2.1 (shared library version
686          5.0.1) and later uses localization and formatting code from the system
687          C library (glibc) version 2.2.5 which contains necessary bugfixes.
688          All GNU/Linux distros make more recent versions available now.
689          libstdc++ 4.6.0 and later require glibc 2.3 or later for this
690          localization and formatting code.
691       </para>
692       <para>The guideline is simple:  the more recent the C++ library, the
693          more recent the C library.  (This is also documented in the main
694          GCC installation instructions.)
695       </para>
697   </answer>
698 </qandaentry>
700 <qandaentry xml:id="faq.freebsd_wchar">
701   <question xml:id="q-freebsd_wchar">
702     <para>
703       Can't use <type>wchar_t</type>/<classname>wstring</classname> on FreeBSD
704     </para>
705   </question>
706   <answer xml:id="a-freebsd_wchar">
707     <note>
708       <para>This answer is old and probably no longer be relevant.</para>
709     </note>
710     <para>
711     Older versions of FreeBSD's C library do not have sufficient
712     support for wide character functions, and as a result the
713     libstdc++ configury decides that <type>wchar_t</type> support should be
714     disabled. In addition, the libstdc++ platform checks that
715     enabled <type>wchar_t</type> were quite strict, and not granular
716     enough to detect when the minimal support to
717     enable <type>wchar_t</type> and C++ library structures
718     like <classname>wstring</classname> were present. This impacted Solaris,
719     Darwin, and BSD variants, and is fixed in libstdc++ versions post 4.1.0.
720     </para> 
721     <para> 
722     </para> 
723   </answer>
724 </qandaentry>
726 </qandadiv>
729 <!-- Known Bugs -->
730 <qandadiv xml:id="faq.known_bugs" xreflabel="Known Bugs">
733 <qandaentry xml:id="faq.what_works">
734   <question xml:id="q-what_works">
735     <para>
736       What works already?
737     </para>
738   </question>
739   <answer xml:id="a-what_works">
740     <para>
741     Short answer: Pretty much everything <emphasis>works</emphasis>
742     except for some corner cases.  Support for localization
743     in <classname>locale</classname> may be incomplete on some non-GNU
744     platforms. Also dependent on the underlying platform is support
745     for <type>wchar_t</type> and <type>long
746     long</type> specializations, and details of thread support.
747     </para>
748     <para>    
749     Long answer: See the implementation status pages for 
750     <link linkend="status.iso.1998">C++98</link>,
751     <link linkend="status.iso.tr1">TR1</link>, and 
752     <link linkend="status.iso.2011">C++11</link>.
753     <link linkend="status.iso.2014">C++14</link>.
754     </para> 
755   </answer>
756 </qandaentry>
758 <qandaentry xml:id="faq.standard_bugs">
759   <question xml:id="q-standard_bugs">
760     <para>
761       Bugs in the ISO C++ language or library specification
762     </para>
763   </question>
764   <answer xml:id="a-standard_bugs">
765     <para>
766     Unfortunately, there are some. 
767     </para>
768     <para>
769     For those people who are not part of the ISO Library Group
770     (i.e., nearly all of us needing to read this page in the first
771     place), a public list of the library defects is occasionally
772     published on <link xmlns:xlink="http://www.w3.org/1999/xlink"
773     xlink:href="http://www.open-std.org/jtc1/sc22/wg21/">the WG21
774     website</link>.
775     Many of these issues have resulted in
776     <link linkend="manual.intro.status.bugs.iso">code changes in libstdc++</link>.
777     </para> 
778     <para>
779     If you think you've discovered a new bug that is not listed,
780     please post a message describing your problem to the author of
781     the library issues list.
782     </para>
783   </answer>
784 </qandaentry>
786 <qandaentry xml:id="faq.compiler_bugs">
787   <question xml:id="q-compiler_bugs">
788     <para>
789       Bugs in the compiler (gcc/g++) and not libstdc++
790     </para>
791   </question>
792   <answer xml:id="a-compiler_bugs">
793     <para>
794     On occasion, the compiler is wrong. Please be advised that this
795     happens much less often than one would think, and avoid jumping to
796     conclusions.
797     </para>
798     <para>
799     First, examine the ISO C++ standard. Second, try another compiler
800     or an older version of the GNU compilers. Third, you can find more
801     information on the libstdc++ and the GCC mailing lists: search
802     these lists with terms describing your issue.
803     </para> 
804     <para> 
805     Before reporting a bug, please examine the
806     <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://gcc.gnu.org/bugs/">bugs database</link>, with the
807     component set to <quote>c++</quote>.
808     </para> 
809   </answer>
810 </qandaentry>
812 </qandadiv>
814 <!-- Known Non-Bugs -->
815 <qandadiv xml:id="faq.known_non-bugs" xreflabel="Known Non-Bugs">
818 <qandaentry xml:id="faq.stream_reopening_fails">
819   <question xml:id="q-stream_reopening_fails">
820     <para>
821       Reopening a stream fails
822     </para>
823   </question>
824   <answer xml:id="a-stream_reopening_fails">
825     <note>
826       <para>This answer is old and probably no longer be relevant.</para>
827     </note>
828     <para>
829     Prior to GCC 4.0 this was one of the most-reported non-bug reports.
830     Executing a sequence like this would fail:
831     </para>
833     <programlisting>
834     #include &lt;fstream&gt;
835     ...
836     std::fstream  fs("a_file");
837     // .
838     // . do things with fs...
839     // .
840     fs.close();
841     fs.open("a_new_file");
842     </programlisting>
843     
844     <para>
845     All operations on the re-opened <varname>fs</varname> would fail, or at
846     least act very strangely, especially if <varname>fs</varname> reached the
847     EOF state on the previous file.
848     The original C++98 standard did not specify behavior in this case, and
849     the <link linkend="manual.bugs.dr22">resolution of DR #22</link> was to
850     leave the state flags unchanged on a successful call to
851     <function>open()</function>.
852     You had to insert a call to <function>fs.clear()</function> between the
853     calls to <function>close()</function> and <function>open()</function>,
854     and then everything will work as expected.
855     <emphasis>Update:</emphasis> For GCC 4.0 we implemented the resolution
856     of <link linkend="manual.bugs.dr409">DR #409</link> and
857     <function>open()</function>
858     now calls <function>clear()</function> on success.
859     </para> 
860   </answer>
861 </qandaentry>
863 <qandaentry xml:id="faq.wefcxx_verbose">
864   <question xml:id="q-wefcxx_verbose">
865     <para>
866       -Weffc++ complains too much
867     </para>
868   </question>
869   <answer xml:id="a-wefcxx_verbose">
870     <para>
871     Many warnings are emitted when <option>-Weffc++</option> is used.  Making
872     libstdc++ <option>-Weffc++</option>-clean is not a goal of the project,
873     for a few reasons.  Mainly, that option tries to enforce
874     object-oriented programming, while the Standard Library isn't
875     necessarily trying to be OO. The option also enforces outdated guidelines
876     from old editions of the books, and the advice isn't all relevant to
877     modern C++ (especially C++11 and later).
878     </para> 
879     <para>
880     We do, however, try to have libstdc++ sources as clean as possible. If
881     you see some simple changes that pacify <option>-Weffc++</option>
882     without other drawbacks, send us a patch.
883     </para>
884   </answer>
885 </qandaentry>
887 <qandaentry xml:id="faq.ambiguous_overloads">
888   <question xml:id="q-ambiguous_overloads">
889     <para>
890       Ambiguous overloads after including an old-style header
891     </para>
892   </question>
893   <answer xml:id="a-ambiguous_overloads">
894     <para>
895     Another problem is the <literal>rel_ops</literal> namespace and the template
896     comparison operator functions contained therein.  If they become
897     visible in the same namespace as other comparison functions
898     (e.g., <quote>using</quote> them and the
899     <filename class="headerfile">&lt;iterator&gt;</filename> header),
900     then you will suddenly be faced with huge numbers of ambiguity
901     errors.  This was discussed on the mailing list; Nathan Myers
902     <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/ml/libstdc++/2001-01/msg00247.html">sums
903       things up here</link>.  The collisions with vector/string iterator
904     types have been fixed for 3.1.
905     </para> 
906   </answer>
907 </qandaentry>
909 <qandaentry xml:id="faq.v2_headers">
910   <question xml:id="q-v2_headers">
911     <para>
912       The g++-3 headers are <emphasis>not ours</emphasis>
913     </para>
914   </question>
915   <answer xml:id="a-v2_headers">
916     <note>
917       <para>This answer is old and probably no longer be relevant.</para>
918     </note>
919       <para>
920         If you are using headers in
921         <filename class="directory">${prefix}/include/g++-3</filename>, or if
922         the installed library's name looks like
923         <filename class="libraryfile">libstdc++-2.10.a</filename> or
924         <filename class="libraryfile">libstdc++-libc6-2.10.so</filename>, then
925         you are using the old libstdc++-v2 library, which is non-standard and
926         unmaintained.  Do not report problems with -v2 to the -v3
927         mailing list.
928       </para>
929       <para>
930         For GCC versions 3.0 and 3.1 the libstdc++ header files are installed in
931         <filename class="directory">${prefix}/include/g++-v3</filename>
932         (see the 'v'?).  Starting with version 3.2 the headers are installed in
933         <filename class="directory">${prefix}/include/c++/${version}</filename>
934         as this prevents headers from previous versions being found by mistake.
935       </para>
937   </answer>
938 </qandaentry>
940 <qandaentry xml:id="faq.boost_concept_checks">
941   <question xml:id="q-boost_concept_checks">
942     <para>
943       Errors about <emphasis>*Concept</emphasis> and
944       <emphasis>constraints</emphasis> in the STL
945     </para>
946   </question>
947   <answer xml:id="a-boost_concept_checks">
948     <para>
949     If you see compilation errors containing messages about
950     <errortext>foo Concept</errortext> and something to do with a
951     <errortext>constraints</errortext> member function, then most
952     likely you have violated one of the requirements for types used
953     during instantiation of template containers and functions.  For
954     example, EqualityComparableConcept appears if your types must be
955     comparable with == and you have not provided this capability (a
956     typo, or wrong visibility, or you just plain forgot, etc).
957     </para>
958     <para>
959     More information, including how to optionally enable/disable the
960     checks, is available in the
961     <link linkend="std.diagnostics.concept_checking">Diagnostics</link>.
962     chapter of the manual.
963     </para> 
964   </answer>
965 </qandaentry>
967 <qandaentry xml:id="faq.dlopen_crash">
968   <question xml:id="q-dlopen_crash">
969     <para>
970       Program crashes when using library code in a
971       dynamically-loaded library
972     </para>
973   </question>
974   <answer xml:id="a-dlopen_crash">
975     <para>
976     If you are using the C++ library across dynamically-loaded
977     objects, make certain that you are passing the correct options
978     when compiling and linking:
979     </para>
981     <literallayout class="normal">
982     Compile your library components:
983     <command>g++ -fPIC -c a.cc</command>
984     <command>g++ -fPIC -c b.cc</command>
985     ...
986     <command>g++ -fPIC -c z.cc</command>
988     Create your library:
989     <command>g++ -fPIC -shared -rdynamic -o libfoo.so a.o b.o ... z.o</command>
991     Link the executable:
992     <command>g++ -fPIC -rdynamic -o foo ... -L. -lfoo -ldl</command>
993     </literallayout>
994   </answer>
995 </qandaentry>
997 <qandaentry xml:id="faq.memory_leaks">
998   <question xml:id="q-memory_leaks">
999     <para>
1000       <quote>Memory leaks</quote> in containers
1001     </para>
1002   </question>
1003   <answer xml:id="a-memory_leaks">
1004     <note>
1005       <para>This answer is old and probably no longer be relevant.</para>
1006     </note>
1007     <para>
1008     A few people have reported that the standard containers appear
1009     to leak memory when tested with memory checkers such as
1010     <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://valgrind.org/"><command>valgrind</command></link>.
1011     Under some (non-default) configurations the library's allocators keep
1012     free memory in a
1013     pool for later reuse, rather than returning it to the OS.  Although
1014     this memory is always reachable by the library and is never
1015     lost, memory debugging tools can report it as a leak.  If you
1016     want to test the library for memory leaks please read
1017     <link linkend="debug.memory">Tips for memory leak hunting</link>
1018     first.
1019     </para> 
1020   </answer>
1021 </qandaentry>
1023 <qandaentry xml:id="faq.list_size_on">
1024   <question xml:id="q-list_size_on">
1025     <para>
1026       <code>list::size()</code> is O(n)!
1027     </para>
1028   </question>
1029   <answer xml:id="a-list_size_on">
1030     <para>
1031     See
1032     the <link linkend="std.containers">Containers</link>
1033     chapter.
1034     </para> 
1035   </answer>
1036 </qandaentry>
1038 <qandaentry xml:id="faq.easy_to_fix">
1039   <question xml:id="q-easy_to_fix">
1040     <para>
1041       Aw, that's easy to fix!
1042     </para>
1043   </question>
1044   <answer xml:id="a-easy_to_fix">
1045     <para>
1046     If you have found a bug in the library and you think you have
1047     a working fix, then send it in!  The main GCC site has a page
1048     on <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/contribute.html">submitting
1049     patches</link> that covers the procedure, but for libstdc++ you
1050     should also send the patch to our mailing list in addition to
1051     the GCC patches mailing list.  The libstdc++
1052     <link linkend="appendix.contrib">contributors' page</link>
1053     also talks about how to submit patches.
1054     </para>
1055     <para>
1056     In addition to the description, the patch, and the ChangeLog
1057     entry, it is a Good Thing if you can additionally create a small
1058     test program to test for the presence of the bug that your patch
1059     fixes.  Bugs have a way of being reintroduced; if an old bug
1060     creeps back in, it will be caught immediately by the testsuite -
1061     but only if such a test exists.
1062     </para> 
1063   </answer>
1064 </qandaentry>
1066 </qandadiv>
1069 <!-- Miscellaneous -->
1070 <qandadiv xml:id="faq.misc" xreflabel="Miscellaneous">
1073 <qandaentry xml:id="faq.iterator_as_pod">
1074   <question xml:id="faq.iterator_as_pod_q">
1075     <para>
1076       <classname>string::iterator</classname> is not <code>char*</code>;
1077       <classname>vector&lt;T&gt;::iterator</classname> is not <code>T*</code>
1078     </para>
1079   </question>
1080   <answer xml:id="faq.iterator_as_pod_a">
1081     <para>
1082     If you have code that depends on container&lt;T&gt; iterators
1083     being implemented as pointer-to-T, your code is broken. It's
1084     considered a feature, not a bug, that libstdc++ points this out.
1085     </para>
1086     <para>
1087     While there are arguments for iterators to be implemented in
1088     that manner, A) they aren't very good ones in the long term,
1089     and B) they were never guaranteed by the Standard anyway.  The
1090     type-safety achieved by making iterators a real class rather
1091     than a typedef for <type>T*</type> outweighs nearly all opposing
1092     arguments.
1093     </para>
1094     <para>
1095     Code which does assume that a vector/string iterator <varname>i</varname>
1096     is a pointer can often be fixed by changing <varname>i</varname> in
1097     certain expressions to <varname>&amp;*i</varname>.
1098     </para>
1099   </answer>
1100 </qandaentry>
1102 <qandaentry xml:id="faq.what_is_next">
1103   <question xml:id="q-what_is_next">
1104     <para>
1105       What's next after libstdc++?
1106     </para>
1107   </question>
1108   <answer xml:id="a-what_is_next">
1109       <para>
1110         The goal of libstdc++ is to produce a
1111         fully-compliant, fully-portable Standard Library.
1112         While the C++ Standard continues to evolve the libstdc++ will
1113         continue to track it.
1114       </para>
1115   </answer>
1116 </qandaentry>
1118 <qandaentry xml:id="faq.sgi_stl">
1119   <question xml:id="q-sgi_stl">
1120     <para>
1121       What about the STL from SGI?
1122     </para>
1123   </question>
1124   <answer xml:id="a-sgi_stl">
1125     <para>
1126     The STL (Standard Template Library) was the inspiration for large chunks
1127     of the C++ Standard Library, but the terms are not interchangeable and
1128     they don't mean the same thing. The C++ Standard Library includes lots of
1129     things that didn't come from the STL, and some of them aren't even
1130     templates, such as <classname>std::locale</classname> and
1131     <classname>std::thread</classname>.
1132     </para>
1133     <para>
1134     Libstdc++-v3 incorporates a lot of code from
1135     <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.sgi.com/tech/stl/">the SGI STL</link>
1136     (the final merge was from
1137     <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.sgi.com/tech/stl/whats_new.html">release 3.3</link>).
1138     The code in libstdc++ contains many fixes and changes compared to the
1139     original SGI code.
1140     </para>
1141     <para>
1142     In particular, <classname>string</classname> is not from SGI and makes no
1143     use of their "rope" class (although that is included as an optional
1144     extension), neither is <classname>valarray</classname> nor some others.
1145     Classes like <classname>vector&lt;&gt;</classname> were from SGI, but have
1146     been extensively modified.
1147     </para>
1148     <para>
1149     More information on the evolution of libstdc++ can be found at the
1150     <link linkend="appendix.porting.api">API
1151     evolution</link>
1152     and <link linkend="manual.appendix.porting.backwards">backwards
1153     compatibility</link> documentation.
1154     </para>
1155     <para>
1156     The <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.sgi.com/tech/stl/FAQ.html">FAQ</link>
1157     for SGI's STL is still recommended reading.
1158     </para> 
1159   </answer>
1160 </qandaentry>
1162 <qandaentry xml:id="faq.extensions_and_backwards_compat">
1163   <question xml:id="q-extensions_and_backwards_compat">
1164     <para>
1165       Extensions and Backward Compatibility
1166     </para>
1167   </question>
1168   <answer xml:id="a-extensions_and_backwards_compat">
1169     <para>
1170       See the <link linkend="manual.appendix.porting.backwards">link</link> on backwards compatibility and <link linkend="appendix.porting.api">link</link> on evolution.
1171     </para> 
1172   </answer>
1173 </qandaentry>
1175 <qandaentry xml:id="faq.tr1_support">
1176   <question xml:id="q-tr1_support">
1177     <para>
1178       Does libstdc++ support TR1?
1179     </para>
1180   </question>
1181   <answer xml:id="a-tr1_support">
1182     <para>
1183     Yes.
1184     </para>
1185     <para>
1186     The C++ Standard Library
1187     <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf">
1188     Technical Report 1</link> added many new features to the library.
1189     </para>
1190     <para>
1191     The implementation status of TR1 in libstdc++ can be tracked
1192     <link linkend="status.iso.tr1">on the TR1 status page</link>.
1193     </para>
1194     <para>
1195     New code should probably not use TR1, because almost everything in it has
1196     been added to the main C++ Standard Library (usually with significant
1197     improvements).
1198     The TR1 implementation in libstdc++ is no longer actively maintained.
1199     </para>
1200   </answer>
1201 </qandaentry>
1203 <qandaentry xml:id="faq.get_iso_cxx">
1204   <question xml:id="q-get_iso_cxx">
1205     <para>How do I get a copy of the ISO C++ Standard?
1206     </para>
1207   </question>
1208   <answer xml:id="a-get_iso_cxx">
1209     <para>
1210     Please refer to the <link linkend="appendix.contrib">Contributing</link>
1211     section in our manual.
1212     </para> 
1213   </answer>
1214 </qandaentry>
1216 <qandaentry xml:id="faq.what_is_abi">
1217   <question xml:id="q-what_is_abi">
1218     <para>
1219       What's an ABI and why is it so messy?
1220     </para>
1221   </question>
1222   <answer xml:id="a-what_is_abi">
1223     <para>
1224     <acronym>ABI</acronym> stands for <quote>Application Binary
1225     Interface</quote>.  Conventionally, it refers to a great
1226     mass of details about how arguments are arranged on the call
1227     stack and/or in registers, and how various types are arranged
1228     and padded in structs.  A single CPU design may suffer
1229     multiple ABIs designed by different development tool vendors
1230     who made different choices, or even by the same vendor for
1231     different target applications or compiler versions.  In ideal
1232     circumstances the CPU designer presents one ABI and all the
1233     OSes and compilers use it.  In practice every ABI omits
1234     details that compiler implementers (consciously or
1235     accidentally) must choose for themselves.
1236     </para>
1237     <para>
1238     That ABI definition suffices for compilers to generate code so a
1239     program can interact safely with an OS and its lowest-level libraries.
1240     Users usually want an ABI to encompass more detail, allowing libraries
1241     built with different compilers (or different releases of the same
1242     compiler!) to be linked together.  For C++, this includes many more
1243     details than for C, and most CPU designers (for good reasons elaborated
1244     below) have not stepped up to publish C++ ABIs.  Such an ABI has been
1245     defined for the Itanium architecture (see
1246     <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://itanium-cxx-abi.github.io/cxx-abi/">C++
1247     ABI for Itanium</link>) and that is used by G++ and other compilers
1248     as the de facto standard ABI on many common architectures (including x86).
1249     G++ can also use the ARM architecture's EABI, for embedded
1250     systems relying only on a <quote>free-standing implementation</quote> that
1251     doesn't include (much of) the standard library, and the GNU EABI for
1252     hosted implementations on ARM.  Those ABIs cover low-level details
1253     such as virtual function implementation, struct inheritance layout,
1254     name mangling, and exception handling.
1255    </para>
1256     <para>
1257     A useful C++ ABI must also incorporate many details of the standard
1258     library implementation.  For a C ABI, the layouts of a few structs
1259     (such as <type>FILE</type>, <type>stat</type>, <type>jmpbuf</type>,
1260     and the like) and a few macros suffice.
1261     For C++, the details include the complete set of names of functions
1262     and types used, the offsets of class members and virtual functions,
1263     and the actual definitions of all inlines.  C++ exposes many more
1264     library details to the caller than C does.  It makes defining
1265     a complete ABI a much bigger undertaking, and requires not just
1266     documenting library implementation details, but carefully designing
1267     those details so that future bug fixes and optimizations don't
1268     force breaking the ABI.
1269     </para>
1270     <para>
1271     There are ways to help isolate library implementation details from the
1272     ABI, but they trade off against speed.  Library details used in inner
1273     loops (e.g., <function>getchar</function>) must be exposed and frozen for
1274     all time, but many others may reasonably be kept hidden from user code,
1275     so they may later be changed.  Deciding which, and implementing
1276     the decisions, must happen before you can reasonably document a
1277     candidate C++ ABI that encompasses the standard library.
1278     </para> 
1279   </answer>
1280 </qandaentry>
1282 <qandaentry xml:id="faq.size_equals_capacity">
1283   <question xml:id="q-size_equals_capacity">
1284     <para>
1285       How do I make <code>std::vector&lt;T&gt;::capacity() == std::vector&lt;T&gt;::size</code>?
1286     </para>
1287   </question>
1288   <answer xml:id="a-size_equals_capacity">
1289     <para>
1290     Since C++11 just call the <function>shrink_to_fit()</function> member
1291     function.
1292     </para>
1293     <para>
1294     Before C++11, the standard idiom for deallocating a
1295     <classname>vector&lt;T&gt;</classname>'s
1296     unused memory was to create a temporary copy of the vector and swap their
1297     contents, e.g. for <classname>vector&lt;T&gt; v</classname>
1298     </para>
1299     <literallayout class="normal">
1300      std::vector&lt;T&gt;(v).swap(v);
1301     </literallayout>
1302     <para>
1303     The copy will take O(n) time and the swap is constant time.
1304     </para>
1305     <para>
1306     See <link linkend="strings.string.shrink">Shrink-to-fit
1307     strings</link> for a similar solution for strings.
1308     </para> 
1309   </answer>
1310 </qandaentry>
1312 </qandadiv>
1315 <!-- FAQ ends here -->
1316 </qandaset>
1318 </article>
1320 </book>