From: Jonathan Wakely Date: Tue, 31 Jul 2018 15:02:32 +0000 (+0100) Subject: Improve libstdc++ docs w.r.t newer C++ standards X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3e64a626d722129828d95dd690da3966bb7ec968;p=gcc.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. * 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: r263163 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index b77a9f00bc9..f2f7676b63f 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,10 @@ 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. + * include/ext/pointer.h [__cplusplus >= 201103L] (_Pointer_adapter::operator bool): Add explicit conversion operator to replace safe bool idiom. diff --git a/libstdc++-v3/doc/html/manual/bugs.html b/libstdc++-v3/doc/html/manual/bugs.html index db124e18a04..4430583c382 100644 --- a/libstdc++-v3/doc/html/manual/bugs.html +++ b/libstdc++-v3/doc/html/manual/bugs.html @@ -526,4 +526,18 @@ weak_ptr::owner_before

Add noexcept. +

2993: + reference_wrapper<T> conversion from T&& + +

Replaced the constructors with a constrained template, + to prevent participation in overload resolution when not valid. +

3074: + Non-member functions for valarray should only deduce from the valarray + +

Change scalar operands to be non-deduced context, so that + they will allow conversions from other types to the value_type. +

3076: + basic_string CTAD ambiguity + +

Change constructors to constrained templates.

\ No newline at end of file diff --git a/libstdc++-v3/doc/html/manual/index.html b/libstdc++-v3/doc/html/manual/index.html index b1a5103ba6c..4fa36bac9b9 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

Implementation Specific Behavior

For behaviour which is also specified by previous standards, + Logical Operator Type Traits (revision 1)YLibrary Fundamentals 2 TS + + N4531 + + std::rand replacement, revision 3YLibrary Fundamentals 2 TS


Implementation Specific Behavior

For behaviour which is also specified by previous standards, see C++ 1998/2003 Implementation Specific Behavior and C++ 2011 Implementation Specific Behavior. This section only diff --git a/libstdc++-v3/doc/html/manual/test.html b/libstdc++-v3/doc/html/manual/test.html index 8edc4facb00..da801987cbd 100644 --- a/libstdc++-v3/doc/html/manual/test.html +++ b/libstdc++-v3/doc/html/manual/test.html @@ -464,12 +464,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 a25323d40ec..0cdff59df5d 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 c8c47d1bbdb..1725cdb69f3 100644
--- a/libstdc++-v3/doc/xml/manual/test.xml
+++ b/libstdc++-v3/doc/xml/manual/test.xml
@@ -763,12 +763,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 67f9cf5216b..a5f2a2d074d 100644 --- a/libstdc++-v3/doc/xml/manual/using.xml +++ b/libstdc++-v3/doc/xml/manual/using.xml @@ -128,7 +128,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. @@ -140,16 +140,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). @@ -207,6 +215,7 @@ valarray vector + @@ -248,14 +257,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). @@ -271,73 +304,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 - @@ -356,39 +349,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 + @@ -426,6 +611,7 @@ mode, i.e. -std=c++11 or -std=gnu++11. tr1/utility + @@ -566,6 +752,7 @@ compiler supports scalar decimal floating-point types defined via ext/vstring.h + @@ -586,18 +773,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 +