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<T></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"><iostream.h></code>, 42 <code class="filename"><defalloc.h></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 <xxx> and <xxx.h> headers?</a>. 48 </p><p>Porting between pre-ISO headers and ISO headers is simple: headers 49like <code class="filename"><vector.h></code> can be replaced with <code class="filename"><vector></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"><hash_map></code> and <code class="filename"><hash_set></code> moved 61to <code class="filename"><ext/hash_map></code> and <code class="filename"><ext/hash_set></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"><unordered_map></code> 65and <code class="filename"><unordered_set></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__ < 3 73 #include <hash_map.h> 74 namespace extension { using ::hash_map; }; // inherit globals 75 #else 76 #include <backward/hash_map> 77 #if __GNUC__ == 3 && __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<int,int> 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 <ext/hash_map>], [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 <ext/hash_set>], [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<..></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"><ext/stdio_filebuf.h></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 <cassert> 181 #include <cctype> 182 #include <cerrno> 183 #include <cfloat> 184 #include <ciso646> 185 #include <climits> 186 #include <clocale> 187 #include <cmath> 188 #include <csetjmp> 189 #include <csignal> 190 #include <cstdarg> 191 #include <cstddef> 192 #include <cstdio> 193 #include <cstdlib> 194 #include <cstring> 195 #include <ctime> 196 197 #include <algorithm> 198 #include <bitset> 199 #include <complex> 200 #include <deque> 201 #include <exception> 202 #include <fstream> 203 #include <functional> 204 #include <iomanip> 205 #include <ios> 206 #include <iosfwd> 207 #include <iostream> 208 #include <istream> 209 #include <iterator> 210 #include <limits> 211 #include <list> 212 #include <locale> 213 #include <map> 214 #include <memory> 215 #include <new> 216 #include <numeric> 217 #include <ostream> 218 #include <queue> 219 #include <set> 220 #include <sstream> 221 #include <stack> 222 #include <stdexcept> 223 #include <streambuf> 224 #include <string> 225 #include <typeinfo> 226 #include <utility> 227 #include <valarray> 228 #include <vector> 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 <tr1/array> 249 #include <tr1/ccomplex> 250 #include <tr1/cctype> 251 #include <tr1/cfenv> 252 #include <tr1/cfloat> 253 #include <tr1/cinttypes> 254 #include <tr1/climits> 255 #include <tr1/cmath> 256 #include <tr1/complex> 257 #include <tr1/cstdarg> 258 #include <tr1/cstdbool> 259 #include <tr1/cstdint> 260 #include <tr1/cstdio> 261 #include <tr1/cstdlib> 262 #include <tr1/ctgmath> 263 #include <tr1/ctime> 264 #include <tr1/cwchar> 265 #include <tr1/cwctype> 266 #include <tr1/functional> 267 #include <tr1/memory> 268 #include <tr1/random> 269 #include <tr1/regex> 270 #include <tr1/tuple> 271 #include <tr1/type_traits> 272 #include <tr1/unordered_set> 273 #include <tr1/unordered_map> 274 #include <tr1/utility> 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 <unordered_map> and <unordered_set>. 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 <tr1/unordered_map>], [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 <tr1/unordered_set>], [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 <typename T> 326 struct check final 327 { 328 static constexpr T value{ __cplusplus }; 329 }; 330 331 typedef check<check<bool>> right_angle_brackets; 332 333 int a; 334 decltype(a) b; 335 336 typedef check<int> check_type; 337 check_type c{}; 338 check_type&& cr = static_cast<check_type&&>(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 <typename T> 353 struct check final 354 { 355 static constexpr T value{ __cplusplus }; 356 }; 357 358 typedef check<check<bool>> right_angle_brackets; 359 360 int a; 361 decltype(a) b; 362 363 typedef check<int> check_type; 364 check_type c{}; 365 check_type&& cr = static_cast<check_type&&>(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 <typename T> 381 struct check final 382 { 383 static constexpr T value{ __cplusplus }; 384 }; 385 386 typedef check<check<bool>> right_angle_brackets; 387 388 int a; 389 decltype(a) b; 390 391 typedef check<int> check_type; 392 check_type c{}; 393 check_type&& cr = static_cast<check_type&&>(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 <cassert> 423 #include <ccomplex> 424 #include <cctype> 425 #include <cerrno> 426 #include <cfenv> 427 #include <cfloat> 428 #include <cinttypes> 429 #include <ciso646> 430 #include <climits> 431 #include <clocale> 432 #include <cmath> 433 #include <csetjmp> 434 #include <csignal> 435 #include <cstdalign> 436 #include <cstdarg> 437 #include <cstdbool> 438 #include <cstddef> 439 #include <cstdint> 440 #include <cstdio> 441 #include <cstdlib> 442 #include <cstring> 443 #include <ctgmath> 444 #include <ctime> 445 // #include <cuchar> 446 #include <cwchar> 447 #include <cwctype> 448 449 #include <algorithm> 450 #include <array> 451 #include <atomic> 452 #include <bitset> 453 #include <chrono> 454 // #include <codecvt> 455 #include <complex> 456 #include <condition_variable> 457 #include <deque> 458 #include <exception> 459 #include <forward_list> 460 #include <fstream> 461 #include <functional> 462 #include <future> 463 #include <initializer_list> 464 #include <iomanip> 465 #include <ios> 466 #include <iosfwd> 467 #include <iostream> 468 #include <istream> 469 #include <iterator> 470 #include <limits> 471 #include <list> 472 #include <locale> 473 #include <map> 474 #include <memory> 475 #include <mutex> 476 #include <new> 477 #include <numeric> 478 #include <ostream> 479 #include <queue> 480 #include <random> 481 #include <ratio> 482 #include <regex> 483 #include <scoped_allocator> 484 #include <set> 485 #include <sstream> 486 #include <stack> 487 #include <stdexcept> 488 #include <streambuf> 489 #include <string> 490 #include <system_error> 491 #include <thread> 492 #include <tuple> 493 #include <typeindex> 494 #include <typeinfo> 495 #include <type_traits> 496 #include <unordered_map> 497 #include <unordered_set> 498 #include <utility> 499 #include <valarray> 500 #include <vector> 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"><unordered_map></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 <unordered_map>], [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 <unordered_set>], [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>