1 <?xml version="1.0" encoding="ISO-8859-1"?>
3 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
8 <meta name="AUTHOR" content="bkoz@gcc.gnu.org (Benjamin Kosnik), Felix Natter" />
9 <meta name="KEYWORDS" content="C++, libstdc++, API, backward, compatibility" />
10 <meta name="DESCRIPTION" content="Backwards Compatibility" />
11 <meta name="GENERATOR" content="emacs and ten fingers" />
12 <title>Backwards Compatibility</title>
13 <link rel="StyleSheet" href="lib3styles.css" type="text/css" />
14 <link rel="Start" href="documentation.html" type="text/html"
15 title="GNU C++ Standard Library" />
16 <link rel="Copyright" href="17_intro/license.html" type="text/html" />
20 <h1 class="centered"><a name="top">Backwards Compatibility</a></h1>
22 <p class="fineprint"><em>
23 The latest version of this document is always available at
24 <a href="http://gcc.gnu.org/onlinedocs/libstdc++/17_intro/backwards_compatibility.html">
25 http://gcc.gnu.org/onlinedocs/libstdc++/17_intro/backwards_compatibility.html</a>.
29 To the <a href="http://gcc.gnu.org/libstdc++/">libstdc++ homepage</a>.
32 <!-- ####################################################### -->
35 <a name="v1">First.</a>
38 <p> The first generation GNU C++ library was called libg++. It was a
39 separate GNU project, although reliably paired with GCC. Rumors imply
40 that it had a working relationship with at least two kinds of
44 <p>Known Issues include many of the limitations of its immediate ancestor.</p>
46 <p>Portability notes and known implementation limitations are as follows.</p>
48 <h5>No <code>ios_base</code></h5>
50 <p> At least some older implementations don't have <code>std::ios_base</code>, so you should use <code>std::ios::badbit</code>, <code>std::ios::failbit</code> and <code>std::ios::eofbit</code> and <code>std::ios::goodbit</code>.
53 <h5>No <code>cout</code> in <code>ostream.h</code>, no <code>cin</code> in <code>istream.h</code></h5>
56 In earlier versions of the standard,
57 <tt><fstream.h></tt>,
58 <tt><ostream.h></tt>
59 and <tt><istream.h></tt>
61 <code>cout</code>, <code>cin</code> and so on. ISO C++ specifies that one needs to include
62 <tt><iostream></tt>
63 explicitly to get the required definitions.
65 <p> Some include adjustment may be required.</p>
68 <p>This project is no longer maintained or supported, and the sources
69 archived. The code is considered replaced and rewritten.
74 <a name="v2">Second.</a>
76 <p> The second generation GNU C++ library was called libstdc++, or
77 libstdc++-v2. It spans the time between libg++ and pre-ISO C++
78 standardization and is usually associated with the following GCC
79 releases: egcs 1.x, gcc 2.95, and gcc 2.96.
82 <p> The STL portions of this library are based on SGI/HP STL release 3.11.
85 <p>Portability notes and known implementation limitations are as follows.</p>
87 <h5>Namespace <code>std::</code> not supported</h5>
90 Some care is required to support C++ compiler and or library
91 implementation that do not have the standard library in
92 <code>namespace std</code>.
95 The following sections list some possible solutions to support compilers
96 that cannot ignore <code>std::</code>-qualified names.
99 <p> First, see if the compiler has a flag for this. Namespace
100 back-portability-issues are generally not a problem for g++
101 compilers that do not have libstdc++ in <code>std::</code>, as
102 the compilers use <code>-fno-honor-std</code> (ignore
103 <code>std::</code>, <code>:: = std::</code>) by default. That
104 is, the responsibility for enabling or disabling
105 <code>std::</code> is on the user; the maintainer does not have
106 to care about it. This probably applies to some other compilers
110 <p>Second, experiment with a variety of pre-processor tricks.</p>
112 <p> By defining <code>std</code> as a macro, fully-qualified namespace calls become global. Volia. </p>
115 #ifdef WICKEDLY_OLD_COMPILER
119 (thanks to Juergen Heinzl who posted this solution on gnu.gcc.help)
121 <p>Another pre-processor based approach is to define a
122 macro <code>NAMESPACE_STD</code>, which is defined to either
123 "" or "std" based on a compile-type test. On GNU
124 systems, this can be done with autotools by means of an autoconf test
125 (see below) for <code>HAVE_NAMESPACE_STD</code>, then using that to
126 set a value for the <code>NAMESPACE_STD</code> macro. At that point,
127 one is able to use <code>NAMESPACE_STD::string</code>, which will
128 evaluate to <code>std::string</code> or
129 <code>::string</code> (ie, in the global namespace on systems that do
130 not put <code>string</code> in <code>std::</code>). </p>
132 <pre style="background: #c0c0c0">
133 dnl @synopsis AC_CXX_NAMESPACE_STD
135 dnl If the compiler supports namespace std, define
136 dnl HAVE_NAMESPACE_STD.
139 dnl @author Todd Veldhuizen
140 dnl @author Luc Maisonobe <luc@spaceroots.org>
141 dnl @version 2004-02-04
142 dnl @license AllPermissive
143 AC_DEFUN([AC_CXX_NAMESPACE_STD], [
144 AC_CACHE_CHECK(if g++ supports namespace std,
145 ac_cv_cxx_have_std_namespace,
148 AC_TRY_COMPILE([#include <iostream>
149 std::istream& is = std::cin;],,
150 ac_cv_cxx_have_std_namespace=yes, ac_cv_cxx_have_std_namespace=no)
153 if test "$ac_cv_cxx_have_std_namespace" = yes; then
154 AC_DEFINE(HAVE_NAMESPACE_STD,,[Define if g++ supports namespace std. ])
159 <h5>Illegal iterator usage</h5>
161 The following illustrate implementation-allowed illegal iterator
162 use, and then correct use.
165 <ul> <li><p>you cannot do
166 <code>ostream::operator<<(iterator)</code> to print the
167 address of the iterator => use <code>operator<<
168 &*iterator</code> instead
170 <li><p>you cannot clear an iterator's reference
171 (<code>iterator = 0</code>) => use
172 <code>iterator = iterator_type();</code>
175 <code>if (iterator)</code> won't work any
176 more => use <code>if (iterator != iterator_type())</code>
180 <h5><code>isspace</code> from <tt><cctype></tt> is a macro
183 <p> Glibc 2.0.x and 2.1.x define <tt><ctype.h></tt>
184 functionality as macros (isspace, isalpha etc.).
188 This implementations of libstdc++, however, keep these functions as
189 macros, and so it is not back-portable to use fully qualified
194 #include <cctype>
195 int main() { std::isspace('X'); }
198 <p>Results in something like this:
202 std:: (__ctype_b[(int) ( ( 'X' ) )] & (unsigned short int) _ISspace ) ;
206 <p> A solution is to modify a header-file so that the compiler tells
207 <tt><ctype.h></tt> to define functions instead of macros:
211 // This keeps isalnum, et al from being propagated as macros.
213 # define __NO_CTYPE 1
217 <p>Then, include <ctype.h>
221 Another problem arises if you put a <code>using namespace std;</code>
222 declaration at the top, and include <tt><ctype.h></tt>. This
223 will result in ambiguities between the definitions in the global
224 namespace (<tt><ctype.h></tt>) and the definitions in namespace
225 <code>std::</code> (<code><cctype></code>).
228 <h5>No <code>vector::at</code>, <code>deque::at</code>, <code>string::at</code></h5>
231 One solution is to add an autoconf-test for this:
233 <pre style="background: #c0c0c0">
234 AC_MSG_CHECKING(for container::at)
237 #include <vector>
238 #include <deque>
239 #include <string>
244 deque<int> test_deque(3);
246 vector<int> test_vector(2);
248 string test_string("test_string");
252 AC_DEFINE(HAVE_CONTAINER_AT)],
257 If you are using other (non-GNU) compilers it might be a good idea
258 to check for <code>string::at</code> separately.
261 <h5>No <code>std::char_traits<char>::eof</code></h5>
264 Use some kind of autoconf test, plus this:
267 #ifdef HAVE_CHAR_TRAITS
268 #define CPP_EOF std::char_traits<char>::eof()
274 <h5>No <code>string::clear</code></h5>
277 There are two functions for deleting the contents of a string:
278 <code>clear</code> and <code>erase</code> (the latter
284 clear() { _M_mutate(0, this->size(), 0); }
288 erase(size_type __pos = 0, size_type __n = npos)
290 return this->replace(_M_check(__pos), _M_fold(__pos, __n),
291 _M_data(), _M_data());
296 Unfortunately, ut <code>clear</code> is not
297 implemented in this version, so you should use
298 <code>erase</code> (which is probably faster than
299 <code>operator=(charT*)</code>).
302 <h5>Removal of <code>ostream::form</code> and
303 <code>istream::scan</code> extensions</h5>
305 <p> These are no longer supported. Please use
306 <a href="#sec-stringstream" title="Using stringstreams">
307 stringstreams</a> instead.
310 <h5>No <code>basic_stringbuf</code>, <code>basic_stringstream</code></h5>
313 Although the ISO standard
314 <code>i/ostringstream</code>-classes are provided, (<tt><sstream></tt>), for compatibility with older implementations the pre-ISO <code>i/ostrstream</code> (<tt><strstream></tt>) interface is also provided, with these caveats:
317 <div class="itemizedlist"><ul type="disc">
318 <li><p> <code>strstream</code> is considered to be
321 <li><p> <code>strstream</code> is limited to
324 <li><p> with <code>ostringstream</code> you don't
325 have to take care of terminating the string or freeing its
328 <li><p> <code>istringstream</code> can be re-filled
329 (clear(); str(input);)
333 You can then use output-stringstreams like this:
338 # include <sstream>
340 # include <strstream>
344 std::ostringstream oss;
349 oss << "Name=" << m_name << ", number=" << m_number << std::endl;
352 oss << std::ends; // terminate the char*-string
355 // str() returns char* for ostrstream and a string for ostringstream
356 // this also causes ostrstream to think that the buffer's memory
358 m_label.set_text(oss.str());
360 // let the ostrstream take care of freeing the memory
366 Input-stringstreams can be used similarly:
373 std::istringstream iss(input);
375 std::istrstream iss(input.c_str());
382 <p> One (the only?) restriction is that an istrstream cannot be re-filled:
386 std::istringstream iss(numerator);
388 // this is not possible with istrstream
390 iss.str(denominator);
395 If you don't care about speed, you can put these conversions in
399 template <class X>
400 void fromString(const string& input, X& any)
403 std::istringstream iss(input);
405 std::istrstream iss(input.c_str());
410 throw runtime_error(..)
415 <p> Another example of using stringstreams is in <a href="../21_strings/howto.html" target="_top">this howto</a>.
418 <p> There is additional information in the libstdc++-v2 info files, in
419 particular "info iostream".
422 <h5>Little or no wide character support</h5>
424 <h5>No templatized iostreams</h5>
426 <h5>Thread safety issues</h5>
428 <p>This project is no longer maintained or supported, and the sources
429 archived. The code is considered replaced and rewritten.
435 <a name="v3">Third.</a>
437 <p> The third generation GNU C++ library is called libstdc++, or
441 <p>The subset commonly known as the Standard Template Library
442 (chapters 23 through 25, mostly) is adapted from the final release
443 of the SGI STL (version 3.3), with extensive changes.
446 <p>A more formal description of the V3 goals can be found in the
447 official <a href="../17_intro/DESIGN">design document</a>.
450 <p>Portability notes and known implementation limitations are as follows.</p>
452 <h5>Pre-ISO headers moved to backwards or removed</h5>
454 <p> The pre-ISO C++ headers
455 (<code>iostream.h</code>, <code>defalloc.h</code> etc.) are
456 available, unlike previous libstdc++ versions, but inclusion
457 generates a warning that you are using deprecated headers.
460 <p>This compatibility layer is constructed by including the
461 standard C++ headers, and injecting any items in
462 <code>std::</code> into the global namespace.
464 <p>For those of you new to ISO C++ (welcome, time travelers!), no,
465 that isn't a typo. Yes, the headers really have new names.
466 Marshall Cline's C++ FAQ Lite has a good explanation in <a
467 href="http://www.parashift.com/c++-faq-lite/coding-standards.html#faq-27.4">item
471 <p> Some include adjustment may be required. What follows is an
472 autoconf test that defines <code>PRE_STDCXX_HEADERS</code> when they
475 <pre style="background: #c0c0c0">
476 # AC_HEADER_PRE_STDCXX
477 AC_DEFUN([AC_HEADER_PRE_STDCXX], [
478 AC_CACHE_CHECK(for pre-ISO C++ include files,
479 ac_cv_cxx_pre_stdcxx,
482 ac_save_CXXFLAGS="$CXXFLAGS"
483 CXXFLAGS="$CXXFLAGS -Wno-deprecated"
485 # Omit defalloc.h, as compilation with newer compilers is problematic.
487 #include <new.h>
488 #include <iterator.h>
489 #include <alloc.h>
490 #include <set.h>
491 #include <hashtable.h>
492 #include <hash_set.h>
493 #include <fstream.h>
494 #include <tempbuf.h>
495 #include <istream.h>
496 #include <bvector.h>
497 #include <stack.h>
498 #include <rope.h>
499 #include <complex.h>
500 #include <ostream.h>
501 #include <heap.h>
502 #include <iostream.h>
503 #include <function.h>
504 #include <multimap.h>
505 #include <pair.h>
506 #include <stream.h>
507 #include <iomanip.h>
508 #include <slist.h>
509 #include <tree.h>
510 #include <vector.h>
511 #include <deque.h>
512 #include <multiset.h>
513 #include <list.h>
514 #include <map.h>
515 #include <algobase.h>
516 #include <hash_map.h>
517 #include <algo.h>
518 #include <queue.h>
519 #include <streambuf.h>
521 ac_cv_cxx_pre_stdcxx=yes, ac_cv_cxx_pre_stdcxx=no)
522 CXXFLAGS="$ac_save_CXXFLAGS"
525 if test "$ac_cv_cxx_pre_stdcxx" = yes; then
526 AC_DEFINE(PRE_STDCXX_HEADERS,,[Define if pre-ISO C++ header files are present. ])
531 <p>Porting between pre-ISO headers and ISO headers is simple: headers
532 like <vector.h> can be replaced with <vector> and a using
533 directive <code>using namespace std;</code> can be put at the global
534 scope. This should be enough to get this code compiling, assuming the
535 other usage is correct.
538 <h5>Extension headers hash_map, hash_set moved to ext or backwards</h5>
540 <p> Header files <code>hash_map</code> and <code>hash_set</code> moved
541 to <code>ext/hash_map</code> and <code>ext/hash_set</code>,
542 respectively. At the same time, all types in these files are enclosed
543 in <code>namespace __gnu_cxx</code>. Later versions move deprecate
544 these files, and suggest using TR1's <code>unordered_map</code>
545 and <code>unordered_set</code> instead.
548 <p>The following autoconf tests check for working HP/SGI hash containers.
551 <pre style="background: #c0c0c0">
552 # AC_HEADER_EXT_HASH_MAP
553 AC_DEFUN([AC_HEADER_EXT_HASH_MAP], [
554 AC_CACHE_CHECK(for ext/hash_map,
555 ac_cv_cxx_ext_hash_map,
558 ac_save_CXXFLAGS="$CXXFLAGS"
559 CXXFLAGS="$CXXFLAGS -Werror"
560 AC_TRY_COMPILE([#include <ext/hash_map>], [using __gnu_cxx::hash_map;],
561 ac_cv_cxx_ext_hash_map=yes, ac_cv_cxx_ext_hash_map=no)
562 CXXFLAGS="$ac_save_CXXFLAGS"
565 if test "$ac_cv_cxx_ext_hash_map" = yes; then
566 AC_DEFINE(HAVE_EXT_HASH_MAP,,[Define if ext/hash_map is present. ])
571 <pre style="background: #c0c0c0">
572 # AC_HEADER_EXT_HASH_SET
573 AC_DEFUN([AC_HEADER_EXT_HASH_SET], [
574 AC_CACHE_CHECK(for ext/hash_set,
575 ac_cv_cxx_ext_hash_set,
578 ac_save_CXXFLAGS="$CXXFLAGS"
579 CXXFLAGS="$CXXFLAGS -Werror"
580 AC_TRY_COMPILE([#include <ext/hash_set>], [using __gnu_cxx::hash_set;],
581 ac_cv_cxx_ext_hash_set=yes, ac_cv_cxx_ext_hash_set=no)
582 CXXFLAGS="$ac_save_CXXFLAGS"
585 if test "$ac_cv_cxx_ext_hash_set" = yes; then
586 AC_DEFINE(HAVE_EXT_HASH_SET,,[Define if ext/hash_set is present. ])
593 No <code>ios::nocreate/ios::noreplace</code>.
596 <p> The existence of <code>ios::nocreate</code> being used for
597 input-streams has been confirmed, most probably because the author
598 thought it would be more correct to specify nocreate explicitly. So
599 it can be left out for input-streams.
602 <p>For output streams, "nocreate" is probably the default,
603 unless you specify <code>std::ios::trunc</code> ? To be safe, you can
604 open the file for reading, check if it has been opened, and then
605 decide whether you want to create/replace or not. To my knowledge,
606 even older implementations support <code>app</code>, <code>ate</code>
607 and <code>trunc</code> (except for <code>app</code> ?).
612 No <code>stream::attach(int fd)</code>
616 Phil Edwards writes: It was considered and rejected for the ISO
617 standard. Not all environments use file descriptors. Of those
618 that do, not all of them use integers to represent them.
622 For a portable solution (among systems which use
623 filedescriptors), you need to implement a subclass of
624 <code>std::streambuf</code> (or
625 <code>std::basic_streambuf<..></code>) which opens a file
626 given a descriptor, and then pass an instance of this to the
631 An extension is available that implements this.
632 <code><ext/stdio_filebuf.h></code> contains a derived class called
633 <a href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/class____gnu__cxx_1_1stdio__filebuf.html"><code>__gnu_cxx::stdio_filebuf</code></a>.
634 This class can be constructed from a C <code>FILE*</code> or a file
635 descriptor, and provides the <code>fd()</code> function.
639 For another example of this, refer to
640 <a href="http://www.josuttis.com/cppcode/fdstream.html" target="_top">fdstream example</a>
645 Support for C++98 dialect.
648 <p>Check for complete library coverage of the C++1998/2003 standard.
651 <pre style="background: #c0c0c0">
653 # AC_HEADER_STDCXX_98
654 AC_DEFUN([AC_HEADER_STDCXX_98], [
655 AC_CACHE_CHECK(for ISO C++ 98 include files,
660 #include <cassert>
661 #include <cctype>
662 #include <cerrno>
663 #include <cfloat>
664 #include <ciso646>
665 #include <climits>
666 #include <clocale>
667 #include <cmath>
668 #include <csetjmp>
669 #include <csignal>
670 #include <cstdarg>
671 #include <cstddef>
672 #include <cstdio>
673 #include <cstdlib>
674 #include <cstring>
675 #include <ctime>
677 #include <algorithm>
678 #include <bitset>
679 #include <complex>
680 #include <deque>
681 #include <exception>
682 #include <fstream>
683 #include <functional>
684 #include <iomanip>
686 #include <iosfwd>
687 #include <iostream>
688 #include <istream>
689 #include <iterator>
690 #include <limits>
691 #include <list>
692 #include <locale>
694 #include <memory>
696 #include <numeric>
697 #include <ostream>
698 #include <queue>
700 #include <sstream>
701 #include <stack>
702 #include <stdexcept>
703 #include <streambuf>
704 #include <string>
705 #include <typeinfo>
706 #include <utility>
707 #include <valarray>
708 #include <vector>
710 ac_cv_cxx_stdcxx_98=yes, ac_cv_cxx_stdcxx_98=no)
713 if test "$ac_cv_cxx_stdcxx_98" = yes; then
714 AC_DEFINE(STDCXX_98_HEADERS,,[Define if ISO C++ 1998 header files are present. ])
721 Support for C++TR1 dialect.
724 <p>Check for library coverage of the TR1 standard.
727 <pre style="background: #c0c0c0">
729 # AC_HEADER_STDCXX_TR1
730 AC_DEFUN([AC_HEADER_STDCXX_TR1], [
731 AC_CACHE_CHECK(for ISO C++ TR1 include files,
732 ac_cv_cxx_stdcxx_tr1,
736 #include <tr1/array>
737 #include <tr1/ccomplex>
738 #include <tr1/cctype>
739 #include <tr1/cfenv>
740 #include <tr1/cfloat>
741 #include <tr1/cinttypes>
742 #include <tr1/climits>
743 #include <tr1/cmath>
744 #include <tr1/complex>
745 #include <tr1/cstdarg>
746 #include <tr1/cstdbool>
747 #include <tr1/cstdint>
748 #include <tr1/cstdio>
749 #include <tr1/cstdlib>
750 #include <tr1/ctgmath>
751 #include <tr1/ctime>
752 #include <tr1/cwchar>
753 #include <tr1/cwctype>
754 #include <tr1/functional>
755 #include <tr1/memory>
756 #include <tr1/random>
757 #include <tr1/regex>
758 #include <tr1/tuple>
759 #include <tr1/type_traits>
760 #include <tr1/unordered_set>
761 #include <tr1/unordered_map>
762 #include <tr1/utility>
764 ac_cv_cxx_stdcxx_tr1=yes, ac_cv_cxx_stdcxx_tr1=no)
767 if test "$ac_cv_cxx_stdcxx_tr1" = yes; then
768 AC_DEFINE(STDCXX_TR1_HEADERS,,[Define if ISO C++ TR1 header files are present. ])
773 <p>An alternative is to check just for specific TR1 includes, such as <unordered_map> and <unordered_set>.
776 <pre style="background: #c0c0c0">
777 # AC_HEADER_TR1_UNORDERED_MAP
778 AC_DEFUN([AC_HEADER_TR1_UNORDERED_MAP], [
779 AC_CACHE_CHECK(for tr1/unordered_map,
780 ac_cv_cxx_tr1_unordered_map,
783 AC_TRY_COMPILE([#include <tr1/unordered_map>], [using std::tr1::unordered_map;],
784 ac_cv_cxx_tr1_unordered_map=yes, ac_cv_cxx_tr1_unordered_map=no)
787 if test "$ac_cv_cxx_tr1_unordered_map" = yes; then
788 AC_DEFINE(HAVE_TR1_UNORDERED_MAP,,[Define if tr1/unordered_map is present. ])
793 <pre style="background: #c0c0c0">
794 # AC_HEADER_TR1_UNORDERED_SET
795 AC_DEFUN([AC_HEADER_TR1_UNORDERED_SET], [
796 AC_CACHE_CHECK(for tr1/unordered_set,
797 ac_cv_cxx_tr1_unordered_set,
800 AC_TRY_COMPILE([#include <tr1/unordered_set>], [using std::tr1::unordered_set;],
801 ac_cv_cxx_tr1_unordered_set=yes, ac_cv_cxx_tr1_unordered_set=no)
804 if test "$ac_cv_cxx_tr1_unordered_set" = yes; then
805 AC_DEFINE(HAVE_TR1_UNORDERED_SET,,[Define if tr1/unordered_set is present. ])
813 Support for C++0x dialect.
816 <p>Check for baseline language coverage in the compiler for the C++0xstandard.
819 <pre style="background: #c0c0c0">
820 # AC_COMPILE_STDCXX_OX
821 AC_DEFUN([AC_COMPILE_STDCXX_0X], [
822 AC_CACHE_CHECK(if g++ supports C++0x features without additional flags,
823 ac_cv_cxx_compile_cxx0x_native,
827 template <typename T>
830 static_assert(sizeof(int) <= sizeof(T), "not big enough");
833 typedef check<check<bool>> right_angle_brackets;
838 typedef check<int> check_type;
840 check_type&& cr = c;],,
841 ac_cv_cxx_compile_cxx0x_native=yes, ac_cv_cxx_compile_cxx0x_native=no)
845 AC_CACHE_CHECK(if g++ supports C++0x features with -std=c++0x,
846 ac_cv_cxx_compile_cxx0x_cxx,
849 ac_save_CXXFLAGS="$CXXFLAGS"
850 CXXFLAGS="$CXXFLAGS -std=c++0x"
852 template <typename T>
855 static_assert(sizeof(int) <= sizeof(T), "not big enough");
858 typedef check<check<bool>> right_angle_brackets;
863 typedef check<int> check_type;
865 check_type&& cr = c;],,
866 ac_cv_cxx_compile_cxx0x_cxx=yes, ac_cv_cxx_compile_cxx0x_cxx=no)
867 CXXFLAGS="$ac_save_CXXFLAGS"
871 AC_CACHE_CHECK(if g++ supports C++0x features with -std=gnu++0x,
872 ac_cv_cxx_compile_cxx0x_gxx,
875 ac_save_CXXFLAGS="$CXXFLAGS"
876 CXXFLAGS="$CXXFLAGS -std=gnu++0x"
878 template <typename T>
881 static_assert(sizeof(int) <= sizeof(T), "not big enough");
884 typedef check<check<bool>> right_angle_brackets;
889 typedef check<int> check_type;
891 check_type&& cr = c;],,
892 ac_cv_cxx_compile_cxx0x_gxx=yes, ac_cv_cxx_compile_cxx0x_gxx=no)
893 CXXFLAGS="$ac_save_CXXFLAGS"
897 if test "$ac_cv_cxx_compile_cxx0x_native" = yes ||
898 test "$ac_cv_cxx_compile_cxx0x_cxx" = yes ||
899 test "$ac_cv_cxx_compile_cxx0x_gxx" = yes; then
900 AC_DEFINE(HAVE_STDCXX_0X,,[Define if g++ supports C++0x features. ])
906 <p>Check for library coverage of the C++0xstandard.
909 <pre style="background: #c0c0c0">
911 # AC_HEADER_STDCXX_0X
912 AC_DEFUN([AC_HEADER_STDCXX_0X], [
913 AC_CACHE_CHECK(for ISO C++ 0x include files,
915 [AC_REQUIRE([AC_COMPILE_STDCXX_0X])
918 ac_save_CXXFLAGS="$CXXFLAGS"
919 CXXFLAGS="$CXXFLAGS -std=gnu++0x"
922 #include <cassert>
923 #include <ccomplex>
924 #include <cctype>
925 #include <cerrno>
926 #include <cfenv>
927 #include <cfloat>
928 #include <cinttypes>
929 #include <ciso646>
930 #include <climits>
931 #include <clocale>
932 #include <cmath>
933 #include <csetjmp>
934 #include <csignal>
935 #include <cstdarg>
936 #include <cstdbool>
937 #include <cstddef>
938 #include <cstdint>
939 #include <cstdio>
940 #include <cstdlib>
941 #include <cstring>
942 #include <ctgmath>
943 #include <ctime>
944 #include <cwchar>
945 #include <cwctype>
947 #include <algorithm>
948 #include <array>
949 #include <bitset>
950 #include <complex>
951 #include <deque>
952 #include <exception>
953 #include <fstream>
954 #include <functional>
955 #include <iomanip>
957 #include <iosfwd>
958 #include <iostream>
959 #include <istream>
960 #include <iterator>
961 #include <limits>
962 #include <list>
963 #include <locale>
965 #include <memory>
967 #include <numeric>
968 #include <ostream>
969 #include <queue>
970 #include <random>
971 #include <regex>
973 #include <sstream>
974 #include <stack>
975 #include <stdexcept>
976 #include <streambuf>
977 #include <string>
978 #include <tuple>
979 #include <typeinfo>
980 #include <type_traits>
981 #include <unordered_map>
982 #include <unordered_set>
983 #include <utility>
984 #include <valarray>
985 #include <vector>
987 ac_cv_cxx_stdcxx_0x=yes, ac_cv_cxx_stdcxx_0x=no)
989 CXXFLAGS="$ac_save_CXXFLAGS"
991 if test "$ac_cv_cxx_stdcxx_0x" = yes; then
992 AC_DEFINE(STDCXX_0X_HEADERS,,[Define if ISO C++ 0x header files are present. ])
997 <p>As is the case for TR1 support, these autoconf macros can be made for a finer-grained, per-header-file check. For <unordered_map>
1000 <pre style="background: #c0c0c0">
1002 # AC_HEADER_UNORDERED_MAP
1003 AC_DEFUN([AC_HEADER_UNORDERED_MAP], [
1004 AC_CACHE_CHECK(for unordered_map,
1005 ac_cv_cxx_unordered_map,
1006 [AC_REQUIRE([AC_COMPILE_STDCXX_0X])
1009 ac_save_CXXFLAGS="$CXXFLAGS"
1010 CXXFLAGS="$CXXFLAGS -std=gnu++0x"
1011 AC_TRY_COMPILE([#include <unordered_map>], [using std::unordered_map;],
1012 ac_cv_cxx_unordered_map=yes, ac_cv_cxx_unordered_map=no)
1013 CXXFLAGS="$ac_save_CXXFLAGS"
1016 if test "$ac_cv_cxx_unordered_map" = yes; then
1017 AC_DEFINE(HAVE_UNORDERED_MAP,,[Define if unordered_map is present. ])
1022 <pre style="background: #c0c0c0">
1023 # AC_HEADER_UNORDERED_SET
1024 AC_DEFUN([AC_HEADER_UNORDERED_SET], [
1025 AC_CACHE_CHECK(for unordered_set,
1026 ac_cv_cxx_unordered_set,
1027 [AC_REQUIRE([AC_COMPILE_STDCXX_0X])
1030 ac_save_CXXFLAGS="$CXXFLAGS"
1031 CXXFLAGS="$CXXFLAGS -std=gnu++0x"
1032 AC_TRY_COMPILE([#include <unordered_set>], [using std::unordered_set;],
1033 ac_cv_cxx_unordered_set=yes, ac_cv_cxx_unordered_set=no)
1034 CXXFLAGS="$ac_save_CXXFLAGS"
1037 if test "$ac_cv_cxx_unordered_set" = yes; then
1038 AC_DEFINE(HAVE_UNORDERED_SET,,[Define if unordered_set is present. ])
1045 Container iterator_type is not necessarily container value_type*
1051 <a name="v4">Fourth, and future</a>
1056 <a name="Links">Links</a>
1060 <a href="http://www.kegel.com/gcc/gcc4.html">Migrating to gcc-4.1</a>, by Dan Kegel.
1064 <a href="http://lists.debian.org/debian-gcc/2006/03/msg00405.html">Building the whole Debian archive with GCC 4.1: a summary</a>, by Martin Michlmayr
1068 <a href="http://annwm.lbl.gov/~leggett/Atlas/gcc-3.2.html">Migration guide for GCC-3.2</a>