xref: /netbsd-src/external/gpl3/gcc/dist/libstdc++-v3/doc/html/manual/backwards.html (revision b1e838363e3c6fc78a55519254d99869742dd33c)
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Backwards Compatibility</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><meta name="keywords" content="ISO C++, backwards" /><meta name="keywords" content="ISO C++, library" /><meta name="keywords" content="ISO C++, runtime, library" /><link rel="home" href="../index.html" title="The GNU C++ Library" /><link rel="up" href="appendix_porting.html" title="Appendix B.  Porting and Maintenance" /><link rel="prev" href="api.html" title="API Evolution and Deprecation History" /><link rel="next" href="appendix_free.html" title="Appendix C.  Free Software Needs Free Documentation" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Backwards Compatibility</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="api.html">Prev</a> </td><th width="60%" align="center">Appendix B. 
3  Porting and Maintenance
4
5</th><td width="20%" align="right"> <a accesskey="n" href="appendix_free.html">Next</a></td></tr></table><hr /></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="manual.appendix.porting.backwards"></a>Backwards Compatibility</h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="backwards.first"></a>First</h3></div></div></div><p>The first generation GNU C++ library was called libg++.  It was a
6separate GNU project, although reliably paired with GCC. Rumors imply
7that it had a working relationship with at least two kinds of
8dinosaur.
9</p><p>Some background: libg++ was designed and created when there was no
10ISO standard to provide guidance.  Classes like linked lists are now
11provided for by <code class="classname">std::list&lt;T&gt;</code> and do not need to be
12created by <code class="function">genclass</code>.  (For that matter, templates exist
13now and are well-supported, whereas genclass (mostly) predates them.)
14</p><p>There are other classes in libg++ that are not specified in the
15ISO Standard (e.g., statistical analysis).  While there are a lot of
16really useful things that are used by a lot of people, the Standards
17Committee couldn't include everything, and so a lot of those
18<span class="quote">“<span class="quote">obvious</span>”</span> classes didn't get included.
19</p><p>That project is no longer maintained or supported, and the sources
20archived. For the desperate, the
21<a class="link" href="https://ftp.gnu.org/old-gnu/libg++/" target="_top">ftp.gnu.org</a>
22server still has the libg++ source.
23</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="backwards.second"></a>Second</h3></div></div></div><p>
24  The second generation GNU C++ library was called libstdc++, or
25  libstdc++-v2. It spans the time between libg++ and pre-ISO C++
26  standardization and is usually associated with the following GCC
27  releases: egcs 1.x, gcc 2.95, and gcc 2.96.
28</p><p>
29  The STL portions of that library are based on SGI/HP STL release 3.11.
30</p><p>
31  That project is no longer maintained or supported, and the sources
32  archived.  The code was replaced and rewritten for libstdc++-v3.
33</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="backwards.third"></a>Third</h3></div></div></div><p> The third generation GNU C++ library is called libstdc++, or
34libstdc++-v3.
35</p><p>The subset commonly known as the Standard Template Library
36	 (clauses 23 through 25 in C++98, mostly) is adapted from the final release
37	 of the SGI STL (version 3.3), with extensive changes.
38      </p><p>A more formal description of the V3 goals can be found in the
39	 official <a class="link" href="source_design_notes.html" title="Design Notes">design document</a>.
40      </p><p>Portability notes and known implementation limitations are as follows.</p><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="backwards.third.headers"></a>Pre-ISO headers removed</h4></div></div></div><p> The pre-ISO C++ headers
41      (<code class="filename">&lt;iostream.h&gt;</code>,
42      <code class="filename">&lt;defalloc.h&gt;</code> etc.) are
43      not supported.
44</p><p>For those of you new to ISO C++ (welcome, time travelers!), the
45      ancient pre-ISO headers have new names.
46      The C++ FAQ has a good explanation in <a class="link" href="https://isocpp.org/wiki/faq/coding-standards#std-headers" target="_top">What's
47      the difference between &lt;xxx&gt; and &lt;xxx.h&gt; headers?</a>.
48   </p><p>Porting between pre-ISO headers and ISO headers is simple: headers
49like <code class="filename">&lt;vector.h&gt;</code> can be replaced with <code class="filename">&lt;vector&gt;</code> and a using
50directive <code class="code">using namespace std;</code> can be put at the global
51scope. This should be enough to get this code compiling, assuming the
52other usage is correct.
53</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="backwards.third.hash"></a>Extension headers hash_map, hash_set moved to ext or backwards</h4></div></div></div><p>At this time most of the features of the SGI STL extension have been
54	 replaced by standardized libraries.
55	 In particular, the <code class="classname">unordered_map</code> and
56	 <code class="classname">unordered_set</code> containers of TR1 and C++ 2011
57	 are suitable replacements for the non-standard
58	 <code class="classname">hash_map</code> and <code class="classname">hash_set</code>
59	 containers in the SGI STL.
60      </p><p> Header files <code class="filename">&lt;hash_map&gt;</code> and <code class="filename">&lt;hash_set&gt;</code> moved
61to <code class="filename">&lt;ext/hash_map&gt;</code> and  <code class="filename">&lt;ext/hash_set&gt;</code>,
62respectively. At the same time, all types in these files are enclosed
63in <code class="code">namespace __gnu_cxx</code>. Later versions deprecate
64these files, and suggest using TR1's  <code class="filename">&lt;unordered_map&gt;</code>
65and  <code class="filename">&lt;unordered_set&gt;</code> instead.
66</p><p>The extensions are no longer in the global or <code class="code">std</code>
67	 namespaces, instead they are declared in the <code class="code">__gnu_cxx</code>
68	 namespace. For maximum portability, consider defining a namespace
69	 alias to use to talk about extensions, e.g.:
70      </p><pre class="programlisting">
71      #ifdef __GNUC__
72      #if __GNUC__ &lt; 3
73	#include &lt;hash_map.h&gt;
74	namespace extension { using ::hash_map; }; // inherit globals
75      #else
76	#include &lt;backward/hash_map&gt;
77	#if __GNUC__ == 3 &amp;&amp; __GNUC_MINOR__ == 0
78	  namespace extension = std;               // GCC 3.0
79	#else
80	  namespace extension = ::__gnu_cxx;       // GCC 3.1 and later
81	#endif
82      #endif
83      #else      // ...  there are other compilers, right?
84	namespace extension = std;
85      #endif
86
87      extension::hash_map&lt;int,int&gt; my_map;
88      </pre><p>This is a bit cleaner than defining typedefs for all the
89	 instantiations you might need.
90      </p><p>The following autoconf tests check for working HP/SGI hash containers.
91</p><pre class="programlisting">
92# AC_HEADER_EXT_HASH_MAP
93AC_DEFUN([AC_HEADER_EXT_HASH_MAP], [
94  AC_CACHE_CHECK(for ext/hash_map,
95  ac_cv_cxx_ext_hash_map,
96  [AC_LANG_SAVE
97  AC_LANG_CPLUSPLUS
98  ac_save_CXXFLAGS="$CXXFLAGS"
99  CXXFLAGS="$CXXFLAGS -Werror"
100  AC_TRY_COMPILE([#include &lt;ext/hash_map&gt;], [using __gnu_cxx::hash_map;],
101  ac_cv_cxx_ext_hash_map=yes, ac_cv_cxx_ext_hash_map=no)
102  CXXFLAGS="$ac_save_CXXFLAGS"
103  AC_LANG_RESTORE
104  ])
105  if test "$ac_cv_cxx_ext_hash_map" = yes; then
106    AC_DEFINE(HAVE_EXT_HASH_MAP,,[Define if ext/hash_map is present. ])
107  fi
108])
109</pre><pre class="programlisting">
110# AC_HEADER_EXT_HASH_SET
111AC_DEFUN([AC_HEADER_EXT_HASH_SET], [
112  AC_CACHE_CHECK(for ext/hash_set,
113  ac_cv_cxx_ext_hash_set,
114  [AC_LANG_SAVE
115  AC_LANG_CPLUSPLUS
116  ac_save_CXXFLAGS="$CXXFLAGS"
117  CXXFLAGS="$CXXFLAGS -Werror"
118  AC_TRY_COMPILE([#include &lt;ext/hash_set&gt;], [using __gnu_cxx::hash_set;],
119  ac_cv_cxx_ext_hash_set=yes, ac_cv_cxx_ext_hash_set=no)
120  CXXFLAGS="$ac_save_CXXFLAGS"
121  AC_LANG_RESTORE
122  ])
123  if test "$ac_cv_cxx_ext_hash_set" = yes; then
124    AC_DEFINE(HAVE_EXT_HASH_SET,,[Define if ext/hash_set is present. ])
125  fi
126])
127</pre></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="backwards.third.nocreate_noreplace"></a>No <code class="code">ios::nocreate/ios::noreplace</code>.
128</h4></div></div></div><p>Historically these flags were used with iostreams to control whether
129new files are created or not when opening a file stream, similar to the
130<code class="code">O_CREAT</code> and <code class="code">O_EXCL</code> flags for the
131<code class="function">open(2)</code> system call. Because iostream modes correspond
132to <code class="function">fopen(3)</code> modes these flags are not supported.
133For input streams a new file will not be created anyway, so
134<code class="code">ios::nocreate</code> is not needed.
135For output streams, a new file will be created if it does not exist, which is
136consistent with the behaviour of <code class="function">fopen</code>.
137</p><p>When one of these flags is needed a possible alternative is to attempt
138to open the file using <span class="type">std::ifstream</span> first to determine whether
139the file already exists or not. This may not be reliable however, because
140whether the file exists or not could change between opening the
141<span class="type">std::istream</span> and re-opening with an output stream. If you need
142to check for existence and open a file as a single operation then you will
143need to use OS-specific facilities outside the C++ standard library, such
144as <code class="function">open(2)</code>.
145</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="backwards.third.streamattach"></a>
146No <code class="code">stream::attach(int fd)</code>
147</h4></div></div></div><p>
148      Phil Edwards writes: It was considered and rejected for the ISO
149      standard.  Not all environments use file descriptors.  Of those
150      that do, not all of them use integers to represent them.
151    </p><p>
152      For a portable solution (among systems which use
153      file descriptors), you need to implement a subclass of
154      <code class="code">std::streambuf</code> (or
155      <code class="code">std::basic_streambuf&lt;..&gt;</code>) which opens a file
156      given a descriptor, and then pass an instance of this to the
157      stream-constructor.
158    </p><p>
159      An extension is available that implements this.
160      <code class="filename">&lt;ext/stdio_filebuf.h&gt;</code>
161      contains a derived class called
162      <code class="classname">__gnu_cxx::stdio_filebuf</code>.
163      This class can be constructed from a C <code class="code">FILE*</code> or a file
164      descriptor, and provides the <code class="code">fd()</code> function.
165    </p><p>
166 For another example of this, refer to
167      <a class="link" href="http://www.josuttis.com/cppcode/fdstream.html" target="_top">fdstream example</a>
168      by Nicolai Josuttis.
169</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="backwards.third.support_cxx98"></a>
170Support for C++98 dialect.
171</h4></div></div></div><p>Check for complete library coverage of the C++1998/2003 standard.
172</p><pre class="programlisting">
173# AC_HEADER_STDCXX_98
174AC_DEFUN([AC_HEADER_STDCXX_98], [
175  AC_CACHE_CHECK(for ISO C++ 98 include files,
176  ac_cv_cxx_stdcxx_98,
177  [AC_LANG_SAVE
178  AC_LANG_CPLUSPLUS
179  AC_TRY_COMPILE([
180    #include &lt;cassert&gt;
181    #include &lt;cctype&gt;
182    #include &lt;cerrno&gt;
183    #include &lt;cfloat&gt;
184    #include &lt;ciso646&gt;
185    #include &lt;climits&gt;
186    #include &lt;clocale&gt;
187    #include &lt;cmath&gt;
188    #include &lt;csetjmp&gt;
189    #include &lt;csignal&gt;
190    #include &lt;cstdarg&gt;
191    #include &lt;cstddef&gt;
192    #include &lt;cstdio&gt;
193    #include &lt;cstdlib&gt;
194    #include &lt;cstring&gt;
195    #include &lt;ctime&gt;
196
197    #include &lt;algorithm&gt;
198    #include &lt;bitset&gt;
199    #include &lt;complex&gt;
200    #include &lt;deque&gt;
201    #include &lt;exception&gt;
202    #include &lt;fstream&gt;
203    #include &lt;functional&gt;
204    #include &lt;iomanip&gt;
205    #include &lt;ios&gt;
206    #include &lt;iosfwd&gt;
207    #include &lt;iostream&gt;
208    #include &lt;istream&gt;
209    #include &lt;iterator&gt;
210    #include &lt;limits&gt;
211    #include &lt;list&gt;
212    #include &lt;locale&gt;
213    #include &lt;map&gt;
214    #include &lt;memory&gt;
215    #include &lt;new&gt;
216    #include &lt;numeric&gt;
217    #include &lt;ostream&gt;
218    #include &lt;queue&gt;
219    #include &lt;set&gt;
220    #include &lt;sstream&gt;
221    #include &lt;stack&gt;
222    #include &lt;stdexcept&gt;
223    #include &lt;streambuf&gt;
224    #include &lt;string&gt;
225    #include &lt;typeinfo&gt;
226    #include &lt;utility&gt;
227    #include &lt;valarray&gt;
228    #include &lt;vector&gt;
229  ],,
230  ac_cv_cxx_stdcxx_98=yes, ac_cv_cxx_stdcxx_98=no)
231  AC_LANG_RESTORE
232  ])
233  if test "$ac_cv_cxx_stdcxx_98" = yes; then
234    AC_DEFINE(STDCXX_98_HEADERS,,[Define if ISO C++ 1998 header files are present. ])
235  fi
236])
237</pre></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="backwards.third.support_tr1"></a>
238Support for C++TR1 dialect.
239</h4></div></div></div><p>Check for library coverage of the TR1 standard.
240</p><pre class="programlisting">
241# AC_HEADER_STDCXX_TR1
242AC_DEFUN([AC_HEADER_STDCXX_TR1], [
243  AC_CACHE_CHECK(for ISO C++ TR1 include files,
244  ac_cv_cxx_stdcxx_tr1,
245  [AC_LANG_SAVE
246  AC_LANG_CPLUSPLUS
247  AC_TRY_COMPILE([
248  #include &lt;tr1/array&gt;
249  #include &lt;tr1/ccomplex&gt;
250  #include &lt;tr1/cctype&gt;
251  #include &lt;tr1/cfenv&gt;
252  #include &lt;tr1/cfloat&gt;
253  #include &lt;tr1/cinttypes&gt;
254  #include &lt;tr1/climits&gt;
255  #include &lt;tr1/cmath&gt;
256  #include &lt;tr1/complex&gt;
257  #include &lt;tr1/cstdarg&gt;
258  #include &lt;tr1/cstdbool&gt;
259  #include &lt;tr1/cstdint&gt;
260  #include &lt;tr1/cstdio&gt;
261  #include &lt;tr1/cstdlib&gt;
262  #include &lt;tr1/ctgmath&gt;
263  #include &lt;tr1/ctime&gt;
264  #include &lt;tr1/cwchar&gt;
265  #include &lt;tr1/cwctype&gt;
266  #include &lt;tr1/functional&gt;
267  #include &lt;tr1/memory&gt;
268  #include &lt;tr1/random&gt;
269  #include &lt;tr1/regex&gt;
270  #include &lt;tr1/tuple&gt;
271  #include &lt;tr1/type_traits&gt;
272  #include &lt;tr1/unordered_set&gt;
273  #include &lt;tr1/unordered_map&gt;
274  #include &lt;tr1/utility&gt;
275  ],,
276  ac_cv_cxx_stdcxx_tr1=yes, ac_cv_cxx_stdcxx_tr1=no)
277  AC_LANG_RESTORE
278  ])
279  if test "$ac_cv_cxx_stdcxx_tr1" = yes; then
280    AC_DEFINE(STDCXX_TR1_HEADERS,,[Define if ISO C++ TR1 header files are present. ])
281  fi
282])
283</pre><p>An alternative is to check just for specific TR1 includes, such as &lt;unordered_map&gt; and &lt;unordered_set&gt;.
284</p><pre class="programlisting">
285# AC_HEADER_TR1_UNORDERED_MAP
286AC_DEFUN([AC_HEADER_TR1_UNORDERED_MAP], [
287  AC_CACHE_CHECK(for tr1/unordered_map,
288  ac_cv_cxx_tr1_unordered_map,
289  [AC_LANG_SAVE
290  AC_LANG_CPLUSPLUS
291  AC_TRY_COMPILE([#include &lt;tr1/unordered_map&gt;], [using std::tr1::unordered_map;],
292  ac_cv_cxx_tr1_unordered_map=yes, ac_cv_cxx_tr1_unordered_map=no)
293  AC_LANG_RESTORE
294  ])
295  if test "$ac_cv_cxx_tr1_unordered_map" = yes; then
296    AC_DEFINE(HAVE_TR1_UNORDERED_MAP,,[Define if tr1/unordered_map is present. ])
297  fi
298])
299</pre><pre class="programlisting">
300# AC_HEADER_TR1_UNORDERED_SET
301AC_DEFUN([AC_HEADER_TR1_UNORDERED_SET], [
302  AC_CACHE_CHECK(for tr1/unordered_set,
303  ac_cv_cxx_tr1_unordered_set,
304  [AC_LANG_SAVE
305  AC_LANG_CPLUSPLUS
306  AC_TRY_COMPILE([#include &lt;tr1/unordered_set&gt;], [using std::tr1::unordered_set;],
307  ac_cv_cxx_tr1_unordered_set=yes, ac_cv_cxx_tr1_unordered_set=no)
308  AC_LANG_RESTORE
309  ])
310  if test "$ac_cv_cxx_tr1_unordered_set" = yes; then
311    AC_DEFINE(HAVE_TR1_UNORDERED_SET,,[Define if tr1/unordered_set is present. ])
312  fi
313])
314</pre></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="backwards.third.support_cxx11"></a>
315Support for C++11 dialect.
316</h4></div></div></div><p>Check for baseline language coverage in the compiler for the C++11 standard.
317</p><pre class="programlisting">
318# AC_COMPILE_STDCXX_11
319AC_DEFUN([AC_COMPILE_STDCXX_11], [
320  AC_CACHE_CHECK(if g++ supports C++11 features without additional flags,
321  ac_cv_cxx_compile_cxx11_native,
322  [AC_LANG_SAVE
323  AC_LANG_CPLUSPLUS
324  AC_TRY_COMPILE([
325  template &lt;typename T&gt;
326    struct check final
327    {
328      static constexpr T value{ __cplusplus };
329    };
330
331    typedef check&lt;check&lt;bool&gt;&gt; right_angle_brackets;
332
333    int a;
334    decltype(a) b;
335
336    typedef check&lt;int&gt; check_type;
337    check_type c{};
338    check_type&amp;&amp; cr = static_cast&lt;check_type&amp;&amp;&gt;(c);
339
340    static_assert(check_type::value == 201103L, "C++11 compiler");],,
341  ac_cv_cxx_compile_cxx11_native=yes, ac_cv_cxx_compile_cxx11_native=no)
342  AC_LANG_RESTORE
343  ])
344
345  AC_CACHE_CHECK(if g++ supports C++11 features with -std=c++11,
346  ac_cv_cxx_compile_cxx11_cxx,
347  [AC_LANG_SAVE
348  AC_LANG_CPLUSPLUS
349  ac_save_CXXFLAGS="$CXXFLAGS"
350  CXXFLAGS="$CXXFLAGS -std=c++11"
351  AC_TRY_COMPILE([
352  template &lt;typename T&gt;
353    struct check final
354    {
355      static constexpr T value{ __cplusplus };
356    };
357
358    typedef check&lt;check&lt;bool&gt;&gt; right_angle_brackets;
359
360    int a;
361    decltype(a) b;
362
363    typedef check&lt;int&gt; check_type;
364    check_type c{};
365    check_type&amp;&amp; cr = static_cast&lt;check_type&amp;&amp;&gt;(c);
366
367    static_assert(check_type::value == 201103L, "C++11 compiler");],,
368  ac_cv_cxx_compile_cxx11_cxx=yes, ac_cv_cxx_compile_cxx11_cxx=no)
369  CXXFLAGS="$ac_save_CXXFLAGS"
370  AC_LANG_RESTORE
371  ])
372
373  AC_CACHE_CHECK(if g++ supports C++11 features with -std=gnu++11,
374  ac_cv_cxx_compile_cxx11_gxx,
375  [AC_LANG_SAVE
376  AC_LANG_CPLUSPLUS
377  ac_save_CXXFLAGS="$CXXFLAGS"
378  CXXFLAGS="$CXXFLAGS -std=gnu++11"
379  AC_TRY_COMPILE([
380  template &lt;typename T&gt;
381    struct check final
382    {
383      static constexpr T value{ __cplusplus };
384    };
385
386    typedef check&lt;check&lt;bool&gt;&gt; right_angle_brackets;
387
388    int a;
389    decltype(a) b;
390
391    typedef check&lt;int&gt; check_type;
392    check_type c{};
393    check_type&amp;&amp; cr = static_cast&lt;check_type&amp;&amp;&gt;(c);
394
395    static_assert(check_type::value == 201103L, "C++11 compiler");],,
396  ac_cv_cxx_compile_cxx11_gxx=yes, ac_cv_cxx_compile_cxx11_gxx=no)
397  CXXFLAGS="$ac_save_CXXFLAGS"
398  AC_LANG_RESTORE
399  ])
400
401  if test "$ac_cv_cxx_compile_cxx11_native" = yes ||
402     test "$ac_cv_cxx_compile_cxx11_cxx" = yes ||
403     test "$ac_cv_cxx_compile_cxx11_gxx" = yes; then
404    AC_DEFINE(HAVE_STDCXX_11,,[Define if g++ supports C++11 features. ])
405  fi
406])
407</pre><p>Check for library coverage of the C++2011 standard.
408  (Some library headers are commented out in this check, they are
409  not currently provided by libstdc++).
410</p><pre class="programlisting">
411# AC_HEADER_STDCXX_11
412AC_DEFUN([AC_HEADER_STDCXX_11], [
413  AC_CACHE_CHECK(for ISO C++11 include files,
414  ac_cv_cxx_stdcxx_11,
415  [AC_REQUIRE([AC_COMPILE_STDCXX_11])
416  AC_LANG_SAVE
417  AC_LANG_CPLUSPLUS
418  ac_save_CXXFLAGS="$CXXFLAGS"
419  CXXFLAGS="$CXXFLAGS -std=gnu++11"
420
421  AC_TRY_COMPILE([
422    #include &lt;cassert&gt;
423    #include &lt;ccomplex&gt;
424    #include &lt;cctype&gt;
425    #include &lt;cerrno&gt;
426    #include &lt;cfenv&gt;
427    #include &lt;cfloat&gt;
428    #include &lt;cinttypes&gt;
429    #include &lt;ciso646&gt;
430    #include &lt;climits&gt;
431    #include &lt;clocale&gt;
432    #include &lt;cmath&gt;
433    #include &lt;csetjmp&gt;
434    #include &lt;csignal&gt;
435    #include &lt;cstdalign&gt;
436    #include &lt;cstdarg&gt;
437    #include &lt;cstdbool&gt;
438    #include &lt;cstddef&gt;
439    #include &lt;cstdint&gt;
440    #include &lt;cstdio&gt;
441    #include &lt;cstdlib&gt;
442    #include &lt;cstring&gt;
443    #include &lt;ctgmath&gt;
444    #include &lt;ctime&gt;
445    // #include &lt;cuchar&gt;
446    #include &lt;cwchar&gt;
447    #include &lt;cwctype&gt;
448
449    #include &lt;algorithm&gt;
450    #include &lt;array&gt;
451    #include &lt;atomic&gt;
452    #include &lt;bitset&gt;
453    #include &lt;chrono&gt;
454    // #include &lt;codecvt&gt;
455    #include &lt;complex&gt;
456    #include &lt;condition_variable&gt;
457    #include &lt;deque&gt;
458    #include &lt;exception&gt;
459    #include &lt;forward_list&gt;
460    #include &lt;fstream&gt;
461    #include &lt;functional&gt;
462    #include &lt;future&gt;
463    #include &lt;initializer_list&gt;
464    #include &lt;iomanip&gt;
465    #include &lt;ios&gt;
466    #include &lt;iosfwd&gt;
467    #include &lt;iostream&gt;
468    #include &lt;istream&gt;
469    #include &lt;iterator&gt;
470    #include &lt;limits&gt;
471    #include &lt;list&gt;
472    #include &lt;locale&gt;
473    #include &lt;map&gt;
474    #include &lt;memory&gt;
475    #include &lt;mutex&gt;
476    #include &lt;new&gt;
477    #include &lt;numeric&gt;
478    #include &lt;ostream&gt;
479    #include &lt;queue&gt;
480    #include &lt;random&gt;
481    #include &lt;ratio&gt;
482    #include &lt;regex&gt;
483    #include &lt;scoped_allocator&gt;
484    #include &lt;set&gt;
485    #include &lt;sstream&gt;
486    #include &lt;stack&gt;
487    #include &lt;stdexcept&gt;
488    #include &lt;streambuf&gt;
489    #include &lt;string&gt;
490    #include &lt;system_error&gt;
491    #include &lt;thread&gt;
492    #include &lt;tuple&gt;
493    #include &lt;typeindex&gt;
494    #include &lt;typeinfo&gt;
495    #include &lt;type_traits&gt;
496    #include &lt;unordered_map&gt;
497    #include &lt;unordered_set&gt;
498    #include &lt;utility&gt;
499    #include &lt;valarray&gt;
500    #include &lt;vector&gt;
501  ],,
502  ac_cv_cxx_stdcxx_11=yes, ac_cv_cxx_stdcxx_11=no)
503  AC_LANG_RESTORE
504  CXXFLAGS="$ac_save_CXXFLAGS"
505  ])
506  if test "$ac_cv_cxx_stdcxx_11" = yes; then
507    AC_DEFINE(STDCXX_11_HEADERS,,[Define if ISO C++11 header files are present. ])
508  fi
509])
510</pre><p>As is the case for TR1 support, these autoconf macros can be made for a finer-grained, per-header-file check. For
511<code class="filename">&lt;unordered_map&gt;</code>
512</p><pre class="programlisting">
513# AC_HEADER_UNORDERED_MAP
514AC_DEFUN([AC_HEADER_UNORDERED_MAP], [
515  AC_CACHE_CHECK(for unordered_map,
516  ac_cv_cxx_unordered_map,
517  [AC_REQUIRE([AC_COMPILE_STDCXX_11])
518  AC_LANG_SAVE
519  AC_LANG_CPLUSPLUS
520  ac_save_CXXFLAGS="$CXXFLAGS"
521  CXXFLAGS="$CXXFLAGS -std=gnu++11"
522  AC_TRY_COMPILE([#include &lt;unordered_map&gt;], [using std::unordered_map;],
523  ac_cv_cxx_unordered_map=yes, ac_cv_cxx_unordered_map=no)
524  CXXFLAGS="$ac_save_CXXFLAGS"
525  AC_LANG_RESTORE
526  ])
527  if test "$ac_cv_cxx_unordered_map" = yes; then
528    AC_DEFINE(HAVE_UNORDERED_MAP,,[Define if unordered_map is present. ])
529  fi
530])
531</pre><pre class="programlisting">
532# AC_HEADER_UNORDERED_SET
533AC_DEFUN([AC_HEADER_UNORDERED_SET], [
534  AC_CACHE_CHECK(for unordered_set,
535  ac_cv_cxx_unordered_set,
536  [AC_REQUIRE([AC_COMPILE_STDCXX_11])
537  AC_LANG_SAVE
538  AC_LANG_CPLUSPLUS
539  ac_save_CXXFLAGS="$CXXFLAGS"
540  CXXFLAGS="$CXXFLAGS -std=gnu++11"
541  AC_TRY_COMPILE([#include &lt;unordered_set&gt;], [using std::unordered_set;],
542  ac_cv_cxx_unordered_set=yes, ac_cv_cxx_unordered_set=no)
543  CXXFLAGS="$ac_save_CXXFLAGS"
544  AC_LANG_RESTORE
545  ])
546  if test "$ac_cv_cxx_unordered_set" = yes; then
547    AC_DEFINE(HAVE_UNORDERED_SET,,[Define if unordered_set is present. ])
548  fi
549])
550</pre><p>
551  Some C++11 features first appeared in GCC 4.3 and could be enabled by
552  <code class="option">-std=c++0x</code> and <code class="option">-std=gnu++0x</code> for GCC
553  releases which pre-date the 2011 standard. Those C++11 features and GCC's
554  support for them were still changing until the 2011 standard was finished,
555  but the autoconf checks above could be extended to test for incomplete
556  C++11 support with <code class="option">-std=c++0x</code> and
557  <code class="option">-std=gnu++0x</code>.
558</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="backwards.third.iterator_type"></a>
559  <code class="code">Container::iterator_type</code> is not necessarily <code class="code">Container::value_type*</code>
560</h4></div></div></div><p>
561  This is a change in behavior from older versions. Now, most
562  <span class="type">iterator_type</span> typedefs in container classes are POD
563  objects, not <span class="type">value_type</span> pointers.
564</p></div></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="api.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="appendix_porting.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="appendix_free.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">API Evolution and Deprecation History </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Appendix C. 
565  Free Software Needs Free Documentation
566
567</td></tr></table></div></body></html>