diff options
Diffstat (limited to 'libstdc++-v3/doc/xml/manual/backwards_compatibility.xml')
-rw-r--r-- | libstdc++-v3/doc/xml/manual/backwards_compatibility.xml | 223 |
1 files changed, 131 insertions, 92 deletions
diff --git a/libstdc++-v3/doc/xml/manual/backwards_compatibility.xml b/libstdc++-v3/doc/xml/manual/backwards_compatibility.xml index 41193bb549d..525157f1814 100644 --- a/libstdc++-v3/doc/xml/manual/backwards_compatibility.xml +++ b/libstdc++-v3/doc/xml/manual/backwards_compatibility.xml @@ -42,24 +42,24 @@ Committee couldn't include everything, and so a lot of those <para>Portability notes and known implementation limitations are as follows.</para> -<section><info><title>No <code>ios_base</code></title></info> +<section xml:id="backwards.first.ios_base"><info><title>No <code>ios_base</code></title></info> <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>. </para> </section> -<section><info><title>No <code>cout</code> in <code>ostream.h</code>, no <code>cin</code> in <code>istream.h</code></title></info> +<section xml:id="backwards.first.cout_cin"><info><title>No <code>cout</code> in <filename class="headerfile"><ostream.h></filename>, no <code>cin</code> in <filename class="headerfile"><istream.h></filename></title></info> <para> In earlier versions of the standard, - <filename class="headerfile">fstream.h</filename>, - <filename class="headerfile">ostream.h</filename> - and <filename class="headerfile">istream.h</filename> + <filename class="headerfile"><fstream.h></filename>, + <filename class="headerfile"><ostream.h></filename> + and <filename class="headerfile"><istream.h></filename> used to define <code>cout</code>, <code>cin</code> and so on. ISO C++ specifies that one needs to include - <filename class="headerfile">iostream</filename> + <filename class="headerfile"><iostream></filename> explicitly to get the required definitions. </para> <para> Some include adjustment may be required.</para> @@ -96,7 +96,7 @@ considered replaced and rewritten. Portability notes and known implementation limitations are as follows. </para> -<section><info><title>Namespace <code>std::</code> not supported</title></info> +<section xml:id="backwards.second.std"><info><title>Namespace <code>std::</code> not supported</title></info> <para> @@ -114,7 +114,7 @@ considered replaced and rewritten. First, see if the compiler has a flag for this. Namespace back-portability-issues are generally not a problem for g++ compilers that do not have libstdc++ in <code>std::</code>, as the - compilers use <code>-fno-honor-std</code> (ignore + compilers use <option>-fno-honor-std</option> (ignore <code>std::</code>, <code>:: = std::</code>) by default. That is, the responsibility for enabling or disabling <code>std::</code> is on the user; the maintainer does not have to care about it. This @@ -182,7 +182,7 @@ AC_DEFUN([AC_CXX_NAMESPACE_STD], [ </programlisting> </section> -<section><info><title>Illegal iterator usage</title></info> +<section xml:id="backwards.second.iterators"><info><title>Illegal iterator usage</title></info> <para> The following illustrate implementation-allowed illegal iterator @@ -212,12 +212,12 @@ AC_DEFUN([AC_CXX_NAMESPACE_STD], [ </itemizedlist> </section> -<section><info><title><code>isspace</code> from <filename class="headerfile">cctype</filename> is a macro +<section xml:id="backwards.second.isspace"><info><title><code>isspace</code> from <filename class="headerfile"><cctype></filename> is a macro </title></info> <para> - Glibc 2.0.x and 2.1.x define <filename class="headerfile">ctype.h</filename> functionality as macros + Glibc 2.0.x and 2.1.x define <filename class="headerfile"><ctype.h></filename> functionality as macros (isspace, isalpha etc.). </para> @@ -242,7 +242,7 @@ std:: (__ctype_b[(int) ( ( 'X' ) )] & (unsigned short int) _ISspace ) ; <para> A solution is to modify a header-file so that the compiler tells - <filename class="headerfile">ctype.h</filename> to define functions + <filename class="headerfile"><ctype.h></filename> to define functions instead of macros: </para> @@ -254,20 +254,21 @@ std:: (__ctype_b[(int) ( ( 'X' ) )] & (unsigned short int) _ISspace ) ; </programlisting> <para> - Then, include <filename class="headerfile">ctype.h</filename> + Then, include <filename class="headerfile"><ctype.h></filename> </para> <para> Another problem arises if you put a <code>using namespace - std;</code> declaration at the top, and include <filename class="headerfile">ctype.h</filename>. This will result in - ambiguities between the definitions in the global namespace - (<filename class="headerfile">ctype.h</filename>) and the + std;</code> declaration at the top, and include + <filename class="headerfile"><ctype.h></filename>. This will + result in ambiguities between the definitions in the global namespace + (<filename class="headerfile"><ctype.h></filename>) and the definitions in namespace <code>std::</code> (<code><cctype></code>). </para> </section> -<section><info><title>No <code>vector::at</code>, <code>deque::at</code>, <code>string::at</code></title></info> +<section xml:id="backwards.second.at"><info><title>No <code>vector::at</code>, <code>deque::at</code>, <code>string::at</code></title></info> <para> @@ -304,7 +305,7 @@ AC_DEFINE(HAVE_CONTAINER_AT)], </section> -<section><info><title>No <code>std::char_traits<char>::eof</code></title></info> +<section xml:id="backwards.second.eof"><info><title>No <code>std::char_traits<char>::eof</code></title></info> <para> @@ -321,7 +322,7 @@ AC_DEFINE(HAVE_CONTAINER_AT)], </section> -<section><info><title>No <code>string::clear</code></title></info> +<section xml:id="backwards.second.stringclear"><info><title>No <code>string::clear</code></title></info> <para> @@ -351,7 +352,7 @@ erase(size_type __pos = 0, size_type __n = npos) </para> </section> -<section><info><title> +<section xml:id="backwards.second.ostreamform_istreamscan"><info><title> Removal of <code>ostream::form</code> and <code>istream::scan</code> extensions </title></info> @@ -362,14 +363,14 @@ erase(size_type __pos = 0, size_type __n = npos) </para> </section> -<section><info><title>No <code>basic_stringbuf</code>, <code>basic_stringstream</code></title></info> +<section xml:id="backwards.second.stringstreams"><info><title>No <code>basic_stringbuf</code>, <code>basic_stringstream</code></title></info> <para> Although the ISO standard <code>i/ostringstream</code>-classes are - provided, (<filename class="headerfile">sstream</filename>), for + provided, (<filename class="headerfile"><sstream></filename>), for compatibility with older implementations the pre-ISO - <code>i/ostrstream</code> (<filename class="headerfile">strstream</filename>) interface is also provided, + <code>i/ostrstream</code> (<filename class="headerfile"><strstream></filename>) interface is also provided, with these caveats: </para> @@ -490,7 +491,7 @@ particular <quote>info iostream</quote>. </para> </section> -<section><info><title>Little or no wide character support</title></info> +<section xml:id="backwards.second.wchar"><info><title>Little or no wide character support</title></info> <para> Classes <classname>wstring</classname> and @@ -499,7 +500,7 @@ particular <quote>info iostream</quote>. </para> </section> -<section><info><title>No templatized iostreams</title></info> +<section xml:id="backwards.second.iostream_templates"><info><title>No templatized iostreams</title></info> <para> Classes <classname>wfilebuf</classname> and @@ -507,7 +508,7 @@ particular <quote>info iostream</quote>. </para> </section> -<section><info><title>Thread safety issues</title></info> +<section xml:id="backwards.second.thread_safety"><info><title>Thread safety issues</title></info> <para> @@ -601,11 +602,12 @@ libstdc++-v3. <para>Portability notes and known implementation limitations are as follows.</para> -<section><info><title>Pre-ISO headers moved to backwards or removed</title></info> +<section xml:id="backwards.third.headers"><info><title>Pre-ISO headers moved to backwards or removed</title></info> <para> The pre-ISO C++ headers - (<code>iostream.h</code>, <code>defalloc.h</code> etc.) are + (<filename class="headerfile"><iostream.h></filename>, + <filename class="headerfile"><defalloc.h></filename> etc.) are available, unlike previous libstdc++ versions, but inclusion generates a warning that you are using deprecated headers. </para> @@ -681,28 +683,30 @@ AC_DEFUN([AC_HEADER_PRE_STDCXX], [ </programlisting> <para>Porting between pre-ISO headers and ISO headers is simple: headers -like <filename class="headerfile">vector.h</filename> can be replaced with <filename class="headerfile">vector</filename> and a using +like <filename class="headerfile"><vector.h></filename> can be replaced with <filename class="headerfile"><vector></filename> and a using directive <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. </para> </section> -<section><info><title>Extension headers hash_map, hash_set moved to ext or backwards</title></info> +<section xml:id="backwards.third.hash"><info><title>Extension headers hash_map, hash_set moved to ext or backwards</title></info> <para>At this time most of the features of the SGI STL extension have been replaced by standardized libraries. - In particular, the unordered_map and unordered_set containers of TR1 - are suitable replacement for the non-standard hash_map and hash_set + In particular, the <classname>unordered_map</classname> and + <classname>unordered_set</classname> containers of TR1 and C++ 2011 + are suitable replacements for the non-standard + <classname>hash_map</classname> and <classname>hash_set</classname> containers in the SGI STL. </para> -<para> Header files <filename class="headerfile">hash_map</filename> and <filename class="headerfile">hash_set</filename> moved -to <filename class="headerfile">ext/hash_map</filename> and <filename class="headerfile">ext/hash_set</filename>, +<para> Header files <filename class="headerfile"><hash_map></filename> and <filename class="headerfile"><hash_set></filename> moved +to <filename class="headerfile"><ext/hash_map></filename> and <filename class="headerfile"><ext/hash_set></filename>, respectively. At the same time, all types in these files are enclosed -in <code>namespace __gnu_cxx</code>. Later versions move deprecate -these files, and suggest using TR1's <filename class="headerfile">unordered_map</filename> -and <filename class="headerfile">unordered_set</filename> instead. +in <code>namespace __gnu_cxx</code>. Later versions deprecate +these files, and suggest using TR1's <filename class="headerfile"><unordered_map></filename> +and <filename class="headerfile"><unordered_set></filename> instead. </para> <para>The extensions are no longer in the global or <code>std</code> @@ -778,7 +782,7 @@ AC_DEFUN([AC_HEADER_EXT_HASH_SET], [ </programlisting> </section> -<section><info><title>No <code>ios::nocreate/ios::noreplace</code>. +<section xml:id="backwards.third.nocreate_noreplace"><info><title>No <code>ios::nocreate/ios::noreplace</code>. </title></info> @@ -797,7 +801,7 @@ and <code>trunc</code> (except for <code>app</code> ?). </para> </section> -<section><info><title> +<section xml:id="backwards.third.streamattach"><info><title> No <code>stream::attach(int fd)</code> </title></info> @@ -819,7 +823,7 @@ No <code>stream::attach(int fd)</code> <para> An extension is available that implements this. - <filename class="headerfile">ext/stdio_filebuf.h</filename> contains a derived class called + <filename class="headerfile"><ext/stdio_filebuf.h></filename> contains a derived class called <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a00074.html"><code>__gnu_cxx::stdio_filebuf</code></link>. This class can be constructed from a C <code>FILE*</code> or a file descriptor, and provides the <code>fd()</code> function. @@ -832,7 +836,7 @@ No <code>stream::attach(int fd)</code> </para> </section> -<section><info><title> +<section xml:id="backwards.third.support_cxx98"><info><title> Support for C++98 dialect. </title></info> @@ -908,7 +912,7 @@ AC_DEFUN([AC_HEADER_STDCXX_98], [ </programlisting> </section> -<section><info><title> +<section xml:id="backwards.third.support_tr1"><info><title> Support for C++TR1 dialect. </title></info> @@ -1000,26 +1004,26 @@ AC_DEFUN([AC_HEADER_TR1_UNORDERED_SET], [ </section> -<section><info><title> -Support for C++0x dialect. +<section xml:id="backwards.third.support_cxx11"><info><title> +Support for C++11 dialect. </title></info> -<para>Check for baseline language coverage in the compiler for the C++0xstandard. +<para>Check for baseline language coverage in the compiler for the C++11 standard. </para> <programlisting> -# AC_COMPILE_STDCXX_OX -AC_DEFUN([AC_COMPILE_STDCXX_0X], [ - AC_CACHE_CHECK(if g++ supports C++0x features without additional flags, - ac_cv_cxx_compile_cxx0x_native, +# 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 <typename T> - struct check + struct check final { - static_assert(sizeof(int) <= sizeof(T), "not big enough"); + static constexpr T value{ __cplusplus }; }; typedef check<check<bool>> right_angle_brackets; @@ -1028,23 +1032,25 @@ AC_DEFUN([AC_COMPILE_STDCXX_0X], [ decltype(a) b; typedef check<int> check_type; - check_type c; - check_type&& cr = c;],, - ac_cv_cxx_compile_cxx0x_native=yes, ac_cv_cxx_compile_cxx0x_native=no) + check_type c{}; + check_type&& cr = static_cast<check_type&&>(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++0x features with -std=c++0x, - ac_cv_cxx_compile_cxx0x_cxx, + 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++0x" + CXXFLAGS="$CXXFLAGS -std=c++11" AC_TRY_COMPILE([ template <typename T> - struct check + struct check final { - static_assert(sizeof(int) <= sizeof(T), "not big enough"); + static constexpr T value{ __cplusplus }; }; typedef check<check<bool>> right_angle_brackets; @@ -1053,24 +1059,26 @@ AC_DEFUN([AC_COMPILE_STDCXX_0X], [ decltype(a) b; typedef check<int> check_type; - check_type c; - check_type&& cr = c;],, - ac_cv_cxx_compile_cxx0x_cxx=yes, ac_cv_cxx_compile_cxx0x_cxx=no) + check_type c{}; + check_type&& cr = static_cast<check_type&&>(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++0x features with -std=gnu++0x, - ac_cv_cxx_compile_cxx0x_gxx, + 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++0x" + CXXFLAGS="$CXXFLAGS -std=gnu++11" AC_TRY_COMPILE([ template <typename T> - struct check + struct check final { - static_assert(sizeof(int) <= sizeof(T), "not big enough"); + static constexpr T value{ __cplusplus }; }; typedef check<check<bool>> right_angle_brackets; @@ -1079,35 +1087,39 @@ AC_DEFUN([AC_COMPILE_STDCXX_0X], [ decltype(a) b; typedef check<int> check_type; - check_type c; - check_type&& cr = c;],, - ac_cv_cxx_compile_cxx0x_gxx=yes, ac_cv_cxx_compile_cxx0x_gxx=no) + check_type c{}; + check_type&& cr = static_cast<check_type&&>(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_cxx0x_native" = yes || - test "$ac_cv_cxx_compile_cxx0x_cxx" = yes || - test "$ac_cv_cxx_compile_cxx0x_gxx" = yes; then - AC_DEFINE(HAVE_STDCXX_0X,,[Define if g++ supports C++0x features. ]) + 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 ]) </programlisting> -<para>Check for library coverage of the C++0xstandard. +<para>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++). </para> <programlisting> -# AC_HEADER_STDCXX_0X -AC_DEFUN([AC_HEADER_STDCXX_0X], [ - AC_CACHE_CHECK(for ISO C++ 0x include files, - ac_cv_cxx_stdcxx_0x, - [AC_REQUIRE([AC_COMPILE_STDCXX_0X]) +# 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++0x" + CXXFLAGS="$CXXFLAGS -std=gnu++11" AC_TRY_COMPILE([ #include <cassert> @@ -1123,6 +1135,7 @@ AC_DEFUN([AC_HEADER_STDCXX_0X], [ #include <cmath> #include <csetjmp> #include <csignal> + #include <cstdalign> #include <cstdarg> #include <cstdbool> #include <cstddef> @@ -1132,21 +1145,29 @@ AC_DEFUN([AC_HEADER_STDCXX_0X], [ #include <cstring> #include <ctgmath> #include <ctime> + // #include <cuchar> #include <cwchar> #include <cwctype> #include <algorithm> #include <array> + #include <atomic> #include <bitset> + #include <chrono> + // #include <codecvt> #include <complex> + #include <condition_variable> #include <deque> #include <exception> + #include <forward_list> #include <fstream> #include <functional> + #include <future> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> + #include <initializer_list> #include <istream> #include <iterator> #include <limits> @@ -1154,19 +1175,25 @@ AC_DEFUN([AC_HEADER_STDCXX_0X], [ #include <locale> #include <map> #include <memory> + #include <mutex> #include <new> #include <numeric> #include <ostream> #include <queue> #include <random> + #include <ratio> #include <regex> + #include <scoped_allocator> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> + #include <system_error> + #include <thread> #include <tuple> + #include <typeindex> #include <typeinfo> #include <type_traits> #include <unordered_map> @@ -1175,17 +1202,18 @@ AC_DEFUN([AC_HEADER_STDCXX_0X], [ #include <valarray> #include <vector> ],, - ac_cv_cxx_stdcxx_0x=yes, ac_cv_cxx_stdcxx_0x=no) + 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_0x" = yes; then - AC_DEFINE(STDCXX_0X_HEADERS,,[Define if ISO C++ 0x header files are present. ]) + if test "$ac_cv_cxx_stdcxx_11" = yes; then + AC_DEFINE(STDCXX_11_HEADERS,,[Define if ISO C++11 header files are present. ]) fi ]) </programlisting> -<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> +<para>As is the case for TR1 support, these autoconf macros can be made for a finer-grained, per-header-file check. For +<filename class="headerfile"><unordered_map></filename> </para> <programlisting> @@ -1193,11 +1221,11 @@ AC_DEFUN([AC_HEADER_STDCXX_0X], [ AC_DEFUN([AC_HEADER_UNORDERED_MAP], [ AC_CACHE_CHECK(for unordered_map, ac_cv_cxx_unordered_map, - [AC_REQUIRE([AC_COMPILE_STDCXX_0X]) + [AC_REQUIRE([AC_COMPILE_STDCXX_11]) AC_LANG_SAVE AC_LANG_CPLUSPLUS ac_save_CXXFLAGS="$CXXFLAGS" - CXXFLAGS="$CXXFLAGS -std=gnu++0x" + CXXFLAGS="$CXXFLAGS -std=gnu++11" AC_TRY_COMPILE([#include <unordered_map>], [using std::unordered_map;], ac_cv_cxx_unordered_map=yes, ac_cv_cxx_unordered_map=no) CXXFLAGS="$ac_save_CXXFLAGS" @@ -1214,11 +1242,11 @@ AC_DEFUN([AC_HEADER_UNORDERED_MAP], [ AC_DEFUN([AC_HEADER_UNORDERED_SET], [ AC_CACHE_CHECK(for unordered_set, ac_cv_cxx_unordered_set, - [AC_REQUIRE([AC_COMPILE_STDCXX_0X]) + [AC_REQUIRE([AC_COMPILE_STDCXX_11]) AC_LANG_SAVE AC_LANG_CPLUSPLUS ac_save_CXXFLAGS="$CXXFLAGS" - CXXFLAGS="$CXXFLAGS -std=gnu++0x" + CXXFLAGS="$CXXFLAGS -std=gnu++11" AC_TRY_COMPILE([#include <unordered_set>], [using std::unordered_set;], ac_cv_cxx_unordered_set=yes, ac_cv_cxx_unordered_set=no) CXXFLAGS="$ac_save_CXXFLAGS" @@ -1229,15 +1257,26 @@ AC_DEFUN([AC_HEADER_UNORDERED_SET], [ fi ]) </programlisting> + +<para> + Some C++11 features first appeared in GCC 4.3 and could be enabled by + <option>-std=c++0x</option> and <option>-std=gnu++0x</option> 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 <option>-std=c++0x</option> and + <option>-std=gnu++0x</option>. +</para> + </section> -<section><info><title> - Container::iterator_type is not necessarily Container::value_type* +<section xml:id="backwards.third.iterator_type"><info><title> + <code>Container::iterator_type</code> is not necessarily <code>Container::value_type*</code> </title></info> <para> - This is a change in behavior from the previous version. Now, most + This is a change in behavior from older versions. Now, most <type>iterator_type</type> typedefs in container classes are POD objects, not <type>value_type</type> pointers. </para> |