aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/doc/html/manual/backwards.html
blob: f52e09d7dc2cd01aceac1f515ce17cb34336c6df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!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. 
  Porting and Maintenance
  
</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
separate GNU project, although reliably paired with GCC. Rumors imply
that it had a working relationship with at least two kinds of
dinosaur.
</p><p>Some background: libg++ was designed and created when there was no
ISO standard to provide guidance.  Classes like linked lists are now
provided for by <code class="classname">std::list&lt;T&gt;</code> and do not need to be
created by <code class="function">genclass</code>.  (For that matter, templates exist
now and are well-supported, whereas genclass (mostly) predates them.)
</p><p>There are other classes in libg++ that are not specified in the
ISO Standard (e.g., statistical analysis).  While there are a lot of
really useful things that are used by a lot of people, the Standards
Committee couldn't include everything, and so a lot of those
<span class="quote"><span class="quote">obvious</span></span> classes didn't get included.
</p><p>That project is no longer maintained or supported, and the sources
archived. For the desperate, the
<a class="link" href="https://ftp.gnu.org/old-gnu/libg++/" target="_top">ftp.gnu.org</a>
server still has the libg++ source.
</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="backwards.second"></a>Second</h3></div></div></div><p>
  The second generation GNU C++ library was called libstdc++, or
  libstdc++-v2. It spans the time between libg++ and pre-ISO C++
  standardization and is usually associated with the following GCC
  releases: egcs 1.x, gcc 2.95, and gcc 2.96.
</p><p>
  The STL portions of that library are based on SGI/HP STL release 3.11.
</p><p>
  That project is no longer maintained or supported, and the sources
  archived.  The code was replaced and rewritten for libstdc++-v3.
</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
libstdc++-v3.
</p><p>The subset commonly known as the Standard Template Library
	 (clauses 23 through 25 in C++98, mostly) is adapted from the final release
	 of the SGI STL (version 3.3), with extensive changes.
      </p><p>A more formal description of the V3 goals can be found in the
	 official <a class="link" href="source_design_notes.html" title="Design Notes">design document</a>.
      </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
      (<code class="filename">&lt;iostream.h&gt;</code>,
      <code class="filename">&lt;defalloc.h&gt;</code> etc.) are
      not supported.
</p><p>For those of you new to ISO C++ (welcome, time travelers!), the
      ancient pre-ISO headers have new names.
      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
      the difference between &lt;xxx&gt; and &lt;xxx.h&gt; headers?</a>.
   </p><p>Porting between pre-ISO headers and ISO headers is simple: headers
like <code class="filename">&lt;vector.h&gt;</code> can be replaced with <code class="filename">&lt;vector&gt;</code> and a using
directive <code class="code">using namespace std;</code> can be put at the global
scope. This should be enough to get this code compiling, assuming the
other usage is correct.
</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
	 replaced by standardized libraries.
	 In particular, the <code class="classname">unordered_map</code> and
	 <code class="classname">unordered_set</code> containers of TR1 and C++ 2011
	 are suitable replacements for the non-standard
	 <code class="classname">hash_map</code> and <code class="classname">hash_set</code>
	 containers in the SGI STL.
      </p><p> Header files <code class="filename">&lt;hash_map&gt;</code> and <code class="filename">&lt;hash_set&gt;</code> moved
to <code class="filename">&lt;ext/hash_map&gt;</code> and  <code class="filename">&lt;ext/hash_set&gt;</code>,
respectively. At the same time, all types in these files are enclosed
in <code class="code">namespace __gnu_cxx</code>. Later versions deprecate
these files, and suggest using TR1's  <code class="filename">&lt;unordered_map&gt;</code>
and  <code class="filename">&lt;unordered_set&gt;</code> instead.
</p><p>The extensions are no longer in the global or <code class="code">std</code>
	 namespaces, instead they are declared in the <code class="code">__gnu_cxx</code>
	 namespace. For maximum portability, consider defining a namespace
	 alias to use to talk about extensions, e.g.:
      </p><pre class="programlisting">
      #ifdef __GNUC__
      #if __GNUC__ &lt; 3
	#include &lt;hash_map.h&gt;
	namespace extension { using ::hash_map; }; // inherit globals
      #else
	#include &lt;backward/hash_map&gt;
	#if __GNUC__ == 3 &amp;&amp; __GNUC_MINOR__ == 0
	  namespace extension = std;               // GCC 3.0
	#else
	  namespace extension = ::__gnu_cxx;       // GCC 3.1 and later
	#endif
      #endif
      #else      // ...  there are other compilers, right?
	namespace extension = std;
      #endif

      extension::hash_map&lt;int,int&gt; my_map;
      </pre><p>This is a bit cleaner than defining typedefs for all the
	 instantiations you might need.
      </p><p>The following autoconf tests check for working HP/SGI hash containers.
</p><pre class="programlisting">
# AC_HEADER_EXT_HASH_MAP
AC_DEFUN([AC_HEADER_EXT_HASH_MAP], [
  AC_CACHE_CHECK(for ext/hash_map,
  ac_cv_cxx_ext_hash_map,
  [AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  ac_save_CXXFLAGS="$CXXFLAGS"
  CXXFLAGS="$CXXFLAGS -Werror"
  AC_TRY_COMPILE([#include &lt;ext/hash_map&gt;], [using __gnu_cxx::hash_map;],
  ac_cv_cxx_ext_hash_map=yes, ac_cv_cxx_ext_hash_map=no)
  CXXFLAGS="$ac_save_CXXFLAGS"
  AC_LANG_RESTORE
  ])
  if test "$ac_cv_cxx_ext_hash_map" = yes; then
    AC_DEFINE(HAVE_EXT_HASH_MAP,,[Define if ext/hash_map is present. ])
  fi
])
</pre><pre class="programlisting">
# AC_HEADER_EXT_HASH_SET
AC_DEFUN([AC_HEADER_EXT_HASH_SET], [
  AC_CACHE_CHECK(for ext/hash_set,
  ac_cv_cxx_ext_hash_set,
  [AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  ac_save_CXXFLAGS="$CXXFLAGS"
  CXXFLAGS="$CXXFLAGS -Werror"
  AC_TRY_COMPILE([#include &lt;ext/hash_set&gt;], [using __gnu_cxx::hash_set;],
  ac_cv_cxx_ext_hash_set=yes, ac_cv_cxx_ext_hash_set=no)
  CXXFLAGS="$ac_save_CXXFLAGS"
  AC_LANG_RESTORE
  ])
  if test "$ac_cv_cxx_ext_hash_set" = yes; then
    AC_DEFINE(HAVE_EXT_HASH_SET,,[Define if ext/hash_set is present. ])
  fi
])
</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>.
</h4></div></div></div><p>Historically these flags were used with iostreams to control whether
new files are created or not when opening a file stream, similar to the
<code class="code">O_CREAT</code> and <code class="code">O_EXCL</code> flags for the
<code class="function">open(2)</code> system call. Because iostream modes correspond
to <code class="function">fopen(3)</code> modes these flags are not supported.
For input streams a new file will not be created anyway, so
<code class="code">ios::nocreate</code> is not needed.
For output streams, a new file will be created if it does not exist, which is
consistent with the behaviour of <code class="function">fopen</code>.
</p><p>When one of these flags is needed a possible alternative is to attempt
to open the file using <span class="type">std::ifstream</span> first to determine whether
the file already exists or not. This may not be reliable however, because
whether the file exists or not could change between opening the
<span class="type">std::istream</span> and re-opening with an output stream. If you need
to check for existence and open a file as a single operation then you will
need to use OS-specific facilities outside the C++ standard library, such
as <code class="function">open(2)</code>.
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="backwards.third.streamattach"></a>
No <code class="code">stream::attach(int fd)</code>
</h4></div></div></div><p>
      Phil Edwards writes: It was considered and rejected for the ISO
      standard.  Not all environments use file descriptors.  Of those
      that do, not all of them use integers to represent them.
    </p><p>
      For a portable solution (among systems which use
      file descriptors), you need to implement a subclass of
      <code class="code">std::streambuf</code> (or
      <code class="code">std::basic_streambuf&lt;..&gt;</code>) which opens a file
      given a descriptor, and then pass an instance of this to the
      stream-constructor.
    </p><p>
      An extension is available that implements this.
      <code class="filename">&lt;ext/stdio_filebuf.h&gt;</code>
      contains a derived class called
      <code class="classname">__gnu_cxx::stdio_filebuf</code>.
      This class can be constructed from a C <code class="code">FILE*</code> or a file
      descriptor, and provides the <code class="code">fd()</code> function.
    </p><p>
 For another example of this, refer to
      <a class="link" href="http://www.josuttis.com/cppcode/fdstream.html" target="_top">fdstream example</a>
      by Nicolai Josuttis.
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="backwards.third.support_cxx98"></a>
Support for C++98 dialect.
</h4></div></div></div><p>Check for complete library coverage of the C++1998/2003 standard.
</p><pre class="programlisting">
# AC_HEADER_STDCXX_98
AC_DEFUN([AC_HEADER_STDCXX_98], [
  AC_CACHE_CHECK(for ISO C++ 98 include files,
  ac_cv_cxx_stdcxx_98,
  [AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  AC_TRY_COMPILE([
    #include &lt;cassert&gt;
    #include &lt;cctype&gt;
    #include &lt;cerrno&gt;
    #include &lt;cfloat&gt;
    #include &lt;ciso646&gt;
    #include &lt;climits&gt;
    #include &lt;clocale&gt;
    #include &lt;cmath&gt;
    #include &lt;csetjmp&gt;
    #include &lt;csignal&gt;
    #include &lt;cstdarg&gt;
    #include &lt;cstddef&gt;
    #include &lt;cstdio&gt;
    #include &lt;cstdlib&gt;
    #include &lt;cstring&gt;
    #include &lt;ctime&gt;

    #include &lt;algorithm&gt;
    #include &lt;bitset&gt;
    #include &lt;complex&gt;
    #include &lt;deque&gt;
    #include &lt;exception&gt;
    #include &lt;fstream&gt;
    #include &lt;functional&gt;
    #include &lt;iomanip&gt;
    #include &lt;ios&gt;
    #include &lt;iosfwd&gt;
    #include &lt;iostream&gt;
    #include &lt;istream&gt;
    #include &lt;iterator&gt;
    #include &lt;limits&gt;
    #include &lt;list&gt;
    #include &lt;locale&gt;
    #include &lt;map&gt;
    #include &lt;memory&gt;
    #include &lt;new&gt;
    #include &lt;numeric&gt;
    #include &lt;ostream&gt;
    #include &lt;queue&gt;
    #include &lt;set&gt;
    #include &lt;sstream&gt;
    #include &lt;stack&gt;
    #include &lt;stdexcept&gt;
    #include &lt;streambuf&gt;
    #include &lt;string&gt;
    #include &lt;typeinfo&gt;
    #include &lt;utility&gt;
    #include &lt;valarray&gt;
    #include &lt;vector&gt;
  ],,
  ac_cv_cxx_stdcxx_98=yes, ac_cv_cxx_stdcxx_98=no)
  AC_LANG_RESTORE
  ])
  if test "$ac_cv_cxx_stdcxx_98" = yes; then
    AC_DEFINE(STDCXX_98_HEADERS,,[Define if ISO C++ 1998 header files are present. ])
  fi
])
</pre></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="backwards.third.support_tr1"></a>
Support for C++TR1 dialect.
</h4></div></div></div><p>Check for library coverage of the TR1 standard.
</p><pre class="programlisting">
# AC_HEADER_STDCXX_TR1
AC_DEFUN([AC_HEADER_STDCXX_TR1], [
  AC_CACHE_CHECK(for ISO C++ TR1 include files,
  ac_cv_cxx_stdcxx_tr1,
  [AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  AC_TRY_COMPILE([
  #include &lt;tr1/array&gt;
  #include &lt;tr1/ccomplex&gt;
  #include &lt;tr1/cctype&gt;
  #include &lt;tr1/cfenv&gt;
  #include &lt;tr1/cfloat&gt;
  #include &lt;tr1/cinttypes&gt;
  #include &lt;tr1/climits&gt;
  #include &lt;tr1/cmath&gt;
  #include &lt;tr1/complex&gt;
  #include &lt;tr1/cstdarg&gt;
  #include &lt;tr1/cstdbool&gt;
  #include &lt;tr1/cstdint&gt;
  #include &lt;tr1/cstdio&gt;
  #include &lt;tr1/cstdlib&gt;
  #include &lt;tr1/ctgmath&gt;
  #include &lt;tr1/ctime&gt;
  #include &lt;tr1/cwchar&gt;
  #include &lt;tr1/cwctype&gt;
  #include &lt;tr1/functional&gt;
  #include &lt;tr1/memory&gt;
  #include &lt;tr1/random&gt;
  #include &lt;tr1/regex&gt;
  #include &lt;tr1/tuple&gt;
  #include &lt;tr1/type_traits&gt;
  #include &lt;tr1/unordered_set&gt;
  #include &lt;tr1/unordered_map&gt;
  #include &lt;tr1/utility&gt;
  ],,
  ac_cv_cxx_stdcxx_tr1=yes, ac_cv_cxx_stdcxx_tr1=no)
  AC_LANG_RESTORE
  ])
  if test "$ac_cv_cxx_stdcxx_tr1" = yes; then
    AC_DEFINE(STDCXX_TR1_HEADERS,,[Define if ISO C++ TR1 header files are present. ])
  fi
])
</pre><p>An alternative is to check just for specific TR1 includes, such as &lt;unordered_map&gt; and &lt;unordered_set&gt;.
</p><pre class="programlisting">
# AC_HEADER_TR1_UNORDERED_MAP
AC_DEFUN([AC_HEADER_TR1_UNORDERED_MAP], [
  AC_CACHE_CHECK(for tr1/unordered_map,
  ac_cv_cxx_tr1_unordered_map,
  [AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  AC_TRY_COMPILE([#include &lt;tr1/unordered_map&gt;], [using std::tr1::unordered_map;],
  ac_cv_cxx_tr1_unordered_map=yes, ac_cv_cxx_tr1_unordered_map=no)
  AC_LANG_RESTORE
  ])
  if test "$ac_cv_cxx_tr1_unordered_map" = yes; then
    AC_DEFINE(HAVE_TR1_UNORDERED_MAP,,[Define if tr1/unordered_map is present. ])
  fi
])
</pre><pre class="programlisting">
# AC_HEADER_TR1_UNORDERED_SET
AC_DEFUN([AC_HEADER_TR1_UNORDERED_SET], [
  AC_CACHE_CHECK(for tr1/unordered_set,
  ac_cv_cxx_tr1_unordered_set,
  [AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  AC_TRY_COMPILE([#include &lt;tr1/unordered_set&gt;], [using std::tr1::unordered_set;],
  ac_cv_cxx_tr1_unordered_set=yes, ac_cv_cxx_tr1_unordered_set=no)
  AC_LANG_RESTORE
  ])
  if test "$ac_cv_cxx_tr1_unordered_set" = yes; then
    AC_DEFINE(HAVE_TR1_UNORDERED_SET,,[Define if tr1/unordered_set is present. ])
  fi
])
</pre></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="backwards.third.support_cxx11"></a>
Support for C++11 dialect.
</h4></div></div></div><p>Check for baseline language coverage in the compiler for the C++11 standard.
</p><pre class="programlisting">
# AC_COMPILE_STDCXX_11
AC_DEFUN([AC_COMPILE_STDCXX_11], [
  AC_CACHE_CHECK(if g++ supports C++11 features without additional flags,
  ac_cv_cxx_compile_cxx11_native,
  [AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  AC_TRY_COMPILE([
  template &lt;typename T&gt;
    struct check final
    {
      static constexpr T value{ __cplusplus };
    };

    typedef check&lt;check&lt;bool&gt;&gt; right_angle_brackets;

    int a;
    decltype(a) b;

    typedef check&lt;int&gt; check_type;
    check_type c{};
    check_type&amp;&amp; cr = static_cast&lt;check_type&amp;&amp;&gt;(c);

    static_assert(check_type::value == 201103L, "C++11 compiler");],,
  ac_cv_cxx_compile_cxx11_native=yes, ac_cv_cxx_compile_cxx11_native=no)
  AC_LANG_RESTORE
  ])

  AC_CACHE_CHECK(if g++ supports C++11 features with -std=c++11,
  ac_cv_cxx_compile_cxx11_cxx,
  [AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  ac_save_CXXFLAGS="$CXXFLAGS"
  CXXFLAGS="$CXXFLAGS -std=c++11"
  AC_TRY_COMPILE([
  template &lt;typename T&gt;
    struct check final
    {
      static constexpr T value{ __cplusplus };
    };

    typedef check&lt;check&lt;bool&gt;&gt; right_angle_brackets;

    int a;
    decltype(a) b;

    typedef check&lt;int&gt; check_type;
    check_type c{};
    check_type&amp;&amp; cr = static_cast&lt;check_type&amp;&amp;&gt;(c);

    static_assert(check_type::value == 201103L, "C++11 compiler");],,
  ac_cv_cxx_compile_cxx11_cxx=yes, ac_cv_cxx_compile_cxx11_cxx=no)
  CXXFLAGS="$ac_save_CXXFLAGS"
  AC_LANG_RESTORE
  ])

  AC_CACHE_CHECK(if g++ supports C++11 features with -std=gnu++11,
  ac_cv_cxx_compile_cxx11_gxx,
  [AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  ac_save_CXXFLAGS="$CXXFLAGS"
  CXXFLAGS="$CXXFLAGS -std=gnu++11"
  AC_TRY_COMPILE([
  template &lt;typename T&gt;
    struct check final
    {
      static constexpr T value{ __cplusplus };
    };

    typedef check&lt;check&lt;bool&gt;&gt; right_angle_brackets;

    int a;
    decltype(a) b;

    typedef check&lt;int&gt; check_type;
    check_type c{};
    check_type&amp;&amp; cr = static_cast&lt;check_type&amp;&amp;&gt;(c);

    static_assert(check_type::value == 201103L, "C++11 compiler");],,
  ac_cv_cxx_compile_cxx11_gxx=yes, ac_cv_cxx_compile_cxx11_gxx=no)
  CXXFLAGS="$ac_save_CXXFLAGS"
  AC_LANG_RESTORE
  ])

  if test "$ac_cv_cxx_compile_cxx11_native" = yes ||
     test "$ac_cv_cxx_compile_cxx11_cxx" = yes ||
     test "$ac_cv_cxx_compile_cxx11_gxx" = yes; then
    AC_DEFINE(HAVE_STDCXX_11,,[Define if g++ supports C++11 features. ])
  fi
])
</pre><p>Check for library coverage of the C++2011 standard.
  (Some library headers are commented out in this check, they are
  not currently provided by libstdc++).
</p><pre class="programlisting">
# AC_HEADER_STDCXX_11
AC_DEFUN([AC_HEADER_STDCXX_11], [
  AC_CACHE_CHECK(for ISO C++11 include files,
  ac_cv_cxx_stdcxx_11,
  [AC_REQUIRE([AC_COMPILE_STDCXX_11])
  AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  ac_save_CXXFLAGS="$CXXFLAGS"
  CXXFLAGS="$CXXFLAGS -std=gnu++11"

  AC_TRY_COMPILE([
    #include &lt;cassert&gt;
    #include &lt;ccomplex&gt;
    #include &lt;cctype&gt;
    #include &lt;cerrno&gt;
    #include &lt;cfenv&gt;
    #include &lt;cfloat&gt;
    #include &lt;cinttypes&gt;
    #include &lt;ciso646&gt;
    #include &lt;climits&gt;
    #include &lt;clocale&gt;
    #include &lt;cmath&gt;
    #include &lt;csetjmp&gt;
    #include &lt;csignal&gt;
    #include &lt;cstdalign&gt;
    #include &lt;cstdarg&gt;
    #include &lt;cstdbool&gt;
    #include &lt;cstddef&gt;
    #include &lt;cstdint&gt;
    #include &lt;cstdio&gt;
    #include &lt;cstdlib&gt;
    #include &lt;cstring&gt;
    #include &lt;ctgmath&gt;
    #include &lt;ctime&gt;
    // #include &lt;cuchar&gt;
    #include &lt;cwchar&gt;
    #include &lt;cwctype&gt;

    #include &lt;algorithm&gt;
    #include &lt;array&gt;
    #include &lt;atomic&gt;
    #include &lt;bitset&gt;
    #include &lt;chrono&gt;
    // #include &lt;codecvt&gt;
    #include &lt;complex&gt;
    #include &lt;condition_variable&gt;
    #include &lt;deque&gt;
    #include &lt;exception&gt;
    #include &lt;forward_list&gt;
    #include &lt;fstream&gt;
    #include &lt;functional&gt;
    #include &lt;future&gt;
    #include &lt;initializer_list&gt;
    #include &lt;iomanip&gt;
    #include &lt;ios&gt;
    #include &lt;iosfwd&gt;
    #include &lt;iostream&gt;
    #include &lt;istream&gt;
    #include &lt;iterator&gt;
    #include &lt;limits&gt;
    #include &lt;list&gt;
    #include &lt;locale&gt;
    #include &lt;map&gt;
    #include &lt;memory&gt;
    #include &lt;mutex&gt;
    #include &lt;new&gt;
    #include &lt;numeric&gt;
    #include &lt;ostream&gt;
    #include &lt;queue&gt;
    #include &lt;random&gt;
    #include &lt;ratio&gt;
    #include &lt;regex&gt;
    #include &lt;scoped_allocator&gt;
    #include &lt;set&gt;
    #include &lt;sstream&gt;
    #include &lt;stack&gt;
    #include &lt;stdexcept&gt;
    #include &lt;streambuf&gt;
    #include &lt;string&gt;
    #include &lt;system_error&gt;
    #include &lt;thread&gt;
    #include &lt;tuple&gt;
    #include &lt;typeindex&gt;
    #include &lt;typeinfo&gt;
    #include &lt;type_traits&gt;
    #include &lt;unordered_map&gt;
    #include &lt;unordered_set&gt;
    #include &lt;utility&gt;
    #include &lt;valarray&gt;
    #include &lt;vector&gt;
  ],,
  ac_cv_cxx_stdcxx_11=yes, ac_cv_cxx_stdcxx_11=no)
  AC_LANG_RESTORE
  CXXFLAGS="$ac_save_CXXFLAGS"
  ])
  if test "$ac_cv_cxx_stdcxx_11" = yes; then
    AC_DEFINE(STDCXX_11_HEADERS,,[Define if ISO C++11 header files are present. ])
  fi
])
</pre><p>As is the case for TR1 support, these autoconf macros can be made for a finer-grained, per-header-file check. For
<code class="filename">&lt;unordered_map&gt;</code>
</p><pre class="programlisting">
# AC_HEADER_UNORDERED_MAP
AC_DEFUN([AC_HEADER_UNORDERED_MAP], [
  AC_CACHE_CHECK(for unordered_map,
  ac_cv_cxx_unordered_map,
  [AC_REQUIRE([AC_COMPILE_STDCXX_11])
  AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  ac_save_CXXFLAGS="$CXXFLAGS"
  CXXFLAGS="$CXXFLAGS -std=gnu++11"
  AC_TRY_COMPILE([#include &lt;unordered_map&gt;], [using std::unordered_map;],
  ac_cv_cxx_unordered_map=yes, ac_cv_cxx_unordered_map=no)
  CXXFLAGS="$ac_save_CXXFLAGS"
  AC_LANG_RESTORE
  ])
  if test "$ac_cv_cxx_unordered_map" = yes; then
    AC_DEFINE(HAVE_UNORDERED_MAP,,[Define if unordered_map is present. ])
  fi
])
</pre><pre class="programlisting">
# AC_HEADER_UNORDERED_SET
AC_DEFUN([AC_HEADER_UNORDERED_SET], [
  AC_CACHE_CHECK(for unordered_set,
  ac_cv_cxx_unordered_set,
  [AC_REQUIRE([AC_COMPILE_STDCXX_11])
  AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  ac_save_CXXFLAGS="$CXXFLAGS"
  CXXFLAGS="$CXXFLAGS -std=gnu++11"
  AC_TRY_COMPILE([#include &lt;unordered_set&gt;], [using std::unordered_set;],
  ac_cv_cxx_unordered_set=yes, ac_cv_cxx_unordered_set=no)
  CXXFLAGS="$ac_save_CXXFLAGS"
  AC_LANG_RESTORE
  ])
  if test "$ac_cv_cxx_unordered_set" = yes; then
    AC_DEFINE(HAVE_UNORDERED_SET,,[Define if unordered_set is present. ])
  fi
])
</pre><p>
  Some C++11 features first appeared in GCC 4.3 and could be enabled by
  <code class="option">-std=c++0x</code> and <code class="option">-std=gnu++0x</code> for GCC
  releases which pre-date the 2011 standard. Those C++11 features and GCC's
  support for them were still changing until the 2011 standard was finished,
  but the autoconf checks above could be extended to test for incomplete
  C++11 support with <code class="option">-std=c++0x</code> and
  <code class="option">-std=gnu++0x</code>.
</p></div><div class="section"><div class="titlepage"><div><div><h4 class="title"><a id="backwards.third.iterator_type"></a>
  <code class="code">Container::iterator_type</code> is not necessarily <code class="code">Container::value_type*</code>
</h4></div></div></div><p>
  This is a change in behavior from older versions. Now, most
  <span class="type">iterator_type</span> typedefs in container classes are POD
  objects, not <span class="type">value_type</span> pointers.
</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. 
  Free Software Needs Free Documentation
  
</td></tr></table></div></body></html>