From: Jonathan Wakely Date: Tue, 7 Aug 2018 22:50:28 +0000 (+0100) Subject: Improve libstdc++ docs w.r.t newer C++ standards X-Git-Tag: releases/gcc-7.4.0~225 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db1e6ce9e8d50ee7975f8fa7e6a0c5ac5cdf425f;p=thirdparty%2Fgcc.git Improve libstdc++ docs w.r.t newer C++ standards Instead of repeating all the old headers for every new standard I've changed the docs to only list the new headers for each standard. Backport from mainline 2018-07-31 Jonathan Wakely * doc/xml/manual/test.xml: Improve documentation on writing tests for newer standards. * doc/xml/manual/using.xml: Document all headers for C++11 and later. * doc/html/*: Regenerate. From-SVN: r263378 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 5df4cbcee233..dcf4f50ec2df 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,13 @@ 2018-08-07 Jonathan Wakely + Backport from mainline + 2018-07-31 Jonathan Wakely + + * doc/xml/manual/test.xml: Improve documentation on writing tests for + newer standards. + * doc/xml/manual/using.xml: Document all headers for C++11 and later. + * doc/html/*: Regenerate. + Backport from mainline 2018-08-03 Jonathan Wakely diff --git a/libstdc++-v3/doc/html/manual/index.html b/libstdc++-v3/doc/html/manual/index.html index ec39379387d3..cd4c98913a51 100644 --- a/libstdc++-v3/doc/html/manual/index.html +++ b/libstdc++-v3/doc/html/manual/index.html @@ -149,7 +149,7 @@ Support for C++11 dialect.
22.10. Non-unique Mapping Containers
22.11. Point Iterator Hierarchy
22.12. Invalidation Guarantee Tags Hierarchy
22.13. Container Tag Hierarchy
22.14. Hash functions, ranged-hash functions, and range-hashing functions
22.15. Insert hash sequence diagram
22.16. Insert hash sequence diagram with a null policy
22.17. Hash policy class diagram
22.18. Balls and bins
22.19. Insert resize sequence diagram
22.20. Standard resize policy trigger sequence diagram
22.21. Standard resize policy size sequence - diagram
22.22. Tree node invariants
22.23. Tree node invalidation
22.24. A tree and its update policy
22.25. Restoring node invariants
22.26. Insert update sequence
22.27. Useless update path
22.28. A PATRICIA trie
22.29. A trie and its update policy
22.30. A simple list
22.31. The counter algorithm
22.32. Underlying Priority-Queue Data-Structures.
22.33. Priority-Queue Data-Structure Tags.
B.1. Configure and Build File Dependencies

List of Equations

22.1. Ranged Hash Function
22.2. Range-Hashing, Division Method
22.3. Division via Prime Modulo
22.4. Division via Bit Mask
22.5. A Standard String Hash Function
22.6. Only k String DNA Hash diff --git a/libstdc++-v3/doc/html/manual/test.html b/libstdc++-v3/doc/html/manual/test.html index aed5a320b56e..0d419b8f00be 100644 --- a/libstdc++-v3/doc/html/manual/test.html +++ b/libstdc++-v3/doc/html/manual/test.html @@ -456,12 +456,15 @@ cat 27_io/objects/char/3_xin.in | a.out

Similarly, tests which depend on a newer standard than the default - should use dg-options instead of an effective target, - so that they are not skipped by default. + must use dg-options instead of (or in addition to) + an effective target, so that they are not skipped by default. For example, tests for C++17 features should use

    // { dg-options "-std=gnu++17" }

- and not -

    // { dg-do run "c++1z" }

+ before any dg-do such as: +

    // { dg-do run "c++17" }

+ The dg-options directive must come first, so that + the -std flag has already been added to the options + before checking the c++17 target.

Examples of Test Directives

Example 1: Testing compilation only:

diff --git a/libstdc++-v3/doc/html/manual/using_headers.html b/libstdc++-v3/doc/html/manual/using_headers.html
index a25323d40ecc..0cdff59df5d4 100644
--- a/libstdc++-v3/doc/html/manual/using_headers.html
+++ b/libstdc++-v3/doc/html/manual/using_headers.html
@@ -4,7 +4,7 @@
      must be available to all hosted implementations.  Actually, the
      word "files" is a misnomer, since the contents of the
      headers don't necessarily have to be in any kind of external
-     file.  The only rule is that when one #include's a
+     file.  The only rule is that when one #includes a
      header, the contents of that header become available, no matter
      how.
    

@@ -12,25 +12,84 @@

There are two main types of include files: header files related to a specific version of the ISO C++ standard (called Standard - Headers), and all others (TR1, C++ ABI, and Extensions). + Headers), and all others (TS, TR1, C++ ABI, and Extensions).

- Two dialects of standard headers are supported, corresponding to - the 1998 standard as updated for 2003, and the current 2011 standard. + Multiple dialects of standard headers are supported, corresponding to + the 1998 standard as updated for 2003, the 2011 standard, the 2014 + standard, and so on.

- C++98/03 include files. These are available in the default compilation mode, i.e. -std=c++98 or -std=gnu++98. -

Table 3.2. C++ 1998 Library Headers

algorithmbitsetcomplexdequeexception
fstreamfunctionaliomanipiosiosfwd
iostreamistreamiteratorlimitslist
localemapmemorynewnumeric
ostreamqueuesetsstreamstack
stdexceptstreambufstringutilitytypeinfo
valarrayvector   

Table 3.3. C++ 1998 Library Headers for C Library Facilities

cassertcerrnocctypecfloatciso646
climitsclocalecmathcsetjmpcsignal
cstdargcstddefcstdiocstdlibcstring
ctimecwcharcwctype  

-C++11 include files. These are only available in C++11 compilation + Table 3.2, “C++ 1998 Library Headers” and + Table 3.3, “C++ 1998 Library Headers for C Library Facilities” and + Table 3.4, “C++ 1998 Deprecated Library Header” + show the C++98/03 include files. + These are available in the C++98 compilation mode, + i.e. -std=c++98 or -std=gnu++98. + Unless specified otherwise below, they are also available in later modes + (C++11, C++14 etc). +

Table 3.2. C++ 1998 Library Headers

algorithmbitsetcomplexdequeexception
fstreamfunctionaliomanipiosiosfwd
iostreamistreamiteratorlimitslist
localemapmemorynewnumeric
ostreamqueuesetsstreamstack
stdexceptstreambufstringutilitytypeinfo
valarrayvector 

Table 3.3. C++ 1998 Library Headers for C Library Facilities

cassertcerrnocctypecfloatciso646
climitsclocalecmathcsetjmpcsignal
cstdargcstddefcstdiocstdlibcstring
ctimecwcharcwctype 

+ The following header is deprecated + and might be removed from a future C++ standard. +

Table 3.4. C++ 1998 Deprecated Library Header

strstream

+Table 3.5, “C++ 2011 Library Headers” and +Table 3.6, “C++ 2011 Library Headers for C Library Facilities” show the C++11 include files. +These are available in C++11 compilation mode, i.e. -std=c++11 or -std=gnu++11. -

Table 3.4. C++ 2011 Library Headers

algorithmarraybitsetchronocomplex
condition_variabledequeexceptionforward_listfstream
functionalfutureinitalizer_listiomanipios
iosfwdiostreamistreamiteratorlimits
listlocalemapmemorymutex
newnumericostreamqueuerandom
ratioregexsetsstreamstack
stdexceptstreambufstringsystem_errorthread
tupletype_traitstypeinfounordered_mapunordered_set
utilityvalarrayvector  

Table 3.5. C++ 2011 Library Headers for C Library Facilities

cassertccomplexcctypecerrnocfenv
cfloatcinttypesciso646climitsclocale
cmathcsetjmpcsignalcstdargcstdbool
cstddefcstdintcstdlibcstdiocstring
ctgmathctimecucharcwcharcwctype

+Including these headers in C++98/03 mode may result in compilation errors. +Unless specified otherwise below, they are also available in later modes +(C++14 etc). +

Table 3.5. C++ 2011 Library Headers

arrayatomicchronocodecvtcondition_variable
forward_listfutureinitalizer_listmutexrandom
ratioregexscoped_allocatorsystem_errorthread
tupletypeindextype_traitsunordered_mapunordered_set

Table 3.6. C++ 2011 Library Headers for C Library Facilities

ccomplexcfenvcinttypescstdaligncstdbool
cstdintctgmathcuchar 

+Table 3.7, “C++ 2014 Library Header” shows the C++14 include file. +This is available in C++14 compilation +mode, i.e. -std=c++14 or -std=gnu++14. +Including this header in C++98/03 mode or C++11 will not result in +compilation errors, but will not define anything. +Unless specified otherwise below, it is also available in later modes +(C++17 etc). +

Table 3.7. C++ 2014 Library Header

shared_mutex

+Table 3.8, “C++ 2017 Library Headers” shows the C++17 include files. +These are available in C++17 compilation +mode, i.e. -std=c++17 or -std=gnu++17. +Including these headers in earlier modes will not result in +compilation errors, but will not define anything. +Unless specified otherwise below, they are also available in later modes +(C++20 etc). +

Table 3.8. C++ 2017 Library Headers

anycharconvexecutionfilesystemmemory_resource
optionalstring_viewvariant 

+Table 3.9, “C++ 2020 Library Headers” +shows the C++2a include files. +These are available in C++2a compilation +mode, i.e. -std=c++2a or -std=gnu++2a. +Including these headers in earlier modes will not result in +compilation errors, but will not define anything. + +

Table 3.9. C++ 2020 Library Headers

bitversion

+ The following headers have been removed in the C++2a working draft. + They are still available when using this implementation, but in future + they might start to produce warnings or errors when included in C++2a mode. + Programs that intend to be portable should not include them. +

Table 3.10. C++ 2020 Obsolete Headers

ccomplexciso646cstdaligncstdboolctgmath

+Table 3.11, “File System TS Header”, +shows the additional include file define by the +File System Technical Specification, ISO/IEC TS 18822. +This is available in C++11 and later compilation modes. +Including this header in earlier modes will not result in +compilation errors, but will not define anything. +

Table 3.11. File System TS Header

experimental/filesystem

+Table 3.12, “Library Fundamentals TS Headers”, +shows the additional include files define by the C++ Extensions for +Library Fundamentals Technical Specification, ISO/IEC TS 19568. +These are available in C++14 and later compilation modes. +Including these headers in earlier modes will not result in +compilation errors, but will not define anything. +

Table 3.12. Library Fundamentals TS Headers

experimental/algorithmexperimental/anyexperimental/arrayexperimental/chronoexperimental/deque
experimental/forward_listexperimental/functionalexperimental/iteratorexperimental/listexperimental/map
experimental/memoryexperimental/memory_resourceexperimental/optionalexperimental/propagate_constexperimental/random
experimental/ratioexperimental/regexexperimental/setexperimental/source_locationexperimental/string
experimental/string_viewexperimental/ssytem_errorexperimental/tupleexperimental/type_traitsexperimental/unordered_map
experimental/unordered_setexperimental/utilityexperimental/vector 

In addition, TR1 includes as: -

Table 3.6. C++ TR 1 Library Headers

tr1/arraytr1/complextr1/memorytr1/functionaltr1/random
tr1/regextr1/tupletr1/type_traitstr1/unordered_maptr1/unordered_set
tr1/utility    

Table 3.7. C++ TR 1 Library Headers for C Library Facilities

tr1/ccomplextr1/cfenvtr1/cfloattr1/cmathtr1/cinttypes
tr1/climitstr1/cstdargtr1/cstdbooltr1/cstdinttr1/cstdio
tr1/cstdlibtr1/ctgmathtr1/ctimetr1/cwchartr1/cwctype

Decimal floating-point arithmetic is available if the C++ +

Table 3.13. C++ TR 1 Library Headers

tr1/arraytr1/complextr1/memorytr1/functionaltr1/random
tr1/regextr1/tupletr1/type_traitstr1/unordered_maptr1/unordered_set
tr1/utility 

Table 3.14. C++ TR 1 Library Headers for C Library Facilities

tr1/ccomplextr1/cfenvtr1/cfloattr1/cmathtr1/cinttypes
tr1/climitstr1/cstdargtr1/cstdbooltr1/cstdinttr1/cstdio
tr1/cstdlibtr1/ctgmathtr1/ctimetr1/cwchartr1/cwctype

Decimal floating-point arithmetic is available if the C++ compiler supports scalar decimal floating-point types defined via __attribute__((mode(SD|DD|LD))). -

Table 3.8. C++ TR 24733 Decimal Floating-Point Header

decimal/decimal

+

Table 3.15. C++ TR 24733 Decimal Floating-Point Header

decimal/decimal

Also included are files for the C++ ABI interface: -

Table 3.9. C++ ABI Headers

cxxabi.hcxxabi_forced.h

+

Table 3.16. C++ ABI Headers

cxxabi.hcxxabi_forced.h

And a large variety of extensions. -

Table 3.10. Extension Headers

ext/algorithmext/atomicity.hext/array_allocator.hext/bitmap_allocator.hext/cast.h
ext/codecvt_specializations.hext/concurrence.hext/debug_allocator.hext/enc_filebuf.hext/extptr_allocator.h
ext/functionalext/iteratorext/malloc_allocator.hext/memoryext/mt_allocator.h
ext/new_allocator.hext/numericext/numeric_traits.hext/pb_ds/assoc_container.hext/pb_ds/priority_queue.h
ext/pod_char_traits.hext/pool_allocator.hext/rb_treeext/ropeext/slist
ext/stdio_filebuf.hext/stdio_sync_filebuf.hext/throw_allocator.hext/typelist.hext/type_traits.h
ext/vstring.h    

Table 3.11. Extension Debug Headers

debug/bitsetdebug/dequedebug/listdebug/mapdebug/set
debug/stringdebug/unordered_mapdebug/unordered_setdebug/vector 

Table 3.12. Extension Profile Headers

profile/bitsetprofile/dequeprofile/listprofile/map
profile/setprofile/unordered_mapprofile/unordered_setprofile/vector

Table 3.13. Extension Parallel Headers

parallel/algorithmparallel/numeric

Mixing Headers

A few simple rules. +

Table 3.17. Extension Headers

ext/algorithmext/atomicity.hext/array_allocator.hext/bitmap_allocator.hext/cast.h
ext/codecvt_specializations.hext/concurrence.hext/debug_allocator.hext/enc_filebuf.hext/extptr_allocator.h
ext/functionalext/iteratorext/malloc_allocator.hext/memoryext/mt_allocator.h
ext/new_allocator.hext/numericext/numeric_traits.hext/pb_ds/assoc_container.hext/pb_ds/priority_queue.h
ext/pod_char_traits.hext/pool_allocator.hext/rb_treeext/ropeext/slist
ext/stdio_filebuf.hext/stdio_sync_filebuf.hext/throw_allocator.hext/typelist.hext/type_traits.h
ext/vstring.h 

Table 3.18. Extension Debug Headers

debug/arraydebug/bitsetdebug/dequedebug/forward_listdebug/list
debug/mapdebug/setdebug/stringdebug/unordered_mapdebug/unordered_set
debug/vector 

Table 3.19. Extension Profile Headers

profile/bitsetprofile/dequeprofile/listprofile/map
profile/setprofile/unordered_mapprofile/unordered_setprofile/vector

Table 3.20. Extension Parallel Headers

parallel/algorithmparallel/numeric

Mixing Headers

A few simple rules.

First, mixing different dialects of the standard headers is not possible. It's an all-or-nothing affair. Thus, code like

diff --git a/libstdc++-v3/doc/xml/manual/test.xml b/libstdc++-v3/doc/xml/manual/test.xml
index 154b74cbf9f0..ef0de7957544 100644
--- a/libstdc++-v3/doc/xml/manual/test.xml
+++ b/libstdc++-v3/doc/xml/manual/test.xml
@@ -753,12 +753,15 @@ cat 27_io/objects/char/3_xin.in | a.out
 
   
     Similarly, tests which depend on a newer standard than the default
-    should use dg-options instead of an effective target,
-    so that they are not skipped by default.
+    must use dg-options instead of (or in addition to)
+    an effective target, so that they are not skipped by default.
     For example, tests for C++17 features should use
     // { dg-options "-std=gnu++17" }
-    and not
-    // { dg-do run "c++1z" }
+    before any dg-do such as:
+    // { dg-do run "c++17" }
+    The dg-options directive must come first, so that
+    the -std flag has already been added to the options
+    before checking the c++17 target.
   
 
 
Examples of Test Directives diff --git a/libstdc++-v3/doc/xml/manual/using.xml b/libstdc++-v3/doc/xml/manual/using.xml index 992e4ecea8d0..a468c404cef3 100644 --- a/libstdc++-v3/doc/xml/manual/using.xml +++ b/libstdc++-v3/doc/xml/manual/using.xml @@ -126,7 +126,7 @@ must be available to all hosted implementations. Actually, the word "files" is a misnomer, since the contents of the headers don't necessarily have to be in any kind of external - file. The only rule is that when one #include's a + file. The only rule is that when one #includes a header, the contents of that header become available, no matter how. @@ -138,16 +138,24 @@ There are two main types of include files: header files related to a specific version of the ISO C++ standard (called Standard - Headers), and all others (TR1, C++ ABI, and Extensions). + Headers), and all others (TS, TR1, C++ ABI, and Extensions). - Two dialects of standard headers are supported, corresponding to - the 1998 standard as updated for 2003, and the current 2011 standard. + Multiple dialects of standard headers are supported, corresponding to + the 1998 standard as updated for 2003, the 2011 standard, the 2014 + standard, and so on. - C++98/03 include files. These are available in the default compilation mode, i.e. -std=c++98 or -std=gnu++98. + and + and + + show the C++98/03 include files. + These are available in the C++98 compilation mode, + i.e. -std=c++98 or -std=gnu++98. + Unless specified otherwise below, they are also available in later modes + (C++11, C++14 etc). @@ -205,6 +213,7 @@ valarray vector + @@ -246,14 +255,38 @@ ctimecwcharcwctype +
-C++11 include files. These are only available in C++11 compilation + The following header is deprecated + and might be removed from a future C++ standard. + + + +C++ 1998 Deprecated Library Header + + + + + +strstream + + + +
+ + + and + show the C++11 include files. +These are available in C++11 compilation mode, i.e. -std=c++11 or -std=gnu++11. +Including these headers in C++98/03 mode may result in compilation errors. +Unless specified otherwise below, they are also available in later modes +(C++14 etc). @@ -269,73 +302,33 @@ mode, i.e. -std=c++11 or -std=gnu++11. -algorithm array -bitset +atomic chrono -complex - - +codecvt condition_variable -deque -exception -forward_list -fstream -functional +forward_list future initalizer_list -iomanip -ios - - -iosfwd -iostream -istream -iterator -limits - - -list -locale -map -memory mutex - - -new -numeric -ostream -queue random ratio regex -set -sstream -stack - - -stdexcept -streambuf -string +scoped_allocator system_error thread tuple +typeindex type_traits -typeinfo unordered_map unordered_set - -utility -valarray -vector - @@ -354,39 +347,231 @@ mode, i.e. -std=c++11 or -std=gnu++11. -cassert ccomplex -cctype -cerrno cfenv +cinttypes +cstdalign +cstdbool -cfloat -cinttypes -ciso646 -climits -clocale +cstdint +ctgmath +cuchar + + + + + + + shows the C++14 include file. +This is available in C++14 compilation +mode, i.e. -std=c++14 or -std=gnu++14. +Including this header in C++98/03 mode or C++11 will not result in +compilation errors, but will not define anything. +Unless specified otherwise below, it is also available in later modes +(C++17 etc). + + + + +C++ 2014 Library Header + + + + -cmath -csetjmp -csignal -cstdarg -cstdbool +shared_mutex + + + +
+ + + shows the C++17 include files. +These are available in C++17 compilation +mode, i.e. -std=c++17 or -std=gnu++17. +Including these headers in earlier modes will not result in +compilation errors, but will not define anything. +Unless specified otherwise below, they are also available in later modes +(C++20 etc). + + + + +C++ 2017 Library Headers + + + + + + + + + +any +charconv +execution +filesystem +memory_resource -cstddef -cstdint -cstdlib -cstdio -cstring +optional +string_view +variant + + + +
+ + + +shows the C++2a include files. +These are available in C++2a compilation +mode, i.e. -std=c++2a or -std=gnu++2a. +Including these headers in earlier modes will not result in +compilation errors, but will not define anything. + + + + + +C++ 2020 Library Headers + + + + + + +bit +version + + + + +
+ + + The following headers have been removed in the C++2a working draft. + They are still available when using this implementation, but in future + they might start to produce warnings or errors when included in C++2a mode. + Programs that intend to be portable should not include them. + + + +C++ 2020 Obsolete Headers + + + + + + + + + +ccomplex +ciso646 +cstdalign +cstdbool ctgmath -ctime -cuchar -cwchar -cwctype + + + +
+ + +, +shows the additional include file define by the +File System Technical Specification, ISO/IEC TS 18822. +This is available in C++11 and later compilation modes. +Including this header in earlier modes will not result in +compilation errors, but will not define anything. + + + + +File System TS Header + + + + + +experimental/filesystem + + + +
+ + + +, +shows the additional include files define by the C++ Extensions for +Library Fundamentals Technical Specification, ISO/IEC TS 19568. +These are available in C++14 and later compilation modes. +Including these headers in earlier modes will not result in +compilation errors, but will not define anything. + + + + +Library Fundamentals TS Headers + + + + + + + + + +experimental/algorithm +experimental/any +experimental/array +experimental/chrono +experimental/deque + + +experimental/forward_list +experimental/functional +experimental/iterator +experimental/list +experimental/map + + +experimental/memory +experimental/memory_resource +experimental/optional +experimental/propagate_const +experimental/random + + +experimental/ratio +experimental/regex +experimental/set +experimental/source_location +experimental/string + + +experimental/string_view +experimental/ssytem_error +experimental/tuple +experimental/type_traits +experimental/unordered_map + + +experimental/unordered_set +experimental/utility +experimental/vector + @@ -424,6 +609,7 @@ mode, i.e. -std=c++11 or -std=gnu++11. tr1/utility + @@ -564,6 +750,7 @@ compiler supports scalar decimal floating-point types defined via ext/vstring.h + @@ -584,18 +771,22 @@ compiler supports scalar decimal floating-point types defined via +debug/array debug/bitset debug/deque +debug/forward_list debug/list -debug/map -debug/set - +debug/map +debug/set debug/string debug/unordered_map debug/unordered_set + + debug/vector +