1 <sect1 id="manual.appendix.porting.backwards" xreflabel="backwards">
2 <?dbhtml filename="backwards.html"?>
15 <title>Backwards Compatibility</title>
17 <sect2 id="backwards.first" xreflabel="backwards.first">
20 <para>The first generation GNU C++ library was called libg++. It was a
21 separate GNU project, although reliably paired with GCC. Rumors imply
22 that it had a working relationship with at least two kinds of
26 <para>Some background: libg++ was designed and created when there was no
27 ISO standard to provide guidance. Classes like linked lists are now
28 provided for by <classname>list<T></classname> and do not need to be
29 created by <function>genclass</function>. (For that matter, templates exist
30 now and are well-supported, whereas genclass (mostly) predates them.)
33 <para>There are other classes in libg++ that are not specified in the
34 ISO Standard (e.g., statistical analysis). While there are a lot of
35 really useful things that are used by a lot of people, the Standards
36 Committee couldn't include everything, and so a lot of those
37 <quote>obvious</quote> classes didn't get included.
40 <para>Known Issues include many of the limitations of its immediate ancestor.</para>
42 <para>Portability notes and known implementation limitations are as follows.</para>
45 <title>No <code>ios_base</code></title>
47 <para> 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>.
52 <title>No <code>cout</code> in <code>ostream.h</code>, no <code>cin</code> in <code>istream.h</code></title>
55 In earlier versions of the standard,
56 <filename class="headerfile">fstream.h</filename>,
57 <filename class="headerfile">ostream.h</filename>
58 and <filename class="headerfile">istream.h</filename>
60 <code>cout</code>, <code>cin</code> and so on. ISO C++ specifies that one needs to include
61 <filename class="headerfile">iostream</filename>
62 explicitly to get the required definitions.
64 <para> Some include adjustment may be required.</para>
66 <para>This project is no longer maintained or supported, and the sources
67 archived. For the desperate,
68 the <ulink url="http://gcc.gnu.org/extensions.html">GCC extensions
69 page</ulink> describes where to find the last libg++ source. The code is
70 considered replaced and rewritten.
75 <sect2 id="backwards.second" xreflabel="backwards.second">
79 The second generation GNU C++ library was called libstdc++, or
80 libstdc++-v2. It spans the time between libg++ and pre-ISO C++
81 standardization and is usually associated with the following GCC
82 releases: egcs 1.x, gcc 2.95, and gcc 2.96.
86 The STL portions of this library are based on SGI/HP STL release 3.11.
90 This project is no longer maintained or supported, and the sources
91 archived. The code is considered replaced and rewritten.
95 Portability notes and known implementation limitations are as follows.
99 <title>Namespace <code>std::</code> not supported</title>
102 Some care is required to support C++ compiler and or library
103 implementation that do not have the standard library in
104 <code>namespace std</code>.
108 The following sections list some possible solutions to support compilers
109 that cannot ignore <code>std::</code>-qualified names.
113 First, see if the compiler has a flag for this. Namespace
114 back-portability-issues are generally not a problem for g++
115 compilers that do not have libstdc++ in <code>std::</code>, as the
116 compilers use <code>-fno-honor-std</code> (ignore
117 <code>std::</code>, <code>:: = std::</code>) by default. That is,
118 the responsibility for enabling or disabling <code>std::</code> is
119 on the user; the maintainer does not have to care about it. This
120 probably applies to some other compilers as well.
124 Second, experiment with a variety of pre-processor tricks.
128 By defining <code>std</code> as a macro, fully-qualified namespace
129 calls become global. Volia.
133 #ifdef WICKEDLY_OLD_COMPILER
139 Thanks to Juergen Heinzl who posted this solution on gnu.gcc.help.
143 Another pre-processor based approach is to define a macro
144 <code>NAMESPACE_STD</code>, which is defined to either
145 <quote> </quote> or <quote>std</quote> based on a compile-type
146 test. On GNU systems, this can be done with autotools by means of
147 an autoconf test (see below) for <code>HAVE_NAMESPACE_STD</code>,
148 then using that to set a value for the <code>NAMESPACE_STD</code>
149 macro. At that point, one is able to use
150 <code>NAMESPACE_STD::string</code>, which will evaluate to
151 <code>std::string</code> or <code>::string</code> (i.e., in the
152 global namespace on systems that do not put <code>string</code> in
157 dnl @synopsis AC_CXX_NAMESPACE_STD
159 dnl If the compiler supports namespace std, define
160 dnl HAVE_NAMESPACE_STD.
163 dnl @author Todd Veldhuizen
164 dnl @author Luc Maisonobe <luc@spaceroots.org>
165 dnl @version 2004-02-04
166 dnl @license AllPermissive
167 AC_DEFUN([AC_CXX_NAMESPACE_STD], [
168 AC_CACHE_CHECK(if g++ supports namespace std,
169 ac_cv_cxx_have_std_namespace,
172 AC_TRY_COMPILE([#include <iostream>
173 std::istream& is = std::cin;],,
174 ac_cv_cxx_have_std_namespace=yes, ac_cv_cxx_have_std_namespace=no)
177 if test "$ac_cv_cxx_have_std_namespace" = yes; then
178 AC_DEFINE(HAVE_NAMESPACE_STD,,[Define if g++ supports namespace std. ])
185 <title>Illegal iterator usage</title>
187 The following illustrate implementation-allowed illegal iterator
188 use, and then correct use.
194 you cannot do <code>ostream::operator<<(iterator)</code>
195 to print the address of the iterator => use
196 <code>operator<< &*iterator</code> instead
201 you cannot clear an iterator's reference (<code>iterator =
202 0</code>) => use <code>iterator = iterator_type();</code>
207 <code>if (iterator)</code> won't work any more => use
208 <code>if (iterator != iterator_type())</code>
215 <title><code>isspace</code> from <filename class="headerfile">cctype</filename> is a macro
219 Glibc 2.0.x and 2.1.x define <filename
220 class="headerfile">ctype.h</filename> functionality as macros
221 (isspace, isalpha etc.).
225 This implementations of libstdc++, however, keep these functions
226 as macros, and so it is not back-portable to use fully qualified
231 #include <cctype>
232 int main() { std::isspace('X'); }
236 Results in something like this:
240 std:: (__ctype_b[(int) ( ( 'X' ) )] & (unsigned short int) _ISspace ) ;
244 A solution is to modify a header-file so that the compiler tells
245 <filename class="headerfile">ctype.h</filename> to define functions
250 // This keeps isalnum, et al from being propagated as macros.
252 # define __NO_CTYPE 1
257 Then, include <filename class="headerfile">ctype.h</filename>
261 Another problem arises if you put a <code>using namespace
262 std;</code> declaration at the top, and include <filename
263 class="headerfile">ctype.h</filename>. This will result in
264 ambiguities between the definitions in the global namespace
265 (<filename class="headerfile">ctype.h</filename>) and the
266 definitions in namespace <code>std::</code>
267 (<code><cctype></code>).
272 <title>No <code>vector::at</code>, <code>deque::at</code>, <code>string::at</code></title>
275 One solution is to add an autoconf-test for this:
279 AC_MSG_CHECKING(for container::at)
282 #include <vector>
283 #include <deque>
284 #include <string>
289 deque<int> test_deque(3);
291 vector<int> test_vector(2);
293 string test_string(<quote>test_string</quote>);
297 AC_DEFINE(HAVE_CONTAINER_AT)],
302 If you are using other (non-GNU) compilers it might be a good idea
303 to check for <code>string::at</code> separately.
309 <title>No <code>std::char_traits<char>::eof</code></title>
312 Use some kind of autoconf test, plus this:
316 #ifdef HAVE_CHAR_TRAITS
317 #define CPP_EOF std::char_traits<char>::eof()
326 <title>No <code>string::clear</code></title>
329 There are two functions for deleting the contents of a string:
330 <code>clear</code> and <code>erase</code> (the latter returns the
336 clear() { _M_mutate(0, this->size(), 0); }
341 erase(size_type __pos = 0, size_type __n = npos)
343 return this->replace(_M_check(__pos), _M_fold(__pos, __n),
344 _M_data(), _M_data());
349 Unfortunately, <code>clear</code> is not implemented in this
350 version, so you should use <code>erase</code> (which is probably
351 faster than <code>operator=(charT*)</code>).
357 Removal of <code>ostream::form</code> and <code>istream::scan</code>
362 These are no longer supported. Please use stringstreams instead.
367 <title>No <code>basic_stringbuf</code>, <code>basic_stringstream</code></title>
370 Although the ISO standard <code>i/ostringstream</code>-classes are
371 provided, (<filename class="headerfile">sstream</filename>), for
372 compatibility with older implementations the pre-ISO
373 <code>i/ostrstream</code> (<filename
374 class="headerfile">strstream</filename>) interface is also provided,
381 <code>strstream</code> is considered to be deprecated
386 <code>strstream</code> is limited to <code>char</code>
391 with <code>ostringstream</code> you don't have to take care of
392 terminating the string or freeing its memory
397 <code>istringstream</code> can be re-filled (clear();
404 You can then use output-stringstreams like this:
409 # include <sstream>
411 # include <strstream>
415 std::ostringstream oss;
420 oss << <quote>Name=</quote> << m_name << <quote>, number=</quote> << m_number << std::endl;
423 oss << std::ends; // terminate the char*-string
426 // str() returns char* for ostrstream and a string for ostringstream
427 // this also causes ostrstream to think that the buffer's memory
429 m_label.set_text(oss.str());
431 // let the ostrstream take care of freeing the memory
437 Input-stringstreams can be used similarly:
444 std::istringstream iss(input);
446 std::istrstream iss(input.c_str());
453 <para> One (the only?) restriction is that an istrstream cannot be re-filled:
457 std::istringstream iss(numerator);
459 // this is not possible with istrstream
461 iss.str(denominator);
466 If you don't care about speed, you can put these conversions in
470 template <class X>
471 void fromString(const string& input, X& any)
474 std::istringstream iss(input);
476 std::istrstream iss(input.c_str());
481 throw runtime_error(..)
487 Another example of using stringstreams is in <link
488 linkend="strings.string.shrink">this howto</link>.
491 <para> There is additional information in the libstdc++-v2 info files, in
492 particular <quote>info iostream</quote>.
497 <title>Little or no wide character support</title>
499 Classes <classname>wstring</classname> and
500 <classname>char_traits<wchar_t></classname> are
506 <title>No templatized iostreams</title>
508 Classes <classname>wfilebuf</classname> and
509 <classname>wstringstream</classname> are not supported.
514 <title>Thread safety issues</title>
517 Earlier GCC releases had a somewhat different approach to
518 threading configuration and proper compilation. Before GCC 3.0,
519 configuration of the threading model was dictated by compiler
520 command-line options and macros (both of which were somewhat
521 thread-implementation and port-specific). There were no
522 guarantees related to being able to link code compiled with one
523 set of options and macro setting with another set.
527 For GCC 3.0, configuration of the threading model used with
528 libraries and user-code is performed when GCC is configured and
529 built using the --enable-threads and --disable-threads options.
530 The ABI is stable for symbol name-mangling and limited functional
531 compatibility exists between code compiled under different
536 The libstdc++ library has been designed so that it can be used in
537 multithreaded applications (with libstdc++-v2 this was only true
538 of the STL parts.) The first problem is finding a
539 <emphasis>fast</emphasis> method of implementation portable to
540 all platforms. Due to historical reasons, some of the library is
541 written against per-CPU-architecture spinlocks and other parts
542 against the gthr.h abstraction layer which is provided by gcc. A
543 minor problem that pops up every so often is different
544 interpretations of what "thread-safe" means for a
545 library (not a general program). We currently use the <ulink
546 url="http://www.sgi.com/tech/stl/thread_safety.html">same
547 definition that SGI</ulink> uses for their STL subset. However,
548 the exception for read-only containers only applies to the STL
549 components. This definition is widely-used and something similar
550 will be used in the next version of the C++ standard library.
554 Here is a small link farm to threads (no pun) in the mail
555 archives that discuss the threading problem. Each link is to the
556 first relevant message in the thread; from there you can use
557 "Thread Next" to move down the thread. This farm is in
558 latest-to-oldest order.
564 Our threading expert Loren gives a breakdown of <ulink
565 url="http://gcc.gnu.org/ml/libstdc++/2001-10/msg00024.html">the
566 six situations involving threads</ulink> for the 3.0
572 <ulink url="http://gcc.gnu.org/ml/libstdc++/2001-05/msg00384.html">
573 This message</ulink> inspired a recent updating of issues with
574 threading and the SGI STL library. It also contains some
575 example POSIX-multithreaded STL code.
581 (A large selection of links to older messages has been removed;
582 many of the messages from 1999 were lost in a disk crash, and the
583 few people with access to the backup tapes have been too swamped
584 with work to restore them. Many of the points have been
591 <sect2 id="backwards.third" xreflabel="backwards.third">
594 <para> The third generation GNU C++ library is called libstdc++, or
598 <para>The subset commonly known as the Standard Template Library
599 (chapters 23 through 25, mostly) is adapted from the final release
600 of the SGI STL (version 3.3), with extensive changes.
603 <para>A more formal description of the V3 goals can be found in the
604 official <ulink url="../17_intro/DESIGN">design document</ulink>.
607 <para>Portability notes and known implementation limitations are as follows.</para>
610 <title>Pre-ISO headers moved to backwards or removed</title>
612 <para> The pre-ISO C++ headers
613 (<code>iostream.h</code>, <code>defalloc.h</code> etc.) are
614 available, unlike previous libstdc++ versions, but inclusion
615 generates a warning that you are using deprecated headers.
618 <para>This compatibility layer is constructed by including the
619 standard C++ headers, and injecting any items in
620 <code>std::</code> into the global namespace.
622 <para>For those of you new to ISO C++ (welcome, time travelers!), no,
623 that isn't a typo. Yes, the headers really have new names.
624 Marshall Cline's C++ FAQ Lite has a good explanation in <ulink url="http://www.parashift.com/c++-faq-lite/coding-standards.html#faq-27.4">item
628 <para> Some include adjustment may be required. What follows is an
629 autoconf test that defines <code>PRE_STDCXX_HEADERS</code> when they
633 # AC_HEADER_PRE_STDCXX
634 AC_DEFUN([AC_HEADER_PRE_STDCXX], [
635 AC_CACHE_CHECK(for pre-ISO C++ include files,
636 ac_cv_cxx_pre_stdcxx,
639 ac_save_CXXFLAGS="$CXXFLAGS"
640 CXXFLAGS="$CXXFLAGS -Wno-deprecated"
642 # Omit defalloc.h, as compilation with newer compilers is problematic.
644 #include <new.h>
645 #include <iterator.h>
646 #include <alloc.h>
647 #include <set.h>
648 #include <hashtable.h>
649 #include <hash_set.h>
650 #include <fstream.h>
651 #include <tempbuf.h>
652 #include <istream.h>
653 #include <bvector.h>
654 #include <stack.h>
655 #include <rope.h>
656 #include <complex.h>
657 #include <ostream.h>
658 #include <heap.h>
659 #include <iostream.h>
660 #include <function.h>
661 #include <multimap.h>
662 #include <pair.h>
663 #include <stream.h>
664 #include <iomanip.h>
665 #include <slist.h>
666 #include <tree.h>
667 #include <vector.h>
668 #include <deque.h>
669 #include <multiset.h>
670 #include <list.h>
671 #include <map.h>
672 #include <algobase.h>
673 #include <hash_map.h>
674 #include <algo.h>
675 #include <queue.h>
676 #include <streambuf.h>
678 ac_cv_cxx_pre_stdcxx=yes, ac_cv_cxx_pre_stdcxx=no)
679 CXXFLAGS="$ac_save_CXXFLAGS"
682 if test "$ac_cv_cxx_pre_stdcxx" = yes; then
683 AC_DEFINE(PRE_STDCXX_HEADERS,,[Define if pre-ISO C++ header files are present. ])
688 <para>Porting between pre-ISO headers and ISO headers is simple: headers
689 like <filename class="headerfile">vector.h</filename> can be replaced with <filename class="headerfile">vector</filename> and a using
690 directive <code>using namespace std;</code> can be put at the global
691 scope. This should be enough to get this code compiling, assuming the
692 other usage is correct.
697 <title>Extension headers hash_map, hash_set moved to ext or backwards</title>
699 <para>At this time most of the features of the SGI STL extension have been
700 replaced by standardized libraries.
701 In particular, the unordered_map and unordered_set containers of TR1
702 are suitable replacement for the non-standard hash_map and hash_set
703 containers in the SGI STL.
705 <para> Header files <filename class="headerfile">hash_map</filename> and <filename class="headerfile">hash_set</filename> moved
706 to <filename class="headerfile">ext/hash_map</filename> and <filename class="headerfile">ext/hash_set</filename>,
707 respectively. At the same time, all types in these files are enclosed
708 in <code>namespace __gnu_cxx</code>. Later versions move deprecate
709 these files, and suggest using TR1's <filename class="headerfile">unordered_map</filename>
710 and <filename class="headerfile">unordered_set</filename> instead.
713 <para>The extensions are no longer in the global or <code>std</code>
714 namespaces, instead they are declared in the <code>__gnu_cxx</code>
715 namespace. For maximum portability, consider defining a namespace
716 alias to use to talk about extensions, e.g.:
721 #include <hash_map.h>
722 namespace extension { using ::hash_map; }; // inherit globals
724 #include <backward/hash_map>
725 #if __GNUC__ == 3 && __GNUC_MINOR__ == 0
726 namespace extension = std; // GCC 3.0
728 namespace extension = ::__gnu_cxx; // GCC 3.1 and later
731 #else // ... there are other compilers, right?
732 namespace extension = std;
735 extension::hash_map<int,int> my_map;
737 <para>This is a bit cleaner than defining typedefs for all the
738 instantiations you might need.
742 <para>The following autoconf tests check for working HP/SGI hash containers.
746 # AC_HEADER_EXT_HASH_MAP
747 AC_DEFUN([AC_HEADER_EXT_HASH_MAP], [
748 AC_CACHE_CHECK(for ext/hash_map,
749 ac_cv_cxx_ext_hash_map,
752 ac_save_CXXFLAGS="$CXXFLAGS"
753 CXXFLAGS="$CXXFLAGS -Werror"
754 AC_TRY_COMPILE([#include <ext/hash_map>], [using __gnu_cxx::hash_map;],
755 ac_cv_cxx_ext_hash_map=yes, ac_cv_cxx_ext_hash_map=no)
756 CXXFLAGS="$ac_save_CXXFLAGS"
759 if test "$ac_cv_cxx_ext_hash_map" = yes; then
760 AC_DEFINE(HAVE_EXT_HASH_MAP,,[Define if ext/hash_map is present. ])
766 # AC_HEADER_EXT_HASH_SET
767 AC_DEFUN([AC_HEADER_EXT_HASH_SET], [
768 AC_CACHE_CHECK(for ext/hash_set,
769 ac_cv_cxx_ext_hash_set,
772 ac_save_CXXFLAGS="$CXXFLAGS"
773 CXXFLAGS="$CXXFLAGS -Werror"
774 AC_TRY_COMPILE([#include <ext/hash_set>], [using __gnu_cxx::hash_set;],
775 ac_cv_cxx_ext_hash_set=yes, ac_cv_cxx_ext_hash_set=no)
776 CXXFLAGS="$ac_save_CXXFLAGS"
779 if test "$ac_cv_cxx_ext_hash_set" = yes; then
780 AC_DEFINE(HAVE_EXT_HASH_SET,,[Define if ext/hash_set is present. ])
787 <title>No <code>ios::nocreate/ios::noreplace</code>.
790 <para> The existence of <code>ios::nocreate</code> being used for
791 input-streams has been confirmed, most probably because the author
792 thought it would be more correct to specify nocreate explicitly. So
793 it can be left out for input-streams.
796 <para>For output streams, <quote>nocreate</quote> is probably the default,
797 unless you specify <code>std::ios::trunc</code> ? To be safe, you can
798 open the file for reading, check if it has been opened, and then
799 decide whether you want to create/replace or not. To my knowledge,
800 even older implementations support <code>app</code>, <code>ate</code>
801 and <code>trunc</code> (except for <code>app</code> ?).
807 No <code>stream::attach(int fd)</code>
811 Phil Edwards writes: It was considered and rejected for the ISO
812 standard. Not all environments use file descriptors. Of those
813 that do, not all of them use integers to represent them.
817 For a portable solution (among systems which use
818 file descriptors), you need to implement a subclass of
819 <code>std::streambuf</code> (or
820 <code>std::basic_streambuf<..></code>) which opens a file
821 given a descriptor, and then pass an instance of this to the
826 An extension is available that implements this.
827 <filename class="headerfile">ext/stdio_filebuf.h</filename> contains a derived class called
828 <ulink url="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/class____gnu__cxx_1_1stdio__filebuf.html"><code>__gnu_cxx::stdio_filebuf</code></ulink>.
829 This class can be constructed from a C <code>FILE*</code> or a file
830 descriptor, and provides the <code>fd()</code> function.
834 For another example of this, refer to
835 <ulink url="http://www.josuttis.com/cppcode/fdstream.html">fdstream example</ulink>
842 Support for C++98 dialect.
845 <para>Check for complete library coverage of the C++1998/2003 standard.
849 # AC_HEADER_STDCXX_98
850 AC_DEFUN([AC_HEADER_STDCXX_98], [
851 AC_CACHE_CHECK(for ISO C++ 98 include files,
856 #include <cassert>
857 #include <cctype>
858 #include <cerrno>
859 #include <cfloat>
860 #include <ciso646>
861 #include <climits>
862 #include <clocale>
863 #include <cmath>
864 #include <csetjmp>
865 #include <csignal>
866 #include <cstdarg>
867 #include <cstddef>
868 #include <cstdio>
869 #include <cstdlib>
870 #include <cstring>
871 #include <ctime>
873 #include <algorithm>
874 #include <bitset>
875 #include <complex>
876 #include <deque>
877 #include <exception>
878 #include <fstream>
879 #include <functional>
880 #include <iomanip>
882 #include <iosfwd>
883 #include <iostream>
884 #include <istream>
885 #include <iterator>
886 #include <limits>
887 #include <list>
888 #include <locale>
890 #include <memory>
892 #include <numeric>
893 #include <ostream>
894 #include <queue>
896 #include <sstream>
897 #include <stack>
898 #include <stdexcept>
899 #include <streambuf>
900 #include <string>
901 #include <typeinfo>
902 #include <utility>
903 #include <valarray>
904 #include <vector>
906 ac_cv_cxx_stdcxx_98=yes, ac_cv_cxx_stdcxx_98=no)
909 if test "$ac_cv_cxx_stdcxx_98" = yes; then
910 AC_DEFINE(STDCXX_98_HEADERS,,[Define if ISO C++ 1998 header files are present. ])
918 Support for C++TR1 dialect.
921 <para>Check for library coverage of the TR1 standard.
925 # AC_HEADER_STDCXX_TR1
926 AC_DEFUN([AC_HEADER_STDCXX_TR1], [
927 AC_CACHE_CHECK(for ISO C++ TR1 include files,
928 ac_cv_cxx_stdcxx_tr1,
932 #include <tr1/array>
933 #include <tr1/ccomplex>
934 #include <tr1/cctype>
935 #include <tr1/cfenv>
936 #include <tr1/cfloat>
937 #include <tr1/cinttypes>
938 #include <tr1/climits>
939 #include <tr1/cmath>
940 #include <tr1/complex>
941 #include <tr1/cstdarg>
942 #include <tr1/cstdbool>
943 #include <tr1/cstdint>
944 #include <tr1/cstdio>
945 #include <tr1/cstdlib>
946 #include <tr1/ctgmath>
947 #include <tr1/ctime>
948 #include <tr1/cwchar>
949 #include <tr1/cwctype>
950 #include <tr1/functional>
951 #include <tr1/memory>
952 #include <tr1/random>
953 #include <tr1/regex>
954 #include <tr1/tuple>
955 #include <tr1/type_traits>
956 #include <tr1/unordered_set>
957 #include <tr1/unordered_map>
958 #include <tr1/utility>
960 ac_cv_cxx_stdcxx_tr1=yes, ac_cv_cxx_stdcxx_tr1=no)
963 if test "$ac_cv_cxx_stdcxx_tr1" = yes; then
964 AC_DEFINE(STDCXX_TR1_HEADERS,,[Define if ISO C++ TR1 header files are present. ])
969 <para>An alternative is to check just for specific TR1 includes, such as <unordered_map> and <unordered_set>.
973 # AC_HEADER_TR1_UNORDERED_MAP
974 AC_DEFUN([AC_HEADER_TR1_UNORDERED_MAP], [
975 AC_CACHE_CHECK(for tr1/unordered_map,
976 ac_cv_cxx_tr1_unordered_map,
979 AC_TRY_COMPILE([#include <tr1/unordered_map>], [using std::tr1::unordered_map;],
980 ac_cv_cxx_tr1_unordered_map=yes, ac_cv_cxx_tr1_unordered_map=no)
983 if test "$ac_cv_cxx_tr1_unordered_map" = yes; then
984 AC_DEFINE(HAVE_TR1_UNORDERED_MAP,,[Define if tr1/unordered_map is present. ])
990 # AC_HEADER_TR1_UNORDERED_SET
991 AC_DEFUN([AC_HEADER_TR1_UNORDERED_SET], [
992 AC_CACHE_CHECK(for tr1/unordered_set,
993 ac_cv_cxx_tr1_unordered_set,
996 AC_TRY_COMPILE([#include <tr1/unordered_set>], [using std::tr1::unordered_set;],
997 ac_cv_cxx_tr1_unordered_set=yes, ac_cv_cxx_tr1_unordered_set=no)
1000 if test "$ac_cv_cxx_tr1_unordered_set" = yes; then
1001 AC_DEFINE(HAVE_TR1_UNORDERED_SET,,[Define if tr1/unordered_set is present. ])
1010 Support for C++0x dialect.
1013 <para>Check for baseline language coverage in the compiler for the C++0xstandard.
1017 # AC_COMPILE_STDCXX_OX
1018 AC_DEFUN([AC_COMPILE_STDCXX_0X], [
1019 AC_CACHE_CHECK(if g++ supports C++0x features without additional flags,
1020 ac_cv_cxx_compile_cxx0x_native,
1024 template <typename T>
1027 static_assert(sizeof(int) <= sizeof(T), "not big enough");
1030 typedef check<check<bool>> right_angle_brackets;
1035 typedef check<int> check_type;
1037 check_type&& cr = c;],,
1038 ac_cv_cxx_compile_cxx0x_native=yes, ac_cv_cxx_compile_cxx0x_native=no)
1042 AC_CACHE_CHECK(if g++ supports C++0x features with -std=c++0x,
1043 ac_cv_cxx_compile_cxx0x_cxx,
1046 ac_save_CXXFLAGS="$CXXFLAGS"
1047 CXXFLAGS="$CXXFLAGS -std=c++0x"
1049 template <typename T>
1052 static_assert(sizeof(int) <= sizeof(T), "not big enough");
1055 typedef check<check<bool>> right_angle_brackets;
1060 typedef check<int> check_type;
1062 check_type&& cr = c;],,
1063 ac_cv_cxx_compile_cxx0x_cxx=yes, ac_cv_cxx_compile_cxx0x_cxx=no)
1064 CXXFLAGS="$ac_save_CXXFLAGS"
1068 AC_CACHE_CHECK(if g++ supports C++0x features with -std=gnu++0x,
1069 ac_cv_cxx_compile_cxx0x_gxx,
1072 ac_save_CXXFLAGS="$CXXFLAGS"
1073 CXXFLAGS="$CXXFLAGS -std=gnu++0x"
1075 template <typename T>
1078 static_assert(sizeof(int) <= sizeof(T), "not big enough");
1081 typedef check<check<bool>> right_angle_brackets;
1086 typedef check<int> check_type;
1088 check_type&& cr = c;],,
1089 ac_cv_cxx_compile_cxx0x_gxx=yes, ac_cv_cxx_compile_cxx0x_gxx=no)
1090 CXXFLAGS="$ac_save_CXXFLAGS"
1094 if test "$ac_cv_cxx_compile_cxx0x_native" = yes ||
1095 test "$ac_cv_cxx_compile_cxx0x_cxx" = yes ||
1096 test "$ac_cv_cxx_compile_cxx0x_gxx" = yes; then
1097 AC_DEFINE(HAVE_STDCXX_0X,,[Define if g++ supports C++0x features. ])
1103 <para>Check for library coverage of the C++0xstandard.
1107 # AC_HEADER_STDCXX_0X
1108 AC_DEFUN([AC_HEADER_STDCXX_0X], [
1109 AC_CACHE_CHECK(for ISO C++ 0x include files,
1110 ac_cv_cxx_stdcxx_0x,
1111 [AC_REQUIRE([AC_COMPILE_STDCXX_0X])
1114 ac_save_CXXFLAGS="$CXXFLAGS"
1115 CXXFLAGS="$CXXFLAGS -std=gnu++0x"
1118 #include <cassert>
1119 #include <ccomplex>
1120 #include <cctype>
1121 #include <cerrno>
1122 #include <cfenv>
1123 #include <cfloat>
1124 #include <cinttypes>
1125 #include <ciso646>
1126 #include <climits>
1127 #include <clocale>
1128 #include <cmath>
1129 #include <csetjmp>
1130 #include <csignal>
1131 #include <cstdarg>
1132 #include <cstdbool>
1133 #include <cstddef>
1134 #include <cstdint>
1135 #include <cstdio>
1136 #include <cstdlib>
1137 #include <cstring>
1138 #include <ctgmath>
1139 #include <ctime>
1140 #include <cwchar>
1141 #include <cwctype>
1143 #include <algorithm>
1144 #include <array>
1145 #include <bitset>
1146 #include <complex>
1147 #include <deque>
1148 #include <exception>
1149 #include <fstream>
1150 #include <functional>
1151 #include <iomanip>
1152 #include <ios>
1153 #include <iosfwd>
1154 #include <iostream>
1155 #include <istream>
1156 #include <iterator>
1157 #include <limits>
1158 #include <list>
1159 #include <locale>
1160 #include <map>
1161 #include <memory>
1162 #include <new>
1163 #include <numeric>
1164 #include <ostream>
1165 #include <queue>
1166 #include <random>
1167 #include <regex>
1168 #include <set>
1169 #include <sstream>
1170 #include <stack>
1171 #include <stdexcept>
1172 #include <streambuf>
1173 #include <string>
1174 #include <tuple>
1175 #include <typeinfo>
1176 #include <type_traits>
1177 #include <unordered_map>
1178 #include <unordered_set>
1179 #include <utility>
1180 #include <valarray>
1181 #include <vector>
1183 ac_cv_cxx_stdcxx_0x=yes, ac_cv_cxx_stdcxx_0x=no)
1185 CXXFLAGS="$ac_save_CXXFLAGS"
1187 if test "$ac_cv_cxx_stdcxx_0x" = yes; then
1188 AC_DEFINE(STDCXX_0X_HEADERS,,[Define if ISO C++ 0x header files are present. ])
1193 <para>As is the case for TR1 support, these autoconf macros can be made for a finer-grained, per-header-file check. For <unordered_map>
1197 # AC_HEADER_UNORDERED_MAP
1198 AC_DEFUN([AC_HEADER_UNORDERED_MAP], [
1199 AC_CACHE_CHECK(for unordered_map,
1200 ac_cv_cxx_unordered_map,
1201 [AC_REQUIRE([AC_COMPILE_STDCXX_0X])
1204 ac_save_CXXFLAGS="$CXXFLAGS"
1205 CXXFLAGS="$CXXFLAGS -std=gnu++0x"
1206 AC_TRY_COMPILE([#include <unordered_map>], [using std::unordered_map;],
1207 ac_cv_cxx_unordered_map=yes, ac_cv_cxx_unordered_map=no)
1208 CXXFLAGS="$ac_save_CXXFLAGS"
1211 if test "$ac_cv_cxx_unordered_map" = yes; then
1212 AC_DEFINE(HAVE_UNORDERED_MAP,,[Define if unordered_map is present. ])
1218 # AC_HEADER_UNORDERED_SET
1219 AC_DEFUN([AC_HEADER_UNORDERED_SET], [
1220 AC_CACHE_CHECK(for unordered_set,
1221 ac_cv_cxx_unordered_set,
1222 [AC_REQUIRE([AC_COMPILE_STDCXX_0X])
1225 ac_save_CXXFLAGS="$CXXFLAGS"
1226 CXXFLAGS="$CXXFLAGS -std=gnu++0x"
1227 AC_TRY_COMPILE([#include <unordered_set>], [using std::unordered_set;],
1228 ac_cv_cxx_unordered_set=yes, ac_cv_cxx_unordered_set=no)
1229 CXXFLAGS="$ac_save_CXXFLAGS"
1232 if test "$ac_cv_cxx_unordered_set" = yes; then
1233 AC_DEFINE(HAVE_UNORDERED_SET,,[Define if unordered_set is present. ])
1241 Container::iterator_type is not necessarily Container::value_type*
1245 This is a change in behavior from the previous version. Now, most
1246 <type>iterator_type</type> typedefs in container classes are POD
1247 objects, not <type>value_type</type> pointers.
1253 <bibliography id="backwards.biblio" xreflabel="backwards.biblio">
1254 <title>Bibliography</title>
1262 Migrating to GCC 4.1
1266 <firstname>Dan</firstname>
1267 <surname>Kegel</surname>
1271 <ulink url="http://www.kegel.com/gcc/gcc4.html">
1283 Building the Whole Debian Archive with GCC 4.1: A Summary
1287 <firstname>Martin</firstname>
1288 <surname>Michlmayr</surname>
1292 <ulink url="http://lists.debian.org/debian-gcc/2006/03/msg00405.html">
1304 Migration guide for GCC-3.2
1308 <ulink url="http://annwm.lbl.gov/~leggett/Atlas/gcc-3.2.html">