diff --git a/.travis.yml b/.travis.yml index 23c2beeb11..6aa3f6338c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,17 @@ # Builds the C++ standard document on Travis CI # +dist: trusty +sudo: required +language: cpp + +services: + - docker + +before_install: + - docker pull godbyk/texlive-basic:latest + - docker run -itd -v $TRAVIS_BUILD_DIR:/$TRAVIS_REPO_SLUG --name texlive-basic godbyk/texlive-basic + env: - BUILD_TYPE=latexmk # build using latexmk, also check for overfull hboxes - BUILD_TYPE=make # build using Makefile @@ -14,26 +25,28 @@ script: # Build std.pdf - pushd source - if [ "$BUILD_TYPE" = "latexmk" ]; then - latexmk -pdf std -silent; + docker exec -it texlive-basic bash -c "cd /$TRAVIS_REPO_SLUG/source && latexmk -pdf std -silent"; ! grep -Fe "Overfull \\hbox" std.log; fi - if [ "$BUILD_TYPE" = "make" ]; then - make -j2; + docker exec -it texlive-basic bash -c "cd /$TRAVIS_REPO_SLUG/source && make -j2"; fi - if [ "$BUILD_TYPE" = "complete" ]; then for FIGURE in *.dot; do - dot -o$(basename $FIGURE .dot).pdf -Tpdf $FIGURE; + docker exec -it texlive-basic bash -c "cd /$TRAVIS_REPO_SLUG/source && dot -o$(basename $FIGURE .dot).pdf -Tpdf $FIGURE"; done; - pdflatex std; - pdflatex std; - pdflatex std; - makeindex generalindex; - makeindex libraryindex; - makeindex grammarindex; - makeindex impldefindex; - makeindex -s basic.gst -o xrefindex.gls xrefindex.glo - pdflatex std; - pdflatex std; + docker exec -it texlive-basic bash -c "cd /$TRAVIS_REPO_SLUG/source && pdflatex std"; + docker exec -it texlive-basic bash -c "cd /$TRAVIS_REPO_SLUG/source && pdflatex std"; + docker exec -it texlive-basic bash -c "cd /$TRAVIS_REPO_SLUG/source && pdflatex std"; + docker exec -it texlive-basic bash -c "cd /$TRAVIS_REPO_SLUG/source && makeindex generalindex"; + docker exec -it texlive-basic bash -c "cd /$TRAVIS_REPO_SLUG/source && makeindex libraryindex"; + docker exec -it texlive-basic bash -c "cd /$TRAVIS_REPO_SLUG/source && makeindex grammarindex"; + docker exec -it texlive-basic bash -c "cd /$TRAVIS_REPO_SLUG/source && makeindex impldefindex"; + docker exec -it texlive-basic bash -c "cd /$TRAVIS_REPO_SLUG/source && pdflatex std"; + docker exec -it texlive-basic bash -c "cd /$TRAVIS_REPO_SLUG/source && makeindex -s basic.gst -o xrefindex.gls xrefindex.glo"; + docker exec -it texlive-basic bash -c "cd /$TRAVIS_REPO_SLUG/source && makeindex -s basic.gst -o xrefdelta.gls xrefdelta.glo"; + docker exec -it texlive-basic bash -c "cd /$TRAVIS_REPO_SLUG/source && pdflatex std"; + docker exec -it texlive-basic bash -c "cd /$TRAVIS_REPO_SLUG/source && pdflatex std"; fi - popd # Fail if there is whitespace at the ends of any lines @@ -52,24 +65,8 @@ script: # Check to see if generated files are out-dated - pushd source - for FIGURE in *.dot; do - dot -o$(basename $FIGURE .dot).pdf -Tpdf $FIGURE; + docker exec -it texlive-basic bash -c "cd /$TRAVIS_REPO_SLUG/source && dot -o$(basename $FIGURE .dot).pdf -Tpdf $FIGURE"; git status --porcelain $(basename $FIGURE .dot).pdf; done - popd -sudo: false - -addons: - apt: - packages: - - latexmk - - poppler-utils - - texlive-binaries - - texlive-fonts-recommended - - texlive-latex-base - - texlive-latex-extra - - texlive-latex-recommended - - texlive-generic-recommended - - texlive-binaries - - graphviz - - lmodern diff --git a/README.rst b/README.rst index 3d61cca030..1b598e7bfe 100644 --- a/README.rst +++ b/README.rst @@ -76,7 +76,9 @@ If you can't use latexmk or make for some reason, you can run LaTeX manually ins #. run ``makeindex libraryindex`` #. run ``makeindex grammarindex`` #. run ``makeindex impldefindex`` +#. run ``pdflatex std`` once more. #. run ``makeindex -s basic.gst -o xrefindex.gls xrefindex.glo`` +#. run ``makeindex -s basic.gst -o xrefdelta.gls xrefdelta.glo`` #. run ``pdflatex std`` twice more. Generated input files diff --git a/papers/n4740.html b/papers/n4740.html new file mode 100644 index 0000000000..72f7586c42 --- /dev/null +++ b/papers/n4740.html @@ -0,0 +1,850 @@ +N4740 +

N4740 Editors' Report -- Programming Languages -- C++

+ +

2018-04-02
+Richard Smith (editor) (Google Inc)
+Dawn Perchik (co-editor) (Bright Side Computing, LLC)
+Thomas Köppe (co-editor) (Google DeepMind)
+<cxxeditor@gmail.com>

+ +

Acknowledgements

+ +

Special thanks to +Jens Maurer +for performing many of the editorial fixes since N4727.

+ +

Thanks to Walter E Brown and Peter Sommerlad for +supplying LaTeX sources for their papers +P0551R3 (LWG motion 13) +and +P0753R2 (LWG motion 14).

+ +

Thanks to all those who have submitted editorial +issues +and to those who have provided pull requests with fixes.

+ +

New papers

+ + + +

Motions incorporated into working draft

+ +

Core working group motions

+ +

CWG motion 1: Core issue resolutions for 17 issue in "tentatively ready" status applied:

+ + + +

CWG motion 2: P0840R2 "Language support for empty objects"

+ +

CWG motion 3: P0962R1 "Relaxing the range-for customization point finding rules"

+ +

CWG motion 4: P0969R0 "Allow structured bindings to accessible members"

+ +

CWG motion 5: P0961R1 "Relaxing the structured bindings customization point finding rules"

+ +

CWG motion 6: P0634R3 "Down with typename!"

+ +

CWG motion 7: P0780R2 "Allow pack expansion in lambda init-capture"

+ +

CWG motion 8: P0479R5 "likely and unlikely attributes"

+ +

CWG motion 9: P0905R1 "Symmetry for spaceship" with wording changes, see below

+ +

CWG motions 10 and 11 apply to the Coroutines TS.

+ +

Library working group motions

+ +

LWG motions 1 and 2 apply to the Parallelism TS.

+ +

LWG motion 3 applies to the Reflection TS.

+ +

LWG motion 4 applies to the Coroutines TS.

+ +

LWG motion 5 applies to the Networking TS.

+ +

LWG motion 6 applies to the Library Fundamentals TS.

+ +

LWG motion 7: Library issue resolutions for 29 issues in "Ready" or "Tentatively Ready" status applied:

+ + + +

LWG motion 8: Library issue resolutions for 2 issues in "Immediate" status applied:

+ + + +

LWG motion 9: P0754R2 "<version>"

+ +

LWG motion 10: P0809R0 "Comparing unordered containers", resolving 1 library issue:

+ + + +

LWG motion 11: P0355R7 "Extending chrono to calendars and time zones" with wording changes, see below

+ +

LWG motion 12: P0966R1 "string::reserve should not shrink"

+ +

LWG motion 13: P0551R3 "Thou shalt not specialize std function templates!"

+ +

LWG motion 14: P0753R2 "Manipulators for C++ synchronized buffered ostream"

+ +

LWG motion 15: P0122R7 "<span>" with wording changes, see below

+ +

LWG motion 16: P0858R0 "Constexpr iterator requirements"

+ +

Notable editorial changes

+ +

CWG motion 9

+ +

After consultation with CWG, the wording for injecting additional operator<=> +candidates has been editorially reworked, introducing a named set of "rewritten +candidates" in the place of the ad-hoc additional lookups previously specified. +That change allows the wording of this motion to be expressed more directly, +but, as a consequence, the wording changes applied for this paper differ +substantially from those moved.

+ +

LWG motion 11

+ +

This paper introduces a large amount of new text (~78 pages), and as such a +substantial quantity of editorial changes were necessary to align the moved +wording with the Working Draft's style guidelines:

+ + + +

LWG motion 15

+ + + +

Simplification of non-member swap presentation

+ +

The specification for the non-member swap function for container types has +been consolidated in the container requirements table, replacing the former +presentation which repeated the description once for each container.

+ +

This removes the subclauses +[deque.special], +[forwardlist.special], +[list.special], +[vector.special], +[map.special], +[multimap.special], +[set.special], +[multiset.special], +[unord.map.swap], +[unord.multimap.swap], +[unord.set.swap], +and +[unord.multiset.swap].

+ +

reverse_iterator subclause consolidation

+ +

reverse_iterator previously had one subclause for each member function, +in violation of our normal presentation style. These subclauses have been +merged into groups of related functionality as follows:

+ + + +

Simplification of basic_regex constant presentation

+ +

The presentation style used for the synopsis of the basic_regex synonyms +for the std::regex_constants has been shortened by use of a typedef, and +the subclause [re.regex.const] containing redundant out-of-line descriptions +of those flags has been removed.

+ +

Cleanup of uses of the word "concept"

+ +

In the Working Draft, the word "concept" is used both in the technical sense, +denoting a C++ concept, and informally, denoting an idea or notion. We have +editorially cleaned up a few of the more confusing and ambiguous instances of +the term; most notably, Clause 6, formerly named "Basic concepts", is now +named "Basics".

+ +

Minor editorial fixes

+ +

A log of editorial fixes made to the working draft since N4727 is below. +This list excludes changes +that do not affect the body text or only affect whitespace or typeface. For a +complete list including such changes (or for the actual deltas applied by these +changes), consult the draft sources on github.

+ +
commit 17191eca85eebcacbc3ef37e61ee51103d892268
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Mar 28 21:05:41 2018 +0200
+
+    [any.class] Rephrase small-object optimization
+
+commit 05675f74017966048a4db1a5c5419be357082622
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Mon Apr 2 22:44:03 2018 +0100
+
+    [any.class, optional.optional] Add missing "namespace std" around class definitions.
+
+commit 2fcacf3f23a5fbf9cd95611342803ba536904d01
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Mon Apr 2 13:45:41 2018 -0700
+
+    [container.node] Remove placeholder class name from subheadings.
+
+    Partially addresses #1242.
+
+commit 87ae756d027d7e611d6e89f7d3232a95b6c72203
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Mon Apr 2 21:56:40 2018 +0200
+
+    [xrefdelta] Fixes for reverse_iterator cleanup (#2015)
+
+commit 4aa55de012f85e9f250f2c608e00a351fc9db9f1
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Mon Apr 2 13:40:32 2018 +0100
+
+    [layout] Place footnotes at the bottom of the page. (#1830)
+
+    This uses a feature introduced by memoir 3.7e, '\feetatbottom',
+    which makes footnotes appear at the bottom of the page, rather
+    than immediately following the main text.
+
+commit 5b5d225156372b717d84e0137ab759626a8886f4
+Author: Hubert Tong <hstong@ca.ibm.com>
+Date:   Mon Apr 2 00:29:33 2018 -0400
+
+    [temp.concept]: Use note; no syntax for explicit specialization, etc.
+
+    Explicit specialization, etc. of a concept cannot be formed
+    syntactically. As such, a further rule to prevent such constructs is
+    redundant as normative text.
+
+    Implements the proposed direction from core/2017/07/2719.
+
+commit bec67956e817d7edd02bdbffe5b1254113102928
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Sun Apr 1 20:11:03 2018 -0700
+
+    [over.match.best] Use new "rewritten candidates" terminology to simplify
+    wording.
+
+commit 51684d21aa98c6cf20a44274f38ffd07b191e2f2
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Mon Mar 26 18:53:28 2018 -0700
+
+    [over.match.oper] Refactor the <=> rewrite candidate rules for clarity.
+
+commit e0a88df11e5cf0988b40dd65218d7ce9f456c763
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Mar 30 11:15:42 2018 +0200
+
+    [ostream.manip,time] Replace "can not" with "cannot"
+
+commit 6c9e27dab526298771cdbf1a8dacf165f6547ead
+Author: Tony Van Eerd <tvaneerd@gmail.com>
+Date:   Sun Apr 1 22:14:59 2018 -0400
+
+    [sequence.reqmts] Convert advice on container selection into a note.
+
+    Also separate out the advice for std::array from that for std::vector and emphasize the main message.
+
+commit 7e4b556f44c47c70c4d1e93c5b3c82b01a949326
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Mar 24 19:42:20 2018 +0100
+
+    [implimits] Clarify meaning of implementation limits
+
+commit b1c4c87a7ca880e4d2e46cb9b62517e940ef0339
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Tue Feb 20 22:55:17 2018 +0100
+
+    [lib] Replace 'requirements of FrobMunchable'
+
+    with 'FrobMunchable requirements'.
+
+commit 2a1d53b1820a460066ae374a95529c7def2dda16
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Tue Feb 20 22:27:27 2018 +0100
+
+    [lib] Use table references for CamelCase requirements.
+
+commit dbeb68f0dd7bb8fd950f33a94409b9d5ba778729
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Mon Feb 19 22:44:54 2018 +0100
+
+    [lib] Use "shall satisfy", not "shall meet", for requirements.
+
+commit 8738c6b38db45d06724e4a75afd2134d3f6e6f3f
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Mar 23 21:27:11 2018 +0100
+
+    [containers] Removed redundant specifications of non-member swap
+
+commit 4d3434c2c9ed41c31925172948ff81166f623f64
+Author: eus <eus@member.fsf.org>
+Date:   Mon Apr 2 03:41:11 2018 +0200
+
+    [expr.ass] Clarify description of simple assignment
+
+    Replace vague "value of the expression" wording with more-precise "result of the right operand".
+
+commit 1b4da01c47fcf7522fa3df0d8c0b96ed840f4103
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sun Mar 18 17:56:14 2018 +0100
+
+    [associative.reqmts] Turn emphasis into a note.
+
+commit 1a9fd49cdf58d6dfe8da51dcad93ce8f73f144e0
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Mon Feb 19 18:37:49 2018 +0100
+
+    [expr.dynamic.cast] Remove redundant statements on casting away constness
+
+commit 73bfbf2d8a40822779dfdd544f5112fd2096a7d9
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Feb 17 11:26:07 2018 +0100
+
+    [stmt.while] Generalize the equivalence for a declaration as the condition.
+
+commit 1d50d2d2d2b39dda529bbfe26d5f144a8ec3eee0
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Thu Feb 15 22:02:06 2018 +0100
+
+    [over.match.oper] Add a note for conversions on synthesized candidates.
+
+commit 63dd5c67b22fb48d79e86028ea0564a3d02ffd7f
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Sun Apr 1 17:31:39 2018 -0700
+
+    [utility] Convert hanging paragraph into [utility.syn] introduction.
+
+    For #1771.
+
+commit eb4d1fec2fc26285b9586e2ace2c289167934811
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Tue Feb 13 22:36:16 2018 +0100
+
+    'floating type' is not a defined term in C++
+
+commit 4b5d9adaaff8b2bf09f1a5a88e8875347adb6714
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Thu Nov 16 00:48:48 2017 +0100
+
+    [unique.ptr] Remove definition of 'transfers ownership'.
+
+    It is mostly subsumed by the detailed descriptions of the move
+    constructors and assignment operators.
+
+commit a257a072efe2b6f2fe2dbdc5529b14315b08fbd8
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Feb 28 10:08:02 2018 +0100
+
+    [dcl.spec.auto] Use of undeduced placeholder types
+
+    As discussed for CWG 2285, variables declared with a
+    placeholder type should never reference itself in the
+    initializer.  Similarly, clarify the treatment of
+    deduced function return types.
+
+commit 27d7912784f9a092b1c5263aeb6d80838d04eac6
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Feb 28 23:49:26 2018 +0100
+
+    [std] Review cross-references to [expr.prim]
+
+    Cross-references to [expr.prim] should instead point to one
+    of its subclauses.
+
+commit a7fc1b661981367e3976053420488e99e22f79af
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sun Mar 25 16:31:20 2018 +0200
+
+    [lib] Avoid 'shall' and 'should' in footnotes.
+
+commit 340eac6a322c3f70734f506c627237fe58ef9e22
+Author: timsong-cpp <rs2740@gmail.com>
+Date:   Sat Mar 31 15:55:36 2018 -0400
+
+    [ostream.manip] Fix typo where "basic_osyncbuf" should be "basic_syncbuf" (#2004)
+
+commit ff08270c5411ac37c32b7c1161c1ff906b7d324e
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Mar 31 21:13:57 2018 +0200
+
+    [span.elem] Fix misplaced colon (#2007)
+
+commit e7479664be7bacd829a31b8302c5a9f38efb6313
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Mar 31 18:12:01 2018 +0200
+
+    [reverse.iterators] Dissolve single-item subclauses. (#1832)
+
+commit 6209ca1f73c66cf19c50e558546d1c9e537ba253
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Mar 31 16:39:28 2018 +0200
+
+    [locale] Remove class name repeated in subheadings (#1932)
+
+commit 296a41539c6e2b8b16f6c706d7d2185f7ef7f255
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Mar 31 16:39:02 2018 +0200
+
+    [containers] Remove class name repeated in subheadings (#1933)
+
+commit 31d6168980ef064112d1ad5498635fa9ca07bc65
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Mar 31 01:35:57 2018 +0200
+
+    [expr.rel] Clarify auxiliary partial ordering (#1977)
+
+commit 720b0695962cf4b37d9e0c204131d8d38a4b04de
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Mar 31 01:32:28 2018 +0200
+
+    Remove uses of 'concept' with ordinary English meaning. (#1918)
+
+commit 10bcbb745f0783dfefddab24755c36022c3df798
+Author: Jonathan Wakely <cxx@kayari.org>
+Date:   Wed Mar 21 14:17:30 2018 +0000
+
+    [sequences] Add exposition-only alias template for deduction guides.
+
+commit 3fca4f451709b90435d3f84ffe5d7b13763cf58d
+Author: Jonathan Wakely <cxx@kayari.org>
+Date:   Wed Mar 21 14:01:31 2018 +0000
+
+    [associative], [unord] Use \placeholder for deduction guide alias templates.
+
+    Also rename iter_val_t to iter-mapped-type and then add iter-value-type for value_type.
+
+    Fixes #1523
+
+commit 174bec6cf075f5234bebdba8361ebb477bb7a84a
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Mar 31 00:35:05 2018 +0200
+
+    [utilities] Move chars_format bitmask statement to [charconv.syn] (#1992)
+
+commit 22ad3d732bb6f1692693f778bf75d06e5cf8a545
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Mar 24 18:46:59 2018 +0100
+
+    [lib] \xref may refer to standards other than C
+
+commit 013c6e02583ab0ca723b21be4e4832ec450b4ba3
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Mar 31 00:14:20 2018 +0200
+
+    Index all mentions of 'implementation-dependent' (#1967)
+
+commit d17c6071d4f1db70b6335b3636150c8266e7d25d
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Mar 31 00:11:54 2018 +0200
+
+    Typeset ordinals as "i^\text{th}" instead of "i-th" (#2003)
+
+commit 3b582e7e19277a8b5a8bb94eab848704a734ef29
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Mar 30 23:38:52 2018 +0200
+
+    [ios.base] Disambiguate names to distinguish parameters from static data members (#1969)
+
+commit cba9d3374881202621385e70323940780cb1f39b
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Mar 30 23:35:41 2018 +0200
+
+    [support.types.byteops] Move 'Remarks' to after 'Effects' (#1973)
+
+commit ea4048f5899f9136820240aed2703a4762547552
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Mar 30 23:32:59 2018 +0200
+
+    [time.duration.nonmember] Replace type designator "CR" with its definition (#1985)
+
+commit 131dfa601c0ad1d53124079ee8142ffcbd825490
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Mar 30 23:30:46 2018 +0200
+
+    [conv.fctptr, special] Pointers to members designate their target (#1968)
+
+commit 47a27a8432016c86d3a20b0600524f0331531761
+Author: FrankHB <frankhb1989@gmail.com>
+Date:   Sat Mar 31 05:09:20 2018 +0800
+
+    [over.best.ics] Fix capitalization of "conversion" in p6 (#1987)
+
+    To avoid confusion, occurrence of "derived-to-base conversion" should not be with capital letter "C", which implies the name of a conversion category. The rank is already specified at the end of the paragraph.
+
+commit 4143715f45af009dd98ffef02e8e1c695048e324
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Mar 30 23:04:05 2018 +0200
+
+    CWG2345 [stmt.stmt, stmt.dcl] Jumping across initializers in init-statements and conditions (#1949)
+
+commit 42e35cf1d7a0b8084c310a4ca8ee02a3aeb127df
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Mar 30 22:59:29 2018 +0200
+
+    [dcl.fct.def.delete] Adjust 'onlydouble' example. (#1950)
+
+commit cc5becb7e47b6f7bc53d3ad68bcfd3f0b8087025
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Mar 30 22:57:35 2018 +0200
+
+    [temp.spec] Fix cross-reference to one-definition rule. (#1980)
+
+commit 174c44e85b419eaedf3f1d97409be889c5d72b17
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Mar 30 17:15:42 2018 +0200
+
+    [temp.local] Fix example not to name the constructor. (#1981)
+
+commit 9355f5dd3ecf1186f139d16629f180f327ca9e59
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Mar 30 17:13:19 2018 +0200
+
+    [re.regex] Avoid duplicate list of constants (#1984)
+
+    Shorten the synopsis and remove [re.regex.const].
+
+commit 9c74ada42d85359d1ef83e78de359fc07de7c0db
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Mar 30 17:05:55 2018 +0200
+
+    [class.temporary] Repair example (#1944)
+
+commit 035bd47dcb5e72b7471892a0fe005ea4daa5ece8
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Fri Mar 30 17:03:42 2018 +0200
+
+    Remove [facets.examples]. (#1957)
+
+commit dcf7f0514bf02092910788911a52e287d23594ef
+Author: Jonathan Wakely <github@kayari.org>
+Date:   Fri Mar 30 16:01:50 2018 +0100
+
+    [error.reporting] Change \rSec3 to \rSec2 (#1954)
+
+    Fixes #1953
+
+commit 1fe02a2c9ff79d1eb0bbe8c3732ef4a5814751c8
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Mar 30 16:59:48 2018 +0200
+
+    [access] Remove inappropriate uses of \term (#1940)
+
+commit 031d2bd4729b39be85822cecd7ca340985a8963e
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Mar 30 16:57:50 2018 +0200
+
+    [intro.abstract] Change example for unspecified behavior. (#1930)
+
+commit feb53073b17f9b14787f7aa0d92fa4dde2b5c62e
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Mar 30 16:54:26 2018 +0200
+
+    [insert.iterators] Dissolve single-item subclauses. (#1924)
+
+commit 69ce701c5b37508fcc21b2396476b7f53252dfde
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Thu Mar 29 01:48:06 2018 +0100
+
+    [views.span] Editorial review fixes:
+
+      * [span.sub] Refactor the specification of subspan() slightly to define the return type precisely. Note that when Extent is not dynamic, then Extent and size() are the same, so we can say "size()" in both cases unconditionally.
+
+      * Introduce new heading "Overview [span.overview]" to remove hanging paragraphs in [views.span].
+
+      * Rephrase "Extent < dynamic_extent" to "Extent is negative and not equal to dynamic_extent" to avoid unnecessary dependency on details of dynamic_extent.
+
+commit 88d223ccf2aa7d822fc1db6c14719c215816acf6
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Thu Mar 29 17:47:29 2018 -0700
+
+    [ostream.manip] Rephrase references to exposition-only variable "buf",
+    and add "Calls" to Effects: clause to match our style guide.
+
+commit e1e43280e84f438edd331a8e5142c1a0760d8cf4
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Mon Mar 26 15:21:35 2018 -0700
+
+    Add normative references to ISO 8601 and RFC 6557, referenced
+    normatively by P0355R7.
+
+    Fixes #1971.
+
+commit 35b73d1ce73e0dae89adae4966eea3197dfc6123
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Mon Mar 26 18:10:25 2018 -0700
+
+    [temp.variadic] Clarify what the elements of pack expansions are.
+
+    Also some minor wording cleanups: strike a stray "identifier" and
+    make paragraph 3 properly parallel to paragraphs 1 and 2.
+
+commit 13f4e960592e662a275ddcc7be1bc7bc6e00bfa8
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Mon Mar 26 17:39:24 2018 -0700
+
+    [temp.res] Convert note to footnote to avoid breaking up flow,
+    add back introductory sentence for the template validity rule,
+    and fix formatting of example.
+
+commit dec138c4f884ff6bc348da80bc7983da0a95455c
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Sat Mar 17 18:06:07 2018 -0400
+
+    [temp.res] Clarify that we're talking about the declarator-id of
+    the function or function template, not that of the
+    parameter-declaration.
+
+commit 9192d658321ebf900a1c3c52931cbf04a15b5b2f
+Author: Dawn Perchik <dperchik@embarcadero.com>
+Date:   Mon Mar 26 18:57:26 2018 -0700
+
+    [diff] Replace "as the following example illustrates" with "For example" for consistency.
+
+commit 0ad3281f3deb677f939311d3464f1155d6fc3fcc
+Author: Dawn Perchik <dperchik@embarcadero.com>
+Date:   Mon Mar 26 18:50:58 2018 -0700
+
+    [diff] Be consistent in formatting and add introductions to examples.
+
+commit 7066a903c55cffe1ca8ba8318b83b1376ed1c2b8
+Author: Richard Smith <richard-github@metafoo.co.uk>
+Date:   Fri Mar 16 22:00:59 2018 -0400
+
+    [expr.reinterpret.cast] Clarify that pointer->int type restriction looks at the type not the pointer value.
+
+    We were imprecise in what we meant by "large enough to hold it", but the intent is clear.
+
+commit 359cc0cbece331e02787b5efd6eee4b3f0906920
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Mon Feb 19 18:44:11 2018 +0100
+
+    [dcl.dcl] Change example for static_assert (#1923)
+
+commit 5a98cbfbf989151425261cb4a982c4b0b26f1a7d
+Author: Casey Carter <Casey@Carter.net>
+Date:   Fri Feb 16 09:29:00 2018 -0800
+
+    [fs.path.nonmember] Fix pluralization/possessive (#1929)
+
+commit a82582e97b4e4abaed32ea8fbe383b61562fc913
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Thu Feb 15 23:59:05 2018 +0100
+
+    [string.classes] Remove class name repeated in subheadings (#1928)
+
+commit 4f11b39e4a9b55b5cc74ae8ced01122796aa0b6a
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Feb 14 22:58:16 2018 +0100
+
+    [depr.str.strstreams] Add synopsis for <strstream> header (#1922)
+
diff --git a/papers/n4740.md b/papers/n4740.md new file mode 100644 index 0000000000..3b0c2a834f --- /dev/null +++ b/papers/n4740.md @@ -0,0 +1,710 @@ +# N4740 Editors' Report -- Programming Languages -- C++ + +2018-04-02 +Richard Smith (editor) (Google Inc) +Dawn Perchik (co-editor) (Bright Side Computing, LLC) +Thomas Köppe (co-editor) (Google DeepMind) +`` + +## Acknowledgements + +Special thanks to +Jens Maurer +for performing many of the editorial fixes since N4727. + +Thanks to Walter E Brown and Peter Sommerlad for +supplying LaTeX sources for their papers +[P0551R3](http://wg21.link/p0551r3) (LWG motion 13) +and +[P0753R2](http://wg21.link/p0753r2) (LWG motion 14). + +Thanks to all those who have [submitted editorial +issues](https://github.com/cplusplus/draft/wiki/How-to-submit-an-editorial-issue) +and to those who have provided pull requests with fixes. + +## New papers + + * [N4741](http://wg21.link/n4741) is the current working draft for C++20. It replaces [N4727](http://wg21.link/n4727). + * N4740 is this Editors' Report. + +## Motions incorporated into working draft + +### Core working group motions + +CWG motion 1: [Core issue resolutions](http://wg21.link/p0968r0) for 17 issue in "tentatively ready" status applied: + + * [1893](http://wg21.link/cwg1893) Function-style cast with *braced-init-list*s and empty pack expansions + * [1910](http://wg21.link/cwg1910) "Shall" requirement applied to runtime behavior + * [1983](http://wg21.link/cwg1983) Inappropriate use of *virt-specifier* + * [2059](http://wg21.link/cwg2059) Linkage and deduced return types + * [2081](http://wg21.link/cwg2081) Deduced return type in redeclaration or specialization of function template + * [2088](http://wg21.link/cwg2088) Late tiebreakers in partial ordering + * [2092](http://wg21.link/cwg2092) Deduction failure and overload resolution + * [2164](http://wg21.link/cwg2164) Name hiding and *using-directives* + * [2226](http://wg21.link/cwg2226) Xvalues vs lvalues in conditional expressions + * [2227](http://wg21.link/cwg2227) Destructor access and default member initializers + * [2229](http://wg21.link/cwg2229) Volatile unnamed bit-fields + * [2234](http://wg21.link/cwg2234) Missing rules for *simple-template-id* as *class-name* + * [2235](http://wg21.link/cwg2235) Partial ordering and non-dependent types + * [2237](http://wg21.link/cwg2237) Can a *template-id* name a constructor? + * [2255](http://wg21.link/cwg2255) Instantiated static data member templates + * [2260](http://wg21.link/cwg2260) Explicit specializations of deleted member functions + * [2299](http://wg21.link/cwg2299) `constexpr` vararg functions + +CWG motion 2: [P0840R2 "Language support for empty objects"](http://wg21.link/p0840r2) + +CWG motion 3: [P0962R1 "Relaxing the range-for customization point finding rules"](http://wg21.link/p0962r1) + +CWG motion 4: [P0969R0 "Allow structured bindings to accessible members"](http://wg21.link/p0969r0) + +CWG motion 5: [P0961R1 "Relaxing the structured bindings customization point finding rules"](http://wg21.link/p0961r1) + +CWG motion 6: [P0634R3 "Down with `typename`!"](http://wg21.link/p0634r3) + +CWG motion 7: [P0780R2 "Allow pack expansion in lambda *init-capture*"](http://wg21.link/p0780r2) + +CWG motion 8: [P0479R5 "`likely` and `unlikely` attributes"](http://wg21.link/p0479r5) + +CWG motion 9: [P0905R1 "Symmetry for spaceship"](http://wg21.link/p0905r1) **with wording changes, see below** + +CWG motions 10 and 11 apply to the Coroutines TS. + +### Library working group motions + +LWG motions 1 and 2 apply to the Parallelism TS. + +LWG motion 3 applies to the Reflection TS. + +LWG motion 4 applies to the Coroutines TS. + +LWG motion 5 applies to the Networking TS. + +LWG motion 6 applies to the Library Fundamentals TS. + +LWG motion 7: [Library issue resolutions](http://wg21.link/p0888r0) for 29 issues in "Ready" or "Tentatively Ready" status applied: + + * [2164](http://wg21.link/lwg2164) What are the semantics of `vector.emplace(vector.begin(), vector.back())`? + * [2243](http://wg21.link/lwg2243) `istream::putback` problem + * [2816](http://wg21.link/lwg2816) `resize_file` has impossible postcondition + * [2843](http://wg21.link/lwg2843) Unclear behavior of `std::pmr::memory_resource::do_allocate()` + * [2849](http://wg21.link/lwg2849) Why does `!is_regular_file(from)` cause `copy_file` to report a "file already exists" error? + * [2851](http://wg21.link/lwg2851) `std::filesystem` enum classes are now underspecified + * [2969](http://wg21.link/lwg2969) `polymorphic_allocator::construct()` shouldn't pass `resource()` + * [2975](http://wg21.link/lwg2975) Missing case for `pair` construction in scoped and polymorphic allocators + * [2989](http://wg21.link/lwg2989) `path`'s stream insertion operator lets you insert everything under the sun + * [3000](http://wg21.link/lwg3000) `monotonic_memory_resource::do_is_equal` uses `dynamic_cast` unnecessarily + * [3004](http://wg21.link/lwg3004) [string.capacity] and [vector.capacity] should specify time complexity for `capacity()` + * [3005](http://wg21.link/lwg3005) Destruction order of arrays by `make_shared`/`allocate_shared` only recommended? + * [3007](http://wg21.link/lwg3007) `allocate_shared` should rebind allocator to cv-unqualified `value_type` for construction + * [3009](http://wg21.link/lwg3009) Including `` doesn't provide `std::size/empty/data` + * [3013](http://wg21.link/lwg3013) (`recursive_`)`directory_iterator` construction and traversal should not be `noexcept` + * [3014](http://wg21.link/lwg3014) More `noexcept` issues with filesystem operations + * [3015](http://wg21.link/lwg3015) `copy_options::unspecified` underspecified + * [3017](http://wg21.link/lwg3017) `list` `splice` functions should use `addressof` + * [3026](http://wg21.link/lwg3026) `filesystem::weakly_canonical` still defined in terms of `canonical(p, base)` + * [3030](http://wg21.link/lwg3030) Who shall meet the requirements of `try_lock`? + * [3034](http://wg21.link/lwg3034) [P0767R1](http://wg21.link/p0767r1) breaks previously-standard-layout types + * [3035](http://wg21.link/lwg3035) `std::allocator`'s constructors should be `constexpr` + * [3039](http://wg21.link/lwg3039) Unnecessary `decay` in `thread` and `packaged_task` + * [3041](http://wg21.link/lwg3041) Unnecessary `decay` in `reference_wrapper` + * [3042](http://wg21.link/lwg3042) `is_literal_type_v` should be `inline` + * [3043](http://wg21.link/lwg3043) Bogus postcondition for `filesystem_error` constructor + * [3045](http://wg21.link/lwg3045) `atomic<`*`floating-point`*`>` doesn't have `value_type` or `difference_type` + * [3048](http://wg21.link/lwg3048) `transform_reduce(exec, first1, last1, first2, init)` discards execution policy + * [3051](http://wg21.link/lwg3051) Floating point classifications were inadvertently changed in [P0175](http://wg21.link/p0175) + +LWG motion 8: [Library issue resolutions](http://wg21.link/p1003r0) for 2 issues in "Immediate" status applied: + + * [2946](http://wg21.link/lwg2946) [LWG 2758](http://wg21.link/lwg2758)'s resolution missed further corrections + * [3075](http://wg21.link/lwg3075) `basic_string` needs deduction guides from `basic_string_view` + +LWG motion 9: [P0754R2 "``"](http://wg21.link/p0754r2) + +LWG motion 10: [P0809R0 "Comparing unordered containers"](http://wg21.link/p0809r0), resolving 1 library issue: + + * [2831](http://wg21.link/lwg2831) Equality can be defined when `Hash` function objects have different behaviour + +LWG motion 11: [P0355R7 "Extending `chrono` to calendars and time zones"](http://wg21.link/p0355r7) **with wording changes, see below** + +LWG motion 12: [P0966R1 "`string::reserve` should not shrink"](http://wg21.link/p0966r1) + +LWG motion 13: [P0551R3 "Thou shalt not specialize `std` function templates!"](http://wg21.link/p0551r3) + +LWG motion 14: [P0753R2 "Manipulators for C++ synchronized buffered ostream"](http://wg21.link/p0753r2) + +LWG motion 15: [P0122R7 "``"](http://wg21.link/p0122r7) **with wording changes, see below** + +LWG motion 16: [P0858R0 "Constexpr iterator requirements"](http://wg21.link/p0858r0) + +## Notable editorial changes + +### CWG motion 9 + +After consultation with CWG, the wording for injecting additional `operator<=>` +candidates has been editorially reworked, introducing a named set of "rewritten +candidates" in the place of the ad-hoc additional lookups previously specified. +That change allows the wording of this motion to be expressed more directly, +but, as a consequence, the wording changes applied for this paper differ +substantially from those moved. + +### LWG motion 11 + +This paper introduces a large amount of new text (~78 pages), and as such a +substantial quantity of editorial changes were necessary to align the moved +wording with the Working Draft's style guidelines: + + * Reordered synopsis to match detailed description. + * Significant changes to stable names, per style guide. + * Added missing `zoned_traits` to `` synopsis. + * Removed redundant `chrono::` qualification in synopsis. + * [time.duration.io] Significant wording changes for comprehensibility. + * Adjusted return type of `clock_cast` in synopsis to match that in detailed description. + * Added subheadings to clock cast description, replacing line comments in the middle of the wording. + * Adjusted specification of `clock_cast` to avoid awkward "at least one of [...] exactly one of" + construction and to avoid references to bullet numbers in the body text. + * Reordered parsing and formatting sections to the end. + * Removed descriptions for `operator!=`, `operator>`, `operator<=`, `operator>=` overloads + that are covered by [operators] + * Removed some tutorial front-matter and design discussion from `day`, `month`, `year`, `weekday`, etc. + * `operator-(month, month)`, `operator-(weekday, weekday)`: + specify returned value in *Returns:* element rather than + splitting the specification across *Returns:* and *Remarks:*. + * Added subheadings for the new classes to separate member and non-member function descriptions + * Modified `time_of_day` examples to include sample code producing the given output + * Removed exposition-only members `tzdb::next` and `tzdb_list::head_` + that are not actually used in the exposition, after consultation with LWG. + * Modified leap-second example to not require updates each time a leap-second is added. + +### LWG motion 15 + + * Rearranged sectioning to match our normal style. + * Removed `std::` from type names in class definition. + * Reordered member descriptions to match the style we use elsewhere. + * Rewrote the `subspan()` wording to avoid deeply-nested expression and to + clarify what type is denoted by the *see below* in the synopsis. + +### Simplification of non-member `swap` presentation + +The specification for the non-member `swap` function for container types has +been consolidated in the container requirements table, replacing the former +presentation which repeated the description once for each container. + +This removes the subclauses +[deque.special], +[forwardlist.special], +[list.special], +[vector.special], +[map.special], +[multimap.special], +[set.special], +[multiset.special], +[unord.map.swap], +[unord.multimap.swap], +[unord.set.swap], +and +[unord.multiset.swap]. + +### `reverse_iterator` subclause consolidation + +`reverse_iterator` previously had one subclause for each member function, +in violation of our normal presentation style. These subclauses have been +merged into groups of related functionality as follows: + + * [reverse.iter.op=] has been merged into [reverse.iter.cons] + * [reverse.iter.{op==, op<, op!=, op>, op>=, op<=}] have been merged into [reverse.iter.cmp] + * [reverse.iter.{op.star, opref, opindex}] have been merged into [reverse.iter.elem] + * [reverse.iter.{op+, op-, op++, op+=, op--, op-=}] have been merged into [reverse.iter.nav] + * [reverse.iter.{opdiff, opsum, make}] have been merged into [reverse.iter.nonmember] + * [reverse.iter.ops] became empty after the above changes and has been removed. + +### Simplification of `basic_regex` constant presentation + +The presentation style used for the synopsis of the `basic_regex` synonyms +for the `std::regex_constants` has been shortened by use of a typedef, and +the subclause [re.regex.const] containing redundant out-of-line descriptions +of those flags has been removed. + +### Cleanup of uses of the word "concept" + +In the Working Draft, the word "concept" is used both in the technical sense, +denoting a C++ concept, and informally, denoting an idea or notion. We have +editorially cleaned up a few of the more confusing and ambiguous instances of +the term; most notably, Clause 6, formerly named "Basic concepts", is now +named "Basics". + +## Minor editorial fixes + +A log of editorial fixes made to the working draft since N4727 is below. +This list excludes changes +that do not affect the body text or only affect whitespace or typeface. For a +complete list including such changes (or for the actual deltas applied by these +changes), consult the [draft sources on github](https://github.com/cplusplus/draft/compare/n4727...n4741). + + commit 17191eca85eebcacbc3ef37e61ee51103d892268 + Author: Jens Maurer + Date: Wed Mar 28 21:05:41 2018 +0200 + + [any.class] Rephrase small-object optimization + + commit 05675f74017966048a4db1a5c5419be357082622 + Author: Thomas Köppe + Date: Mon Apr 2 22:44:03 2018 +0100 + + [any.class, optional.optional] Add missing "namespace std" around class definitions. + + commit 2fcacf3f23a5fbf9cd95611342803ba536904d01 + Author: Richard Smith + Date: Mon Apr 2 13:45:41 2018 -0700 + + [container.node] Remove placeholder class name from subheadings. + + Partially addresses #1242. + + commit 87ae756d027d7e611d6e89f7d3232a95b6c72203 + Author: Jens Maurer + Date: Mon Apr 2 21:56:40 2018 +0200 + + [xrefdelta] Fixes for reverse_iterator cleanup (#2015) + + commit 4aa55de012f85e9f250f2c608e00a351fc9db9f1 + Author: Thomas Köppe + Date: Mon Apr 2 13:40:32 2018 +0100 + + [layout] Place footnotes at the bottom of the page. (#1830) + + This uses a feature introduced by memoir 3.7e, '\feetatbottom', + which makes footnotes appear at the bottom of the page, rather + than immediately following the main text. + + commit 5b5d225156372b717d84e0137ab759626a8886f4 + Author: Hubert Tong + Date: Mon Apr 2 00:29:33 2018 -0400 + + [temp.concept]: Use note; no syntax for explicit specialization, etc. + + Explicit specialization, etc. of a concept cannot be formed + syntactically. As such, a further rule to prevent such constructs is + redundant as normative text. + + Implements the proposed direction from core/2017/07/2719. + + commit bec67956e817d7edd02bdbffe5b1254113102928 + Author: Richard Smith + Date: Sun Apr 1 20:11:03 2018 -0700 + + [over.match.best] Use new "rewritten candidates" terminology to simplify + wording. + + commit 51684d21aa98c6cf20a44274f38ffd07b191e2f2 + Author: Richard Smith + Date: Mon Mar 26 18:53:28 2018 -0700 + + [over.match.oper] Refactor the <=> rewrite candidate rules for clarity. + + commit e0a88df11e5cf0988b40dd65218d7ce9f456c763 + Author: Jens Maurer + Date: Fri Mar 30 11:15:42 2018 +0200 + + [ostream.manip,time] Replace "can not" with "cannot" + + commit 6c9e27dab526298771cdbf1a8dacf165f6547ead + Author: Tony Van Eerd + Date: Sun Apr 1 22:14:59 2018 -0400 + + [sequence.reqmts] Convert advice on container selection into a note. + + Also separate out the advice for std::array from that for std::vector and emphasize the main message. + + commit 7e4b556f44c47c70c4d1e93c5b3c82b01a949326 + Author: Jens Maurer + Date: Sat Mar 24 19:42:20 2018 +0100 + + [implimits] Clarify meaning of implementation limits + + commit b1c4c87a7ca880e4d2e46cb9b62517e940ef0339 + Author: Jens Maurer + Date: Tue Feb 20 22:55:17 2018 +0100 + + [lib] Replace 'requirements of FrobMunchable' + + with 'FrobMunchable requirements'. + + commit 2a1d53b1820a460066ae374a95529c7def2dda16 + Author: Jens Maurer + Date: Tue Feb 20 22:27:27 2018 +0100 + + [lib] Use table references for CamelCase requirements. + + commit dbeb68f0dd7bb8fd950f33a94409b9d5ba778729 + Author: Jens Maurer + Date: Mon Feb 19 22:44:54 2018 +0100 + + [lib] Use "shall satisfy", not "shall meet", for requirements. + + commit 8738c6b38db45d06724e4a75afd2134d3f6e6f3f + Author: Jens Maurer + Date: Fri Mar 23 21:27:11 2018 +0100 + + [containers] Removed redundant specifications of non-member swap + + commit 4d3434c2c9ed41c31925172948ff81166f623f64 + Author: eus + Date: Mon Apr 2 03:41:11 2018 +0200 + + [expr.ass] Clarify description of simple assignment + + Replace vague "value of the expression" wording with more-precise "result of the right operand". + + commit 1b4da01c47fcf7522fa3df0d8c0b96ed840f4103 + Author: Jens Maurer + Date: Sun Mar 18 17:56:14 2018 +0100 + + [associative.reqmts] Turn emphasis into a note. + + commit 1a9fd49cdf58d6dfe8da51dcad93ce8f73f144e0 + Author: Jens Maurer + Date: Mon Feb 19 18:37:49 2018 +0100 + + [expr.dynamic.cast] Remove redundant statements on casting away constness + + commit 73bfbf2d8a40822779dfdd544f5112fd2096a7d9 + Author: Jens Maurer + Date: Sat Feb 17 11:26:07 2018 +0100 + + [stmt.while] Generalize the equivalence for a declaration as the condition. + + commit 1d50d2d2d2b39dda529bbfe26d5f144a8ec3eee0 + Author: Jens Maurer + Date: Thu Feb 15 22:02:06 2018 +0100 + + [over.match.oper] Add a note for conversions on synthesized candidates. + + commit 63dd5c67b22fb48d79e86028ea0564a3d02ffd7f + Author: Richard Smith + Date: Sun Apr 1 17:31:39 2018 -0700 + + [utility] Convert hanging paragraph into [utility.syn] introduction. + + For #1771. + + commit eb4d1fec2fc26285b9586e2ace2c289167934811 + Author: Jens Maurer + Date: Tue Feb 13 22:36:16 2018 +0100 + + 'floating type' is not a defined term in C++ + + commit 4b5d9adaaff8b2bf09f1a5a88e8875347adb6714 + Author: Jens Maurer + Date: Thu Nov 16 00:48:48 2017 +0100 + + [unique.ptr] Remove definition of 'transfers ownership'. + + It is mostly subsumed by the detailed descriptions of the move + constructors and assignment operators. + + commit a257a072efe2b6f2fe2dbdc5529b14315b08fbd8 + Author: Jens Maurer + Date: Wed Feb 28 10:08:02 2018 +0100 + + [dcl.spec.auto] Use of undeduced placeholder types + + As discussed for CWG 2285, variables declared with a + placeholder type should never reference itself in the + initializer. Similarly, clarify the treatment of + deduced function return types. + + commit 27d7912784f9a092b1c5263aeb6d80838d04eac6 + Author: Jens Maurer + Date: Wed Feb 28 23:49:26 2018 +0100 + + [std] Review cross-references to [expr.prim] + + Cross-references to [expr.prim] should instead point to one + of its subclauses. + + commit a7fc1b661981367e3976053420488e99e22f79af + Author: Jens Maurer + Date: Sun Mar 25 16:31:20 2018 +0200 + + [lib] Avoid 'shall' and 'should' in footnotes. + + commit 340eac6a322c3f70734f506c627237fe58ef9e22 + Author: timsong-cpp + Date: Sat Mar 31 15:55:36 2018 -0400 + + [ostream.manip] Fix typo where "basic_osyncbuf" should be "basic_syncbuf" (#2004) + + commit ff08270c5411ac37c32b7c1161c1ff906b7d324e + Author: Jens Maurer + Date: Sat Mar 31 21:13:57 2018 +0200 + + [span.elem] Fix misplaced colon (#2007) + + commit e7479664be7bacd829a31b8302c5a9f38efb6313 + Author: Jens Maurer + Date: Sat Mar 31 18:12:01 2018 +0200 + + [reverse.iterators] Dissolve single-item subclauses. (#1832) + + commit 6209ca1f73c66cf19c50e558546d1c9e537ba253 + Author: Jens Maurer + Date: Sat Mar 31 16:39:28 2018 +0200 + + [locale] Remove class name repeated in subheadings (#1932) + + commit 296a41539c6e2b8b16f6c706d7d2185f7ef7f255 + Author: Jens Maurer + Date: Sat Mar 31 16:39:02 2018 +0200 + + [containers] Remove class name repeated in subheadings (#1933) + + commit 31d6168980ef064112d1ad5498635fa9ca07bc65 + Author: Jens Maurer + Date: Sat Mar 31 01:35:57 2018 +0200 + + [expr.rel] Clarify auxiliary partial ordering (#1977) + + commit 720b0695962cf4b37d9e0c204131d8d38a4b04de + Author: Jens Maurer + Date: Sat Mar 31 01:32:28 2018 +0200 + + Remove uses of 'concept' with ordinary English meaning. (#1918) + + commit 10bcbb745f0783dfefddab24755c36022c3df798 + Author: Jonathan Wakely + Date: Wed Mar 21 14:17:30 2018 +0000 + + [sequences] Add exposition-only alias template for deduction guides. + + commit 3fca4f451709b90435d3f84ffe5d7b13763cf58d + Author: Jonathan Wakely + Date: Wed Mar 21 14:01:31 2018 +0000 + + [associative], [unord] Use \placeholder for deduction guide alias templates. + + Also rename iter_val_t to iter-mapped-type and then add iter-value-type for value_type. + + Fixes #1523 + + commit 174bec6cf075f5234bebdba8361ebb477bb7a84a + Author: Jens Maurer + Date: Sat Mar 31 00:35:05 2018 +0200 + + [utilities] Move chars_format bitmask statement to [charconv.syn] (#1992) + + commit 22ad3d732bb6f1692693f778bf75d06e5cf8a545 + Author: Jens Maurer + Date: Sat Mar 24 18:46:59 2018 +0100 + + [lib] \xref may refer to standards other than C + + commit 013c6e02583ab0ca723b21be4e4832ec450b4ba3 + Author: Jens Maurer + Date: Sat Mar 31 00:14:20 2018 +0200 + + Index all mentions of 'implementation-dependent' (#1967) + + commit d17c6071d4f1db70b6335b3636150c8266e7d25d + Author: Jens Maurer + Date: Sat Mar 31 00:11:54 2018 +0200 + + Typeset ordinals as "i^\text{th}" instead of "i-th" (#2003) + + commit 3b582e7e19277a8b5a8bb94eab848704a734ef29 + Author: Jens Maurer + Date: Fri Mar 30 23:38:52 2018 +0200 + + [ios.base] Disambiguate names to distinguish parameters from static data members (#1969) + + commit cba9d3374881202621385e70323940780cb1f39b + Author: Jens Maurer + Date: Fri Mar 30 23:35:41 2018 +0200 + + [support.types.byteops] Move 'Remarks' to after 'Effects' (#1973) + + commit ea4048f5899f9136820240aed2703a4762547552 + Author: Jens Maurer + Date: Fri Mar 30 23:32:59 2018 +0200 + + [time.duration.nonmember] Replace type designator "CR" with its definition (#1985) + + commit 131dfa601c0ad1d53124079ee8142ffcbd825490 + Author: Jens Maurer + Date: Fri Mar 30 23:30:46 2018 +0200 + + [conv.fctptr, special] Pointers to members designate their target (#1968) + + commit 47a27a8432016c86d3a20b0600524f0331531761 + Author: FrankHB + Date: Sat Mar 31 05:09:20 2018 +0800 + + [over.best.ics] Fix capitalization of "conversion" in p6 (#1987) + + To avoid confusion, occurrence of "derived-to-base conversion" should not be with capital letter "C", which implies the name of a conversion category. The rank is already specified at the end of the paragraph. + + commit 4143715f45af009dd98ffef02e8e1c695048e324 + Author: Jens Maurer + Date: Fri Mar 30 23:04:05 2018 +0200 + + CWG2345 [stmt.stmt, stmt.dcl] Jumping across initializers in init-statements and conditions (#1949) + + commit 42e35cf1d7a0b8084c310a4ca8ee02a3aeb127df + Author: Jens Maurer + Date: Fri Mar 30 22:59:29 2018 +0200 + + [dcl.fct.def.delete] Adjust 'onlydouble' example. (#1950) + + commit cc5becb7e47b6f7bc53d3ad68bcfd3f0b8087025 + Author: Jens Maurer + Date: Fri Mar 30 22:57:35 2018 +0200 + + [temp.spec] Fix cross-reference to one-definition rule. (#1980) + + commit 174c44e85b419eaedf3f1d97409be889c5d72b17 + Author: Jens Maurer + Date: Fri Mar 30 17:15:42 2018 +0200 + + [temp.local] Fix example not to name the constructor. (#1981) + + commit 9355f5dd3ecf1186f139d16629f180f327ca9e59 + Author: Jens Maurer + Date: Fri Mar 30 17:13:19 2018 +0200 + + [re.regex] Avoid duplicate list of constants (#1984) + + Shorten the synopsis and remove [re.regex.const]. + + commit 9c74ada42d85359d1ef83e78de359fc07de7c0db + Author: Jens Maurer + Date: Fri Mar 30 17:05:55 2018 +0200 + + [class.temporary] Repair example (#1944) + + commit 035bd47dcb5e72b7471892a0fe005ea4daa5ece8 + Author: Eelis + Date: Fri Mar 30 17:03:42 2018 +0200 + + Remove [facets.examples]. (#1957) + + commit dcf7f0514bf02092910788911a52e287d23594ef + Author: Jonathan Wakely + Date: Fri Mar 30 16:01:50 2018 +0100 + + [error.reporting] Change \rSec3 to \rSec2 (#1954) + + Fixes #1953 + + commit 1fe02a2c9ff79d1eb0bbe8c3732ef4a5814751c8 + Author: Jens Maurer + Date: Fri Mar 30 16:59:48 2018 +0200 + + [access] Remove inappropriate uses of \term (#1940) + + commit 031d2bd4729b39be85822cecd7ca340985a8963e + Author: Jens Maurer + Date: Fri Mar 30 16:57:50 2018 +0200 + + [intro.abstract] Change example for unspecified behavior. (#1930) + + commit feb53073b17f9b14787f7aa0d92fa4dde2b5c62e + Author: Jens Maurer + Date: Fri Mar 30 16:54:26 2018 +0200 + + [insert.iterators] Dissolve single-item subclauses. (#1924) + + commit 69ce701c5b37508fcc21b2396476b7f53252dfde + Author: Thomas Köppe + Date: Thu Mar 29 01:48:06 2018 +0100 + + [views.span] Editorial review fixes: + + * [span.sub] Refactor the specification of subspan() slightly to define the return type precisely. Note that when Extent is not dynamic, then Extent and size() are the same, so we can say "size()" in both cases unconditionally. + + * Introduce new heading "Overview [span.overview]" to remove hanging paragraphs in [views.span]. + + * Rephrase "Extent < dynamic_extent" to "Extent is negative and not equal to dynamic_extent" to avoid unnecessary dependency on details of dynamic_extent. + + commit 88d223ccf2aa7d822fc1db6c14719c215816acf6 + Author: Richard Smith + Date: Thu Mar 29 17:47:29 2018 -0700 + + [ostream.manip] Rephrase references to exposition-only variable "buf", + and add "Calls" to Effects: clause to match our style guide. + + commit e1e43280e84f438edd331a8e5142c1a0760d8cf4 + Author: Richard Smith + Date: Mon Mar 26 15:21:35 2018 -0700 + + Add normative references to ISO 8601 and RFC 6557, referenced + normatively by P0355R7. + + Fixes #1971. + + commit 35b73d1ce73e0dae89adae4966eea3197dfc6123 + Author: Richard Smith + Date: Mon Mar 26 18:10:25 2018 -0700 + + [temp.variadic] Clarify what the elements of pack expansions are. + + Also some minor wording cleanups: strike a stray "identifier" and + make paragraph 3 properly parallel to paragraphs 1 and 2. + + commit 13f4e960592e662a275ddcc7be1bc7bc6e00bfa8 + Author: Richard Smith + Date: Mon Mar 26 17:39:24 2018 -0700 + + [temp.res] Convert note to footnote to avoid breaking up flow, + add back introductory sentence for the template validity rule, + and fix formatting of example. + + commit dec138c4f884ff6bc348da80bc7983da0a95455c + Author: Richard Smith + Date: Sat Mar 17 18:06:07 2018 -0400 + + [temp.res] Clarify that we're talking about the declarator-id of + the function or function template, not that of the + parameter-declaration. + + commit 9192d658321ebf900a1c3c52931cbf04a15b5b2f + Author: Dawn Perchik + Date: Mon Mar 26 18:57:26 2018 -0700 + + [diff] Replace "as the following example illustrates" with "For example" for consistency. + + commit 0ad3281f3deb677f939311d3464f1155d6fc3fcc + Author: Dawn Perchik + Date: Mon Mar 26 18:50:58 2018 -0700 + + [diff] Be consistent in formatting and add introductions to examples. + + commit 7066a903c55cffe1ca8ba8318b83b1376ed1c2b8 + Author: Richard Smith + Date: Fri Mar 16 22:00:59 2018 -0400 + + [expr.reinterpret.cast] Clarify that pointer->int type restriction looks at the type not the pointer value. + + We were imprecise in what we meant by "large enough to hold it", but the intent is clear. + + commit 359cc0cbece331e02787b5efd6eee4b3f0906920 + Author: Jens Maurer + Date: Mon Feb 19 18:44:11 2018 +0100 + + [dcl.dcl] Change example for static_assert (#1923) + + commit 5a98cbfbf989151425261cb4a982c4b0b26f1a7d + Author: Casey Carter + Date: Fri Feb 16 09:29:00 2018 -0800 + + [fs.path.nonmember] Fix pluralization/possessive (#1929) + + commit a82582e97b4e4abaed32ea8fbe383b61562fc913 + Author: Jens Maurer + Date: Thu Feb 15 23:59:05 2018 +0100 + + [string.classes] Remove class name repeated in subheadings (#1928) + + commit 4f11b39e4a9b55b5cc74ae8ced01122796aa0b6a + Author: Jens Maurer + Date: Wed Feb 14 22:58:16 2018 +0100 + + [depr.str.strstreams] Add synopsis for header (#1922) diff --git a/papers/n4741.pdf b/papers/n4741.pdf new file mode 100644 index 0000000000..326a997333 Binary files /dev/null and b/papers/n4741.pdf differ diff --git a/source/Makefile b/source/Makefile index 62957b3d6a..aefaf3ed98 100644 --- a/source/Makefile +++ b/source/Makefile @@ -42,6 +42,7 @@ reindex: makeindex libraryindex makeindex grammarindex makeindex impldefindex + $(STDPDF) makeindex -s basic.gst -o xrefindex.gls xrefindex.glo makeindex -s basic.gst -o xrefdelta.gls xrefdelta.glo $(STDPDF) diff --git a/source/access.tex b/source/access.tex index 67fbb854dd..f8ec21f7f2 100644 --- a/source/access.tex +++ b/source/access.tex @@ -90,13 +90,13 @@ \end{note} \pnum -It should be noted that it is -\term{access} -to members and base classes that is controlled, not their -\term{visibility}. +\begin{note} +Access to members and base classes is controlled, not their +visibility\iref{basic.scope.hiding}. Names of members are still visible, and implicit conversions to base classes are still considered, when those members and base classes are inaccessible. +\end{note} The interpretation of a given construct is established without regard to access control. If the interpretation @@ -389,9 +389,9 @@ of \tcode{N} is -\term{accessible} +\defn{accessible} at -\term{R}, +\placeholder{R}, if \begin{itemize} \item @@ -400,7 +400,7 @@ would be a public member of \tcode{N}, or \item -\term{R} +\placeholder{R} occurs in a member or friend of class \tcode{N}, and an invented public member of @@ -408,7 +408,7 @@ would be a private or protected member of \tcode{N}, or \item -\term{R} +\placeholder{R} occurs in a member or friend of a class \tcode{P} derived from @@ -425,13 +425,13 @@ is a base class of \tcode{S} accessible at -\term{R} +\placeholder{R} and \tcode{S} is a base class of \tcode{N} accessible at -\term{R}. +\placeholder{R}. \end{itemize} \begin{example} @@ -492,7 +492,7 @@ A member \tcode{m} is accessible at the point -\term{R} +\placeholder{R} when named in class \tcode{N} if @@ -507,7 +507,7 @@ as a member of \tcode{N} is private, and -\term{R} +\placeholder{R} occurs in a member or friend of class \tcode{N}, or @@ -516,7 +516,7 @@ as a member of \tcode{N} is protected, and -\term{R} +\placeholder{R} occurs in a member or friend of class \tcode{N}, or in a member of a class @@ -534,11 +534,11 @@ of \tcode{N} that is accessible at -\term{R}, +\placeholder{R}, and \tcode{m} is accessible at -\term{R} +\placeholder{R} when named in class \tcode{B}. \begin{example} @@ -586,8 +586,6 @@ The following example illustrates the differences between members and friends: \indextext{friend function!member function and}% -\indextext{example!friend function}% -\indextext{example!member function}% \begin{codeblock} class X { @@ -963,8 +961,6 @@ The members of an enclosing class have no special access to members of a nested class; the usual access rules\iref{class.access} shall be obeyed. \begin{example} -\indextext{example!nested class definition}% - \begin{codeblock} class E { int x; diff --git a/source/algorithms.tex b/source/algorithms.tex index dcc4e3846c..59e86a2701 100644 --- a/source/algorithms.tex +++ b/source/algorithms.tex @@ -13,7 +13,7 @@ mutating sequence operations, sorting and related operations, and algorithms from the ISO C library, -as summarized in Table~\ref{tab:algorithms.summary}. +as summarized in \tref{algorithms.summary}. \begin{libsumtab}{Algorithms library summary}{tab:algorithms.summary} \ref{alg.nonmodifying} & Non-modifying sequence operations & \\ @@ -1350,7 +1350,7 @@ If an object is modified by an element access function, the algorithm will perform no other unsynchronized accesses to that object. The modifying element access functions are those -which are specified as modifying the object in the relevant concept. +which are specified as modifying the object. \begin{note} For example, \tcode{swap()}, \tcode{++}, \tcode{--}, \tcode{@=}, and assignments @@ -1627,10 +1627,10 @@ \begin{itemdescr} \pnum -\requires \tcode{Function} shall meet the requirements of -\tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}). +\requires \tcode{Function} shall satisfy the +\tcode{MoveConstructible} requirements (\tref{moveconstructible}). \begin{note} \tcode{Function} need not meet the requirements of -\tcode{CopyConstructible} (Table~\ref{tab:copyconstructible}). \end{note} +\tcode{CopyConstructible} (\tref{copyconstructible}). \end{note} \pnum \effects @@ -1672,7 +1672,7 @@ \begin{itemdescr} \pnum \requires -\tcode{Function} shall meet the requirements of \tcode{CopyConstructible}. +\tcode{Function} shall satisfy the \tcode{CopyConstructible} requirements. \pnum \effects @@ -1710,7 +1710,7 @@ \begin{itemdescr} \pnum \requires -\tcode{Function} shall meet the requirements of \tcode{MoveConstructible} +\tcode{Function} shall satisfy the \tcode{MoveConstructible} requirements \begin{note} \tcode{Function} need not meet the requirements of \tcode{CopyConstructible}. \end{note} @@ -1746,7 +1746,7 @@ \begin{itemdescr} \pnum \requires -\tcode{Function} shall meet the requirements of \tcode{CopyConstructible}. +\tcode{Function} shall satisfy the \tcode{CopyConstructible} requirements. \pnum \requires @@ -2476,7 +2476,7 @@ \begin{note} For the overload with an \tcode{ExecutionPolicy}, there may be a performance cost if \tcode{iterator_traits::value_type} is not -\tcode{Move\-Constructible} (Table~\ref{tab:moveconstructible}). +\tcode{Move\-Constructible} (\tref{moveconstructible}). \end{note} \pnum @@ -3019,7 +3019,7 @@ The type of \tcode{*first} shall satisfy the \tcode{MoveAssignable} -requirements (Table~\ref{tab:moveassignable}). +requirements (\tref{moveassignable}). \pnum \effects @@ -3088,7 +3088,7 @@ \begin{note} For the overloads with an \tcode{ExecutionPolicy}, there may be a performance cost if \tcode{iterator_traits::value_type} is not -\tcode{Move\-Constructible} (Table~\ref{tab:moveconstructible}). +\tcode{Move\-Constructible} (\tref{moveconstructible}). \end{note} \pnum @@ -3138,7 +3138,7 @@ \requires The comparison function shall be an equivalence relation. The type of \tcode{*first} shall satisfy the -\tcode{MoveAssignable} requirements (Table~\ref{tab:moveassignable}). +\tcode{MoveAssignable} requirements (\tref{moveassignable}). \pnum \effects @@ -3215,9 +3215,9 @@ then there are no additional requirements for \tcode{T}. Otherwise, if \tcode{OutputIterator} meets the forward iterator requirements and its value type is the same as \tcode{T}, -then \tcode{T} shall be \tcode{CopyAssignable} (Table~\ref{tab:copyassignable}). +then \tcode{T} shall be \tcode{CopyAssignable} (\tref{copyassignable}). Otherwise, \tcode{T} shall be both -\tcode{CopyConstructible} (Table~\ref{tab:copyconstructible}) and \tcode{CopyAssignable}. +\tcode{CopyConstructible} (\tref{copyconstructible}) and \tcode{CopyAssignable}. \begin{note} For the overloads with an \tcode{ExecutionPolicy}, there may be a performance cost if the value type of \tcode{ForwardIterator1} is not both @@ -3262,8 +3262,8 @@ \begin{itemdescr} \pnum \requires -\tcode{BidirectionalIterator} shall satisfy the requirements of -\tcode{ValueSwappable}\iref{swappable.requirements}. +\tcode{BidirectionalIterator} shall satisfy the +\tcode{ValueSwappable} requirements\iref{swappable.requirements}. \pnum \effects @@ -3346,13 +3346,10 @@ and \range{middle}{last} shall be valid ranges. -\tcode{ForwardIterator} shall satisfy the requirements of -\tcode{ValueSwappable}\iref{swappable.requirements}. The type of \tcode{*first} shall satisfy -the requirements of \tcode{MoveConstructible} -(Table~\ref{tab:moveconstructible}) and the -requirements of -\tcode{MoveAssignable} -(Table~\ref{tab:moveassignable}). +\tcode{ForwardIterator} shall satisfy the +\tcode{ValueSwappable} requirements\iref{swappable.requirements}. The type of \tcode{*first} shall satisfy +the \tcode{MoveConstructible} (\tref{moveconstructible}) and +\tcode{MoveAssignable} (\tref{moveassignable}) requirements. \pnum \effects @@ -3450,7 +3447,7 @@ \tcode{Distance} shall be an integer type. \item \tcode{remove_reference_t} -shall meet the requirements of a uniform random bit generator type\iref{rand.req.urng} +shall satisfy the requirements of a uniform random bit generator type\iref{rand.req.urng} whose return type is convertible to \tcode{Distance}. \item \tcode{out} shall not be in the range \range{first}{last}. @@ -3500,11 +3497,11 @@ \begin{itemdescr} \pnum \requires -\tcode{RandomAccessIterator} shall satisfy the requirements of -\tcode{ValueSwappable}\iref{swappable.requirements}. +\tcode{RandomAccessIterator} shall satisfy the +\tcode{ValueSwappable} requirements\iref{swappable.requirements}. The type \tcode{remove_reference_t} -shall meet the requirements of a +shall satisfy the requirements of a uniform random bit generator\iref{rand.req.urng} type whose return type is convertible to \tcode{iterator_traits::difference_type}. @@ -3676,11 +3673,11 @@ \begin{itemdescr} \pnum \requires -\tcode{RandomAccessIterator} shall satisfy the requirements of -\tcode{ValueSwappable}\iref{swappable.requirements}. The type -of \tcode{*first} shall satisfy the requirements of -\tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) and of -\tcode{MoveAssignable} (Table~\ref{tab:moveassignable}). +\tcode{RandomAccessIterator} shall satisfy the +\tcode{ValueSwappable} requirements\iref{swappable.requirements}. The type +of \tcode{*first} shall satisfy the +\tcode{MoveConstructible} (\tref{moveconstructible}) and +\tcode{MoveAssignable} (\tref{moveassignable}) requirements. \pnum \effects @@ -3714,11 +3711,11 @@ \begin{itemdescr} \pnum \requires -\tcode{RandomAccessIterator} shall satisfy the requirements of -\tcode{ValueSwappable}\iref{swappable.requirements}. The type -of \tcode{*first} shall satisfy the requirements of -\tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) and of -\tcode{MoveAssignable} (Table~\ref{tab:moveassignable}). +\tcode{RandomAccessIterator} shall satisfy the +\tcode{ValueSwappable} requirements\iref{swappable.requirements}. The type +of \tcode{*first} shall satisfy the +\tcode{MoveConstructible} (\tref{moveconstructible}) and +\tcode{MoveAssignable} (\tref{moveassignable}) requirements. \pnum \effects @@ -3765,11 +3762,11 @@ \begin{itemdescr} \pnum \requires -\tcode{RandomAccessIterator} shall satisfy the requirements of -\tcode{ValueSwappable}\iref{swappable.requirements}. The type -of \tcode{*first} shall satisfy the requirements of -\tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) and of -\tcode{MoveAssignable} (Table~\ref{tab:moveassignable}). +\tcode{RandomAccessIterator} shall satisfy the +\tcode{ValueSwappable} requirements\iref{swappable.requirements}. The type +of \tcode{*first} shall satisfy the +\tcode{MoveConstructible} (\tref{moveconstructible}) and +\tcode{MoveAssignable} (\tref{moveassignable}) requirements. \pnum \effects @@ -3827,11 +3824,11 @@ \begin{itemdescr} \pnum \requires -\tcode{RandomAccessIterator} shall satisfy the requirements of -\tcode{ValueSwappable}\iref{swappable.requirements}. The type -of \tcode{*result_first} shall satisfy the requirements of -\tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) and of -\tcode{Move\-Assignable} (Table~\ref{tab:moveassignable}). +\tcode{RandomAccessIterator} shall satisfy the +\tcode{ValueSwappable} requirements\iref{swappable.requirements}. The type +of \tcode{*result_first} shall satisfy the +\tcode{MoveConstructible} (\tref{moveconstructible}) and +\tcode{Move\-Assignable} (\tref{moveassignable}) requirements. \pnum \effects @@ -3966,11 +3963,11 @@ \begin{itemdescr} \pnum \requires -\tcode{RandomAccessIterator} shall satisfy the requirements of -\tcode{ValueSwappable}\iref{swappable.requirements}. The type -of \tcode{*first} shall satisfy the requirements of -\tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) and of -\tcode{MoveAssignable} (Table~\ref{tab:moveassignable}). +\tcode{RandomAccessIterator} shall satisfy the +\tcode{ValueSwappable} requirements\iref{swappable.requirements}. The type +of \tcode{*first} shall satisfy the +\tcode{MoveConstructible} (\tref{moveconstructible}) and +\tcode{MoveAssignable} (\tref{moveassignable}) requirements. \pnum \effects @@ -4278,8 +4275,8 @@ \begin{itemdescr} \pnum \requires -\tcode{ForwardIterator} shall satisfy the requirements of -\tcode{ValueSwappable}\iref{swappable.requirements}. +\tcode{ForwardIterator} shall satisfy the +\tcode{ValueSwappable} requirements\iref{swappable.requirements}. \pnum \effects Places all the elements in the range \range{first}{last} that satisfy \tcode{pred} before all the elements that do not satisfy it. @@ -4315,11 +4312,11 @@ \begin{itemdescr} \pnum \requires -\tcode{BidirectionalIterator} shall satisfy the requirements of -\tcode{ValueSwappable}\iref{swappable.requirements}. The type -of \tcode{*first} shall satisfy the requirements of -\tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) and of -\tcode{MoveAssignable} (Table~\ref{tab:moveassignable}). +\tcode{BidirectionalIterator} shall satisfy the +\tcode{ValueSwappable} requirements\iref{swappable.requirements}. The type +of \tcode{*first} shall satisfy the +\tcode{MoveConstructible} (\tref{moveconstructible}) and +\tcode{MoveAssignable} (\tref{moveassignable}) requirements. \pnum \effects @@ -4378,7 +4375,7 @@ \begin{itemize} \item For the overload with no \tcode{ExecutionPolicy}, \tcode{InputIterator}'s -value type shall be \tcode{CopyAssignable} (Table~\ref{tab:copyassignable}), +value type shall be \tcode{CopyAssignable} (\tref{copyassignable}), and shall be writable\iref{iterator.requirements.general} to the \tcode{out_true} and \tcode{out_false} \tcode{OutputIterator}s, and shall be convertible to \tcode{Predicate}'s argument type. @@ -4516,11 +4513,11 @@ \requires The ranges \range{first}{middle} and \range{middle}{last} shall be sorted with respect to \tcode{operator<} or \tcode{comp}. -\tcode{BidirectionalIterator} shall satisfy the requirements of -\tcode{ValueSwappable}\iref{swappable.requirements}. The type -of \tcode{*first} shall satisfy the requirements of -\tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) and of -\tcode{MoveAssignable} (Table~\ref{tab:moveassignable}). +\tcode{BidirectionalIterator} shall satisfy the +\tcode{ValueSwappable} requirements\iref{swappable.requirements}. The type +of \tcode{*first} shall satisfy the +\tcode{MoveConstructible} (\tref{moveconstructible}) and +\tcode{MoveAssignable} (\tref{moveassignable}) requirements. \pnum \effects @@ -4932,9 +4929,9 @@ shall be a valid heap. The type of \tcode{*first} shall satisfy the \tcode{MoveConstructible} requirements -(Table~\ref{tab:moveconstructible}) and the +(\tref{moveconstructible}) and the \tcode{MoveAssignable} requirements -(Table~\ref{tab:moveassignable}). +(\tref{moveassignable}). \pnum \effects @@ -4968,11 +4965,11 @@ The range \range{first}{last} shall be a valid non-empty heap. -\tcode{RandomAccessIterator} shall satisfy the requirements of -\tcode{ValueSwappable}\iref{swappable.requirements}. The type -of \tcode{*first} shall satisfy the requirements of -\tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) and of -\tcode{MoveAssignable} (Table~\ref{tab:moveassignable}). +\tcode{RandomAccessIterator} shall satisfy the +\tcode{ValueSwappable} requirements\iref{swappable.requirements}. The type +of \tcode{*first} shall satisfy the +\tcode{MoveConstructible} (\tref{moveconstructible}) and +\tcode{MoveAssignable} (\tref{moveassignable}) requirements. \pnum @@ -5007,9 +5004,9 @@ \pnum \requires The type of \tcode{*first} shall satisfy the \tcode{MoveConstructible} requirements -(Table~\ref{tab:moveconstructible}) and the +(\tref{moveconstructible}) and the \tcode{MoveAssignable} requirements -(Table~\ref{tab:moveassignable}). +(\tref{moveassignable}). \pnum \effects @@ -5038,11 +5035,11 @@ \begin{itemdescr} \pnum \requires The range \range{first}{last} shall be a valid heap. -\tcode{RandomAccessIterator} shall satisfy the requirements of -\tcode{ValueSwappable}\iref{swappable.requirements}. The type -of \tcode{*first} shall satisfy the requirements of -\tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) and of -\tcode{MoveAssignable} (Table~\ref{tab:moveassignable}). +\tcode{RandomAccessIterator} shall satisfy the +\tcode{ValueSwappable} requirements\iref{swappable.requirements}. The type +of \tcode{*first} shall satisfy the +\tcode{MoveConstructible} (\tref{moveconstructible}) and +\tcode{MoveAssignable} (\tref{moveassignable}) requirements. \pnum \effects @@ -5160,7 +5157,7 @@ \pnum \requires For the first form, type \tcode{T} shall be -\tcode{LessThanComparable} (Table~\ref{tab:lessthancomparable}). +\tcode{LessThanComparable} (\tref{lessthancomparable}). \pnum \returns @@ -5210,7 +5207,7 @@ \pnum \requires For the first form, type \tcode{T} shall be -\tcode{LessThanComparable} (Table~\ref{tab:lessthancomparable}). +\tcode{LessThanComparable} (\tref{lessthancomparable}). \pnum \returns @@ -5261,7 +5258,7 @@ \pnum \requires For the first form, type \tcode{T} shall be -\tcode{LessThanComparable} (Table~\ref{tab:lessthancomparable}). +\tcode{LessThanComparable} (\tref{lessthancomparable}). \pnum \returns @@ -5445,7 +5442,7 @@ \requires The value of \tcode{lo} shall be no greater than \tcode{hi}. For the first form, type \tcode{T} -shall be \tcode{LessThan\-Comparable} (Table~\ref{tab:lessthancomparable}). +shall be \tcode{LessThan\-Comparable} (\tref{lessthancomparable}). \pnum \returns @@ -5640,8 +5637,8 @@ \begin{itemdescr} \pnum \requires -\tcode{BidirectionalIterator} shall satisfy the requirements of -\tcode{ValueSwappable}\iref{swappable.requirements}. +\tcode{BidirectionalIterator} shall satisfy the +\tcode{ValueSwappable} requirements\iref{swappable.requirements}. \pnum \effects @@ -5682,8 +5679,8 @@ \begin{itemdescr} \pnum \requires -\tcode{BidirectionalIterator} shall satisfy the requirements of -\tcode{ValueSwappable}\iref{swappable.requirements}. +\tcode{BidirectionalIterator} shall satisfy the +\tcode{ValueSwappable} requirements\iref{swappable.requirements}. \pnum \effects diff --git a/source/atomics.tex b/source/atomics.tex index bfd052ba0a..67bfb5b828 100644 --- a/source/atomics.tex +++ b/source/atomics.tex @@ -1146,6 +1146,8 @@ \begin{codeblock} namespace std { template<> struct atomic<@\placeholder{floating-point}@> { + using value_type = @\placeholdernc{floating-point}@; + using difference_type = value_type; static constexpr bool is_always_lock_free = @\impdefx{whether a given \tcode{atomic} type's operations are always lock free}@; bool is_lock_free() const volatile noexcept; bool is_lock_free() const noexcept; @@ -1213,7 +1215,7 @@ \pnum The following operations perform arithmetic addition and subtraction computations. The key, operator, and computation correspondence are identified in -Table~\ref{tab:atomic.arithmetic.computations}. +\tref{atomic.arithmetic.computations}. \indexlibrary{\idxcode{atomic_fetch_add}}% \indexlibrary{\idxcode{atomic_fetch_sub}}% diff --git a/source/basic.tex b/source/basic.tex index 5f934a983a..5503cae341 100644 --- a/source/basic.tex +++ b/source/basic.tex @@ -1,7 +1,7 @@ %!TEX root = std.tex -\rSec0[basic]{Basic concepts} +\rSec0[basic]{Basics} -\gramSec[gram.basic]{Basic concepts} +\gramSec[gram.basic]{Basics} \pnum \begin{note} This Clause presents the basic concepts of the \Cpp{} language. @@ -31,7 +31,7 @@ structured binding, function, enumerator, type, class member, bit-field, template, template specialization, namespace, or -parameter pack. +pack. \pnum A \defn{name} is a use of an \grammarterm{identifier}\iref{lex.name}, @@ -183,7 +183,6 @@ \end{itemize} A declaration is said to be a \defn{definition} of each entity that it defines. \begin{example} All but one of the following are definitions: -\indextext{example!definition}% \begin{codeblock} int a; // defines \tcode{a} extern const int c = 1; // defines \tcode{c} @@ -202,7 +201,6 @@ \end{codeblock} whereas these are just declarations: -\indextext{example!declaration}% \begin{codeblock} extern int a; // declares \tcode{a} extern const int c; // declares \tcode{c} @@ -954,7 +952,7 @@ \pnum A namespace member can also be referred to after the \tcode{::} scope -resolution operator\iref{expr.prim} applied to the name of its +resolution operator\iref{expr.prim.id.qual} applied to the name of its namespace or the name of a namespace which nominates the member's namespace in a \grammarterm{using-directive}; see~\ref{namespace.qual}. @@ -1040,7 +1038,7 @@ of its class\iref{expr.ref} or a class derived from its class, \item after the \tcode{->} operator applied to a pointer to an object of its class\iref{expr.ref} or a class derived from its class, -\item after the \tcode{::} scope resolution operator\iref{expr.prim} +\item after the \tcode{::} scope resolution operator\iref{expr.prim.id.qual} applied to the name of its class or a class derived from its class. \end{itemize} @@ -1141,16 +1139,18 @@ \indextext{scope name hiding and}% \indextext{name hiding}% \indextext{hiding|see{name hiding}}% -A name can be hidden by an explicit declaration of that same name in a -nested declarative region or derived class\iref{class.member.lookup}. +A declaration of a name in a nested declarative region +hides a declaration of the same name in an enclosing declarative region; +see \ref{basic.scope.declarative} and \ref{basic.lookup.unqual}. \pnum \indextext{name hiding}% -A class name\iref{class.name} or enumeration name\iref{dcl.enum} can -be hidden by the name of a variable, data member, function, or enumerator declared in -the same scope. If a class or enumeration name and a variable, data member, function, -or enumerator are declared in the same scope (in any order) with the -same name, the class or enumeration name is hidden wherever the variable, data member, +If a class name\iref{class.name} or enumeration name\iref{dcl.enum} and +a variable, data member, function, or enumerator +are declared in the same declarative region (in any order) with the +same name (excluding declarations made visible +via \grammarterm{using-directive}{s}\iref{basic.lookup.unqual}), +the class or enumeration name is hidden wherever the variable, data member, function, or enumerator name is visible. \pnum @@ -1699,7 +1699,7 @@ \indextext{qualification!explicit}% The name of a class or namespace member or enumerator can be referred to after the -\tcode{::} scope resolution operator\iref{expr.prim} applied to a +\tcode{::} scope resolution operator\iref{expr.prim.id.qual} applied to a \grammarterm{nested-name-specifier} that denotes its class, namespace, or enumeration. If a @@ -1752,7 +1752,7 @@ \pnum \indextext{operator!scope resolution}% \indextext{scope resolution operator|see{operator, scope resolution}}% -A name prefixed by the unary scope operator \tcode{::}\iref{expr.prim} +A name prefixed by the unary scope operator \tcode{::}\iref{expr.prim.id.qual} is looked up in global scope, in the translation unit where it is used. The name shall be declared in global namespace scope or shall be a name whose declaration is visible in global scope because of a @@ -2470,21 +2470,12 @@ \item it is a cv-qualified\iref{basic.type.qualifier} version of a type that has linkage. \end{itemize} -A type without linkage shall not be used as the type of a variable or -function with external linkage unless -\begin{itemize} -\item the entity has C language linkage\iref{dcl.link}, or - -\item the entity is not odr-used\iref{basic.def.odr} or is defined in -the same translation unit. -\end{itemize} \begin{note} In other words, a type without linkage contains a class or enumeration that -cannot be named outside its translation unit. An entity with external linkage declared -using such a type could not correspond to any other entity in another translation unit -of the program and thus must be defined in the -translation unit if it is odr-used. Also note that classes with linkage may contain members -whose types do not have linkage, and that typedef names are ignored in the determination +cannot be named outside its translation unit. +Classes with linkage may contain members +whose types do not have linkage. +Typedef names are ignored in the determination of whether a type has linkage. \end{note} @@ -2501,7 +2492,7 @@ A a = { 1 }; B ba; // declares \tcode{B::g(A)} and \tcode{B::h(A)} ba.g(a); // OK - ba.h(a); // error: \tcode{B::h(A) not defined in the translation unit} + ba.h(a); // error: \tcode{B::h(A)} not defined; \tcode{A} cannot be named in another translation unit i(ba, a); // OK } \end{codeblock} @@ -2762,27 +2753,55 @@ \defn{most derived object}. \pnum +A \defn{potentially-overlapping subobject} is either: +\begin{itemize} +\item a base class subobject, or +\item a non-static data member +declared with the \tcode{no_unique_address} attribute\iref{dcl.attr.nouniqueaddr}. +\end{itemize} + +\pnum +\indextext{object!zero size}% +\indextext{object!nonzero size}% +An object has nonzero size if it +\begin{itemize} +\item is not a potentially-overlapping subobject, or +\item is not of class type, or +\item is of a class type with virtual member functions or virtual base classes, or +\item has subobjects of nonzero size or bit-fields of nonzero length. +\end{itemize} +Otherwise, if the object is a base class subobject +of a standard-layout class type +with no non-static data members, +it has zero size. +Otherwise, the circumstances under which the object has zero size +are \impldef{which non-standard-layout objects +containing no data are considered empty}. \indextext{most derived object!bit-field}% -Unless it is a bit-field\iref{class.bit}, a most derived object shall have a -nonzero size and shall occupy one or more bytes of storage. Base class -subobjects may have zero size. An object of trivially copyable or +Unless it is a bit-field\iref{class.bit}, +an object with nonzero size +shall occupy one or more bytes of storage, +including every byte that is occupied in full or in part +by any of its subobjects. +An object of trivially copyable or standard-layout type\iref{basic.types} shall occupy contiguous bytes of storage. \pnum \indextext{most derived object!bit-field}% \indextext{most derived object!zero size subobject}% -Unless an object is a bit-field or a base class subobject of zero size, the +Unless an object is a bit-field or a subobject of zero size, the address of that object is the address of the first byte it occupies. -Two objects \placeholder{a} and \placeholder{b} +Two objects with overlapping lifetimes that are not bit-fields may have the same address if one is nested within the other, or -if at least one is a base class subobject of zero size +if at least one is a subobject of zero size and they are of different types; -otherwise, they have distinct addresses.\footnote{Under the ``as-if'' rule an +otherwise, they have distinct addresses +and occupy disjoint bytes of storage.\footnote{Under the ``as-if'' rule an implementation is allowed to store two objects at the same machine address or not store an object at all if the program cannot observe the difference\iref{intro.execution}.} @@ -2793,6 +2812,9 @@ const bool b = &test1 != &test2; // always \tcode{true} \end{codeblock} \end{example} +The address of a non-bit-field subobject of zero size is +the address of an unspecified byte of storage +occupied by the complete object of that subobject. \pnum \begin{note} @@ -2970,9 +2992,8 @@ class type, does not contain any non-static data member whose type is const-qualified or a reference type, and -\item the original object was a most derived object\iref{intro.object} -of type \tcode{T} and the new object is a most derived object of type -\tcode{T} (that is, they are not base class subobjects). +\item neither the original object nor the new object +is a potentially-overlapping subobject\iref{intro.object}. \end{itemize} \begin{example} \begin{codeblock} @@ -3236,10 +3257,11 @@ class\iref{class.free}. \pnum -Any allocation and/or deallocation functions defined in a \Cpp{} program, -including the default versions in the library, shall conform to the -semantics specified in~\ref{basic.stc.dynamic.allocation} -and~\ref{basic.stc.dynamic.deallocation}. +If the behavior of an allocation or deallocation function +does not satisfy the semantic constraints +specified in~\ref{basic.stc.dynamic.allocation} +and~\ref{basic.stc.dynamic.deallocation}, +the behavior is undefined. \rSec4[basic.stc.dynamic.allocation]{Allocation functions} @@ -3251,37 +3273,41 @@ global scope. The return type shall be \tcode{void*}. The first parameter shall have type \tcode{std::size_t}\iref{support.types}. The first parameter shall not have an associated default -argument\iref{dcl.fct.default}. The value of the first parameter shall -be interpreted as the requested size of the allocation. An allocation +argument\iref{dcl.fct.default}. The value of the first parameter +is interpreted as the requested size of the allocation. An allocation function can be a function template. Such a template shall declare its return type and first parameter as specified above (that is, template parameter types shall not be used in the return type and first parameter type). Template allocation functions shall have two or more parameters. \pnum -The allocation function attempts to allocate the requested amount of -storage. If it is successful, it shall return the address of the start -of a block of storage whose length in bytes shall be at least as large -as the requested size. There are no constraints on the contents of the -allocated storage on return from the allocation function. The order, +An allocation function attempts to allocate the requested amount of +storage. If it is successful, it returns the address of the start +of a block of storage whose length in bytes is at least as large +as the requested size. +The order, contiguity, and initial value of storage allocated by successive calls -to an allocation function are unspecified. The pointer returned shall be +to an allocation function are unspecified. +For an allocation function other than +a reserved placement allocation function\iref{new.delete.placement}, +the pointer returned is suitably aligned so that it can be converted to a pointer to any suitable complete object type\iref{new.delete.single} and then used to access the object or array in the storage allocated (until the storage is explicitly deallocated by a call to a corresponding deallocation function). Even if the size of the space requested is zero, the request can fail. If the request succeeds, the -value returned shall be a non-null pointer value\iref{conv.ptr} +value returned by a replaceable allocation function +is a non-null pointer value\iref{conv.ptr} \tcode{p0} different from any previously returned value \tcode{p1}, -unless that value \tcode{p1} was subsequently passed to an -\tcode{operator} \tcode{delete}. +unless that value \tcode{p1} was subsequently passed to a +replaceable deallocation function. Furthermore, for the library allocation functions in~\ref{new.delete.single} and~\ref{new.delete.array}, -\tcode{p0} shall represent the address of a block of storage disjoint from the storage +\tcode{p0} represents the address of a block of storage disjoint from the storage for any other object accessible to the caller. The effect of indirecting through a pointer -returned as a request for zero size is undefined.\footnote{The intent is +returned from a request for zero size is undefined.\footnote{The intent is to have \tcode{operator new()} implementable by calling \tcode{std::malloc()} or \tcode{std::calloc()}, so the rules are substantially the same. \Cpp{} differs from C in requiring a zero request @@ -3295,11 +3321,13 @@ A program-supplied allocation function can obtain the address of the currently installed \tcode{new_handler} using the \tcode{std::get_new_handler} function\iref{set.new.handler}. \end{note} -If an allocation function that has a non-throwing +An allocation function that has a non-throwing exception specification\iref{except.spec} -fails to allocate storage, it shall return a null pointer. Any other -allocation function that fails to allocate storage shall indicate -failure only by throwing an exception\iref{except.throw} of a type +indicates failure by returning +a null pointer value. +Any other allocation function +never returns a null pointer value and +indicates failure only by throwing an exception\iref{except.throw} of a type that would match a handler\iref{except.handle} of type \tcode{std::bad_alloc}\iref{bad.alloc}. @@ -3573,7 +3601,7 @@ \pnum \indextext{object!byte copying and|(}% \indextext{type!trivially copyable}% -For any object (other than a base-class subobject) of trivially copyable type +For any object (other than a potentially-overlapping subobject) of trivially copyable type \tcode{T}, whether or not the object holds a valid value of type \tcode{T}, the underlying bytes\iref{intro.memory} making up the object can be copied into an array of @@ -3597,7 +3625,7 @@ \pnum For any trivially copyable type \tcode{T}, if two pointers to \tcode{T} point to distinct \tcode{T} objects \tcode{obj1} and \tcode{obj2}, where neither -\tcode{obj1} nor \tcode{obj2} is a base-class subobject, if the underlying +\tcode{obj1} nor \tcode{obj2} is a potentially-overlapping subobject, if the underlying bytes\iref{intro.memory} making up \tcode{obj1} are copied into \tcode{obj2},\footnote{By using, for example, the library functions\iref{headers} \tcode{std::memcpy} or \tcode{std::memmove}.} @@ -3763,7 +3791,7 @@ \pnum \indextext{type!fundamental}% \indextext{type!integral}% -\indextext{type!floating-point}% +\indextext{floating-point type|see{type, floating-point}}% \indextext{type!implementation-defined \tcode{sizeof}}% \indextext{type!Boolean}% \indextext{type!\idxcode{char}}% @@ -3940,7 +3968,7 @@ \end{example} \pnum -There are three \defnx{floating-point}{floating-point type} types: +There are three \defnx{floating-point types}{type!floating-point}: \indextext{type!\idxcode{float}}% \tcode{float}, \indextext{type!\idxcode{double}}% @@ -3960,7 +3988,7 @@ This document imposes no requirements on the accuracy of floating-point operations; see also~\ref{support.limits}. \end{note} -Integral and floating types are collectively +Integral and floating-point types are collectively called \defnx{arithmetic}{type!arithmetic} types. \indextext{\idxcode{numeric_limits}!specializations for arithmetic types}% Specializations of the standard library template @@ -4208,7 +4236,7 @@ \pnum There is a partial ordering on cv-qualifiers, so that a type can be said to be \defn{more cv-qualified} than another. -Table~\ref{tab:relations.on.const.and.volatile} shows the relations that +\tref{relations.on.const.and.volatile} shows the relations that constitute this ordering. \begin{floattable}{Relations on \tcode{const} and \tcode{volatile}}{tab:relations.on.const.and.volatile} diff --git a/source/classes.tex b/source/classes.tex index b30cfc7cc2..ce46e62b35 100644 --- a/source/classes.tex +++ b/source/classes.tex @@ -55,6 +55,10 @@ \terminal{union} \end{bnf} +A class declaration where the \grammarterm{class-name} +in the \grammarterm{class-head-name} is a \grammarterm{simple-template-id} +shall be an explicit specialization\iref{temp.expl.spec} or +a partial specialization\iref{temp.class.spec}. A \grammarterm{class-specifier} whose \grammarterm{class-head} omits the \grammarterm{class-head-name} defines an unnamed class. \begin{note} An unnamed class thus can't @@ -97,8 +101,14 @@ \end{example} \pnum -Complete objects and member subobjects of class type shall have nonzero -size.\footnote{Base class subobjects are not so constrained.} +\begin{note} +Complete objects of class type have nonzero size. +Base class subobjects and +members declared with the \tcode{no_unique_address} attribute\iref{dcl.attr.nouniqueaddr} +are not so constrained. +\end{note} + +\pnum \begin{note} Class objects can be assigned, passed as arguments to functions, and returned by functions (except objects of classes for which copying or moving has @@ -171,8 +181,11 @@ inherited\iref{class.derived}) non-static data members, the set $M(\mathtt{X})$ is empty. -\item If \tcode{X} is a non-union class type whose first non-static data -member has type $\mathtt{X}_0$ (where said member may be an anonymous union), +\item If \tcode{X} is a non-union class type with a non-static data +member of type $\mathtt{X}_0$ +that is either of zero size or +is the first non-static data member of \tcode{X} +(where said member may be an anonymous union), the set $M(\mathtt{X})$ consists of $\mathtt{X}_0$ and the elements of $M(\mathtt{X}_0)$. @@ -189,8 +202,7 @@ \end{itemize} \begin{note} $M(\mathtt{X})$ is the set of the types of all non-base-class subobjects -that are guaranteed in a standard-layout class to be at a zero offset -in \tcode{X}. \end{note} +that may be at a zero offset in \tcode{X}. \end{note} \begin{example} \begin{codeblock} @@ -352,7 +364,6 @@ \end{example} \begin{note} Such declarations allow definition of classes that refer to each other. -\indextext{example!friend}% \begin{example} \begin{codeblock} class Vector; @@ -637,7 +648,7 @@ A \grammarterm{virt-specifier-seq} shall contain at most one of each \grammarterm{virt-specifier}. A \grammarterm{virt-specifier-seq} -shall appear only in the declaration of a virtual member +shall appear only in the first declaration of a virtual member function\iref{class.virtual}. \pnum @@ -649,7 +660,7 @@ \pnum \begin{note} -See~\ref{expr.prim} for restrictions on the use of non-static data +See~\ref{expr.prim.id} for restrictions on the use of non-static data members and non-static member functions. \end{note} @@ -661,7 +672,6 @@ \end{note} \pnum -\indextext{example!class definition}% \begin{example} A simple example of a class definition is @@ -739,8 +749,12 @@ types is the longest sequence of non-static data members and bit-fields in declaration order, starting with the first such entity in each of the structs, such that corresponding entities -have layout-compatible types and either neither entity is a bit-field or -both are bit-fields with the same width. +have layout-compatible types, +either both entities are declared with +the \tcode{no_unique_address} attribute\iref{dcl.attr.nouniqueaddr} +or neither is, +and either both entities are bit-fields with the same width +or neither is a bit-field. \begin{example} \begin{codeblock} struct A { int a; char b; }; @@ -927,7 +941,7 @@ \tcode{X}, the behavior is undefined. \pnum -When an \grammarterm{id-expression}\iref{expr.prim} that is not part of a +When an \grammarterm{id-expression}\iref{expr.prim.id} that is not part of a class member access syntax\iref{expr.ref} and not used to form a pointer to member\iref{expr.unary.op} is used in a member of class \tcode{X} in a context where \tcode{this} can be @@ -947,15 +961,14 @@ member access expression is ill-formed. \end{note} Similarly during name lookup, when an -\grammarterm{unqualified-id}\iref{expr.prim} used in the definition of a +\grammarterm{unqualified-id}\iref{expr.prim.id.unqual} used in the definition of a member function for class \tcode{X} resolves to a static member, an enumerator or a nested type of class \tcode{X} or of a base class of \tcode{X}, the \grammarterm{unqualified-id} is transformed into a -\grammarterm{qualified-id}\iref{expr.prim} in which the +\grammarterm{qualified-id}\iref{expr.prim.id.qual} in which the \grammarterm{nested-name-specifier} names the class of the member function. These transformations do not apply in the template definition context\iref{temp.dep.type}. -\indextext{example!member function}% \begin{example} \begin{codeblock} @@ -1149,7 +1162,7 @@ \end{example} \pnum -If an \grammarterm{unqualified-id}\iref{expr.prim} is used in the +If an \grammarterm{unqualified-id}\iref{expr.prim.id.unqual} is used in the definition of a static member following the member's \grammarterm{declarator-id}, and name lookup\iref{basic.lookup.unqual} finds that the \grammarterm{unqualified-id} refers to a static @@ -1159,7 +1172,7 @@ \grammarterm{nested-name-specifier} names the class scope from which the member is referenced. \begin{note} -See~\ref{expr.prim} for restrictions on the use of non-static data +See~\ref{expr.prim.id} for restrictions on the use of non-static data members and non-static member functions. \end{note} @@ -1220,7 +1233,6 @@ operator. The \grammarterm{initializer} expression in the definition of a static data member is in the scope of its class\iref{basic.scope.class}. -\indextext{example!static member}% \begin{example} \begin{codeblock} @@ -1330,6 +1342,7 @@ A declaration for a bit-field that omits the \grammarterm{identifier} declares an \defn{unnamed bit-field}. Unnamed bit-fields are not members and cannot be initialized. +An unnamed bit-field shall not be declared with a cv-qualified type. \begin{note} An unnamed bit-field is useful for padding to conform to externally-imposed layouts. @@ -1399,13 +1412,11 @@ \indextext{nested class!scope of}% The nested class is in the scope of its enclosing class. \begin{note} -See~\ref{expr.prim} for restrictions on the use of non-static data +See~\ref{expr.prim.id} for restrictions on the use of non-static data members and non-static member functions. \end{note} -\indextext{example!nested class}% \begin{example} - \begin{codeblock} int x; int y; @@ -1435,9 +1446,7 @@ \pnum Member functions and static data members of a nested class can be defined in a namespace scope enclosing the definition of their class. -\indextext{example!nested class definition}% \begin{example} - \begin{codeblock} struct enclose { struct inner { @@ -1457,9 +1466,7 @@ \tcode{Y} may be declared in class \tcode{X} and later defined in the definition of class \tcode{X} or be later defined in a namespace scope enclosing the definition of class \tcode{X}. -\indextext{example!nested class forward declaration}% \begin{example} - \begin{codeblock} class E { class I1; // forward declaration of nested class @@ -1487,8 +1494,6 @@ particular, type names defined within a class definition cannot be used outside their class without qualification. \begin{example} - -\indextext{example!nested type name}% \begin{codeblock} struct X { typedef int I; @@ -1777,7 +1782,6 @@ enclosing scope. \end{note} \begin{example} -\indextext{example!local class}% \begin{codeblock} int x; void f() { diff --git a/source/compatibility.tex b/source/compatibility.tex index 290437df9e..008e6ad6f3 100644 --- a/source/compatibility.tex +++ b/source/compatibility.tex @@ -873,7 +873,7 @@ this International Standard. Specifically, macros named \tcode{R}, \tcode{u8}, \tcode{u8R}, \tcode{u}, \tcode{uR}, \tcode{U}, \tcode{UR}, or \tcode{LR} will not be expanded when adjacent to a string literal but will be interpreted as -part of the string literal. For example, +part of the string literal. For example: \begin{codeblock} #define u8 "abc" @@ -885,7 +885,8 @@ \rationale Required for new features. \effect Valid \CppIII{} code may fail to compile or produce different results in -this International Standard, as the following example illustrates. +this International Standard. +For example: \begin{codeblock} #define _x "there" @@ -900,7 +901,7 @@ \change New keywords. \rationale Required for new features. \effect -Added to Table~\ref{tab:keywords}, the following identifiers are new keywords: +Added to \tref{keywords}, the following identifiers are new keywords: \tcode{alignas}, \tcode{alignof}, \tcode{char16_t}, @@ -929,7 +930,8 @@ \rationale Removing surprising interactions with templates and constant expressions. \effect Valid \CppIII{} code may fail to compile or produce different results in -this International Standard, as the following example illustrates: +this International Standard. +For example: \begin{codeblock} void f(void *); // \#1 @@ -954,7 +956,8 @@ \rationale Required for new features. \effect Valid \CppIII{} code may fail to compile or produce different results in -this International Standard, as the following example illustrates: +this International Standard. +For example: \begin{codeblock} bool b1 = new int && false; // previously \tcode{false}, now ill-formed @@ -1467,6 +1470,7 @@ by aggregate initialization. \effect Valid \CppXI{} code may fail to compile or may change meaning in this International Standard. +For example: \begin{codeblock} struct S { // Aggregate in \CppXIV{} onwards. int m = 1; @@ -1530,6 +1534,7 @@ this International Standard. Specifically, character sequences like \tcode{0p+0} and \tcode{0e1_p+0} are three separate tokens each in \CppXIV{}, but one single token in this International Standard. +For example: \begin{codeblock} #define F(a) b ## a @@ -1588,7 +1593,8 @@ \rationale Improve type-safety. \effect Valid \CppXIV{} code may fail to compile or change meaning in this -International Standard: +International Standard. +For example: \begin{codeblock} void g1() noexcept; @@ -1605,7 +1611,8 @@ Valid \CppXIV{} code may fail to compile or produce different results in this International Standard; initialization from an empty initializer list will perform aggregate initialization instead of invoking a default constructor -for the affected types: +for the affected types. +For example: \begin{codeblock} struct derived; struct base { @@ -1655,7 +1662,8 @@ allows partial specializations to decompose from the type deduced for the non-type template argument. \effect Valid \CppXIV{} code may fail to compile -or produce different results in this International Standard: +or produce different results in this International Standard. +For example: \begin{codeblock} template struct A; template int foo(A *) = delete; @@ -1694,6 +1702,7 @@ \effect The following \Cpp{} headers are new: \tcode{}, +\tcode{}, \tcode{}, \tcode{}, \tcode{}, @@ -1863,6 +1872,26 @@ if those entities are only referenced in contexts that do not result in an odr-use. +\rSec2[diff.cpp17.special]{\ref{special}: special member functions} + +\diffrefs{class.ctor}{class.dtor} +\change +A \grammarterm{simple-template-id} +is no longer valid as the \grammarterm{declarator-id} of a constructor or destructor. +\rationale +Remove potentially error-prone option for redundancy. +\effect +Valid \CppXVII{} code may fail to compile +in this International Standard. For example: +\begin{codeblock} +template +struct A { + A(); // error: \grammarterm{simple-template-id} not allowed for constructor + A(int); // OK, \grammarterm{injected-class-name} used + ~A(); // error: \grammarterm{simple-template-id} not allowed for destructor +}; +\end{codeblock} + \rSec2[diff.cpp17.temp]{\ref{temp}: templates} \diffref{temp.names} @@ -1896,14 +1925,15 @@ \rSec2[diff.cpp17.library]{\ref{library}: library introduction} -\ref{headers} +\diffref{headers} \change New headers. \rationale New functionality. \effect The following \Cpp{} headers are new: -\tcode{} -and -\tcode{}. +\tcode{}, +\tcode{}, +\tcode{}, and +\tcode{}. Valid \CppXVII{} code that \tcode{\#include}{s} headers with these names may be invalid in this International Standard. diff --git a/source/config.tex b/source/config.tex index 31ef054268..9140f76a1b 100644 --- a/source/config.tex +++ b/source/config.tex @@ -1,8 +1,8 @@ %!TEX root = std.tex %%-------------------------------------------------- %% Version numbers -\newcommand{\docno}{N4727} -\newcommand{\prevdocno}{N4713} +\newcommand{\docno}{N4741} +\newcommand{\prevdocno}{N4727} \newcommand{\cppver}{201703L} %% Release date diff --git a/source/containers.tex b/source/containers.tex index c3c57d7701..f4584bdef5 100644 --- a/source/containers.tex +++ b/source/containers.tex @@ -14,7 +14,7 @@ sequence containers and associative containers, as summarized in -Table~\ref{tab:containers.lib.summary}. +\tref{containers.lib.summary}. \begin{libsumtab}{Containers library summary}{tab:containers.lib.summary} \ref{container.requirements} & Requirements & \\ \rowsep @@ -29,6 +29,7 @@ & & \tcode{} \\ \rowsep \ref{container.adaptors} & Container adaptors & \tcode{} \\ & & \tcode{} \\ \rowsep +\ref{views} & Views & \tcode{} \\ \rowsep \end{libsumtab} @@ -234,7 +235,7 @@ \tcode{swap(a, b)} & \tcode{void} & - \tcode{a.swap(b)} & + Equivalent to \tcode{a.swap(b)} & & (Note A) \\ \rowsep @@ -360,7 +361,7 @@ the container is called \term{reversible} and satisfies the additional requirements -in Table~\ref{tab:containers.reversible.requirements}. +in \tref{containers.reversible.requirements}. \begin{libreqtab4a} {Reversible container requirements} @@ -458,10 +459,10 @@ are contiguous iterators\iref{iterator.requirements.general}. \pnum -Table~\ref{tab:containers.optional.operations} lists operations that are provided +\tref{containers.optional.operations} lists operations that are provided for some types of containers but not others. Those containers for which the listed operations are provided shall implement the semantics described in -Table~\ref{tab:containers.optional.operations} unless otherwise stated. +\tref{containers.optional.operations} unless otherwise stated. \begin{libreqtab5} {Optional container operations} @@ -510,7 +511,7 @@ \pnum All of the containers defined in this Clause and in~\ref{basic.string} except \tcode{array} meet the additional requirements of an allocator-aware container, as described in -Table~\ref{tab:containers.allocatoraware}. +\tref{containers.allocatoraware}. Given an allocator type \tcode{A} and given a container type \tcode{X} having a \tcode{value_type} identical to \tcode{T} @@ -595,7 +596,7 @@ \end{note} \pnum -In Table~\ref{tab:containers.allocatoraware}, \tcode{X} denotes an allocator-aware container class +In \tref{containers.allocatoraware}, \tcode{X} denotes an allocator-aware container class with a \tcode{value_type} of \tcode{T} using allocator of type \tcode{A}, \tcode{u} denotes a variable, \tcode{a} and \tcode{b} denote non-const lvalues of type \tcode{X}, @@ -754,11 +755,14 @@ might define). \pnum +\begin{note} The sequence containers offer the programmer different complexity trade-offs and should be used accordingly. -\tcode{vector} or \tcode{array} +\tcode{vector} is the type of sequence container that should be used by default. +\tcode{array} +should be used when the container has a fixed size known during translation. \tcode{list} or \tcode{forward_list} should be used when there are frequent insertions and deletions from the middle of the sequence. @@ -766,6 +770,9 @@ is the data structure of choice when most insertions and deletions take place at the beginning or at the end of the sequence. +When choosing a container, remember \tcode{vector} is best; +leave a comment to explain if you choose from the rest! +\end{note} \pnum In Tables~\ref{tab:containers.sequence.requirements} @@ -853,7 +860,10 @@ \tcode{T} is also \tcode{MoveInsertable} into \tcode{X} and \tcode{MoveAssignable}. \effects\ Inserts an object of type \tcode{T} constructed with - \tcode{std::forward<\brk{}Args\brk{}>(\brk{}args)...} before \tcode{p}. \\ \rowsep + \tcode{std::forward<\brk{}Args\brk{}>(\brk{}args)...} before \tcode{p}. + \begin{note} \tcode{args} may directly or indirectly refer to + a value in \tcode{a}. \end{note} + \\ \rowsep \tcode{a.insert(p,t)} & \tcode{iterator} & @@ -1027,7 +1037,7 @@ \end{itemize} \pnum -Table~\ref{tab:containers.sequence.optional} lists operations +\tref{containers.sequence.optional} lists operations that are provided for some types of sequence containers but not others. An implementation shall provide @@ -1189,16 +1199,16 @@ \rSec2[container.node]{Node handles} -\rSec3[container.node.overview]{\tcode{node_handle} overview} +\rSec3[container.node.overview]{Overview} \pnum -A \term{node handle} is an object that accepts ownership of a single element +A \defn{node handle} is an object that accepts ownership of a single element from an associative container\iref{associative.reqmts} or an unordered associative container\iref{unord.req}. It may be used to transfer that ownership to another container with compatible nodes. Containers with compatible nodes have the same node handle type. Elements may be transferred in either direction between container types in the same row of -Table~\ref{tab:containers.node.compat}. +\tref{containers.node.compat}. \begin{floattable}{Container types with compatible nodes}{tab:containers.node.compat} {ll} @@ -1239,46 +1249,51 @@ \begin{codeblock} template<@\unspecnc@> - class @\placeholder{node_handle}@ { - public: - // These type declarations are described in Tables \ref{tab:containers.associative.requirements} and \ref{tab:HashRequirements}. - using value_type = @\seebelownc{}@; // not present for map containers - using key_type = @\seebelownc{}@; // not present for set containers - using mapped_type = @\seebelownc{}@; // not present for set containers - using allocator_type = @\seebelownc{}@; - - private: - using container_node_type = @\unspecnc@; - using ator_traits = allocator_traits; - - typename ator_traits::rebind_traits::pointer ptr_; - optional alloc_; - - public: - constexpr @\placeholdernc{node_handle}@() noexcept : ptr_(), alloc_() {} - ~@\placeholdernc{node_handle}@(); - @\placeholdernc{node_handle}@(@\placeholdernc{node_handle}@&&) noexcept; - @\placeholdernc{node_handle}@& operator=(@\placeholdernc{node_handle}@&&); - - value_type& value() const; // not present for map containers - key_type& key() const; // not present for set containers - mapped_type& mapped() const; // not present for set containers - - allocator_type get_allocator() const; - explicit operator bool() const noexcept; - [[nodiscard]] bool empty() const noexcept; - - void swap(@\placeholdernc{node_handle}@&) - noexcept(ator_traits::propagate_on_container_swap::value || - ator_traits::is_always_equal::value); - - friend void swap(@\placeholdernc{node_handle}@& x, @\placeholdernc{node_handle}@& y) noexcept(noexcept(x.swap(y))) { - x.swap(y); - } +class @\placeholder{node_handle}@ { +public: + // These type declarations are described in Tables \ref{tab:containers.associative.requirements} and \ref{tab:HashRequirements}. + using value_type = @\seebelownc{}@; // not present for map containers + using key_type = @\seebelownc{}@; // not present for set containers + using mapped_type = @\seebelownc{}@; // not present for set containers + using allocator_type = @\seebelownc{}@; + +private: + using container_node_type = @\unspecnc@; + using ator_traits = allocator_traits; + + typename ator_traits::rebind_traits::pointer ptr_; + optional alloc_; + +public: + // \ref{container.node.cons}, constructors, copy, and assignment + constexpr @\placeholdernc{node_handle}@() noexcept : ptr_(), alloc_() {} + @\placeholdernc{node_handle}@(@\placeholdernc{node_handle}@&&) noexcept; + @\placeholdernc{node_handle}@& operator=(@\placeholdernc{node_handle}@&&); + + // \ref{container.node.dtor}, destructor + ~@\placeholdernc{node_handle}@(); + + // \ref{container.node.observers}, observers + value_type& value() const; // not present for map containers + key_type& key() const; // not present for set containers + mapped_type& mapped() const; // not present for set containers + + allocator_type get_allocator() const; + explicit operator bool() const noexcept; + [[nodiscard]] bool empty() const noexcept; + + // \ref{container.node.modifiers}, modifiers + void swap(@\placeholdernc{node_handle}@&) + noexcept(ator_traits::propagate_on_container_swap::value || + ator_traits::is_always_equal::value); + + friend void swap(@\placeholdernc{node_handle}@& x, @\placeholdernc{node_handle}@& y) noexcept(noexcept(x.swap(y))) { + x.swap(y); + } }; \end{codeblock} -\rSec3[container.node.cons]{\tcode{\placeholder{node_handle}} constructors, copy, and assignment} +\rSec3[container.node.cons]{Constructors, copy, and assignment} \begin{itemdecl} @\placeholdernc{node_handle}@(@\placeholdernc{node_handle}@&& nh) noexcept; @@ -1326,7 +1341,7 @@ \pnum \throws Nothing. \end{itemdescr} -\rSec3[container.node.dtor]{\tcode{\placeholder{node_handle}} destructor} +\rSec3[container.node.dtor]{Destructor} \begin{itemdecl} ~@\placeholdernc{node_handle}@(); @@ -1340,7 +1355,7 @@ \tcode{ator_traits::rebind_traits::deallocate}. \end{itemdescr} -\rSec3[container.node.observers]{\tcode{\placeholder{node_handle}} observers} +\rSec3[container.node.observers]{Observers} \begin{itemdecl} value_type& value() const; @@ -1429,7 +1444,7 @@ \returns \tcode{ptr_ == nullptr}. \end{itemdescr} -\rSec3[container.node.modifiers]{\tcode{\placeholder{node_handle}} modifiers} +\rSec3[container.node.modifiers]{Modifiers} \begin{itemdecl} void swap(@\placeholdernc{node_handle}@& nh) @@ -1507,11 +1522,7 @@ \pnum The phrase ``equivalence of keys'' means the equivalence relation imposed by the -comparison and -\textit{not} -the -\tcode{operator==} -on keys. +comparison object. That is, two keys \tcode{k1} and @@ -1520,6 +1531,9 @@ comparison object \tcode{comp}, \tcode{comp(k1, k2) == false \&\& comp(k2, k1) == false}. +\begin{note} +This is not necessarily the same as the result of \tcode{k1 == k2}. +\end{note} For any two keys \tcode{k1} and @@ -1559,18 +1573,18 @@ The associative containers meet all the requirements of Allocator-aware containers\iref{container.requirements.general}, except that for \tcode{map} and \tcode{multimap}, the requirements placed on \tcode{value_type} -in Table~\ref{tab:containers.allocatoraware} apply instead to \tcode{key_type} +in \tref{containers.allocatoraware} apply instead to \tcode{key_type} and \tcode{mapped_type}. \begin{note} For example, in some cases \tcode{key_type} and \tcode{mapped_type} are required to be \tcode{CopyAssignable} even though the associated \tcode{value_type}, \tcode{pair}, is not \tcode{CopyAssignable}. \end{note} \pnum -In Table~\ref{tab:containers.associative.requirements}, +In \tref{containers.associative.requirements}, \tcode{X} denotes an associative container class, \tcode{a} denotes a value of type \tcode{X}, \tcode{a2} denotes a value of a type with nodes compatible with type -\tcode{X} (Table~\ref{tab:containers.node.compat}), +\tcode{X} (\tref{containers.node.compat}), \tcode{b} denotes a possibly \tcode{const} value of type \tcode{X}, \tcode{u} denotes the name of a variable being declared, \tcode{a_uniq} denotes a value of type \tcode{X} @@ -2176,7 +2190,7 @@ The unordered associative containers meet all the requirements of Allocator-aware containers\iref{container.requirements.general}, except that for \tcode{unordered_map} and \tcode{unordered_multimap}, the requirements placed on \tcode{value_type} -in Table~\ref{tab:containers.allocatoraware} apply instead to \tcode{key_type} +in \tref{containers.allocatoraware} apply instead to \tcode{key_type} and \tcode{mapped_type}. \begin{note} For example, \tcode{key_type} and \tcode{mapped_type} are sometimes required to be \tcode{CopyAssignable} even though the associated \tcode{value_type}, \tcode{pair}, is not @@ -2189,11 +2203,11 @@ \indextext{unordered associative containers!unique keys}% \indextext{unordered associative containers!equivalent keys}% \indextext{requirements!container}% -In Table~\ref{tab:HashRequirements}: +In \tref{HashRequirements}: \tcode{X} denotes an unordered associative container class, \tcode{a} denotes a value of type \tcode{X}, \tcode{a2} denotes a value of a type with nodes compatible with type -\tcode{X} (Table~\ref{tab:containers.node.compat}), +\tcode{X} (\tref{containers.node.compat}), \tcode{b} denotes a possibly const value of type \tcode{X}, \tcode{a_uniq} denotes a value of type \tcode{X} when \tcode{X} supports unique keys, \tcode{a_eq} denotes a value of type \tcode{X} when \tcode{X} supports equivalent keys, @@ -2212,6 +2226,15 @@ \tcode{z} denotes a value of type \tcode{float}, and \tcode{nh} denotes a non-const rvalue of type \tcode{X::node_type}. +% Local command to index names as members of all unordered containers. +\newcommand{\indexunordmem}[1]{% +\indexlibrary{\idxcode{#1}!unordered associative containers}% +\indexlibrary{\idxcode{unordered_set}!\idxcode{#1}}% +\indexlibrary{\idxcode{unordered_map}!\idxcode{#1}}% +\indexlibrary{\idxcode{unordered_multiset}!\idxcode{#1}}% +\indexlibrary{\idxcode{unordered_multimap}!\idxcode{#1}}% +} + \begin{libreqtab4d} {Unordered associative container requirements (in addition to container)} {tab:HashRequirements} @@ -2225,9 +2248,8 @@ & & \chdr{pre-/post-condition} & \\ \capsep \endhead %% +\indexunordmem{key_type}% \tcode{X::key_type} & -\indextext{unordered associative containers!\idxcode{key_type}}% -\indextext{\idxcode{key_type}!unordered associative containers}% \tcode{Key} & & compile time \\ \rowsep @@ -2247,25 +2269,24 @@ \requires\ \tcode{value_type} is \tcode{Erasable} from \tcode{X} & compile time \\ \rowsep +\indexunordmem{hasher}% \tcode{X::hasher} & \tcode{Hash} & \tcode{Hash} shall be a unary function object type such that the expression \tcode{hf(k)} has type \tcode{size_t}.% - \indextext{unordered associative containers!\idxcode{hasher}}% - \indextext{\idxcode{hasher}!unordered associative containers}% & compile time \\ \rowsep % +\indexunordmem{key_equal}% \tcode{X::key_equal} & \tcode{Pred} & \requires\ \tcode{Pred} is \tcode{CopyConstructible}.\br \tcode{Pred} shall be a binary predicate that takes two arguments of type \tcode{Key}. \tcode{Pred} is an equivalence relation.% - \indextext{unordered associative containers!\idxcode{key_equal}}% - \indextext{\idxcode{key_equal}!unordered associative containers}% & compile time \\ \rowsep % +\indexunordmem{local_iterator}% \tcode{X::local_iterator} & An iterator type whose category, value type, difference type, and pointer and reference types are the same as @@ -2273,11 +2294,10 @@ & A \tcode{local_iterator} object may be used to iterate through a single bucket, but may not be used to iterate across buckets.% - \indextext{unordered associative containers!\idxcode{local_iterator}}% - \indextext{\idxcode{local_iterator}!unordered associative containers}% & compile time \\ \rowsep % +\indexunordmem{const_local_iterator}% \tcode{X::const_local_iterator} & An iterator type whose category, value type, difference type, and pointer and reference types are the same as @@ -2285,11 +2305,10 @@ & A \tcode{const_local_iterator} object may be used to iterate through a single bucket, but may not be used to iterate across buckets.% - \indextext{unordered associative containers!\idxcode{const_local_iterator}}% - \indextext{\idxcode{const_local_iterator}!unordered associative containers}% & compile time \\ \rowsep % +\indexunordmem{node_type}% \tcode{X::node_type} & a specialization of a \tcode{\placeholder{node_handle}} class template, such that the public nested types are @@ -2404,7 +2423,7 @@ \tcode{X(b)}\br \tcode{X a(b);} & \tcode{X} & Copy constructor. In addition to the requirements - of Table~\ref{tab:containers.container.requirements}, copies the + of \tref{containers.container.requirements}, copies the hash function, predicate, and maximum load factor. & Average case linear in \tcode{b.size()}, worst case quadratic. \\ \rowsep @@ -2412,7 +2431,7 @@ \tcode{a = b} & \tcode{X\&} & Copy assignment operator. In addition to the - requirements of Table~\ref{tab:containers.container.requirements}, copies + requirements of \tref{containers.container.requirements}, copies the hash function, predicate, and maximum load factor. & Average case linear in \tcode{b.size()}, worst case quadratic. \\ \rowsep @@ -2427,19 +2446,17 @@ & Same as \tcode{a = X(il)}. \\ \rowsep % +\indexunordmem{hash_function}% \tcode{b.hash_function()} & \tcode{hasher} & Returns \tcode{b}'s hash function.% - \indextext{unordered associative containers!\idxcode{hash_function}}% - \indextext{\idxcode{hash_function}!unordered associative containers}% & constant \\ \rowsep % +\indexunordmem{key_eq}% \tcode{b.key_eq()} & \tcode{key_equal} & Returns \tcode{b}'s key equality predicate.% - \indextext{unordered associative containers!\idxcode{key_eq}}% - \indextext{\idxcode{key_eq}!unordered associative containers}% & constant \\ \rowsep % @@ -2477,6 +2494,7 @@ Average case \bigoh{1}, worst case \bigoh{\tcode{a.} \tcode{size()}}. \\ \rowsep +\indexunordmem{insert}% \tcode{a_uniq.insert(t)} & \tcode{pair} & \requires\ If \tcode{t} is a non-const rvalue expression, \tcode{value_type} shall be @@ -2487,8 +2505,6 @@ component of the returned pair indicates whether the insertion takes place, and the \tcode{iterator} component points to the element with key equivalent to the key of \tcode{t}.% - \indextext{unordered associative containers!\idxcode{insert}}% - \indextext{\idxcode{insert}!unordered associative containers}% & Average case \bigoh{1}, worst case \bigoh{\tcode{a_uniq.}\br\tcode{size()}}. \\ \rowsep % @@ -2499,8 +2515,6 @@ \tcode{CopyInsertable} into \tcode{X}.\br \effects\ Inserts \tcode{t}, and returns an iterator pointing to the newly inserted element. - \indextext{unordered associative containers!\idxcode{insert}}% - \indextext{\idxcode{insert}!unordered associative containers}% & Average case \bigoh{1}, worst case \bigoh{\tcode{a_eq.}\br\tcode{size()}}. \\ \rowsep % @@ -2513,8 +2527,6 @@ to the element with the key equivalent to that of \tcode{t}. The iterator \tcode{p} is a hint pointing to where the search should start. Implementations are permitted to ignore the hint.% - \indextext{unordered associative containers!\idxcode{insert}}% - \indextext{\idxcode{insert}!unordered associative containers}% & Average case \bigoh{1}, worst case \bigoh{\tcode{a.size()}}. \\ \rowsep % @@ -2523,8 +2535,6 @@ & \requires\ \tcode{value_type} shall be \tcode{EmplaceConstructible} into \tcode{X} from \tcode{*i}.\br \requires \tcode{i} and \tcode{j} are not iterators in \tcode{a}.\br \effects Equivalent to \tcode{a.insert(t)} for each element in \tcode{[i,j)}.% - \indextext{unordered associative containers!\idxcode{insert}}% - \indextext{\idxcode{insert}!unordered associative containers}% & Average case \bigoh{N}, where $N$ is \tcode{distance(i, j)}. Worst case \bigoh{N(\tcode{a.size()}\brk{}+\brk{}1)}. \\ \rowsep @@ -2615,12 +2625,11 @@ \bigoh{\tcode{a.size()}}. \\ \rowsep % +\indexunordmem{erase}% \tcode{a.erase(q)} & \tcode{iterator} & Erases the element pointed to by \tcode{q}. Returns the iterator immediately following \tcode{q} prior to the erasure. - \indextext{unordered associative containers!\idxcode{erase}}% - \indextext{\idxcode{erase}!unordered associative containers}% & Average case \bigoh{1}, worst case \bigoh{\tcode{a.size()}}. \\ \rowsep % @@ -2628,8 +2637,6 @@ & \tcode{iterator} & Erases the element pointed to by \tcode{r}. Returns the iterator immediately following \tcode{r} prior to the erasure. - \indextext{unordered associative containers!\idxcode{erase}}% - \indextext{\idxcode{erase}!unordered associative containers}% & Average case \bigoh{1}, worst case \bigoh{\tcode{a.size()}}. \\ \rowsep % @@ -2638,67 +2645,60 @@ & Erases all elements in the range \tcode{[q1, q2)}. Returns the iterator immediately following the erased elements prior to the erasure.% - \indextext{unordered associative containers!\idxcode{erase}}% - \indextext{\idxcode{erase}!unordered associative containers}% & Average case linear in \tcode{distance(q1, q2)}, worst case \bigoh{\tcode{a.size()}}. \\ \rowsep % +\indexunordmem{clear}% \tcode{a.clear()} & \tcode{void} & Erases all elements in the container. \postconditions \tcode{a.empty()} returns \tcode{true}% - \indextext{unordered associative containers!\idxcode{clear}}% - \indextext{\idxcode{clear}!unordered associative containers}% & Linear in \tcode{a.size()}. \\ \rowsep % +\indexunordmem{find}% \tcode{b.find(k)} & \tcode{iterator}; \br \tcode{const_iterator} for const \tcode{b}. & Returns an iterator pointing to an element with key equivalent to \tcode{k}, or \tcode{b.end()} if no such element exists.% - \indextext{unordered associative containers!\idxcode{find}}% - \indextext{\idxcode{find}!unordered associative containers}% & Average case \bigoh{1}, worst case \bigoh{\tcode{b.size()}}. \\ \rowsep % +\indexunordmem{count}% \tcode{b.count(k)} & \tcode{size_type} & Returns the number of elements with key equivalent to \tcode{k}.% - \indextext{unordered associative containers!\idxcode{count}}% - \indextext{\idxcode{count}!unordered associative containers}% & Average case \bigoh{\tcode{b.count(k)}}, worst case \bigoh{\tcode{b.size()}}. \\ \rowsep % +\indexunordmem{equal_range}% \tcode{b.equal_range(k)} & \tcode{pair}; \br \tcode{pair} for const \tcode{b}. & Returns a range containing all elements with keys equivalent to \tcode{k}. Returns \tcode{make_pair(b.end(), b.end())} if no such elements exist.% - \indextext{unordered associative containers!\idxcode{equal_range}}% - \indextext{\idxcode{equal_range}!unordered associative containers}% & Average case \bigoh{\tcode{b.count(k)}}. Worst case \bigoh{\tcode{b.size()}}. \\ \rowsep % +\indexunordmem{bucket_count}% \tcode{b.bucket_count()} & \tcode{size_type} & Returns the number of buckets that \tcode{b} contains.% - \indextext{unordered associative containers!\idxcode{bucket_count}}% - \indextext{\idxcode{bucket_count}!unordered associative containers}% & Constant \\ \rowsep % +\indexunordmem{max_bucket_count}% \tcode{b.max_bucket_count()} & \tcode{size_type} & Returns an upper bound on the number of buckets that \tcode{b} might ever contain.% - \indextext{unordered associative containers!\idxcode{max_bucket_count}}% - \indextext{\idxcode{max_bucket_count}!unordered associative containers}% & Constant \\ \rowsep % +\indexunordmem{bucket}% \tcode{b.bucket(k)} & \tcode{size_type} & @@ -2706,20 +2706,18 @@ Returns the index of the bucket in which elements with keys equivalent to \tcode{k} would be found, if any such element existed. \postconditions the return value shall be in the range \tcode{[0, b.bucket_count())}.% - \indextext{unordered associative containers!\idxcode{bucket}}% - \indextext{\idxcode{bucket}!unordered associative containers}% & Constant \\ \rowsep % +\indexunordmem{bucket_size}% \tcode{b.bucket_size(n)} & \tcode{size_type} & \requires \tcode{n} shall be in the range \tcode{[0, b.bucket_count())}. Returns the number of elements in the $\texttt{n}^{\textrm{ th}}$ bucket.% - \indextext{unordered associative containers!\idxcode{bucket_size}}% - \indextext{\idxcode{bucket_size}!unordered associative containers}% & \bigoh{\tcode{b.bucket_}\-\tcode{size(n)}} \\ \rowsep % +\indexunordmem{begin}% \tcode{b.begin(n)} & \tcode{local_iterator}; \br \tcode{const_local_iterator} for const \tcode{b}. @@ -2727,59 +2725,52 @@ \tcode{b.begin(n)} returns an iterator referring to the first element in the bucket. If the bucket is empty, then \tcode{b.begin(n) == b.end(n)}.% - \indextext{unordered associative containers!\idxcode{begin}}% - \indextext{\idxcode{begin}!unordered associative containers}% & Constant \\ \rowsep % +\indexunordmem{end}% \tcode{b.end(n)} & \tcode{local_iterator}; \br \tcode{const_local_iterator} for const \tcode{b}. & \requires \tcode{n} shall be in the range \tcode{[0, b.bucket_count())}. \tcode{b.end(n)} returns an iterator which is the past-the-end value for the bucket.% - \indextext{unordered associative containers!\idxcode{end}}% - \indextext{\idxcode{end}!unordered associative containers}% & Constant \\ \rowsep % +\indexunordmem{cbegin}% \tcode{b.cbegin(n)} & \tcode{const_local_iterator} & \requires \tcode{n} shall be in the range \tcode{[0, b.bucket_count())}. \tcode{b.cbegin(n)} returns an iterator referring to the first element in the bucket. If the bucket is empty, then \tcode{b.cbegin(n) == b.cend(n)}.% - \indextext{unordered associative containers!\idxcode{cbegin}}% - \indextext{\idxcode{cbegin}!unordered associative containers}% & Constant \\ \rowsep % +\indexunordmem{cend}% \tcode{b.cend(n)} & \tcode{const_local_iterator} & \requires \tcode{n} shall be in the range \tcode{[0, b.bucket_count())}.% \tcode{b.cend(n)} returns an iterator which is the past-the-end value for the bucket.% - \indextext{unordered associative containers!\idxcode{cend}}% - \indextext{\idxcode{cend}!unordered associative containers}% & Constant \\ \rowsep % +\indexunordmem{load_factor}% \tcode{b.load_factor()} & \tcode{float} & Returns the average number of elements per bucket.% - \indextext{unordered associative containers!\idxcode{load_factor}}% - \indextext{\idxcode{load_factor}!unordered associative containers}% & Constant \\ \rowsep % +\indexunordmem{max_load_factor}% \tcode{b.max_load_factor()} & \tcode{float} & Returns a positive number that the container attempts to keep the load factor less than or equal to. The container automatically increases the number of buckets as necessary to keep the load factor below this number.% - \indextext{unordered associative containers!\idxcode{max_load_factor}}% - \indextext{\idxcode{max_load_factor}!unordered associative containers}% & Constant \\ \rowsep % @@ -2790,15 +2781,15 @@ & Constant \\ \rowsep % +\indexunordmem{rehash}% \tcode{a.rehash(n)} & \tcode{void} & \postconditions \tcode{a.bucket_count() >= a.size() / a.max_load_factor()} and \tcode{a.bucket_count() >= n}.% - \indextext{unordered associative containers!\idxcode{rehash}}% - \indextext{\idxcode{rehash}!unordered associative containers}% & Average case linear in \tcode{a.size()}, worst case quadratic. \\ \rowsep +\indexunordmem{reserve}% \tcode{a.reserve(n)} & \tcode{void} & Same as \tcode{a.rehash(ceil(n /} \tcode{a.max_load_factor()))}. & @@ -2829,7 +2820,7 @@ proportional to $N$ (but worst-case complexity remains \bigoh{N^2}, e.g., for a pathologically bad hash function). The behavior of a program that uses \tcode{operator==} or \tcode{operator!=} on unordered containers is undefined -unless the \tcode{Hash} and \tcode{Pred} function objects respectively have +unless the \tcode{Pred} function object has the same behavior for both containers and the equality comparison function for \tcode{Key} is a refinement\footnote{Equality comparison is a refinement of partitioning if no two objects that @@ -2924,6 +2915,14 @@ \tcode{}, and \tcode{} define class templates that meet the requirements for sequence containers. +\pnum +The following exposition-only alias template may appear in deduction guides for sequence containers: + +\begin{codeblock} +template + using @\placeholdernc{iter-value-type}@ = typename iterator_traits::value_type; // \expos +\end{codeblock} + \rSec2[array.syn]{Header \tcode{} synopsis} \indexhdr{array}% @@ -3116,7 +3115,7 @@ \rSec2[array]{Class template \tcode{array}} \indexlibrary{\idxcode{array}}% -\rSec3[array.overview]{Class template \tcode{array} overview} +\rSec3[array.overview]{Overview} \pnum \indextext{\idxcode{array}!contiguous storage}% @@ -3145,6 +3144,10 @@ one of these tables and for operations where there is additional semantic information. +\pnum +The types \tcode{iterator} and \tcode{const_iterator} satisfy +the constexpr iterator requirements\iref{iterator.requirements.general}. + \indexlibrary{\idxcode{array}}% \indexlibrarymember{array}{begin}% \indexlibrarymember{array}{end}% @@ -3212,7 +3215,7 @@ } \end{codeblock} -\rSec3[array.cons]{\tcode{array} constructors, copy, and assignment} +\rSec3[array.cons]{Constructors, copy, and assignment} \pnum \indextext{\idxcode{array}!initialization}% @@ -3235,7 +3238,7 @@ \requires \tcode{(is_same_v \&\& ...)} is \tcode{true}. Otherwise the program is ill-formed. \end{itemdescr} -\rSec3[array.members]{\tcode{array} member functions} +\rSec3[array.members]{Member functions} \indexlibrarymember{array}{size}% \begin{itemdecl} @@ -3285,7 +3288,7 @@ \end{note} \end{itemdescr} -\rSec3[array.special]{\tcode{array} specialized algorithms} +\rSec3[array.special]{Specialized algorithms} \indexlibrarymember{array}{swap}% \begin{itemdecl} @@ -3305,7 +3308,7 @@ \complexity Linear in \tcode{N}. \end{itemdescr} -\rSec3[array.zero]{Zero sized arrays} +\rSec3[array.zero]{Zero-sized arrays} \indextext{\idxcode{array}!zero sized}% \pnum\tcode{array} shall provide support for the special case \tcode{N == 0}. @@ -3321,7 +3324,7 @@ Member function \tcode{swap()} shall have a non-throwing exception specification. -\rSec3[array.tuple]{Tuple interface to class template \tcode{array}} +\rSec3[array.tuple]{Tuple interface} \indexlibrary{\idxcode{array}}% \indexlibrary{\idxcode{tuple}}% \indextext{\idxcode{array}!tuple interface to}% @@ -3361,13 +3364,13 @@ \requires \tcode{I < N}. The program is ill-formed if \tcode{I} is out of bounds. \pnum -\returns A reference to the \tcode{I}th element of \tcode{a}, +\returns A reference to the $\tcode{I}^\text{th}$ element of \tcode{a}, where indexing is zero-based. \end{itemdescr} \rSec2[deque]{Class template \tcode{deque}} -\rSec3[deque.overview]{Class template \tcode{deque} overview} +\rSec3[deque.overview]{Overview} \pnum A @@ -3384,7 +3387,7 @@ \tcode{deque} satisfies all of the requirements of a container, of a reversible container (given in tables in~\ref{container.requirements}), of a sequence container, -including the optional sequence container requirements\iref{sequence.reqmts}, and of an allocator-aware container (Table~\ref{tab:containers.allocatoraware}). +including the optional sequence container requirements\iref{sequence.reqmts}, and of an allocator-aware container (\tref{containers.allocatoraware}). Descriptions are provided here only for operations on \tcode{deque} that are not described in one of these tables @@ -3493,19 +3496,18 @@ void clear() noexcept; }; - template::value_type>> + template>> deque(InputIterator, InputIterator, Allocator = Allocator()) - -> deque::value_type, Allocator>; + -> deque<@\placeholder{iter-value-type}@, Allocator>; - // \ref{deque.special}, specialized algorithms + // swap template void swap(deque& x, deque& y) noexcept(noexcept(x.swap(y))); } \end{codeblock} -\rSec3[deque.cons]{\tcode{deque} constructors, copy, and assignment} +\rSec3[deque.cons]{Constructors, copy, and assignment} \indexlibrary{\idxcode{deque}!constructor}% \begin{itemdecl} @@ -3581,7 +3583,7 @@ \complexity Linear in \tcode{distance(first, last)}. \end{itemdescr} -\rSec3[deque.capacity]{\tcode{deque} capacity} +\rSec3[deque.capacity]{Capacity} \indexlibrary{\idxcode{resize}!\idxcode{deque}}% \begin{itemdecl} @@ -3639,7 +3641,7 @@ referring to the elements in the sequence as well as the past-the-end iterator. \end{itemdescr} -\rSec3[deque.modifiers]{\tcode{deque} modifiers} +\rSec3[deque.modifiers]{Modifiers} \indexlibrary{\idxcode{insert}!\idxcode{deque}}% \indexlibrary{\idxcode{push_front}!\idxcode{deque}}% @@ -3725,24 +3727,9 @@ \tcode{T}. \end{itemdescr} -\rSec3[deque.special]{\tcode{deque} specialized algorithms} - -\indexlibrarymember{swap}{deque}% -\begin{itemdecl} -template - void swap(deque& x, deque& y) - noexcept(noexcept(x.swap(y))); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects -As if by \tcode{x.swap(y)}. -\end{itemdescr} - \rSec2[forwardlist]{Class template \tcode{forward_list}} -\rSec3[forwardlist.overview]{Class template \tcode{forward_list} overview} +\rSec3[forwardlist.overview]{Overview} \pnum A \tcode{forward_list} is a container that supports forward iterators and allows @@ -3754,13 +3741,13 @@ \pnum A \tcode{forward_list} satisfies all of the requirements of a container -(Table~\ref{tab:containers.container.requirements}), except that the \tcode{size()} +(\tref{containers.container.requirements}), except that the \tcode{size()} member function is not provided and \tcode{operator==} has linear complexity. A \tcode{forward_list} also satisfies all of the requirements for an allocator-aware -container (Table~\ref{tab:containers.allocatoraware}). In addition, a \tcode{forward_list} +container (\tref{containers.allocatoraware}). In addition, a \tcode{forward_list} provides the \tcode{assign} member functions -(Table~\ref{tab:containers.sequence.requirements}) and several of the optional -container requirements (Table~\ref{tab:containers.sequence.optional}). +(\tref{containers.sequence.requirements}) and several of the optional +container requirements (\tref{containers.sequence.optional}). Descriptions are provided here only for operations on \tcode{forward_list} that are not described in that table or for operations where there is additional semantic information. @@ -3882,12 +3869,11 @@ void reverse() noexcept; }; - template::value_type>> + template>> forward_list(InputIterator, InputIterator, Allocator = Allocator()) - -> forward_list::value_type, Allocator>; + -> forward_list<@\placeholder{iter-value-type}@, Allocator>; - // \ref{forwardlist.spec}, specialized algorithms + // swap template void swap(forward_list& x, forward_list& y) noexcept(noexcept(x.swap(y))); @@ -3901,7 +3887,7 @@ \tcode{T} shall be complete before any member of the resulting specialization of \tcode{forward_list} is referenced. -\rSec3[forwardlist.cons]{\tcode{forward_list} constructors, copy, assignment} +\rSec3[forwardlist.cons]{Constructors, copy, and assignment} \indexlibrary{\idxcode{forward_list}!constructor}% \begin{itemdecl} @@ -3963,7 +3949,7 @@ \complexity Linear in \tcode{distance(first, last)}. \end{itemdescr} -\rSec3[forwardlist.iter]{\tcode{forward_list} iterators} +\rSec3[forwardlist.iter]{Iterators} \indexlibrarymember{before_begin}{forward_list}% \indexlibrarymember{cbefore_begin}{forward_list}% @@ -3986,7 +3972,7 @@ \remarks \tcode{before_begin() == end()} shall equal \tcode{false}. \end{itemdescr} -\rSec3[forwardlist.access]{\tcode{forward_list} element access} +\rSec3[forwardlist.access]{Element access} \indexlibrarymember{front}{forward_list}% \begin{itemdecl} @@ -3999,7 +3985,7 @@ \returns \tcode{*begin()} \end{itemdescr} -\rSec3[forwardlist.modifiers]{\tcode{forward_list} modifiers} +\rSec3[forwardlist.modifiers]{Modifiers} \pnum None of the overloads of \tcode{insert_after} shall affect the validity of iterators and @@ -4216,13 +4202,13 @@ \remarks Does not invalidate past-the-end iterators. \end{itemdescr} -\rSec3[forwardlist.ops]{\tcode{forward_list} operations} +\rSec3[forwardlist.ops]{Operations} \pnum In this subclause, arguments for a template parameter named \tcode{Predicate} or \tcode{BinaryPredicate} -shall meet the corresponding requirements in \ref{algorithms.requirements}. +shall satisfy the corresponding requirements in \ref{algorithms.requirements}. For \tcode{merge} and \tcode{sort}, the definitions and requirements in \ref{alg.sorting} apply. @@ -4237,7 +4223,7 @@ \requires \tcode{position} is \tcode{before_begin()} or is a dereferenceable iterator in the range \range{begin()}{end()}. \tcode{get_allocator() == x.get_allocator()}. -\tcode{\&x != this}. +\tcode{addressof(x) != this}. \pnum \effects Inserts the contents of \tcode{x} after @@ -4421,23 +4407,9 @@ \complexity Linear time. \end{itemdescr} -\rSec3[forwardlist.spec]{\tcode{forward_list} specialized algorithms} - -\indexlibrarymember{swap}{forward_list}% -\begin{itemdecl} -template - void swap(forward_list& x, forward_list& y) - noexcept(noexcept(x.swap(y))); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects As if by \tcode{x.swap(y)}. -\end{itemdescr} - \rSec2[list]{Class template \tcode{list}} -\rSec3[list.overview]{Class template \tcode{list} overview} +\rSec3[list.overview]{Overview} \pnum \indexlibrary{\idxcode{list}}% @@ -4456,7 +4428,7 @@ \ref{container.requirements}), of a sequence container, including most of the optional sequence container requirements\iref{sequence.reqmts}, and of an allocator-aware container -(Table~\ref{tab:containers.allocatoraware}). +(\tref{containers.allocatoraware}). The exceptions are the \tcode{operator[]} and @@ -4589,12 +4561,11 @@ void reverse() noexcept; }; - template::value_type>> + template>> list(InputIterator, InputIterator, Allocator = Allocator()) - -> list::value_type, Allocator>; + -> list<@\placeholder{iter-value-type}@, Allocator>; - // \ref{list.special}, specialized algorithms + // swap template void swap(list& x, list& y) noexcept(noexcept(x.swap(y))); @@ -4608,7 +4579,7 @@ \tcode{T} shall be complete before any member of the resulting specialization of \tcode{list} is referenced. -\rSec3[list.cons]{\tcode{list} constructors, copy, and assignment} +\rSec3[list.cons]{Constructors, copy, and assignment} \indexlibrary{\idxcode{list}!constructor}% \begin{itemdecl} @@ -4689,7 +4660,7 @@ \tcode{distance(first, last)}. \end{itemdescr} -\rSec3[list.capacity]{\tcode{list} capacity} +\rSec3[list.capacity]{Capacity} \indexlibrary{\idxcode{resize}!\idxcode{list}}% \begin{itemdecl} @@ -4741,7 +4712,7 @@ \requires \tcode{T} shall be \tcode{CopyInsertable} into \tcode{*this}. \end{itemdescr} -\rSec3[list.modifiers]{\tcode{list} modifiers} +\rSec3[list.modifiers]{Modifiers} \indexlibrary{\idxcode{insert}!\idxcode{list}}% \begin{itemdecl} @@ -4806,7 +4777,7 @@ is exactly equal to the size of the range. \end{itemdescr} -\rSec3[list.ops]{\tcode{list} operations} +\rSec3[list.ops]{Operations} \pnum Since lists allow fast insertion and erasing from the middle of a list, certain @@ -4816,7 +4787,7 @@ In this subclause, arguments for a template parameter named \tcode{Predicate} or \tcode{BinaryPredicate} -shall meet the corresponding requirements in \ref{algorithms.requirements}. +shall satisfy the corresponding requirements in \ref{algorithms.requirements}. For \tcode{merge} and \tcode{sort}, the definitions and requirements in \ref{alg.sorting} apply. @@ -4834,7 +4805,7 @@ \begin{itemdescr} \pnum \requires -\tcode{\&x != this}. +\tcode{addressof(x) != this}. \pnum \effects @@ -5038,7 +5009,7 @@ \pnum \effects -If \tcode{(\&x == this)} does nothing; otherwise, merges the two sorted ranges \tcode{[begin(), +If \tcode{addressof(x) == this}, does nothing; otherwise, merges the two sorted ranges \tcode{[begin(), end())} and \tcode{[x.\brk{}begin(), x.end())}. The result is a range in which the elements will be sorted in non-decreasing order according to the ordering defined by \tcode{comp}; that is, for every iterator \tcode{i}, in the range other than the first, the condition @@ -5049,7 +5020,7 @@ \tcode{x}. \pnum -\remarks Stable\iref{algorithm.stable}. If \tcode{(\&x != this)} the range \tcode{[x.begin(), x.end())} +\remarks Stable\iref{algorithm.stable}. If \tcode{addressof(x) != this}, the range \tcode{[x.begin(), x.end())} is empty after the merge. No elements are copied by this operation. The behavior is undefined if \tcode{get_allocator() != x.get_allocator()}. @@ -5059,7 +5030,7 @@ At most \tcode{size() + x.size() - 1} applications of \tcode{comp} if -\tcode{(\&x != this)}; +\tcode{addressof(x) != this}; otherwise, no applications of \tcode{comp} are performed. If an exception is thrown other than by a comparison there are no effects. \end{itemdescr} @@ -5105,24 +5076,9 @@ \tcode{N == size()}. \end{itemdescr} -\rSec3[list.special]{\tcode{list} specialized algorithms} - -\indexlibrarymember{swap}{list}% -\begin{itemdecl} -template - void swap(list& x, list& y) - noexcept(noexcept(x.swap(y))); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects -As if by \tcode{x.swap(y)}. -\end{itemdescr} - \rSec2[vector]{Class template \tcode{vector}} -\rSec3[vector.overview]{Class template \tcode{vector} overview} +\rSec3[vector.overview]{Overview} \pnum \indexlibrary{\idxcode{vector}}% @@ -5139,7 +5095,7 @@ reversible container (given in two tables in~\ref{container.requirements}), of a sequence container, including most of the optional sequence container requirements\iref{sequence.reqmts}, of an allocator-aware container -(Table~\ref{tab:containers.allocatoraware}), +(\tref{containers.allocatoraware}), and, for an element type other than \tcode{bool}, of a contiguous container\iref{container.requirements.general}. The exceptions are the @@ -5251,12 +5207,11 @@ void clear() noexcept; }; - template::value_type>> + template>> vector(InputIterator, InputIterator, Allocator = Allocator()) - -> vector::value_type, Allocator>; + -> vector<@\placeholder{iter-value-type}@, Allocator>; - // \ref{vector.special}, specialized algorithms + // swap template void swap(vector& x, vector& y) noexcept(noexcept(x.swap(y))); @@ -5272,7 +5227,7 @@ \tcode{T} shall be complete before any member of the resulting specialization of \tcode{vector} is referenced. -\rSec3[vector.cons]{\tcode{vector} constructors, copy, and assignment} +\rSec3[vector.cons]{Constructors, copy, and assignment} \indexlibrary{\idxcode{vector}!constructor} \begin{itemdecl} @@ -5357,7 +5312,7 @@ reallocations if they are just input iterators. \end{itemdescr} -\rSec3[vector.capacity]{\tcode{vector} capacity} +\rSec3[vector.capacity]{Capacity} \indexlibrary{\idxcode{capacity}!\idxcode{vector}}% \begin{itemdecl} @@ -5369,6 +5324,9 @@ \returns The total number of elements that the vector can hold without requiring reallocation. + +\pnum +\complexity Constant time. \end{itemdescr} \indexlibrary{\idxcode{reserve}!\idxcode{vector}}% @@ -5510,7 +5468,7 @@ \remarks If an exception is thrown there are no effects. \end{itemdescr} -\rSec3[vector.data]{\tcode{vector} data} +\rSec3[vector.data]{Data} \indexlibrary{\idxcode{data}!\idxcode{vector}}% \begin{itemdecl} @@ -5529,7 +5487,7 @@ Constant time. \end{itemdescr} -\rSec3[vector.modifiers]{\tcode{vector} modifiers} +\rSec3[vector.modifiers]{Modifiers} \indexlibrary{\idxcode{insert}!\idxcode{vector}}% \begin{itemdecl} @@ -5596,21 +5554,6 @@ \tcode{T}. \end{itemdescr} -\rSec3[vector.special]{\tcode{vector} specialized algorithms} - -\indexlibrarymember{swap}{vector}% -\begin{itemdecl} -template - void swap(vector& x, vector& y) - noexcept(noexcept(x.swap(y))); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects -As if by \tcode{x.swap(y)}. -\end{itemdescr} - \rSec2[vector.bool]{Class \tcode{vector}} \pnum @@ -5794,18 +5737,20 @@ \pnum The following exposition-only alias templates may appear in deduction guides for associative containers: - \begin{codeblock} template - using iter_key_t = remove_const_t< - typename iterator_traits::value_type::first_type>; // \expos + using @\placeholder{iter-value-type}@ = + typename iterator_traits::value_type; // \expos +template + using @\placeholder{iter-key-type}@ = remove_const_t< + typename iterator_traits::value_type::first_type>; // \expos template - using iter_val_t - = typename iterator_traits::value_type::second_type; // \expos + using @\placeholder{iter-mapped-type}@ = + typename iterator_traits::value_type::second_type; // \expos template - using iter_to_alloc_t - = pair::value_type::first_type>, - typename iterator_traits::value_type::second_type>; // \expos + using @\placeholder{iter-to-alloc-type}@ = pair< + add_const_t::value_type::first_type>, + typename iterator_traits::value_type::second_type>; // \expos \end{codeblock} \rSec2[associative.map.syn]{Header \tcode{} synopsis} @@ -5961,7 +5906,7 @@ \rSec2[map]{Class template \tcode{map}} -\rSec3[map.overview]{Class template \tcode{map} overview} +\rSec3[map.overview]{Overview} \indexlibrary{\idxcode{map}}% \pnum @@ -5974,7 +5919,7 @@ A \tcode{map} satisfies all of the requirements of a container, of a reversible container\iref{container.requirements}, of -an associative container\iref{associative.reqmts}, and of an allocator-aware container (Table~\ref{tab:containers.allocatoraware}). +an associative container\iref{associative.reqmts}, and of an allocator-aware container (\tref{containers.allocatoraware}). A \tcode{map} also provides most operations described in~\ref{associative.reqmts} @@ -6177,10 +6122,10 @@ pair equal_range(const K& x) const; }; - template>, - class Allocator = allocator>> + template>, + class Allocator = allocator<@\placeholder{iter-to-alloc-type}@>> map(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator()) - -> map, iter_val_t, Compare, Allocator>; + -> map<@\placeholder{iter-key-type}@, @\placeholder{iter-mapped-type}@, Compare, Allocator>; template, class Allocator = allocator>> @@ -6189,13 +6134,13 @@ template map(InputIterator, InputIterator, Allocator) - -> map, iter_val_t, - less>, Allocator>; + -> map<@\placeholder{iter-key-type}@, @\placeholder{iter-mapped-type}@, + less<@\placeholder{iter-key-type}@>, Allocator>; template map(initializer_list>, Allocator) -> map, Allocator>; - // \ref{map.special}, specialized algorithms + // swap template void swap(map& x, map& y) @@ -6204,7 +6149,7 @@ \end{codeblock} -\rSec3[map.cons]{\tcode{map} constructors, copy, and assignment}% +\rSec3[map.cons]{Constructors, copy, and assignment}% \indexlibrary{\idxcode{map}!\idxcode{operator==}}% \indexlibrary{\idxcode{map}!\idxcode{operator<}} @@ -6250,7 +6195,7 @@ is \tcode{last - first}. \end{itemdescr} -\rSec3[map.access]{\tcode{map} element access} +\rSec3[map.access]{Element access} \indexlibrary{\idxcode{operator[]}!\idxcode{map}}% \begin{itemdecl} @@ -6294,7 +6239,7 @@ \complexity Logarithmic. \end{itemdescr} -\rSec3[map.modifiers]{\tcode{map} modifiers} +\rSec3[map.modifiers]{Modifiers} \indexlibrarymember{insert}{map}% \begin{itemdecl} @@ -6468,25 +6413,9 @@ respectively. \end{itemdescr} -\rSec3[map.special]{\tcode{map} specialized algorithms} - -\indexlibrarymember{swap}{map}% -\begin{itemdecl} -template - void swap(map& x, - map& y) - noexcept(noexcept(x.swap(y))); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects -As if by \tcode{x.swap(y)}. -\end{itemdescr} - \rSec2[multimap]{Class template \tcode{multimap}} -\rSec3[multimap.overview]{Class template \tcode{multimap} overview} +\rSec3[multimap.overview]{Overview} \pnum \indexlibrary{\idxcode{multimap}}% @@ -6506,7 +6435,7 @@ \tcode{multimap} satisfies all of the requirements of a container and of a reversible container\iref{container.requirements}, of an associative container\iref{associative.reqmts}, and of an allocator-aware container -(Table~\ref{tab:containers.allocatoraware}). +(\tref{containers.allocatoraware}). A \tcode{multimap} also provides most operations described in~\ref{associative.reqmts} @@ -6685,10 +6614,11 @@ pair equal_range(const K& x) const; }; - template>, - class Allocator = allocator>> + template>, + class Allocator = allocator<@\placeholder{iter-to-alloc-type}@>> multimap(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator()) - -> multimap, iter_val_t, Compare, Allocator>; + -> multimap<@\placeholder{iter-key-type}@, @\placeholder{iter-mapped-type}@, + Compare, Allocator>; template, class Allocator = allocator>> @@ -6697,14 +6627,14 @@ template multimap(InputIterator, InputIterator, Allocator) - -> multimap, iter_val_t, - less>, Allocator>; + -> multimap<@\placeholder{iter-key-type}@, @\placeholder{iter-mapped-type}@, + less<@\placeholder{iter-key-type}@>, Allocator>; template multimap(initializer_list>, Allocator) -> multimap, Allocator>; - // \ref{multimap.special}, specialized algorithms + // swap template void swap(multimap& x, multimap& y) @@ -6714,7 +6644,7 @@ \indexlibrary{\idxcode{multimap}!\idxcode{operator==}}% \indexlibrary{\idxcode{multimap}!\idxcode{operator<}} -\rSec3[multimap.cons]{\tcode{multimap} constructors} +\rSec3[multimap.cons]{Constructors} \indexlibrary{\idxcode{multimap}!constructor}% \begin{itemdecl} @@ -6760,7 +6690,7 @@ \tcode{last - first}. \end{itemdescr} -\rSec3[multimap.modifiers]{\tcode{multimap} modifiers} +\rSec3[multimap.modifiers]{Modifiers} \indexlibrarymember{insert}{multimap}% \begin{itemdecl} @@ -6782,25 +6712,9 @@ \tcode{true}. \end{itemdescr} -\rSec3[multimap.special]{\tcode{multimap} specialized algorithms} - -\indexlibrarymember{swap}{multimap}% -\begin{itemdecl} -template - void swap(multimap& x, - multimap& y) - noexcept(noexcept(x.swap(y))); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects -As if by \tcode{x.swap(y)}. -\end{itemdescr} - \rSec2[set]{Class template \tcode{set}} -\rSec3[set.overview]{Class template \tcode{set} overview} +\rSec3[set.overview]{Overview} \pnum \indexlibrary{\idxcode{set}}% @@ -6816,7 +6730,7 @@ A \tcode{set} satisfies all of the requirements of a container, of a reversible container\iref{container.requirements}, of an associative container\iref{associative.reqmts}, and of an allocator-aware container -(Table~\ref{tab:containers.allocatoraware}). +(\tref{containers.allocatoraware}). A \tcode{set} also provides most operations described in~\ref{associative.reqmts} @@ -6980,11 +6894,11 @@ }; template::value_type>, - class Allocator = allocator::value_type>> + class Compare = less<@\placeholder{iter-value-type}@>, + class Allocator = allocator<@\placeholder{iter-value-type}@>> set(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator()) - -> set::value_type, Compare, Allocator>; + -> set<@\placeholder{iter-value-type}@, Compare, Allocator>; template, class Allocator = allocator> set(initializer_list, Compare = Compare(), Allocator = Allocator()) @@ -6992,13 +6906,13 @@ template set(InputIterator, InputIterator, Allocator) - -> set::value_type, - less::value_type>, Allocator>; + -> set<@\placeholder{iter-value-type}@, + less<@\placeholder{iter-value-type}@>, Allocator>; template set(initializer_list, Allocator) -> set, Allocator>; - // \ref{set.special}, specialized algorithms + // swap template void swap(set& x, set& y) @@ -7008,7 +6922,7 @@ \indexlibrary{\idxcode{set}!\idxcode{operator==}}% \indexlibrary{\idxcode{set}!\idxcode{operator<}} -\rSec3[set.cons]{\tcode{set} constructors, copy, and assignment} +\rSec3[set.cons]{Constructors, copy, and assignment} \indexlibrary{\idxcode{set}!constructor}% \begin{itemdecl} @@ -7051,25 +6965,9 @@ \tcode{last - first}. \end{itemdescr} -\rSec3[set.special]{\tcode{set} specialized algorithms} - -\indexlibrarymember{swap}{set}% -\begin{itemdecl} -template - void swap(set& x, - set& y) - noexcept(noexcept(x.swap(y))); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects -As if by \tcode{x.swap(y)}. -\end{itemdescr} - \rSec2[multiset]{Class template \tcode{multiset}} -\rSec3[multiset.overview]{Class template \tcode{multiset} overview} +\rSec3[multiset.overview]{Overview} \pnum \indexlibrary{\idxcode{multiset}}% @@ -7085,7 +6983,7 @@ A \tcode{multiset} satisfies all of the requirements of a container, of a reversible container\iref{container.requirements}, of an associative container\iref{associative.reqmts}, and of an allocator-aware container -(Table~\ref{tab:containers.allocatoraware}). +(\tref{containers.allocatoraware}). \tcode{multiset} also provides most operations described in~\ref{associative.reqmts} for duplicate keys. @@ -7247,11 +7145,11 @@ }; template::value_type>, - class Allocator = allocator::value_type>> + class Compare = less<@\placeholder{iter-value-type}@>, + class Allocator = allocator<@\placeholder{iter-value-type}@>> multiset(InputIterator, InputIterator, Compare = Compare(), Allocator = Allocator()) - -> multiset::value_type, Compare, Allocator>; + -> multiset<@\placeholder{iter-value-type}@, Compare, Allocator>; template, class Allocator = allocator> multiset(initializer_list, Compare = Compare(), Allocator = Allocator()) @@ -7259,13 +7157,13 @@ template multiset(InputIterator, InputIterator, Allocator) - -> multiset::value_type, - less::value_type>, Allocator>; + -> multiset<@\placeholder{iter-value-type}@, + less<@\placeholder{iter-value-type}@>, Allocator>; template multiset(initializer_list, Allocator) -> multiset, Allocator>; - // \ref{multiset.special}, specialized algorithms + // swap template void swap(multiset& x, multiset& y) @@ -7275,7 +7173,7 @@ \indexlibrary{\idxcode{multiset}!\idxcode{operator==}}% \indexlibrary{\idxcode{multiset}!\idxcode{operator<}} -\rSec3[multiset.cons]{\tcode{multiset} constructors} +\rSec3[multiset.cons]{Constructors} \indexlibrary{\idxcode{multiset}!constructor}% \begin{itemdecl} @@ -7318,22 +7216,6 @@ \tcode{last - first}. \end{itemdescr} -\rSec3[multiset.special]{\tcode{multiset} specialized algorithms} - -\indexlibrarymember{swap}{multiset}% -\begin{itemdecl} -template - void swap(multiset& x, - multiset& y) - noexcept(noexcept(x.swap(y))); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects -As if by \tcode{x.swap(y)}. -\end{itemdescr} - \rSec1[unord]{Unordered associative containers} \rSec2[unord.general]{In general} @@ -7345,7 +7227,8 @@ \tcode{unordered_set} and \tcode{unordered_multiset}. \pnum -The exposition-only alias templates \tcode{iter_key_t}, \tcode{iter_val_t}, and \tcode{iter_to_alloc_t} +The exposition-only alias templates \placeholder{iter-value-type}, +\placeholder{iter-key-type}, \placeholder{iter-mapped-type}, and \placeholder{iter-to-alloc-type} defined in \ref{associative.general} may appear in deduction guides for unordered containers. \rSec2[unord.map.syn]{Header \tcode{} synopsis}% @@ -7481,7 +7364,7 @@ \rSec2[unord.map]{Class template \tcode{unordered_map}}% \indexlibrary{\idxcode{unordered_map}} -\rSec3[unord.map.overview]{Class template \tcode{unordered_map} overview} +\rSec3[unord.map.overview]{Overview} \pnum \indextext{\idxcode{unordered_map}!unique keys}% @@ -7494,7 +7377,7 @@ supports forward iterators. \pnum -An \tcode{unordered_map} satisfies all of the requirements of a container, of an unordered associative container, and of an allocator-aware container (Table~\ref{tab:containers.allocatoraware}). It provides the operations described in the preceding requirements table for unique keys; that is, an \tcode{unordered_map} supports the \tcode{a_uniq} operations in that table, not the \tcode{a_eq} operations. For an \tcode{unordered_map} the \tcode{key type} is \tcode{Key}, the mapped type is \tcode{T}, and the value type is \tcode{pair}. +An \tcode{unordered_map} satisfies all of the requirements of a container, of an unordered associative container, and of an allocator-aware container (\tref{containers.allocatoraware}). It provides the operations described in the preceding requirements table for unique keys; that is, an \tcode{unordered_map} supports the \tcode{a_uniq} operations in that table, not the \tcode{a_eq} operations. For an \tcode{unordered_map} the \tcode{key type} is \tcode{Key}, the mapped type is \tcode{T}, and the value type is \tcode{pair}. \pnum This subclause only describes operations on \tcode{unordered_map} that @@ -7683,12 +7566,12 @@ }; template>, - class Pred = equal_to>, - class Allocator = allocator>> + class Hash = hash<@\placeholder{iter-key-type}@>, + class Pred = equal_to<@\placeholder{iter-key-type}@>, + class Allocator = allocator<@\placeholder{iter-to-alloc-type}@>> unordered_map(InputIterator, InputIterator, typename @\seebelow@::size_type = @\seebelow@, Hash = Hash(), Pred = Pred(), Allocator = Allocator()) - -> unordered_map, iter_val_t, Hash, Pred, + -> unordered_map<@\placeholder{iter-key-type}@, @\placeholder{iter-mapped-type}@, Hash, Pred, Allocator>; template, @@ -7700,20 +7583,20 @@ template unordered_map(InputIterator, InputIterator, typename @\seebelow@::size_type, Allocator) - -> unordered_map, iter_val_t, - hash>, equal_to>, - Allocator>; + -> unordered_map<@\placeholder{iter-key-type}@, @\placeholder{iter-mapped-type}@, + hash<@\placeholder{iter-key-type}@>, + equal_to<@\placeholder{iter-key-type}@>, Allocator>; template unordered_map(InputIterator, InputIterator, Allocator) - -> unordered_map, iter_val_t, - hash>, equal_to>, - Allocator>; + -> unordered_map<@\placeholder{iter-key-type}@, @\placeholder{iter-mapped-type}@, + hash<@\placeholder{iter-key-type}@>, + equal_to<@\placeholder{iter-key-type}@>, Allocator>; template unordered_map(InputIterator, InputIterator, typename @\seebelow@::size_type, Hash, Allocator) - -> unordered_map, iter_val_t, Hash, - equal_to>, Allocator>; + -> unordered_map<@\placeholder{iter-key-type}@, @\placeholder{iter-mapped-type}@, Hash, + equal_to<@\placeholder{iter-key-type}@>, Allocator>; template unordered_map(initializer_list>, typename @\seebelow@::size_type, @@ -7729,7 +7612,7 @@ Allocator) -> unordered_map, Allocator>; - // \ref{unord.map.swap}, swap + // swap template void swap(unordered_map& x, unordered_map& y) @@ -7741,7 +7624,7 @@ A \tcode{size_type} parameter type in an \tcode{unordered_map} deduction guide refers to the \tcode{size_type} member type of the type deduced by the deduction guide. -\rSec3[unord.map.cnstr]{\tcode{unordered_map} constructors} +\rSec3[unord.map.cnstr]{Constructors} \indexlibrary{\idxcode{unordered_map}!constructor}% \begin{itemdecl} @@ -7796,7 +7679,7 @@ \complexity Average case linear, worst case quadratic. \end{itemdescr} -\rSec3[unord.map.elem]{\tcode{unordered_map} element access} +\rSec3[unord.map.elem]{Element access} \indexlibrarymember{unordered_map}{operator[]}% \indextext{\idxcode{unordered_map}!element access}% @@ -7835,7 +7718,7 @@ \throws An exception object of type \tcode{out_of_range} if no such element is present. \end{itemdescr} -\rSec3[unord.map.modifiers]{\tcode{unordered_map} modifiers} +\rSec3[unord.map.modifiers]{Modifiers} \indexlibrarymember{unordered_map}{insert}% \begin{itemdecl} @@ -8018,24 +7901,10 @@ respectively. \end{itemdescr} -\rSec3[unord.map.swap]{\tcode{unordered_map} swap} - -\indexlibrarymember{unordered_map}{swap}% -\begin{itemdecl} -template - void swap(unordered_map& x, - unordered_map& y) - noexcept(noexcept(x.swap(y))); -\end{itemdecl} - -\begin{itemdescr} -\pnum\effects As if by \tcode{x.swap(y)}. -\end{itemdescr} - \rSec2[unord.multimap]{Class template \tcode{unordered_multimap}}% \indexlibrary{\idxcode{unordered_multimap}} -\rSec3[unord.multimap.overview]{Class template \tcode{unordered_multimap} overview} +\rSec3[unord.multimap.overview]{Overview} \pnum \indextext{\idxcode{unordered_multimap}!equivalent keys}% @@ -8050,7 +7919,7 @@ \pnum An \tcode{unordered_multimap} satisfies all of the requirements of a container, of an unordered associative container, and of an allocator-aware container -(Table~\ref{tab:containers.allocatoraware}). It provides the operations described in the +(\tref{containers.allocatoraware}). It provides the operations described in the preceding requirements table for equivalent keys; that is, an \tcode{unordered_multimap} supports the \tcode{a_eq} operations in that table, not the \tcode{a_uniq} operations. For an \tcode{unordered_multimap} the \tcode{key type} is \tcode{Key}, the @@ -8219,14 +8088,14 @@ }; template>, - class Pred = equal_to>, - class Allocator = allocator>> + class Hash = hash<@\placeholder{iter-key-type}@>, + class Pred = equal_to<@\placeholder{iter-key-type}@>, + class Allocator = allocator<@\placeholder{iter-to-alloc-type}@>> unordered_multimap(InputIterator, InputIterator, typename @\seebelow@::size_type = @\seebelow@, Hash = Hash(), Pred = Pred(), Allocator = Allocator()) - -> unordered_multimap, iter_val_t, Hash, Pred, - Allocator>; + -> unordered_multimap<@\placeholder{iter-key-type}@, @\placeholder{iter-mapped-type}@, + Hash, Pred, Allocator>; template, class Pred = equal_to, class Allocator = allocator>> @@ -8237,21 +8106,21 @@ template unordered_multimap(InputIterator, InputIterator, typename @\seebelow@::size_type, Allocator) - -> unordered_multimap, iter_val_t, - hash>, - equal_to>, Allocator>; + -> unordered_multimap<@\placeholder{iter-key-type}@, @\placeholder{iter-mapped-type}@, + hash<@\placeholder{iter-key-type}@>, + equal_to<@\placeholder{iter-key-type}@>, Allocator>; template unordered_multimap(InputIterator, InputIterator, Allocator) - -> unordered_multimap, iter_val_t, - hash>, - equal_to>, Allocator>; + -> unordered_multimap<@\placeholder{iter-key-type}@, @\placeholder{iter-mapped-type}@, + hash<@\placeholder{iter-key-type}@>, + equal_to<@\placeholder{iter-key-type}@>, Allocator>; template unordered_multimap(InputIterator, InputIterator, typename @\seebelow@::size_type, Hash, Allocator) - -> unordered_multimap, iter_val_t, Hash, - equal_to>, Allocator>; + -> unordered_multimap<@\placeholder{iter-key-type}@, @\placeholder{iter-mapped-type}@, Hash, + equal_to<@\placeholder{iter-key-type}@>, Allocator>; template unordered_multimap(initializer_list>, typename @\seebelow@::size_type, @@ -8267,7 +8136,7 @@ Hash, Allocator) -> unordered_multimap, Allocator>; - // \ref{unord.multimap.swap}, swap + // swap template void swap(unordered_multimap& x, unordered_multimap& y) @@ -8279,7 +8148,7 @@ A \tcode{size_type} parameter type in an \tcode{unordered_multimap} deduction guide refers to the \tcode{size_type} member type of the type deduced by the deduction guide. -\rSec3[unord.multimap.cnstr]{\tcode{unordered_multimap} constructors} +\rSec3[unord.multimap.cnstr]{Constructors} \indexlibrary{\idxcode{unordered_multimap}!constructor}% \begin{itemdecl} @@ -8334,7 +8203,7 @@ \complexity Average case linear, worst case quadratic. \end{itemdescr} -\rSec3[unord.multimap.modifiers]{\tcode{unordered_multimap} modifiers} +\rSec3[unord.multimap.modifiers]{Modifiers} \indexlibrarymember{unordered_multimap}{insert}% \begin{itemdecl} @@ -8367,25 +8236,10 @@ unless \tcode{is_constructible_v} is \tcode{true}. \end{itemdescr} -\rSec3[unord.multimap.swap]{\tcode{unordered_multimap} swap} - -\indexlibrarymember{unordered_multimap}{swap}% -\begin{itemdecl} -template - void swap(unordered_multimap& x, - unordered_multimap& y) - noexcept(noexcept(x.swap(y))); -\end{itemdecl} - - -\begin{itemdescr} -\pnum\effects As if by \tcode{x.swap(y)}. -\end{itemdescr} - \rSec2[unord.set]{Class template \tcode{unordered_set}}% \indexlibrary{\idxcode{unordered_set}} -\rSec3[unord.set.overview]{Class template \tcode{unordered_set} overview} +\rSec3[unord.set.overview]{Overview} \pnum \indextext{\idxcode{unordered_set}!unique keys}% @@ -8398,7 +8252,7 @@ supports forward iterators. \pnum -An \tcode{unordered_set} satisfies all of the requirements of a container, of an unordered associative container, and of an allocator-aware container (Table~\ref{tab:containers.allocatoraware}). It provides the operations described in the preceding requirements table for unique keys; that is, an \tcode{unordered_set} supports the \tcode{a_uniq} operations in that table, not the \tcode{a_eq} operations. For an \tcode{unordered_set} the \tcode{key type} and the value type are both \tcode{Key}. The \tcode{iterator} and \tcode{const_iterator} types are both constant iterator types. It is unspecified whether they are the same type. +An \tcode{unordered_set} satisfies all of the requirements of a container, of an unordered associative container, and of an allocator-aware container (\tref{containers.allocatoraware}). It provides the operations described in the preceding requirements table for unique keys; that is, an \tcode{unordered_set} supports the \tcode{a_uniq} operations in that table, not the \tcode{a_eq} operations. For an \tcode{unordered_set} the \tcode{key type} and the value type are both \tcode{Key}. The \tcode{iterator} and \tcode{const_iterator} types are both constant iterator types. It is unspecified whether they are the same type. \pnum This subclause only describes operations on \tcode{unordered_set} that @@ -8560,12 +8414,12 @@ }; template::value_type>, - class Pred = equal_to::value_type>, - class Allocator = allocator::value_type>> + class Hash = hash<@\placeholder{iter-value-type}@>, + class Pred = equal_to<@\placeholder{iter-value-type}@>, + class Allocator = allocator<@\placeholder{iter-value-type}@>> unordered_set(InputIterator, InputIterator, typename @\seebelow@::size_type = @\seebelow@, Hash = Hash(), Pred = Pred(), Allocator = Allocator()) - -> unordered_set::value_type, + -> unordered_set<@\placeholder{iter-value-type}@, Hash, Pred, Allocator>; template, @@ -8576,16 +8430,16 @@ template unordered_set(InputIterator, InputIterator, typename @\seebelow@::size_type, Allocator) - -> unordered_set::value_type, - hash::value_type>, - equal_to::value_type>, + -> unordered_set<@\placeholder{iter-value-type}@, + hash<@\placeholder{iter-value-type}@>, + equal_to<@\placeholder{iter-value-type}@>, Allocator>; template unordered_set(InputIterator, InputIterator, typename @\seebelow@::size_type, Hash, Allocator) - -> unordered_set::value_type, Hash, - equal_to::value_type>, + -> unordered_set<@\placeholder{iter-value-type}@, Hash, + equal_to<@\placeholder{iter-value-type}@>, Allocator>; template @@ -8596,7 +8450,7 @@ unordered_set(initializer_list, typename @\seebelow@::size_type, Hash, Allocator) -> unordered_set, Allocator>; - // \ref{unord.set.swap}, swap + // swap template void swap(unordered_set& x, unordered_set& y) @@ -8609,7 +8463,7 @@ refers to the \tcode{size_type} member type of the type deduced by the deduction guide. -\rSec3[unord.set.cnstr]{\tcode{unordered_set} constructors} +\rSec3[unord.set.cnstr]{Constructors} \indexlibrary{\idxcode{unordered_set}!constructor}% \begin{itemdecl} @@ -8664,24 +8518,10 @@ \complexity Average case linear, worst case quadratic. \end{itemdescr} -\rSec3[unord.set.swap]{\tcode{unordered_set} swap} - -\indexlibrarymember{unordered_set}{swap}% -\begin{itemdecl} -template - void swap(unordered_set& x, - unordered_set& y) - noexcept(noexcept(x.swap(y))); -\end{itemdecl} - -\begin{itemdescr} -\pnum\effects As if by \tcode{x.swap(y)}. -\end{itemdescr} - \rSec2[unord.multiset]{Class template \tcode{unordered_multiset}}% \indexlibrary{\idxcode{unordered_multiset}} -\rSec3[unord.multiset.overview]{Class template \tcode{unordered_multiset} overview} +\rSec3[unord.multiset.overview]{Overview} \pnum \indextext{\idxcode{unordered_multiset}!equivalent keys}% @@ -8696,7 +8536,7 @@ \pnum An \tcode{unordered_multiset} satisfies all of the requirements of a container, of an unordered associative container, and of an allocator-aware container -(Table~\ref{tab:containers.allocatoraware}). It provides the operations described in the +(\tref{containers.allocatoraware}). It provides the operations described in the preceding requirements table for equivalent keys; that is, an \tcode{unordered_multiset} supports the \tcode{a_eq} operations in that table, not the \tcode{a_uniq} operations. For an \tcode{unordered_multiset} the \tcode{key type} and the value type are @@ -8862,12 +8702,12 @@ }; template::value_type>, - class Pred = equal_to::value_type>, - class Allocator = allocator::value_type>> + class Hash = hash<@\placeholder{iter-value-type}@>, + class Pred = equal_to<@\placeholder{iter-value-type}@>, + class Allocator = allocator<@\placeholder{iter-value-type}@>> unordered_multiset(InputIterator, InputIterator, @\seebelow@::size_type = @\seebelow@, Hash = Hash(), Pred = Pred(), Allocator = Allocator()) - -> unordered_multiset::value_type, + -> unordered_multiset<@\placeholder{iter-value-type}@, Hash, Pred, Allocator>; template, @@ -8878,16 +8718,16 @@ template unordered_multiset(InputIterator, InputIterator, typename @\seebelow@::size_type, Allocator) - -> unordered_multiset::value_type, - hash::value_type>, - equal_to::value_type>, + -> unordered_multiset<@\placeholder{iter-value-type}@, + hash<@\placeholder{iter-value-type}@>, + equal_to<@\placeholder{iter-value-type}@>, Allocator>; template unordered_multiset(InputIterator, InputIterator, typename @\seebelow@::size_type, Hash, Allocator) - -> unordered_multiset::value_type, Hash, - equal_to::value_type>, + -> unordered_multiset<@\placeholder{iter-value-type}@, Hash, + equal_to<@\placeholder{iter-value-type}@>, Allocator>; template @@ -8898,7 +8738,7 @@ unordered_multiset(initializer_list, typename @\seebelow@::size_type, Hash, Allocator) -> unordered_multiset, Allocator>; - // \ref{unord.multiset.swap}, swap + // swap template void swap(unordered_multiset& x, unordered_multiset& y) @@ -8911,7 +8751,7 @@ refers to the \tcode{size_type} member type of the type deduced by the deduction guide. -\rSec3[unord.multiset.cnstr]{\tcode{unordered_multiset} constructors} +\rSec3[unord.multiset.cnstr]{Constructors} \indexlibrary{\idxcode{unordered_multiset}!constructor}% \begin{itemdecl} @@ -8965,20 +8805,6 @@ \pnum\complexity Average case linear, worst case quadratic. \end{itemdescr} -\rSec3[unord.multiset.swap]{\tcode{unordered_multiset} swap} - -\indexlibrarymember{unordered_multiset}{swap}% -\begin{itemdecl} -template - void swap(unordered_multiset& x, - unordered_multiset& y) - noexcept(noexcept(x.swap(y))); -\end{itemdecl} - -\begin{itemdescr} -\pnum\effects As if by \tcode{x.swap(y)}. -\end{itemdescr} - \rSec1[container.adaptors]{Container adaptors} \rSec2[container.adaptors.general]{In general} @@ -9073,7 +8899,7 @@ \rSec2[queue]{Class template \tcode{queue}} -\rSec3[queue.defn]{\tcode{queue} definition} +\rSec3[queue.defn]{Definition} \pnum \indexlibrary{\idxcode{queue}}% @@ -9145,7 +8971,7 @@ } \end{codeblock} -\rSec3[queue.cons]{\tcode{queue} constructors} +\rSec3[queue.cons]{Constructors} \begin{itemdecl} explicit queue(const Container& cont); @@ -9165,7 +8991,7 @@ \effects\ Initializes \tcode{c} with \tcode{std::move(cont)}. \end{itemdescr} -\rSec3[queue.cons.alloc]{\tcode{queue} constructors with allocators} +\rSec3[queue.cons.alloc]{Constructors with allocators} \pnum If \tcode{uses_allocator_v} is \tcode{false} @@ -9220,7 +9046,7 @@ as the second argument. \end{itemdescr} -\rSec3[queue.ops]{\tcode{queue} operators} +\rSec3[queue.ops]{Operators} \indexlibrary{\idxcode{operator==}!\idxcode{queue}}% \begin{itemdecl} @@ -9295,7 +9121,7 @@ \tcode{x.c >= y.c}. \end{itemdescr} -\rSec3[queue.special]{\tcode{queue} specialized algorithms} +\rSec3[queue.special]{Specialized algorithms} \indexlibrarymember{swap}{queue}% \begin{itemdecl} @@ -9315,6 +9141,8 @@ \rSec2[priority.queue]{Class template \tcode{priority_queue}} +\rSec3[priqueue.overview]{Overview} + \pnum \indexlibrary{\idxcode{priority_queue}}% Any sequence container with random access iterator and supporting operations @@ -9406,7 +9234,7 @@ } \end{codeblock} -\rSec3[priqueue.cons]{\tcode{priority_queue} constructors} +\rSec3[priqueue.cons]{Constructors} \indexlibrary{\idxcode{priority_queue}!constructor}% \begin{itemdecl} @@ -9457,7 +9285,7 @@ \tcode{make_heap(c.begin(), c.end(), comp)}. \end{itemdescr} -\rSec3[priqueue.cons.alloc]{\tcode{priority_queue} constructors with allocators} +\rSec3[priqueue.cons.alloc]{Constructors with allocators} \pnum If \tcode{uses_allocator_v} is \tcode{false} @@ -9531,7 +9359,7 @@ as the second argument, and initializes \tcode{comp} with \tcode{std::move(q.comp)}. \end{itemdescr} -\rSec3[priqueue.members]{\tcode{priority_queue} members} +\rSec3[priqueue.members]{Members} \indexlibrary{\idxcode{push}!\idxcode{priority_queue}}% \begin{itemdecl} @@ -9594,7 +9422,7 @@ \end{codeblock} \end{itemdescr} -\rSec3[priqueue.special]{\tcode{priority_queue} specialized algorithms} +\rSec3[priqueue.special]{Specialized algorithms} \indexlibrarymember{swap}{priority_queue}% \begin{itemdecl} @@ -9632,7 +9460,7 @@ \tcode{deque}\iref{deque} can be used. -\rSec3[stack.defn]{\tcode{stack} definition} +\rSec3[stack.defn]{Definition} \begin{codeblock} namespace std { @@ -9683,7 +9511,7 @@ } \end{codeblock} -\rSec3[stack.cons]{\tcode{stack} constructors} +\rSec3[stack.cons]{Constructors} \indexlibrary{\idxcode{stack}!constructor}% \begin{itemdecl} @@ -9705,7 +9533,7 @@ \effects Initializes \tcode{c} with \tcode{std::move(cont)}. \end{itemdescr} -\rSec3[stack.cons.alloc]{\tcode{stack} constructors with allocators} +\rSec3[stack.cons.alloc]{Constructors with allocators} \pnum If \tcode{uses_allocator_v} is \tcode{false} @@ -9765,7 +9593,7 @@ as the second argument. \end{itemdescr} -\rSec3[stack.ops]{\tcode{stack} operators} +\rSec3[stack.ops]{Operators} \indexlibrary{\idxcode{operator==}!\idxcode{stack}}% \begin{itemdecl} @@ -9839,7 +9667,7 @@ \tcode{x.c >= y.c}. \end{itemdescr} -\rSec3[stack.special]{\tcode{stack} specialized algorithms} +\rSec3[stack.special]{Specialized algorithms} \indexlibrarymember{swap}{stack}% \begin{itemdecl} @@ -9856,3 +9684,702 @@ \pnum \effects As if by \tcode{x.swap(y)}. \end{itemdescr} + +\rSec1[views]{Views} + +\rSec2[views.general]{General} + +\pnum +The header \tcode{} defines the view \tcode{span}. +A \tcode{span} is a view over a contiguous sequence of objects, +the storage of which is owned by some other object. + +\rSec2[span.syn]{Header \tcode{} synopsis}% +\indexhdr{span}% + +\begin{codeblock} +namespace std { + // constants + inline constexpr ptrdiff_t dynamic_extent = -1; + + // \ref{views.span}, class template span + template + class span; + + // \ref{span.comparison}, comparison operators + template + constexpr bool operator==(span l, span r); + template + constexpr bool operator!=(span l, span r); + template + constexpr bool operator<(span l, span r); + template + constexpr bool operator<=(span l, span r); + template + constexpr bool operator>(span l, span r); + template + constexpr bool operator>=(span l, span r); + + // \ref{span.objectrep}, views of object representation + template + span(sizeof(ElementType)) * Extent> + as_bytes(span s) noexcept; + + template + span(sizeof(ElementType)) * Extent> + as_writable_bytes(span s) noexcept; +} +\end{codeblock} + +\rSec2[views.span]{Class template \tcode{span}} + +\rSec3[span.overview]{Overview} + +\pnum +\indexlibrary{\idxcode{span}}% +A \tcode{span} is a view over a contiguous sequence of objects, +the storage of which is owned by some other object. + +\pnum +\tcode{ElementType} is required to be a complete object type that is not an abstract class type. + +\pnum +If \tcode{Extent} is negative and not equal to \tcode{dynamic_extent}, +the program is ill-formed. + +\pnum +The iterator type for span is a random access iterator and a contiguous iterator. + +\pnum +All member functions of \tcode{span} have constant time complexity. + +\indexlibrary{\idxcode{span}}% +\begin{codeblock} +nnamespace std { + template + class span { + public: + // constants and types + using element_type = ElementType; + using value_type = remove_cv_t; + using index_type = ptrdiff_t; + using difference_type = ptrdiff_t; + using pointer = element_type*; + using reference = element_type&; + using iterator = @\impdefx{type of \tcode{span::iterator}}@; + using const_iterator = @\impdefx{type of \tcode{span::const_iterator}}@; + using reverse_iterator = reverse_iterator; + using const_reverse_iterator = reverse_iterator; + static constexpr index_type extent = Extent; + + // \ref{span.cons}, constructors, copy, and assignment + constexpr span() noexcept; + constexpr span(pointer ptr, index_type count); + constexpr span(pointer first, pointer last); + template + constexpr span(element_type (&arr)[N]) noexcept; + template + constexpr span(array& arr) noexcept; + template + constexpr span(const array& arr) noexcept; + template + constexpr span(Container& cont); + template + constexpr span(const Container& cont); + constexpr span(const span& other) noexcept = default; + template + constexpr span(const span& s) noexcept; + + ~span() noexcept = default; + + constexpr span& operator=(const span& other) noexcept = default; + + // \ref{span.sub}, subviews + template + constexpr span first() const; + template + constexpr span last() const; + template + constexpr span subspan() const; + + constexpr span first(index_type count) const; + constexpr span last(index_type count) const; + constexpr span subspan( + index_type offset, index_type count = dynamic_extent) const; + + // \ref{span.obs}, observers + constexpr index_type size() const noexcept; + constexpr index_type size_bytes() const noexcept; + constexpr bool empty() const noexcept; + + // \ref{span.elem}, element access + constexpr reference operator[](index_type idx) const; + constexpr reference operator()(index_type idx) const; + constexpr pointer data() const noexcept; + + // \ref{span.iterators}, iterator support + constexpr iterator begin() const noexcept; + constexpr iterator end() const noexcept; + constexpr const_iterator cbegin() const noexcept; + constexpr const_iterator cend() const noexcept; + constexpr reverse_iterator rbegin() const noexcept; + constexpr reverse_iterator rend() const noexcept; + constexpr const_reverse_iterator crbegin() const noexcept; + constexpr const_reverse_iterator crend() const noexcept; + + private: + pointer data_; // \expos + index_type size_; // \expos + }; + + template + span(T (&)[N]) -> span; + template + span(array&) -> span; + template + span(const array&) -> span; + template + span(Container&) -> span; + template + span(const Container&) -> span; +} +\end{codeblock} + +\rSec3[span.cons]{Constructors, copy, and assignment} + +\indexlibrary{\idxcode{span}!constructor}% +\begin{itemdecl} +constexpr span() noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\effects +Constructs an empty \tcode{span}. + +\pnum +\postconditions +\tcode{size() == 0 \&\& data() == nullptr}. + +\pnum +\remarks +This constructor shall not participate in overload resolution +unless \tcode{Extent <= 0} is \tcode{true}. +\end{itemdescr} + +\indexlibrary{\idxcode{span}!constructor}% +\begin{itemdecl} +constexpr span(pointer ptr, index_type count); +\end{itemdecl} +\begin{itemdescr} +\pnum +\requires \range{ptr}{ptr + count} shall be a valid range. +If \tcode{extent} is not equal to \tcode{dynamic_extent}, +then \tcode{count} shall be equal to \tcode{extent}. + +\pnum +\effects +Constructs a \tcode{span} that is a view over the range \range{ptr}{ptr + count}. +If \tcode{count} is 0 then an empty span is constructed. + +\pnum +\postconditions +\tcode{size() == count \&\& data() == ptr}. + +\throws +Nothing. +\end{itemdescr} + +\indexlibrary{\idxcode{span}!constructor}% +\begin{itemdecl} +constexpr span(pointer first, pointer last); +\end{itemdecl} +\begin{itemdescr} +\pnum +\requires +\range{first}{last} shall be a valid range. +If \tcode{extent} is not equal to \tcode{dynamic_extent}, +then \tcode{last - first} shall be equal to \tcode{extent}. + +\pnum +\effects +Constructs a span that is a view over the range \range{first}{last}. +If \tcode{last - first == 0} then an empty \tcode{span} is constructed. + +\pnum +\postconditions +\tcode{size() == last - first \&\& data() == first}. + +\pnum +\throws +Nothing. +\end{itemdescr} + +\indexlibrary{\idxcode{span}!constructor}% +\begin{itemdecl} +template constexpr span(element_type (&arr)[N]) noexcept; +template constexpr span(array& arr) noexcept; +template constexpr span(const array& arr) noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\effects +Constructs a \tcode{span} that is a view over the supplied array. + +\pnum +\postconditions +\tcode{size() == N \&\& data() == data(arr)}. + +\pnum +\remarks +These constructors shall not participate in overload resolution unless: +\begin{itemize} +\item \tcode{extent == dynamic_extent || N == extent} is \tcode{true}, and +\item \tcode{remove_pointer_t(*)[]} is convertible to \tcode{ElementType(*)[]}. +\end{itemize} +\end{itemdescr} + +\indexlibrary{\idxcode{span}!constructor}% +\begin{itemdecl} +template constexpr span(Container& cont); +template constexpr span(const Container& cont); +\end{itemdecl} +\begin{itemdescr} +\pnum +\requires +\range{data(cont)}{data(cont) + size(cont)} shall be a valid range. +If \tcode{extent} is not equal to \tcode{dynamic_extent}, +then \tcode{size(cont)} shall be equal to \tcode{extent}. + +\pnum +\effects +Constructs a \tcode{span} that is a view over the range \range{data(cont)}{data(cont) + size(cont)}. + +\pnum +\postconditions +\tcode{size() == size(cont) \&\& data() == data(cont)}. + +\pnum +\throws +What and when \tcode{data(cont)} and \tcode{size(cont)} throw. + +\pnum +\remarks +These constructors shall not participate in overload resolution unless: +\begin{itemize} +\item \tcode{Container} is not a specialization of \tcode{span}, +\item \tcode{Container} is not a specialization of \tcode{array}, +\item \tcode{is_array_v} is \tcode{false}, +\item \tcode{data(cont)} and \tcode{size(cont)} are both well-formed, and +\item \tcode{remove_pointer_t(*)[]} is convertible to \tcode{ElementType(*)[]}. +\end{itemize} +\end{itemdescr} + +\indexlibrary{\idxcode{span}!constructor}% +\begin{itemdecl} +constexpr span(const span& other) noexcept = default; +\end{itemdecl} +\begin{itemdescr} +\pnum +\postconditions +\tcode{other.size() == size() \&\& other.data() == data()}. +\end{itemdescr} + +\indexlibrary{\idxcode{span}!constructor}% +\begin{itemdecl} +template + constexpr span(const span& s) noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\effects +Constructs a \tcode{span} that is a view over the range +\range{s.data()}{s.data() + s.size()}. + +\pnum +\postconditions +\tcode{size() == s.size() \&\& data() == s.data()}. + +\pnum +\remarks +This constructor shall not participate in overload resolution unless: +\begin{itemize} +\item \tcode{Extent == dynamic_extent || Extent == OtherExtent} is \tcode{true}, and +\item \tcode{OtherElementType(*)[]} is convertible to \tcode{ElementType(*)[]}. +\end{itemize} +\end{itemdescr} + +\indexlibrary{\idxcode{operator=}!\idxcode{span}}% +\begin{itemdecl} +constexpr span& operator=(const span& other) noexcept = default; +\end{itemdecl} +\begin{itemdescr} +\pnum +\postconditions +\tcode{size() == other.size() \&\& data() == other.data()}. +\end{itemdescr} + +\rSec3[span.sub]{Subviews} + +\indexlibrarymember{span}{first}% +\begin{itemdecl} +template constexpr span first() const; +\end{itemdecl} +\begin{itemdescr} +\pnum +\requires +\tcode{0 <= Count \&\& Count <= size()}. + +\pnum +\effects +Equivalent to: \tcode{return \{data(), Count\};} +\end{itemdescr} + +\indexlibrarymember{span}{last}% +\begin{itemdecl} +template constexpr span last() const; +\end{itemdecl} +\begin{itemdescr} +\pnum +\requires +\tcode{0 <= Count \&\& Count <= size()}. + +\pnum +\effects +Equivalent to: \tcode{return \{data() + (size() - Count), Count\};} +\end{itemdescr} + +\indexlibrarymember{span}{subspan}% +\begin{itemdecl} +template + constexpr span subspan() const; +\end{itemdecl} +\begin{itemdescr} +\pnum +\requires +\begin{codeblock} +(0 <= Offset && Offset <= size()) +&& (Count == dynamic_extent || Count >= 0 && Offset + Count <= size()) +\end{codeblock} + +\pnum +\effects +Equivalent to: +\begin{codeblock} +return span( + data() + Offset, Count != dynamic_extent ? Count : size() - Offset); +\end{codeblock} + +\pnum +\remarks +The second template argument of the returned \tcode{span} type is: +\begin{codeblock} +Count != dynamic_extent ? Count + : (Extent != dynamic_extent ? Extent - Offset + : dynamic_extent) +\end{codeblock} +\end{itemdescr} + +\indexlibrarymember{span}{first}% +\begin{itemdecl} +constexpr span first(index_type count) const; +\end{itemdecl} +\begin{itemdescr} +\pnum +\requires +\tcode{0 <= count \&\& count <= size()}. + +\pnum +\effects +Equivalent to: \tcode{return \{data(), count\};} +\end{itemdescr} + +\indexlibrarymember{span}{last}% +\begin{itemdecl} +constexpr span last(index_type count) const; +\end{itemdecl} +\begin{itemdescr} +\pnum +\requires +\tcode{0 <= count 0 \&\& count <= size()}. + +\pnum +\effects +Equivalent to: \tcode{return \{data() + (size() - count), count\};} +\end{itemdescr} + +\indexlibrarymember{span}{subspan}% +\begin{itemdecl} +constexpr span subspan( + index_type offset, index_type count = dynamic_extent) const; +\end{itemdecl} +\begin{itemdescr} +\pnum +\requires +\begin{codeblock} +(0 <= offset && offset <= size()) +&& (count == dynamic_extent || count >= 0 && offset + count <= size()) +\end{codeblock} + +\pnum +\effects +Equivalent to: +\begin{codeblock} +return {data() + offset, count == dynamic_extent ? size() - offset : count}; +\end{codeblock} +\end{itemdescr} + +\rSec3[span.obs]{Observers} + +\indexlibrarymember{span}{size}% +\begin{itemdecl} +constexpr index_type size() const noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\effects +Equivalent to: \tcode{return size_;} +\end{itemdescr} + +\indexlibrarymember{span}{size_bytes}% +\begin{itemdecl} +constexpr index_type size_bytes() const noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\effects +Equivalent to: \tcode{return size() * sizeof(element_type);} +\end{itemdescr} + +\indexlibrarymember{span}{empty}% +\begin{itemdecl} +constexpr bool empty() const noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\effects +Equivalent to: \tcode{return size() == 0;} +\end{itemdescr} + +\rSec3[span.elem]{Element access} + +\indexlibrary{\idxcode{operator[]}!\idxcode{span}}% +\indexlibrary{\idxcode{operator()}!\idxcode{span}}% +\begin{itemdecl} +constexpr reference operator[](index_type idx) const; +constexpr reference operator()(index_type idx) const; +\end{itemdecl} +\begin{itemdescr} +\pnum +\requires +\tcode{0 <= idx \&\& idx < size()}. + +\pnum +\effects +Equivalent to: \tcode{return *(data() + idx);} +\end{itemdescr} + +\indexlibrarymember{span}{data}% +\begin{itemdecl} +constexpr pointer data() const noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\effects +Equivalent to: \tcode{return data_;} +\end{itemdescr} + +\rSec3[span.iterators]{Iterator support} + +\indexlibrarymember{span}{begin}% +\begin{itemdecl} +constexpr iterator begin() const noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\returns +An iterator referring to the first element in the span. +If \tcode{empty()} is \tcode{true}, then it returns the +same value as \tcode{end()}. +\end{itemdescr} + +\indexlibrarymember{span}{end}% +\begin{itemdecl} +constexpr iterator end() const noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\returns +An iterator which is the past-the-end value. +\end{itemdescr} + +\indexlibrarymember{span}{rbegin}% +\begin{itemdecl} +constexpr reverse_iterator rbegin() const noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\effects +Equivalent to: \tcode{return reverse_iterator(end());} +\end{itemdescr} + +\indexlibrarymember{span}{rend}% +\begin{itemdecl} +constexpr reverse_iterator rend() const noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\returns +Equivalent to: \tcode{return reverse_iterator(begin());} +\end{itemdescr} + +\indexlibrarymember{span}{cbegin}% +\begin{itemdecl} +constexpr const_iterator cbegin() const noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\returns +A constant iterator referring to the first element in the span. +If \tcode{empty()} is \tcode{true}, then it returns the same value +as \tcode{cend()}. +\end{itemdescr} + +\indexlibrarymember{span}{cend}% +\begin{itemdecl} +constexpr const_iterator cend() const noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\returns +A constant iterator which is the past-the-end value. +\end{itemdescr} + +\indexlibrarymember{span}{crbegin}% +\begin{itemdecl} +constexpr const_reverse_iterator crbegin() const noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\effects +Equivalent to: \tcode{return const_reverse_iterator(cend());} +\end{itemdescr} + +\indexlibrarymember{span}{crend}% +\begin{itemdecl} +constexpr const_reverse_iterator crend() const noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\effects +Equivalent to: \tcode{return const_reverse_iterator(cbegin());} +\end{itemdescr} + +\rSec3[span.comparison]{Comparison operators} + +\indexlibrary{\idxcode{operator==}!\idxcode{span}}% +\begin{itemdecl} +template + constexpr bool operator==(span l, span r); +\end{itemdecl} +\begin{itemdescr} +\pnum +\effects +Equivalent to: \tcode{return equal(l.begin(), l.end(), r.begin(), r.end());} +\end{itemdescr} + +\indexlibrary{\idxcode{operator"!=}!\idxcode{span}}% +\begin{itemdecl} +template + constexpr bool operator!=(span l, span r); +\end{itemdecl} +\begin{itemdescr} +\pnum +\effects +Equivalent to: \tcode{return !(l == r);} +\end{itemdescr} + +\indexlibrary{\idxcode{operator<}!\idxcode{span}}% +\begin{itemdecl} +template + constexpr bool operator<(span l, span r); +\end{itemdecl} +\begin{itemdescr} +\pnum +\effects +Equivalent to: +\begin{codeblock} +return lexicographical_compare(l.begin(), l.end(), r.begin(), r.end()); +\end{codeblock} +\end{itemdescr} + +\indexlibrary{\idxcode{operator<=}!\idxcode{span}}% +\begin{itemdecl} +template + constexpr bool operator<=(span l, span r); +\end{itemdecl} +\begin{itemdescr} +\pnum +\effects +Equivalent to: \tcode{return !(r < l);} +\end{itemdescr} + +\indexlibrary{\idxcode{operator>}!\idxcode{span}}% +\begin{itemdecl} +template + constexpr bool operator>(span l, span r); +\end{itemdecl} +\begin{itemdescr} +\pnum +\effects +Equivalent to: \tcode{return (r < l);} +\end{itemdescr} + +\indexlibrary{\idxcode{operator>=}!\idxcode{span}}% +\begin{itemdecl} +template + constexpr bool operator>=(span l, span r); +\end{itemdecl} +\begin{itemdescr} +\pnum +\effects +Equivalent to: \tcode{return !(l < r);} +\end{itemdescr} + +\rSec3[span.objectrep]{Views of object representation} + +\indexlibrary{\idxcode{as_bytes}}% +\begin{itemdecl} +template + span(sizeof(ElementType)) * Extent> + as_bytes(span s) noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\effects +Equivalent to: \tcode{return \{reinterpret_cast(s.data()), s.size_bytes()\};} +\end{itemdescr} + +\indexlibrary{\idxcode{as_writable_bytes}}% +\begin{itemdecl} +template + span(sizeof(ElementType)) * Extent> + as_writable_bytes(span s) noexcept; +\end{itemdecl} +\begin{itemdescr} +\pnum +\effects +Equivalent to: \tcode{return \{reinterpret_cast(s.data()), s.size_bytes()\};} + +\pnum +\remarks +This function shall not participate in overload resolution unless +\tcode{is_const_v} is \tcode{false}. +\end{itemdescr} diff --git a/source/conversions.tex b/source/conversions.tex index 5f356bf015..13e028ae23 100644 --- a/source/conversions.tex +++ b/source/conversions.tex @@ -80,7 +80,7 @@ well-formed if and only if \tcode{e} can be implicitly converted to a type \tcode{T} that is determined as follows: \tcode{E} is searched for non-explicit conversion functions -whose return type is \cvqual{cv} \tcode{T} or reference to \cvqual{cv} +whose return type is \cv{} \tcode{T} or reference to \cv{} \tcode{T} such that \tcode{T} is allowed by the context. There shall be exactly one such \tcode{T}. @@ -241,21 +241,21 @@ \pnum A \defn{cv-decomposition} of a type \tcode{T} is a sequence of -$cv_i$ and $P_i$ +$\cv{}_i$ and $P_i$ such that \tcode{T} is \begin{indented} -``$cv_0$ $P_0$ $cv_1$ $P_1$ $\cdots$ $cv_{n-1}$ $P_{n-1}$ $cv_n$ \tcode{U}'' for $n > 0$, +``$\cv{}_0$ $P_0$ $\cv{}_1$ $P_1$ $\cdots$ $\cv{}_{n-1}$ $P_{n-1}$ $\cv{}_n$ \tcode{U}'' for $n > 0$, \end{indented} where -each $cv_i$ is a set of cv-qualifiers\iref{basic.type.qualifier}, and +each $\cv{}_i$ is a set of cv-qualifiers\iref{basic.type.qualifier}, and each $P_i$ is ``pointer to''\iref{dcl.ptr}, ``pointer to member of class $C_i$ of type''\iref{dcl.mptr}, ``array of $N_i$'', or ``array of unknown bound of''\iref{dcl.array}. If $P_i$ designates an array, -the cv-qualifiers $cv_{i+1}$ on the element type are also taken as -the cv-qualifiers $cv_i$ of the array. +the cv-qualifiers $\cv{}_{i+1}$ on the element type are also taken as +the cv-qualifiers $\cv{}_i$ of the array. \begin{example} The type denoted by the \grammarterm{type-id} \tcode{const int **} has two cv-decompositions, @@ -263,7 +263,7 @@ \end{example} The $n$-tuple of cv-qualifiers after the first one in the longest cv-decomposition of \tcode{T}, that is, -$cv_1, cv_2, \dotsc, cv_n$, is called the +$\cv{}_1, \cv{}_2, \dotsc, \cv{}_n$, is called the \defn{cv-qualification signature} of \tcode{T}. \pnum @@ -280,16 +280,16 @@ % NB: forbid line break between 'where' and 'cv' % to stop superscript j from running into % descender of p on the previous line. -where~$cv_i^j$ denotes the cv-qualifiers in the cv-qualification signature of $\tcode{T}_j$:% +where~$\cv{}_i^j$ denotes the cv-qualifiers in the cv-qualification signature of $\tcode{T}_j$:% \footnote{These rules ensure that const-safety is preserved by the conversion.} \begin{itemize} \item $\tcode{T}_1$ and $\tcode{T}_2$ are similar. -\item For every $i > 0$, if \tcode{const} is in $\text{\cv}_i^1$ then \tcode{const} is in $\text{\cv}_i^2$, and similarly for \tcode{volatile}. +\item For every $i > 0$, if \tcode{const} is in $\cv{}_i^1$ then \tcode{const} is in $\cv{}_i^2$, and similarly for \tcode{volatile}. -\item If the $\text{\cv}_i^1$ and $\text{\cv}_i^2$ are different, -then \tcode{const} is in every $\text{\cv}_k^2$ for $0 < k < i$. +\item If the $\cv{}_i^1$ and $\cv{}_i^2$ are different, +then \tcode{const} is in every $\cv{}_k^2$ for $0 < k < i$. \end{itemize} \begin{note} @@ -477,7 +477,7 @@ represented exactly, it is an \impldef{value of result of inexact integer to floating-point conversion} choice of either the next lower or higher representable value. \begin{note} Loss of precision occurs if the integral value cannot be represented -exactly as a value of the floating type. \end{note} If the value being converted is +exactly as a value of the floating-point type. \end{note} If the value being converted is outside the range of values that can be represented, the behavior is undefined. If the source type is \tcode{bool}, the value \tcode{false} is converted to zero and the value \tcode{true} is converted to one. @@ -507,15 +507,15 @@ \begin{note} The resulting prvalue is not a null pointer value. \end{note} \pnum -A prvalue of type ``pointer to \cvqual{cv} \tcode{T}'', where \tcode{T} +A prvalue of type ``pointer to \cv{} \tcode{T}'', where \tcode{T} is an object type, can be converted to a prvalue of type ``pointer to -\cvqual{cv} \tcode{void}''. +\cv{} \tcode{void}''. The pointer value\iref{basic.compound} is unchanged by this conversion. \pnum -A prvalue of type ``pointer to \cvqual{cv} \tcode{D}'', where \tcode{D} +A prvalue of type ``pointer to \cv{} \tcode{D}'', where \tcode{D} is a class type, can be converted to a prvalue of type ``pointer to -\cvqual{cv} \tcode{B}'', where \tcode{B} is a base class\iref{class.derived} +\cv{} \tcode{B}'', where \tcode{B} is a base class\iref{class.derived} of \tcode{D}. If \tcode{B} is an inaccessible\iref{class.access} or ambiguous\iref{class.member.lookup} base class of \tcode{D}, a program @@ -543,9 +543,9 @@ followed by a qualification conversion\iref{conv.qual}. \pnum -A prvalue of type ``pointer to member of \tcode{B} of type \cvqual{cv} +A prvalue of type ``pointer to member of \tcode{B} of type \cv{} \tcode{T}'', where \tcode{B} is a class type, can be converted to -a prvalue of type ``pointer to member of \tcode{D} of type \cvqual{cv} +a prvalue of type ``pointer to member of \tcode{D} of type \cv{} \tcode{T}'', where \tcode{D} is a derived class\iref{class.derived} of \tcode{B}. If \tcode{B} is an inaccessible\iref{class.access}, @@ -556,7 +556,7 @@ member before the conversion took place, but it refers to the base class member as if it were a member of the derived class. The result refers to the member in \tcode{D}'s instance of \tcode{B}. Since the result has -type ``pointer to member of \tcode{D} of type \cvqual{cv} \tcode{T}'', +type ``pointer to member of \tcode{D} of type \cv{} \tcode{T}'', indirection through it with a \tcode{D} object is valid. The result is the same as if indirecting through the pointer to member of \tcode{B} with the \tcode{B} subobject of \tcode{D}. The null member pointer value is @@ -582,7 +582,7 @@ The result is a pointer to the function. A prvalue of type ``pointer to member of type \tcode{noexcept} function'' can be converted to a prvalue of type ``pointer to member of type function''. -The result points to the member function. +The result designates the member function. \begin{example} \begin{codeblock} diff --git a/source/declarations.tex b/source/declarations.tex index 0cf853027b..933427f297 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -174,7 +174,7 @@ \begin{example} \begin{codeblock} -static_assert(char(-1) < 0, "this library requires plain 'char' to be signed"); +static_assert(sizeof(int) == sizeof(void*), "wrong pointer size"); \end{codeblock}\end{example} \pnum @@ -207,14 +207,14 @@ \pnum If the \grammarterm{decl-specifier-seq} contains the \tcode{typedef} -specifier, the declaration is called a \term{typedef declaration} and the name +specifier, the declaration is called a \defnx{typedef declaration}{declaration!typedef} and the name of each \grammarterm{init-declarator} is declared to be a \grammarterm{typedef-name}, synonymous with its associated type\iref{dcl.typedef}. If the \grammarterm{decl-specifier-seq} contains no \tcode{typedef} specifier, the -declaration is called a \term{function declaration} if +declaration is called a \defnx{function declaration}{declaration!function} if the type associated with the name is a function type\iref{dcl.fct} and -an \term{object declaration} otherwise. +an \defnx{object declaration}{declaration!object} otherwise. \pnum \indextext{definition!declaration as}% @@ -414,7 +414,6 @@ the same linkage. Each function in a given set of overloaded functions can have a different linkage, however. \begin{example} -\indextext{example!linkage consistency}% \begin{codeblock} static char* f(); // \tcode{f()} has internal linkage char* f() // \tcode{f()} still has internal linkage @@ -549,7 +548,6 @@ \grammarterm{typedef-name} does not introduce a new type the way a class declaration\iref{class.name} or enum declaration does. \begin{example} -\indextext{example!\idxcode{typedef}}% After \begin{codeblock} @@ -978,7 +976,7 @@ \indextext{inline function}% A function declaration~(\ref{dcl.fct}, \ref{class.mfct}, \ref{class.friend}) with an \tcode{inline} specifier declares an -\term{inline function}. The inline specifier indicates to +\defnx{inline function}{function!inline}. The inline specifier indicates to the implementation that inline substitution of the function body at the point of call is to be preferred to the usual function call mechanism. An implementation is not required to perform this inline substitution at @@ -988,7 +986,7 @@ \pnum A variable declaration with an \tcode{inline} specifier declares an -\term{inline variable}. +\defnx{inline variable}{variable!inline}. \pnum A function defined within a class definition is an inline function. @@ -1119,7 +1117,7 @@ \grammarterm{type-specifier}{s} are discussed in the rest of this subclause. \end{note} -\rSec3[dcl.type.cv]{The \grammarterm{cv-qualifier}{s}}% +\rSec3[dcl.type.cv]{The \fakegrammarterm{cv-qualifier}{s}}% \indextext{specifier!cv-qualifier}% \indextext{initialization!\idxcode{const}}% \indextext{type specifier!\idxcode{const}}% @@ -1298,7 +1296,7 @@ specify either a previously-declared type, a type determined from an expression, or one of the fundamental types\iref{basic.fundamental}. -Table~\ref{tab:simple.type.specifiers} +\tref{simple.type.specifiers} summarizes the valid combinations of \grammarterm{simple-type-specifier}{s} and the types they specify. @@ -1651,14 +1649,14 @@ \end{example} \pnum -If the type of an entity with an undeduced placeholder type is needed to -determine the type of an expression, the program is ill-formed. Once a +If the name of an entity with an undeduced placeholder type appears in an +expression, the program is ill-formed. Once a non-discarded \tcode{return} statement has been seen in a function, however, the return type deduced from that statement can be used in the rest of the function, including in other \tcode{return} statements. \begin{example} \begin{codeblock} -auto n = n; // error, \tcode{n}'s type is unknown +auto n = n; // error, \tcode{n}'s initializer refers to \tcode{n} auto f(); void g() { &f; } // error, \tcode{f}'s return type is unknown auto sum(int i) { @@ -1692,6 +1690,10 @@ Redeclarations or specializations of a function or function template with a declared return type that uses a placeholder type shall also use that placeholder, not a deduced type. +Similarly, +redeclarations or specializations of a function or function template with a +declared return type that does not use a placeholder type +shall not use a placeholder. \begin{example} \begin{codeblock} auto f(); @@ -1990,11 +1992,11 @@ \indextext{enumeration}% The enumeration type declared with an \grammarterm{enum-key} of only \tcode{enum} is an \defnx{unscoped enumeration}{enumeration!unscoped}, -and its \grammarterm{enumerator}{s} are \term{unscoped enumerators}. +and its \grammarterm{enumerator}{s} are \defnx{unscoped enumerators}{enumerator!unscoped}. The \grammarterm{enum-key}{s} \tcode{enum class} and \tcode{enum struct} are semantically equivalent; an enumeration type declared with one of these is a \defnx{scoped enumeration}{enumeration!scoped}, -and its \grammarterm{enumerator}{s} are \term{scoped enumerators}. +and its \grammarterm{enumerator}{s} are \defnx{scoped enumerators}{enumerator!scoped}. The optional \grammarterm{identifier} shall not be omitted in the declaration of a scoped enumeration. The \grammarterm{type-specifier-seq} of an \grammarterm{enum-base} shall name an integral type; any cv-qualification is ignored. @@ -2141,7 +2143,6 @@ The value of an enumerator or an object of an unscoped enumeration type is converted to an integer by integral promotion\iref{conv.prom}. \begin{example} -\indextext{example!enumeration}% \begin{codeblock} enum color { red, yellow, green=20, blue }; color col = red; @@ -2328,7 +2329,7 @@ \end{example} \pnum -The \term{enclosing namespaces} of a declaration are those +The \defnx{enclosing namespaces}{namespace!enclosing} of a declaration are those namespaces in which the declaration lexically appears, except for a redeclaration of a namespace member outside its original namespace (e.g., a definition as specified in~\ref{namespace.memdef}). Such a @@ -2353,7 +2354,7 @@ \pnum If the optional initial \tcode{inline} keyword appears in a \grammarterm{namespace-definition} for a particular namespace, that namespace is -declared to be an \term{inline namespace}. The \tcode{inline} keyword may be +declared to be an \defnx{inline namespace}{namespace!inline}. The \tcode{inline} keyword may be used on a \grammarterm{namespace-definition} that extends a namespace only if it was previously used on the \grammarterm{namespace-definition} that initially declared the \grammarterm{namespace-name} for that namespace. @@ -2383,9 +2384,9 @@ These properties are transitive: if a namespace \tcode{N} contains an inline namespace \tcode{M}, which in turn contains an inline namespace \tcode{O}, then the members of \tcode{O} can be used as though they were members of \tcode{M} or \tcode{N}. -The \term{inline namespace set} of \tcode{N} is the transitive closure of all +The \defn{inline namespace set} of \tcode{N} is the transitive closure of all inline namespaces in \tcode{N}. -The \term{enclosing namespace set} of \tcode{O} is the set of namespaces +The \defn{enclosing namespace set} of \tcode{O} is the set of namespaces consisting of the innermost non-inline namespace enclosing an inline namespace \tcode{O}, together with any intervening inline namespaces. @@ -2670,7 +2671,7 @@ \end{note} \indextext{inheritance!\idxgram{using-declaration} and}% If the \grammarterm{using-declarator} names a constructor, -it declares that the class \term{inherits} the set of constructor declarations +it declares that the class \defnx{inherits}{constructor!inherited} the set of constructor declarations introduced by the \grammarterm{using-declarator} from the nominated base class. \pnum @@ -3351,7 +3352,7 @@ \pnum All function types, function names with external linkage, and variable -names with external linkage have a \term{language linkage}. +names with external linkage have a \defn{language linkage}. \begin{note} Some of the properties associated with an entity with language linkage are specific to each implementation and are not described here. For @@ -4025,6 +4026,66 @@ \end{codeblock} \end{example} +\rSec2[dcl.attr.likelihood]{Likelihood attributes}% +\indextext{attribute!likely} +\indextext{attribute!unlikely} + +\pnum +The \grammarterm{attribute-token}s +\tcode{likely} and \tcode{unlikely} +may be applied to labels or statements. +The \grammarterm{attribute-token}s +\tcode{likely} and \tcode{unlikely} +shall appear at most once in each \grammarterm{attribute-list} +and no \grammarterm{attribute-argument-clause} shall be present. +The \grammarterm{attribute-token} \tcode{likely} +shall not appear in an \grammarterm{attribute-specifier-seq} +that contains the \grammarterm{attribute-token} \tcode{unlikely}. + +\pnum +\begin{note} +The use of the \tcode{likely} attribute +is intended to allow implementations to optimize for +the case where paths of execution including it +are arbitrarily more likely +than any alternative path of execution +that does not include such an attribute on a statement or label. +The use of the \tcode{unlikely} attribute +is intended to allow implementations to optimize for +the case where paths of execution including it +are arbitrarily more unlikely +than any alternative path of execution +that does not include such an attribute on a statement or label. +A path of execution includes a label +if and only if it contains a jump to that label. +Excessive usage of either of these attributes +is liable to result in performance degradation. +\end{note} + +\pnum +\begin{example} +\begin{codeblock} +void g(int); +int f(int n) { + if (n > 5) [[unlikely]] { // \tcode{n > 5} is considered to be arbitrarily unlikely + g(0); + return n * 2 + 1; + } + + switch (n) { + case 1: + g(1); + [[fallthrough]]; + + [[likely]] case 2: // \tcode{n == 3} is considered to be arbitrarily more + g(2); // likely than any other value of \tcode{n} + break; + } + return 3; +} +\end{codeblock} +\end{example} + \rSec2[dcl.attr.unused]{Maybe unused attribute}% \indextext{attribute!maybe unused} @@ -4137,3 +4198,42 @@ } \end{codeblock} \end{example} + +\rSec2[dcl.attr.nouniqueaddr]{No unique address attribute}% +\indextext{attribute!no unique address} + +\pnum +The \grammarterm{attribute-token} \tcode{no_unique_address} +specifies that a non-static data member +is a potentially-overlapping subobject\iref{intro.object}. +It shall appear at most once in each \grammarterm{attribute-list} +and no \grammarterm{attribute-argument-clause} shall be present. +The attribute may appertain to a non-static data member +other than a bit-field. + +\pnum +\begin{note} +The non-static data member can share the address of +another non-static data member or that of a base class, +and any padding that would normally be inserted +at the end of the object +can be reused as storage for other members. +\end{note} +\begin{example} +\begin{codeblock} +template +class hash_map { + [[no_unique_address]] Hash hasher; + [[no_unique_address]] Pred pred; + [[no_unique_address]] Allocator alloc; + Bucket *buckets; + // ... +public: + // ... +}; +\end{codeblock} +Here, \tcode{hasher}, \tcode{pred}, and \tcode{alloc} +could have the same address as \tcode{buckets} +if their respective types are all empty. +\end{example} diff --git a/source/declarators.tex b/source/declarators.tex index c9a9c6216f..895ee4bd93 100644 --- a/source/declarators.tex +++ b/source/declarators.tex @@ -255,8 +255,6 @@ The named type is then the same as the type of the hypothetical identifier. \begin{example} -\indextext{example!type name}% -\indextext{example!declarator}% \begin{codeblock} int // \tcode{int i} int * // \tcode{int *pi} @@ -567,8 +565,6 @@ \pnum \begin{example} The declarations -\indextext{example!\idxcode{const}}% -\indextext{example!constant pointer}% \begin{codeblock} const int ci = 10, *pc = &ci, *const cpc = pc, **ppc; int i, *p, *const cp = &i; @@ -870,9 +866,7 @@ pointer-to-member. \pnum -\begin{example}% -\indextext{example!pointer-to-member} - +\begin{example} \begin{codeblock} struct X { void f(int); @@ -1091,7 +1085,6 @@ \pnum \begin{example} -\indextext{example!array}% \begin{codeblock} float fa[17], *afp[17]; \end{codeblock} @@ -1120,7 +1113,6 @@ \tcode{x3d[i][j]}, \tcode{x3d[i][j][k]} can reasonably appear in an expression. -\indextext{example!subscripting}% The expression \tcode{x3d[i]} is equivalent to @@ -1364,8 +1356,6 @@ is synonymous with ``\tcode{...}''. \begin{example} -\indextext{example!ellipsis}% -\indextext{example!variable parameter list}% The declaration \begin{codeblock} @@ -1482,7 +1472,6 @@ \pnum \begin{example} -\indextext{example!function declaration}% The declaration \begin{codeblock} @@ -1548,7 +1537,6 @@ \begin{example} The declaration -\indextext{example!declaration}% \begin{codeblock} int i, *pi, @@ -1633,14 +1621,14 @@ \pnum A \grammarterm{declarator-id} or \grammarterm{abstract-declarator} containing an ellipsis shall only -be used in a \grammarterm{parameter-declaration}. Such a -\grammarterm{parameter-declaration} is a parameter -pack\iref{temp.variadic}. When it is part of a -\grammarterm{parameter-declaration-clause}, the parameter pack is a -function parameter pack\iref{temp.variadic}. \begin{note} +be used in a \grammarterm{parameter-declaration}. +When it is part of a +\grammarterm{parameter-declaration-clause}, +the \grammarterm{parameter-declaration} declares a +function parameter pack\iref{temp.variadic}. Otherwise, the \grammarterm{parameter-declaration} is part of a -\grammarterm{template-parameter-list} and the parameter pack is a -template parameter pack; see~\ref{temp.param}. \end{note} +\grammarterm{template-parameter-list} and declares a +template parameter pack; see~\ref{temp.param}. A function parameter pack is a pack expansion\iref{temp.variadic}. \begin{example} @@ -1713,7 +1701,9 @@ \grammarterm{template-parameter}\iref{temp.param}; in the latter case, the \grammarterm{initializer-clause} shall be an \grammarterm{assignment-expression}. -A default argument shall not be specified for a parameter pack. +A default argument shall not be specified for +a template parameter pack or +a function parameter pack. If it is specified in a \grammarterm{parameter-declaration-clause}, it shall not occur within a @@ -2018,7 +2008,6 @@ \begin{example} A simple example of a complete function definition is -\indextext{example!function definition}% \begin{codeblock} int max(int a, int b, int c) { int m = (a > b) ? a : b; @@ -2062,7 +2051,6 @@ Unused parameters need not be named. For example, -\indextext{example!unnamed parameter}% \begin{codeblock} void print(int a, int) { std::printf("a = %d\n",a); @@ -2226,12 +2214,13 @@ constitute a reference. \end{note} \pnum -\begin{example} One can enforce non-default-initialization and non-integral -initialization with +\begin{example} One can prevent default initialization and +initialization by non-\tcode{double}s with \begin{codeblock} struct onlydouble { onlydouble() = delete; // OK, but redundant - onlydouble(std::intmax_t) = delete; + template + onlydouble(T) = delete; onlydouble(double); }; \end{codeblock} @@ -2350,7 +2339,10 @@ the \grammarterm{identifier-list} shall be equal to the value of that expression. The \grammarterm{unqualified-id} \tcode{get} is looked up in the scope of \tcode{E} by class member access lookup\iref{basic.lookup.classref}, -and if that finds at least one declaration, the initializer is +and if that finds at least one declaration +that is a function template whose first template parameter +is a non-type parameter, +the initializer is \tcode{e.get()}. Otherwise, the initializer is \tcode{get(e)}, where \tcode{get} is looked up in the associated namespaces\iref{basic.lookup.argdep}. In either case, \tcode{get} is interpreted as a \grammarterm{template-id}. @@ -2370,11 +2362,15 @@ the referenced type is $\tcode{T}_i$. \pnum -Otherwise, all of \tcode{E}'s non-static data members shall be public direct -members of \tcode{E} or of the same unambiguous public base class of \tcode{E}, -\tcode{E} shall not have an anonymous union member, and the number of elements -in the \grammarterm{identifier-list} shall be equal to the number of non-static -data members of \tcode{E}. +Otherwise, +all of \tcode{E}'s non-static data members +shall be direct members of \tcode{E} or +of the same base class of \tcode{E}, +well-formed when named as \tcode{e.\placeholder{name}} +in the context of the structured binding, +\tcode{E} shall not have an anonymous union member, and +the number of elements in the \grammarterm{identifier-list} shall be +equal to the number of non-static data members of \tcode{E}. Designating the non-static data members of \tcode{E} as \tcode{m}$_0$, \tcode{m}$_1$, \tcode{m}$_2$, ... (in declaration order), @@ -3160,6 +3156,16 @@ An aggregate that is a class can also be initialized with a single expression not enclosed in braces, as described in~\ref{dcl.init}. +\pnum +The destructor for each element of class type +is potentially invoked\iref{class.dtor} +from the context where the aggregate initialization occurs. +\begin{note} +This provision ensures that destructors can be called +for fully-constructed subobjects +in case an exception is thrown\iref{except.ctor}. +\end{note} + \pnum An array of unknown bound initialized with a brace-enclosed diff --git a/source/derived.tex b/source/derived.tex index babf5b0fc3..bd073cf63a 100644 --- a/source/derived.tex +++ b/source/derived.tex @@ -88,7 +88,7 @@ unless their names are hidden or ambiguous\iref{class.member.lookup}. \indextext{operator!scope resolution}% \begin{note} -The scope resolution operator \tcode{::}\iref{expr.prim} can be used +The scope resolution operator \tcode{::}\iref{expr.prim.id.qual} can be used to refer to a direct or indirect base member explicitly. This allows access to a name that has been redeclared in the derived class. A derived class can itself serve as a base class subject to access @@ -104,7 +104,6 @@ \term{base class subobjects} contained in an object of the derived class type. \begin{example} -\indextext{example!derived class}% \begin{codeblock} struct Base { int a, b, c; @@ -421,8 +420,6 @@ If the name of an overloaded function is unambiguously found, overload resolution\iref{over.match} also takes place before access control. -\indextext{example!scope resolution operator}% -\indextext{example!explicit qualification}% \indextext{overloading!resolution!scoping ambiguity}% Ambiguities can often be resolved by qualifying a name with its class name. \begin{example} @@ -733,7 +730,6 @@ the type returned by the (statically chosen) overridden function\iref{expr.call}. \begin{example} -\indextext{example!virtual function}% \begin{codeblock} class B { }; class D : private B { friend class Derived; }; @@ -807,7 +803,6 @@ \indextext{multiple inheritance!\tcode{virtual} and}% \begin{example} Here are some uses of virtual functions with multiple base classes: -\indextext{example!virtual function}% \begin{codeblock} struct A { virtual void f(); @@ -890,7 +885,7 @@ \pnum \indextext{operator!scope resolution}% \indextext{virtual function call}% -Explicit qualification with the scope operator\iref{expr.prim} +Explicit qualification with the scope operator\iref{expr.prim.id.qual} suppresses the virtual call mechanism. \begin{example} \begin{codeblock} @@ -940,9 +935,8 @@ \indextext{definition!pure virtual function}% A pure virtual function need be defined only if called with, or as if with\iref{class.dtor}, the \grammarterm{qualified-id} -syntax\iref{expr.prim}. +syntax\iref{expr.prim.id.qual}. \begin{example} -\indextext{example!pure virtual function}% \begin{codeblock} class point { @\commentellip@ }; class shape { // abstract class diff --git a/source/diagnostics.tex b/source/diagnostics.tex index 220bdd6ad8..ea891f8f70 100644 --- a/source/diagnostics.tex +++ b/source/diagnostics.tex @@ -12,7 +12,7 @@ reporting several kinds of exceptional conditions, documenting program assertions, and a global variable for error number codes, -as summarized in Table~\ref{tab:diagnostics.lib.summary}. +as summarized in \tref{diagnostics.lib.summary}. \begin{libsumtab}{Diagnostics library summary}{tab:diagnostics.lib.summary} \ref{std.exceptions} & Exception classes & \tcode{} \\ \rowsep @@ -557,7 +557,7 @@ except that a macro named \tcode{static_assert} is not defined. -\xref ISO C 7.2 +\xrefc{7.2} \rSec2[assertions.assert]{The \tcode{assert} macro} @@ -752,7 +752,7 @@ \pnum The meaning of the macros in this header is defined by the POSIX standard. -\xref ISO C 7.5 +\xrefc{7.5} \rSec1[syserr]{System error support} diff --git a/source/expressions.tex b/source/expressions.tex index 9032006f12..307bb52653 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -286,13 +286,13 @@ similar to \tcode{T1} whose cv-qualification signature\iref{conv.qual} is: \begin{itemize} \item -for every $i > 0$, $cv^3_i$ is the union of -$cv^1_i$ and $cv^2_i$; +for every $i > 0$, $\cv{}^3_i$ is the union of +$\cv{}^1_i$ and $\cv{}^2_i$; \item -if the resulting $cv^3_i$ is different from -$cv^1_i$ or $cv^2_i$, then -\tcode{const} is added to every $cv^3_k$ for $0 < k < i$. +if the resulting $\cv{}^3_i$ is different from +$\cv{}^1_i$ or $\cv{}^2_i$, then +\tcode{const} is added to every $\cv{}^3_k$ for $0 < k < i$. \end{itemize} \begin{note} Given similar types \tcode{T1} and \tcode{T2}, this @@ -377,7 +377,7 @@ An unevaluated operand is not evaluated. \begin{note} In an unevaluated operand, a non-static class member may be -named\iref{expr.prim} and naming of objects or functions does not, by +named\iref{expr.prim.id} and naming of objects or functions does not, by itself, require that a definition be provided\iref{basic.def.odr}. An unevaluated operand is considered a full-expression\iref{intro.execution}. \end{note} @@ -1229,14 +1229,15 @@ \begin{bnf} \nontermdef{capture-list}\br - capture \opt{\terminal{...}}\br - capture-list \terminal{,} capture \opt{\terminal{...}} + capture\br + capture-list \terminal{,} capture \end{bnf} \begin{bnf} \nontermdef{capture}\br - simple-capture\br - init-capture + simple-capture \opt{\terminal{...}}\br + % FIXME: This is wrong. The ... should go after the &. + \opt{\terminal{...}} init-capture \end{bnf} \begin{bnf} @@ -1642,14 +1643,22 @@ \pnum A \grammarterm{simple-capture} followed by an ellipsis is a pack -expansion\iref{temp.variadic}. An \grammarterm{init-capture} followed by an -ellipsis is ill-formed. +expansion\iref{temp.variadic}. +\indextext{init-capture pack@\fakegrammarterm{init-capture} pack}% +An \grammarterm{init-capture} preceded by an ellipsis is a pack +expansion that introduces an +\grammarterm{init-capture} pack\iref{temp.variadic} +whose declarative region is +the \grammarterm{lambda-expression}'s \grammarterm{compound-statement}. \begin{example} \begin{codeblock} template void f(Args... args) { auto lm = [&, args...] { return g(args...); }; lm(); + + auto lm2 = [...xs=std::move(args)] { return g(xs...); }; + lm2(); } \end{codeblock} \end{example}% @@ -1659,7 +1668,7 @@ \indextext{expression!fold|(} \pnum -A fold expression performs a fold of a template parameter +A fold expression performs a fold of a pack\iref{temp.variadic} over a binary operator. \begin{bnf} @@ -1692,7 +1701,7 @@ are collectively called \defnx{unary folds}{unary fold}. In a unary fold, the \grammarterm{cast-expression} -shall contain an unexpanded parameter pack\iref{temp.variadic}. +shall contain an unexpanded pack\iref{temp.variadic}. \pnum \indextext{fold!binary}% @@ -1704,13 +1713,13 @@ \placeholder{op1} and \placeholder{op2} shall be the same \grammarterm{fold-operator}, and either \tcode{e1} -shall contain an unexpanded parameter pack +shall contain an unexpanded pack or \tcode{e2} -shall contain an unexpanded parameter pack, +shall contain an unexpanded pack, but not both. -If \tcode{e2} contains an unexpanded parameter pack, +If \tcode{e2} contains an unexpanded pack, the expression is called a \defn{binary left fold}. -If \tcode{e1} contains an unexpanded parameter pack, +If \tcode{e1} contains an unexpanded pack, the expression is called a \defn{binary right fold}. \begin{example} \begin{codeblock} @@ -1721,7 +1730,7 @@ template bool f(Args ...args) { - return (args + ... + args); // error: both operands contain unexpanded parameter packs + return (args + ... + args); // error: both operands contain unexpanded packs } \end{codeblock} \end{example} @@ -2162,10 +2171,10 @@ the postfix expression shall be either an lvalue that refers to a function (in which case the function-to-pointer standard conversion\iref{conv.func} is suppressed on the postfix expression), -or it shall have function pointer type. Calling a function through an -expression whose function type is different -from the function type of the called function's -definition results in undefined behavior\iref{dcl.link}. For a call to a non-static +or it shall have function pointer type. + +\pnum +For a call to a non-static member function, the postfix expression shall be an implicit~(\ref{class.mfct.non-static}, \ref{class.static}) or explicit @@ -2179,9 +2188,11 @@ A member function call of the form \tcode{f()} is interpreted as \tcode{(*this).f()} (see~\ref{class.mfct.non-static}). \end{note} -If a function or member function name is used, the name can be -overloaded\iref{over}, in which case the appropriate function -shall be selected according to the rules in~\ref{over.match}. If the selected + +\pnum +If a function or member function name is used, +the appropriate function and the validity of the call are determined +according to the rules in~\ref{over.match}. If the selected function is non-virtual, or if the \grammarterm{id-expression} in the class member access expression is a \grammarterm{qualified-id}, that function is called. Otherwise, its final overrider\iref{class.virtual} in the dynamic type @@ -2212,6 +2223,12 @@ \indextext{type!incomplete}% This return type shall be an object type, a reference type or \cv{}~\tcode{void}. +\pnum +Calling a function through an +expression whose function type is different +from the function type of the called function's +definition results in undefined behavior\iref{dcl.link}. + \pnum \indextext{function argument|see{argument}}% \indextext{function parameter|see{parameter}}% @@ -2410,15 +2427,16 @@ expression\iref{expr.cast}. \indextext{type!incomplete}% Otherwise, if the type is \cv{}~\tcode{void} -and the initializer is \tcode{()}, +and the initializer is \tcode{()} +(after pack expansion, if any), the expression is a prvalue of the specified type that performs no initialization. Otherwise, the expression is a prvalue of the specified type whose result object is direct-initialized\iref{dcl.init} with the initializer. -For an expression of the form \tcode{T()}, -\tcode{T} shall not be an array type. +If the initializer is a parenthesized optional \grammarterm{expression-list}, +the specified type shall not be an array type. \rSec3[expr.pseudo]{Pseudo destructor call} @@ -2437,7 +2455,7 @@ \pnum The left-hand side of the dot operator shall be of scalar type. The left-hand side of the arrow operator shall be of pointer to scalar type. -This scalar type is the object type. The \cvqual{cv}-unqualified +This scalar type is the object type. The cv-unqualified versions of the object type and of the type designated by the \grammarterm{pseudo-destructor-name} shall be the same type. Furthermore, the two \grammarterm{type-name}{s} in a \grammarterm{pseudo-destructor-name} of @@ -2557,13 +2575,13 @@ \item Otherwise, if \tcode{E1.E2} refers to a non-static member function and the type of \tcode{E2} is ``function of -parameter-type-list \cvqual{cv} \opt{\grammarterm{ref-qualifier}} returning \tcode{T}'', then +parameter-type-list \cv{} \opt{\grammarterm{ref-qualifier}} returning \tcode{T}'', then \tcode{E1.E2} is a prvalue. The expression designates a non-static member function. The expression can be used only as the left-hand operand of a member function call\iref{class.mfct}. \begin{note} Any redundant set of parentheses surrounding the expression -is ignored\iref{expr.prim}. \end{note} The type of \tcode{E1.E2} is -``function of parameter-type-list \cvqual{cv} returning \tcode{T}''. +is ignored\iref{expr.prim.paren}. \end{note} The type of \tcode{E1.E2} is +``function of parameter-type-list \cv{} returning \tcode{T}''. \end{itemize} \item If \tcode{E2} is a nested type, the expression \tcode{E1.E2} is @@ -2640,7 +2658,7 @@ converting the expression \tcode{v} to type \tcode{T}. \indextext{type!incomplete}% \tcode{T} shall be a pointer or reference to a complete class type, or -``pointer to \cvqual{cv} \tcode{void}''. The \tcode{dynamic_cast} operator shall not cast +``pointer to \cv{} \tcode{void}''. The \tcode{dynamic_cast} operator shall not cast away constness\iref{expr.const.cast}. \pnum @@ -2653,9 +2671,8 @@ result is an xvalue of the type referred to by \tcode{T}. \pnum -If the type of \tcode{v} is the same as \tcode{T}, or it is -the same as \tcode{T} except that the class object type in \tcode{T} is -more cv-qualified than the class object type in \tcode{v}, the result is +If the type of \tcode{v} is the same as \tcode{T} (ignoring cv-qualifications), +the result is \tcode{v} (converted if necessary). \pnum @@ -2675,8 +2692,7 @@ \tcode{v} can contain other \tcode{B} objects as base classes, but these are ignored.} In both the pointer and -reference cases, the program is ill-formed if \cvqual{cv2} has greater -cv-qualification than \cvqual{cv1} or if \tcode{B} is an inaccessible or +reference cases, the program is ill-formed if \tcode{B} is an inaccessible or ambiguous base class of \tcode{D}. \begin{example} @@ -2694,7 +2710,7 @@ type\iref{class.virtual}. \pnum -If \tcode{T} is ``pointer to \cvqual{cv} \tcode{void}'', then the result +If \tcode{T} is ``pointer to \cv{} \tcode{void}'', then the result is a pointer to the most derived object pointed to by \tcode{v}. Otherwise, a runtime check is applied to see if the object pointed or referred to by \tcode{v} can be converted to the type pointed or @@ -3110,7 +3126,7 @@ \indextext{cast!reinterpret!pointer to integer}% \indextext{cast!pointer to integer}% A pointer can be explicitly converted to any integral type large enough -to hold it. +to hold all values of its type. \indextext{conversion!implementation-defined pointer integer}% The mapping function is \impldef{mapping of pointer to integer}. \begin{note} @@ -3319,13 +3335,13 @@ \tcode{T2} has a cv-decomposition of the form \begin{indented} -$cv_0^2$ $P_0^2$ $cv_1^2$ $P_1^2$ $\cdots$ $cv_{n-1}^2$ $P_{n-1}^2$ $cv_n^2$ $\mathtt{U}_2$, +$\cv{}_0^2$ $P_0^2$ $\cv{}_1^2$ $P_1^2$ $\cdots$ $\cv{}_{n-1}^2$ $P_{n-1}^2$ $\cv{}_n^2$ $\mathtt{U}_2$, \end{indented} and there is no qualification conversion that converts \tcode{T1} to \begin{indented} -$cv_0^2$ $P_0^1$ $cv_1^2$ $P_1^1$ $\cdots$ $cv_{n-1}^2$ $P_{n-1}^1$ $cv_n^2$ $\mathtt{U}_1$. +$\cv{}_0^2$ $P_0^1$ $\cv{}_1^2$ $P_1^1$ $\cdots$ $\cv{}_{n-1}^2$ $P_{n-1}^1$ $\cv{}_n^2$ $\mathtt{U}_1$. \end{indented} \pnum @@ -3409,7 +3425,7 @@ \begin{note} \indextext{type!incomplete}% Indirection through a pointer to an incomplete type (other than -\cvqual{cv} \tcode{void}) is valid. The lvalue thus obtained can be +\cv{} \tcode{void}) is valid. The lvalue thus obtained can be used in limited ways (to initialize a reference, for example); this lvalue must not be converted to a prvalue, see~\ref{conv.lval}. \end{note} @@ -3570,8 +3586,9 @@ \indextext{expression!\idxcode{sizeof}}% \indextext{operator!\idxcode{sizeof}}% \indextext{byte}% -The \tcode{sizeof} operator yields the number of bytes in the object -representation of its operand. The operand is either an expression, +The \tcode{sizeof} operator yields the number of bytes +occupied by a non-potentially-overlapping object of the type +of its operand. The operand is either an expression, which is an unevaluated operand\iref{expr.prop}, or a parenthesized \grammarterm{type-id}. \indextext{type!incomplete}% @@ -3602,12 +3619,14 @@ \indextext{class object!\idxcode{sizeof}}% When applied to a class, the result is the number of bytes in an object of that class including any padding required for placing objects of that -type in an array. The size of a most derived class shall be greater than -zero\iref{intro.object}. The result of applying \tcode{sizeof} to a -base class subobject is the size of the base class type.\footnote{The actual -size of a base class subobject may be less than the result of +type in an array. +The result of applying \tcode{sizeof} to a +potentially-overlapping subobject is +the size of the type, not the size of the subobject.% +\footnote{The actual size of a potentially-overlapping subobject +may be less than the result of applying \tcode{sizeof} to the subobject, due to virtual base classes -and less strict padding requirements on base class subobjects.} +and less strict padding requirements on potentially-overlapping subobjects.} \indextext{array!\idxcode{sizeof}}% When applied to an array, the result is the total number of bytes in the array. This implies that the size of an array of \term{n} elements is @@ -3627,9 +3646,9 @@ is applied. \pnum -The identifier in a \tcode{sizeof...} expression shall name a parameter -pack. The \tcode{sizeof...} operator yields the number of arguments -provided for the parameter pack \grammarterm{identifier}. +The identifier in a \tcode{sizeof...} expression shall name a +pack. The \tcode{sizeof...} operator yields the number of elements +in the pack\iref{temp.variadic}. A \tcode{sizeof...} expression is a pack expansion\iref{temp.variadic}. \begin{example} @@ -4601,9 +4620,9 @@ Otherwise, the expression \tcode{E1} is sequenced before the expression \tcode{E2}. \pnum -The restrictions on \cvqual{cv-}qualification, and the manner in which -the \cvqual{cv-}qualifiers of the operands are combined to produce the -\cvqual{cv-}qualifiers of the result, are the same as the rules for +The restrictions on cv-qualification, and the manner in which +the cv-qualifiers of the operands are combined to produce the +cv-qualifiers of the result, are the same as the rules for \tcode{E1.E2} given in~\ref{expr.ref}. \begin{note} It is not possible to use a pointer to member that refers to a @@ -5052,27 +5071,27 @@ After conversions, the operands shall have the same type. \pnum -Comparing unequal pointers to objects% +The result of comparing unequal pointers to objects% \footnote{An object that is not an array element is considered to belong to a single-element array for this purpose; see~\ref{expr.unary.op}. A pointer past the last element of an array \tcode{x} of $n$ elements is considered to be equivalent to a pointer to a hypothetical element $\mathtt{x[}n\mathtt{]}$ for this purpose; see~\ref{basic.compound}.} -is defined as follows: +is defined in terms of a partial order consistent with the following rules: \begin{itemize} \item If two pointers point to different elements of the same array, or to subobjects thereof, the pointer to the element with the higher subscript -compares greater. +is required to compare greater. \item If two pointers point to different non-static data members of the same object, or to subobjects of such members, recursively, -the pointer to the later declared member compares greater provided the -two members -have the same access control\iref{class.access} -and provided their class is not a union. +the pointer to the later declared member is required to compare greater provided +the two members have the same access control\iref{class.access}, +neither member is a subobject of zero size, +and their class is not a union. -\item Otherwise, neither pointer compares greater than the other. +\item Otherwise, neither pointer is required to compare greater than the other. \end{itemize} @@ -5376,9 +5395,9 @@ Otherwise, if the second and third operand are glvalue bit-fields of the same value category and of types \cvqual{cv1} \tcode{T} and \cvqual{cv2} \tcode{T}, respectively, -the operands are considered to be of type \cvqual{cv} \tcode{T} +the operands are considered to be of type \cv{} \tcode{T} for the remainder of this subclause, -where \cvqual{cv} is the union of \cvqual{cv1} and \cvqual{cv2}. +where \cv{} is the union of \cvqual{cv1} and \cvqual{cv2}. \pnum Otherwise, if the second and third operand have different types and @@ -5400,7 +5419,7 @@ \item If \tcode{E2} is an lvalue, the target type is ``lvalue reference to \tcode{T2}'', subject to the constraint that in the conversion the reference must bind -directly\iref{dcl.init.ref} to an lvalue. +directly\iref{dcl.init.ref} to a glvalue. \item If \tcode{E2} is an xvalue, the target type is ``rvalue reference to \tcode{T2}'', @@ -5593,8 +5612,8 @@ \end{bnf} \pnum -In simple assignment (\tcode{=}), the value of the expression replaces -that of the object referred to by the left operand. +In simple assignment (\tcode{=}), the result of the right operand replaces +the value of the object referred to by the left operand. \pnum \indextext{assignment!conversion by}% @@ -5897,17 +5916,20 @@ \item a relational\iref{expr.rel} or equality\iref{expr.eq} -operator where the result is unspecified; or +operator where the result is unspecified; \item -a \grammarterm{throw-expression}\iref{expr.throw}. +a \grammarterm{throw-expression}\iref{expr.throw}; or + +\item +an invocation of the \tcode{va_arg} macro\iref{cstdarg.syn}. \end{itemize} If \tcode{e} satisfies the constraints of a core constant expression, but evaluation of \tcode{e} would evaluate an operation that has undefined behavior -as specified in \ref{library} through \ref{\lastlibchapter} of this -document, it is unspecified whether \tcode{e} is a core constant -expression. +as specified in \ref{library} through \ref{\lastlibchapter} of this document, or +an invocation of the \tcode{va_start} macro\iref{cstdarg.syn}, +it is unspecified whether \tcode{e} is a core constant expression. \begin{example} \begin{codeblock} diff --git a/source/future.tex b/source/future.tex index 72c7630fae..5034bc7371 100644 --- a/source/future.tex +++ b/source/future.tex @@ -87,7 +87,7 @@ The header \tcode{} and the header \tcode{} shall not define a macro named \tcode{alignas}. -\xref ISO C 7.15 +\xrefc{7.15} \rSec2[depr.cstdbool.syn]{Header \tcode{} synopsis} @@ -104,7 +104,7 @@ The header \tcode{} and the header \tcode{} shall not define macros named \tcode{bool}, \tcode{true}, or \tcode{false}. -\xref ISO C 7.18 +\xrefc{7.18} \rSec2[depr.ctgmath.syn]{Header \tcode{} synopsis} @@ -130,7 +130,7 @@ For compatibility with the \indextext{library!C standard}% C standard library, the \Cpp{} standard library provides -the \defnx{C headers}{headers!C library} shown in Table~\ref{tab:future.c.headers}. +the \defnx{C headers}{headers!C library} shown in \tref{future.c.headers}. \begin{floattable}{C headers}{tab:future.c.headers} {lllll} @@ -239,7 +239,7 @@ \begin{itemdescr} \pnum \requires -Type \tcode{T} is \tcode{EqualityComparable} (Table~\ref{tab:equalitycomparable}). +Type \tcode{T} is \tcode{EqualityComparable} (\tref{equalitycomparable}). \pnum \returns @@ -254,7 +254,7 @@ \begin{itemdescr} \pnum \requires -Type \tcode{T} is \tcode{LessThanComparable} (Table~\ref{tab:lessthancomparable}). +Type \tcode{T} is \tcode{LessThanComparable} (\tref{lessthancomparable}). \pnum \returns @@ -269,7 +269,7 @@ \begin{itemdescr} \pnum \requires -Type \tcode{T} is \tcode{LessThanComparable} (Table~\ref{tab:lessthancomparable}). +Type \tcode{T} is \tcode{LessThanComparable} (\tref{lessthancomparable}). \pnum \returns @@ -284,7 +284,7 @@ \begin{itemdescr} \pnum \requires -Type \tcode{T} is \tcode{LessThanComparable} (Table~\ref{tab:lessthancomparable}). +Type \tcode{T} is \tcode{LessThanComparable} (\tref{lessthancomparable}). \pnum \returns @@ -293,13 +293,24 @@ \rSec1[depr.str.strstreams]{\tcode{char*} streams} +\rSec2[depr.strstream.syn]{Header \tcode{} synopsis} + \pnum The header \indexhdr{strstream}% \tcode{} -defines three types that associate stream buffers with +defines types that associate stream buffers with character array objects and assist reading and writing such objects. +\begin{codeblock} +namespace std { + class strstreambuf; + class istrstream; + class ostrstream; + class strstream; +} +\end{codeblock} + \rSec2[depr.strstreambuf]{Class \tcode{strstreambuf}} \indexlibrary{\idxcode{strstreambuf}}% @@ -426,7 +437,7 @@ \tcode{strstreambuf}, initializing the base class with \tcode{streambuf()}. -The postconditions of this function are indicated in Table~\ref{tab:future.strstreambuf.effects}. +The postconditions of this function are indicated in \tref{future.strstreambuf.effects}. \end{itemdescr} \begin{libtab2}{\tcode{strstreambuf(streamsize)} effects}{tab:future.strstreambuf.effects} @@ -450,7 +461,7 @@ \tcode{strstreambuf}, initializing the base class with \tcode{streambuf()}. -The postconditions of this function are indicated in Table~\ref{tab:future.strstreambuf1.effects}. +The postconditions of this function are indicated in \tref{future.strstreambuf1.effects}. \begin{libtab2}{\tcode{strstreambuf(void* (*)(size_t), void (*)(void*))} effects} {tab:future.strstreambuf1.effects} @@ -480,7 +491,7 @@ \tcode{strstreambuf}, initializing the base class with \tcode{streambuf()}. -The postconditions of this function are indicated in Table~\ref{tab:future.strstreambuf2.effects}. +The postconditions of this function are indicated in \tref{future.strstreambuf2.effects}. \begin{libtab2}{\tcode{strstreambuf(charT*, streamsize, charT*)} effects} {tab:future.strstreambuf2.effects} @@ -809,7 +820,7 @@ \pnum \effects Alters the stream position within one of the -controlled sequences, if possible, as indicated in Table~\ref{tab:future.seekoff.positioning}. +controlled sequences, if possible, as indicated in \tref{future.seekoff.positioning}. \begin{libtab2}{\tcode{seekoff} positioning}{tab:future.seekoff.positioning} {p{2.5in}l}{Conditions}{Result} @@ -832,7 +843,7 @@ For a sequence to be positioned, if its next pointer is a null pointer, the positioning operation fails. Otherwise, the function determines \tcode{newoff} as indicated in -Table~\ref{tab:future.newoff.values}. +\tref{future.newoff.values}. \begin{libtab2}{\tcode{newoff} values}{tab:future.newoff.values} {p{2.0in}p{2.0in}}{Condition}{\tcode{newoff} Value} @@ -2148,7 +2159,7 @@ \begin{codeblock} namespace std { template struct is_literal_type; - template constexpr bool is_literal_type_v = is_literal_type::value; + template inline constexpr bool is_literal_type_v = is_literal_type::value; template struct result_of; // not defined template struct result_of; @@ -2539,6 +2550,36 @@ The weak form may fail spuriously. See~\ref{atomics.types.operations}. \end{itemdescr} +\rSec1[depr.string.capacity]{Deprecated \tcode{basic_string} capacity} + +\pnum +The following member is declared in addition to those members specified +in \ref{string.capacity}: + +\indexlibrary{\idxcode{basic_string}}% +\begin{codeblock} +namespace std { + template, + class Allocator = allocator> + class basic_string { + public: + void reserve(); + }; +} +\end{codeblock} + +\indexlibrarymember{reserve}{basic_string}% +\begin{itemdecl} +void reserve(); +\end{itemdecl} + +\begin{itemdescr} +\pnum\effects +After this call, \tcode{capacity()} has an unspecified value +greater than or equal to \tcode{size()}. +\begin{note} This is a non-binding shrink to fit request. \end{note} +\end{itemdescr} + \rSec1[depr.locale.stdcvt]{Deprecated standard code conversion facets} \pnum @@ -2974,7 +3015,7 @@ described by the class \tcode{Tr}, to and from a byte stream buffer of type \tcode{streambuf}. Conversion between a sequence of \tcode{Elem} values and multibyte sequences is performed by an object of class -\tcode{Codecvt}, which shall meet the requirements +\tcode{Codecvt}, which shall satisfy the requirements of the standard code-conversion facet \tcode{codecvt}. \pnum diff --git a/source/intro.tex b/source/intro.tex index 1f46914c2e..d8d103fff0 100644 --- a/source/intro.tex +++ b/source/intro.tex @@ -35,8 +35,18 @@ \begin{itemize} \item Ecma International, \doccite{ECMAScript Language Specification}, Standard Ecma-262, third edition, 1999. +%%% Format for this entry is based on that specified at +%%% http://www.iec.ch/standardsdev/resources/draftingpublications/directives/principles/referencing.htm +\item INTERNET ENGINEERING TASK FORCE (IETF). RFC 6557: +Procedures for Maintaining the Time Zone Database [online]. +Edited by E. Lear, P. Eggert. +February 2012 [viewed 2018-03-26]. +Available at +\url{https://www.ietf.org/rfc/rfc6557.txt} \item ISO/IEC 2382 (all parts), \doccite{Information technology --- Vocabulary} +\item ISO 8601:2004, \doccite{Data elements and interchange formats --- +Information interchange --- Representation of dates and times} \item ISO/IEC 9899:2011, \doccite{Programming languages --- C} \item ISO/IEC 9945:2003, \doccite{Information Technology --- Portable Operating System Interface (POSIX)} @@ -483,8 +493,8 @@ \pnum Certain other aspects and operations of the abstract machine are described in this document as unspecified (for example, -evaluation of expressions in a \grammarterm{new-initializer} if the allocation -function fails to allocate memory\iref{expr.new}). Where possible, this +order of evaluation of arguments in a function call\iref{expr.call}). +Where possible, this document defines a set of allowable behaviors. These define the nondeterministic aspects of the abstract machine. An instance of the abstract machine can thus have more than one possible execution diff --git a/source/iostreams.tex b/source/iostreams.tex index b45083a4ef..2b5561d511 100644 --- a/source/iostreams.tex +++ b/source/iostreams.tex @@ -18,7 +18,7 @@ stream formatting and manipulators, string streams, and file streams, -as summarized in Table~\ref{tab:iostreams.lib.summary}. +as summarized in \tref{iostreams.lib.summary}. \begin{libsumtab}{Input/output library summary}{tab:iostreams.lib.summary} \ref{iostreams.requirements} & Requirements & \\ \rowsep @@ -449,7 +449,7 @@ \pnum Concurrent access to a synchronized\iref{ios.members.static} standard iostream object's formatted and unformatted input\iref{istream} and output\iref{ostream} functions or a standard C stream by multiple threads shall not result in a data race\iref{intro.multithread}. \begin{note} Users must still synchronize concurrent use of these objects and streams by multiple threads if they wish to avoid interleaved characters. \end{note} -\xref ISO C 7.21.2 +\xrefc{7.21.2} \rSec2[narrow.stream.objects]{Narrow stream objects} @@ -728,19 +728,7 @@ integral types. It is used to represent the number of characters transferred in an I/O operation, or the size of I/O buffers.\footnote{\tcode{streamsize} -is used in most places where ISO C would use -\tcode{size_t}. -Most of the uses of -\tcode{streamsize} -could use -\tcode{size_t}, -except for the -\tcode{strstreambuf} -constructors, which require negative values. -It should probably be the signed type corresponding to -\tcode{size_t} -(which is what Posix.2 calls -\tcode{ssize_t}).} +is used in most places where ISO C would use \tcode{size_t}.} \end{itemdescr} \rSec2[ios.base]{Class \tcode{ios_base}} @@ -814,16 +802,16 @@ // \ref{ios.base.storage}, storage static int xalloc(); - long& iword(int index); - void*& pword(int index); + long& iword(int idx); + void*& pword(int idx); // destructor virtual ~ios_base(); // \ref{ios.base.callback}, callbacks enum event { erase_event, imbue_event, copyfmt_event }; - using event_callback = void (*)(event, ios_base&, int index); - void register_callback(event_callback fn, int index); + using event_callback = void (*)(event, ios_base&, int idx); + void register_callback(event_callback fn, int idx); ios_base(const ios_base&) = delete; ios_base& operator=(const ios_base&) = delete; @@ -967,7 +955,7 @@ The type \tcode{fmtflags} is a bitmask type\iref{bitmask.types}. -Setting its elements has the effects indicated in Table~\ref{tab:iostreams.fmtflags.effects}. +Setting its elements has the effects indicated in \tref{iostreams.fmtflags.effects}. \begin{libefftab}{\tcode{fmtflags} effects}{tab:iostreams.fmtflags.effects} \tcode{boolalpha} & @@ -1006,7 +994,7 @@ \pnum Type \tcode{fmtflags} -also defines the constants indicated in Table~\ref{tab:iostreams.fmtflags.constants}. +also defines the constants indicated in \tref{iostreams.fmtflags.constants}. \begin{floattable}{\tcode{fmtflags} constants}{tab:iostreams.fmtflags.constants} {ll} @@ -1030,7 +1018,7 @@ The type \tcode{iostate} is a bitmask type\iref{bitmask.types} -that contains the elements indicated in Table~\ref{tab:iostreams.iostate.effects}. +that contains the elements indicated in \tref{iostreams.iostate.effects}. \begin{libefftab}{\tcode{iostate} effects}{tab:iostreams.iostate.effects} \tcode{badbit} & @@ -1066,7 +1054,7 @@ The type \tcode{openmode} is a bitmask type\iref{bitmask.types}. -It contains the elements indicated in Table~\ref{tab:iostreams.openmode.effects}. +It contains the elements indicated in \tref{iostreams.openmode.effects}. \begin{libefftab}{\tcode{openmode} effects}{tab:iostreams.openmode.effects} \tcode{app} & @@ -1096,7 +1084,7 @@ The type \tcode{seekdir} is an enumerated type\iref{enumerated.types} -that contains the elements indicated in Table~\ref{tab:iostreams.seekdir.effects}. +that contains the elements indicated in \tref{iostreams.seekdir.effects}. \begin{libefftabmean}{\tcode{seekdir} effects}{tab:iostreams.seekdir.effects} \tcode{beg} & @@ -1327,9 +1315,9 @@ \pnum \effects Calls each registered callback pair -\tcode{(fn, index)}\iref{ios.base.callback} +\tcode{(fn, idx)}\iref{ios.base.callback} as -\tcode{(*fn)(imbue_event, *this, index)} +\tcode{(*fn)(imbue_event, *this, idx)} at such a time that a call to \tcode{ios_base::getloc()} from within @@ -1542,14 +1530,14 @@ \indexlibrarymember{register_callback}{ios_base}% \begin{itemdecl} -void register_callback(event_callback fn, int index); +void register_callback(event_callback fn, int idx); \end{itemdecl} \begin{itemdescr} \pnum \effects Registers the pair -\tcode{(fn, index)} +\tcode{(fn, idx)} such that during calls to \tcode{imbue()}\iref{ios.base.locales}, \tcode{copyfmt()}, @@ -1558,7 +1546,7 @@ the function \tcode{fn} is called with argument -\tcode{index}. +\tcode{idx}. Functions registered are called when an event occurs, in opposite order of registration. Functions registered while a callback function is active are not called until the next event. @@ -1605,8 +1593,8 @@ Destroys an object of class \tcode{ios_base}. Calls each registered callback pair -\tcode{(fn, index)}\iref{ios.base.callback} as -\tcode{(*fn)(\brk{}erase_event, *this, index)} +\tcode{(fn, idx)}\iref{ios.base.callback} as +\tcode{(*fn)(\brk{}erase_event, *this, idx)} at such time that any \tcode{ios_base} member function called from within @@ -1659,7 +1647,7 @@ \pnum \indexlibrary{\idxcode{fpos}}% \indexlibrary{\idxcode{streamoff}}% -Operations specified in Table~\ref{tab:iostreams.position.requirements} are permitted. +Operations specified in \tref{iostreams.position.requirements} are permitted. In that table, \begin{itemize} \item \tcode{P} refers to an instance of \tcode{fpos}, @@ -1876,7 +1864,7 @@ \begin{itemdescr} \pnum \postconditions -The postconditions of this function are indicated in Table~\ref{tab:iostreams.basicios.init.effects}. +The postconditions of this function are indicated in \tref{iostreams.basicios.init.effects}. \begin{libefftabvalue}{\tcode{basic_ios::init()} effects}{tab:iostreams.basicios.init.effects} \tcode{rdbuf()} & @@ -2063,8 +2051,8 @@ the corresponding member objects of \tcode{rhs} as follows: \begin{itemize} -\item calls each registered callback pair \tcode{(fn, index)} as -\tcode{(*fn)(erase_event, *this, index)}; +\item calls each registered callback pair \tcode{(fn, idx)} as +\tcode{(*fn)(erase_event, *this, idx)}; \item then, assigns to the member objects of \tcode{*this} the corresponding member objects of \tcode{rhs}, except that @@ -2084,7 +2072,7 @@ \end{itemize} \item then, calls each callback pair that was copied from \tcode{rhs} as -\tcode{(*fn)(copyfmt_event, *this, index)}; +\tcode{(*fn)(copyfmt_event, *this, idx)}; \item then, calls \tcode{exceptions(rhs.exceptions())}. @@ -2099,7 +2087,7 @@ \pnum \postconditions -The postconditions of this function are indicated in Table~\ref{tab:iostreams.copyfmt.effects}. +The postconditions of this function are indicated in \tref{iostreams.copyfmt.effects}. \begin{LibEffTab}{\tcode{basic_ios::copyfmt()} effects} @@ -2348,6 +2336,10 @@ \rSec3[fmtflags.manip]{\tcode{fmtflags} manipulators} +\pnum +Each function specified in this subclause +is a designated addressable function\iref{namespace.std}. + \indexlibrary{\idxcode{boolalpha}}% \begin{itemdecl} ios_base& boolalpha(ios_base& str); @@ -2574,6 +2566,10 @@ \rSec3[adjustfield.manip]{\tcode{adjustfield} manipulators} +\pnum +Each function specified in this subclause +is a designated addressable function\iref{namespace.std}. + \indexlibrary{\idxcode{internal}}% \begin{itemdecl} ios_base& internal(ios_base& str); @@ -2624,6 +2620,10 @@ \rSec3[basefield.manip]{\tcode{basefield} manipulators} +\pnum +Each function specified in this subclause +is a designated addressable function\iref{namespace.std}. + \indexlibrary{\idxcode{dec}}% \begin{itemdecl} ios_base& dec(ios_base& str); @@ -2682,6 +2682,10 @@ \rSec3[floatfield.manip]{\tcode{floatfield} manipulators} +\pnum +Each function specified in this subclause +is a designated addressable function\iref{namespace.std}. + \indexlibrary{\idxcode{fixed}}% \begin{itemdecl} ios_base& fixed(ios_base& str); @@ -2747,7 +2751,7 @@ \returns \tcode{str}. \end{itemdescr} -\rSec3[error.reporting]{Error reporting} +\rSec2[error.reporting]{Error reporting} \indexlibrarymember{make_error_code}{io_errc}% \begin{itemdecl} @@ -4089,6 +4093,13 @@ template basic_ostream& flush(basic_ostream& os); + template + basic_ostream& emit_on_flush(basic_ostream& os); + template + basic_ostream& noemit_on_flush(basic_ostream& os); + template + basic_ostream& flush_emit(basic_ostream& os); + template basic_ostream& operator<<(basic_ostream&& os, const T& x); } @@ -4484,7 +4495,8 @@ During preparation, the constructor may call \tcode{setstate(failbit)} (which may throw -\tcode{ios_base::\brk{}failure}\iref{iostate.flags})\footnote{The sentry +\tcode{ios_base::\brk{}failure}\iref{iostate.flags})\footnote{The +\tcode{sentry} constructor and destructor can also perform additional \indextext{implementation-dependent}% @@ -5356,11 +5368,11 @@ If \tcode{rdbuf()} is not null, calls -\tcode{rdbuf->sputbackc()}. +\tcode{rdbuf()->sputbackc(c)}. If \tcode{rdbuf()} is null, or if -\tcode{sputbackc()} +\tcode{sputbackc} returns \tcode{traits::eof()}, calls @@ -5402,7 +5414,7 @@ If \tcode{rdbuf()} is null, or if -\tcode{sungetc()} +\tcode{sungetc} returns \tcode{traits::eof()}, calls @@ -5526,6 +5538,11 @@ \rSec3[istream.manip]{Standard \tcode{basic_istream} manipulators} +\pnum +Each instantiation of the function template +specified in this subclause +is a designated addressable function\iref{namespace.std}. + \indexlibrary{\idxcode{ws}}% \begin{itemdecl} template @@ -5976,6 +5993,7 @@ \tcode{sentry} constructor and destructor can also perform additional +\indextext{implementation-dependent}% implementation-dependent operations.} \end{itemdescr} @@ -6597,6 +6615,11 @@ \rSec3[ostream.manip]{Standard \tcode{basic_ostream} manipulators} +\pnum +Each instantiation of any of the function templates +specified in this subclause +is a designated addressable function\iref{namespace.std}. + \indexlibrary{\idxcode{endl}}% \begin{itemdecl} template @@ -6651,6 +6674,72 @@ \tcode{os}. \end{itemdescr} +\indexlibrary{\idxcode{emit_on_flush}}% +\begin{itemdecl} +template + basic_ostream& emit_on_flush(basic_ostream& os); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +If \tcode{os.rdbuf()} is a +\tcode{basic_syncbuf*}, +called \tcode{buf} for the purpose of exposition, +calls \tcode{buf->set_emit_on_sync(true)}. +Otherwise this manipulator has no effect. +\begin{note} +To work around the issue that the +\tcode{Allocator} template argument cannot be deduced, +implementations can introduce an intermediate base class +to \tcode{basic_syncbuf} that manages its \tcode{emit_on_sync} flag. +\end{note} + +\pnum +\returns +\tcode{os}. +\end{itemdescr} + +\indexlibrary{\idxcode{noemit_on_flush}}% +\begin{itemdecl} +template + basic_ostream& noemit_on_flush(basic_ostream& os); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +If \tcode{os.rdbuf()} is a +\tcode{basic_syncbuf*}, +called \tcode{buf} for the purpose of exposition, +calls \tcode{buf->set_emit_on_sync(false)}. +Otherwise this manipulator has no effect. + +\pnum +\returns +\tcode{os}. +\end{itemdescr} + +\indexlibrary{\idxcode{flush_emit}}% +\begin{itemdecl} +template + basic_ostream& flush_emit(basic_ostream& os); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Calls \tcode{os.flush()}. +Then, if \tcode{os.rdbuf()} is a +\tcode{basic_syncbuf*}, +called \tcode{buf} for the purpose of exposition, +calls \tcode{buf->emit()}. + +\pnum +\returns +\tcode{os}. +\end{itemdescr} + \rSec3[ostream.rvalue]{Rvalue stream insertion} \indexlibrarymember{operator<<}{basic_ostream}% @@ -7658,7 +7747,7 @@ \pnum \effects Alters the stream position within one of the -controlled sequences, if possible, as indicated in Table~\ref{tab:iostreams.seekoff.positioning}. +controlled sequences, if possible, as indicated in \tref{iostreams.seekoff.positioning}. \begin{libtab2}{\tcode{seekoff} positioning}{tab:iostreams.seekoff.positioning} {p{2.5in}l}{Conditions}{Result} @@ -7681,7 +7770,7 @@ \pnum For a sequence to be positioned, the function determines \tcode{newoff} as indicated in -Table~\ref{tab:iostreams.newoff.values}. +\tref{iostreams.newoff.values}. If the sequence's next pointer (either \tcode{gptr()} @@ -8660,7 +8749,7 @@ \indexlibrary{\idxcode{fopen}}% The \ntbs{} \tcode{modstr} is determined from \tcode{mode \& \~{}ios_base::ate} -as indicated in Table~\ref{tab:iostreams.file.open.modes}. +as indicated in \tref{iostreams.file.open.modes}. If \tcode{mode} is not some combination of flags shown in the table then the open fails. @@ -9049,7 +9138,7 @@ The function determines one of three values for the argument \tcode{whence}, of type \tcode{int}, -as indicated in Table~\ref{tab:iostreams.seekoff.effects}. +as indicated in \tref{iostreams.seekoff.effects}. \begin{libtab2}{\tcode{seekoff} effects}{tab:iostreams.seekoff.effects} {ll}{\tcode{way} Value}{\tcode{stdio} Equivalent} @@ -9941,6 +10030,8 @@ \indexlibrary{\idxcode{osyncstream}}% \indexlibrary{\idxcode{wosyncstream}}% \begin{codeblock} +#include // see \ref{ostream.syn} + namespace std { template class basic_syncbuf; @@ -10063,7 +10154,7 @@ \begin{itemdescr} \pnum \effects -Move constructs from \tcode{other} (Table~\ref{tab:moveconstructible}). +Move constructs from \tcode{other} (\tref{moveconstructible}). \pnum \postconditions @@ -10327,7 +10418,8 @@ \end{codeblock} \pnum -\tcode{Allocator} shall meet the allocator requirements\iref{allocator.requirements}. +\tcode{Allocator} shall satisfy the \tcode{Allocator} requirements +(\tref{utilities.allocator.requirements}). \pnum \begin{example} @@ -10657,7 +10749,7 @@ unless \tcode{EcharT} is one of the encoded character types. \pnum -Template parameters named \tcode{InputIterator} shall meet the +Template parameters named \tcode{InputIterator} shall satisfy the input iterator requirements\iref{input.iterators} and shall have a value type that is one of the encoded character types. @@ -10669,8 +10761,8 @@ they are not included as permitted types. \end{note} \pnum -Template parameters named \tcode{Allocator} shall meet the -Allocator requirements\iref{allocator.requirements}. +Template parameters named \tcode{Allocator} shall satisfy the +\tcode{Allocator} requirements (\tref{utilities.allocator.requirements}). \rSec3[fs.req.namespace]{Namespaces and headers} @@ -10699,14 +10791,6 @@ path operator/ (const path& lhs, const path& rhs); - // \ref{fs.path.io}, \tcode{path} inserter and extractor - template - basic_ostream& - operator<<(basic_ostream& os, const path& p); - template - basic_istream& - operator>>(basic_istream& is, path& p); - // \ref{fs.path.factory}, \tcode{path} factory functions template path u8path(const Source& source); @@ -10749,7 +10833,7 @@ enum class copy_options; enum class directory_options; - using file_time_type = chrono::time_point<@\textit{trivial-clock}@>; + using file_time_type = chrono::time_point; // \ref{fs.op.funcs}, filesystem operations path absolute(const path& p); @@ -10759,23 +10843,23 @@ path canonical(const path& p, error_code& ec); void copy(const path& from, const path& to); - void copy(const path& from, const path& to, error_code& ec) noexcept; + void copy(const path& from, const path& to, error_code& ec); void copy(const path& from, const path& to, copy_options options); void copy(const path& from, const path& to, copy_options options, - error_code& ec) noexcept; + error_code& ec); bool copy_file(const path& from, const path& to); - bool copy_file(const path& from, const path& to, error_code& ec) noexcept; + bool copy_file(const path& from, const path& to, error_code& ec); bool copy_file(const path& from, const path& to, copy_options option); bool copy_file(const path& from, const path& to, copy_options option, - error_code& ec) noexcept; + error_code& ec); void copy_symlink(const path& existing_symlink, const path& new_symlink); void copy_symlink(const path& existing_symlink, const path& new_symlink, error_code& ec) noexcept; bool create_directories(const path& p); - bool create_directories(const path& p, error_code& ec) noexcept; + bool create_directories(const path& p, error_code& ec); bool create_directory(const path& p); bool create_directory(const path& p, error_code& ec) noexcept; @@ -10827,7 +10911,7 @@ bool is_directory(const path& p, error_code& ec) noexcept; bool is_empty(const path& p); - bool is_empty(const path& p, error_code& ec) noexcept; + bool is_empty(const path& p, error_code& ec); bool is_fifo(file_status s) noexcept; bool is_fifo(const path& p); @@ -10874,7 +10958,7 @@ bool remove(const path& p, error_code& ec) noexcept; uintmax_t remove_all(const path& p); - uintmax_t remove_all(const path& p, error_code& ec) noexcept; + uintmax_t remove_all(const path& p, error_code& ec); void rename(const path& from, const path& to); void rename(const path& from, const path& to, error_code& ec) noexcept; @@ -11156,6 +11240,14 @@ iterator begin() const; iterator end() const; + + // \ref{fs.path.io}, \tcode{path} inserter and extractor + template + friend basic_ostream& + operator<<(basic_ostream& os, const path& p); + template + friend basic_istream& + operator>>(basic_istream& is, path& p); }; } \end{codeblock} @@ -12581,6 +12673,45 @@ \returns The end iterator. \end{itemdescr} +\rSec3[fs.path.io]{\tcode{path} inserter and extractor} + +\indexlibrarymember{operator<<}{path}% +\begin{itemdecl} +template + friend basic_ostream& + operator<<(basic_ostream& os, const path& p); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects Equivalent to \tcode{os << quoted(p.string())}. +\begin{note} The \tcode{quoted} function is described in~\ref{quoted.manip}. \end{note} + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{operator>>}{path}% +\begin{itemdecl} +template + friend basic_istream& + operator>>(basic_istream& is, path& p); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Equivalent to: +\begin{codeblock} +basic_string tmp; +is >> quoted(tmp); +p = tmp; +\end{codeblock} + +\pnum +\returns \tcode{is}. +\end{itemdescr} + \rSec3[fs.path.nonmember]{\tcode{path} non-member functions} \indexlibrary{\idxcode{swap}!\idxcode{path}}% @@ -12658,7 +12789,7 @@ \begin{note} Path equality and path equivalence have different semantics. \begin{itemize} \item Equality is determined by the \tcode{path} non-member \tcode{operator==}, -which considers the two path's lexical representations only. +which considers the two paths' lexical representations only. \begin{example} \tcode{path("foo") == "bar"} is never \tcode{true}. \end{example} \item Equivalence is determined by the \tcode{equivalent()} non-member function, which determines if two paths resolve\iref{fs.class.path} to the same file system entity. @@ -12691,45 +12822,6 @@ \effects Equivalent to: \tcode{return path(lhs) /= rhs;} \end{itemdescr} -\rSec4[fs.path.io]{\tcode{path} inserter and extractor} - -\indexlibrarymember{operator<<}{path}% -\begin{itemdecl} -template - basic_ostream& - operator<<(basic_ostream& os, const path& p); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects Equivalent to \tcode{os << quoted(p.string())}. -\begin{note} The \tcode{quoted} function is described in~\ref{quoted.manip}. \end{note} - -\pnum -\returns \tcode{os}. -\end{itemdescr} - -\indexlibrarymember{operator>>}{path}% -\begin{itemdecl} -template - basic_istream& - operator>>(basic_istream& is, path& p); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects -Equivalent to: -\begin{codeblock} -basic_string tmp; -is >> quoted(tmp); -p = tmp; -\end{codeblock} - -\pnum -\returns \tcode{is}. -\end{itemdescr} - \rSec4[fs.path.factory]{\tcode{path} factory functions} \indexlibrary{\idxcode{u8path}}% @@ -12831,19 +12923,13 @@ \begin{itemdescr} \pnum -\postconditions The postconditions of this function are indicated in -Table~\ref{tab:filesystem_error.1}. - -\begin{floattable} -{\tcode{filesystem_error(const string\&, error_code)} effects}{tab:filesystem_error.1} -{ll} -\topline -\lhdr{Expression} & \rhdr{Value} \\ \capsep -\tcode{runtime_error::what()} & \tcode{what_arg.c_str()} \\ \rowsep -\tcode{code()} & \tcode{ec} \\ \rowsep -\tcode{path1().empty()} & \tcode{true} \\ \rowsep -\tcode{path2().empty()} & \tcode{true} \\ \rowsep -\end{floattable} +\postconditions +\begin{itemize} +\item \tcode{code() == ec}, +\item \tcode{path1().empty() == true}, +\item \tcode{path2().empty() == true}, and +\item \tcode{string_view(what()).find(what_arg)} \tcode{!= string_view::npos}. +\end{itemize} \end{itemdescr} \indexlibrary{\idxcode{filesystem_error}!constructor}% @@ -12853,19 +12939,13 @@ \begin{itemdescr} \pnum -\postconditions The postconditions of this function are indicated in -Table~\ref{tab:filesystem_error.2}. - -\begin{floattable} -{\tcode{filesystem_error(const string\&, const path\&, error_code)} effects}{tab:filesystem_error.2} -{ll} -\topline -\lhdr{Expression} & \rhdr{Value} \\ \capsep -\tcode{runtime_error::what()} & \tcode{what_arg.c_str()} \\ \rowsep -\tcode{code()} & \tcode{ec} \\ \rowsep -\tcode{path1()} & Reference to stored copy of \tcode{p1} \\ \rowsep -\tcode{path2().empty()} & \tcode{true} \\ \rowsep -\end{floattable} +\postconditions +\begin{itemize} +\item \tcode{code() == ec}, +\item \tcode{path1()} returns a reference to the stored copy of \tcode{p1}, +\item \tcode{path2().empty() == true}, and +\item \tcode{string_view(what()).find(what_arg)} \tcode{!= string_view::npos}. +\end{itemize} \end{itemdescr} \indexlibrary{\idxcode{filesystem_error}!constructor}% @@ -12875,19 +12955,13 @@ \begin{itemdescr} \pnum -\postconditions The postconditions of this function are indicated in -Table~\ref{tab:filesystem_error.3}. - -\begin{floattable} -{\tcode{filesystem_error(const string\&, const path\&, const path\&, error_code)} effects}{tab:filesystem_error.3} -{ll} -\topline -\lhdr{Expression} & \rhdr{Value} \\ \capsep -\tcode{runtime_error::what()} & \tcode{what_arg.c_str()} \\ \rowsep -\tcode{code()} & \tcode{ec} \\ \rowsep -\tcode{path1()} & Reference to stored copy of \tcode{p1} \\ \rowsep -\tcode{path2()} & Reference to stored copy of \tcode{p2} \\ \rowsep -\end{floattable} +\postconditions +\begin{itemize} +\item \tcode{code() == ec}, +\item \tcode{path1()} returns a reference to the stored copy of \tcode{p1}, +\item \tcode{path2()} returns a reference to the stored copy of \tcode{p2}, and +\item \tcode{string_view(what()).find(what_arg)} \tcode{!= string_view::npos}. +\end{itemize} \end{itemdescr} \indexlibrarymember{path1}{filesystem_error}% @@ -12919,7 +12993,9 @@ \begin{itemdescr} \pnum -\returns A string containing \tcode{runtime_error::what()}. The exact format is unspecified. +\returns An \ntbs{} that incorporates + the \tcode{what_arg} argument supplied to the constructor. + The exact format is unspecified. Implementations should include the \tcode{system_error::what()} string and the pathnames of \tcode{path1} and \tcode{path2} @@ -12932,7 +13008,7 @@ \pnum This enum specifies constants used to identify the format of the character -sequence, with the meanings listed in Table~\ref{tab:enum.path.format}. +sequence, with the meanings listed in \tref{enum.path.format}. \begin{floattable} {Enum \tcode{path::format}}{tab:enum.path.format}{lp{4in}} @@ -12956,7 +13032,8 @@ \indexlibrary{\idxcode{file_type}}% \pnum This enum class specifies constants used to identify file types, -with the meanings listed in Table~\ref{tab:fs.enum.file_type}. +with the meanings listed in \tref{fs.enum.file_type}. +The values of the constants are distinct. \begin{floattable} {Enum class \tcode{file_type}}{tab:fs.enum.file_type} @@ -12998,9 +13075,11 @@ \pnum The \tcode{enum class} type \tcode{copy_options} is a bitmask type\iref{bitmask.types} that specifies bitmask constants used to control the semantics of -copy operations. The constants are specified in option groups with the meanings listed in Table~\ref{tab:fs.enum.copy_options}. -Constant \tcode{none} is shown in each option group for purposes of exposition; +copy operations. The constants are specified in option groups with the meanings listed in \tref{fs.enum.copy_options}. +The constant \tcode{none} represents the empty bitmask, and +is shown in each option group for purposes of exposition; implementations shall provide only a single definition. +Every other constant in the table represents a distinct bitmask element. \begin{floattable} {Enum class \tcode{copy_options}}{tab:fs.enum.copy_options} @@ -13053,7 +13132,7 @@ \pnum The \tcode{enum class} type \tcode{perms} is a bitmask type\iref{bitmask.types} that specifies bitmask constants used to identify file -permissions, with the meanings listed in Table~\ref{tab:fs.enum.perms}. +permissions, with the meanings listed in \tref{fs.enum.perms}. \begin{floattable} {Enum class \tcode{perms}}{tab:fs.enum.perms} @@ -13113,9 +13192,9 @@ The \tcode{enum class} type \tcode{perm_options} is a bitmask type\iref{bitmask.types} that specifies bitmask constants used to control the semantics of permissions operations, -with the meanings listed in Table~\ref{tab:enum.perm_options}. +with the meanings listed in \tref{enum.perm_options}. The bitmask constants are bitmask elements. -In Table~\ref{tab:enum.perm_options} \tcode{perm} denotes a value of type \tcode{perms} +In \tref{enum.perm_options} \tcode{perm} denotes a value of type \tcode{perms} passed to \tcode{permissions}. \begin{floattable} @@ -13143,7 +13222,9 @@ \pnum The \tcode{enum class} type \tcode{directory_options} is a bitmask type\iref{bitmask.types} that specifies bitmask constants used to identify - directory traversal options, with the meanings listed in Table~\ref{tab:fs.enum.directory_options}. + directory traversal options, with the meanings listed in \tref{fs.enum.directory_options}. + The constant \tcode{none} represents the empty bitmask; + every other constant in the table represents a distinct bitmask element. \begin{floattable} {Enum class \tcode{directory_options}}{tab:fs.enum.directory_options} @@ -13763,9 +13844,9 @@ directory_iterator() noexcept; explicit directory_iterator(const path& p); directory_iterator(const path& p, directory_options options); - directory_iterator(const path& p, error_code& ec) noexcept; + directory_iterator(const path& p, error_code& ec); directory_iterator(const path& p, directory_options options, - error_code& ec) noexcept; + error_code& ec); directory_iterator(const directory_iterator& rhs); directory_iterator(directory_iterator&& rhs) noexcept; ~directory_iterator(); @@ -13776,7 +13857,7 @@ const directory_entry& operator*() const; const directory_entry* operator->() const; directory_iterator& operator++(); - directory_iterator& increment(error_code& ec) noexcept; + directory_iterator& increment(error_code& ec); // other members as required by \ref{input.iterators}, input iterators }; @@ -13860,8 +13941,8 @@ \begin{itemdecl} explicit directory_iterator(const path& p); directory_iterator(const path& p, directory_options options); -directory_iterator(const path& p, error_code& ec) noexcept; -directory_iterator(const path& p, directory_options options, error_code& ec) noexcept; +directory_iterator(const path& p, error_code& ec); +directory_iterator(const path& p, directory_options options, error_code& ec); \end{itemdecl} \begin{itemdescr} @@ -13920,7 +14001,7 @@ \indexlibrarymember{operator++}{directory_iterator}% \begin{itemdecl} directory_iterator& operator++(); -directory_iterator& increment(error_code& ec) noexcept; +directory_iterator& increment(error_code& ec); \end{itemdecl} \begin{itemdescr} @@ -13986,8 +14067,8 @@ explicit recursive_directory_iterator(const path& p); recursive_directory_iterator(const path& p, directory_options options); recursive_directory_iterator(const path& p, directory_options options, - error_code& ec) noexcept; - recursive_directory_iterator(const path& p, error_code& ec) noexcept; + error_code& ec); + recursive_directory_iterator(const path& p, error_code& ec); recursive_directory_iterator(const recursive_directory_iterator& rhs); recursive_directory_iterator(recursive_directory_iterator&& rhs) noexcept; ~recursive_directory_iterator(); @@ -14007,7 +14088,7 @@ operator=(recursive_directory_iterator&& rhs) noexcept; recursive_directory_iterator& operator++(); - recursive_directory_iterator& increment(error_code& ec) noexcept; + recursive_directory_iterator& increment(error_code& ec); void pop(); void pop(error_code& ec); @@ -14050,8 +14131,8 @@ \begin{itemdecl} explicit recursive_directory_iterator(const path& p); recursive_directory_iterator(const path& p, directory_options options); -recursive_directory_iterator(const path& p, directory_options options, error_code& ec) noexcept; -recursive_directory_iterator(const path& p, error_code& ec) noexcept; +recursive_directory_iterator(const path& p, directory_options options, error_code& ec); +recursive_directory_iterator(const path& p, error_code& ec); \end{itemdecl} \begin{itemdescr} @@ -14208,7 +14289,7 @@ \indexlibrarymember{operator++}{recursive_directory_iterator}% \begin{itemdecl} recursive_directory_iterator& operator++(); -recursive_directory_iterator& increment(error_code& ec) noexcept; +recursive_directory_iterator& increment(error_code& ec); \end{itemdecl} \begin{itemdescr} @@ -14401,7 +14482,7 @@ \indexlibrary{\idxcode{copy}!\idxcode{path}}% \begin{itemdecl} -void copy(const path& from, const path& to, error_code& ec) noexcept; +void copy(const path& from, const path& to, error_code& ec); \end{itemdecl} \begin{itemdescr} @@ -14414,7 +14495,7 @@ \begin{itemdecl} void copy(const path& from, const path& to, copy_options options); void copy(const path& from, const path& to, copy_options options, - error_code& ec) noexcept; + error_code& ec); \end{itemdecl} \begin{itemdescr} @@ -14495,8 +14576,12 @@ \item Then, iterate over the files in \tcode{from}, as if by \begin{codeblock} for (const directory_entry& x : directory_iterator(from)) - copy(x.path(), to/x.path().filename(), options | copy_options::@\unspec@) + copy(x.path(), to/x.path().filename(), + options | copy_options::@\placeholder{in-recursive-copy}@); \end{codeblock} + where \tcode{\placeholder{in-recursive-copy}} + is a bitmask element of \tcode{copy_options} + that is not one of the elements in~\ref{fs.enum.copy.opts}. \end{itemize} \item @@ -14558,7 +14643,7 @@ \indexlibrary{\idxcode{copy_file}}% \begin{itemdecl} bool copy_file(const path& from, const path& to); -bool copy_file(const path& from, const path& to, error_code& ec) noexcept; +bool copy_file(const path& from, const path& to, error_code& ec); \end{itemdecl} \begin{itemdescr} @@ -14575,7 +14660,7 @@ \begin{itemdecl} bool copy_file(const path& from, const path& to, copy_options options); bool copy_file(const path& from, const path& to, copy_options options, - error_code& ec) noexcept; + error_code& ec); \end{itemdecl} \begin{itemdescr} @@ -14589,7 +14674,7 @@ As follows: \begin{itemize} \item -Report a file already exists error as specified in~\ref{fs.err.report} if: +Report an error as specified in~\ref{fs.err.report} if: \begin{itemize} \item \tcode{is_regular_file(from)} is \tcode{false}, or \item \tcode{exists(to)} is \tcode{true} and \tcode{is_regular_file(to)} is \tcode{false}, or @@ -14655,7 +14740,7 @@ \indexlibrary{\idxcode{create_directories}}% \begin{itemdecl} bool create_directories(const path& p); -bool create_directories(const path& p, error_code& ec) noexcept; +bool create_directories(const path& p, error_code& ec); \end{itemdecl} \begin{itemdescr} @@ -15089,7 +15174,7 @@ \indexlibrary{\idxcode{is_empty}!function}% \begin{itemdecl} bool is_empty(const path& p); -bool is_empty(const path& p, error_code& ec) noexcept; +bool is_empty(const path& p, error_code& ec); \end{itemdecl} \begin{itemdescr} @@ -15483,7 +15568,7 @@ \indexlibrary{\idxcode{remove_all}}% \begin{itemdecl} uintmax_t remove_all(const path& p); -uintmax_t remove_all(const path& p, error_code& ec) noexcept; +uintmax_t remove_all(const path& p, error_code& ec); \end{itemdecl} \begin{itemdescr} @@ -15550,13 +15635,11 @@ \begin{itemdescr} \pnum -\postconditions \tcode{file_size(p) == new_size}. +\effects Causes the size that would be returned by \tcode{file_size(p)} to be +equal to \tcode{new_size}, as if by POSIX \tcode{truncate()}. \pnum \throws As specified in~\ref{fs.err.report}. - -\pnum -\remarks Achieves its postconditions as if by POSIX \tcode{truncate()}. \end{itemdescr} @@ -15796,7 +15879,6 @@ to determine existence, return a path composed by \tcode{operator/=} from the result of calling \tcode{canonical()} - without a \tcode{base} argument and with a path argument composed of the leading elements of \tcode{p} that exist, if any, followed by the elements of \tcode{p} that do not exist, if any. @@ -15972,7 +16054,7 @@ introduce a data race\iref{res.on.data.races} with other calls to \tcode{tmpnam} with an argument that is a null pointer value. -\xref ISO C 7.21 +\xrefc{7.21} \rSec2[cinttypes.syn]{Header \tcode{} synopsis} @@ -16137,4 +16219,4 @@ \tcode{imaxdiv_t imaxdiv(intmax_t, intmax_t)}, respectively. \end{itemize} -\xref ISO C 7.8 +\xrefc{7.8} diff --git a/source/iterators.tex b/source/iterators.tex index dbd9d44930..63d0ca3dd6 100644 --- a/source/iterators.tex +++ b/source/iterators.tex @@ -16,7 +16,7 @@ iterator primitives, predefined iterators, and stream iterators, -as summarized in Table~\ref{tab:iterators.lib.summary}. +as summarized in \tref{iterators.lib.summary}. \begin{libsumtab}{Iterators library summary}{tab:iterators.lib.summary} \ref{iterator.requirements} & Requirements & \\ \rowsep @@ -81,7 +81,7 @@ \techterm{bidirectional iterators} and \techterm{random access iterators}, -as shown in Table~\ref{tab:iterators.relations}. +as shown in \tref{iterators.relations}. \begin{floattable}{Relations among iterator categories}{tab:iterators.relations} {llll} @@ -222,6 +222,21 @@ is undefined. } +\pnum +\indextext{iterator!constexpr} +Iterators are called \defn{constexpr iterators} +if all operations provided to satisfy iterator category operations +are constexpr functions, except for +\begin{itemize} +\item \tcode{swap}, +\item a pseudo-destructor call\iref{expr.pseudo}, and +\item the construction of an iterator with a singular value. +\end{itemize} +\begin{note} +For example, the types ``pointer to \tcode{int}'' and +\tcode{reverse_iterator} are constexpr iterators. +\end{note} + \pnum In the following sections, \tcode{a} @@ -254,7 +269,7 @@ \rSec2[iterator.iterators]{Iterator} \pnum -The \tcode{Iterator} requirements form the basis of the iterator concept +The \tcode{Iterator} requirements form the basis of the iterator taxonomy; every iterator satisfies the \tcode{Iterator} requirements. This set of requirements specifies operations for dereferencing and incrementing an iterator. Most algorithms will require additional operations to @@ -270,7 +285,7 @@ \tcode{Destructible} requirements\iref{utility.arg.requirements} and lvalues of type \tcode{X} are swappable\iref{swappable.requirements}, and -\item the expressions in Table~\ref{tab:iterator.requirements} are valid and have +\item the expressions in \tref{iterator.requirements} are valid and have the indicated semantics. \end{itemize} @@ -308,12 +323,12 @@ \tcode{T} if \tcode{X} satisfies the \tcode{Iterator}\iref{iterator.iterators} and -\tcode{EqualityComparable} (Table~\ref{tab:equalitycomparable}) requirements and -the expressions in Table~\ref{tab:iterator.input.requirements} are valid and have +\tcode{EqualityComparable} (\tref{equalitycomparable}) requirements and +the expressions in \tref{iterator.input.requirements} are valid and have the indicated semantics. \pnum -In Table~\ref{tab:iterator.input.requirements}, the term +In \tref{iterator.input.requirements}, the term \techterm{the domain of \tcode{==}} is used in the ordinary mathematical sense to denote the set of values over which @@ -400,7 +415,7 @@ They should be \term{single pass} algorithms. -Value type \tcode{T} is not required to be a \tcode{CopyAssignable} type (Table~\ref{tab:copyassignable}). +Value type \tcode{T} is not required to be a \tcode{CopyAssignable} type (\tref{copyassignable}). These algorithms can be used with istreams as the source of the input data through the \tcode{istream_iterator} class template. @@ -413,7 +428,7 @@ \tcode{X} satisfies the requirements of an output iterator if \tcode{X} satisfies the \tcode{Iterator} requirements\iref{iterator.iterators} -and the expressions in Table~\ref{tab:iterator.output.requirements} +and the expressions in \tref{iterator.output.requirements} are valid and have the indicated semantics. \begin{libreqtab4b} @@ -488,7 +503,7 @@ \item if \tcode{X} is a mutable iterator, \tcode{reference} is a reference to \tcode{T}; if \tcode{X} is a constant iterator, \tcode{reference} is a reference to \tcode{const T}, -\item the expressions in Table~\ref{tab:iterator.forward.requirements} +\item the expressions in \tref{iterator.forward.requirements} are valid and have the indicated semantics, and \item objects of type \tcode{X} offer the multi-pass guarantee, described below. @@ -563,7 +578,7 @@ \tcode{X} satisfies the requirements of a bidirectional iterator if, in addition to satisfying the requirements for forward iterators, -the following expressions are valid as shown in Table~\ref{tab:iterator.bidirectional.requirements}. +the following expressions are valid as shown in \tref{iterator.bidirectional.requirements}. \begin{libreqtab4b} {Bidirectional iterator requirements (in addition to forward iterator)} @@ -608,7 +623,7 @@ \tcode{X} satisfies the requirements of a random access iterator if, in addition to satisfying the requirements for bidirectional iterators, -the following expressions are valid as shown in Table~\ref{tab:iterator.random.access.requirements}. +the following expressions are valid as shown in \tref{iterator.random.access.requirements}. \begin{libreqtab4b} {Random access iterator requirements (in addition to bidirectional iterator)} @@ -1247,31 +1262,29 @@ \pnum The template parameter \tcode{Iterator} -shall meet all the requirements of a Bidirectional Iterator\iref{bidirectional.iterators}. +shall satisfy all the requirements of a Bidirectional Iterator\iref{bidirectional.iterators}. \pnum Additionally, \tcode{Iterator} -shall meet the requirements of a random access iterator\iref{random.access.iterators} +shall satisfy the requirements of a random access iterator\iref{random.access.iterators} if any of the members -\tcode{operator+}~(\ref{reverse.iter.op+}), -\tcode{operator-}~(\ref{reverse.iter.op-}), -\tcode{operator+=}~(\ref{reverse.iter.op+=}), -\tcode{operator-=}~(\ref{reverse.iter.op-=}), -\tcode{operator[]}\iref{reverse.iter.opindex}, -or the non-member operators -\tcode{operator<}~(\ref{reverse.iter.op<}), -\tcode{operator>}~(\ref{reverse.iter.op>}),\\ -\tcode{operator<=}~(\ref{reverse.iter.op<=}), -\tcode{operator>=}~(\ref{reverse.iter.op>=}), -\tcode{operator-}\iref{reverse.iter.opdiff} +\tcode{operator+}, +\tcode{operator-}, +\tcode{operator+=}, +\tcode{operator-=}\iref{reverse.iter.nav}, +\tcode{operator[]}\iref{reverse.iter.elem}, +or the non-member operators\iref{reverse.iter.cmp} +\tcode{operator<}, +\tcode{operator>}, +\tcode{operator<=}, +\tcode{operator>=}, +\tcode{operator-}, or -\tcode{operator+}\iref{reverse.iter.opsum} +\tcode{operator+}\iref{reverse.iter.nonmember} are referenced in a way that requires instantiation\iref{temp.inst}. -\rSec3[reverse.iter.ops]{\tcode{reverse_iterator} operations} - -\rSec4[reverse.iter.cons]{\tcode{reverse_iterator} constructor} +\rSec3[reverse.iter.cons]{\tcode{reverse_iterator} construction and assignment} \indexlibrary{\idxcode{reverse_iterator}!constructor}% \begin{itemdecl} @@ -1315,8 +1328,6 @@ \tcode{u.current}. \end{itemdescr} -\rSec4[reverse.iter.op=]{\tcode{reverse_iterator::operator=}} - \indexlibrarymember{operator=}{reverse_iterator}% \begin{itemdecl} template @@ -1334,7 +1345,7 @@ \tcode{*this}. \end{itemdescr} -\rSec4[reverse.iter.conv]{Conversion} +\rSec3[reverse.iter.conv]{Conversion} \indexlibrarymember{base}{reverse_iterator}% \begin{itemdecl} @@ -1347,7 +1358,7 @@ \tcode{current}. \end{itemdescr} -\rSec4[reverse.iter.op.star]{\tcode{operator*}} +\rSec3[reverse.iter.elem]{\tcode{reverse_iterator} element access} \indexlibrarymember{operator*}{reverse_iterator}% \begin{itemdecl} @@ -1365,8 +1376,6 @@ \end{itemdescr} -\rSec4[reverse.iter.opref]{\tcode{operator->}} - \indexlibrarymember{operator->}{reverse_iterator}% \begin{itemdecl} constexpr pointer operator->() const; @@ -1377,7 +1386,40 @@ \returns \tcode{addressof(operator*())}. \end{itemdescr} -\rSec4[reverse.iter.op++]{\tcode{operator++}} +\indexlibrarymember{operator[]}{reverse_iterator}% +\begin{itemdecl} +constexpr @\unspec@ operator[](difference_type n) const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\tcode{current[-n-1]}. +\end{itemdescr} + +\rSec3[reverse.iter.nav]{\tcode{reverse_iterator} navigation} + +\indexlibrarymember{operator+}{reverse_iterator}% +\begin{itemdecl} +constexpr reverse_iterator operator+(difference_type n) const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\tcode{reverse_iterator(current-n)}. +\end{itemdescr} + +\indexlibrarymember{operator-}{reverse_iterator}% +\begin{itemdecl} +constexpr reverse_iterator operator-(difference_type n) const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\tcode{reverse_iterator(current+n)}. +\end{itemdescr} \indexlibrarymember{operator++}{reverse_iterator}% \begin{itemdecl} @@ -1410,8 +1452,6 @@ \end{codeblock} \end{itemdescr} -\rSec4[reverse.iter.op\dcr]{\tcode{operator\dcr}} - \indexlibrarymember{operator\dcr}{reverse_iterator}% \begin{itemdecl} constexpr reverse_iterator& operator--(); @@ -1443,21 +1483,6 @@ \end{codeblock} \end{itemdescr} -\rSec4[reverse.iter.op+]{\tcode{operator+}} - -\indexlibrarymember{operator+}{reverse_iterator}% -\begin{itemdecl} -constexpr reverse_iterator operator+(difference_type n) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{reverse_iterator(current-n)}. -\end{itemdescr} - -\rSec4[reverse.iter.op+=]{\tcode{operator+=}} - \indexlibrarymember{operator+=}{reverse_iterator}% \begin{itemdecl} constexpr reverse_iterator& operator+=(difference_type n); @@ -1473,21 +1498,6 @@ \tcode{*this}. \end{itemdescr} -\rSec4[reverse.iter.op-]{\tcode{operator-}} - -\indexlibrarymember{operator-}{reverse_iterator}% -\begin{itemdecl} -constexpr reverse_iterator operator-(difference_type n) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{reverse_iterator(current+n)}. -\end{itemdescr} - -\rSec4[reverse.iter.op-=]{\tcode{operator-=}} - \indexlibrarymember{operator-=}{reverse_iterator}% \begin{itemdecl} constexpr reverse_iterator& operator-=(difference_type n); @@ -1503,20 +1513,7 @@ \tcode{*this}. \end{itemdescr} -\rSec4[reverse.iter.opindex]{\tcode{operator[]}} - -\indexlibrarymember{operator[]}{reverse_iterator}% -\begin{itemdecl} -constexpr @\unspec@ operator[](difference_type n) const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{current[-n-1]}. -\end{itemdescr} - -\rSec4[reverse.iter.op==]{\tcode{operator==}} +\rSec3[reverse.iter.cmp]{\tcode{reverse_iterator} comparisons} \indexlibrarymember{operator==}{reverse_iterator}% \begin{itemdecl} @@ -1532,8 +1529,6 @@ \tcode{x.current == y.current}. \end{itemdescr} -\rSec4[reverse.iter.op<]{\tcode{operator<}} - \indexlibrarymember{operator<}{reverse_iterator}% \begin{itemdecl} template @@ -1548,8 +1543,6 @@ \tcode{x.current > y.current}. \end{itemdescr} -\rSec4[reverse.iter.op!=]{\tcode{operator!=}} - \indexlibrarymember{operator"!=}{reverse_iterator}% \begin{itemdecl} template @@ -1564,8 +1557,6 @@ \tcode{x.current != y.current}. \end{itemdescr} -\rSec4[reverse.iter.op>]{\tcode{operator>}} - \indexlibrarymember{operator>}{reverse_iterator}% \begin{itemdecl} template @@ -1580,8 +1571,6 @@ \tcode{x.current < y.current}. \end{itemdescr} -\rSec4[reverse.iter.op>=]{\tcode{operator>=}} - \indexlibrarymember{operator>=}{reverse_iterator}% \begin{itemdecl} template @@ -1596,8 +1585,6 @@ \tcode{x.current <= y.current}. \end{itemdescr} -\rSec4[reverse.iter.op<=]{\tcode{operator<=}} - \indexlibrarymember{operator<=}{reverse_iterator}% \begin{itemdecl} template @@ -1612,7 +1599,7 @@ \tcode{x.current >= y.current}. \end{itemdescr} -\rSec4[reverse.iter.opdiff]{\tcode{operator-}} +\rSec3[reverse.iter.nonmember]{Non-member functions} \indexlibrarymember{operator-}{reverse_iterator}% \begin{itemdecl} @@ -1628,8 +1615,6 @@ \tcode{y.current - x.current}. \end{itemdescr} -\rSec4[reverse.iter.opsum]{\tcode{operator+}} - \indexlibrarymember{operator+}{reverse_iterator}% \begin{itemdecl} template @@ -1644,8 +1629,6 @@ \tcode{reverse_iterator (x.current - n)}. \end{itemdescr} -\rSec4[reverse.iter.make]{Non-member function \tcode{make_reverse_iterator()}} - \indexlibrary{\idxcode{reverse_iterator}!\idxcode{make_reverse_iterator} non-member function}% \indexlibrary{\idxcode{make_reverse_iterator}}% \begin{itemdecl} @@ -1740,9 +1723,7 @@ } \end{codeblock} -\rSec3[back.insert.iter.ops]{\tcode{back_insert_iterator} operations} - -\rSec4[back.insert.iter.cons]{\tcode{back_insert_iterator} constructor} +\rSec4[back.insert.iter.ops]{\tcode{back_insert_iterator} operations} \indexlibrary{\idxcode{back_insert_iterator}!constructor}% \begin{itemdecl} @@ -1757,8 +1738,6 @@ with \tcode{addressof(x)}. \end{itemdescr} -\rSec4[back.insert.iter.op=]{\tcode{back_insert_iterator::operator=}} - \indexlibrarymember{operator=}{back_insert_iterator}% \begin{itemdecl} back_insert_iterator& operator=(const typename Container::value_type& value); @@ -1789,8 +1768,6 @@ \tcode{*this}. \end{itemdescr} -\rSec4[back.insert.iter.op*]{\tcode{back_insert_iterator::operator*}} - \indexlibrarymember{operator*}{back_insert_iterator}% \begin{itemdecl} back_insert_iterator& operator*(); @@ -1802,8 +1779,6 @@ \tcode{*this}. \end{itemdescr} -\rSec4[back.insert.iter.op++]{\tcode{back_insert_iterator::operator++}} - \indexlibrarymember{operator++}{back_insert_iterator}% \begin{itemdecl} back_insert_iterator& operator++(); @@ -1862,9 +1837,7 @@ } \end{codeblock} -\rSec3[front.insert.iter.ops]{\tcode{front_insert_iterator} operations} - -\rSec4[front.insert.iter.cons]{\tcode{front_insert_iterator} constructor} +\rSec4[front.insert.iter.ops]{\tcode{front_insert_iterator} operations} \indexlibrary{\idxcode{front_insert_iterator}!constructor}% \begin{itemdecl} @@ -1879,8 +1852,6 @@ with \tcode{addressof(x)}. \end{itemdescr} -\rSec4[front.insert.iter.op=]{\tcode{front_insert_iterator::operator=}} - \indexlibrarymember{operator=}{front_insert_iterator}% \begin{itemdecl} front_insert_iterator& operator=(const typename Container::value_type& value); @@ -1911,8 +1882,6 @@ \tcode{*this}. \end{itemdescr} -\rSec4[front.insert.iter.op*]{\tcode{front_insert_iterator::operator*}} - \indexlibrarymember{operator*}{front_insert_iterator}% \begin{itemdecl} front_insert_iterator& operator*(); @@ -1924,8 +1893,6 @@ \tcode{*this}. \end{itemdescr} -\rSec4[front.insert.iter.op++]{\tcode{front_insert_iterator::operator++}} - \indexlibrarymember{operator++}{front_insert_iterator}% \begin{itemdecl} front_insert_iterator& operator++(); @@ -1985,9 +1952,7 @@ } \end{codeblock} -\rSec3[insert.iter.ops]{\tcode{insert_iterator} operations} - -\rSec4[insert.iter.cons]{\tcode{insert_iterator} constructor} +\rSec4[insert.iter.ops]{\tcode{insert_iterator} operations} \indexlibrary{\idxcode{insert_iterator}!constructor}% \begin{itemdecl} @@ -2004,8 +1969,6 @@ with \tcode{i}. \end{itemdescr} -\rSec4[insert.iter.op=]{\tcode{insert_iterator::operator=}} - \indexlibrarymember{operator=}{insert_iterator}% \begin{itemdecl} insert_iterator& operator=(const typename Container::value_type& value); @@ -2044,8 +2007,6 @@ \tcode{*this}. \end{itemdescr} -\rSec4[insert.iter.op*]{\tcode{insert_iterator::operator*}} - \indexlibrarymember{operator*}{insert_iterator}% \begin{itemdecl} insert_iterator& operator*(); @@ -2057,8 +2018,6 @@ \tcode{*this}. \end{itemdescr} -\rSec4[insert.iter.op++]{\tcode{insert_iterator::operator++}} - \indexlibrarymember{operator++}{insert_iterator}% \begin{itemdecl} insert_iterator& operator++(); @@ -2189,10 +2148,10 @@ \rSec3[move.iter.requirements]{\tcode{move_iterator} requirements} \pnum -The template parameter \tcode{Iterator} shall meet +The template parameter \tcode{Iterator} shall satisfy the requirements of an input iterator\iref{input.iterators}. Additionally, if any of the bidirectional or random access traversal -functions are instantiated, the template parameter shall meet the +functions are instantiated, the template parameter shall satisfy the requirements for a Bidirectional Iterator\iref{bidirectional.iterators} or a Random Access Iterator\iref{random.access.iterators}, respectively. @@ -2590,7 +2549,7 @@ The behavior of a program that applies \tcode{operator++()} to an end-of-stream iterator is undefined. It is impossible to store things into istream iterators. -The type \tcode{T} shall meet the \tcode{DefaultConstructible}, +The type \tcode{T} shall satisfy the \tcode{DefaultConstructible}, \tcode{CopyConstructible}, and \tcode{CopyAssignable} requirements. \pnum @@ -3343,8 +3302,10 @@ In addition to being available via inclusion of the \tcode{} header, the function templates in \ref{iterator.range} are available when any of the following headers are included: \tcode{}, \tcode{}, \tcode{}, -\tcode{}, \tcode{}, \tcode{}, \tcode{}, \tcode{}, +\tcode{}, \tcode{}, \tcode{}, \tcode{}, \tcode{}, \tcode{}, \tcode{}, \tcode{}, \tcode{}, and \tcode{}. +Each of these templates +is a designated customization point\iref{namespace.std}. \indexlibrary{\idxcode{begin(C\&)}}% \begin{itemdecl} @@ -3472,15 +3433,17 @@ \pnum \returns \tcode{std::rend(c)}. \end{itemdescr} -\rSec1[iterator.container]{Container access} +\rSec1[iterator.container]{Container and view access} \pnum In addition to being available via inclusion of the \tcode{} header, the function templates in \ref{iterator.container} are available when any of the following headers are included: \tcode{}, \tcode{}, \tcode{}, \tcode{}, -\tcode{}, \tcode{}, \tcode{}, \tcode{}, -\tcode{}, \tcode{}, and \tcode{}. +\tcode{}, \tcode{}, \tcode{}, \tcode{}, \tcode{}, +\tcode{}, \tcode{}, \tcode{}, and \tcode{}. +Each of these templates +is a designated customization point\iref{namespace.std}. \indexlibrary{\idxcode{size(C\& c)}}% \begin{itemdecl} diff --git a/source/layout.tex b/source/layout.tex index 994241dc15..58a97cec00 100644 --- a/source/layout.tex +++ b/source/layout.tex @@ -24,6 +24,11 @@ %% even if \raggedbottom (default) is in effect. \addtolength{\topskip}{0pt plus 20pt} +%%-------------------------------------------------- +%% Place footnotes at the bottom of the page, rather +%% than immediately following the main text. +\feetatbottom + %%-------------------------------------------------- %% Paragraph and bullet numbering diff --git a/source/lex.tex b/source/lex.tex index e0f4677333..54ea4d6339 100644 --- a/source/lex.tex +++ b/source/lex.tex @@ -360,7 +360,7 @@ \tcode{[} and \tcode{<:} will be different, maintaining the source spelling, but the tokens can otherwise be freely interchanged. } The set of alternative tokens is defined in -Table~\ref{tab:alternative.tokens}. +\tref{alternative.tokens}. \begin{tokentable}{Alternative tokens}{tab:alternative.tokens}{Alternative}{Primary} \tcode{<\%} & \tcode{\{} & @@ -545,10 +545,10 @@ An identifier is an arbitrarily long sequence of letters and digits. Each \grammarterm{universal-character-name} in an identifier shall designate a character whose encoding in ISO 10646 falls into one of the ranges -specified in Table~\ref{tab:charname.allowed}. +specified in \tref{charname.allowed}. The initial element shall not be a \grammarterm{universal-character-name} designating a character whose encoding falls into one of the ranges -specified in Table~\ref{tab:charname.disallowed}. +specified in \tref{charname.disallowed}. Upper- and lower-case letters are different. All characters are significant.\footnote{On systems in which linkers cannot accept extended characters, an encoding of the \grammarterm{universal-character-name} may be used in @@ -621,7 +621,7 @@ \end{floattable} \pnum -The identifiers in Table~\ref{tab:identifiers.special} have a special meaning when +The identifiers in \tref{identifiers.special} have a special meaning when appearing in a certain context. When referred to in the grammar, these identifiers are used explicitly rather than using the \grammarterm{identifier} grammar production. Unless otherwise specified, any ambiguity as to whether a given @@ -664,7 +664,7 @@ \enlargethispage{\baselineskip}% \pnum \indextext{keyword|(}% -The identifiers shown in Table~\ref{tab:keywords} are reserved for use +The identifiers shown in \tref{keywords} are reserved for use as keywords (that is, they are unconditionally treated as keywords in phase 7) except in an \grammarterm{attribute-token}\iref{dcl.attr.grammar}: @@ -769,7 +769,7 @@ \pnum Furthermore, the alternative representations shown in -Table~\ref{tab:alternative.representations} for certain operators and +\tref{alternative.representations} for certain operators and punctuators\iref{lex.digraph} are reserved and shall not be used otherwise: @@ -963,7 +963,7 @@ \indextext{suffix!\idxcode{l}}% \indextext{suffix!\idxcode{u}}% The type of an integer literal is the first of the corresponding list -in Table~\ref{tab:lex.type.integer.literal} in which its value can be +in \tref{lex.type.integer.literal} in which its value can be represented. \enlargethispage{\baselineskip}% @@ -1204,7 +1204,7 @@ \indextext{\idxcode{\textbackslash}|see{backslash character}}% \indextext{escape character|see{backslash character}}% \tcode{\textbackslash}, can be represented according to -Table~\ref{tab:escape.sequences}. +\tref{escape.sequences}. \indextext{escape sequence!undefined}% The double quote \tcode{"} and the question mark \tcode{?}, can be represented as themselves or by the escape sequences @@ -1213,7 +1213,7 @@ shall be represented by the escape sequences \tcode{\textbackslash'} and \tcode{\textbackslash\textbackslash} respectively. Escape sequences in which the character following the backslash is not listed in -Table~\ref{tab:escape.sequences} are conditionally-supported, with \impldef{semantics of +\tref{escape.sequences} are conditionally-supported, with \impldef{semantics of non-standard escape sequences} semantics. An escape sequence specifies a single character. @@ -1603,7 +1603,7 @@ \grammarterm{string-literal}'s initial rawness has no effect on the interpretation or well-formedness of the concatenation. \end{note} -Table~\ref{tab:lex.string.concat} has some examples of valid concatenations. +\tref{lex.string.concat} has some examples of valid concatenations. \begin{floattable}{String literal concatenations}{tab:lex.string.concat} {lll|lll|lll} diff --git a/source/lib-intro.tex b/source/lib-intro.tex index 78ddd72551..432c061fd5 100644 --- a/source/lib-intro.tex +++ b/source/lib-intro.tex @@ -20,7 +20,7 @@ \pnum Detailed specifications for each of the components in the library are in \ref{\firstlibchapter}--\ref{\lastlibchapter}, as shown in -Table~\ref{tab:library.categories}. +\tref{library.categories}. \begin{libsumtabbase}{Library categories}{tab:library.categories}{Clause}{Category} \ref{language.support} & & Language support library \\ @@ -540,7 +540,7 @@ \pnum Paragraphs labeled ``\textsc{See also}'' contain cross-references to the relevant portions -of the ISO C standard. +of other standards\iref{intro.refs}. \rSec2[conventions]{Other conventions} \indextext{conventions}% @@ -858,7 +858,7 @@ \begin{itemdescr} \pnum \requires -Type \tcode{T} is \tcode{EqualityComparable} (Table~\ref{tab:equalitycomparable}). +Type \tcode{T} is \tcode{EqualityComparable} (\tref{equalitycomparable}). \pnum \returns @@ -873,7 +873,7 @@ \begin{itemdescr} \pnum \requires -Type \tcode{T} is \tcode{LessThanComparable} (Table~\ref{tab:lessthancomparable}). +Type \tcode{T} is \tcode{LessThanComparable} (\tref{lessthancomparable}). \pnum \returns @@ -888,7 +888,7 @@ \begin{itemdescr} \pnum \requires -Type \tcode{T} is \tcode{LessThanComparable} (Table~\ref{tab:lessthancomparable}). +Type \tcode{T} is \tcode{LessThanComparable} (\tref{lessthancomparable}). \pnum \returns @@ -903,7 +903,7 @@ \begin{itemdescr} \pnum \requires -Type \tcode{T} is \tcode{LessThanComparable} (Table~\ref{tab:lessthancomparable}). +Type \tcode{T} is \tcode{LessThanComparable} (\tref{lessthancomparable}). \pnum \returns @@ -1007,97 +1007,102 @@ \pnum The \Cpp{} standard library provides the \defnx{\Cpp{} library headers}{header!C++ library}, -shown in Table~\ref{tab:cpp.library.headers}. +shown in \tref{cpp.library.headers}. \begin{floattable}{\Cpp{} library headers}{tab:cpp.library.headers} {llll} \topline \tcode{} & -\tcode{} & -\tcode{} & -\tcode{} \\ - -\tcode{} & \tcode{} & -\tcode{} & +\tcode{} & \tcode{} \\ -\tcode{} & +\tcode{} & \tcode{} & -\tcode{} & -\tcode{} \\ - -\tcode{} & -\tcode{} & \tcode{} & \tcode{} \\ -\tcode{} & -\tcode{} & +\tcode{} & +\tcode{} & \tcode{} & \tcode{} \\ -\tcode{} & -\tcode{} & +\tcode{} & +\tcode{} & \tcode{} & \tcode{} \\ -\tcode{} & -\tcode{} & +\tcode{} & +\tcode{} & \tcode{} & \tcode{} \\ -\tcode{} & -\tcode{} & +\tcode{} & +\tcode{} & \tcode{} & \tcode{} \\ -\tcode{} & -\tcode{} & +\tcode{} & +\tcode{} & \tcode{} & \tcode{} \\ -\tcode{} & -\tcode{} & +\tcode{} & +\tcode{} & \tcode{} & \tcode{} \\ -\tcode{} & -\tcode{} & +\tcode{} & +\tcode{} & \tcode{} & \tcode{} \\ -\tcode{} & -\tcode{} & +\tcode{} & +\tcode{} & \tcode{} & \tcode{} \\ -\tcode{} & +\tcode{} & +\tcode{} & +\tcode{} & +\tcode{} \\ + +\tcode{} & \tcode{} & \tcode{} & -\tcode{} \\ +\tcode{} \\ -\tcode{} & +\tcode{} & \tcode{} & \tcode{} & -\tcode{} \\ +\tcode{} \\ -\tcode{} & +\tcode{} & \tcode{} & \tcode{} & -\tcode{} \\ +\tcode{} \\ -\tcode{} & +\tcode{} & \tcode{} & \tcode{} & -\tcode{} \\ +\tcode{} \\ + +\tcode{} & +\tcode{} & +\tcode{} & +\\ + +\tcode{} & +\tcode{} & +\tcode{} & +\\ \end{floattable} \pnum The facilities of the C standard library are provided in the \indextext{library!C standard}% -additional headers shown in Table~\ref{tab:cpp.c.headers}.% +additional headers shown in \tref{cpp.c.headers}.% \footnote{It is intentional that there is no \Cpp{} header for any of these C headers: \tcode{}\indextext{\idxhdr{stdatomic.h}!absence thereof}, @@ -1202,7 +1207,7 @@ (None of them is declared in namespace \tcode{std}.) \pnum -Table~\ref{tab:c.annex.k.names} lists the Annex K names +\tref{c.annex.k.names} lists the Annex K names that may be declared in some header. These names are also subject to the restrictions of~\ref{macro.names}. @@ -1316,12 +1321,12 @@ \pnum A freestanding implementation\indextext{implementation!freestanding} has an \impldef{headers for freestanding implementation} set of headers. This set shall -include at least the headers shown in Table~\ref{tab:cpp.headers.freestanding}. +include at least the headers shown in \tref{cpp.headers.freestanding}. \begin{libsumtab}{\Cpp{} headers for freestanding implementations}{tab:cpp.headers.freestanding} & & \tcode{} \\ \rowsep \ref{support.types} & Types & \tcode{} \\ \rowsep -\ref{support.limits} & Implementation properties & \tcode{} \tcode{} \tcode{} \\ \rowsep +\ref{support.limits} & Implementation properties & \tcode{} \tcode{} \tcode{} \tcode{} \\ \rowsep \ref{cstdint} & Integer types & \tcode{} \\ \rowsep \ref{support.start.term} & Start and termination & \tcode{} \\ \rowsep \ref{support.dynamic} & Dynamic memory management & \tcode{} \\ \rowsep @@ -1619,7 +1624,7 @@ \pnum A type \tcode{X} satisfying any of the iterator requirements\iref{iterator.requirements} -satisfies the requirements of \tcode{ValueSwappable} if, +satisfies the \tcode{ValueSwappable} requirements if, for any dereferenceable object \tcode{x} of type \tcode{X}, \tcode{*x} is swappable. @@ -1672,16 +1677,16 @@ \pnum A \tcode{NullablePointer} type is a pointer-like type that supports null values. -A type \tcode{P} meets the requirements of \tcode{NullablePointer} if: +A type \tcode{P} satisfies the \tcode{Nullable\-Pointer} requirements if: \begin{itemize} -\item \tcode{P} satisfies the requirements of \tcode{EqualityComparable}, +\item \tcode{P} satisfies the \tcode{EqualityComparable}, \tcode{DefaultConstructible}, \tcode{CopyConstructible}, \tcode{CopyAssignable}, -and \tcode{Destructible}, +and \tcode{Destructible} requirements, \item lvalues of type \tcode{P} are swappable\iref{swappable.requirements}, -\item the expressions shown in Table~\ref{tab:nullablepointer} are +\item the expressions shown in \tref{nullablepointer} are valid and have the indicated semantics, and \item \tcode{P} satisfies all the other requirements of this subclause. @@ -1703,7 +1708,7 @@ via an exception. \pnum -In Table~\ref{tab:nullablepointer}, \tcode{u} denotes an identifier, \tcode{t} +In \tref{nullablepointer}, \tcode{u} denotes an identifier, \tcode{t} denotes a non-\tcode{const} lvalue of type \tcode{P}, \tcode{a} and \tcode{b} denote values of type (possibly \tcode{const}) \tcode{P}, and \tcode{np} denotes a value of type (possibly \tcode{const}) \tcode{std::nullptr_t}. @@ -1754,15 +1759,15 @@ \begin{itemize} \item it is a function object type\iref{function.objects}, -\item it satisfies the requirements of \tcode{CopyConstructible} and - \tcode{Destructible}\iref{utility.arg.requirements}, and -\item the expressions shown in Table~\ref{tab:hash} +\item it satisfies the \tcode{CopyConstructible} (\tref{copyconstructible}) and + \tcode{Destructible} (\tref{destructible}) requirements, and +\item the expressions shown in \tref{hash} are valid and have the indicated semantics. \end{itemize} \pnum Given \tcode{Key} is an argument type for function objects of type \tcode{H}, in -Table~\ref{tab:hash} \tcode{h} is a value of type (possibly \tcode{const}) \tcode{H}, +\tref{hash} \tcode{h} is a value of type (possibly \tcode{const}) \tcode{H}, \tcode{u} is an lvalue of type \tcode{Key}, and \tcode{k} is a value of a type convertible to (possibly \tcode{const}) \tcode{Key}. @@ -1802,12 +1807,12 @@ \pnum The class template \tcode{allocator_traits}\iref{allocator.traits} supplies a uniform interface to all allocator types. -Table~\ref{tab:desc.var.def} describes the types manipulated -through allocators. Table~\ref{tab:utilities.allocator.requirements} +\tref{desc.var.def} describes the types manipulated +through allocators. \tref{utilities.allocator.requirements} describes the requirements on allocator types and thus on types used to instantiate \tcode{allocator_traits}. A requirement is optional if the last column of -Table~\ref{tab:utilities.allocator.requirements} specifies a default for a +\tref{utilities.allocator.requirements} specifies a default for a given expression. Within the standard library \tcode{allocator_traits} template, an optional requirement that is not supplied by an allocator is replaced by the specified default expression. A user specialization of @@ -2068,22 +2073,22 @@ Note B: If \tcode{X::propagate_on_container_copy_assignment::value} is \tcode{true}, \tcode{X} shall satisfy the -\tcode{CopyAssign\-able} requirements (Table~\ref{tab:copyassignable}) +\tcode{CopyAssign\-able} requirements (\tref{copyassignable}) and the copy operation shall not throw exceptions. If \tcode{X::propagate_on_container_move_assignment::value} is \tcode{true}, \tcode{X} shall satisfy the -\tcode{MoveAssignable} requirements (Table~\ref{tab:moveassignable}) +\tcode{MoveAssignable} requirements (\tref{moveassignable}) and the move operation shall not throw exceptions. If \tcode{X::propagate_on_container_swap::value} is \tcode{true}, lvalues of type \tcode{X} shall be swappable\iref{swappable.requirements} and the \tcode{swap} operation shall not throw exceptions. \pnum -An allocator type \tcode{X} shall satisfy the requirements of -\tcode{CopyConstructible}\iref{utility.arg.requirements}. +An allocator type \tcode{X} shall satisfy the +\tcode{CopyConstructible} requirements (\tref{copyconstructible}). The \tcode{X::pointer}, \tcode{X::const_pointer}, \tcode{X::void_pointer}, and -\tcode{X::const_void_pointer} types shall satisfy the requirements of -\tcode{NullablePointer}\iref{nullablepointer.requirements}. +\tcode{X::const_void_pointer} types shall satisfy the +\tcode{Nullable\-Pointer} requirements (\tref{nullablepointer}). No constructor, comparison function, copy operation, move operation, or swap operation on these pointer types shall exit via an exception. \tcode{X::pointer} and \tcode{X::const_pointer} shall also @@ -2134,7 +2139,7 @@ \begin{example} The following is an allocator class template supporting the minimal interface that satisfies the requirements of -Table~\ref{tab:utilities.allocator.requirements}: +\tref{utilities.allocator.requirements}: \begin{codeblock} template @@ -2194,17 +2199,23 @@ \rSec4[namespace.std]{Namespace \tcode{std}} \pnum -The behavior of a \Cpp{} program is undefined if it adds declarations or definitions to namespace +Unless otherwise specified, +the behavior of a \Cpp{} program is undefined if it adds declarations or definitions to namespace \tcode{std} or to a namespace within namespace -\tcode{std} -unless otherwise specified. -A program may add a template specialization for any standard library template +\tcode{std}. + +\pnum +Unless explicitly prohibited, +a program may add a template specialization for +any standard library class template to namespace -\tcode{std} only if the declaration -depends on a user-defined type -and the specialization meets the standard library requirements -for the original template and is not explicitly prohibited.\footnote{Any +\tcode{std} provided that +(a) the added declaration +depends on at least one user-defined type +and +(b) the specialization meets the standard library requirements +for the original template.\footnote{Any library code that instantiates other library templates must be prepared to work adequately with any user-supplied specialization that meets the minimum requirements of this document.} @@ -2229,11 +2240,90 @@ \item a deduction guide for any standard library class template. \end{itemize} -A program may explicitly instantiate a template defined in the standard library -only if the declaration depends on the name of a user-defined type -and the instantiation meets the standard library requirements for the + +\pnum +A program may explicitly instantiate +a class template defined in the standard library +only if the declaration +(a) depends on the name of at least one user-defined type +and +(b) the instantiation meets the standard library requirements for the original template. +\pnum +Let \tcode{\placeholder{F}} denote +a standard library function\iref{global.functions}, +a standard library static member function, +or an instantiation +of a standard library function template. +Unless \tcode{\placeholder{F}} is designated +an \defn{addressable function}, +the behavior of a \Cpp{} program is unspecified (possibly ill-formed) +if it explicitly or implicitly attempts +to form a pointer +to \tcode{\placeholder{F}}. +\begin{note} +Possible means of forming such pointers include +application of the unary \tcode{\&} operator\iref{expr.unary.op}, +\tcode{addressof}\iref{specialized.addressof}, +or +a function-to-pointer standard conversion\iref{conv.func}. +\end{note} +Moreover, +the behavior of a \Cpp{} program is unspecified (possibly ill-formed) +if it attempts to form a reference +to \tcode{\placeholder{F}} +or +if it attempts to form a pointer-to-member designating +either a standard library non-static member function\iref{member.functions} +or an instantiation of a standard library member function template. + +\pnum +Other than in namespace \tcode{std} +or in a namespace +within namespace \tcode{std}, +a program may provide +an overload for any library function template +designated as a \defn{customization point}, +provided that +(a) +the overload's declaration depends +on at least one user-defined type +and +(b) +the overload meets the standard library requirements +for the customization point.% +\footnote{ +Any library customization point +must be prepared +to work adequately +with any user-defined overload +that meets the minimum requirements +of this document. +Therefore +an implementation may elect, +under the as-if rule\iref{intro.execution}, +to provide any customization point +in the form +of an instantiated function object\iref{function.objects} +even though the customization point's specification +is in the form +of a function template. +The template parameters +of each such function object +and the function parameters +and return type +of the object's \tcode{operator()} +must match those +of the corresponding customization point's specification.} +\begin{note} +This permits +a (qualified or unqualified) call +to the customization point +to invoke the most appropriate overload +for the given arguments. +\end{note} + \pnum A translation unit shall not declare namespace \tcode{std} to be an inline namespace\iref{namespace.def}. @@ -2324,7 +2414,7 @@ \indextext{unit!translation}% A translation unit shall not \tcode{\#define} or \tcode{\#undef} names lexically identical to keywords, to the identifiers listed in -Table~\ref{tab:identifiers.special}, or to the \grammarterm{attribute-token}{s} described +\tref{identifiers.special}, or to the \grammarterm{attribute-token}{s} described in~\ref{dcl.attr}. \rSec4[extern.names]{External linkage} diff --git a/source/limits.tex b/source/limits.tex index 0bf337993e..e0f6c5e2ea 100644 --- a/source/limits.tex +++ b/source/limits.tex @@ -75,7 +75,7 @@ statements) [16\,384]. \item% -Data members in a single class\iref{class.mem} [16\,384]. +Non-static data members (including inherited ones) in a single class\iref{class.mem} [16\,384]. \item% Lambda-captures in one \grammarterm{lambda-expression}\iref{expr.prim.lambda.capture} [256]. \item% @@ -96,14 +96,15 @@ \item% Direct base classes for a single class\iref{class.derived} [1\,024]. \item% -Members declared in a single class\iref{class.mem} [4\,096]. +Class members declared in a single \grammarterm{member-specification} +(including member functions)\iref{class.mem} [4\,096]. \item% Final overriding virtual functions in a class, accessible or not\iref{class.virtual} [16\,384]. \item% Direct and indirect virtual bases of a class\iref{class.mi} [1\,024]. \item% -Static members of a class\iref{class.static} [1\,024]. +Static data members of a class\iref{class.static.data} [1\,024]. \item% Friend declarations in a class\iref{class.friend} [4\,096]. \item% @@ -115,13 +116,13 @@ \item% Scope qualifications of one identifier\iref{expr.prim.id.qual} [256]. \item% -Nested external specifications [1\,024]. +Nested \grammarterm{linkage-specification}s\iref{dcl.link} [1\,024]. \item% Recursive constexpr function invocations\iref{dcl.constexpr} [512]. \item% Full-expressions evaluated within a core constant expression\iref{expr.const} [1\,048\,576]. \item% -Template arguments in a template declaration\iref{temp.param} [1\,024]. +Template parameters in a template declaration\iref{temp.param} [1\,024]. \item% Recursively nested template instantiations\iref{temp.inst}, including substitution during template argument deduction\iref{temp.deduct} [1\,024]. diff --git a/source/locales.tex b/source/locales.tex index 2c2ad50064..00f081882e 100644 --- a/source/locales.tex +++ b/source/locales.tex @@ -14,7 +14,7 @@ \pnum The following subclauses describe components for locales themselves, the standard facets, and facilities -from the ISO C library, as summarized in Table~\ref{tab:localization.lib.summary}. +from the ISO C library, as summarized in \tref{localization.lib.summary}. \begin{libsumtab}{Localization library summary}{tab:localization.lib.summary} \ref{locales} & Locales & \tcode{} \\ @@ -219,7 +219,7 @@ function template \tcode{has_facet()}. User-defined facets may be installed in a locale, and used identically as -may standard facets\iref{facets.examples}. +may standard facets. \pnum \begin{note} @@ -279,7 +279,7 @@ thread. If there is a single global locale object for the entire program, implementations are not required to avoid data races on it\iref{res.on.data.races}. -\rSec3[locale.types]{\tcode{locale} types} +\rSec3[locale.types]{Types} \rSec4[locale.category]{Type \tcode{locale::category}} @@ -340,7 +340,7 @@ value identifies a set of locale categories. Each locale category, in turn, identifies a set of locale facets, including at least those -shown in Table~\ref{tab:localization.category.facets}. +shown in \tref{localization.category.facets}. \begin{floattable}{Locale category facets}{tab:localization.category.facets} {ml} @@ -369,7 +369,7 @@ either constructed, or returned by \tcode{locale::classic()}, and any facet \tcode{Facet} -shown in Table~\ref{tab:localization.category.facets}, +shown in \tref{localization.category.facets}, \tcode{has_facet(loc)} is \tcode{true}. Each @@ -381,7 +381,7 @@ \pnum An implementation is required to provide those specializations for facet templates identified as members of a category, and for those -shown in Table~\ref{tab:localization.required.specializations}. +shown in \tref{localization.required.specializations}. \begin{floattable}{Required specializations}{tab:localization.required.specializations} {ml} @@ -572,7 +572,7 @@ This depends only on static storage being zero before constructors run\iref{basic.start.static}. \end{note} -\rSec3[locale.cons]{\tcode{locale} constructors and destructor} +\rSec3[locale.cons]{Constructors and destructor} \indexlibrary{\idxcode{locale}!constructor}% \begin{itemdecl} @@ -743,7 +743,7 @@ A non-virtual destructor that throws no exceptions. \end{itemdescr} -\rSec3[locale.members]{\tcode{locale} members} +\rSec3[locale.members]{Members} \indexlibrarymember{locale}{combine}% \begin{itemdecl} @@ -790,7 +790,7 @@ if it has one; otherwise, the string \tcode{"*"}. \end{itemdescr} -\rSec3[locale.operators]{\tcode{locale} operators} +\rSec3[locale.operators]{Operators} \indexlibrarymember{locale}{operator==}% \begin{itemdecl} @@ -859,7 +859,7 @@ \end{example} \end{itemdescr} -\rSec3[locale.statics]{\tcode{locale} static members} +\rSec3[locale.statics]{Static members} \indexlibrarymember{locale}{global}% \begin{itemdecl} @@ -1173,7 +1173,7 @@ for character classing during input parsing. \pnum -The specializations required in Table~\ref{tab:localization.category.facets}\iref{locale.category}, namely +The specializations required in \tref{localization.category.facets}\iref{locale.category}, namely \tcode{ctype} and \tcode{ctype}, @@ -1894,7 +1894,7 @@ argument selects the pair of character encodings being mapped between. \pnum -The specializations required in Table~\ref{tab:localization.category.facets}\iref{locale.category} +The specializations required in \tref{localization.category.facets}\iref{locale.category} convert the implementation-defined native character set. \tcode{codecvt} implements a degenerate conversion; @@ -2110,7 +2110,7 @@ \pnum \returns -An enumeration value, as summarized in Table~\ref{tab:localization.convert.result.values.out.in}. +An enumeration value, as summarized in \tref{localization.convert.result.values.out.in}. \begin{floattable}{\tcode{do_in/do_out} result values}{tab:localization.convert.result.values.out.in} {lp{3in}} @@ -2162,7 +2162,7 @@ \pnum \returns -An enumeration value, as summarized in Table~\ref{tab:localization.convert.result.values.unshift}. +An enumeration value, as summarized in \tref{localization.convert.result.values.unshift}. \begin{floattable}{\tcode{do_unshift} result values}{tab:localization.convert.result.values.unshift} {lp{.50\hsize}} @@ -2521,7 +2521,7 @@ For conversion to an integral type, the function determines the integral conversion specifier as indicated in -Table~\ref{tab:localization.integer.conversions.in}. +\tref{localization.integer.conversions.in}. The table is ordered. That is, the first line whose condition is true applies. @@ -2536,7 +2536,7 @@ \tcode{unsigned} integral type & \tcode{\%u} \\ \end{floattable} -For conversions to a floating type the specifier is +For conversions to a floating-point type the specifier is \tcode{\%g}. For conversions to @@ -2545,7 +2545,7 @@ \tcode{\%p}. A length modifier is added to the conversion specification, if needed, -as indicated in Table~\ref{tab:localization.length.modifier.in}. +as indicated in \tref{localization.length.modifier.in}. \begin{floattable}{Length modifier}{tab:localization.length.modifier.in} {lc} @@ -2907,7 +2907,7 @@ For conversion from an integral type other than a character type, the function determines the integral conversion specifier as indicated in -Table~\ref{tab:localization.integer.conversions.out}. +\tref{localization.integer.conversions.out}. \begin{floattable}{Integer conversions}{tab:localization.integer.conversions.out} {lc} @@ -2921,7 +2921,7 @@ \end{floattable} For conversion from a floating-point type, the function determines -the floating-point conversion specifier as indicated in Table~\ref{tab:localization.fp.conversions.out}. +the floating-point conversion specifier as indicated in \tref{localization.fp.conversions.out}. \begin{floattable}{Floating-point conversions}{tab:localization.fp.conversions.out} {lc} @@ -2938,7 +2938,7 @@ For conversions from an integral or floating-point type a length modifier is added to the -conversion specifier as indicated in Table~\ref{tab:localization.length.modifier.out}. +conversion specifier as indicated in \tref{localization.length.modifier.out}. \begin{floattable}{Length modifier}{tab:localization.length.modifier.out} {lc} @@ -2953,7 +2953,7 @@ \end{floattable} The conversion specifier has the following optional additional qualifiers -prepended as indicated in Table~\ref{tab:localization.numeric.conversions}. +prepended as indicated in \tref{localization.numeric.conversions}. \begin{floattable}{Numeric conversions}{tab:localization.numeric.conversions} {llc} @@ -3017,7 +3017,7 @@ \tcode{0} which is \textit{not} -a padding character.} is determined according to Table~\ref{tab:localization.fill.padding}. +a padding character.} is determined according to \tref{localization.fill.padding}. \begin{floattable}{Fill padding}{tab:localization.fill.padding} {p{3in}l} @@ -3125,7 +3125,7 @@ \pnum \tcode{numpunct<>} specifies numeric punctuation. -The specializations required in Table~\ref{tab:localization.category.facets}\iref{locale.category}, namely +The specializations required in \tref{localization.category.facets}\iref{locale.category}, namely \tcode{numpunct<\brk{}wchar_t>} and \tcode{numpunct}, @@ -3367,7 +3367,7 @@ \tcode{operator()}, uses the collate facet to allow a locale to act directly as the predicate argument for standard algorithms\iref{algorithms} and containers operating on strings. -The specializations required in Table~\ref{tab:localization.category.facets}\iref{locale.category}, namely +The specializations required in \tref{localization.category.facets}\iref{locale.category}, namely \tcode{collate} and \tcode{collate}, @@ -3430,7 +3430,7 @@ if the first string is greater than the second, \tcode{-1} if less, zero otherwise. -The specializations required in Table~\ref{tab:localization.category.facets}\iref{locale.category}, namely +The specializations required in \tref{localization.category.facets}\iref{locale.category}, namely \tcode{collate} and \tcode{collate}, @@ -3810,7 +3810,7 @@ to produce one of the following formats, or until it encounters an error. The format depends on the value returned by \tcode{date_order()} as shown in -Table~\ref{tab:lib.locale.time.get.virtuals.dogetdate}. +\tref{lib.locale.time.get.virtuals.dogetdate}. \begin{libtab2}{\tcode{do_get_date} effects}{tab:lib.locale.time.get.virtuals.dogetdate} {ll}{\tcode{date_order()}}{Format} @@ -4568,7 +4568,7 @@ value \tcode{static_cast(p.field[i])} determines the -\tcode{i}th +$\tcode{i}^\text{th}$ component of the format\footnote{An array of \tcode{char}, rather than an array of @@ -4824,7 +4824,7 @@ \begin{itemdescr} \pnum \returns -The specializations required in Table~\ref{tab:localization.required.specializations}\iref{locale.category}, namely +The specializations required in \tref{localization.required.specializations}\iref{locale.category}, namely \tcode{moneypunct}, \tcode{moneypunct<\brk{}wchar_t>}, \tcode{moneypunct}, @@ -5036,218 +5036,6 @@ } \end{codeblock} -\rSec2[facets.examples]{Program-defined facets} - -\pnum -A \Cpp{} program may define facets to be added to a locale and used identically as -the built-in facets. -To create a new facet interface, \Cpp{} programs simply derive from -\tcode{locale::facet} -a class containing a static member: -\tcode{static locale::id id}. - -\pnum -\begin{note} -The locale member function templates verify its type and storage class. -\end{note} - -\pnum -\begin{example} -Traditional global localization is still easy: - -\begin{codeblock} -#include -#include -int main(int argc, char** argv) { - using namespace std; - locale::global(locale("")); // set the global locale - // imbue it on all the std streams - cin.imbue(locale()); - cout.imbue(locale()); - cerr.imbue(locale()); - wcin.imbue(locale()); - wcout.imbue(locale()); - wcerr.imbue(locale()); - - return MyObject(argc, argv).doit(); -} -\end{codeblock} -\end{example} - -\pnum -\begin{example} -Greater flexibility is possible: - -\begin{codeblock} -#include -#include -int main() { - using namespace std; - cin.imbue(locale("")); // the user's preferred locale - cout.imbue(locale::classic()); - double f; - while (cin >> f) cout << f << endl; - return (cin.fail() != 0); -} -\end{codeblock} - -In a European locale, with input -\tcode{3.456,78}, -output is -\tcode{3456.78}. -\end{example} - -\pnum -This can be important even for simple programs, which may need to -write a data file in a fixed format, regardless of a user's preference. - -\pnum -\begin{example} -Here is an example of the use of locales in a library interface. - -\begin{codeblock} -// file: \tcode{Date.h} -#include -#include -#include - -class Date { -public: - Date(unsigned day, unsigned month, unsigned year); - std::string asString(const std::locale& = std::locale()); -}; - -std::istream& operator>>(std::istream& s, Date& d); -std::ostream& operator<<(std::ostream& s, Date d); -\end{codeblock} - -\pnum -This example illustrates two architectural uses of class -\tcode{locale}. - -\pnum -The first is as a default argument in -\tcode{Date::asString()}, -where the -default is the global (presumably user-preferred) locale. - -\pnum -The second is in the operators -\tcode{<<} and \tcode{>>}, -where a locale ``hitchhikes'' -on another object, in this case a stream, to the point where it -is needed. - -\begin{codeblock} -// file: \tcode{Date.C} -#include "Date" // includes \tcode{} -#include -std::string Date::asString(const std::locale& l) { - using namespace std; - ostringstream s; s.imbue(l); - s << *this; return s.str(); -} - -std::istream& operator>>(std::istream& s, Date& d) { - using namespace std; - istream::sentry cerberos(s); - if (cerberos) { - ios_base::iostate err = goodbit; - struct tm t; - use_facet>(s.getloc()).get_date(s, 0, s, err, &t); - if (!err) d = Date(t.tm_day, t.tm_mon + 1, t.tm_year + 1900); - s.setstate(err); - } - return s; -} -\end{codeblock} -\end{example} - -\pnum -A locale object may be extended with a new facet simply by constructing -it with an instance of a class derived from -\tcode{locale::facet}. -The only member a \Cpp{} program must define is the static member -\tcode{id}, -which identifies your class interface as a new facet. - -\pnum -\begin{example} -Classifying Japanese characters: - -\begin{codeblock} -// file: \tcode{} -#include -namespace My { - using namespace std; - class JCtype : public locale::facet { - public: - static locale::id id; // required for use as a new locale facet - bool is_kanji (wchar_t c) const; - JCtype() { } - protected: - ~JCtype() { } - }; -} - -// file: \tcode{filt.C} -#include -#include -#include "jctype" // above -std::locale::id My::JCtype::id; // the static \tcode{JCtype} member declared above. - -int main() { - using namespace std; - using wctype = ctype; - locale loc(locale(""), // the user's preferred locale ... - new My::JCtype); // and a new feature ... - wchar_t c = use_facet(loc).widen('!'); - if (!use_facet(loc).is_kanji(c)) - cout << "no it isn't!" << endl; -} -\end{codeblock} - -\pnum -The new facet is used exactly like the built-in facets. -\end{example} - -\pnum -\begin{example} -Replacing an existing facet is even easier. -The code does not define a member -\tcode{id} -because it is reusing the -\tcode{numpunct} -facet interface: - -\begin{codeblock} -// file: \tcode{my_bool.C} -#include -#include -#include -namespace My { - using namespace std; - using cnumpunct = numpunct_byname; - class BoolNames : public cnumpunct { - protected: - string do_truename() const { return "Oui Oui!"; } - string do_falsename() const { return "Mais Non!"; } - ~BoolNames() { } - public: - BoolNames(const char* name) : cnumpunct(name) { } - }; -} - -int main(int argc, char** argv) { - using namespace std; - // make the user's preferred locale, except for... - locale loc(locale(""), new My::BoolNames("")); - cout.imbue(loc); - cout << boolalpha << "Any arguments today? " << (argc > 1) << endl; -} -\end{codeblock} -\end{example} - \rSec1[c.locales]{C library locales} \rSec2[clocale.syn]{Header \tcode{} synopsis} @@ -5288,9 +5076,9 @@ \pnum Calls to the function \tcode{setlocale} may introduce a data race\iref{res.on.data.races} with other calls to \tcode{setlocale} or with calls to -the functions listed in Table~\ref{tab:setlocale.data.races}. +the functions listed in \tref{setlocale.data.races}. -\xref ISO C 7.11 +\xrefc{7.11} \begin{floattable} {Potential \tcode{setlocale} data races} diff --git a/source/macros.tex b/source/macros.tex index 49927478ef..891c9dcdd4 100644 --- a/source/macros.tex +++ b/source/macros.tex @@ -253,10 +253,14 @@ %% Cross reference \newcommand{\xref}{\textsc{See also:}\space} +\newcommand{\xrefc}[1]{\xref{} ISO C #1} %% Inline parenthesized reference \newcommand{\iref}[1]{\nolinebreak[3] (\ref{#1})} +%% Inline non-parenthesized table reference (override memoir's \tref) +\renewcommand{\tref}[1]{\tablerefname \nolinebreak[3] \ref{tab:#1}} + %% NTBS, etc. \newcommand{\NTS}[1]{\textsc{#1}} \newcommand{\ntbs}{\NTS{ntbs}} @@ -318,6 +322,7 @@ %% Change descriptions \newcommand{\diffdef}[1]{\hfill\break\textbf{#1:}\space} \newcommand{\diffref}[1]{\pnum\textbf{Affected subclause:} \ref{#1}} +\newcommand{\diffrefs}[2]{\pnum\textbf{Affected subclauses:} \ref{#1}, \ref{#2}} \newcommand{\change}{\diffdef{Change}} \newcommand{\rationale}{\diffdef{Rationale}} \newcommand{\effect}{\diffdef{Effect on original feature}} @@ -329,7 +334,7 @@ \newcommand{\stage}[1]{\item[Stage #1:]} \newcommand{\doccite}[1]{\textit{#1}} \newcommand{\cvqual}[1]{\textit{#1}} -\newcommand{\cv}{\cvqual{cv}} +\newcommand{\cv}{\ifmmode\mathit{cv}\else\cvqual{cv}\fi} \newcommand{\numconst}[1]{\textsl{#1}} \newcommand{\logop}[1]{{\footnotesize #1}} diff --git a/source/numerics.tex b/source/numerics.tex index 317d8fb342..bc720f00e7 100644 --- a/source/numerics.tex +++ b/source/numerics.tex @@ -14,7 +14,7 @@ \textit{n}-at-a-time) arrays, generalized numeric algorithms, and mathematical functions for floating-point types, -as summarized in Table~\ref{tab:numerics.lib.summary}. +as summarized in \tref{numerics.lib.summary}. \begin{libsumtab}{Numerics library summary}{tab:numerics.lib.summary} \ref{numerics.defns} & Definitions & \\ @@ -242,7 +242,7 @@ A separate floating-point environment shall be maintained for each thread. Each function accesses the environment corresponding to its calling thread. -\xref ISO C 7.6 +\xrefc{7.6} \rSec1[complex.numbers]{Complex numbers} @@ -992,7 +992,7 @@ \pnum \remarks Behaves the same as the C function \tcode{cproj}. -\xref ISO C 7.3.9.5 +\xrefc{7.3.9.5} \end{itemdescr} \indexlibrary{\idxcode{polar}!\idxcode{complex}}% @@ -1029,7 +1029,7 @@ \pnum \remarks Behaves the same as the C function \tcode{cacos}. -\xref ISO C 7.3.5.1 +\xrefc{7.3.5.1} \end{itemdescr} \indexlibrary{\idxcode{asin}!\idxcode{complex}}% @@ -1045,7 +1045,7 @@ \pnum \remarks Behaves the same as the C function \tcode{casin}. -\xref ISO C 7.3.5.2 +\xrefc{7.3.5.2} \end{itemdescr} \indexlibrary{\idxcode{atan}!\idxcode{complex}}% @@ -1061,7 +1061,7 @@ \pnum \remarks Behaves the same as the C function \tcode{catan}. -\xref ISO C 7.3.5.3 +\xrefc{7.3.5.3} \end{itemdescr} \indexlibrary{\idxcode{acosh}!\idxcode{complex}}% @@ -1077,7 +1077,7 @@ \pnum \remarks Behaves the same as the C function \tcode{cacosh}. -\xref ISO C 7.3.6.1 +\xrefc{7.3.6.1} \end{itemdescr} \indexlibrary{\idxcode{asinh}!\idxcode{complex}}% @@ -1093,7 +1093,7 @@ \pnum \remarks Behaves the same as the C function \tcode{casinh}. -\xref ISO C 7.3.6.2 +\xrefc{7.3.6.2} \end{itemdescr} \indexlibrary{\idxcode{atanh}!\idxcode{complex}}% @@ -1109,7 +1109,7 @@ \pnum \remarks Behaves the same as the C function \tcode{catanh}. -\xref ISO C 7.3.6.3 +\xrefc{7.3.6.3} \end{itemdescr} \indexlibrary{\idxcode{cos}!\idxcode{complex}}% @@ -1315,8 +1315,8 @@ \rSec2[complex.literals]{Suffixes for complex number literals} -\indexlibrary{complex!literals}% -\indexlibrary{literals!complex}% +\indextext{literal!complex}% +\indexlibrary{\tcode{complex}!literals}% \pnum This subclause describes literal suffixes for constructing complex number literals. The suffixes \tcode{i}, \tcode{il}, and \tcode{if} create complex numbers of @@ -1582,7 +1582,7 @@ satisfies the requirements of a seed sequence if the expressions shown -in Table~\ref{tab:SeedSequence} +in \tref{SeedSequence} are valid and have the indicated semantics, and if \tcode{S} also satisfies all other requirements of this subclause \ref{rand.req.seedseq}. @@ -1723,7 +1723,7 @@ satisfies the requirements of a \techterm{uniform random bit generator} if the expressions shown -in Table~\ref{tab:UniformRandomBitGenerator} +in \tref{UniformRandomBitGenerator} are valid and have the indicated semantics, and if \tcode{G} also satisfies all other requirements of this subclause \ref{rand.req.urng}. @@ -1847,7 +1847,7 @@ also satisfies the requirements of a \techterm{random number engine} if the expressions shown -in Table~\ref{tab:RandomEngine} +in \tref{RandomEngine} are valid and have the indicated semantics, and if \tcode{E} also satisfies all other requirements of this subclause \ref{rand.req.eng}. @@ -1903,21 +1903,21 @@ with the same initial state as all other default-constructed engines of type \tcode{E}. - & \bigoh{$\mbox{size of state}$} + & \bigoh{$\text{size of state}$} \\ \rowsep \tcode{E(x)} \indextext{copy constructor!random number engine requirement} & & Creates an engine that compares equal to \tcode{x}. - & \bigoh{$\mbox{size of state}$} + & \bigoh{$\text{size of state}$} \\ \rowsep \tcode{E(s)}% \indextext{constructor!random number engine requirement} & & Creates an engine with initial state determined by \tcode{s}. - & \bigoh{$\mbox{size of state}$} + & \bigoh{$\text{size of state}$} \\ \rowsep \tcode{E(q)}% \indextext{constructor!random number engine requirement}\footnote{ This constructor @@ -1964,7 +1964,7 @@ \state{e}{i+1} $ = \mathsf{TA}($\state{e}{i}$)$ and returns $ \mathsf{GA}($\state{e}{i}$)$. - & per Table~\ref{tab:UniformRandomBitGenerator} + & per \tref{UniformRandomBitGenerator} \\ \rowsep \tcode{e.discard(z)}% \indextext{\idxcode{discard}!random number engine requirement} @@ -1996,13 +1996,13 @@ returns \tcode{true} if $ S_x = S_y $; else returns \tcode{false}. - & \bigoh{$\mbox{size of state}$} + & \bigoh{$\text{size of state}$} \\ \rowsep \tcode{x != y}% \indextext{\idxcode{operator"!=}!random number engine requirement} & \tcode{bool} & \tcode{!(x == y)}. - & \bigoh{$\mbox{size of state}$} + & \bigoh{$\text{size of state}$} \\ \rowsep \tcode{os << x}% \indextext{\idxcode{operator<<}!random number engine requirement} @@ -2018,7 +2018,7 @@ by one or more space characters. \postconditions The \tcode{os.}\textit{fmtflags} and fill character are unchanged. - & \bigoh{$\mbox{size of state}$} + & \bigoh{$\text{size of state}$} \\ \rowsep \tcode{is >> v}% \indextext{\idxcode{operator>>}!random number engine requirement} @@ -2049,16 +2049,16 @@ were respectively the same as those of \tcode{is}. \postconditions The \tcode{is.}\textit{fmtflags} are unchanged. - & \bigoh{$\mbox{size of state}$} + & \bigoh{$\text{size of state}$} \\ \end{libreqtab4d} \pnum -\tcode{E} shall meet the requirements -of \tcode{CopyConstructible} (Table~\ref{tab:copyconstructible}) -and \tcode{CopyAssignable} (Table~\ref{tab:copyassignable}) types. +\tcode{E} shall satisfy the +\tcode{CopyConstructible} (\tref{copyconstructible}) +and \tcode{CopyAssignable} (\tref{copyassignable}) requirements. These operations shall each be of complexity -no worse than \bigoh{\mbox{size of state}}. +no worse than \bigoh{\text{size of state}}. \indextext{requirements!random number engine|)} @@ -2230,7 +2230,7 @@ satisfies the requirements of a \techterm{random number distribution} if the expressions shown -in Table~\ref{tab:RandomDistribution} +in \tref{RandomDistribution} are valid and have the indicated semantics, and if \tcode{D} and its associated types also satisfy all other requirements @@ -2433,9 +2433,9 @@ \end{libreqtab4d} \pnum -\tcode{D} shall satisfy the requirements -of \tcode{CopyConstructible} (Table~\ref{tab:copyconstructible}) -and \tcode{CopyAssignable} (Table~\ref{tab:copyassignable}) types. +\tcode{D} shall satisfy the +\tcode{CopyConstructible} (\tref{copyconstructible}) +and \tcode{CopyAssignable} (\tref{copyassignable}) requirements. \pnum The sequence of numbers @@ -2465,11 +2465,11 @@ for convenience of exposition only. \pnum -\tcode{P} shall satisfy the requirements -of \tcode{CopyConstructible} (Table~\ref{tab:copyconstructible}), -\tcode{CopyAssignable} (Table~\ref{tab:copyassignable}), +\tcode{P} shall satisfy the +\tcode{CopyConstructible} (\tref{copyconstructible}), +\tcode{CopyAssignable} (\tref{copyassignable}), and -\tcode{EqualityComparable} (Table~\ref{tab:equalitycomparable}) types. +\tcode{EqualityComparable} (\tref{equalitycomparable}) requirements. \pnum For each of the constructors of \tcode{D} @@ -3996,7 +3996,7 @@ \begin{itemdescr} \pnum\requires \tcode{InputIterator} shall satisfy the requirements - of an input iterator (Table~\ref{tab:iterator.input.requirements}) type. + of an input iterator (\tref{iterator.input.requirements}) type. Moreover, \tcode{iterator_traits::value_type} shall denote an integer type. @@ -4017,7 +4017,7 @@ \begin{itemdescr} \pnum\requires \tcode{RandomAccessIterator} - shall meet the requirements of a mutable random access iterator\iref{random.access.iterators}. + shall satisfy the requirements of a mutable random access iterator\iref{random.access.iterators}. Moreover, \tcode{iterator_traits::value_type} shall denote an unsigned integer type @@ -6041,7 +6041,7 @@ \pnum\requires \tcode{InputIteratorB} and \tcode{InputIteratorW} shall each satisfy the requirements - of an input iterator (Table~\ref{tab:iterator.input.requirements}) type. + of an input iterator (\tref{iterator.input.requirements}) type. Moreover, \tcode{iterator_traits::value_type} and \tcode{iterator_traits::value_type} @@ -6262,7 +6262,7 @@ \pnum\requires \tcode{InputIteratorB} and \tcode{InputIteratorW} shall each satisfy the requirements - of an input iterator (Table~\ref{tab:iterator.input.requirements}) type. + of an input iterator (\tref{iterator.input.requirements}) type. Moreover, \tcode{iterator_traits::value_type} and \tcode{iterator_traits::value_type} @@ -6417,7 +6417,7 @@ \end{note} \end{itemdescr} -\xref ISO C 7.22.2 +\xrefc{7.22.2} \indextext{random number generation|)} @@ -6818,7 +6818,7 @@ elements of \tcode{v}.\footnote{This copy constructor creates a distinct array rather than an alias. Implementations in which arrays share storage are permitted, but they -shall implement a copy-on-reference mechanism to ensure that arrays are +would need to implement a copy-on-reference mechanism to ensure that arrays are conceptually distinct.} \end{itemdescr} @@ -8790,8 +8790,8 @@ \begin{itemdescr} \pnum \requires -\tcode{T} shall meet the requirements of \tcode{CopyConstructible} (Table~\ref{tab:copyconstructible}) -and \tcode{CopyAssignable} (Table~\ref{tab:copyassignable}) types. +\tcode{T} shall satisfy the \tcode{CopyConstructible} (\tref{copyconstructible}) +and \tcode{CopyAssignable} (\tref{copyassignable}) requirements. In the range \crange{first}{last}, \tcode{binary_op} @@ -8897,7 +8897,7 @@ \pnum \requires \begin{itemize} -\item \tcode{T} shall be \tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}). +\item \tcode{T} shall be \tcode{MoveConstructible} (\tref{moveconstructible}). \item All of \tcode{binary_op(init, *first)}, \tcode{binary_op(*first, init)}, \tcode{binary_op(init, init)}, and \tcode{binary_op(*first, *first)} shall be convertible to \tcode{T}. @@ -8940,8 +8940,8 @@ \begin{itemdescr} \pnum \requires -\tcode{T} shall meet the requirements of \tcode{CopyConstructible} (Table~\ref{tab:copyconstructible}) -and \tcode{CopyAssignable} (Table~\ref{tab:copyassignable}) types. +\tcode{T} shall satisfy the \tcode{CopyConstructible} (\tref{copyconstructible}) +and \tcode{CopyAssignable} (\tref{copyassignable}) requirements. In the ranges \crange{first1}{last1} and @@ -8978,6 +8978,18 @@ T transform_reduce(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, T init); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects Equivalent to: +\begin{codeblock} +return transform_reduce(first1, last1, first2, init, plus<>(), multiplies<>()); +\end{codeblock} +\end{itemdescr} + +\indexlibrary{\idxcode{transform_reduce}}% +\begin{itemdecl} template T transform_reduce(ExecutionPolicy&& exec, @@ -8990,7 +9002,8 @@ \pnum \effects Equivalent to: \begin{codeblock} -return transform_reduce(first1, last1, first2, init, plus<>(), multiplies<>()); +return transform_reduce(std::forward(exec), + first1, last1, first2, init, plus<>(), multiplies<>()); \end{codeblock} \end{itemdescr} @@ -9018,7 +9031,7 @@ \pnum \requires \begin{itemize} -\item \tcode{T} shall be \tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}). +\item \tcode{T} shall be \tcode{MoveConstructible} (\tref{moveconstructible}). \item All of \begin{itemize} \item \tcode{binary_op1(init, init)}, @@ -9062,7 +9075,7 @@ \pnum \requires \begin{itemize} -\item \tcode{T} shall be \tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}). +\item \tcode{T} shall be \tcode{MoveConstructible} (\tref{moveconstructible}). \item All of \begin{itemize} \item \tcode{binary_op(init, init)}, @@ -9199,7 +9212,7 @@ \pnum \requires \begin{itemize} -\item \tcode{T} shall be \tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}). +\item \tcode{T} shall be \tcode{MoveConstructible} (\tref{moveconstructible}). \item All of \tcode{binary_op(init, init)}, \tcode{binary_op(init, *first)}, and \tcode{binary_op(*first, *first)} shall be convertible to \tcode{T}. \item \tcode{binary_op} shall neither invalidate iterators or subranges, nor modify @@ -9230,8 +9243,8 @@ \pnum \begin{note} The difference between \tcode{exclusive_scan} and \tcode{inclusive_scan} is -that \tcode{exclusive_scan} excludes the \tcode{i}th input element from the -\tcode{i}th sum. If \tcode{binary_op} is not mathematically associative, the +that \tcode{exclusive_scan} excludes the $i^\text{th}$ input element from the +$i^\text{th}$ sum. If \tcode{binary_op} is not mathematically associative, the behavior of \tcode{exclusive_scan} may be nondeterministic. \end{note} \end{itemdescr} @@ -9295,7 +9308,7 @@ \requires \begin{itemize} \item If \tcode{init} is provided, \tcode{T} shall be \tcode{MoveConstructible} -(Table~\ref{tab:moveconstructible}); otherwise, \tcode{ForwardIterator1}'s value +(\tref{moveconstructible}); otherwise, \tcode{ForwardIterator1}'s value type shall be \tcode{MoveConstructible}. \item If \tcode{init} is provided, all of \tcode{binary_op(init, init)}, @@ -9336,8 +9349,8 @@ \pnum \begin{note} The difference between \tcode{exclusive_scan} and \tcode{inclusive_scan} is -that \tcode{inclusive_scan} includes the \tcode{i}th input element in the -\tcode{i}th sum. If \tcode{binary_op} is not mathematically associative, the +that \tcode{inclusive_scan} includes the $i^\text{th}$ input element in the +$i^\text{th}$ sum. If \tcode{binary_op} is not mathematically associative, the behavior of \tcode{inclusive_scan} may be nondeterministic. \end{note} \end{itemdescr} @@ -9364,7 +9377,7 @@ \pnum \requires \begin{itemize} -\item \tcode{T} shall be \tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}). +\item \tcode{T} shall be \tcode{MoveConstructible} (\tref{moveconstructible}). \item All of \begin{itemize} \item \tcode{binary_op(init, init)}, @@ -9449,7 +9462,7 @@ \requires \begin{itemize} \item If \tcode{init} is provided, \tcode{T} shall be \tcode{MoveConstructible} -(Table~\ref{tab:moveconstructible}); otherwise, \tcode{ForwardIterator1}'s value +(\tref{moveconstructible}); otherwise, \tcode{ForwardIterator1}'s value type shall be \tcode{MoveConstructible}. \item If \tcode{init} is provided, all of @@ -9534,7 +9547,7 @@ \begin{itemize} \item For the overloads with no \tcode{ExecutionPolicy}, \tcode{InputIterator}'s value -type shall be \tcode{MoveAssignable} (Table~\ref{tab:moveassignable}) and shall +type shall be \tcode{MoveAssignable} (\tref{moveassignable}) and shall be constructible from the type of \tcode{*first}. \tcode{acc} (defined below) shall be writable\iref{iterator.requirements.general} to the \tcode{result} output iterator. The result of the expression \tcode{val - std::move(acc)} or @@ -9543,7 +9556,7 @@ \item For the overloads with an \tcode{ExecutionPolicy}, the value type of \tcode{ForwardIterator1} -shall be \tcode{CopyConstructible} (Table~\ref{tab:copyconstructible}), +shall be \tcode{CopyConstructible} (\tref{copyconstructible}), constructible from the expression \tcode{*first - *first} or \tcode{binary_op(*first, *first)}, and assignable to the value type of \tcode{ForwardIterator2}. @@ -10276,49 +10289,49 @@ int fpclassify(double x); int fpclassify(long double x); - int isfinite(float x); - int isfinite(double x); - int isfinite(long double x); + bool isfinite(float x); + bool isfinite(double x); + bool isfinite(long double x); - int isinf(float x); - int isinf(double x); - int isinf(long double x); + bool isinf(float x); + bool isinf(double x); + bool isinf(long double x); - int isnan(float x); - int isnan(double x); - int isnan(long double x); + bool isnan(float x); + bool isnan(double x); + bool isnan(long double x); - int isnormal(float x); - int isnormal(double x); - int isnormal(long double x); + bool isnormal(float x); + bool isnormal(double x); + bool isnormal(long double x); - int signbit(float x); - int signbit(double x); - int signbit(long double x); + bool signbit(float x); + bool signbit(double x); + bool signbit(long double x); - int isgreater(float x, float y); - int isgreater(double x, double y); - int isgreater(long double x, long double y); + bool isgreater(float x, float y); + bool isgreater(double x, double y); + bool isgreater(long double x, long double y); - int isgreaterequal(float x, float y); - int isgreaterequal(double x, double y); - int isgreaterequal(long double x, long double y); + bool isgreaterequal(float x, float y); + bool isgreaterequal(double x, double y); + bool isgreaterequal(long double x, long double y); - int isless(float x, float y); - int isless(double x, double y); - int isless(long double x, long double y); + bool isless(float x, float y); + bool isless(double x, double y); + bool isless(long double x, long double y); - int islessequal(float x, float y); - int islessequal(double x, double y); - int islessequal(long double x, long double y); + bool islessequal(float x, float y); + bool islessequal(double x, double y); + bool islessequal(long double x, long double y); - int islessgreater(float x, float y); - int islessgreater(double x, double y); - int islessgreater(long double x, long double y); + bool islessgreater(float x, float y); + bool islessgreater(double x, double y); + bool islessgreater(long double x, long double y); - int isunordered(float x, float y); - int isunordered(double x, double y); - int isunordered(long double x, long double y); + bool isunordered(float x, float y); + bool isunordered(double x, double y); + bool isunordered(long double x, long double y); // \ref{sf.cmath}, mathematical special functions @@ -10511,7 +10524,7 @@ \end{note} \end{itemdescr} -\xref ISO C 7.12.7.2, 7.22.6.1 +\xrefc{7.12.7.2, 7.22.6.1} \rSec2[c.math.hypot3]{Three-dimensional hypotenuse} diff --git a/source/overloading.tex b/source/overloading.tex index 5155c3b3a5..85e5832f5b 100644 --- a/source/overloading.tex +++ b/source/overloading.tex @@ -18,10 +18,11 @@ cannot be overloaded. \pnum -When an overloaded function name is used in a call, which overloaded function -declaration is being referenced is determined by comparing the types +When a function name is used in a call, which function +declaration is being referenced and the validity of the call +are determined by comparing the types of the arguments at the point of use with the types of the parameters -in the overloaded declarations that are visible at the point of use. +in the declarations that are visible at the point of use. This function selection process is called \defn{overload resolution} and is defined in~\ref{over.match}. \begin{example} @@ -496,7 +497,7 @@ functions to be resolved against the same argument list. So that argument and parameter lists are comparable within this heterogeneous set, a member function is considered to have an -extra parameter, called the +extra first parameter, called the \defn{implicit object parameter}, which represents the object for which the member function has been called. @@ -508,13 +509,8 @@ Similarly, when appropriate, the context can construct an argument list that contains an \defn{implied object argument} -to denote +as the first argument in the list to denote the object to be operated on. -Since arguments and parameters are -associated by position within their respective lists, the -convention is that the implicit object parameter, if present, is -always the first parameter and the implied object argument, if -present, is always the first argument. \pnum For non-static member functions, the type of the implicit object @@ -951,7 +947,7 @@ operator. Therefore, the operator notation is first transformed to the equivalent function-call notation as summarized in -Table~\ref{tab:over.rel.op.func} +\tref{over.rel.op.func} (where \tcode{@} denotes one of the operators covered in the specified subclause). However, the operands are sequenced in the order prescribed for the built-in operator\iref{expr.compound}. @@ -979,10 +975,12 @@ \tcode{T1} and a right operand of a type whose cv-unqualified version is \tcode{T2}, -three sets of candidate functions, designated +four sets of candidate functions, designated \defnx{member candidates}{member candidate}, -\defnx{non-member candidates}{non-member candidate} -and \defnx{built-in candidates}{built-in candidate}, +\defnx{non-member candidates}{non-member candidate}, +\defnx{built-in candidates}{built-in candidate}, +and +\defnx{rewritten candidates}{rewritten candidate}, are constructed as follows: \begin{itemize} \item @@ -1037,6 +1035,37 @@ do not have the same parameter-type-list as any non-member candidate that is not a function template specialization. \end{itemize} + +\item +For the +relational\iref{expr.rel} and +equality\iref{expr.eq} operators, +the rewritten candidates include +all member, non-member, and built-in candidates +for the operator \tcode{<=>} +for which the rewritten expression +\tcode{(x <=> y) @ 0} is well-formed using that \tcode{operator<=>}. +For the +relational\iref{expr.rel}, +equality\iref{expr.eq}, +and +three-way comparison\iref{expr.spaceship} +operators, +the rewritten candidates also include +a synthesized candidate, +with the order of the two parameters reversed, +for each member, non-member, and built-in candidate +for the operator \tcode{<=>} +for which the rewritten expression +\tcode{0 @ (y <=> x)} is well-formed using that \tcode{operator<=>}. +\begin{note} +A candidate synthesized from a member candidate has its implicit +object parameter as the second parameter, thus implicit conversions +are considered for the first, but not for the second, parameter. +\end{note} +In each case, rewritten candidates are not considered +in the context of the rewritten expression. +For all other operators, the rewritten candidate set is empty. \end{itemize} \pnum @@ -1058,24 +1087,12 @@ The set of candidate functions for overload resolution for some operator \tcode{@} is the -union of the member candidates, the non-member candidates, and -the built-in candidates for that operator \tcode{@}. -If that operator is a -relational\iref{expr.rel} or equality\iref{expr.eq} operator -with operands \tcode{x} and \tcode{y}, -then for each member, non-member, or built-in candidate -for the operator \tcode{<=>}: -\begin{itemize} -\item -that operator is added to the set of candidate functions for overload resolution -if \tcode{x <=> y @ 0} is well-formed using that \tcode{operator<=>}; and -\item -a synthesized candidate is added to the candidate set -where the order of the two parameters is reversed -if \tcode{0 @ y <=> x} is well-formed using that \tcode{operator<=>}; -\end{itemize} -where in each case \tcode{operator<=>} candidates -are not considered for the recursive lookup of operator \tcode{@}. +union of +the member candidates, +the non-member candidates, +the built-in candidates, +and the rewritten candidates +for that operator \tcode{@}. \pnum The argument list contains all of the @@ -1099,15 +1116,15 @@ \end{example} \pnum -If an \tcode{operator<=>} candidate +If a rewritten candidate is selected by overload resolution for an operator \tcode{@}, -but \tcode{@} is not \tcode{<=>}, \tcode{x @ y} -is interpreted as \tcode{0 @ y <=> x} +is interpreted as the rewritten expression: +\tcode{0 @ (y <=> x)} if the selected candidate is a synthesized candidate with reversed order of parameters, -or \tcode{x <=> y @ 0} otherwise, -using the selected \tcode{operator<=>} candidate. +or \tcode{(x <=> y) @ 0} otherwise, +using the selected rewritten \tcode{operator<=>} candidate. \pnum If a built-in candidate is selected by overload resolution, the @@ -1747,10 +1764,8 @@ or, if not that, \item -\tcode{F1} is an operator function -for a relational\iref{expr.rel} or equality\iref{expr.eq} operator -and \tcode{F2} is an operator function -for a three-way comparison operator\iref{expr.spaceship} +\tcode{F2} is a rewritten candidate\iref{over.match.oper} and +\tcode{F1} is not \begin{example} \begin{codeblock} struct S { @@ -1763,8 +1778,7 @@ or, if not that, \item -\tcode{F1} and \tcode{F2} are operator functions -for \tcode{operator<=>} and +\tcode{F1} and \tcode{F2} are rewritten candidates, and \tcode{F2} is a synthesized candidate with reversed order of parameters and \tcode{F1} is not @@ -2017,12 +2031,12 @@ derived class type, the implicit conversion sequence is a derived-to-base \indextext{conversion!derived-to-base}% -Conversion from the derived class to the base class. +conversion from the derived class to the base class. \begin{note} -There is no such standard conversion; this derived-to-base Conversion exists +There is no such standard conversion; this derived-to-base conversion exists only in the description of implicit conversion sequences. \end{note} -A derived-to-base Conversion has Conversion rank\iref{over.ics.scs}. +A derived-to-base conversion has Conversion rank\iref{over.ics.scs}. \pnum In all contexts, when converting to the implicit object parameter @@ -2078,7 +2092,7 @@ \rSec4[over.ics.scs]{Standard conversion sequences} \pnum -Table~\ref{tab:over.conversions} +\tref{over.conversions} summarizes the conversions defined in \ref{conv} and partitions them into four disjoint categories: Lvalue Transformation, Qualification Adjustment, Promotion, and Conversion. @@ -2110,7 +2124,7 @@ \pnum \indextext{conversion rank}% -Each conversion in Table~\ref{tab:over.conversions} +Each conversion in \tref{over.conversions} also has an associated rank (Exact Match, Promotion, or Conversion). These are used @@ -2212,7 +2226,7 @@ conversion sequence is a user-defined conversion sequence\iref{over.ics.user}, with the second standard conversion sequence either an identity conversion or, if the conversion function returns an entity of a type that is a derived class -of the parameter type, a derived-to-base Conversion. +of the parameter type, a derived-to-base conversion. \pnum When a parameter of reference type is not bound directly to an argument @@ -2900,7 +2914,7 @@ other than those listed. \begin{note} Any redundant set of parentheses surrounding the overloaded function name is -ignored\iref{expr.prim}. +ignored\iref{expr.prim.paren}. \end{note} \pnum @@ -3599,7 +3613,7 @@ \tcode{char}). Similarly, the term \defn{promoted arithmetic type} -refers to floating types plus promoted integral types. +refers to floating-point types plus promoted integral types. \begin{note} In all cases where a promoted integral type or promoted arithmetic type is required, an operand of enumeration type will be acceptable by way of the diff --git a/source/preprocessor.tex b/source/preprocessor.tex index 6736608d48..7ec0e0e122 100644 --- a/source/preprocessor.tex +++ b/source/preprocessor.tex @@ -1292,11 +1292,12 @@ \indextext{__CPLUSPLUS@\xname{cplusplus}}% \item \xname{cplusplus}\\ -The integer literal \tcode{\cppver}.\footnote{It is intended that future +The integer literal \tcode{\cppver}. +\begin{note} +It is intended that future versions of this International Standard will replace the value of this macro with a greater value. -Non-conforming compilers should use a value with at most -five decimal digits.} +\end{note} \indextext{__DATE__@\mname{DATE}}% \item \mname{DATE}\\ diff --git a/source/regex.tex b/source/regex.tex index ce8abb915d..95db9fb1d2 100644 --- a/source/regex.tex +++ b/source/regex.tex @@ -18,7 +18,7 @@ result of a regular expression match, a series of algorithms that allow a character sequence to be operated upon by a regular expression, and two iterator types for -enumerating regular expression matches, as described in Table~\ref{tab:re.lib.summary}. +enumerating regular expression matches, as described in \tref{re.lib.summary}. \begin{libsumtab}{Regular expressions library summary}{tab:re.lib.summary} \ref{re.def} & Definitions & \\ @@ -108,7 +108,7 @@ \indextext{requirements!regular expression traits}% \indextext{regular expression!requirements}% \indextext{locale}% -In Table~\ref{tab:re:RegexpTraits} \tcode{X} denotes a traits class +In \tref{re:RegexpTraits} \tcode{X} denotes a traits class defining types and functions for the character container type \tcode{charT}; \tcode{u} is an object of type \tcode{X}; \tcode{v} is an object of type \tcode{const @@ -654,7 +654,7 @@ \indexlibrary{\idxcode{syntax_option_type}!\idxcode{egrep}}% The type \tcode{syntax_option_type} is an \impldef{type of \tcode{syntax_option_type}} bitmask type\iref{bitmask.types}. Setting its elements has the effects listed in -Table~\ref{tab:re:syntaxoption}. A valid value of type +\tref{re:syntaxoption}. A valid value of type \tcode{syntax_option_type} shall have at most one of the grammar elements \tcode{ECMAScript}, \tcode{basic}, \tcode{extended}, \tcode{awk}, \tcode{grep}, \tcode{egrep}, set. If no grammar element is set, the default grammar is \tcode{ECMAScript}. @@ -696,22 +696,23 @@ \tcode{ECMAScript} & Specifies that the grammar recognized by the regular expression engine shall be that used by ECMAScript in ECMA-262, as modified in~\ref{re.grammar}. +\newline \xref ECMA-262 15.10 \indextext{ECMAScript}% \indexlibrary{\idxcode{syntax_option_type}!\idxcode{ECMAScript}}% \\ \rowsep % \tcode{basic} & Specifies that the grammar recognized by the regular expression engine -shall be that used by basic regular expressions in POSIX, Base Definitions and -Headers, Section 9, Regular Expressions. +shall be that used by basic regular expressions in POSIX. +\newline \xref POSIX, Base Definitions and Headers, Section 9.3 \indextext{POSIX!regular expressions}% \indexlibrary{\idxcode{syntax_option_type}!\idxcode{basic}}% \\ \rowsep % \tcode{extended} & Specifies that the grammar recognized by the regular expression engine -shall be that used by extended regular expressions in POSIX, Base Definitions and -Headers, Section 9, Regular Expressions. +shall be that used by extended regular expressions in POSIX. +\newline \xref POSIX, Base Definitions and Headers, Section 9.4 \indextext{POSIX!extended regular expressions}% \indexlibrary{\idxcode{syntax_option_type}!\idxcode{extended}}% \\ \rowsep @@ -793,7 +794,7 @@ \tcode{format_default} constants are empty bitmasks. Matching a regular expression against a sequence of characters \range{first}{last} proceeds according to the rules of the grammar specified for the regular -expression object, modified according to the effects listed in Table~\ref{tab:re:matchflag} for +expression object, modified according to the effects listed in \tref{re:matchflag} for any bitmask elements set. \begin{longlibefftab} @@ -912,7 +913,7 @@ The type \tcode{error_type} is an \impldef{type of \tcode{regex_constants::error_type}} enumerated type\iref{enumerated.types}. Values of type \tcode{error_type} represent the error -conditions described in Table~\ref{tab:re:errortype}: +conditions described in \tref{re:errortype}: \begin{longliberrtab} {\tcode{error_type} values in the C locale} @@ -1165,9 +1166,9 @@ \pnum \remarks For \tcode{regex_traits}, at least the narrow character names -in Table~\ref{tab:re.traits.classnames} shall be recognized. +in \tref{re.traits.classnames} shall be recognized. For \tcode{regex_traits}, at least the wide character names -in Table~\ref{tab:re.traits.classnames} shall be recognized. +in \tref{re.traits.classnames} shall be recognized. \end{itemdescr} \indexlibrarymember{regex_traits}{isctype}% @@ -1188,7 +1189,7 @@ ctype_base::mask convert(typename regex_traits::char_class_type f); \end{codeblock} that returns a value in which each \tcode{ctype_base::mask} value corresponding to -a value in \tcode{f} named in Table~\ref{tab:re.traits.classnames} is set, then the +a value in \tcode{f} named in \tref{re.traits.classnames} is set, then the result is determined as if by: \begin{codeblock} ctype_base::mask m = convert(f); @@ -1336,29 +1337,18 @@ using flag_type = regex_constants::syntax_option_type; using locale_type = typename traits::locale_type; - // \ref{re.regex.const}, constants - static constexpr regex_constants::syntax_option_type - icase = regex_constants::icase; - static constexpr regex_constants::syntax_option_type - nosubs = regex_constants::nosubs; - static constexpr regex_constants::syntax_option_type - optimize = regex_constants::optimize; - static constexpr regex_constants::syntax_option_type - collate = regex_constants::collate; - static constexpr regex_constants::syntax_option_type - ECMAScript = regex_constants::ECMAScript; - static constexpr regex_constants::syntax_option_type - basic = regex_constants::basic; - static constexpr regex_constants::syntax_option_type - extended = regex_constants::extended; - static constexpr regex_constants::syntax_option_type - awk = regex_constants::awk; - static constexpr regex_constants::syntax_option_type - grep = regex_constants::grep; - static constexpr regex_constants::syntax_option_type - egrep = regex_constants::egrep; - static constexpr regex_constants::syntax_option_type - multiline = regex_constants::multiline; + // \ref{re.synopt}, constants + static constexpr flag_type icase = regex_constants::icase; + static constexpr flag_type nosubs = regex_constants::nosubs; + static constexpr flag_type optimize = regex_constants::optimize; + static constexpr flag_type collate = regex_constants::collate; + static constexpr flag_type ECMAScript = regex_constants::ECMAScript; + static constexpr flag_type basic = regex_constants::basic; + static constexpr flag_type extended = regex_constants::extended; + static constexpr flag_type awk = regex_constants::awk; + static constexpr flag_type grep = regex_constants::grep; + static constexpr flag_type egrep = regex_constants::egrep; + static constexpr flag_type multiline = regex_constants::multiline; // \ref{re.regex.construct}, construct/copy/destroy basic_regex(); @@ -1416,28 +1406,6 @@ } \end{codeblock} -\rSec2[re.regex.const]{\tcode{basic_regex} constants} -\indexlibrary{\idxcode{basic_regex}!constants}% - -\begin{codeblock} -static constexpr regex_constants::syntax_option_type icase = regex_constants::icase; -static constexpr regex_constants::syntax_option_type nosubs = regex_constants::nosubs; -static constexpr regex_constants::syntax_option_type optimize = regex_constants::optimize; -static constexpr regex_constants::syntax_option_type collate = regex_constants::collate; -static constexpr regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript; -static constexpr regex_constants::syntax_option_type basic = regex_constants::basic; -static constexpr regex_constants::syntax_option_type extended = regex_constants::extended; -static constexpr regex_constants::syntax_option_type awk = regex_constants::awk; -static constexpr regex_constants::syntax_option_type grep = regex_constants::grep; -static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep; -static constexpr regex_constants::syntax_option_type multiline = regex_constants::multiline; -\end{codeblock} - -\pnum -\indexlibrary{\idxcode{basic_regex}!constants}% -The static constant members are provided as synonyms for the constants -declared in namespace \tcode{regex_constants}. - \rSec2[re.regex.construct]{\tcode{basic_regex} constructors} \indexlibrary{\idxcode{basic_regex}!constructor}% @@ -2606,7 +2574,7 @@ \begin{itemdescr} \pnum \effects\ Move constructs an object of class \tcode{match_results} from \tcode{m} -satisfying the same postconditions as Table~\ref{tab:re:results:assign}. Additionally, +satisfying the same postconditions as \tref{re:results:assign}. Additionally, the stored \tcode{Allocator} value is move constructed from \tcode{m.get_allocator()}. \pnum @@ -2621,7 +2589,7 @@ \begin{itemdescr} \pnum \effects Assigns \tcode{m} to \tcode{*this}. The postconditions of this -function are indicated in Table~\ref{tab:re:results:assign}. +function are indicated in \tref{re:results:assign}. \end{itemdescr} \indexlibrarymember{match_results}{operator=}% @@ -2632,7 +2600,7 @@ \begin{itemdescr} \pnum \effects\ Move-assigns \tcode{m} to \tcode{*this}. The postconditions of this function -are indicated in Table~\ref{tab:re:results:assign}. +are indicated in \tref{re:results:assign}. \end{itemdescr} \begin{libefftabvalue} @@ -3012,7 +2980,7 @@ \begin{itemdescr} \pnum \requires The type \tcode{BidirectionalIterator} shall satisfy the requirements -of a Bidirectional Iterator\iref{bidirectional.iterators}. +of a bidirectional iterator\iref{bidirectional.iterators}. \pnum \effects Determines whether there is a match between the @@ -3041,7 +3009,7 @@ on parameter \tcode{m} is unspecified except that \tcode{m.size()} returns \tcode{0} and \tcode{m.empty()} returns \tcode{true}. Otherwise the effects on parameter \tcode{m} are given in -Table~\ref{tab:re:alg:match}. +\tref{re:alg:match}. \end{itemdescr} \begin{longlibefftabvalue} @@ -3194,8 +3162,8 @@ \begin{itemdescr} \pnum -\requires Type \tcode{BidirectionalIterator} shall satisfy the requirements of a Bidirectional -Iterator\iref{bidirectional.iterators}. +\requires Type \tcode{BidirectionalIterator} shall satisfy the requirements of a bidirectional +iterator\iref{bidirectional.iterators}. \pnum \effects Determines whether there is some sub-sequence within \range{first}{last} that matches @@ -3209,7 +3177,7 @@ If the function returns \tcode{false}, then the effect on parameter \tcode{m} is unspecified except that \tcode{m.size()} returns \tcode{0} and \tcode{m.empty()} returns \tcode{true}. Otherwise -the effects on parameter \tcode{m} are given in Table~\ref{tab:re:alg:search}. +the effects on parameter \tcode{m} are given in \tref{re:alg:search}. \end{itemdescr} \begin{longlibefftabvalue} @@ -4224,4 +4192,5 @@ \indextext{regular expression traits!\idxcode{lookup_classname}}% \indextext{\idxcode{lookup_classname}!regular expression traits}% \end{itemize} +\xref ECMA-262 15.10 \indextext{regular expression|)} diff --git a/source/special.tex b/source/special.tex index 924326182b..918ef4ba66 100644 --- a/source/special.tex +++ b/source/special.tex @@ -33,7 +33,7 @@ \pnum Programs may explicitly refer to implicitly-declared special member functions. \begin{example} -A program may explicitly call, take the address of, or form a pointer to member +A program may explicitly call or form a pointer to member to an implicitly-declared special member function. \begin{codeblock} @@ -89,16 +89,10 @@ \begin{itemize} \item in a \grammarterm{member-declaration} that belongs to the -\grammarterm{member-specification} of a class but is not a friend +\grammarterm{member-specification} of a class or class template +but is not a friend declaration\iref{class.friend}, the \grammarterm{id-expression} is the -injected-class-name\iref{class} of the immediately-enclosing class; - -\item -in a \grammarterm{member-declaration} that belongs to the -\grammarterm{member-specification} of a class template but is not a friend -declaration, the \grammarterm{id-expression} is a \grammarterm{class-name} that -names the current instantiation\iref{temp.dep.type} of the -immediately-enclosing class template; or +injected-class-name\iref{class} of the immediately-enclosing entity or \item in a declaration at namespace scope or in a friend declaration, the @@ -304,8 +298,6 @@ The syntax looks like an explicit call of the constructor. \end{note} \begin{example} -\indextext{example!constructor}% - \begin{codeblock} complex zz = complex(1,2.3); cprint( complex(7.8,1.2) ); @@ -571,6 +563,7 @@ \begin{codeblock} template using id = T; +int i = 1; int&& a = id{1, 2, 3}[i]; // temporary array has same lifetime as \tcode{a} const int& b = static_cast(0); // temporary \tcode{int} has same lifetime as \tcode{b} int&& c = cond ? id{1, 2, 3}[i] : static_cast(0); @@ -1023,17 +1016,11 @@ \begin{itemize} \item in a \grammarterm{member-declaration} that belongs to the -\grammarterm{member-specification} of a class but is not a friend +\grammarterm{member-specification} of a class or class template +but is not a friend declaration\iref{class.friend}, the \grammarterm{id-expression} is \tcode{\~}\grammarterm{class-name} and the \grammarterm{class-name} is the -injected-class-name\iref{class} of the immediately-enclosing class; - -\item -in a \grammarterm{member-declaration} that belongs to the -\grammarterm{member-specification} of a class template but is not a friend -declaration, the \grammarterm{id-expression} is -\tcode{\~}\grammarterm{class-name} and the \grammarterm{class-name} names the -current instantiation\iref{temp.dep.type} of the immediately-enclosing class template; or +injected-class-name\iref{class} of the immediately-enclosing entity or \item in a declaration at namespace scope or in a friend declaration, the @@ -1206,8 +1193,8 @@ \begin{note} An array of class type contains several subobjects for each of which the destructor is invoked. \end{note} A destructor can also be invoked explicitly. A destructor is \term{potentially invoked} -if it is invoked or as specified in~\ref{expr.new}, \ref{class.base.init}, -and~\ref{except.throw}. +if it is invoked or as specified in~\ref{expr.new}, \ref{dcl.init.aggr}, +\ref{class.base.init}, and~\ref{except.throw}. A program is ill-formed if a destructor that is potentially invoked is deleted or not accessible from the context of the invocation. @@ -1264,7 +1251,7 @@ \end{example} \begin{note} An explicit destructor call must always be written using -a member access operator\iref{expr.ref} or a \grammarterm{qualified-id}\iref{expr.prim}; +a member access operator\iref{expr.ref} or a \grammarterm{qualified-id}\iref{expr.prim.id.qual}; in particular, the \grammarterm{unary-expression} \tcode{\~{}X()} @@ -1282,7 +1269,6 @@ to cope with dedicated hardware resources and for writing memory management facilities. For example, -\indextext{example!explicit destructor call}% \begin{codeblock} void* operator new(std::size_t, void* p) { return p; } struct X { @@ -1398,9 +1384,7 @@ \tcode{X} is a static member (even if not explicitly declared \tcode{static}). -\indextext{example!\idxcode{delete}}% \begin{example} - \begin{codeblock} class X { void operator delete(void*); @@ -1419,8 +1403,6 @@ \tcode{static} they cannot be virtual. \begin{note} -\indextext{example!destructor and \tcode{delete}}% -\indextext{example!scope of \tcode{delete}}% However, when the \grammarterm{cast-expression} of a @@ -1542,7 +1524,6 @@ form of initialization. Either direct-initialization semantics or copy-initialization semantics apply; see~\ref{dcl.init}. -\indextext{example!constructor and initialization}% \begin{example} \begin{codeblock} struct complex { diff --git a/source/statements.tex b/source/statements.tex index 857e2de2d3..666864ecc7 100644 --- a/source/statements.tex +++ b/source/statements.tex @@ -35,7 +35,10 @@ \indextext{\idxgram{condition}{s}!rules for}% The rules for \grammarterm{condition}{s} apply both to \grammarterm{selection-statement}{s} and to the \tcode{for} and \tcode{while} -statements\iref{stmt.iter}. The \grammarterm{declarator} shall not +statements\iref{stmt.iter}. +A \grammarterm{condition} that is not an \grammarterm{expression} is a +declaration\iref{dcl.dcl}. +The \grammarterm{declarator} shall not specify a function or an array. The \grammarterm{decl-specifier-seq} shall not define a class or enumeration. If the \tcode{auto} \grammarterm{type-specifier} appears in the \grammarterm{decl-specifier-seq}, @@ -507,26 +510,23 @@ When the condition of a \tcode{while} statement is a declaration, the scope of the variable that is declared extends from its point of declaration\iref{basic.scope.pdecl} to the end of the \tcode{while} -\grammarterm{statement}. A \tcode{while} statement of the form - -\begin{codeblock} -while (T t = x) @\grammarterm{statement}@ -\end{codeblock} - +\grammarterm{statement}. A \tcode{while} statement whose \grammarterm{condition} +is an initialized declaration of some variable \tcode{t} is equivalent to -\begin{codeblock} -label: -{ // start of condition scope - T t = x; - if (t) { - @\grammarterm{statement}@ - goto label; - } -} // end of condition scope -\end{codeblock} +\begin{ncbnftab} +\terminal{label:}\br +\terminal{\{}\>\>\>// start of condition scope\br +\>condition \terminal{;}\>\>// declares \terminal{t}\br +\>\terminal{if (t) \{}\br +\>\>statement\br +\>\>\terminal{goto label;}\br +\>\terminal{\}}\br +\terminal{\}}\>\>\>// end of condition scope +\end{ncbnftab} -The variable created in a condition is destroyed and created with each +\begin{note} +The variable created in the condition is destroyed and created with each iteration of the loop. \begin{example} @@ -548,6 +548,7 @@ once for the condition that succeeds and once for the condition that fails. \end{example} +\end{note} \rSec2[stmt.do]{The \tcode{do} statement}% \indextext{statement!\idxcode{do}} @@ -672,8 +673,8 @@ \item if the \grammarterm{for-range-initializer} is an expression of class type \tcode{C}, the \grammarterm{unqualified-id}{s} \tcode{begin} and \tcode{end} are looked up in the scope of \tcode{C} -as if by class member access lookup\iref{basic.lookup.classref}, and if either -(or both) finds at least one declaration, \placeholder{begin-expr} and +as if by class member access lookup\iref{basic.lookup.classref}, and if +both find at least one declaration, \placeholder{begin-expr} and \placeholder{end-expr} are \tcode{__range.begin()} and \tcode{__range.end()}, respectively; @@ -898,7 +899,9 @@ \indextext{initialization!jump past}% \indextext{\idxcode{goto}!initialization and}% It is possible to transfer into a block, but not in a way that bypasses -declarations with initialization. A program that jumps\footnote{The transfer from the condition of a \tcode{switch} statement to a +declarations with initialization (including ones in \grammarterm{condition}s +and \grammarterm{init-statement}s). +A program that jumps\footnote{The transfer from the condition of a \tcode{switch} statement to a \tcode{case} label is considered a jump in this respect.} from a point where a variable with automatic storage duration is not in scope to a point where it is in scope is ill-formed unless the diff --git a/source/std.tex b/source/std.tex index 1e6106fe99..8335379149 100644 --- a/source/std.tex +++ b/source/std.tex @@ -74,7 +74,7 @@ %%-------------------------------------------------- %% add special hyphenation rules -\hyphenation{tem-plate ex-am-ple in-put-it-er-a-tor name-space name-spaces non-zero} +\hyphenation{tem-plate ex-am-ple in-put-it-er-a-tor name-space name-spaces non-zero cus-tom-i-za-tion} %%-------------------------------------------------- %% turn off all ligatures inside \texttt diff --git a/source/strings.tex b/source/strings.tex index fd21544b10..3b0cfd8e78 100644 --- a/source/strings.tex +++ b/source/strings.tex @@ -5,7 +5,7 @@ \pnum This Clause describes components for manipulating sequences of -any non-array trivial\iref{basic.types} type. +any non-array trivial standard-layout\iref{basic.types} type. Such types are called \defnx{char-like types}{char-like type}, and objects of char-like types are called \defnx{char-like objects}{char-like object} or @@ -15,7 +15,7 @@ The following subclauses describe a character traits class, string classes, and null-terminated sequence utilities, -as summarized in Table~\ref{tab:strings.lib.summary}. +as summarized in \tref{strings.lib.summary}. \begin{libsumtab}{Strings library summary}{tab:strings.lib.summary} \ref{char.traits} & Character traits & \tcode{} \\ \rowsep @@ -83,7 +83,7 @@ \rSec2[char.traits.require]{Character traits requirements} \pnum -In Table~\ref{tab:char.traits.require}, +In \tref{char.traits.require}, \tcode{X} denotes a Traits class defining types and functions for the character container type @@ -275,10 +275,10 @@ \pnum \requires \tcode{state_type} -shall meet the requirements of -\tcode{CopyAssignable} (Table~\ref{tab:copyassignable}), -\tcode{CopyConstructible} (Table~\ref{tab:copyconstructible}), and -\tcode{DefaultConstructible} (Table~\ref{tab:defaultconstructible}) types. +shall satisfy the +\tcode{CopyAssignable} (\tref{copyassignable}), +\tcode{CopyConstructible} (\tref{copyconstructible}), and +\tcode{DefaultConstructible} (\tref{defaultconstructible}) requirements. \end{itemdescr} \rSec2[char.traits.specializations]{\tcode{char_traits} specializations} @@ -924,7 +924,8 @@ const Allocator& a = Allocator()); template basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); - explicit basic_string(basic_string_view sv, const Allocator& a = Allocator()); + template + explicit basic_string(const T& t, const Allocator& a = Allocator()); basic_string(const charT* s, size_type n, const Allocator& a = Allocator()); basic_string(const charT* s, const Allocator& a = Allocator()); basic_string(size_type n, charT c, const Allocator& a = Allocator()); @@ -939,7 +940,8 @@ basic_string& operator=(basic_string&& str) noexcept(allocator_traits::propagate_on_container_move_assignment::value || allocator_traits::is_always_equal::value); - basic_string& operator=(basic_string_view sv); + template + basic_string& operator=(const T& t); basic_string& operator=(const charT* s); basic_string& operator=(charT c); basic_string& operator=(initializer_list); @@ -967,7 +969,7 @@ void resize(size_type n, charT c); void resize(size_type n); size_type capacity() const noexcept; - void reserve(size_type res_arg = 0); + void reserve(size_type res_arg); void shrink_to_fit(); void clear() noexcept; [[nodiscard]] bool empty() const noexcept; @@ -985,13 +987,15 @@ // \ref{string.modifiers}, modifiers basic_string& operator+=(const basic_string& str); - basic_string& operator+=(basic_string_view sv); + template + basic_string& operator+=(const T& t); basic_string& operator+=(const charT* s); basic_string& operator+=(charT c); basic_string& operator+=(initializer_list); basic_string& append(const basic_string& str); basic_string& append(const basic_string& str, size_type pos, size_type n = npos); - basic_string& append(basic_string_view sv); + template + basic_string& append(const T& t); template basic_string& append(const T& t, size_type pos, size_type n = npos); basic_string& append(const charT* s, size_type n); @@ -1008,7 +1012,8 @@ noexcept(allocator_traits::propagate_on_container_move_assignment::value || allocator_traits::is_always_equal::value); basic_string& assign(const basic_string& str, size_type pos, size_type n = npos); - basic_string& assign(basic_string_view sv); + template + basic_string& assign(const T& t); template basic_string& assign(const T& t, size_type pos, size_type n = npos); basic_string& assign(const charT* s, size_type n); @@ -1021,7 +1026,8 @@ basic_string& insert(size_type pos, const basic_string& str); basic_string& insert(size_type pos1, const basic_string& str, size_type pos2, size_type n = npos); - basic_string& insert(size_type pos, basic_string_view sv); + template + basic_string& insert(size_type pos, const T& t); template basic_string& insert(size_type pos1, const T& t, size_type pos2, size_type n = npos); basic_string& insert(size_type pos, const charT* s, size_type n); @@ -1042,7 +1048,8 @@ basic_string& replace(size_type pos1, size_type n1, const basic_string& str); basic_string& replace(size_type pos1, size_type n1, const basic_string& str, size_type pos2, size_type n2 = npos); - basic_string& replace(size_type pos1, size_type n1, basic_string_view sv); + template + basic_string& replace(size_type pos1, size_type n1, const T& t); template basic_string& replace(size_type pos1, size_type n1, const T& t, size_type pos2, size_type n2 = npos); @@ -1051,8 +1058,8 @@ basic_string& replace(size_type pos, size_type n1, size_type n2, charT c); basic_string& replace(const_iterator i1, const_iterator i2, const basic_string& str); - basic_string& replace(const_iterator i1, const_iterator i2, - basic_string_view sv); + template + basic_string& replace(const_iterator i1, const_iterator i2, const T& t); basic_string& replace(const_iterator i1, const_iterator i2, const charT* s, size_type n); basic_string& replace(const_iterator i1, const_iterator i2, const charT* s); basic_string& replace(const_iterator i1, const_iterator i2, size_type n, charT c); @@ -1074,46 +1081,50 @@ operator basic_string_view() const noexcept; allocator_type get_allocator() const noexcept; - size_type find (basic_string_view sv, size_type pos = 0) const noexcept; + template + size_type find (const T& t, size_type pos = 0) const; size_type find (const basic_string& str, size_type pos = 0) const noexcept; size_type find (const charT* s, size_type pos, size_type n) const; size_type find (const charT* s, size_type pos = 0) const; size_type find (charT c, size_type pos = 0) const; - size_type rfind(basic_string_view sv, size_type pos = npos) const noexcept; + template + size_type rfind(const T& t, size_type pos = npos) const; size_type rfind(const basic_string& str, size_type pos = npos) const noexcept; size_type rfind(const charT* s, size_type pos, size_type n) const; size_type rfind(const charT* s, size_type pos = npos) const; size_type rfind(charT c, size_type pos = npos) const; - size_type find_first_of(basic_string_view sv, - size_type pos = 0) const noexcept; + template + size_type find_first_of(const T& t, size_type pos = 0) const; size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept; size_type find_first_of(const charT* s, size_type pos, size_type n) const; size_type find_first_of(const charT* s, size_type pos = 0) const; size_type find_first_of(charT c, size_type pos = 0) const; - size_type find_last_of (basic_string_view sv, - size_type pos = npos) const noexcept; + template + size_type find_last_of (const T& t, size_type pos = npos) const; size_type find_last_of (const basic_string& str, size_type pos = npos) const noexcept; size_type find_last_of (const charT* s, size_type pos, size_type n) const; size_type find_last_of (const charT* s, size_type pos = npos) const; size_type find_last_of (charT c, size_type pos = npos) const; - size_type find_first_not_of(basic_string_view sv, - size_type pos = 0) const noexcept; + template + size_type find_first_not_of(const T& t, size_type pos = 0) const; size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept; size_type find_first_not_of(const charT* s, size_type pos, size_type n) const; size_type find_first_not_of(const charT* s, size_type pos = 0) const; size_type find_first_not_of(charT c, size_type pos = 0) const; - size_type find_last_not_of (basic_string_view sv, - size_type pos = npos) const noexcept; + template + size_type find_last_not_of (const T& t, size_type pos = npos) const; size_type find_last_not_of (const basic_string& str, size_type pos = npos) const noexcept; size_type find_last_not_of (const charT* s, size_type pos, size_type n) const; size_type find_last_not_of (const charT* s, size_type pos = npos) const; size_type find_last_not_of (charT c, size_type pos = npos) const; basic_string substr(size_type pos = 0, size_type n = npos) const; - int compare(basic_string_view sv) const noexcept; - int compare(size_type pos1, size_type n1, basic_string_view sv) const; + template + int compare(const T& t) const; + template + int compare(size_type pos1, size_type n1, const T& t) const; template int compare(size_type pos1, size_type n1, const T& t, size_type pos2, size_type n2 = npos) const; @@ -1139,10 +1150,30 @@ -> basic_string::value_type, char_traits::value_type>, Allocator>; + + template> + explicit basic_string(basic_string_view, const Allocator& = Allocator()) + -> basic_string; + + template> + basic_string(basic_string_view, + typename @\seebelow@::size_type, typename @\seebelow@::size_type, + const Allocator& = Allocator()) + -> basic_string; } \end{codeblock} -\rSec3[string.require]{\tcode{basic_string} general requirements} +\pnum +A \tcode{size_type} parameter type in +a \tcode{basic_string} deduction guide +refers to the \tcode{size_type} member type of +the type deduced by the deduction guide. + +\rSec3[string.require]{General requirements} \pnum If any operation would cause \tcode{size()} to @@ -1191,7 +1222,7 @@ \tcode{rend}. \end{itemize} -\rSec3[string.cons]{\tcode{basic_string} constructors and assignment operators} +\rSec3[string.cons]{Constructors and assignment operators} \indexlibrary{\idxcode{basic_string}!constructor}% \begin{itemdecl} @@ -1283,12 +1314,22 @@ \indexlibrary{\idxcode{basic_string}!constructor}% \begin{itemdecl} -explicit basic_string(basic_string_view sv, const Allocator& a = Allocator()); +template + explicit basic_string(const T& t, const Allocator& a = Allocator()); \end{itemdecl} \begin{itemdescr} \pnum -\effects Same as \tcode{basic_string(sv.data(), sv.size(), a)}. +\effects Creates a variable, \tcode{sv}, as if by +\tcode{basic_string_view sv = t;} and +then behaves the same as \tcode{basic_string(sv.data(), sv.size(), a)}. + +\pnum +\remarks This constructor shall not participate in overload resolution unless +\begin{itemize} +\item \tcode{is_convertible_v>} is \tcode{true} and +\item \tcode{is_convertible_v} is \tcode{false}. +\end{itemize} \end{itemdescr} \indexlibrary{\idxcode{basic_string}!constructor}% @@ -1437,6 +1478,29 @@ or if \tcode{Allocator} is a type that does not qualify as an allocator\iref{container.requirements.general}. \end{itemdescr} +\begin{itemdecl} +template> + explicit basic_string(basic_string_view, const Allocator& = Allocator()) + -> basic_string; + +template> + basic_string(basic_string_view, + typename @\seebelow@::size_type, typename @\seebelow@::size_type, + const Allocator& = Allocator()) + -> basic_string; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks Shall not participate in overload resolution if +\tcode{Allocator} is a type that does not qualify as +an allocator\iref{container.requirements.general}. +\end{itemdescr} + \indexlibrarymember{operator=}{basic_string}% \begin{itemdecl} basic_string& operator=(const basic_string& str); @@ -1477,12 +1541,24 @@ \indexlibrarymember{operator=}{basic_string}% \begin{itemdecl} -basic_string& operator=(basic_string_view sv); +template + basic_string& operator=(const T& t); \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return assign(sv);} +\effects Equivalent to: +\begin{codeblock} +{ + basic_string_view sv = t; + return assign(sv); +} +\end{codeblock} + +\pnum +\remarks This function shall not participate in overload resolution unless +\tcode{is_convertible_v>} is \tcode{true} and +\tcode{is_convertible_v} is \tcode{false}. \end{itemdescr} \indexlibrarymember{operator=}{basic_string}% @@ -1526,7 +1602,7 @@ \returns \tcode{*this}. \end{itemdescr} -\rSec3[string.iterators]{\tcode{basic_string} iterator support} +\rSec3[string.iterators]{Iterator support} \indexlibrarymember{begin}{basic_string}% \indexlibrarymember{cbegin}{basic_string}% @@ -1586,7 +1662,7 @@ \tcode{reverse_iterator(begin())}. \end{itemdescr} -\rSec3[string.capacity]{\tcode{basic_string} capacity} +\rSec3[string.capacity]{Capacity} \indexlibrarymember{size}{basic_string}% \begin{itemdecl} @@ -1688,39 +1764,32 @@ \pnum \returns The size of the allocated storage in the string. + +\pnum +\complexity Constant time. \end{itemdescr} \indexlibrarymember{reserve}{basic_string}% \begin{itemdecl} -void reserve(size_type res_arg=0); +void reserve(size_type res_arg); \end{itemdecl} \begin{itemdescr} -\pnum -The member function -\tcode{reserve()} -is a directive that informs a -\tcode{basic_string} -object of a planned change in size, -so that it can manage the storage allocation accordingly. - \pnum \effects +A directive that informs a \tcode{basic_string} of a planned change in size, +so that the storage allocation can be managed accordingly. After \tcode{reserve()}, \tcode{capacity()} is greater or equal to the argument of -\tcode{reserve}. -\begin{note} -Calling -\tcode{reserve()} -with a \tcode{res_arg} argument less than +\tcode{reserve} +if reallocation happens; and +equal to the previous value of \tcode{capacity()} -is in effect a non-binding shrink request. -A call with -\tcode{res_arg <= size()} -is in effect a non-binding shrink-to-fit request. -\end{note} +otherwise. +Reallocation happens at this point if and only if +the current capacity is less than the argument of \tcode{reserve()}. \pnum \throws @@ -1780,7 +1849,7 @@ \tcode{size() == 0}. \end{itemdescr} -\rSec3[string.access]{\tcode{basic_string} element access} +\rSec3[string.access]{Element access} \indexlibrarymember{operator[]}{basic_string}% \begin{itemdecl} @@ -1855,7 +1924,7 @@ Equivalent to: \tcode{return operator[](size() - 1);} \end{itemdescr} -\rSec3[string.modifiers]{\tcode{basic_string} modifiers} +\rSec3[string.modifiers]{Modifiers} \rSec4[string.op+=]{\tcode{basic_string::operator+=}} @@ -1875,17 +1944,26 @@ \indexlibrarymember{operator+=}{basic_string}% \begin{itemdecl} -basic_string& operator+=(basic_string_view sv); +template + basic_string& operator+=(const T& t); \end{itemdecl} \begin{itemdescr} \pnum \effects -Calls \tcode{append(sv)}. +Creates a variable, \tcode{sv}, as if by +\tcode{basic_string_view sv = t;} and +then calls \tcode{append(sv)}. \pnum \returns \tcode{*this}. + +\pnum +\remarks +This function shall not participate in overload resolution unless +\tcode{is_convertible_v>} is \tcode{true} and +\tcode{is_convertible_v} is \tcode{false}. \end{itemdescr} \indexlibrarymember{operator+=}{basic_string}% @@ -1971,13 +2049,26 @@ \indexlibrarymember{append}{basic_string}% \begin{itemdecl} -basic_string& append(basic_string_view sv); +template + basic_string& append(const T& t); \end{itemdecl} \begin{itemdescr} \pnum \effects -Equivalent to: \tcode{return append(sv.data(), sv.size());} +Equivalent to: +\begin{codeblock} +{ + basic_string_view sv = t; + return append(sv.data(), sv.size()); +} +\end{codeblock} + +\pnum +\remarks +This function shall not participate in overload resolution unless +\tcode{is_convertible_v>} is \tcode{true} and +\tcode{is_convertible_v} is \tcode{false}. \end{itemdescr} \indexlibrarymember{append}{basic_string}% @@ -2155,13 +2246,26 @@ \indexlibrarymember{assign}{basic_string}% \begin{itemdecl} -basic_string& assign(basic_string_view sv); +template + basic_string& assign(const T& t); \end{itemdecl} \begin{itemdescr} \pnum \effects -Equivalent to: \tcode{return assign(sv.data(), sv.size());} +Equivalent to: +\begin{codeblock} +{ + basic_string_view sv = t; + return assign(sv.data(), sv.size()); +} +\end{codeblock} + +\pnum +\remarks +This function shall not participate in overload resolution unless +\tcode{is_convertible_v>} is \tcode{true} and +\tcode{is_convertible_v} is \tcode{false}. \end{itemdescr} \indexlibrarymember{assign}{basic_string}% @@ -2309,13 +2413,26 @@ \indexlibrarymember{insert}{basic_string}% \begin{itemdecl} -basic_string& insert(size_type pos, basic_string_view sv); +template + basic_string& insert(size_type pos, const T& t); \end{itemdecl} \begin{itemdescr} \pnum \effects -Equivalent to: \tcode{return insert(pos, sv.data(), sv.size());} +Equivalent to: +\begin{codeblock} +{ + basic_string_view sv = t; + return insert(pos, sv.data(), sv.size()); +} +\end{codeblock} + +\pnum +\remarks +This function shall not participate in overload resolution unless +\tcode{is_convertible_v>} is \tcode{true} and +\tcode{is_convertible_v} is \tcode{false}. \end{itemdescr} \indexlibrarymember{insert}{basic_string}% @@ -2627,14 +2744,26 @@ \indexlibrarymember{replace}{basic_string}% \begin{itemdecl} -basic_string& replace(size_type pos1, size_type n1, - basic_string_view sv); +template + basic_string& replace(size_type pos1, size_type n1, const T& t); \end{itemdecl} \begin{itemdescr} \pnum \effects -Equivalent to: \tcode{return replace(pos1, n1, sv.data(), sv.size());} +Equivalent to: +\begin{codeblock} +{ + basic_string_view sv = t; + return replace(pos1, n1, sv.data(), sv.size()); +} +\end{codeblock} + +\pnum +\remarks +This function shall not participate in overload resolution unless +\tcode{is_convertible_v>} is \tcode{true} and +\tcode{is_convertible_v} is \tcode{false}. \end{itemdescr} \indexlibrarymember{replace}{basic_string}% @@ -2747,7 +2876,8 @@ \indexlibrarymember{replace}{basic_string}% \begin{itemdecl} -basic_string& replace(const_iterator i1, const_iterator i2, basic_string_view sv); +template + basic_string& replace(const_iterator i1, const_iterator i2, const T& t); \end{itemdecl} \begin{itemdescr} @@ -2757,11 +2887,19 @@ \pnum \effects -Calls \tcode{replace(i1 - begin(), i2 - i1, sv)}. +Creates a variable, \tcode{sv}, as if by +\tcode{basic_string_view sv = t;} and then +calls \tcode{replace(i1 - begin(), i2 - i1, sv)}. \pnum \returns \tcode{*this}. + +\pnum +\remarks +This function shall not participate in overload resolution unless +\tcode{is_convertible_v>} is \tcode{true} and +\tcode{is_convertible_v} is \tcode{false}. \end{itemdescr} \indexlibrarymember{replace}{basic_string}% @@ -2909,9 +3047,9 @@ \complexity Constant time. \end{itemdescr} -\rSec3[string.ops]{\tcode{basic_string} string operations} +\rSec3[string.ops]{String operations} -\rSec4[string.accessors]{\tcode{basic_string} accessors} +\rSec4[string.accessors]{Accessors} \indexlibrarymember{c_str}{basic_string}% \indexlibrarymember{data}{basic_string}% @@ -2980,13 +3118,16 @@ \indexlibrarymember{find}{basic_string}% \begin{itemdecl} -size_type find(basic_string_view sv, size_type pos = 0) const noexcept; +template + size_type find(const T& t, size_type pos = 0) const; \end{itemdecl} \begin{itemdescr} \pnum \effects -Determines the lowest position \tcode{xpos}, if possible, such that both of +Creates a variable, \tcode{sv}, as if by +\tcode{basic_string_view sv = t;} and then +determines the lowest position \tcode{xpos}, if possible, such that both of the following conditions hold: \begin{itemize} \item @@ -3003,6 +3144,16 @@ \tcode{xpos} if the function can determine such a value for \tcode{xpos}. Otherwise, returns \tcode{npos}. + +\pnum +\remarks +This function shall not participate in overload resolution unless +\tcode{is_convertible_v>} is \tcode{true} and +\tcode{is_convertible_v} is \tcode{false}. + +\pnum +\throws +Nothing unless the initialization of \tcode{sv} throws an exception. \end{itemdescr} \indexlibrarymember{find}{basic_string}% @@ -3057,13 +3208,16 @@ \indexlibrarymember{rfind}{basic_string}% \begin{itemdecl} -size_type rfind(basic_string_view sv, size_type pos = npos) const noexcept; +template + size_type rfind(const T& t, size_type pos = npos) const; \end{itemdecl} \begin{itemdescr} \pnum \effects -Determines the highest position \tcode{xpos}, if possible, such that both of +Creates a variable, \tcode{sv}, as if by +\tcode{basic_string_view sv = t;} and then +determines the highest position \tcode{xpos}, if possible, such that both of the following conditions hold: \begin{itemize} \item @@ -3081,6 +3235,16 @@ \tcode{xpos} if the function can determine such a value for \tcode{xpos}. Otherwise, returns \tcode{npos}. + +\pnum +\remarks +This function shall not participate in overload resolution unless +\tcode{is_convertible_v>} is \tcode{true} and +\tcode{is_convertible_v} is \tcode{false}. + +\pnum +\throws +Nothing unless the initialization of \tcode{sv} throws an exception. \end{itemdescr} \indexlibrarymember{rfind}{basic_string}% @@ -3135,13 +3299,16 @@ \indexlibrarymember{find_first_of}{basic_string}% \begin{itemdecl} -size_type find_first_of(basic_string_view sv, size_type pos = 0) const noexcept; +template + size_type find_first_of(const T& t, size_type pos = 0) const; \end{itemdecl} \begin{itemdescr} \pnum \effects -Determines the lowest position \tcode{xpos}, if possible, such that both of +Creates a variable, \tcode{sv}, as if by +\tcode{basic_string_view sv = t;} and then +determines the lowest position \tcode{xpos}, if possible, such that both of the following conditions hold: \begin{itemize} @@ -3160,6 +3327,16 @@ \tcode{xpos} if the function can determine such a value for \tcode{xpos}. Otherwise, returns \tcode{npos}. + +\pnum +\remarks +This function shall not participate in overload resolution unless +\tcode{is_convertible_v>} is \tcode{true} and +\tcode{is_convertible_v} is \tcode{false}. + +\pnum +\throws +Nothing unless the initialization of \tcode{sv} throws an exception. \end{itemdescr} \indexlibrarymember{find_first_of}{basic_string}% @@ -3214,13 +3391,16 @@ \indexlibrarymember{find_last_of}{basic_string}% \begin{itemdecl} -size_type find_last_of(basic_string_view sv, size_type pos = npos) const noexcept; +template + size_type find_last_of(const T& t, size_type pos = npos) const; \end{itemdecl} \begin{itemdescr} \pnum \effects -Determines the highest position \tcode{xpos}, if possible, such that both of +Creates a variable, \tcode{sv}, as if by +\tcode{basic_string_view sv = t;} and then +determines the highest position \tcode{xpos}, if possible, such that both of the following conditions hold: \begin{itemize} \item @@ -3233,6 +3413,16 @@ for some element \tcode{I} of the data referenced by \tcode{sv}. \end{itemize} +\pnum +\remarks +This function shall not participate in overload resolution unless +\tcode{is_convertible_v>} is \tcode{true} and +\tcode{is_convertible_v} is \tcode{false}. + +\pnum +\throws +Nothing unless the initialization of \tcode{sv} throws an exception. + \pnum \returns \tcode{xpos} if the function can determine such a value for \tcode{xpos}. @@ -3292,13 +3482,16 @@ \indexlibrarymember{find_first_not_of}{basic_string}% \begin{itemdecl} -size_type find_first_not_of(basic_string_view sv, size_type pos = 0) const noexcept; +template + size_type find_first_not_of(const T& t, size_type pos = 0) const; \end{itemdecl} \begin{itemdescr} \pnum \effects -Determines the lowest position \tcode{xpos}, if possible, such that both of +Creates a variable, \tcode{sv}, as if by +\tcode{basic_string_view sv = t;} and then +determines the lowest position \tcode{xpos}, if possible, such that both of the following conditions hold: \begin{itemize} \item @@ -3311,6 +3504,16 @@ for no element \tcode{I} of the data referenced by \tcode{sv}. \end{itemize} +\pnum +\remarks +This function shall not participate in overload resolution unless +\tcode{is_convertible_v>} is \tcode{true} and +\tcode{is_convertible_v} is \tcode{false}. + +\pnum +\throws +Nothing unless the initialization of \tcode{sv} throws an exception. + \pnum \returns \tcode{xpos} if the function can determine such a value for \tcode{xpos}. @@ -3373,14 +3576,16 @@ \indexlibrarymember{find_last_not_of}{basic_string}% \begin{itemdecl} -size_type find_last_not_of(basic_string_view sv, - size_type pos = npos) const noexcept; +template + size_type find_last_not_of(const T& t, size_type pos = npos) const; \end{itemdecl} \begin{itemdescr} \pnum \effects -Determines the highest position \tcode{xpos}, if possible, such that both of +Creates a variable, \tcode{sv}, as if by +\tcode{basic_string_view sv = t;} and then +determines the highest position \tcode{xpos}, if possible, such that both of the following conditions hold: \begin{itemize} \item @@ -3393,6 +3598,16 @@ for no element \tcode{I} of the data referenced by \tcode{sv}. \end{itemize} +\pnum +\remarks +This function shall not participate in overload resolution unless +\tcode{is_convertible_v>} is \tcode{true} and +\tcode{is_convertible_v} is \tcode{false}. + +\pnum +\throws +Nothing unless the initialization of \tcode{sv} throws an exception. + \pnum \returns \tcode{xpos} if the function can determine such a value for \tcode{xpos}. @@ -3479,13 +3694,16 @@ \indexlibrarymember{compare}{basic_string}% \begin{itemdecl} -int compare(basic_string_view sv) const noexcept; +template + int compare(const T& t) const; \end{itemdecl} \begin{itemdescr} \pnum \effects -Determines the effective length +Creates a variable, \tcode{sv}, as if by +\tcode{basic_string_view sv = t;} and then +determines the effective length \tcode{rlen} of the strings to compare as the smaller of \tcode{size()} @@ -3497,7 +3715,7 @@ \pnum \returns The nonzero result if the result of the comparison is nonzero. -Otherwise, returns a value as indicated in Table~\ref{tab:strings.compare}. +Otherwise, returns a value as indicated in \tref{strings.compare}. \begin{floattable}{\tcode{compare()} results}{tab:strings.compare} {lc} @@ -3507,11 +3725,22 @@ \tcode{size() == sv.size()} & \tcode{ \ 0} \\ \tcode{size() > \ sv.size()} & \tcode{> 0} \\ \end{floattable} + +\pnum +\remarks +This function shall not participate in overload resolution unless +\tcode{is_convertible_v>} is \tcode{true} and +\tcode{is_convertible_v} is \tcode{false}. + +\pnum +\throws +Nothing unless the initialization of \tcode{sv} throws an exception. \end{itemdescr} \indexlibrarymember{compare}{basic_string}% \begin{itemdecl} -int compare(size_type pos1, size_type n1, basic_string_view sv) const; +template + int compare(size_type pos1, size_type n1, const T& t) const; \end{itemdecl} \begin{itemdescr} @@ -3519,8 +3748,17 @@ \effects Equivalent to: \begin{codeblock} -return basic_string_view(data(), size()).substr(pos1, n1).compare(sv); +{ + basic_string_view sv = t; + return basic_string_view(data(), size()).substr(pos1, n1).compare(sv); +} \end{codeblock} + +\pnum +\remarks +This function shall not participate in overload resolution unless +\tcode{is_convertible_v>} is \tcode{true} and +\tcode{is_convertible_v} is \tcode{false}. \end{itemdescr} \indexlibrarymember{compare}{basic_string}% @@ -3651,7 +3889,7 @@ \end{codeblock} \end{itemdescr} -\rSec2[string.nonmembers]{\tcode{basic_string} non-member functions} +\rSec2[string.nonmembers]{Non-member functions} \indexlibrary{\idxcode{basic_string}} @@ -4735,6 +4973,10 @@ In every specialization \tcode{basic_string_view}, the type \tcode{traits} shall satisfy the character traits requirements\iref{char.traits}, and the type \tcode{traits::char_type} shall name the same type as \tcode{charT}. +\pnum +The type \tcode{iterator} satisfies +the constexpr iterator requirements\iref{iterator.requirements.general}. + \rSec3[string.view.cons]{Construction and assignment} \indexlibrary{\idxcode{basic_string_view}!constructor}% @@ -4765,7 +5007,7 @@ \pnum \effects Constructs a \tcode{basic_string_view}, with the postconditions -in Table~\ref{tab:string.view.ctr.2}. +in \tref{string.view.ctr.2}. \begin{libefftabvaluenarrow}{\tcode{basic_string_view(const charT*)} effects}{tab:string.view.ctr.2} \tcode{data_} & \tcode{str} \\ \tcode{size_} & \tcode{traits::length(str)} \\ @@ -4788,7 +5030,7 @@ \pnum \effects -Constructs a \tcode{basic_string_view}, with the postconditions in Table~\ref{tab:string.view.ctr.3}. +Constructs a \tcode{basic_string_view}, with the postconditions in \tref{string.view.ctr.3}. \begin{libefftabvaluenarrow}{\tcode{basic_string_view(const charT*, size_type)} effects}{tab:string.view.ctr.3} \tcode{data_} & \tcode{str} \\ \tcode{size_} & \tcode{len} \\ @@ -5134,7 +5376,7 @@ \pnum \returns The nonzero result if the result of the comparison is nonzero. -Otherwise, returns a value as indicated in Table~\ref{tab:string.view.compare}. +Otherwise, returns a value as indicated in \tref{string.view.compare}. \begin{libtab2}{\tcode{compare()} results}{tab:string.view.compare}{cc}{Condition}{Return Value} \tcode{size() < str.size()} & \tcode{< 0}\\ \tcode{size() == str.size()} & \tcode{ \ 0}\\ @@ -5464,7 +5706,7 @@ \pnum Let \tcode{S} be \tcode{basic_string_view}, and \tcode{sv} be an instance of \tcode{S}. Implementations shall provide sufficient additional overloads marked \tcode{constexpr} and \tcode{noexcept} -so that an object \tcode{t} with an implicit conversion to \tcode{S} can be compared according to Table~\ref{tab:string.view.comparison.overloads}. +so that an object \tcode{t} with an implicit conversion to \tcode{S} can be compared according to \tref{string.view.comparison.overloads}. \begin{libtab2}{Additional \tcode{basic_string_view} comparison overloads}{tab:string.view.comparison.overloads}{cc}{Expression}{Equivalent to} \tcode{t == sv} & \tcode{S(t) == sv} \\ \tcode{sv == t} & \tcode{sv == S(t)} \\ @@ -5715,7 +5957,7 @@ The contents and meaning of the header \tcode{} are the same as the C standard library header \tcode{}. -\xref ISO C 7.4 +\xrefc{7.4} \rSec2[cwctype.syn]{Header \tcode{} synopsis} @@ -5776,7 +6018,7 @@ The contents and meaning of the header \tcode{} are the same as the C standard library header \tcode{}. -\xref ISO C 7.30 +\xrefc{7.30} \rSec2[cstring.syn]{Header \tcode{} synopsis} @@ -5862,7 +6104,7 @@ but they have the same behavior as in the C standard library\iref{library.c}. \end{note} -\xref ISO C 7.24 +\xrefc{7.24} \rSec2[cwchar.syn]{Header \tcode{} synopsis} @@ -6030,7 +6272,7 @@ but they have the same behavior as in the C standard library\iref{library.c}. \end{note} -\xref ISO C 7.29 +\xrefc{7.29} \rSec2[cuchar.syn]{Header \tcode{} synopsis} @@ -6060,7 +6302,7 @@ \tcode{}, except that it does not declare types \tcode{char16_t} nor \tcode{char32_t}. -\xref ISO C 7.28 +\xrefc{7.28} \rSec2[c.mb.wcs]{Multibyte / wide string and character conversion functions} @@ -6090,7 +6332,7 @@ These functions have the semantics specified in the C standard library. \end{itemdescr} -\xref ISO C 7.22.7.1, 7.22.8, 7.29.6.2.1 +\xrefc{7.22.7.1, 7.22.8, 7.29.6.2.1} \indexlibrary{\idxcode{mbtowc}}% \indexlibrary{\idxcode{wctomb}}% @@ -6111,7 +6353,7 @@ with other calls to the same function. \end{itemdescr} -\xref ISO C 7.22.7 +\xrefc{7.22.7} \indexlibrary{\idxcode{mbrlen}}% \indexlibrary{\idxcode{mbrstowcs}}% @@ -6140,4 +6382,4 @@ with an \tcode{mbstate_t*} argument that is a null pointer value. \end{itemdescr} -\xref ISO C 7.29.6.3 +\xrefc{7.29.6.3} diff --git a/source/support.tex b/source/support.tex index f206b26c0d..dbe3f613de 100644 --- a/source/support.tex +++ b/source/support.tex @@ -19,14 +19,15 @@ support for dynamic type identification, support for exception processing, support for initializer lists, and other runtime support, -as summarized in Table~\ref{tab:lang.sup.lib.summary}. +as summarized in \tref{lang.sup.lib.summary}. \begin{libsumtab}{Language support library summary}{tab:lang.sup.lib.summary} \ref{support.types} & Common definitions & \tcode{} \\ & & \tcode{} \\ \rowsep \ref{support.limits} & Implementation properties & \tcode{} \\ & & \tcode{} \\ - & & \tcode{} \\ \rowsep + & & \tcode{} \\ + & & \tcode{} \\ \rowsep \ref{cstdint} & Integer types & \tcode{} \\ \rowsep \ref{support.start.term} & Start and termination & \tcode{} \\ \rowsep \ref{support.dynamic} & Dynamic memory management & \tcode{} \\ \rowsep @@ -94,7 +95,7 @@ \ref{support.types.nullptr} and \ref{support.types.layout}. -\xref ISO C 7.19 +\xrefc{7.19} \rSec2[cstdlib.syn]{Header \tcode{} synopsis} @@ -256,7 +257,7 @@ but they have the same behavior as in the C standard library\iref{library.c}. \end{note} -\xref ISO C 7.22 +\xrefc{7.22} \rSec2[support.types.nullptr]{Null pointers} @@ -283,7 +284,7 @@ but not \tcode{(void*)0}.} -\xref ISO C 7.19 +\xrefc{7.19} \rSec2[support.types.layout]{Sizes, alignments, and offsets} @@ -331,11 +332,11 @@ \pnum The type \indexlibrary{\idxcode{max_align_t}}% -\tcode{max_align_t} is a trivial type whose alignment requirement +\tcode{max_align_t} is a trivial standard-layout type whose alignment requirement is at least as great as that of every scalar type, and whose alignment requirement is supported in every context\iref{basic.align}. -\xref ISO C 7.19 +\xrefc{7.19} \rSec2[support.types.byteops]{\tcode{byte} type operations} @@ -346,11 +347,11 @@ \end{itemdecl} \begin{itemdescr} -\pnum \remarks This function shall not participate in overload resolution unless -\tcode{is_integral_v} is \tcode{true}. - \pnum \effects Equivalent to: \tcode{return b = b << shift;} + +\pnum \remarks This function shall not participate in overload resolution unless +\tcode{is_integral_v} is \tcode{true}. \end{itemdescr} \indexlibrarymember{operator<<}{byte}% @@ -360,14 +361,14 @@ \end{itemdecl} \begin{itemdescr} -\pnum \remarks This function shall not participate in overload resolution unless -\tcode{is_integral_v} is \tcode{true}. - \pnum \effects Equivalent to: \begin{codeblock} return static_cast(static_cast( static_cast(b) << shift)); \end{codeblock} + +\pnum \remarks This function shall not participate in overload resolution unless +\tcode{is_integral_v} is \tcode{true}. \end{itemdescr} \indexlibrarymember{operator>>=}{byte}% @@ -377,11 +378,11 @@ \end{itemdecl} \begin{itemdescr} -\pnum \remarks This function shall not participate in overload resolution unless -\tcode{is_integral_v} is \tcode{true}. - \pnum \effects Equivalent to: \tcode{return b >> shift;} + +\pnum \remarks This function shall not participate in overload resolution unless +\tcode{is_integral_v} is \tcode{true}. \end{itemdescr} \indexlibrarymember{operator>>}{byte}% @@ -391,14 +392,14 @@ \end{itemdecl} \begin{itemdescr} -\pnum \remarks This function shall not participate in overload resolution unless -\tcode{is_integral_v} is \tcode{true}. - \pnum \effects Equivalent to: \begin{codeblock} return static_cast(static_cast( static_cast(b) >> shift)); \end{codeblock} + +\pnum \remarks This function shall not participate in overload resolution unless +\tcode{is_integral_v} is \tcode{true}. \end{itemdescr} \indexlibrarymember{operator"|=}{byte}% @@ -487,10 +488,10 @@ \end{itemdecl} \begin{itemdescr} +\pnum \effects Equivalent to: \tcode{return static_cast(b);} + \pnum \remarks This function shall not participate in overload resolution unless \tcode{is_integral_v} is \tcode{true}. - -\pnum \effects Equivalent to: \tcode{return static_cast(b);} \end{itemdescr} \rSec1[support.limits]{Implementation properties} @@ -502,9 +503,17 @@ \tcode{}\iref{limits.syn}, \tcode{}\iref{climits.syn}, and \tcode{}\iref{cfloat.syn} -supply characteristics of imple\-mentation-dependent +supply characteristics of +\indextext{implementation-dependent}% +imple\-mentation-dependent arithmetic types\iref{basic.fundamental}. +\pnum +The header \tcode{} +supplies implementation-dependent information +about the C++ standard library +(e.g., version number and release date). + \rSec2[limits.syn]{Header \tcode{} synopsis} \indexhdr{limits}% \indextext{\idxcode{numeric_limits}}% @@ -741,7 +750,7 @@ \indextext{number!subnormal}% \pnum -For floating types with subnormal numbers, returns the minimum positive +For floating-point types with subnormal numbers, returns the minimum positive normalized value. \pnum @@ -878,7 +887,7 @@ \begin{itemdescr} \pnum -For floating types, specifies the base or radix of the exponent representation +For floating-point types, specifies the base or radix of the exponent representation (often 2).\footnote{Equivalent to \tcode{FLT_RADIX}.} \pnum @@ -1409,7 +1418,7 @@ required to match the types to which the macros refer. \end{note} -\xref ISO C 5.2.4.2.1 +\xrefc{5.2.4.2.1} \rSec2[cfloat.syn]{Header \tcode{} synopsis} @@ -1500,7 +1509,7 @@ The header \tcode{} defines all macros the same as the C standard library header \tcode{}. -\xref ISO C 5.2.4.2.2 +\xrefc{5.2.4.2.2} \rSec1[cstdint]{Integer types} @@ -1597,7 +1606,7 @@ The header defines all types and macros the same as the C standard library header \tcode{}. -\xref ISO C 7.20 +\xrefc{7.20} \rSec1[support.start.term]{Start and termination} @@ -1799,7 +1808,7 @@ when the functions registered with \tcode{at_quick_exit} are. \end{itemdescr} -\xref ISO C 7.22.4 +\xrefc{7.22.4} \rSec1[support.dynamic]{Dynamic memory management} @@ -3381,7 +3390,7 @@ \pnum \tcode{exception_ptr} shall satisfy the requirements of -\tcode{NullablePointer}\iref{nullablepointer.requirements}. +\tcode{NullablePointer} (\tref{nullablepointer}). \pnum Two non-null values of type \tcode{exception_ptr} are equivalent and compare equal if and @@ -3829,6 +3838,8 @@ friend constexpr bool operator!=(weak_equality v, @\unspec@) noexcept; friend constexpr bool operator==(@\unspec@, weak_equality v) noexcept; friend constexpr bool operator!=(@\unspec@, weak_equality v) noexcept; + friend constexpr weak_equality operator<=>(weak_equality v, @\unspec@) noexcept; + friend constexpr weak_equality operator<=>(@\unspec@, weak_equality v) noexcept; }; // valid values' definitions @@ -3861,6 +3872,18 @@ \tcode{v.value != 0}. \end{itemdescr} +\indexlibrarymember{operator<=>}{weak_equality}% +\begin{itemdecl} +constexpr weak_equality operator<=>(weak_equality v, @\unspec@) noexcept; +constexpr weak_equality operator<=>(@\unspec@, weak_equality v) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\tcode{v}. +\end{itemdescr} + \rSec3[cmp.strongeq]{Class \tcode{strong_equality}} \pnum @@ -3897,6 +3920,8 @@ friend constexpr bool operator!=(strong_equality v, @\unspec@) noexcept; friend constexpr bool operator==(@\unspec@, strong_equality v) noexcept; friend constexpr bool operator!=(@\unspec@, strong_equality v) noexcept; + friend constexpr strong_equality operator<=>(strong_equality v, @\unspec@) noexcept; + friend constexpr strong_equality operator<=>(@\unspec@, strong_equality v) noexcept; }; // valid values' definitions @@ -3942,6 +3967,18 @@ \tcode{v.value != 0}. \end{itemdescr} +\indexlibrarymember{operator<=>}{strong_equality}% +\begin{itemdecl} +constexpr strong_equality operator<=>(strong_equality v, @\unspec@) noexcept; +constexpr strong_equality operator<=>(@\unspec@, strong_equality v) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\tcode{v}. +\end{itemdescr} + \rSec3[cmp.partialord]{Class \tcode{partial_ordering}} \pnum @@ -3994,6 +4031,8 @@ friend constexpr bool operator<=(@\unspec@, partial_ordering v) noexcept; friend constexpr bool operator> (@\unspec@, partial_ordering v) noexcept; friend constexpr bool operator>=(@\unspec@, partial_ordering v) noexcept; + friend constexpr partial_ordering operator<=>(partial_ordering v, @\unspec@) noexcept; + friend constexpr partial_ordering operator<=>(@\unspec@, partial_ordering v) noexcept; }; // valid values' definitions @@ -4068,6 +4107,28 @@ For \tcode{operator@}, \tcode{!v.is_ordered || v.value != 0}. \end{itemdescr} +\indexlibrarymember{operator<=>}{partial_ordering}% +\begin{itemdecl} +constexpr partial_ordering operator<=>(partial_ordering v, @\unspec@) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\tcode{v}. +\end{itemdescr} + +\indexlibrarymember{operator<=>}{partial_ordering}% +\begin{itemdecl} +constexpr partial_ordering operator<=>(@\unspec@, partial_ordering v) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\tcode{v < 0 ?\ partial_ordering::greater :\ v > 0 ?\ partial_ordering::less :\ v}. +\end{itemdescr} + \rSec3[cmp.weakord]{Class \tcode{weak_ordering}} \pnum @@ -4112,6 +4173,8 @@ friend constexpr bool operator<=(@\unspec@, weak_ordering v) noexcept; friend constexpr bool operator> (@\unspec@, weak_ordering v) noexcept; friend constexpr bool operator>=(@\unspec@, weak_ordering v) noexcept; + friend constexpr weak_ordering operator<=>(weak_ordering v, @\unspec@) noexcept; + friend constexpr weak_ordering operator<=>(@\unspec@, weak_ordering v) noexcept; }; // valid values' definitions @@ -4189,6 +4252,28 @@ \tcode{0 @ v.value} for \tcode{operator@}. \end{itemdescr} +\indexlibrarymember{operator<=>}{weak_ordering}% +\begin{itemdecl} +constexpr weak_ordering operator<=>(weak_ordering v, @\unspec@) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\tcode{v}. +\end{itemdescr} + +\indexlibrarymember{operator<=>}{weak_ordering}% +\begin{itemdecl} +constexpr weak_ordering operator<=>(@\unspec@, weak_ordering v) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\tcode{v < 0 ?\ weak_ordering::greater :\ v > 0 ?\ weak_ordering::less :\ v}. +\end{itemdescr} + \rSec3[cmp.strongord]{Class \tcode{strong_ordering}} \pnum @@ -4237,6 +4322,8 @@ friend constexpr bool operator<=(@\unspec@, strong_ordering v) noexcept; friend constexpr bool operator> (@\unspec@, strong_ordering v) noexcept; friend constexpr bool operator>=(@\unspec@, strong_ordering v) noexcept; + friend constexpr strong_ordering operator<=>(strong_ordering v, @\unspec@) noexcept; + friend constexpr strong_ordering operator<=>(@\unspec@, strong_ordering v) noexcept; }; // valid values' definitions @@ -4341,6 +4428,28 @@ \tcode{0 @ v.value} for \tcode{operator@}. \end{itemdescr} +\indexlibrarymember{operator<=>}{strong_ordering}% +\begin{itemdecl} +constexpr strong_ordering operator<=>(strong_ordering v, @\unspec@) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\tcode{v}. +\end{itemdescr} + +\indexlibrarymember{operator<=>}{strong_ordering}% +\begin{itemdecl} +constexpr strong_ordering operator<=>(@\unspec@, strong_ordering v) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\tcode{v < 0 ?\ strong_ordering::greater :\ v > 0 ?\ strong_ordering::less :\ v}. +\end{itemdescr} + \rSec2[cmp.common]{Class template \tcode{common_comparison_category}} \pnum @@ -4639,7 +4748,7 @@ type that results when passing an argument for which there is no parameter, the behavior is undefined. -\xref ISO C 7.16.1.1 +\xrefc{7.16.1.1} \rSec2[csetjmp.syn]{Header \tcode{} synopsis} @@ -4671,7 +4780,7 @@ by \tcode{catch} and \tcode{throw} would invoke any non-trivial destructors for any automatic objects. -\xref ISO C 7.13 +\xrefc{7.13} \rSec2[csignal.syn]{Header \tcode{} synopsis} @@ -4787,4 +4896,4 @@ with the first argument equal to the signal number corresponding to the signal that caused the invocation of the handler. -\xref ISO C 7.14 +\xrefc{7.14} diff --git a/source/templates.tex b/source/templates.tex index e636360b2f..40e795985b 100644 --- a/source/templates.tex +++ b/source/templates.tex @@ -735,15 +735,15 @@ If a \grammarterm{template-parameter} is a \grammarterm{type-parameter} with an ellipsis prior to its optional \grammarterm{identifier} or is a -\grammarterm{parameter-declaration} that declares a parameter +\grammarterm{parameter-declaration} that declares a pack\iref{dcl.fct}, then the \grammarterm{template-parameter} is a template parameter pack\iref{temp.variadic}. A template parameter pack that is a \grammarterm{parameter-declaration} whose type -contains one or more unexpanded parameter packs is a pack expansion. Similarly, +contains one or more unexpanded packs is a pack expansion. Similarly, a template parameter pack that is a \grammarterm{type-parameter} with a \grammarterm{template-parameter-list} containing one or more unexpanded -parameter packs is a pack expansion. A template parameter pack that is a pack -expansion shall not expand a parameter pack declared in the same +packs is a pack expansion. A template parameter pack that is a pack +expansion shall not expand a template parameter pack declared in the same \grammarterm{template-parameter-list}. \begin{example} \begin{codeblock} @@ -1418,7 +1418,7 @@ \pnum A \grammarterm{template-argument} matches a template \grammarterm{template-parameter} \tcode{P} when \tcode{P} is at least as specialized as the \grammarterm{template-argument} \tcode{A}. -If \tcode{P} contains a parameter pack, then \tcode{A} also matches \tcode{P} +If \tcode{P} contains a template parameter pack, then \tcode{A} also matches \tcode{P} if each of \tcode{A}'s template parameters matches the corresponding template parameter in the \grammarterm{template-head} of \tcode{P}. @@ -1514,7 +1514,7 @@ for each template parameter \tcode{PP} in the \grammarterm{template-head} of the function template, a corresponding template argument \tcode{AA} is formed. -If \tcode{PP} declares a parameter pack, +If \tcode{PP} declares a template parameter pack, then \tcode{AA} is the pack expansion \tcode{PP...}\iref{temp.variadic}; otherwise, \tcode{AA} is the \grammarterm{id-expression} \tcode{PP}. \end{itemize} @@ -2531,15 +2531,40 @@ \begin{codeblock} template void f(Types ... args); -f(); // OK: \tcode{args} contains no arguments -f(1); // OK: \tcode{args} contains one argument: \tcode{int} -f(2, 1.0); // OK: \tcode{args} contains two arguments: \tcode{int} and \tcode{double} +f(); // \tcode{args} contains no arguments +f(1); // \tcode{args} contains one argument: \tcode{int} +f(2, 1.0); // \tcode{args} contains two arguments: \tcode{int} and \tcode{double} \end{codeblock} \end{example} \pnum -A \defn{parameter pack} is either a template parameter -pack or a function parameter pack. +An \defnx{\grammarterm{init-capture} pack}{init-capture pack@\fakegrammarterm{init-capture} pack} +is a lambda capture that introduces an \grammarterm{init-capture} +for each of the elements in the pack expansion of its \grammarterm{initializer}. +\begin{example} +\begin{codeblock} +template +void foo(Args... args) { + [...xs=args]{ + bar(xs...); // \tcode{xs} is an \grammarterm{init-capture} pack + }; +} + +foo(); // \tcode{xs} contains zero \grammarterm{init-captures} +foo(1); // \tcode{xs} contains one \grammarterm{init-capture} +\end{codeblock} +\end{example} + +\pnum +A \defn{pack} is +a template parameter pack, +a function parameter pack, +or an \grammarterm{init-capture} pack. +The number of elements of a template parameter pack +or a function parameter pack +is the number of arguments provided for the parameter pack. +The number of elements of an \grammarterm{init-capture} pack +is the number of elements in the pack expansion of its \grammarterm{initializer}. \pnum \indextext{pattern|see{pack expansion, pattern}}% @@ -2595,7 +2620,7 @@ \item In a \grammarterm{fold-expression}\iref{expr.prim.fold}; the pattern is the \grammarterm{cast-expression} -that contains an unexpanded parameter pack. +that contains an unexpanded pack. \end{itemize} \begin{example} @@ -2608,20 +2633,20 @@ \end{example} \pnum -For the purpose of determining whether a parameter pack satisfies a rule -regarding entities other than parameter packs, the parameter pack is +For the purpose of determining whether a pack satisfies a rule +regarding entities other than packs, the pack is considered to be the entity that would result from an instantiation of the pattern in which it appears. \pnum -A parameter pack whose name appears within the pattern of a pack +A pack whose name appears within the pattern of a pack expansion is expanded by that pack expansion. An appearance of the name of -a parameter pack is only expanded by the innermost enclosing pack expansion. -The pattern of a pack expansion shall name one or more parameter packs that -are not expanded by a nested pack expansion; such parameter packs are called -\defnx{unexpanded parameter packs}{parameter pack!unexpanded} in the pattern. All of the parameter packs expanded +a pack is only expanded by the innermost enclosing pack expansion. +The pattern of a pack expansion shall name one or more packs that +are not expanded by a nested pack expansion; such packs are called +\defnx{unexpanded packs}{pack!unexpanded} in the pattern. All of the packs expanded by a pack expansion shall have the same number of arguments specified. An -appearance of a name of a parameter pack that is not expanded is +appearance of a name of a pack that is not expanded is ill-formed. \begin{example} \begin{codeblock} @@ -2642,8 +2667,8 @@ template void g(Args ... args) { // OK: \tcode{Args} is expanded by the function parameter pack \tcode{args} f(const_cast(&args)...); // OK: ``\tcode{Args}'' and ``\tcode{args}'' are expanded - f(5 ...); // error: pattern does not contain any parameter packs - f(args); // error: parameter pack ``\tcode{args}'' is not expanded + f(5 ...); // error: pattern does not contain any packs + f(args); // error: pack ``\tcode{args}'' is not expanded f(h(args ...) + args ...); // OK: first ``\tcode{args}'' expanded within \tcode{h}, // second ``\tcode{args}'' expanded within \tcode{f} } @@ -2656,12 +2681,12 @@ that is neither a \tcode{sizeof...} expression nor a \grammarterm{fold-expression} produces a -list -$\mathtt{E}_1, \mathtt{E}_2, \dotsc, \mathtt{E}_N$, +list of elements +$\mathtt{E}_1,$ $\mathtt{E}_2,$ $\cdots,$ $\mathtt{E}_N$, where $N$ is the number of elements in the pack expansion parameters. Each $\mathtt{E}_i$ is generated by instantiating the pattern and -replacing each pack expansion parameter with its $i$th element. +replacing each pack expansion parameter with its $i^{\textrm{th}}$ element. Such an element, in the context of the instantiation, is interpreted as follows: @@ -2669,17 +2694,27 @@ \item if the pack is a template parameter pack, the element is a template parameter\iref{temp.param} of the corresponding kind (type or -non-type) designating the type or value from the template -argument; otherwise, +non-type) designating the $i^{\textrm{th}}$ +corresponding type or value template argument; \item if the pack is a function parameter pack, the element is an \grammarterm{id-expression} -designating the function parameter that resulted from -the instantiation of the pattern where the pack is declared. +designating the $i^{\textrm{th}}$ function parameter +that resulted from instantiation of +the function parameter pack declaration; +otherwise + +\item +if the pack is an \grammarterm{init-capture} pack, +the element is an \grammarterm{id-expression} +designating the variable introduced by +the $i^{\textrm{th}}$ \grammarterm{init-capture} +that resulted from instantiation of +the \grammarterm{init-capture} pack. \end{itemize} -All of the $\mathtt{E}_i$ become elements in the enclosing list. +All of the $\mathtt{E}_i$ become items in the enclosing list. \begin{note} The variety of list varies with the context: \grammarterm{expression-list}, \grammarterm{base-specifier-list}, @@ -2702,7 +2737,7 @@ \pnum The instantiation of a \tcode{sizeof...} expression\iref{expr.sizeof} produces -an integral constant containing the number of elements in the parameter pack +an integral constant containing the number of elements in the pack it expands. \pnum @@ -2745,7 +2780,7 @@ For a binary fold-expression, $\mathtt{E}$ is generated by instantiating the \grammarterm{cast-expression} -that did not contain an unexpanded parameter pack. +that did not contain an unexpanded pack. \begin{example} \begin{codeblock} template @@ -2759,14 +2794,14 @@ which evaluates to \tcode{false}. \end{example} If $N$ is zero for a unary fold-expression, -the value of the expression is shown in Table~\ref{tab:fold.empty}; -if the operator is not listed in Table~\ref{tab:fold.empty}, +the value of the expression is shown in \tref{fold.empty}; +if the operator is not listed in \tref{fold.empty}, the instantiation is ill-formed. \begin{floattable}{Value of folding empty sequences}{tab:fold.empty} {ll} \topline -\lhdr{Operator} & \rhdr{Value when parameter pack is empty} \\ +\lhdr{Operator} & \rhdr{Value when pack is empty} \\ \capsep \tcode{\&\&} & \tcode{true} \\ \tcode{||} & \tcode{false} \\ @@ -3152,7 +3187,7 @@ The template parameter list of a specialization shall not contain default template argument values.\footnote{There is no way in which they could be used.} \item -An argument shall not contain an unexpanded parameter pack. If +An argument shall not contain an unexpanded pack. If an argument is a pack expansion\iref{temp.variadic}, it shall be the last argument in the template argument list. \end{itemize} @@ -3945,13 +3980,13 @@ \pnum A concept is not instantiated\iref{temp.spec}. -A program that -explicitly instantiates\iref{temp.explicit}, -explicitly specializes\iref{temp.expl.spec}, -or partially specializes a concept is ill-formed. \begin{note} An \grammarterm{id-expression} that denotes a concept specialization is evaluated as an expression\iref{expr.prim.id}. +A concept cannot be +explicitly instantiated\iref{temp.explicit}, +explicitly specialized\iref{temp.expl.spec}, +or partially specialized. \end{note} \pnum @@ -4015,19 +4050,6 @@ \end{codeblock} \end{example} -\pnum -When a \grammarterm{qualified-id} is intended to refer to a type -that is not a member of the current instantiation\iref{temp.dep.type} -and its \grammarterm{nested-name-specifier} -refers to a dependent type, -it shall be -prefixed by the keyword \tcode{typename}, forming a -\grammarterm{typename-specifier}. -If the \grammarterm{qualified-id} in a \grammarterm{typename-specifier} -does not denote a type -or a class template, -the program is ill-formed. - \begin{bnf} \nontermdef{typename-specifier}\br \terminal{typename} nested-name-specifier identifier\br @@ -4035,15 +4057,10 @@ \end{bnf} \pnum -If a specialization of a template is instantiated for a set of -\grammarterm{template-argument}{s} -such that the -\grammarterm{qualified-id} -prefixed by -\tcode{typename} -does not denote a type -or a class template, -the specialization is ill-formed. +A \grammarterm{typename-specifier} +denotes the type or class template +denoted by the \grammarterm{simple-type-specifier}\iref{dcl.type.simple} +formed by omitting the keyword \tcode{typename}. The usual qualified name lookup\iref{basic.lookup.qual} is used to find the \grammarterm{qualified-id} even in the presence of @@ -4088,20 +4105,76 @@ \end{note} \pnum -If, for a given set of template arguments, a specialization of a template is -instantiated -that refers to a \grammarterm{qualified-id} -that denotes a type -or a class template, -and the -\grammarterm{qualified-id} refers to a member of an unknown specialization, -the \grammarterm{qualified-id} shall either be -prefixed by \tcode{typename} or shall be used in a context in which it -implicitly names a type as described above. \begin{example} +A \grammarterm{qualified-id} +is assumed to name a type if +\begin{itemize} +\item it is a qualified name in a type-id-only context (see below), or +\item it is a \grammarterm{decl-specifier} of the \grammarterm{decl-specifier-seq} of a +\begin{itemize} +\item \grammarterm{simple-declaration} or a \grammarterm{function-definition} in namespace scope, +\item \grammarterm{member-declaration}, +\item \grammarterm{parameter-declaration} in a \grammarterm{member-declaration}% +\footnote{This includes friend function declarations.}, +unless that \grammarterm{parameter-declaration} appears in a default argument, +\item \grammarterm{parameter-declaration} in a \grammarterm{declarator} +of a function or function template declaration +whose \grammarterm{declarator-id} is qualified, +unless that \grammarterm{parameter-declaration} +appears in a default argument, +\item \grammarterm{parameter-declaration} in a \grammarterm{lambda-declarator}, +unless that \grammarterm{parameter-declaration} appears in a default argument, or +\item \grammarterm{parameter-declaration} of a (non-type) \grammarterm{template-parameter}. +\end{itemize} +\end{itemize} +A qualified name is said to be in a \defn{type-id-only context} +if it appears in a +\grammarterm{type-id}, +\grammarterm{new-type-id}, or +\grammarterm{defining-type-id} +and the smallest enclosing +\grammarterm{type-id}, +\grammarterm{new-type-id}, or +\grammarterm{defining-type-id} +is a +\grammarterm{new-type-id}, +\grammarterm{defining-type-id}, +\grammarterm{trailing-return-type}, +default argument of a \grammarterm{type-parameter} of a template, or +\grammarterm{type-id} of a +\tcode{static_cast}, +\tcode{const_cast}, +\tcode{reinterpret_cast}, or +\tcode{dynamic_cast}. +\begin{example} +\begin{codeblock} +template T::R f(); // OK, return type of a function declaration at global scope +template void f(T::R); // ill-formed (no diagnostic required), attempt to declare + // a \tcode{void} variable template +template struct S { + using Ptr = PtrTraits::Ptr; // OK, in a \grammarterm{defining-type-id} + T::R f(T::P p) { // OK, class scope + return static_cast(p); // OK, \grammarterm{type-id} of a \tcode{static_cast} + } + auto g() -> S::Ptr; // OK, \grammarterm{trailing-return-type} +}; +template void f() { + void (*pf)(T::X); // variable \tcode{pf} of type \tcode{void*} initialized with \tcode{T::X} + void g(T::X); // error: \tcode{T::X} at block scope does not denote a type + // (attempt to declare a \tcode{void} variable) +} +\end{codeblock} +\end{example} + +\pnum +A \grammarterm{qualified-id} that refers to a member of an unknown specialization, +that is not prefixed by \tcode{typename}, +and that is not otherwise assumed to name a type (see above) +denotes a non-type. +\begin{example} \begin{codeblock} template void f(int i) { - T::x * i; // \tcode{T::x} must not be a type + T::x * i; // expression, not the declaration of a variable \tcode{i} } struct Foo { @@ -4123,20 +4196,13 @@ Within the definition of a class template or within the definition of a member of a class template following the \grammarterm{declarator-id}, the keyword \tcode{typename} -is not required when referring to the name of a previously -declared member of the class template that declares a type -or a class template. -\begin{note} Such names can be found using unqualified name lookup\iref{basic.lookup.unqual}, -class member lookup\iref{class.qual} into the current instantiation\iref{temp.dep.type}, -or class member access expression lookup\iref{basic.lookup.classref} when the -type of the object expression is the current instantiation\iref{temp.dep.expr}. -\end{note} +is not required when referring to +a member of the current instantiation\iref{temp.dep.type}. \begin{example} - \begin{codeblock} template struct A { typedef int B; - B b; // OK, no typename required + B b; // OK, no \tcode{typename} required }; \end{codeblock} \end{example} @@ -4144,8 +4210,11 @@ \pnum \indextext{checking!syntax}% \indextext{checking!point of error}% +The validity of a template may be checked prior to any instantiation. +\begin{note} Knowing which names are type names allows the syntax of every template -to be checked. +to be checked in this way. +\end{note} The program is ill-formed, no diagnostic required, if: \begin{itemize} @@ -4392,7 +4461,7 @@ }; template class U = T::template Base> struct Third { }; -Third > t; // OK: default argument uses injected-class-name as a template +Third > t; // OK: default argument uses injected-class-name as a template \end{codeblock} \end{example} @@ -4704,21 +4773,21 @@ the class template followed by the template argument list of the partial specialization enclosed in \tcode{<>} (or an equivalent template alias specialization). -If the \textit{n}th template parameter is -a parameter pack, the \textit{n}th template argument is a pack +If the $n^\text{th}$ template parameter is +a template parameter pack, the $n^\text{th}$ template argument is a pack expansion\iref{temp.variadic} whose pattern is the name of -the parameter pack. +the template parameter pack. \end{itemize} \pnum The template argument list of a primary template is a template argument list in which the -\textit{n}th +$n^\text{th}$ template argument has the value of the -\textit{n}th +$n^\text{th}$ template parameter of the class template. -If the \textit{n}th template parameter is a template -parameter pack\iref{temp.variadic}, the \textit{n}th template argument is a pack +If the $n^\text{th}$ template parameter is a template +parameter pack\iref{temp.variadic}, the $n^\text{th}$ template argument is a pack expansion\iref{temp.variadic} whose pattern is the name of the template parameter pack. @@ -5457,6 +5526,10 @@ instantiated member function. A member class instantiated from a member class template is called an instantiated member class. +A variable instantiated from a variable template is called an +instantiated variable. +A static data member instantiated from a static data member template +is called an instantiated static data member. \pnum An explicit specialization may be declared for a function template, @@ -5508,7 +5581,7 @@ an explicit instantiation definition shall appear at most once in a program, \item an explicit specialization shall be defined at most once -in a program (according to~\ref{basic.def.odr}), and +in a program, as specified in \ref{basic.def.odr}, and \item both an explicit instantiation and a declaration of an explicit specialization shall not appear in a program unless @@ -5631,16 +5704,37 @@ \pnum The implicit instantiation of a class template specialization causes -the implicit instantiation of the declarations, but not of the definitions, -default arguments, or \grammarterm{noexcept-specifier}{s} of the -class member functions, -member classes, -scoped member enumerations, -static data members, -member templates, and -friends; and -it causes the implicit instantiation of the definitions of -unscoped member enumerations and member anonymous unions. +\begin{itemize} +\item + the implicit instantiation of the declarations, but not of the definitions, + of the non-deleted + class member functions, + member classes, + scoped member enumerations, + static data members, + member templates, and + friends; and +\item + the implicit instantiation of the definitions of + deleted member functions, + unscoped member enumerations, and + member anonymous unions. +\end{itemize} +The implicit instantiation of a class template specialization +does not cause the implicit instantiation of +default arguments or \grammarterm{noexcept-specifier}{s} +of the class member functions. +\begin{example} +\begin{codeblock} +template +struct C { + void f() { T x; } + void g() = delete; +}; +C c; // OK, definition of \tcode{C::f} is not instantiated at this point +template<> void C::g() { } // error: redefinition of \tcode{C::g} +\end{codeblock} +\end{example} However, for the purpose of determining whether an instantiated redeclaration is valid according to~\ref{basic.def.odr} and \ref{class.mem}, a declaration that corresponds to a definition in the template @@ -6182,6 +6276,7 @@ instantiation~(\ref{temp.constr.decl}, \ref{temp.constr.constr}), except as described below. \begin{note} In addition, it will typically be an explicit instantiation of certain +\indextext{implementation-dependent}% implementation-dependent data about the class. \end{note} \pnum @@ -7150,7 +7245,7 @@ \begin{note} Type deduction may fail for the following reasons: \begin{itemize} -\item Attempting to instantiate a pack expansion containing multiple parameter packs of differing lengths. +\item Attempting to instantiate a pack expansion containing multiple packs of differing lengths. \item Attempting to create an array with an element type that is \tcode{void}, a function type, a reference type, or an abstract class type, or attempting @@ -7332,7 +7427,7 @@ Each deduction deduces template arguments for subsequent positions in the template parameter packs expanded by the function parameter pack. When a function parameter pack appears in a non-deduced -context\iref{temp.deduct.type}, the type of that parameter pack is +context\iref{temp.deduct.type}, the type of that pack is never deduced. \begin{example} \begin{codeblock} @@ -7706,15 +7801,15 @@ \tcode{A} is a type \begin{indented} -$\text{\cv}_{1,0}$ ``pointer to $\ldots$'' $\text{\cv}_{1,n-1}$ ``pointer to'' -$\text{\cv}_{1,n}$ \tcode{T1} +$\cv{}_{1,0}$ ``pointer to $\ldots$'' $\cv{}_{1,n-1}$ ``pointer to'' +$\cv{}_{1,n}$ \tcode{T1} \end{indented} and \tcode{P} is a type \begin{indented} -$\text{\cv}_{2,0}$ ``pointer to $\ldots$'' $\text{\cv}_{2,n-1}$ ``pointer to'' -$\text{\cv}_{2,n}$ \tcode{T2}, +$\cv{}_{2,0}$ ``pointer to $\ldots$'' $\cv{}_{2,n-1}$ ``pointer to'' +$\cv{}_{2,n}$ \tcode{T2}, \end{indented} then the cv-unqualified \tcode{T1} @@ -7780,9 +7875,6 @@ \tcode{P} and \tcode{A}. -If a particular \tcode{P} contains no \grammarterm{template-parameter}{s} -that participate in template argument deduction, that \tcode{P} is not -used to determine the ordering. \pnum Before the partial ordering is done, certain transformations are performed @@ -7863,8 +7955,8 @@ \end{example} \pnum -If, for a given type, deduction succeeds in both directions (i.e., the -types are identical after the transformations above) +If, for a given type, the +types are identical after the transformations above and both \tcode{P} and \tcode{A} were reference types (before being replaced with the type referred to above): @@ -8029,7 +8121,7 @@ If a template parameter is used only in non-deduced contexts and is not explicitly specified, template argument deduction fails. \begin{note} -Under \ref{temp.deduct.call} and \ref{temp.deduct.partial}, +Under \ref{temp.deduct.call}, if \tcode{P} contains no \grammarterm{template-parameter}{s} that appear in deduced contexts, no deduction is done, so \tcode{P} and \tcode{A} need not have the same form. @@ -8629,9 +8721,8 @@ \pnum \indextext{overloading!resolution!function template}% -A function template can be overloaded either by (non-template) functions of its -name or by (other) function templates of the same name. -When a call to that name is written (explicitly, or implicitly using the +When a call to the name of a function or function template +is written (explicitly, or implicitly using the operator notation), template argument deduction\iref{temp.deduct} and checking of any explicit template arguments\iref{temp.arg} are performed for each function template to find the template argument values (if any) that diff --git a/source/threads.tex b/source/threads.tex index cb328287e9..3dfd67e89c 100644 --- a/source/threads.tex +++ b/source/threads.tex @@ -7,7 +7,7 @@ The following subclauses describe components to create and manage threads\iref{intro.multithread}, perform mutual exclusion, and communicate conditions and values -between threads, as summarized in Table~\ref{tab:thread.lib.summary}. +between threads, as summarized in \tref{thread.lib.summary}. \begin{libsumtab}{Thread support library summary}{tab:thread.lib.summary} \ref{thread.req} & Requirements & \\ \rowsep @@ -27,6 +27,10 @@ requirements. If a template parameter is named \tcode{Predicate}, \tcode{operator()} applied to the template argument shall return a value that is convertible to \tcode{bool}. +If a template parameter is named \tcode{Clock}, +the corresponding template argument shall be a type \tcode{C} +for which \tcode{is_clock_v} is \tcode{true}; +otherwise the program is ill-formed. \rSec2[thread.req.exception]{Exceptions} @@ -128,7 +132,7 @@ \term{native resolution}. \pnum -Implementation-provided clocks that are used for these functions shall meet the +Implementation-provided clocks that are used for these functions shall satisfy the \tcode{TrivialClock} requirements\iref{time.clock.req}. \pnum @@ -529,7 +533,7 @@ \pnum \remarks -This constructor shall not participate in overload resolution if \tcode{decay_t} +This constructor shall not participate in overload resolution if \tcode{remove_cvref_t} is the same type as \tcode{std::thread}. \pnum @@ -887,11 +891,11 @@ The \defn{mutex types} are the standard library types \tcode{mutex}, \tcode{recursive_mutex}, \tcode{timed_mutex}, \tcode{recursive_timed_mutex}, \tcode{shared_mutex}, and \tcode{shared_timed_mutex}. -They shall meet the requirements set out in this subclause. In this description, \tcode{m} +They shall satisfy the requirements set out in this subclause. In this description, \tcode{m} denotes an object of a mutex type. \pnum -The mutex types shall meet the \tcode{Lockable} requirements\iref{thread.req.lockable.req}. +The mutex types shall satisfy the \tcode{Lockable} requirements\iref{thread.req.lockable.req}. \pnum The mutex types shall be \tcode{DefaultConstructible} and \tcode{Destructible}. If @@ -1137,7 +1141,7 @@ instantiation of \tcode{time_point}\iref{time.point}. \pnum -The timed mutex types shall meet the \tcode{TimedLockable} +The timed mutex types shall satisfy the \tcode{TimedLockable} requirements\iref{thread.req.lockable.timed}. \pnum @@ -1326,9 +1330,9 @@ \pnum The standard library types \tcode{shared_mutex} and \tcode{shared_timed_mutex} -are \defn{shared mutex types}. Shared mutex types shall meet the requirements of +are \defn{shared mutex types}. Shared mutex types shall satisfy the requirements of mutex types\iref{thread.mutex.requirements.mutex}, and additionally -shall meet the requirements set out below. In this description, +shall satisfy the requirements set out below. In this description, \tcode{m} denotes an object of a shared mutex type. \pnum @@ -1480,10 +1484,10 @@ \pnum The standard library type \tcode{shared_timed_mutex} is a -\defn{shared timed mutex type}. Shared timed mutex types shall meet the requirements of +\defn{shared timed mutex type}. Shared timed mutex types shall satisfy the requirements of timed mutex types\iref{thread.timedmutex.requirements}, shared mutex types\iref{thread.sharedmutex.requirements}, and additionally -shall meet the requirements set out below. In this description, +shall satisfy the requirements set out below. In this description, \tcode{m} denotes an object of a shared timed mutex type, \tcode{rel_type} denotes an object of an instantiation of \tcode{duration}\iref{time.duration}, and @@ -1677,7 +1681,7 @@ object throughout the \tcode{lock_guard} object's lifetime\iref{basic.life}. The behavior of a program is undefined if the lockable object referenced by \tcode{pm} does not exist for the entire lifetime of the \tcode{lock_guard} -object. The supplied \tcode{Mutex} type shall meet the \tcode{BasicLockable} +object. The supplied \tcode{Mutex} type shall satisfy the \tcode{BasicLockable} requirements\iref{thread.req.lockable.basic}. \indexlibrary{\idxcode{lock_guard}!constructor}% @@ -1756,9 +1760,9 @@ object. When \tcode{sizeof...(MutexTypes)} is \tcode{1}, the supplied \tcode{Mutex} type -shall meet the \tcode{BasicLockable} requirements\iref{thread.req.lockable.basic}. +shall satisfy the \tcode{BasicLockable} requirements\iref{thread.req.lockable.basic}. Otherwise, each of the mutex types -shall meet the \tcode{Lockable} requirements\iref{thread.req.lockable.req}. +shall satisfy the \tcode{Lockable} requirements\iref{thread.req.lockable.req}. \indexlibrary{\idxcode{scoped_lock}!constructor}% \begin{itemdecl} @@ -1871,7 +1875,7 @@ \tcode{pm} is not null and the lockable object pointed to by \tcode{pm} does not exist for the entire remaining lifetime\iref{basic.life} of the \tcode{unique_lock} object. The supplied -\tcode{Mutex} type shall meet the \tcode{BasicLockable} +\tcode{Mutex} type shall satisfy the \tcode{BasicLockable} requirements\iref{thread.req.lockable.basic}. \pnum @@ -1934,7 +1938,7 @@ \begin{itemdescr} \pnum \requires -The supplied \tcode{Mutex} type shall meet the \tcode{Lockable} +The supplied \tcode{Mutex} type shall satisfy the \tcode{Lockable} requirements\iref{thread.req.lockable.req}. If \tcode{mutex_type} is not a recursive mutex the calling thread does not own the mutex. @@ -1974,7 +1978,7 @@ \begin{itemdescr} \pnum \requires If \tcode{mutex_type} is not a recursive mutex the calling thread -does not own the mutex. The supplied \tcode{Mutex} type shall meet the +does not own the mutex. The supplied \tcode{Mutex} type shall satisfy the \tcode{TimedLockable} requirements\iref{thread.req.lockable.timed}. \pnum @@ -1995,7 +1999,7 @@ \begin{itemdescr} \pnum \requires If \tcode{mutex_type} is not a recursive mutex the calling thread does not own the mutex. -The supplied \tcode{Mutex} type shall meet the \tcode{TimedLockable} requirements\iref{thread.req.lockable.timed}. +The supplied \tcode{Mutex} type shall satisfy the \tcode{TimedLockable} requirements\iref{thread.req.lockable.timed}. \pnum \effects Constructs an object of type \tcode{unique_lock} and calls \tcode{m.try_lock_for(rel_time)}. @@ -2075,7 +2079,7 @@ \begin{itemdescr} \pnum -\requires The supplied \tcode{Mutex} shall meet the \tcode{Lockable} +\requires The supplied \tcode{Mutex} shall satisfy the \tcode{Lockable} requirements\iref{thread.req.lockable.req}. \pnum @@ -2109,7 +2113,7 @@ \begin{itemdescr} \pnum -\requires The supplied \tcode{Mutex} type shall meet the \tcode{TimedLockable} +\requires The supplied \tcode{Mutex} type shall satisfy the \tcode{TimedLockable} requirements\iref{thread.req.lockable.timed}. \pnum @@ -2143,7 +2147,7 @@ \begin{itemdescr} \pnum -\requires The supplied \tcode{Mutex} type shall meet the \tcode{TimedLockable} requirements\iref{thread.req.lockable.timed}. +\requires The supplied \tcode{Mutex} type shall satisfy the \tcode{TimedLockable} requirements\iref{thread.req.lockable.timed}. \pnum \effects As if by \tcode{pm->try_lock_for(rel_time)}. @@ -2312,7 +2316,7 @@ is undefined if the contained pointer \tcode{pm} is not null and the lockable object pointed to by \tcode{pm} does not exist for the entire remaining lifetime\iref{basic.life} of the \tcode{shared_lock} object. The supplied -\tcode{Mutex} type shall meet the shared mutex +\tcode{Mutex} type shall satisfy the shared mutex requirements\iref{thread.sharedtimedmutex.requirements}. \pnum @@ -2691,7 +2695,7 @@ \begin{itemdescr} \pnum -\requires Each template parameter type shall meet the \tcode{Lockable} requirements. \begin{note} The +\requires Each template parameter type shall satisfy the \tcode{Lockable} requirements. \begin{note} The \tcode{unique_lock} class template meets these requirements when suitably instantiated. \end{note} @@ -2699,8 +2703,8 @@ \effects Calls \tcode{try_lock()} for each argument in order beginning with the first until all arguments have been processed or a call to \tcode{try_lock()} fails, either by returning \tcode{false} or by throwing an exception. If a call to -\tcode{try_lock()} fails, \tcode{unlock()} shall be called for all prior arguments -and there shall be no further calls to \tcode{try_lock()}. +\tcode{try_lock()} fails, \tcode{unlock()} is called for all prior arguments +with no further calls to \tcode{try_lock()}. \pnum \returns \tcode{-1} if all calls to \tcode{try_lock()} returned \tcode{true}, @@ -2715,18 +2719,18 @@ \begin{itemdescr} \pnum -\requires Each template parameter type shall meet the \tcode{Lockable} requirements, +\requires Each template parameter type shall satisfy the \tcode{Lockable} requirements, \begin{note} The \tcode{unique_lock} class template meets these requirements when suitably instantiated. \end{note} \pnum \effects All arguments are locked via a sequence of calls to \tcode{lock()}, -\tcode{try_lock()}, or \tcode{unlock()} on each argument. The sequence of calls shall +\tcode{try_lock()}, or \tcode{unlock()} on each argument. The sequence of calls does not result in deadlock, but is otherwise unspecified. \begin{note} A deadlock avoidance algorithm such as try-and-back-off must be used, but the specific algorithm is not specified to avoid over-constraining implementations. \end{note} If a call to -\tcode{lock()} or \tcode{try_lock()} throws an exception, \tcode{unlock()} shall be +\tcode{lock()} or \tcode{try_lock()} throws an exception, \tcode{unlock()} is called for any argument that had been locked by a call to \tcode{lock()} or \tcode{try_lock()}. \end{itemdescr} @@ -3321,7 +3325,7 @@ \rSec2[thread.condition.condvarany]{Class \tcode{condition_variable_any}} \pnum -A \tcode{Lock} type shall meet the \tcode{BasicLockable} +A \tcode{Lock} type shall satisfy the \tcode{BasicLockable} requirements\iref{thread.req.lockable.basic}. \begin{note} All of the standard mutex types meet this requirement. If a \tcode{Lock} type other than one of the standard mutex types or a \tcode{unique_lock} wrapper for a standard mutex type @@ -3930,7 +3934,8 @@ \begin{itemdescr} \pnum -\requires \tcode{Alloc} shall be an Allocator\iref{allocator.requirements}. +\requires \tcode{Alloc} shall satisfy the \tcode{Allocator} +requirements (\tref{utilities.allocator.requirements}). \end{itemdescr} @@ -5014,7 +5019,7 @@ \pnum \remarks -This constructor shall not participate in overload resolution if \tcode{decay_t} +This constructor shall not participate in overload resolution if \tcode{remove_cvref_t} is the same type as \tcode{packaged_task}. \pnum diff --git a/source/utilities.tex b/source/utilities.tex index b69a1ec78f..6aa99ed783 100644 --- a/source/utilities.tex +++ b/source/utilities.tex @@ -6,7 +6,7 @@ \pnum This Clause describes utilities that are generally useful in \Cpp{} programs; some of these utilities are used by other elements of the \Cpp{} standard library. -These utilities are summarized in Table~\ref{tab:util.lib.summary}. +These utilities are summarized in \tref{util.lib.summary}. \begin{libsumtab}{General utilities library summary}{tab:util.lib.summary} \ref{utility} & Utility components & \tcode{} \\ \rowsep @@ -34,14 +34,15 @@ \rSec1[utility]{Utility components} -\pnum -This subclause contains some basic function and class templates that are used -throughout the rest of the library. - \indexhdr{utility}% \indexlibrary{\idxcode{rel_ops}}% \rSec2[utility.syn]{Header \tcode{} synopsis} +\pnum +The header \tcode{} +contains some basic function and class templates that are used +throughout the rest of the library. + \begin{codeblock} #include // see \ref{initializer_list.syn} @@ -177,19 +178,6 @@ } \end{codeblock} -\pnum -The header \tcode{} defines several types and function templates -that are described in this Clause. It also defines the template \tcode{pair} -and various function templates that operate on \tcode{pair} objects. - -\pnum -The type \tcode{chars_format} -is a bitmask type\iref{bitmask.types} -with elements -\tcode{scientific}, -\tcode{fixed}, -and \tcode{hex}. - \rSec2[utility.swap]{\tcode{swap}} \indexlibrary{\idxcode{swap}}% @@ -200,7 +188,9 @@ \begin{itemdescr} \pnum -\remarks This function shall not participate in overload resolution +\remarks This function +is a designated customization point\iref{namespace.std} and +shall not participate in overload resolution unless \tcode{is_move_constructible_v} is \tcode{true} and \tcode{is_move_assignable_v} is \tcode{true}. The expression inside \tcode{noexcept} is equivalent to: @@ -214,9 +204,9 @@ Type \tcode{T} shall be -\tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) +\tcode{MoveConstructible} (\tref{moveconstructible}) and -\tcode{MoveAssignable} (Table~\ref{tab:moveassignable}). +\tcode{MoveAssignable} (\tref{moveassignable}). \pnum \effects @@ -433,11 +423,10 @@ \indexlibrarymember{value_type}{integer_sequence}% \begin{codeblock} namespace std { - template - struct integer_sequence { - using value_type = T; - static constexpr size_t size() noexcept { return sizeof...(I); } - }; + template struct integer_sequence { + using value_type = T; + static constexpr size_t size() noexcept { return sizeof...(I); } + }; } \end{codeblock} @@ -483,30 +472,35 @@ \begin{codeblock} namespace std { template - struct pair { - using first_type = T1; - using second_type = T2; - - T1 first; - T2 second; - - pair(const pair&) = default; - pair(pair&&) = default; - @\EXPLICIT@ constexpr pair(); - @\EXPLICIT@ constexpr pair(const T1& x, const T2& y); - template @\EXPLICIT@ constexpr pair(U1&& x, U2&& y); - template @\EXPLICIT@ constexpr pair(const pair& p); - template @\EXPLICIT@ constexpr pair(pair&& p); - template - pair(piecewise_construct_t, tuple first_args, tuple second_args); - - pair& operator=(const pair& p); - template pair& operator=(const pair& p); - pair& operator=(pair&& p) noexcept(@\seebelow@); - template pair& operator=(pair&& p); - - void swap(pair& p) noexcept(@\seebelow@); - }; + struct pair { + using first_type = T1; + using second_type = T2; + + T1 first; + T2 second; + + pair(const pair&) = default; + pair(pair&&) = default; + @\EXPLICIT@ constexpr pair(); + @\EXPLICIT@ constexpr pair(const T1& x, const T2& y); + template + @\EXPLICIT@ constexpr pair(U1&& x, U2&& y); + template + @\EXPLICIT@ constexpr pair(const pair& p); + template + @\EXPLICIT@ constexpr pair(pair&& p); + template + pair(piecewise_construct_t, tuple first_args, tuple second_args); + + pair& operator=(const pair& p); + template + pair& operator=(const pair& p); + pair& operator=(pair&& p) noexcept(@\seebelow@); + template + pair& operator=(pair&& p); + + void swap(pair& p) noexcept(@\seebelow@); + }; template pair(T1, T2) -> pair; @@ -833,8 +827,8 @@ \indexlibrary{\idxcode{swap}!\idxcode{pair}}% \begin{itemdecl} -template void swap(pair& x, pair& y) - noexcept(noexcept(x.swap(y))); +template + void swap(pair& x, pair& y) noexcept(noexcept(x.swap(y))); \end{itemdecl} \begin{itemdescr} @@ -1087,64 +1081,64 @@ \begin{codeblock} namespace std { template - class tuple { - public: - // \ref{tuple.cnstr}, \tcode{tuple} construction - @\EXPLICIT@ constexpr tuple(); - @\EXPLICIT@ constexpr tuple(const Types&...); // only if \tcode{sizeof...(Types) >= 1} - template - @\EXPLICIT@ constexpr tuple(UTypes&&...); // only if \tcode{sizeof...(Types) >= 1} - - tuple(const tuple&) = default; - tuple(tuple&&) = default; - - template - @\EXPLICIT@ constexpr tuple(const tuple&); - template - @\EXPLICIT@ constexpr tuple(tuple&&); - - template - @\EXPLICIT@ constexpr tuple(const pair&); // only if \tcode{sizeof...(Types) == 2} - template - @\EXPLICIT@ constexpr tuple(pair&&); // only if \tcode{sizeof...(Types) == 2} - - // allocator-extended constructors - template - tuple(allocator_arg_t, const Alloc& a); - template - @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, const Types&...); - template - @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, UTypes&&...); - template - tuple(allocator_arg_t, const Alloc& a, const tuple&); - template - tuple(allocator_arg_t, const Alloc& a, tuple&&); - template - @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, const tuple&); - template - @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, tuple&&); - template - @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, const pair&); - template - @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, pair&&); - - // \ref{tuple.assign}, \tcode{tuple} assignment - tuple& operator=(const tuple&); - tuple& operator=(tuple&&) noexcept(@\seebelow@); - - template - tuple& operator=(const tuple&); - template - tuple& operator=(tuple&&); - - template - tuple& operator=(const pair&); // only if \tcode{sizeof...(Types) == 2} - template - tuple& operator=(pair&&); // only if \tcode{sizeof...(Types) == 2} - - // \ref{tuple.swap}, \tcode{tuple} swap - void swap(tuple&) noexcept(@\seebelow@); - }; + class tuple { + public: + // \ref{tuple.cnstr}, \tcode{tuple} construction + @\EXPLICIT@ constexpr tuple(); + @\EXPLICIT@ constexpr tuple(const Types&...); // only if \tcode{sizeof...(Types) >= 1} + template + @\EXPLICIT@ constexpr tuple(UTypes&&...); // only if \tcode{sizeof...(Types) >= 1} + + tuple(const tuple&) = default; + tuple(tuple&&) = default; + + template + @\EXPLICIT@ constexpr tuple(const tuple&); + template + @\EXPLICIT@ constexpr tuple(tuple&&); + + template + @\EXPLICIT@ constexpr tuple(const pair&); // only if \tcode{sizeof...(Types) == 2} + template + @\EXPLICIT@ constexpr tuple(pair&&); // only if \tcode{sizeof...(Types) == 2} + + // allocator-extended constructors + template + tuple(allocator_arg_t, const Alloc& a); + template + @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, const Types&...); + template + @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, UTypes&&...); + template + tuple(allocator_arg_t, const Alloc& a, const tuple&); + template + tuple(allocator_arg_t, const Alloc& a, tuple&&); + template + @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, const tuple&); + template + @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, tuple&&); + template + @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, const pair&); + template + @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, pair&&); + + // \ref{tuple.assign}, \tcode{tuple} assignment + tuple& operator=(const tuple&); + tuple& operator=(tuple&&) noexcept(@\seebelow@); + + template + tuple& operator=(const tuple&); + template + tuple& operator=(tuple&&); + + template + tuple& operator=(const pair&); // only if \tcode{sizeof...(Types) == 2} + template + tuple& operator=(pair&&); // only if \tcode{sizeof...(Types) == 2} + + // \ref{tuple.swap}, \tcode{tuple} swap + void swap(tuple&) noexcept(@\seebelow@); + }; template tuple(UTypes...) -> tuple; @@ -1401,8 +1395,8 @@ \begin{itemdescr} \pnum -\requires \tcode{Alloc} shall meet the requirements for an -\tcode{Allocator}\iref{allocator.requirements}. +\requires \tcode{Alloc} shall satisfy the +\tcode{Allocator} requirements (\tref{utilities.allocator.requirements}). \pnum \effects Equivalent to the preceding constructors except that each element is constructed with @@ -1679,8 +1673,8 @@ $\tcode{A}_{ik}$ the following requirements shall be satisfied: \begin{itemize} \item If $\tcode{T}_i$ is deduced as an lvalue reference type, then - \tcode{is_constructible_v<$\tcode{A}_{ik}$, $cv_i\;\tcode{A}_{ik}$\&> == true}, otherwise -\item \tcode{is_constructible_v<$\tcode{A}_{ik}$, $cv_i\;\tcode{A}_{ik}$\&\&> == true}. + \tcode{is_constructible_v<$\tcode{A}_{ik}$, $\cv{}_i\;\tcode{A}_{ik}$\&> == true}, otherwise +\item \tcode{is_constructible_v<$\tcode{A}_{ik}$, $\cv{}_i\;\tcode{A}_{ik}$\&\&> == true}. \end{itemize} \pnum @@ -1770,7 +1764,7 @@ \begin{itemdescr} \pnum -\remarks All specializations of \tcode{tuple_size} shall meet the +\remarks All specializations of \tcode{tuple_size} shall satisfy the \tcode{UnaryTypeTrait} requirements\iref{meta.rqmts} with a base characteristic of \tcode{integral_constant} for some \tcode{N}. @@ -1798,7 +1792,7 @@ \pnum \ctype \tcode{TI} is the -type of the \tcode{I}th element of \tcode{Types}, +type of the $\tcode{I}^\text{th}$ element of \tcode{Types}, where indexing is zero-based. \end{itemdescr} @@ -1814,7 +1808,7 @@ Let \tcode{TS} denote \tcode{tuple_size} of the \cv-unqualified type \tcode{T}. If the expression \tcode{TS::value} is well-formed when treated as an unevaluated operand, then each -of the three templates shall meet the \tcode{UnaryTypeTrait} requirements\iref{meta.rqmts} +of the three templates shall satisfy the \tcode{UnaryTypeTrait} requirements\iref{meta.rqmts} with a base characteristic of \begin{codeblock} integral_constant @@ -1849,7 +1843,7 @@ \begin{itemdescr} \pnum Let \tcode{TE} denote \tcode{tuple_element_t} of the \cv-unqualified type \tcode{T}. Then -each of the three templates shall meet the \tcode{TransformationTrait} +each of the three templates shall satisfy the \tcode{TransformationTrait} requirements\iref{meta.rqmts} with a member typedef \tcode{type} that names the following type: @@ -1891,7 +1885,7 @@ The program is ill-formed if \tcode{I} is out of bounds. \pnum -\returns A reference to the \tcode{I}th element of \tcode{t}, where +\returns A reference to the $\tcode{I}^\text{th}$ element of \tcode{t}, where indexing is zero-based. \pnum @@ -2064,7 +2058,8 @@ \begin{itemdescr} \pnum -\requires \tcode{Alloc} shall be an \tcode{Allocator}\iref{allocator.requirements}. +\requires \tcode{Alloc} shall satisfy the \tcode{Allocator} +requirements (\tref{utilities.allocator.requirements}). \pnum \begin{note} Specialization of this trait informs other library components that @@ -2127,17 +2122,17 @@ // \ref{optional.relops}, relational operators template - constexpr bool operator==(const optional&, const optional&); + constexpr bool operator==(const optional&, const optional&); template - constexpr bool operator!=(const optional&, const optional&); + constexpr bool operator!=(const optional&, const optional&); template - constexpr bool operator<(const optional&, const optional&); + constexpr bool operator<(const optional&, const optional&); template - constexpr bool operator>(const optional&, const optional&); + constexpr bool operator>(const optional&, const optional&); template - constexpr bool operator<=(const optional&, const optional&); + constexpr bool operator<=(const optional&, const optional&); template - constexpr bool operator>=(const optional&, const optional&); + constexpr bool operator>=(const optional&, const optional&); // \ref{optional.nullops}, comparison with \tcode{nullopt} template constexpr bool operator==(const optional&, nullopt_t) noexcept; @@ -2194,7 +2189,8 @@ \indexlibrary{\idxcode{optional}}% \indexlibrarymember{value_type}{optional}% \begin{codeblock} -template +namespace std { + template class optional { public: using value_type = T; @@ -2251,10 +2247,12 @@ void reset() noexcept; private: - T *val; // \expos + T *val; // \expos }; -template optional(T) -> optional; + template + optional(T) -> optional; +} \end{codeblock} \pnum @@ -2272,7 +2270,7 @@ Member \tcode{val} is provided for exposition only. When an \tcode{optional} object contains a value, \tcode{val} points to the contained value. \pnum -\tcode{T} shall be an object type and shall satisfy the requirements of \tcode{Destructible} (Table~\ref{tab:destructible}). +\tcode{T} shall be an object type and shall satisfy the \tcode{Destructible} requirements (\tref{destructible}). \rSec3[optional.ctor]{Constructors} @@ -2564,7 +2562,7 @@ \begin{itemdescr} \pnum \effects -See Table~\ref{tab:optional.assign.copy}. +See \tref{optional.assign.copy}. \begin{lib2dtab2}{\tcode{optional::operator=(const optional\&)} effects}{tab:optional.assign.copy} {\tcode{*this} contains a value} {\tcode{*this} does not contain a value} @@ -2606,7 +2604,7 @@ \begin{itemdescr} \pnum \effects -See Table~\ref{tab:optional.assign.move}. +See \tref{optional.assign.move}. The result of the expression \tcode{bool(rhs)} remains unchanged. \begin{lib2dtab2}{\tcode{optional::operator=(optional\&\&)} effects}{tab:optional.assign.move} {\tcode{*this} contains a value} @@ -2684,7 +2682,7 @@ \begin{itemdescr} \pnum \effects -See Table~\ref{tab:optional.assign.copy.templ}. +See \tref{optional.assign.copy.templ}. \begin{lib2dtab2}{\tcode{optional::operator=(const optional\&)} effects}{tab:optional.assign.copy.templ} {\tcode{*this} contains a value} {\tcode{*this} does not contain a value} @@ -2745,7 +2743,7 @@ \begin{itemdescr} \pnum \effects -See Table~\ref{tab:optional.assign.move.templ}. +See \tref{optional.assign.move.templ}. The result of the expression \tcode{bool(rhs)} remains unchanged. \begin{lib2dtab2}{\tcode{optional::operator=(optional\&\&)} effects}{tab:optional.assign.move.templ} {\tcode{*this} contains a value} @@ -2872,7 +2870,7 @@ \pnum \effects -See Table~\ref{tab:optional.swap}. +See \tref{optional.swap}. \begin{lib2dtab2}{\tcode{optional::swap(optional\&)} effects}{tab:optional.swap} {\tcode{*this} contains a value} {\tcode{*this} does not contain a value} @@ -2895,7 +2893,7 @@ \pnum \throws -Any exceptions thrown by the operations in the relevant part of Table~\ref{tab:optional.swap}. +Any exceptions thrown by the operations in the relevant part of \tref{optional.swap}. \pnum \remarks @@ -3792,52 +3790,52 @@ \begin{codeblock} namespace std { template - class variant { - public: - // \ref{variant.ctor}, constructors - constexpr variant() noexcept(@\seebelow@); - variant(const variant&); - variant(variant&&) noexcept(@\seebelow@); - - template - constexpr variant(T&&) noexcept(@\seebelow@); - - template - constexpr explicit variant(in_place_type_t, Args&&...); - template - constexpr explicit variant(in_place_type_t, initializer_list, Args&&...); - - template - constexpr explicit variant(in_place_index_t, Args&&...); - template - constexpr explicit variant(in_place_index_t, initializer_list, Args&&...); - - // \ref{variant.dtor}, destructor - ~variant(); - - // \ref{variant.assign}, assignment - variant& operator=(const variant&); - variant& operator=(variant&&) noexcept(@\seebelow@); - - template variant& operator=(T&&) noexcept(@\seebelow@); - - // \ref{variant.mod}, modifiers - template - T& emplace(Args&&...); - template - T& emplace(initializer_list, Args&&...); - template - variant_alternative_t>& emplace(Args&&...); - template - variant_alternative_t>& emplace(initializer_list, Args&&...); - - // \ref{variant.status}, value status - constexpr bool valueless_by_exception() const noexcept; - constexpr size_t index() const noexcept; - - // \ref{variant.swap}, swap - void swap(variant&) noexcept(@\seebelow@); - }; + class variant { + public: + // \ref{variant.ctor}, constructors + constexpr variant() noexcept(@\seebelow@); + variant(const variant&); + variant(variant&&) noexcept(@\seebelow@); + + template + constexpr variant(T&&) noexcept(@\seebelow@); + + template + constexpr explicit variant(in_place_type_t, Args&&...); + template + constexpr explicit variant(in_place_type_t, initializer_list, Args&&...); + + template + constexpr explicit variant(in_place_index_t, Args&&...); + template + constexpr explicit variant(in_place_index_t, initializer_list, Args&&...); + + // \ref{variant.dtor}, destructor + ~variant(); + + // \ref{variant.assign}, assignment + variant& operator=(const variant&); + variant& operator=(variant&&) noexcept(@\seebelow@); + + template variant& operator=(T&&) noexcept(@\seebelow@); + + // \ref{variant.mod}, modifiers + template + T& emplace(Args&&...); + template + T& emplace(initializer_list, Args&&...); + template + variant_alternative_t>& emplace(Args&&...); + template + variant_alternative_t>& emplace(initializer_list, Args&&...); + + // \ref{variant.status}, value status + constexpr bool valueless_by_exception() const noexcept; + constexpr size_t index() const noexcept; + + // \ref{variant.swap}, swap + void swap(variant&) noexcept(@\seebelow@); + }; } \end{codeblock} @@ -4532,7 +4530,7 @@ \begin{itemdescr} \pnum \remarks -All specializations of \tcode{variant_size} shall meet the +All specializations of \tcode{variant_size} shall satisfy the \tcode{UnaryTypeTrait} requirements\iref{meta.rqmts} with a base characteristic of \tcode{integral_constant} for some \tcode{N}. \end{itemdescr} @@ -4547,7 +4545,7 @@ \begin{itemdescr} \pnum Let \tcode{VS} denote \tcode{variant_size} of the cv-unqualified -type \tcode{T}. Then each of the three templates shall meet the +type \tcode{T}. Then each of the three templates shall satisfy the \tcode{UnaryTypeTrait} requirements\iref{meta.rqmts} with a base characteristic of \tcode{integral_constant}. \end{itemdescr} @@ -5064,41 +5062,45 @@ \rSec2[any.class]{Class \tcode{any}} \begin{codeblock} -class any { -public: - // \ref{any.cons}, construction and destruction - constexpr any() noexcept; +namespace std { + class any { + public: + // \ref{any.cons}, construction and destruction + constexpr any() noexcept; - any(const any& other); - any(any&& other) noexcept; + any(const any& other); + any(any&& other) noexcept; - template any(T&& value); + template + any(T&& value); - template - explicit any(in_place_type_t, Args&&...); - template - explicit any(in_place_type_t, initializer_list, Args&&...); + template + explicit any(in_place_type_t, Args&&...); + template + explicit any(in_place_type_t, initializer_list, Args&&...); - ~any(); + ~any(); - // \ref{any.assign}, assignments - any& operator=(const any& rhs); - any& operator=(any&& rhs) noexcept; + // \ref{any.assign}, assignments + any& operator=(const any& rhs); + any& operator=(any&& rhs) noexcept; - template any& operator=(T&& rhs); + template + any& operator=(T&& rhs); - // \ref{any.modifiers}, modifiers - template - decay_t& emplace(Args&& ...); - template - decay_t& emplace(initializer_list, Args&&...); - void reset() noexcept; - void swap(any& rhs) noexcept; + // \ref{any.modifiers}, modifiers + template + decay_t& emplace(Args&& ...); + template + decay_t& emplace(initializer_list, Args&&...); + void reset() noexcept; + void swap(any& rhs) noexcept; - // \ref{any.observers}, observers - bool has_value() const noexcept; - const type_info& type() const noexcept; -}; + // \ref{any.observers}, observers + bool has_value() const noexcept; + const type_info& type() const noexcept; + }; +} \end{codeblock} \pnum @@ -5112,11 +5114,12 @@ \pnum Implementations should avoid the use of dynamically allocated memory for a small contained value. +However, any such small-object optimization shall only be applied to types \tcode{T} for which +\tcode{is_nothrow_move_constructible_v} is \tcode{true}. \begin{example} -where the object constructed is holding only an \tcode{int}. +A contained value of type \tcode{int} could be stored in an internal buffer, +not in separately-allocated memory. \end{example} -Such small-object optimization shall only be applied to types \tcode{T} for which -\tcode{is_nothrow_move_constructible_v} is \tcode{true}. \rSec3[any.cons]{Construction and destruction} @@ -7113,7 +7116,7 @@ disambiguate constructor and function overloading. Specifically, several types (see \tcode{tuple}~\ref{tuple}) have constructors with \tcode{allocator_arg_t} as the first argument, immediately followed by an argument of a type that satisfies the -\tcode{Allocator} requirements\iref{allocator.requirements}. +\tcode{Allocator} requirements (\tref{utilities.allocator.requirements}). \rSec2[allocator.uses]{\tcode{uses_allocator}} @@ -7470,9 +7473,9 @@ using propagate_on_container_move_assignment = true_type; using is_always_equal = true_type; - allocator() noexcept; - allocator(const allocator&) noexcept; - template allocator(const allocator&) noexcept; + constexpr allocator() noexcept; + constexpr allocator(const allocator&) noexcept; + template constexpr allocator(const allocator&) noexcept; ~allocator(); [[nodiscard]] T* allocate(size_t n); @@ -7921,7 +7924,7 @@ \tcode{::operator delete()}\indexlibrary{\idxcode{delete}!\idxcode{operator}}. \end{itemdescr} -\xref ISO C 7.22.3 +\xrefc{7.22.3} \rSec1[smartptr]{Smart pointers} @@ -7947,23 +7950,6 @@ deleter, but properly disposes of its owned object via the associated deleter before such replacement is considered completed. -\pnum -Additionally, \textit{u} can, upon request, \defn{transfer ownership} to another -unique pointer \textit{u2}. Upon completion of such a transfer, the following -postconditions hold: - -\begin{itemize} -\item \textit{u2.p} is equal to the pre-transfer \textit{u.p}, -\item \textit{u.p} is equal to \tcode{nullptr}, and -\item if the pre-transfer \textit{u.d} maintained state, such state has been -transferred to \textit{u2.d}. -\end{itemize} - -As in the case of a reset, \textit{u2} properly disposes of its pre-transfer -owned object via the pre-transfer associated deleter before the ownership -transfer is considered complete. \begin{note} A deleter's state need never be -copied, only moved or swapped as ownership is transferred. \end{note} - \pnum Each object of a type \tcode{U} instantiated from the \tcode{unique_ptr} template specified in this subclause has the strict ownership semantics, specified above, @@ -8139,7 +8125,7 @@ \pnum If the deleter's type \tcode{D} is not a reference type, \tcode{D} shall satisfy -the requirements of \tcode{Destructible} (Table~\ref{tab:destructible}). +the \tcode{Destructible} requirements (\tref{destructible}). \pnum If the \grammarterm{qualified-id} \tcode{remove_reference_t::pointer} is valid and denotes a @@ -8147,10 +8133,10 @@ D>::pointer} shall be a synonym for \tcode{remove_reference_t::pointer}. Otherwise \tcode{unique_ptr::pointer} shall be a synonym for \tcode{element_type*}. The type \tcode{unique_ptr::pointer} shall -satisfy the requirements of \tcode{NullablePointer}\iref{nullablepointer.requirements}. +satisfy the \tcode{NullablePointer} requirements (\tref{nullablepointer}). \pnum -\begin{example} Given an allocator type \tcode{X}\iref{allocator.requirements} and +\begin{example} Given an allocator type \tcode{X} (\tref{utilities.allocator.requirements}) and letting \tcode{A} be a synonym for \tcode{allocator_traits}, the types \tcode{A::pointer}, \tcode{A::const_pointer}, \tcode{A::void_pointer}, and \tcode{A::const_void_pointer} may be used as \tcode{unique_ptr::pointer}. \end{example} @@ -8166,7 +8152,7 @@ \begin{itemdescr} \pnum \requires \tcode{D} shall -satisfy the requirements of \tcode{DefaultConstructible} (Table~\ref{tab:defaultconstructible}), +satisfy the \tcode{DefaultConstructible} requirements (\tref{defaultconstructible}), and that construction shall not throw an exception. \pnum @@ -8191,7 +8177,7 @@ \begin{itemdescr} \pnum \requires \tcode{D} shall -satisfy the requirements of \tcode{DefaultConstructible} (Table~\ref{tab:defaultconstructible}), +satisfy the \tcode{DefaultConstructible} requirements (\tref{defaultconstructible}), and that construction shall not throw an exception. \pnum @@ -8249,10 +8235,10 @@ \pnum \requires For the first constructor, if \tcode{D} is not a reference type, -\tcode{D} shall satisfy the requirements of \tcode{CopyConstructible} and +\tcode{D} shall satisfy the \tcode{CopyConstructible} requirements and such construction shall not exit via an exception. For the second constructor, if \tcode{D} is not a reference type, -\tcode{D} shall satisfy the requirements of \tcode{MoveConstructible} and +\tcode{D} shall satisfy the \tcode{MoveConstructible} requirements and such construction shall not exit via an exception. \pnum @@ -8296,22 +8282,23 @@ \begin{itemdescr} \pnum \requires If \tcode{D} is not a reference type, -\tcode{D} shall satisfy the requirements of \tcode{MoveConstructible} -(Table~\ref{tab:moveconstructible}). +\tcode{D} shall satisfy the \tcode{MoveConstructible} +requirements (\tref{moveconstructible}). Construction of the deleter from an rvalue of type \tcode{D} shall not throw an exception. \pnum -\effects Constructs a \tcode{unique_ptr} by transferring ownership from -\tcode{u} to \tcode{*this}. If \tcode{D} is a reference type, this +\effects Constructs a \tcode{unique_ptr} from +\tcode{u}. If \tcode{D} is a reference type, this deleter is copy constructed from \tcode{u}'s deleter; otherwise, this deleter is move constructed from \tcode{u}'s deleter. \begin{note} The -deleter constructor can be implemented with \tcode{std::forward}. \end{note} +construction of the deleter can be implemented with \tcode{std::forward}. \end{note} \pnum \postconditions \tcode{get()} yields the value \tcode{u.get()} -yielded before the construction. \tcode{get_deleter()} returns a reference +yielded before the construction. \tcode{u.get() == nullptr}. +\tcode{get_deleter()} returns a reference to the stored deleter that was constructed from \tcode{u.get_deleter()}. If \tcode{D} is a reference type then \tcode{get_deleter()} and \tcode{u.get_deleter()} both reference @@ -8342,15 +8329,15 @@ \end{itemize} \pnum -\effects Constructs a \tcode{unique_ptr} by transferring ownership from \tcode{u} -to \tcode{*this}. If \tcode{E} is a reference type, this deleter is copy constructed from +\effects Constructs a \tcode{unique_ptr} from \tcode{u}. +If \tcode{E} is a reference type, this deleter is copy constructed from \tcode{u}'s deleter; otherwise, this deleter is move constructed from \tcode{u}'s deleter. \begin{note} The deleter constructor can be implemented with \tcode{std::forward}. \end{note} \pnum \postconditions \tcode{get()} yields the value \tcode{u.get()} -yielded before the construction. +yielded before the construction. \tcode{u.get() == nullptr}. \tcode{get_deleter()} returns a reference to the stored deleter that was constructed from \tcode{u.get_deleter()}. @@ -8385,7 +8372,7 @@ \begin{itemdescr} \pnum \requires If \tcode{D} is not a reference type, \tcode{D} shall satisfy the -requirements of \tcode{MoveAssignable} (Table~\ref{tab:moveassignable}) and assignment +\tcode{MoveAssignable} requirements (\tref{moveassignable}) and assignment of the deleter from an rvalue of type \tcode{D} shall not throw an exception. Otherwise, \tcode{D} is a reference type; \tcode{remove_reference_t} shall satisfy the \tcode{CopyAssignable} @@ -8393,13 +8380,14 @@ lvalue of type \tcode{D} shall not throw an exception. \pnum -\effects -Transfers ownership from \tcode{u} to \tcode{*this} as if by calling -\tcode{reset(u.release())} followed by -\tcode{get_deleter() = std::forward(u.get_deleter())}. +\effects Calls \tcode{reset(u.release())} followed by +\tcode{get_deleter() = std::forward(u.get_dele\-ter())}. \pnum \returns \tcode{*this}. + +\pnum +\postconditions \tcode{u.get() == nullptr}. \end{itemdescr} \indexlibrarymember{operator=}{unique_ptr}% @@ -8424,12 +8412,14 @@ \end{itemize} \pnum -\effects Transfers ownership from \tcode{u} to \tcode{*this} as if by calling -\tcode{reset(u.release())} followed by -\tcode{get_deleter() = std::forward(u.get_deleter())}. +\effects Calls \tcode{reset(u.release())} followed by +\tcode{get_deleter() = std::forward(u.get_dele\-ter())}. \pnum \returns \tcode{*this}. + +\pnum +\postconditions \tcode{u.get() == nullptr}. \end{itemdescr} \indexlibrarymember{operator=}{unique_ptr}% @@ -9276,7 +9266,8 @@ initialized with \tcode{std::move(d)} shall not throw exceptions. The expression \tcode{d(p)} shall have well-defined behavior and shall not throw exceptions. -\tcode{A} shall be an allocator\iref{allocator.requirements}. +\tcode{A} shall satisfy the \tcode{Allocator} requirements +(\tref{utilities.allocator.requirements}). \pnum\effects Constructs a \tcode{shared_ptr} object that owns the object \tcode{p} and the deleter \tcode{d}. @@ -9676,7 +9667,8 @@ \begin{itemdescr} \pnum -\requires \tcode{A} shall be an allocator\iref{allocator.requirements}. +\requires \tcode{A} shall satisfy the \tcode{Allocator} +requirements (\tref{utilities.allocator.requirements}). \pnum \effects Allocates memory for an object of type \tcode{T} @@ -9741,7 +9733,7 @@ suitable to hold an object of type \tcode{U} and \tcode{a2} of type \tcode{A2} is a rebound copy of the allocator \tcode{a} passed to \tcode{allocate_shared} - such that its \tcode{value_type} is \tcode{U}. + such that its \tcode{value_type} is \tcode{remove_cv_t}. \item When a (sub)object of non-array type \tcode{U} is specified to have a default initial value, @@ -9758,13 +9750,14 @@ suitable to hold an object of type \tcode{U} and \tcode{a2} of type \tcode{A2} is a rebound copy of the allocator \tcode{a} passed to \tcode{allocate_shared} - such that its \tcode{value_type} is \tcode{U}. + such that its \tcode{value_type} is \tcode{remove_cv_t}. \item Array elements are initialized in ascending order of their addresses. \item When the lifetime of the object managed by the return value ends, or when the initialization of an array element throws an exception, - the initialized elements should be destroyed in the reverse order of their construction. + the initialized elements are destroyed in the reverse order + of their original construction. \end{itemize} \begin{note} These functions will typically allocate more memory than \tcode{sizeof(T)} to @@ -11251,9 +11244,10 @@ \pnum \returns -A derived class shall implement this function to return a pointer to allocated storage\iref{basic.stc.dynamic.allocation} with a size of at least \tcode{bytes}. -The returned storage is aligned to the specified alignment, if such alignment is supported\iref{basic.align}; -otherwise it is aligned to \tcode{max_align}. +A derived class shall implement this function to +return a pointer to allocated storage\iref{basic.stc.dynamic.allocation} +with a size of at least \tcode{bytes}, +aligned to the specified \tcode{alignment}. \pnum \throws @@ -11325,7 +11319,7 @@ \pnum A specialization of class template \tcode{pmr::polymorphic_allocator} -conforms to the \tcode{Allocator} requirements\iref{allocator.requirements}. +satisfies the \tcode{Allocator} requirements (\tref{utilities.allocator.requirements}). Constructed with different memory resources, different instances of the same specialization of \tcode{pmr::polymorphic_allocator} can exhibit entirely different allocation behavior. @@ -11337,50 +11331,49 @@ \indexlibrarymember{value_type}{polymorphic_allocator}% \begin{codeblock} namespace std::pmr { - template - class polymorphic_allocator { - memory_resource* memory_rsrc; // \expos + template class polymorphic_allocator { + memory_resource* memory_rsrc; // \expos - public: - using value_type = Tp; + public: + using value_type = Tp; - // \ref{mem.poly.allocator.ctor}, constructors - polymorphic_allocator() noexcept; - polymorphic_allocator(memory_resource* r); + // \ref{mem.poly.allocator.ctor}, constructors + polymorphic_allocator() noexcept; + polymorphic_allocator(memory_resource* r); - polymorphic_allocator(const polymorphic_allocator& other) = default; + polymorphic_allocator(const polymorphic_allocator& other) = default; - template - polymorphic_allocator(const polymorphic_allocator& other) noexcept; + template + polymorphic_allocator(const polymorphic_allocator& other) noexcept; - polymorphic_allocator& operator=(const polymorphic_allocator& rhs) = delete; + polymorphic_allocator& operator=(const polymorphic_allocator& rhs) = delete; - // \ref{mem.poly.allocator.mem}, member functions - [[nodiscard]] Tp* allocate(size_t n); - void deallocate(Tp* p, size_t n); + // \ref{mem.poly.allocator.mem}, member functions + [[nodiscard]] Tp* allocate(size_t n); + void deallocate(Tp* p, size_t n); - template - void construct(T* p, Args&&... args); + template + void construct(T* p, Args&&... args); - template - void construct(pair* p, piecewise_construct_t, - tuple x, tuple y); - template - void construct(pair* p); - template - void construct(pair* p, U&& x, V&& y); - template - void construct(pair* p, const pair& pr); - template - void construct(pair* p, pair&& pr); + template + void construct(pair* p, piecewise_construct_t, + tuple x, tuple y); + template + void construct(pair* p); + template + void construct(pair* p, U&& x, V&& y); + template + void construct(pair* p, const pair& pr); + template + void construct(pair* p, pair&& pr); - template - void destroy(T* p); + template + void destroy(T* p); - polymorphic_allocator select_on_container_copy_construction() const; + polymorphic_allocator select_on_container_copy_construction() const; - memory_resource* resource() const; - }; + memory_resource* resource() const; + }; } \end{codeblock} @@ -11423,8 +11416,7 @@ \indexlibrary{\idxcode{polymorphic_allocator}!constructor}% \begin{itemdecl} -template - polymorphic_allocator(const polymorphic_allocator& other) noexcept; +template polymorphic_allocator(const polymorphic_allocator& other) noexcept; \end{itemdecl} \begin{itemdescr} @@ -11481,7 +11473,7 @@ \pnum \requires Uses-allocator construction of \tcode{T} -with allocator \tcode{resource()} (see~\ref{allocator.uses.construction}) +with allocator \tcode{*this} (see~\ref{allocator.uses.construction}) and constructor arguments \tcode{std::forward(args)...} is well-formed. \begin{note} Uses-allocator construction is always well-formed @@ -11491,12 +11483,17 @@ \effects Construct a \tcode{T} object in the storage whose address is represented by \tcode{p} -by uses-allocator construction with allocator \tcode{resource()} +by uses-allocator construction with allocator \tcode{*this} and constructor arguments \tcode{std::forward(args)...}. \pnum \throws Nothing unless the constructor for \tcode{T} throws. + +\pnum +\remarks +This function shall not participate in overload resolution if +\tcode{T} is a specialization of \tcode{pair}. \end{itemdescr} \indexlibrarymember{construct}{polymorphic_allocator}% @@ -11521,32 +11518,32 @@ constructing a \tcode{pair} object in the storage whose address is represented by \tcode{p}, as if by separate uses-allocator construction -with allocator \tcode{resource()}\iref{allocator.uses.construction} +with allocator \tcode{*this}\iref{allocator.uses.construction} of \tcode{p->first} using the elements of \tcode{x} and \tcode{p->second} using the elements of \tcode{y}. \end{note} \begin{itemize} \item -If \tcode{uses_allocator_v} is \tcode{false} +If \tcode{uses_allocator_v} is \tcode{false} \\ and \tcode{is_constructible_v} is \tcode{true}, \\ then \tcode{xprime} is \tcode{x}. \item -Otherwise, if \tcode{uses_allocator_v} is \tcode{true} +Otherwise, if \tcode{uses_allocator_v} is \tcode{true} \\ and -\tcode{is_constructible_v} is \tcode{true}, +\tcode{is_constructible_v} is \tcode{true}, \\ -then \tcode{xprime} is \tcode{tuple_cat(make_tuple(allocator_arg, resource()), std::move(x))}. +then \tcode{xprime} is \tcode{tuple_cat(make_tuple(allocator_arg, *this), std::move(x))}. \item -Otherwise, if \tcode{uses_allocator_v} is \tcode{true} +Otherwise, if \tcode{uses_allocator_v} is \tcode{true} \\ and -\tcode{is_constructible_v} is \tcode{true}, +\tcode{is_constructible_v} is \tcode{true}, \\ -then \tcode{xprime} is \tcode{tuple_cat(std::move(x), make_tuple(resource()))}. +then \tcode{xprime} is \tcode{tuple_cat(std::move(x), make_tuple(*this))}. \item Otherwise the program is ill formed. \end{itemize} @@ -11554,27 +11551,27 @@ according to the appropriate rule from the following list: \begin{itemize} \item -If \tcode{uses_allocator_v} is \tcode{false} +If \tcode{uses_allocator_v} is \tcode{false} \\ and \tcode{is_constructible_v} is \tcode{true}, \\ then \tcode{yprime} is \tcode{y}. \item -Otherwise, if \tcode{uses_allocator_v} is \tcode{true} +Otherwise, if \tcode{uses_allocator_v} is \tcode{true} \\ and -\tcode{is_constructible_v} is \tcode{true}, +\tcode{is_constructible_v} is \tcode{true}, \\ -then \tcode{yprime} is \tcode{tuple_cat(make_tuple(allocator_arg, resource()), std::move(y))}. +then \tcode{yprime} is \tcode{tuple_cat(make_tuple(allocator_arg, *this), std::move(y))}. \item -Otherwise, if \tcode{uses_allocator_v} is \tcode{true} +Otherwise, if \tcode{uses_allocator_v} is \tcode{true} \\ and -\tcode{is_constructible_v} is \tcode{true}, +\tcode{is_constructible_v} is \tcode{true}, \\ then -\tcode{yprime} is \tcode{tuple_cat(std::move(y), make_tuple(resource()))}. +\tcode{yprime} is \tcode{tuple_cat(std::move(y), make_tuple(*this))}. \item Otherwise the program is ill formed. \end{itemize} @@ -12061,7 +12058,7 @@ A pointer to allocated storage\iref{basic.stc.dynamic.allocation} with a size of at least \tcode{bytes}. The size and alignment of the allocated memory shall meet the requirements -for a class derived from \tcode{memory_resource}\iref{mem.res}. +for a class derived from \tcode{memory_resource}\iref{mem.res.class}. \pnum \effects @@ -12095,27 +12092,15 @@ \end{itemdescr} \indexlibrarymember{do_is_equal}{synchronized_pool_resource}% -\begin{itemdecl} -bool synchronized_pool_resource::do_is_equal( - const memory_resource& other) const noexcept override; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{this == dynamic_cast(\&other)}. -\end{itemdescr} - \indexlibrarymember{do_is_equal}{unsynchronized_pool_resource}% \begin{itemdecl} -bool unsynchronized_pool_resource::do_is_equal( - const memory_resource& other) const noexcept override; +bool do_is_equal(const memory_resource& other) const noexcept override; \end{itemdecl} \begin{itemdescr} \pnum \returns -\tcode{this == dynamic_cast(\&other)}. +\tcode{this == \&other}. \end{itemdescr} \rSec2[mem.res.monotonic.buffer]{Class \tcode{monotonic_buffer_resource}} @@ -12285,7 +12270,7 @@ A pointer to allocated storage\iref{basic.stc.dynamic.allocation} with a size of at least \tcode{bytes}. The size and alignment of the allocated memory shall meet the requirements -for a class derived from \tcode{memory_resource}\iref{mem.res}. +for a class derived from \tcode{memory_resource}\iref{mem.res.class}. \pnum \effects @@ -12331,7 +12316,7 @@ \begin{itemdescr} \pnum \returns -\tcode{this == dynamic_cast(\&other)}. +\tcode{this == \&other}. \end{itemdescr} @@ -12387,7 +12372,7 @@ \begin{codeblock} namespace std { template - class scoped_allocator_adaptor : public OuterAlloc { + class scoped_allocator_adaptor : public OuterAlloc { private: using OuterTraits = allocator_traits; // \expos scoped_allocator_adaptor inner; // \expos @@ -12409,11 +12394,10 @@ using propagate_on_container_swap = @\seebelow@; using is_always_equal = @\seebelow@; - template - struct rebind { - using other = scoped_allocator_adaptor< - OuterTraits::template rebind_alloc, InnerAllocs...>; - }; + template struct rebind { + using other = scoped_allocator_adaptor< + OuterTraits::template rebind_alloc, InnerAllocs...>; + }; scoped_allocator_adaptor(); template @@ -12750,6 +12734,11 @@ contained element. \end{note} \end{itemize} + +\pnum +\remarks +This function shall not participate in overload resolution if +\tcode{T} is a specialization of \tcode{pair}. \end{itemdescr} \indexlibrarymember{construct}{scoped_allocator_adaptor}% @@ -12761,7 +12750,7 @@ \begin{itemdescr} \pnum \requires All of the types in \tcode{Args1} and \tcode{Args2} shall be -\tcode{CopyConstructible} (Table~\ref{tab:copyconstructible}). +\tcode{CopyConstructible} (\tref{copyconstructible}). \pnum \effects Constructs a \tcode{tuple} object \tcode{xprime} from \tcode{x} by the @@ -13281,7 +13270,7 @@ \end{codeblock} This constructor shall not participate in overload resolution unless the expression \tcode{\placeholdernc{FUN}(declval())} is well-formed and -\tcode{is_same_v, reference_wrapper>} is \tcode{false}. +\tcode{is_same_v, reference_wrapper>} is \tcode{false}. The expression inside \tcode{noexcept} is equivalent to \tcode{noexcept(\placeholdernc{FUN}(declval()))}. @@ -14202,7 +14191,7 @@ \begin{itemdescr} \pnum \requires -\tcode{FD} shall satisfy the requirements of \tcode{MoveConstructible}. +\tcode{FD} shall satisfy the \tcode{MoveConstructible} requirements. \tcode{is_constructible_v} shall be \tcode{true}. \tcode{fd} shall be a callable object\iref{func.def}. @@ -14273,7 +14262,7 @@ uses \tcode{is_bind_expression} to detect subexpressions. \pnum -Instantiations of the \tcode{is_bind_expression} template shall meet +Instantiations of the \tcode{is_bind_expression} template shall satisfy the \tcode{UnaryTypeTrait} requirements\iref{meta.rqmts}. The implementation shall provide a definition that has a base characteristic of \tcode{true_type} if \tcode{T} is a type returned from \tcode{bind}, @@ -14297,7 +14286,7 @@ \tcode{is_placeholder} to detect placeholders. \pnum -Instantiations of the \tcode{is_placeholder} template shall meet +Instantiations of the \tcode{is_placeholder} template shall satisfy the \tcode{UnaryTypeTrait} requirements\iref{meta.rqmts}. The implementation shall provide a definition that has the base characteristic of \tcode{integral_constant} if \tcode{T} is the type of @@ -14362,9 +14351,9 @@ \tcode{fd} or of one of the values $\tcode{td}_i$ throws an exception. \pnum -\remarks The return type shall satisfy the requirements of \tcode{MoveConstructible}. If all -of \tcode{FD} and $\tcode{TD}_i$ satisfy the requirements of \tcode{CopyConstructible}, then the -return type shall satisfy the requirements of \tcode{CopyConstructible}. \begin{note} This implies +\remarks The return type shall satisfy the \tcode{MoveConstructible} requirements. If all +of \tcode{FD} and $\tcode{TD}_i$ satisfy the \tcode{CopyConstructible} requirements, then the +return type shall satisfy the \tcode{CopyConstructible} requirements. \begin{note} This implies that all of \tcode{FD} and $\tcode{TD}_i$ are \tcode{MoveConstructible}. \end{note} \end{itemdescr} @@ -14405,9 +14394,9 @@ \tcode{fd} or of one of the values $\tcode{td}_i$ throws an exception. \pnum -\remarks The return type shall satisfy the requirements of \tcode{MoveConstructible}. If all -of \tcode{FD} and $\tcode{TD}_i$ satisfy the requirements of \tcode{CopyConstructible}, then the -return type shall satisfy the requirements of \tcode{CopyConstructible}. \begin{note} This implies +\remarks The return type shall satisfy the \tcode{MoveConstructible} requirements. If all +of \tcode{FD} and $\tcode{TD}_i$ satisfy the \tcode{CopyConstructible} requirements, then the +return type shall satisfy the \tcode{CopyConstructible} requirements. \begin{note} This implies that all of \tcode{FD} and $\tcode{TD}_i$ are \tcode{MoveConstructible}. \end{note} \end{itemdescr} @@ -14944,7 +14933,7 @@ provided to the function call operator. \pnum -Each specialization of a class template specified in this subclause \ref{func.search} shall meet the \tcode{CopyConstructible} and \tcode{CopyAssignable} requirements. +Each specialization of a class template specified in this subclause \ref{func.search} shall satisfy the \tcode{CopyConstructible} and \tcode{CopyAssignable} requirements. Template parameters named \begin{itemize} \item \tcode{ForwardIterator}, @@ -14956,9 +14945,10 @@ \item \tcode{BinaryPredicate} \end{itemize} of templates specified in this subclause -\ref{func.search} shall meet the same requirements and semantics as +\ref{func.search} shall satisfy the same requirements and semantics as specified in \ref{algorithms.general}. -Template parameters named \tcode{Hash} shall meet the requirements as specified in \ref{hash.requirements}. +Template parameters named \tcode{Hash} shall satisfy the \tcode{Hash} +requirements (\tref{hash}). \pnum The Boyer-Moore searcher implements the Boyer-Moore search algorithm. @@ -15061,7 +15051,7 @@ \begin{itemdescr} \pnum \requires -The value type of \tcode{RandomAccessIterator1} shall meet the \tcode{DefaultConstructible} requirements, +The value type of \tcode{RandomAccessIterator1} shall satisfy the \tcode{DefaultConstructible} requirements, the \tcode{CopyConstructible} requirements, and the \tcode{CopyAssignable} requirements. \pnum @@ -15154,7 +15144,7 @@ \begin{itemdescr} \pnum \requires -The value type of \tcode{RandomAccessIterator1} shall meet the \tcode{DefaultConstructible}, +The value type of \tcode{RandomAccessIterator1} shall satisfy the \tcode{DefaultConstructible}, \tcode{Copy\-Constructible}, and \tcode{CopyAssignable} requirements. \pnum @@ -15223,7 +15213,7 @@ Each specialization of \tcode{hash} is either enabled or disabled, as described below. \begin{note} -Enabled specializations meet the requirements of \tcode{Hash}, and +Enabled specializations meet the \tcode{Hash} requirements, and disabled specializations do not. \end{note} Each header that declares the template \tcode{hash} @@ -15256,10 +15246,10 @@ \pnum An enabled specialization \tcode{hash} will: \begin{itemize} -\item satisfy the \tcode{Hash} requirements\iref{hash.requirements}, +\item satisfy the \tcode{Hash} requirements (\tref{hash}), with \tcode{Key} as the function -call argument type, the \tcode{Default\-Constructible} requirements (Table~\ref{tab:defaultconstructible}), -the \tcode{CopyAssignable} requirements (Table~\ref{tab:copyassignable}), +call argument type, the \tcode{Default\-Constructible} requirements (\tref{defaultconstructible}), +the \tcode{CopyAssignable} requirements (\tref{copyassignable}), \item be swappable\iref{swappable.requirements} for lvalues, \item satisfy the requirement that if \tcode{k1 == k2} is \tcode{true}, \tcode{h(k1) == h(k2)} is also \tcode{true}, where \tcode{h} is an object of type \tcode{hash} and \tcode{k1} and \tcode{k2} @@ -15977,7 +15967,7 @@ \tcode{template}\br \tcode{struct is_empty;} & \tcode{T} is a class type, but not a union type, with no non-static data - members other than bit-fields of length 0, no virtual member functions, + members other than subobjects of zero size, no virtual member functions, no virtual base classes, and no base class \tcode{B} for which \tcode{is_empty_v} is \tcode{false}. & If \tcode{T} is a non-union class type, \tcode{T} shall be a complete type. \\ \rowsep @@ -16854,7 +16844,7 @@ The value of \textit{default-alignment} shall be the most stringent alignment requirement for any \Cpp{} object type whose size is no greater than \tcode{Len}\iref{basic.types}. - The member typedef \tcode{type} shall be a trivial type + The member typedef \tcode{type} shall be a trivial standard-layout type suitable for use as uninitialized storage for any object whose size is at most \tcode{Len} and whose alignment is a divisor of \tcode{Align}.\br \requires{} \tcode{Len} shall not be zero. \tcode{Align} shall be equal to @@ -16865,7 +16855,7 @@ class... Types>\br struct aligned_union;} & - The member typedef \tcode{type} shall be a trivial type suitable for use as + The member typedef \tcode{type} shall be a trivial standard-layout type suitable for use as uninitialized storage for any object whose type is listed in \tcode{Types}; its size shall be at least \tcode{Len}. The static member \tcode{alignment_value} shall be an integral constant of type \tcode{size_t} whose value is the @@ -17328,7 +17318,7 @@ Each of the alias templates \tcode{ratio_add}, \tcode{ratio_subtract}, \tcode{ratio_multiply}, and \tcode{ratio_divide} denotes the result of an arithmetic computation on two \tcode{ratio}{s} \tcode{R1} and \tcode{R2}. With \tcode{X} and \tcode{Y} computed (in the -absence of arithmetic overflow) as specified by Table~\ref{tab:ratio.arithmetic}, each alias +absence of arithmetic overflow) as specified by \tref{ratio.arithmetic}, each alias denotes a \tcode{ratio} such that \tcode{U} is the same as \tcode{ratio::num} and \tcode{V} is the same as \tcode{ratio::den}. @@ -17460,6 +17450,35 @@ \rSec2[time.syn]{Header \tcode{} synopsis} \indexhdr{chrono}% +\indexlibrary{\idxcode{treat_as_floating_point_v}}% +\indexlibrary{\idxcode{is_clock_v}}% +\indexlibrary{\idxcode{nanoseconds}}% +\indexlibrary{\idxcode{microseconds}}% +\indexlibrary{\idxcode{milliseconds}}% +\indexlibrary{\idxcode{seconds}}% +\indexlibrary{\idxcode{minutes}}% +\indexlibrary{\idxcode{hours}}% +\indexlibrary{\idxcode{days}}% +\indexlibrary{\idxcode{weeks}}% +\indexlibrary{\idxcode{years}}% +\indexlibrary{\idxcode{months}}% +\indexlibrary{\idxcode{sys_time}}% +\indexlibrary{\idxcode{sys_seconds}}% +\indexlibrary{\idxcode{sys_days}}% +\indexlibrary{\idxcode{utc_time}}% +\indexlibrary{\idxcode{utc_seconds}}% +\indexlibrary{\idxcode{tai_time}}% +\indexlibrary{\idxcode{tai_seconds}}% +\indexlibrary{\idxcode{gps_time}}% +\indexlibrary{\idxcode{gps_seconds}}% +\indexlibrary{\idxcode{file_time}}% +\indexlibrary{\idxcode{local_time}}% +\indexlibrary{\idxcode{local_seconds}}% +\indexlibrary{\idxcode{local_days}}% +\indexlibrary{\idxcode{local_t}}% +\indexlibrary{\idxcode{choose}}% +\indexlibrarymember{earliest}{choose}% +\indexlibrarymember{latest}{choose}% \begin{codeblock} namespace std { namespace chrono { @@ -17486,6 +17505,9 @@ template inline constexpr bool treat_as_floating_point_v = treat_as_floating_point::value; + template struct is_clock; + template inline constexpr bool is_clock_v = is_clock::value; + // \ref{time.duration.nonmember}, \tcode{duration} arithmetic template constexpr common_type_t, duration> @@ -17542,6 +17564,22 @@ template constexpr ToDuration round(const duration& d); + // \ref{time.duration.io}, \tcode{duration} I/O + template + basic_ostream& + operator<<(basic_ostream& os, + const duration& d); + template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, + const duration& d); + template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + duration& d, + basic_string* abbrev = nullptr, + minutes* offset = nullptr); + // convenience typedefs using nanoseconds = duration<@\term{signed integer type of at least 64 bits}@, nano>; using microseconds = duration<@\term{signed integer type of at least 55 bits}@, micro>; @@ -17549,6 +17587,14 @@ using seconds = duration<@\term{signed integer type of at least 35 bits}@>; using minutes = duration<@\term{signed integer type of at least 29 bits}@, ratio< 60>>; using hours = duration<@\term{signed integer type of at least 23 bits}@, ratio<3600>>; + using days = duration<@\term{signed integer type of at least 25 bits}@, + ratio_multiply, hours::period>>; + using weeks = duration<@\term{signed integer type of at least 22 bits}@, + ratio_multiply, days::period>>; + using years = duration<@\term{signed integer type of at least 17 bits}@, + ratio_multiply, days::period>>; + using months = duration<@\term{signed integer type of at least 20 bits}@, + ratio_divide>>; // \ref{time.point.nonmember}, \tcode{time_point} arithmetic template @@ -17600,27 +17646,790 @@ template constexpr duration abs(duration d); - // \ref{time.clock}, clocks + // \ref{time.clock.system}, class \tcode{system_clock} class system_clock; + + template + using sys_time = time_point; + using sys_seconds = sys_time; + using sys_days = sys_time; + + template + basic_ostream& + operator<<(basic_ostream& os, const sys_time& tp); + + template + basic_ostream& + operator<<(basic_ostream& os, const sys_days& dp); + + template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, + const sys_time& tp); + + template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + sys_time& tp, + basic_string* abbrev = nullptr, + minutes* offset = nullptr); + + // \ref{time.clock.utc}, class \tcode{utc_clock} + class utc_clock; + + template + using utc_time = time_point; + using utc_seconds = utc_time; + + template + basic_ostream& + operator<<(basic_ostream& os, const utc_time& t); + template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, + const utc_time& tp); + template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + utc_time& tp, + basic_string* abbrev = nullptr, + minutes* offset = nullptr); + + // \ref{time.clock.tai}, class \tcode{tai_clock} + class tai_clock; + + template + using tai_time = time_point; + using tai_seconds = tai_time; + + template + basic_ostream& + operator<<(basic_ostream& os, const tai_time& t); + template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, + const tai_time& tp); + template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + tai_time& tp, + basic_string* abbrev = nullptr, + minutes* offset = nullptr); + + // \ref{time.clock.gps}, class \tcode{gps_clock} + class gps_clock; + + template + using gps_time = time_point; + using gps_seconds = gps_time; + + template + basic_ostream& + operator<<(basic_ostream& os, const gps_time& t); + template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, + const gps_time& tp); + template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + gps_time& tp, + basic_string* abbrev = nullptr, + minutes* offset = nullptr); + + // \ref{time.clock.file}, class \tcode{file_clock} + class file_clock; + + template + using file_time = time_point; + + template + basic_ostream& + operator<<(basic_ostream& os, const file_time& tp); + template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, + const file_time& tp); + template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + file_time& tp, + basic_string* abbrev = nullptr, + minutes* offset = nullptr); + + // \ref{time.clock.steady}, class \tcode{steady_clock} class steady_clock; + + // \ref{time.clock.hires}, class \tcode{high_resolution_clock} class high_resolution_clock; + + // \ref{time.clock.local}, local time + struct local_t {}; + template + using local_time = time_point; + using local_seconds = local_time; + using local_days = local_time; + + template + basic_ostream& + operator<<(basic_ostream& os, const local_time& tp); + template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, + const local_time& tp, + const string* abbrev = nullptr, const seconds* offset_sec = nullptr); + template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + local_time& tp, + basic_string* abbrev = nullptr, + minutes* offset = nullptr); + + // \ref{time.clock.cast}, \tcode{time_point} conversions + template + struct clock_time_conversion; + + template + auto clock_cast(const time_point& t); + + // \ref{time.cal.last}, class \tcode{last_spec} + struct last_spec; + + // \ref{time.cal.day}, class \tcode{day} + class day; + + constexpr bool operator==(const day& x, const day& y) noexcept; + constexpr bool operator!=(const day& x, const day& y) noexcept; + constexpr bool operator< (const day& x, const day& y) noexcept; + constexpr bool operator> (const day& x, const day& y) noexcept; + constexpr bool operator<=(const day& x, const day& y) noexcept; + constexpr bool operator>=(const day& x, const day& y) noexcept; + + constexpr day operator+(const day& x, const days& y) noexcept; + constexpr day operator+(const days& x, const day& y) noexcept; + constexpr day operator-(const day& x, const days& y) noexcept; + constexpr days operator-(const day& x, const day& y) noexcept; + + template + basic_ostream& + operator<<(basic_ostream& os, const day& d); + template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, const day& d); + template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + day& d, basic_string* abbrev = nullptr, + minutes* offset = nullptr); + + // \ref{time.cal.month}, class \tcode{month} + class month; + + constexpr bool operator==(const month& x, const month& y) noexcept; + constexpr bool operator!=(const month& x, const month& y) noexcept; + constexpr bool operator< (const month& x, const month& y) noexcept; + constexpr bool operator> (const month& x, const month& y) noexcept; + constexpr bool operator<=(const month& x, const month& y) noexcept; + constexpr bool operator>=(const month& x, const month& y) noexcept; + + constexpr month operator+(const month& x, const months& y) noexcept; + constexpr month operator+(const months& x, const month& y) noexcept; + constexpr month operator-(const month& x, const months& y) noexcept; + constexpr months operator-(const month& x, const month& y) noexcept; + + template + basic_ostream& + operator<<(basic_ostream& os, const month& m); + template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, const month& m); + template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + month& m, basic_string* abbrev = nullptr, + minutes* offset = nullptr); + + // \ref{time.cal.year}, class \tcode{year} + class year; + + constexpr bool operator==(const year& x, const year& y) noexcept; + constexpr bool operator!=(const year& x, const year& y) noexcept; + constexpr bool operator< (const year& x, const year& y) noexcept; + constexpr bool operator> (const year& x, const year& y) noexcept; + constexpr bool operator<=(const year& x, const year& y) noexcept; + constexpr bool operator>=(const year& x, const year& y) noexcept; + + constexpr year operator+(const year& x, const years& y) noexcept; + constexpr year operator+(const years& x, const year& y) noexcept; + constexpr year operator-(const year& x, const years& y) noexcept; + constexpr years operator-(const year& x, const year& y) noexcept; + + template + basic_ostream& + operator<<(basic_ostream& os, const year& y); + + template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, const year& y); + + template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + year& y, basic_string* abbrev = nullptr, + minutes* offset = nullptr); + + // \ref{time.cal.wd}, class \tcode{weekday} + class weekday; + + constexpr bool operator==(const weekday& x, const weekday& y) noexcept; + constexpr bool operator!=(const weekday& x, const weekday& y) noexcept; + + constexpr weekday operator+(const weekday& x, const days& y) noexcept; + constexpr weekday operator+(const days& x, const weekday& y) noexcept; + constexpr weekday operator-(const weekday& x, const days& y) noexcept; + constexpr days operator-(const weekday& x, const weekday& y) noexcept; + + template + basic_ostream& + operator<<(basic_ostream& os, const weekday& wd); + + template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, const weekday& wd); + + template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + weekday& wd, basic_string* abbrev = nullptr, + minutes* offset = nullptr); + + // \ref{time.cal.wdidx}, class \tcode{weekday_indexed} + class weekday_indexed; + + constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept; + constexpr bool operator!=(const weekday_indexed& x, const weekday_indexed& y) noexcept; + + template + basic_ostream& + operator<<(basic_ostream& os, const weekday_indexed& wdi); + + // \ref{time.cal.wdlast}, class \tcode{weekday_last} + class weekday_last; + + constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept; + constexpr bool operator!=(const weekday_last& x, const weekday_last& y) noexcept; + + template + basic_ostream& + operator<<(basic_ostream& os, const weekday_last& wdl); + + // \ref{time.cal.md}, class \tcode{month_day} + class month_day; + + constexpr bool operator==(const month_day& x, const month_day& y) noexcept; + constexpr bool operator!=(const month_day& x, const month_day& y) noexcept; + constexpr bool operator< (const month_day& x, const month_day& y) noexcept; + constexpr bool operator> (const month_day& x, const month_day& y) noexcept; + constexpr bool operator<=(const month_day& x, const month_day& y) noexcept; + constexpr bool operator>=(const month_day& x, const month_day& y) noexcept; + + template + basic_ostream& + operator<<(basic_ostream& os, const month_day& md); + + template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, const month_day& md); + + template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + month_day& md, basic_string* abbrev = nullptr, + minutes* offset = nullptr); + + // \ref{time.cal.mdlast}, class \tcode{month_day_last} + class month_day_last; + + constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept; + constexpr bool operator!=(const month_day_last& x, const month_day_last& y) noexcept; + constexpr bool operator< (const month_day_last& x, const month_day_last& y) noexcept; + constexpr bool operator> (const month_day_last& x, const month_day_last& y) noexcept; + constexpr bool operator<=(const month_day_last& x, const month_day_last& y) noexcept; + constexpr bool operator>=(const month_day_last& x, const month_day_last& y) noexcept; + + template + basic_ostream& + operator<<(basic_ostream& os, const month_day_last& mdl); + + // \ref{time.cal.mwd}, class \tcode{month_weekday} + class month_weekday; + + constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept; + constexpr bool operator!=(const month_weekday& x, const month_weekday& y) noexcept; + + template + basic_ostream& + operator<<(basic_ostream& os, const month_weekday& mwd); + + // \ref{time.cal.mwdlast}, class \tcode{month_weekday_last} + class month_weekday_last; + + constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept; + constexpr bool operator!=(const month_weekday_last& x, const month_weekday_last& y) noexcept; + + template + basic_ostream& + operator<<(basic_ostream& os, const month_weekday_last& mwdl); + + // \ref{time.cal.ym}, class \tcode{year_month} + class year_month; + + constexpr bool operator==(const year_month& x, const year_month& y) noexcept; + constexpr bool operator!=(const year_month& x, const year_month& y) noexcept; + constexpr bool operator< (const year_month& x, const year_month& y) noexcept; + constexpr bool operator> (const year_month& x, const year_month& y) noexcept; + constexpr bool operator<=(const year_month& x, const year_month& y) noexcept; + constexpr bool operator>=(const year_month& x, const year_month& y) noexcept; + + constexpr year_month operator+(const year_month& ym, const months& dm) noexcept; + constexpr year_month operator+(const months& dm, const year_month& ym) noexcept; + constexpr year_month operator-(const year_month& ym, const months& dm) noexcept; + constexpr months operator-(const year_month& x, const year_month& y) noexcept; + constexpr year_month operator+(const year_month& ym, const years& dy) noexcept; + constexpr year_month operator+(const years& dy, const year_month& ym) noexcept; + constexpr year_month operator-(const year_month& ym, const years& dy) noexcept; + + template + basic_ostream& + operator<<(basic_ostream& os, const year_month& ym); + + template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, const year_month& ym); + + template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + year_month& ym, basic_string* abbrev = nullptr, + minutes* offset = nullptr); + + // \ref{time.cal.ymd}, class \tcode{year_month_day} + class year_month_day; + + constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept; + constexpr bool operator!=(const year_month_day& x, const year_month_day& y) noexcept; + constexpr bool operator< (const year_month_day& x, const year_month_day& y) noexcept; + constexpr bool operator> (const year_month_day& x, const year_month_day& y) noexcept; + constexpr bool operator<=(const year_month_day& x, const year_month_day& y) noexcept; + constexpr bool operator>=(const year_month_day& x, const year_month_day& y) noexcept; + + constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept; + constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept; + constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept; + constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept; + constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept; + constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept; + + template + basic_ostream& + operator<<(basic_ostream& os, const year_month_day& ymd); + + template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, + const year_month_day& ymd); + + template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + year_month_day& ymd, + basic_string* abbrev = nullptr, + minutes* offset = nullptr); + + // \ref{time.cal.ymdlast}, class \tcode{year_month_day_last} + class year_month_day_last; + + constexpr bool operator==(const year_month_day_last& x, + const year_month_day_last& y) noexcept; + constexpr bool operator!=(const year_month_day_last& x, + const year_month_day_last& y) noexcept; + constexpr bool operator< (const year_month_day_last& x, + const year_month_day_last& y) noexcept; + constexpr bool operator> (const year_month_day_last& x, + const year_month_day_last& y) noexcept; + constexpr bool operator<=(const year_month_day_last& x, + const year_month_day_last& y) noexcept; + constexpr bool operator>=(const year_month_day_last& x, + const year_month_day_last& y) noexcept; + + constexpr year_month_day_last + operator+(const year_month_day_last& ymdl, const months& dm) noexcept; + constexpr year_month_day_last + operator+(const months& dm, const year_month_day_last& ymdl) noexcept; + constexpr year_month_day_last + operator+(const year_month_day_last& ymdl, const years& dy) noexcept; + constexpr year_month_day_last + operator+(const years& dy, const year_month_day_last& ymdl) noexcept; + constexpr year_month_day_last + operator-(const year_month_day_last& ymdl, const months& dm) noexcept; + constexpr year_month_day_last + operator-(const year_month_day_last& ymdl, const years& dy) noexcept; + + template + basic_ostream& + operator<<(basic_ostream& os, const year_month_day_last& ymdl); + + // \ref{time.cal.ymwd}, class \tcode{year_month_weekday} + class year_month_weekday; + + constexpr bool operator==(const year_month_weekday& x, + const year_month_weekday& y) noexcept; + constexpr bool operator!=(const year_month_weekday& x, + const year_month_weekday& y) noexcept; + + constexpr year_month_weekday + operator+(const year_month_weekday& ymwd, const months& dm) noexcept; + constexpr year_month_weekday + operator+(const months& dm, const year_month_weekday& ymwd) noexcept; + constexpr year_month_weekday + operator+(const year_month_weekday& ymwd, const years& dy) noexcept; + constexpr year_month_weekday + operator+(const years& dy, const year_month_weekday& ymwd) noexcept; + constexpr year_month_weekday + operator-(const year_month_weekday& ymwd, const months& dm) noexcept; + constexpr year_month_weekday + operator-(const year_month_weekday& ymwd, const years& dy) noexcept; + + template + basic_ostream& + operator<<(basic_ostream& os, const year_month_weekday& ymwdi); + + // \ref{time.cal.ymwdlast}, class \tcode{year_month_weekday_last} + class year_month_weekday_last; + + constexpr bool operator==(const year_month_weekday_last& x, + const year_month_weekday_last& y) noexcept; + constexpr bool operator!=(const year_month_weekday_last& x, + const year_month_weekday_last& y) noexcept; + + constexpr year_month_weekday_last + operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept; + constexpr year_month_weekday_last + operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept; + constexpr year_month_weekday_last + operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept; + constexpr year_month_weekday_last + operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept; + constexpr year_month_weekday_last + operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept; + constexpr year_month_weekday_last + operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept; + + template + basic_ostream& + operator<<(basic_ostream& os, const year_month_weekday_last& ymwdl); + + // \ref{time.cal.operators}, civil calendar conventional syntax operators + constexpr year_month + operator/(const year& y, const month& m) noexcept; + constexpr year_month + operator/(const year& y, int m) noexcept; + constexpr month_day + operator/(const month& m, const day& d) noexcept; + constexpr month_day + operator/(const month& m, int d) noexcept; + constexpr month_day + operator/(int m, const day& d) noexcept; + constexpr month_day + operator/(const day& d, const month& m) noexcept; + constexpr month_day + operator/(const day& d, int m) noexcept; + constexpr month_day_last + operator/(const month& m, last_spec) noexcept; + constexpr month_day_last + operator/(int m, last_spec) noexcept; + constexpr month_day_last + operator/(last_spec, const month& m) noexcept; + constexpr month_day_last + operator/(last_spec, int m) noexcept; + constexpr month_weekday + operator/(const month& m, const weekday_indexed& wdi) noexcept; + constexpr month_weekday + operator/(int m, const weekday_indexed& wdi) noexcept; + constexpr month_weekday + operator/(const weekday_indexed& wdi, const month& m) noexcept; + constexpr month_weekday + operator/(const weekday_indexed& wdi, int m) noexcept; + constexpr month_weekday_last + operator/(const month& m, const weekday_last& wdl) noexcept; + constexpr month_weekday_last + operator/(int m, const weekday_last& wdl) noexcept; + constexpr month_weekday_last + operator/(const weekday_last& wdl, const month& m) noexcept; + constexpr month_weekday_last + operator/(const weekday_last& wdl, int m) noexcept; + constexpr year_month_day + operator/(const year_month& ym, const day& d) noexcept; + constexpr year_month_day + operator/(const year_month& ym, int d) noexcept; + constexpr year_month_day + operator/(const year& y, const month_day& md) noexcept; + constexpr year_month_day + operator/(int y, const month_day& md) noexcept; + constexpr year_month_day + operator/(const month_day& md, const year& y) noexcept; + constexpr year_month_day + operator/(const month_day& md, int y) noexcept; + constexpr year_month_day_last + operator/(const year_month& ym, last_spec) noexcept; + constexpr year_month_day_last + operator/(const year& y, const month_day_last& mdl) noexcept; + constexpr year_month_day_last + operator/(int y, const month_day_last& mdl) noexcept; + constexpr year_month_day_last + operator/(const month_day_last& mdl, const year& y) noexcept; + constexpr year_month_day_last + operator/(const month_day_last& mdl, int y) noexcept; + constexpr year_month_weekday + operator/(const year_month& ym, const weekday_indexed& wdi) noexcept; + constexpr year_month_weekday + operator/(const year& y, const month_weekday& mwd) noexcept; + constexpr year_month_weekday + operator/(int y, const month_weekday& mwd) noexcept; + constexpr year_month_weekday + operator/(const month_weekday& mwd, const year& y) noexcept; + constexpr year_month_weekday + operator/(const month_weekday& mwd, int y) noexcept; + constexpr year_month_weekday_last + operator/(const year_month& ym, const weekday_last& wdl) noexcept; + constexpr year_month_weekday_last + operator/(const year& y, const month_weekday_last& mwdl) noexcept; + constexpr year_month_weekday_last + operator/(int y, const month_weekday_last& mwdl) noexcept; + constexpr year_month_weekday_last + operator/(const month_weekday_last& mwdl, const year& y) noexcept; + constexpr year_month_weekday_last + operator/(const month_weekday_last& mwdl, int y) noexcept; + + // \ref{time.tod}, class template \tcode{time_of_day} + template class time_of_day; + template<> class time_of_day; + template<> class time_of_day; + template<> class time_of_day; + template class time_of_day>; + + template + basic_ostream& + operator<<(basic_ostream& os, const time_of_day& t); + + template + basic_ostream& + operator<<(basic_ostream& os, const time_of_day& t); + + template + basic_ostream& + operator<<(basic_ostream& os, const time_of_day& t); + + template + basic_ostream& + operator<<(basic_ostream& os, + const time_of_day>& t); + + // \ref{time.zone.db}, time zone database + struct tzdb; + class tzdb_list; + + // \ref{time.zone.db.access}, time zone database access + const tzdb& get_tzdb(); + tzdb_list& get_tzdb_list(); + const time_zone* locate_zone(string_view tz_name); + const time_zone* current_zone(); + + // \ref{time.zone.db.remote}, remote time zone database support + const tzdb& reload_tzdb(); + string remote_version(); + + // \ref{time.zone.exception}, exception classes + class nonexistent_local_time; + class ambiguous_local_time; + + // \ref{time.zone.info}, information classes + struct sys_info; + template + basic_ostream& + operator<<(basic_ostream& os, const sys_info& si); + + struct local_info; + template + basic_ostream& + operator<<(basic_ostream& os, const local_info& li); + + // \ref{time.zone.timezone}, class \tcode{time_zone} + enum class choose {earliest, latest}; + class time_zone; + + bool operator==(const time_zone& x, const time_zone& y) noexcept; + bool operator!=(const time_zone& x, const time_zone& y) noexcept; + + bool operator<(const time_zone& x, const time_zone& y) noexcept; + bool operator>(const time_zone& x, const time_zone& y) noexcept; + bool operator<=(const time_zone& x, const time_zone& y) noexcept; + bool operator>=(const time_zone& x, const time_zone& y) noexcept; + + // \ref{time.zone.zonedtraits}, class template \tcode{zoned_traits} + template struct zoned_traits; + + // \ref{time.zone.zonedtime}, class template \tcode{zoned_time} + template class zoned_time; + + using zoned_seconds = zoned_time; + + template + bool operator==(const zoned_time& x, + const zoned_time& y); + + template + bool operator!=(const zoned_time& x, + const zoned_time& y); + + template + basic_ostream& + operator<<(basic_ostream& os, + const zoned_time& t); + + template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, + const zoned_time& tp); + + // \ref{time.zone.leap}, leap second support + class leap; + + bool operator==(const leap& x, const leap& y); + bool operator!=(const leap& x, const leap& y); + bool operator< (const leap& x, const leap& y); + bool operator> (const leap& x, const leap& y); + bool operator<=(const leap& x, const leap& y); + bool operator>=(const leap& x, const leap& y); + + template + bool operator==(const leap& x, const sys_time& y); + template + bool operator==(const sys_time& x, const leap& y); + template + bool operator!=(const leap& x, const sys_time& y); + template + bool operator!=(const sys_time& x, const leap& y); + template + bool operator< (const leap& x, const sys_time& y); + template + bool operator< (const sys_time& x, const leap& y); + template + bool operator> (const leap& x, const sys_time& y); + template + bool operator> (const sys_time& x, const leap& y); + template + bool operator<=(const leap& x, const sys_time& y); + template + bool operator<=(const sys_time& x, const leap& y); + template + bool operator>=(const leap& x, const sys_time& y); + template + bool operator>=(const sys_time& x, const leap& y); + + // \ref{time.zone.link}, class \tcode{link} + class link; + + bool operator==(const link& x, const link& y); + bool operator!=(const link& x, const link& y); + bool operator< (const link& x, const link& y); + bool operator> (const link& x, const link& y); + bool operator<=(const link& x, const link& y); + bool operator>=(const link& x, const link& y); + + // \ref{time.format}, formatting + template + basic_string + format(const charT* fmt, const Streamable& s); + template + basic_string + format(const locale& loc, const charT* fmt, const Streamable& s); + template + basic_string + format(const basic_string& fmt, const Streamable& s); + template + basic_string + format(const locale& loc, const basic_string& fmt, + const Streamable& s); + + // \ref{time.parse}, parsing + template + @\unspec@ + parse(const basic_string& format, Parsable& tp); + + template + @\unspec@ + parse(const basic_string& format, Parsable& tp, + basic_string& abbrev); + + template + @\unspec@ + parse(const basic_string& format, Parsable& tp, + minutes& offset); + + template + @\unspec@ + parse(const basic_string& format, Parsable& tp, + basic_string& abbrev, minutes& offset); + + // calendrical constants + inline constexpr last_spec last{}; + + inline constexpr weekday Sunday{0}; + inline constexpr weekday Monday{1}; + inline constexpr weekday Tuesday{2}; + inline constexpr weekday Wednesday{3}; + inline constexpr weekday Thursday{4}; + inline constexpr weekday Friday{5}; + inline constexpr weekday Saturday{6}; + + inline constexpr month January{1}; + inline constexpr month February{2}; + inline constexpr month March{3}; + inline constexpr month April{4}; + inline constexpr month May{5}; + inline constexpr month June{6}; + inline constexpr month July{7}; + inline constexpr month August{8}; + inline constexpr month September{9}; + inline constexpr month October{10}; + inline constexpr month November{11}; + inline constexpr month December{12}; } inline namespace literals { inline namespace chrono_literals { // \ref{time.duration.literals}, suffixes for duration literals + constexpr chrono::year operator""y(unsigned long long y) noexcept; + constexpr chrono::day operator""d(unsigned long long d) noexcept; + constexpr chrono::hours operator""h(unsigned long long); constexpr chrono::duration<@\unspec,@ ratio<3600, 1>> operator""h(long double); - constexpr chrono::minutes operator""min(unsigned long long); - constexpr chrono::duration<@\unspec,@ ratio<60, 1>> operator""min(long double); - constexpr chrono::seconds operator""s(unsigned long long); - constexpr chrono::duration<@\unspec@> @\itcorr[-1]@ operator""s(long double); - constexpr chrono::milliseconds operator""ms(unsigned long long); - constexpr chrono::duration<@\unspec,@ milli> operator""ms(long double); - constexpr chrono::microseconds operator""us(unsigned long long); - constexpr chrono::duration<@\unspec,@ micro> operator""us(long double); - constexpr chrono::nanoseconds operator""ns(unsigned long long); - constexpr chrono::duration<@\unspec,@ nano> operator""ns(long double); + + constexpr chrono::minutes operator""min(unsigned long long); + constexpr chrono::duration<@\unspec,@ ratio<60, 1>> operator""min(long double); + + constexpr chrono::seconds operator""s(unsigned long long); + constexpr chrono::duration<@\unspec@>@\itcorr[-1]@ operator""s(long double); + + constexpr chrono::milliseconds operator""ms(unsigned long long); + constexpr chrono::duration<@\unspec,@ milli> operator""ms(long double); + + constexpr chrono::microseconds operator""us(unsigned long long); + constexpr chrono::duration<@\unspec,@ micro> operator""us(long double); + + constexpr chrono::nanoseconds operator""ns(unsigned long long); + constexpr chrono::duration<@\unspec,@ nano> operator""ns(long double); } } @@ -17636,10 +18445,10 @@ A clock is a bundle consisting of a \tcode{duration}, a \tcode{time_point}, and a function \tcode{now()} to get the current \tcode{time_point}. The origin of the clock's \tcode{time_point} is referred to as the clock's \defn{epoch}. - A clock shall meet the requirements in Table~\ref{tab:time.clock}. + A clock shall satisfy the requirements in \tref{time.clock}. \pnum -In Table~\ref{tab:time.clock} \tcode{C1} and \tcode{C2} denote clock types. \tcode{t1} and +In \tref{time.clock} \tcode{C1} and \tcode{C2} denote clock types. \tcode{t1} and \tcode{t2} are values returned by \tcode{C1::now()} where the call returning \tcode{t1} happens before\iref{intro.multithread} the call returning \tcode{t2} and both of these calls occur @@ -17697,12 +18506,12 @@ \item \tcode{TC} satisfies the \tcode{Clock} requirements\iref{time.clock.req}, \item the types \tcode{TC::rep}, \tcode{TC::duration}, and \tcode{TC::time_point} -satisfy the requirements of \tcode{EqualityCom\-parable} (Table~\ref{tab:equalitycomparable}), -\tcode{LessThanComparable} (Table~\ref{tab:lessthancomparable}), -\tcode{DefaultConstructible} (Table~\ref{tab:defaultconstructible}), -\tcode{CopyCon\-structible} (Table~\ref{tab:copyconstructible}), -\tcode{CopyAssignable} (Table~\ref{tab:copyassignable}), -\tcode{Destructible} (Table~\ref{tab:destructible}), and the requirements of +satisfy the \tcode{EqualityComparable} (\tref{equalitycomparable}), +\tcode{LessThanComparable} (\tref{lessthancomparable}), +\tcode{DefaultConstructible} (\tref{defaultconstructible}), +\tcode{CopyCon\-structible} (\tref{copyconstructible}), +\tcode{CopyAssignable} (\tref{copyassignable}), and +\tcode{Destructible} (\tref{destructible}) requirements and the requirements of numeric types\iref{numeric.requirements}. \begin{note} This means, in particular, that operations on these types will not throw exceptions. \end{note} @@ -17838,6 +18647,43 @@ The common type of two \tcode{time_point} types is a \tcode{time_point} with the same clock as the two types and the common type of their two \tcode{duration}s. +\rSec3[time.traits.is_clock]{Class template \tcode{is_clock}} + +\indexlibrary{\idxcode{is_clock}}% +\begin{itemdecl} +template struct is_clock; +\end{itemdecl} + +\pnum +\tcode{is_clock} is a UnaryTypeTrait\iref{meta.rqmts} +with a base characteristic of \tcode{true_type} +if \tcode{T} meets the Clock requirements\iref{time.clock.req}, +otherwise \tcode{false_type}. +For the purposes of the specification of this trait, +the extent to which an implementation determines +that a type cannot meet the Clock requirements is unspecified, +except that as a minimum +a type \tcode{T} shall not qualify as a Clock +unless it satisfies all of the following conditions: + +\begin{itemize} +\item the \grammarterm{qualified-id}s +\tcode{T::rep}, +\tcode{T::period}, +\tcode{T::duration}, and +\tcode{T::time_point} +are valid and each denotes a type\iref{temp.deduct}, +\item the expression +\tcode{T::is_steady} +is well-formed when treated as an unevaluated operand, +\item the expression +\tcode{T::now()} +is well-formed when treated as an unevaluated operand. +\end{itemize} + +\pnum +The behavior of a program that adds specializations for \tcode{is_clock} is undefined. + \rSec2[time.duration]{Class template \tcode{duration}} \pnum @@ -17850,48 +18696,48 @@ \begin{codeblock} namespace std::chrono { template> - class duration { - public: - using rep = Rep; - using period = typename Period::type; + class duration { + public: + using rep = Rep; + using period = typename Period::type; - private: - rep rep_; // \expos + private: + rep rep_; // \expos - public: - // \ref{time.duration.cons}, construct/copy/destroy - constexpr duration() = default; - template - constexpr explicit duration(const Rep2& r); - template - constexpr duration(const duration& d); - ~duration() = default; - duration(const duration&) = default; - duration& operator=(const duration&) = default; - - // \ref{time.duration.observer}, observer - constexpr rep count() const; - - // \ref{time.duration.arithmetic}, arithmetic - constexpr common_type_t operator+() const; - constexpr common_type_t operator-() const; - constexpr duration& operator++(); - constexpr duration operator++(int); - constexpr duration& operator--(); - constexpr duration operator--(int); - - constexpr duration& operator+=(const duration& d); - constexpr duration& operator-=(const duration& d); - - constexpr duration& operator*=(const rep& rhs); - constexpr duration& operator/=(const rep& rhs); - constexpr duration& operator%=(const rep& rhs); - constexpr duration& operator%=(const duration& rhs); - - // \ref{time.duration.special}, special values - static constexpr duration zero(); - static constexpr duration min(); - static constexpr duration max(); + public: + // \ref{time.duration.cons}, construct/copy/destroy + constexpr duration() = default; + template + constexpr explicit duration(const Rep2& r); + template + constexpr duration(const duration& d); + ~duration() = default; + duration(const duration&) = default; + duration& operator=(const duration&) = default; + + // \ref{time.duration.observer}, observer + constexpr rep count() const; + + // \ref{time.duration.arithmetic}, arithmetic + constexpr common_type_t operator+() const; + constexpr common_type_t operator-() const; + constexpr duration& operator++(); + constexpr duration operator++(int); + constexpr duration& operator--(); + constexpr duration operator--(int); + + constexpr duration& operator+=(const duration& d); + constexpr duration& operator-=(const duration& d); + + constexpr duration& operator*=(const rep& rhs); + constexpr duration& operator/=(const rep& rhs); + constexpr duration& operator%=(const rep& rhs); + constexpr duration& operator%=(const duration& rhs); + + // \ref{time.duration.special}, special values + static constexpr duration zero(); + static constexpr duration min(); + static constexpr duration max(); }; } \end{codeblock} @@ -18180,7 +19026,7 @@ \pnum In the function descriptions that follow, \tcode{CD} represents the return type -of the function. \tcode{CR(A, B)} represents \tcode{common_type_t}. +of the function. \indexlibrary{\idxcode{common_type}}% \begin{itemdecl} @@ -18216,7 +19062,7 @@ \begin{itemdescr} \pnum \remarks This operator shall not participate in overload -resolution unless \tcode{Rep2} is implicitly convertible to \tcode{CR(Rep1, Rep2)}. +resolution unless \tcode{Rep2} is implicitly convertible to \tcode{common_type_t}. \pnum \returns \tcode{CD(CD(d).count() * s)}. @@ -18232,7 +19078,7 @@ \begin{itemdescr} \pnum \remarks This operator shall not participate in overload -resolution unless \tcode{Rep1} is implicitly convertible to \tcode{CR(Rep1, Rep2)}. +resolution unless \tcode{Rep1} is implicitly convertible to \tcode{common_type_t}. \pnum \returns \tcode{d * s}. @@ -18248,7 +19094,7 @@ \begin{itemdescr} \pnum \remarks This operator shall not participate in overload -resolution unless \tcode{Rep2} is implicitly convertible to \tcode{CR(Rep1, Rep2)} +resolution unless \tcode{Rep2} is implicitly convertible to \tcode{common_type_t} and \tcode{Rep2} is not a specialization of \tcode{duration}. \pnum @@ -18277,7 +19123,7 @@ \begin{itemdescr} \pnum \remarks This operator shall not participate in overload -resolution unless \tcode{Rep2} is implicitly convertible to \tcode{CR(Rep1, Rep2)} and +resolution unless \tcode{Rep2} is implicitly convertible to \tcode{common_type_t} and \tcode{Rep2} is not a specialization of \tcode{duration}. \pnum @@ -18606,45 +19452,166 @@ otherwise return \tcode{-d}. \end{itemdescr} +\rSec3[time.duration.io]{\tcode{duration} I/O} + +\indexlibrarymember{operator<<}{duration}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const duration& d); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\requires \tcode{Rep} is an integral type +whose integer conversion rank\iref{conv.rank} +is greater than or equal to that of \tcode{short}, +or a floating point type. +\tcode{charT} is \tcode{char} or \tcode{wchar_t}. + +\pnum +\effects +Forms a \tcode{basic_string} from \tcode{d.count()} +using \tcode{to_string} if \tcode{charT} is \tcode{char}, +or \tcode{to_wstring} if \tcode{charT} is \tcode{wchar_t}. +Appends the units suffix described below to the \tcode{basic_string}. +Inserts the resulting \tcode{basic_string} into \tcode{os}. +\begin{note} +This specification ensures that the result of this streaming operation +will obey the width and alignment properties of the stream. +\end{note} + +\pnum +The units suffix depends on the type \tcode{Period::type} as follows: +\begin{itemize} +\item If \tcode{Period::type} is \tcode{atto}, the suffix is \tcode{"as"}. +\item Otherwise, if \tcode{Period::type} is \tcode{femto}, the suffix is \tcode{"fs"}. +\item Otherwise, if \tcode{Period::type} is \tcode{pico}, the suffix is \tcode{"ps"}. +\item Otherwise, if \tcode{Period::type} is \tcode{nano}, the suffix is \tcode{"ns"}. +\item Otherwise, if \tcode{Period::type} is \tcode{micro}, the suffix is \tcode{"\textmu{}s"} (\tcode{"\textbackslash{}u00b5\textbackslash{}u0073"}). +\item Otherwise, if \tcode{Period::type} is \tcode{milli}, the suffix is \tcode{"ms"}. +\item Otherwise, if \tcode{Period::type} is \tcode{centi}, the suffix is \tcode{"cs"}. +\item Otherwise, if \tcode{Period::type} is \tcode{deci}, the suffix is \tcode{"ds"}. +\item Otherwise, if \tcode{Period::type} is \tcode{ratio<1>}, the suffix is \tcode{"s"}. +\item Otherwise, if \tcode{Period::type} is \tcode{deca}, the suffix is \tcode{"das"}. +\item Otherwise, if \tcode{Period::type} is \tcode{hecto}, the suffix is \tcode{"hs"}. +\item Otherwise, if \tcode{Period::type} is \tcode{kilo}, the suffix is \tcode{"ks"}. +\item Otherwise, if \tcode{Period::type} is \tcode{mega}, the suffix is \tcode{"Ms"}. +\item Otherwise, if \tcode{Period::type} is \tcode{giga}, the suffix is \tcode{"Gs"}. +\item Otherwise, if \tcode{Period::type} is \tcode{tera}, the suffix is \tcode{"Ts"}. +\item Otherwise, if \tcode{Period::type} is \tcode{peta}, the suffix is \tcode{"Ps"}. +\item Otherwise, if \tcode{Period::type} is \tcode{exa}, the suffix is \tcode{"Es"}. +\item Otherwise, if \tcode{Period::type} is \tcode{ratio<60>}, the suffix is \tcode{"min"}. +\item Otherwise, if \tcode{Period::type} is \tcode{ratio<3600>}, the suffix is \tcode{"h"}. +\item Otherwise, if \tcode{Period::type::den == 1}, the suffix is \tcode{"[\placeholder{num}]s"}. +\item Otherwise, the suffix is \tcode{"[\placeholder{num}/\placeholder{den}]s"}. +\end{itemize} +In the list above the use of \tcode{\placeholder{num}} and \tcode{\placeholder{den}} +refer to the static data members of \tcode{Period::type}, +which are converted to arrays of \tcode{charT} using a decimal conversion with no leading zeroes. + +\pnum +For streams where \tcode{charT} has an 8-bit representation, +\tcode{"\textmu{}s"} should be encoded as UTF-8. Otherwise UTF-16 or UTF-32 is encouraged. +The implementation may substitute other encodings, including \tcode{"us"}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{to_stream}{duration}% +\begin{itemdecl} +template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, + const duration& d); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Streams \tcode{d} into \tcode{os} using +the format specified by the NTCTS \tcode{fmt}. +\tcode{fmt} encoding follows the rules specified in \ref{time.format}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{from_stream}{duration}% +\begin{itemdecl} +template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + duration& d, + basic_string* abbrev = nullptr, + minutes* offset = nullptr); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Attempts to parse the input stream \tcode{is} +into the duration \tcode{d} +using the format flags given in the NTCTS \tcode{fmt} +as specified in \ref{time.parse}. +If the parse parses everything specified by the parsing format flags without error, +and yet none of the flags impacts a duration, +\tcode{d} will be assigned a zero value. +If \tcode{\%Z} is used and successfully parsed, +that value will be assigned to \tcode{*abbrev} if \tcode{abbrev} is non-null. +If \tcode{\%z} (or a modified variant) is used and successfully parsed, +that value will be assigned to \tcode{*offset} if \tcode{offset} is non-null. + +\pnum +\returns \tcode{is}. +\end{itemdescr} + \rSec2[time.point]{Class template \tcode{time_point}} \indexlibrary{\idxcode{time_point}}% \begin{codeblock} namespace std::chrono { template - class time_point { - public: - using clock = Clock; - using duration = Duration; - using rep = typename duration::rep; - using period = typename duration::period; + class time_point { + public: + using clock = Clock; + using duration = Duration; + using rep = typename duration::rep; + using period = typename duration::period; - private: - duration d_; // \expos + private: + duration d_; // \expos - public: - // \ref{time.point.cons}, construct - constexpr time_point(); // has value epoch - constexpr explicit time_point(const duration& d); // same as \tcode{time_point() + d} - template - constexpr time_point(const time_point& t); - - // \ref{time.point.observer}, observer - constexpr duration time_since_epoch() const; - - // \ref{time.point.arithmetic}, arithmetic - constexpr time_point& operator+=(const duration& d); - constexpr time_point& operator-=(const duration& d); - - // \ref{time.point.special}, special values - static constexpr time_point min(); - static constexpr time_point max(); + public: + // \ref{time.point.cons}, construct + constexpr time_point(); // has value epoch + constexpr explicit time_point(const duration& d); // same as \tcode{time_point() + d} + template + constexpr time_point(const time_point& t); + + // \ref{time.point.observer}, observer + constexpr duration time_since_epoch() const; + + // \ref{time.point.arithmetic}, arithmetic + constexpr time_point& operator++(); + constexpr time_point operator++(int); + constexpr time_point& operator--(); + constexpr time_point operator--(int); + constexpr time_point& operator+=(const duration& d); + constexpr time_point& operator-=(const duration& d); + + // \ref{time.point.special}, special values + static constexpr time_point min(); + static constexpr time_point max(); }; } \end{codeblock} \pnum -\tcode{Clock} shall meet the Clock requirements\iref{time.clock.req}. +\tcode{Clock} shall either +satisfy the Clock requirements\iref{time.clock.req} +or be the type \tcode{local_t}. \pnum If \tcode{Duration} is not an instance of \tcode{duration}, @@ -18706,6 +19673,52 @@ \rSec3[time.point.arithmetic]{\tcode{time_point} arithmetic} +\indexlibrarymember{operator++}{time_point}% +\begin{itemdecl} +constexpr time_point& operator++(); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{++d_}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator++}{time_point}% +\begin{itemdecl} +constexpr time_point operator++(int); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{time_point\{d_++\}}. +\end{itemdescr} + +\indexlibrarymember{operator--}{time_point}% +\begin{itemdecl} +constexpr time_point& operator--(); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{--d_}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator--}{time_point}% +\begin{itemdecl} +constexpr time_point operator--(int); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{time_point\{d_--\}}. +\end{itemdescr} + \indexlibrarymember{operator+=}{time_point}% \begin{itemdecl} constexpr time_point& operator+=(const duration& d); @@ -18954,14 +19967,13 @@ \pnum The types defined in this subclause shall satisfy the \tcode{TrivialClock} -requirements\iref{time.clock.req}. +requirements\iref{time.clock.req} +unless otherwise specified. \rSec3[time.clock.system]{Class \tcode{system_clock}} -\indexlibrary{\idxcode{system_clock}}% -\pnum -Objects of class \tcode{system_clock} represent wall clock time from the system-wide -realtime clock. +\rSec4[time.clock.system.overview]{Overview} +\indexlibrary{\idxcode{system_clock}}% \begin{codeblock} namespace std::chrono { @@ -18975,13 +19987,29 @@ static time_point now() noexcept; - // map to C API + // mapping to/from C type \tcode{time_t} static time_t to_time_t (const time_point& t) noexcept; static time_point from_time_t(time_t t) noexcept; }; } \end{codeblock} +\pnum +Objects of type \tcode{system_clock} represent wall clock time from the system-wide +realtime clock. +Objects of type \tcode{sys_time} measure time since (and before) +1970-01-01 00:00:00 UTC excluding leap seconds. +This measure is commonly referred to as \defn{Unix time}. +This measure facilitates an efficient mapping between +\tcode{sys_time} and calendar types\iref{time.cal}. +\begin{example} \\ +\tcode{sys_seconds\{sys_days\{1970y/January/1\}\}.time_since_epoch()} is \tcode{0s}. \\ +\tcode{sys_seconds\{sys_days\{2000y/January/1\}\}.time_since_epoch()} is \tcode{946'684'800s}, +which is \tcode{10'957 * 86'400s}. \\ +\end{example} + +\rSec4[time.clock.system.members]{Members} + \indexlibrarymember{rep}{system_clock}% \begin{itemdecl} using system_clock::rep = @\unspec@; @@ -19024,52 +20052,8571 @@ whether values are rounded or truncated to the required precision. \end{itemdescr} -\rSec3[time.clock.steady]{Class \tcode{steady_clock}} -\indexlibrary{\idxcode{steady_clock}}% +\rSec4[time.clock.system.nonmembers]{Non-member functions} + +\indexlibrarymember{operator<<}{sys_time}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const sys_time& tp); +\end{itemdecl} +\begin{itemdescr} \pnum -Objects of class \tcode{steady_clock} represent clocks for which values of \tcode{time_point} -never decrease as physical time advances and for which values of \tcode{time_point} advance at -a steady rate relative to real time. That is, the clock may not be adjusted. +\remarks +This operator shall not participate in overload resolution if +\tcode{treat_as_floating_point_v} is \tcode{true}, +or if \tcode{Duration\{1\} >= days\{1\}}. +\pnum +\effects \begin{codeblock} -namespace std::chrono { - class steady_clock { - public: - using rep = @\unspec@; - using period = ratio<@\unspecnc@, @\unspec{}@>; - using duration = chrono::duration; - using time_point = chrono::time_point<@\unspecnc@, duration>; - static constexpr bool is_steady = true; - - static time_point now() noexcept; - }; -} +auto const dp = floor(tp); +os << year_month_day{dp} << ' ' << time_of_day{tp-dp}; \end{codeblock} -\rSec3[time.clock.hires]{Class \tcode{high_resolution_clock}} -\indexlibrary{\idxcode{high_resolution_clock}}% +\pnum +\returns \tcode{os}. \pnum -Objects of class \tcode{high_resolution_clock} represent clocks with the -shortest tick period. \tcode{high_resolution_clock} may be a synonym for +\begin{example} +\begin{codeblock} +cout << sys_seconds{0s} << '\n'; // 1970-01-01 00:00:00 +cout << sys_seconds{946'684'800s} << '\n'; // 2000-01-01 00:00:00 +cout << sys_seconds{946'688'523s} << '\n'; // 2000-01-01 01:02:03 +\end{codeblock} +\end{example} +\end{itemdescr} + +\indexlibrarymember{operator<<}{sys_days}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const sys_days& dp); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{os << year_month_day\{dp\}}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{to_stream}{sys_time}% +\begin{itemdecl} +template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, const sys_time& tp); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Streams \tcode{tp} into \tcode{os} using +the format specified by the NTCTS \tcode{fmt}. +\tcode{fmt} encoding follows the rules specified in \ref{time.format}. +If \tcode{\%Z} is used, it will be replaced with +\tcode{"UTC"} widened to \tcode{charT}. +If \tcode{\%z} is used (or a modified variant of \tcode{\%z}), +an offset of \tcode{0min} will be formatted. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{from_stream}{sys_time}% +\begin{itemdecl} +template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + sys_time& tp, basic_string* abbrev = nullptr, + minutes* offset = nullptr); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects Attempts to parse the input stream \tcode{is} +into the \tcode{sys_time} \tcode{tp} using +the format flags given in the NTCTS \tcode{fmt} +as specified in \ref{time.parse}. +If the parse fails to decode a valid date, +\tcode{is.setstate(ios_base::failbit)} +shall be called and \tcode{tp} shall not be modified. +If \tcode{\%Z} is used and successfully parsed, +that value will be assigned to \tcode{*abbrev} if \tcode{abbrev} is non-null. +If \tcode{\%z} (or a modified variant) is used and successfully parsed, +that value will be assigned to \tcode{*offset} if \tcode{offset} is non-null. +Additionally, the parsed offset will be subtracted +from the successfully parsed timestamp +prior to assigning that difference to \tcode{tp}. + +\pnum +\returns is. +\end{itemdescr} + +\rSec3[time.clock.utc]{Class \tcode{utc_clock}} + +\rSec4[time.clock.utc.overview]{Overview} +\indexlibrary{\idxcode{utc_clock}}% + +\begin{codeblock} +namespace std::chrono { + class utc_clock { + public: + using rep = @\textit{a signed arithmetic type}@; + using period = ratio<@\unspecnc@, @\unspec@>; + using duration = chrono::duration; + using time_point = chrono::time_point; + static constexpr bool is_steady = @\unspec@; + + static time_point now(); + + template + static sys_time> + to_sys(const utc_time& t); + template + static utc_time> + from_sys(const sys_time& t); + }; +} +\end{codeblock} + +\pnum +In contrast to \tcode{sys_time}, +which does not take leap seconds into account, +\tcode{utc_clock} and its associated \tcode{time_point}, \tcode{utc_time}, +count time, including leap seconds, since 1970-01-01 00:00:00 UTC. +\begin{example} \\ +\tcode{clock_cast(sys_seconds\{sys_days\{1970y/January/1\}\}).time_since_epoch()} is \tcode{0s}. \\ +\tcode{clock_cast(sys_seconds\{sys_days\{2000y/January/1\}\}).time_since_epoch()} \\ +is \tcode{946'684'822s}, which is \tcode{10'957 * 86'400s + 22s}. \\ +\end{example} + +\pnum +\tcode{utc_clock} is not a TrivialClock +unless the implementation can guarantee that \tcode{utc_clock::now()} +does not propagate an exception. +\begin{note} \tcode{noexcept(from_sys(system_clock::now()))} is \tcode{false}. \end{note} + +\rSec4[time.clock.utc.members]{Member functions} + +\indexlibrarymember{now}{utc_clock}% +\begin{itemdecl} +static time_point now(); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{from_sys(system_clock::now())}, or a more accurate value of \tcode{utc_time}. +\end{itemdescr} + +\indexlibrarymember{to_sys}{utc_clock}% +\begin{itemdecl} +template + static sys_time> + to_sys(const utc_time& u); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +A \tcode{sys_time} \tcode{t}, +such that \tcode{from_sys(t) == u} if such a mapping exists. +Otherwise \tcode{u} represents a \tcode{time_point} +during a leap second insertion +and the last representable value of \tcode{sys_time} +prior to the insertion of the leap second is returned. +\end{itemdescr} + +\indexlibrarymember{from_sys}{utc_clock}% +\begin{itemdecl} +template + static utc_time> + from_sys(const sys_time& t); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +A \tcode{utc_time} \tcode{u}, such that +\tcode{u.time_since_epoch() - t.time_since_epoch()} +is equal to the number of leap seconds that were inserted +between \tcode{t} and 1970-01-01. +If \tcode{t} is exactly the date of leap second insertion, +then the conversion counts that leap second as inserted. + +\begin{example} +\begin{codeblock} +auto t = sys_days{July/1/2015} - 2ns; +auto u = utc_clock::from_sys(t); +assert(u.time_since_epoch() - t.time_since_epoch() == 25s); +t += 1ns; +u = utc_clock::from_sys(t); +assert(u.time_since_epoch() - t.time_since_epoch() == 25s); +t += 1ns; +u = utc_clock::from_sys(t); +assert(u.time_since_epoch() - t.time_since_epoch() == 26s); +t += 1ns; +u = utc_clock::from_sys(t); +assert(u.time_since_epoch() - t.time_since_epoch() == 26s); +\end{codeblock} +\end{example} +\end{itemdescr} + +\rSec4[time.clock.utc.nonmembers]{Non-member functions} + +\indexlibrarymember{operator<<}{utc_time}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const utc_time& t); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Calls \tcode{to_stream(os, fmt, t)}, +where \tcode{fmt} is a string containing \tcode{"\%F \%T"} +widened to \tcode{charT}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{to_stream}{utc_time}% +\begin{itemdecl} +template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, const utc_time& tp); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Streams \tcode{tp} into \tcode{os} using +the format specified by the NTCTS \tcode{fmt}. +\tcode{fmt} encoding follows the rules specified in \ref{time.format}. +If \tcode{\%Z} is used, it will be replaced with \tcode{"UTC"} widened to \tcode{charT}. +If \tcode{\%z} is used (or a modified variant of \tcode{\%z}), +an offset of \tcode{0min} will be formatted. +If \tcode{tp} represents a time during a leap second insertion, +and if a seconds field is formatted, +the integral portion of that format shall be \tcode{"60"} widened to \tcode{charT}. + +\pnum +\returns \tcode{os}. + +\pnum +\begin{example} +\begin{codeblock} +auto t = sys_days{July/1/2015} - 500ms; +auto u = clock_cast(t); +for (auto i = 0; i < 8; ++i, u += 250ms) + cout << u << " UTC\n"; +\end{codeblock} + +Produces this output: + +\begin{codeblock} +2015-06-30 23:59:59.500 UTC +2015-06-30 23:59:59.750 UTC +2015-06-30 23:59:60.000 UTC +2015-06-30 23:59:60.250 UTC +2015-06-30 23:59:60.500 UTC +2015-06-30 23:59:60.750 UTC +2015-07-01 00:00:00.000 UTC +2015-07-01 00:00:00.250 UTC +\end{codeblock} +\end{example} +\end{itemdescr} + +\indexlibrarymember{from_stream}{utc_time}% +\begin{itemdecl} +template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + utc_time& tp, basic_string* abbrev = nullptr, + minutes* offset = nullptr); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Attempts to parse the input stream \tcode{is} +into the \tcode{utc_time} \tcode{tp} using +the format flags given in the NTCTS \tcode{fmt} +as specified in \ref{time.parse}. +If the parse fails to decode a valid date, +\tcode{is.setstate(ios_base::failbit)} shall be called +and \tcode{tp} shall not be modified. +If \tcode{\%Z} is used and successfully parsed, +that value will be assigned to \tcode{*abbrev} if \tcode{abbrev} is non-null. +If \tcode{\%z} (or a modified variant) is used and successfully parsed, +that value will be assigned to \tcode{*offset} if \tcode{offset} is non-null. +Additionally, the parsed offset will be subtracted from +the successfully parsed timestamp +prior to assigning that difference to \tcode{tp}. + +\pnum +\returns \tcode{is}. +\end{itemdescr} + +\rSec3[time.clock.tai]{Class \tcode{tai_clock}} + +\rSec4[time.clock.tai.overview]{Overview} +\indexlibrary{\idxcode{tai_clock}}% + +\begin{codeblock} +namespace std::chrono { + class tai_clock { + public: + using rep = @\textit{a signed arithmetic type}@; + using period = ratio<@\unspecnc@, @\unspec@>; + using duration = chrono::duration; + using time_point = chrono::time_point; + static constexpr bool is_steady = @\unspec@; + + static time_point now(); + + template + static utc_time> + to_utc(const tai_time&) noexcept; + template + static tai_time> + from_utc(const utc_time&) noexcept; + }; +} +\end{codeblock} + +\pnum +The clock \tcode{tai_clock} measures seconds since 1958-01-01 00:00:00 +and is offset 10s ahead of UTC at this date. +That is, 1958-01-01 00:00:00 TAI is equivalent to 1957-12-31 23:59:50 UTC. +Leap seconds are not inserted into TAI. +Therefore every time a leap second is inserted into UTC, +UTC falls another second behind TAI. +For example by 2000-01-01 there had been 22 leap seconds inserted +so 2000-01-01 00:00:00 UTC is equivalent to 2000-01-01 00:00:32 TAI +(22s plus the initial 10s offset). + +\pnum +\tcode{tai_clock} is not a TrivialClock +unless the implementation can guarantee that \tcode{tai_clock::now()} +does not propagate an exception. +\begin{note} +\tcode{noexcept(from_utc(utc_clock::now()))} is \tcode{false}. +\end{note} + +\rSec4[time.clock.tai.members]{Member functions} + +\indexlibrarymember{now}{tai_clock}% +\begin{itemdecl} +static time_point now(); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{from_utc(utc_clock::now())}, or a more accurate value of \tcode{tai_time}. +\end{itemdescr} + +\indexlibrarymember{to_utc}{tai_clock}% +\begin{itemdecl} +template + static utc_time> + to_utc(const tai_time& t) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\begin{codeblock} +utc_time>{t.time_since_epoch()} - 378691210s +\end{codeblock} +\begin{note} +\begin{codeblock} +378691210s == sys_days{1970y/January/1} - sys_days{1958y/January/1} + 10s +\end{codeblock} +\end{note} +\end{itemdescr} + +\indexlibrarymember{from_utc}{tai_clock}% +\begin{itemdecl} +template + static tai_time> + from_utc(const utc_time& t) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\begin{codeblock} +tai_time>{t.time_since_epoch()} + 378691210s +\end{codeblock} +\begin{note} +\begin{codeblock} +378691210s == sys_days{1970y/January/1} - sys_days{1958y/January/1} + 10s +\end{codeblock} +\end{note} +\end{itemdescr} + +\rSec4[time.clock.tai.nonmembers]{Non-member functions} + +\indexlibrarymember{operator<<}{tai_time}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const tai_time& t); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Calls \tcode{to_stream(os, fmt, t)}, +where \tcode{fmt} is a string containing +\tcode{"\%F \%T"} widened to \tcode{charT}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{to_stream}{tai_time}% +\begin{itemdecl} +template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, const tai_time& tp); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Streams \tcode{tp} into \tcode{os} using +the format specified by the NTCTS \tcode{fmt}. +\tcode{fmt} encoding follows the rules specified in \ref{time.format}. +If \tcode{\%Z} is used, it will be replaced with \tcode{"TAI"}. +If \tcode{\%z} is used (or a modified variant of \tcode{\%z}), +an offset of \tcode{0min} will be formatted. +The date and time formatted shall be equivalent to +that formatted by a \tcode{sys_time} initialized with: +\begin{codeblock} +sys_time{tp.time_since_epoch()} - + (sys_days{1970y/January/1} - sys_days{1958y/January/1}) +\end{codeblock} + +\pnum +\returns os. + +\pnum +\begin{example} +\begin{codeblock} +auto st = sys_days{2000y/January/1}; +auto tt = clock_cast(st); +cout << format("%F %T %Z == ", st) << format("%F %T %Z\n", tt); +\end{codeblock} + +Produces this output: + +\begin{codeblock} +2000-01-01 00:00:00 UTC == 2000-01-01 00:00:32 TAI +\end{codeblock} +\end{example} +\end{itemdescr} + +\indexlibrarymember{from_stream}{tai_time}% +\begin{itemdecl} +template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + tai_time& tp, basic_string* abbrev = nullptr, + minutes* offset = nullptr); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Attempts to parse the input stream \tcode{is} +into the \tcode{tai_time} \tcode{tp} using +the format flags given in the NTCTS \tcode{fmt} +as specified in \ref{time.parse}. +If the parse fails to decode a valid date, +\tcode{is.setstate(ios_base::failbit)} shall be called +and \tcode{tp} shall not be modified. +If \tcode{\%Z} is used and successfully parsed, +that value will be assigned to \tcode{*abbrev} if \tcode{abbrev} is non-null. +If \tcode{\%z} (or a modified variant) is used and successfully parsed, +that value will be assigned to \tcode{*offset} if \tcode{offset} is non-null. +Additionally, the parsed offset will be subtracted from +the successfully parsed timestamp prior to assigning that difference to \tcode{tp}. + +\pnum +\returns \tcode{is}. +\end{itemdescr} + +\rSec3[time.clock.gps]{Class \tcode{gps_clock}} + +\rSec4[time.clock.gps.overview]{Overview} +\indexlibrary{\idxcode{gps_clock}}% + +\begin{codeblock} +namespace std::chrono { + class gps_clock { + public: + using rep = @\textit{a signed arithmetic type}@; + using period = ratio<@\unspecnc@, @\unspec@>; + using duration = chrono::duration; + using time_point = chrono::time_point; + static constexpr bool is_steady = @\unspec@; + + static time_point now(); + + template + static utc_time> + to_utc(const gps_time&) noexcept; + template + static gps_time> + from_utc(const utc_time&) noexcept; + }; +} +\end{codeblock} + +\pnum +The clock \tcode{gps_clock} measures +seconds since the first Sunday of January, 1980 00:00:00 UTC. +Leap seconds are not inserted into GPS. +Therefore every time a leap second is inserted into UTC, +UTC falls another second behind GPS. +Aside from the offset from \tcode{1958y/January/1} to \tcode{1980y/January/Sunday[1]}, +GPS is behind TAI by 19s due to the 10s offset between 1958 and 1970 +and the additional 9 leap seconds inserted between 1970 and 1980. + +\pnum +\tcode{gps_clock} is not a TrivialClock +unless the implementation can guarantee that +\tcode{gps_clock::now()} does not propagate an exception. +\begin{note} +\tcode{noexcept(from_utc(utc_clock::now()))} is \tcode{false}. +\end{note} + +\rSec4[time.clock.gps.members]{Member functions} + +\indexlibrarymember{now}{gps_clock}% +\begin{itemdecl} +static time_point now(); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{from_utc(utc_clock::now())}, or a more accurate value of \tcode{gps_time}. +\end{itemdescr} + +\indexlibrarymember{to_utc}{gps_clock}% +\begin{itemdecl} +template + static utc_time> + to_utc(const gps_time& t) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\begin{codeblock} +gps_time>{t.time_since_epoch()} + 315964809s +\end{codeblock} +\begin{note} +\begin{codeblock} +315964809s == sys_days{1980y/January/Sunday[1]} - sys_days{1970y/January/1} + 9s +\end{codeblock} +\end{note} +\end{itemdescr} + +\indexlibrarymember{from_utc}{gps_clock}% +\begin{itemdecl} +template + static gps_time> + from_utc(const utc_time& t) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\begin{codeblock} +gps_time>{t.time_since_epoch()} - 315964809s +\end{codeblock} +\begin{note} +\begin{codeblock} +315964809s == sys_days{1980y/January/Sunday[1]} - sys_days{1970y/January/1} + 9s +\end{codeblock} +\end{note} +\end{itemdescr} + +\rSec4[time.clock.gps.nonmembers]{Non-member functions} + +\indexlibrarymember{operator<<}{gps_time}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const gps_time& t); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects Calls \tcode{to_stream(os, fmt, t)}, +where \tcode{fmt} is a string containing +\tcode{"\%F \%T"} widened to \tcode{charT}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{to_stream}{gps_time}% +\begin{itemdecl} +template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, const gps_time& tp); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects Streams \tcode{tp} into \tcode{os} using +the format specified by the NTCTS \tcode{fmt}. +\tcode{fmt} encoding follows the rules specified in \ref{time.format}. +If \tcode{\%Z} is used, it will be replaced with \tcode{"GPS"}. +If \tcode{\%z} is used (or a modified variant of \tcode{\%z}), +an offset of \tcode{0min} will be formatted. +The date and time formatted +shall be equivalent to that formatted by a \tcode{sys_time} initialized with: +\begin{codeblock} +sys_time{tp.time_since_epoch()} + + (sys_days{1980y/January/Sunday[1]} - sys_days{1970y/January/1}) +\end{codeblock} + +\pnum +\returns os. + +\pnum +\begin{example} +\begin{codeblock} +auto st = sys_days{2000y/January/1}; +auto gt = clock_cast(st); +cout << format("%F %T %Z == ", st) << format("%F %T %Z\n", gt); +\end{codeblock} + +Produces this output: + +\begin{codeblock} +2000-01-01 00:00:00 UTC == 2000-01-01 00:00:13 GPS +\end{codeblock} +\end{example} +\end{itemdescr} + +\indexlibrarymember{from_stream}{gps_time}% +\begin{itemdecl} +template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + gps_time& tp, basic_string* abbrev = nullptr, + minutes* offset = nullptr); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Attempts to parse the input stream \tcode{is} +into the \tcode{gps_time} \tcode{tp} using +the format flags given in the NTCTS \tcode{fmt} +as specified in \ref{time.parse}. +If the parse fails to decode a valid date, +\tcode{is.setstate(ios_base::failbit)} shall be called +and \tcode{tp} shall not be modified. +If \tcode{\%Z} is used and successfully parsed, +that value will be assigned to \tcode{*abbrev} if \tcode{abbrev} is non-null. +If \tcode{\%z} (or a modified variant) is used and successfully parsed, +that value will be assigned to \tcode{*offset} if \tcode{offset} is non-null. +Additionally, the parsed offset will be subtracted from +the successfully parsed timestamp prior to assigning that difference to \tcode{tp}. + +\pnum +\returns \tcode{is}. +\end{itemdescr} + +\rSec3[time.clock.file]{Class \tcode{file_clock}} + +\rSec4[time.clock.file.overview]{Overview} +\indexlibrary{\idxcode{file_clock}}% + +\begin{codeblock} +namespace std::chrono { + class file_clock { + public: + using rep = @\textit{a signed arithmetic type}@; + using period = ratio<@\unspecnc@, @\unspec@>; + using duration = chrono::duration; + using time_point = chrono::time_point; + static constexpr bool is_steady = @\unspec@; + + static time_point now() noexcept; + + // Conversion functions, see below + }; +} +\end{codeblock} + +\pnum +The clock \tcode{file_clock} is used to create the \tcode{time_point} system +used for \tcode{file_time_type}\iref{filesystems}. Its epoch is unspecified. + +\rSec4[time.clock.file.members]{Member functions} + +\indexlibrarymember{now}{file_clock}% +\begin{itemdecl} +static time_point now(); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns A \tcode{file_clock::time_point} indicating the current time. +\end{itemdescr} + +\pnum +The class \tcode{file_clock} shall provide +precisely one of the following two sets of static member functions: + +\begin{codeblock} +template + static sys_time<@\seebelow@> + to_sys(const file_time&); +template + static file_time<@\seebelow@> + from_sys(const sys_time&); +\end{codeblock} + +or: + +\begin{codeblock} +template + static utc_time<@\seebelow@> + to_utc(const file_time&); +template + static file_time<@\seebelow@> + from_utc(const utc_time&); +\end{codeblock} + +These member functions shall provide \tcode{time_point} conversions +consistent with those specified by +\tcode{utc_clock}, \tcode{tai_clock}, and \tcode{gps_clock}. +The \tcode{Duration} of the resultant \tcode{time_point} +is computed from the \tcode{Duration} of the input \tcode{time_point}. + +\rSec4[time.clock.file.nonmembers]{Non-member functions} + +\indexlibrarymember{operator<<}{file_time}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const file_time& t); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects Calls \tcode{to_stream(os, fmt, t)}, +where \tcode{fmt} is a string containing +\tcode{"\%F \%T"} widened to \tcode{charT}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{to_stream}{file_time}% +\begin{itemdecl} +template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, const file_time& tp); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Streams \tcode{tp} into \tcode{os} using +the format specified by the NTCTS \tcode{fmt}. +\tcode{fmt} encoding follows the rules specified in \ref{time.format}. +If \tcode{\%Z} is used, it will be replaced with \tcode{"UTC"} widened to \tcode{charT}. +If \tcode{\%z} is used (or a modified variant of \tcode{\%z}), +an offset of \tcode{0min} will be formatted. +The date and time formatted shall be equivalent to +that formatted by a \tcode{sys_time} initialized with +\tcode{clock_cast(tp)}, +or by a \tcode{utc_time} initialized with +\tcode{clock_cast(tp)}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{from_stream}{file_time}% +\begin{itemdecl} +template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + file_time& tp, basic_string* abbrev = nullptr, + minutes* offset = nullptr); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Attempts to parse the input stream \tcode{is} +into the \tcode{file_time} \tcode{tp} using +the format flags given in the NTCTS \tcode{fmt} +as specified in \ref{time.parse}. +If the parse fails to decode a valid date, +\tcode{is.setstate(ios_base::failbit)} shall be called +and \tcode{tp} shall not be modified. +If \tcode{\%Z} is used and successfully parsed, +that value will be assigned to \tcode{*abbrev} if \tcode{abbrev} is non-null. +If \tcode{\%z} (or a modified variant) is used and successfully parsed, +that value will be assigned to \tcode{*offset} if \tcode{offset} is non-null. +Additionally, the parsed offset will be subtracted from +the successfully parsed timestamp prior to assigning that difference to \tcode{tp}. + +\pnum +\returns \tcode{is}. +\end{itemdescr} + +\rSec3[time.clock.steady]{Class \tcode{steady_clock}} +\indexlibrary{\idxcode{steady_clock}}% + +\begin{codeblock} +namespace std::chrono { + class steady_clock { + public: + using rep = @\unspec@; + using period = ratio<@\unspecnc@, @\unspec{}@>; + using duration = chrono::duration; + using time_point = chrono::time_point<@\unspecnc@, duration>; + static constexpr bool is_steady = true; + + static time_point now() noexcept; + }; +} +\end{codeblock} + +\pnum +Objects of class \tcode{steady_clock} represent clocks for which values of \tcode{time_point} +never decrease as physical time advances and for which values of \tcode{time_point} advance at +a steady rate relative to real time. That is, the clock may not be adjusted. + +\rSec3[time.clock.hires]{Class \tcode{high_resolution_clock}} +\indexlibrary{\idxcode{high_resolution_clock}}% + +\begin{codeblock} +namespace std::chrono { + class high_resolution_clock { + public: + using rep = @\unspec@; + using period = ratio<@\unspecnc@, @\unspec{}@>; + using duration = chrono::duration; + using time_point = chrono::time_point<@\unspecnc@, duration>; + static constexpr bool is_steady = @\unspec@; + + static time_point now() noexcept; + }; +} +\end{codeblock} + +\pnum +Objects of class \tcode{high_resolution_clock} represent clocks with the +shortest tick period. \tcode{high_resolution_clock} may be a synonym for \tcode{system_clock} or \tcode{steady_clock}. +\rSec3[time.clock.local]{Local time} +\indexlibrary{\idxcode{local_time}}% + +\pnum +The family of time points +denoted by \tcode{local_time} +are based on the pseudo clock \tcode{local_t}. +\tcode{local_t} has no member \tcode{now()} +and thus does not meet the clock requirements. +Nevertheless \tcode{local_time} serves the vital role of +representing local time with respect to a not-yet-specified time zone. +Aside from being able to get the current time, +the complete \tcode{time_point} algebra is available +for \tcode{local_time} (just as for \tcode{sys_time}). + +\indexlibrarymember{operator<<}{local_time}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const local_time& lt); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +\begin{codeblock} +os << sys_time{lt.time_since_epoch()}; +\end{codeblock} + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{to_stream}{local_time}% +\begin{itemdecl} +template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, const local_time& tp, + const string* abbrev = nullptr, const seconds* offset_sec = nullptr); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Streams \tcode{tp} into \tcode{os} using +the format specified by the NTCTS \tcode{fmt}. +\tcode{fmt} encoding follows the rules specified in \ref{time.format}. +If \tcode{\%Z} is used, +it will be replaced with \tcode{*abbrev} if \tcode{abbrev} is not equal to \tcode{nullptr}. +If \tcode{abbrev} is equal to \tcode{nullptr} (and \tcode{\%Z} is used), +\tcode{os.setstate(ios_base::failbit)} shall be called. +If \tcode{\%z} is used (or a modified variant of \tcode{\%z}), +it will be formatted with the value of \tcode{*offset_sec} +if \tcode{offset_sec} is not equal to \tcode{nullptr}. +If \tcode{\%z} (or a modified variant of \tcode{\%z}) is used, +and \tcode{offset_sec} is equal to \tcode{nullptr}, then +\tcode{os.setstate(ios_base::failbit)} shall be called. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{from_stream}{local_time}% +\begin{itemdecl} +template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + local_time& tp, basic_string* abbrev = nullptr, + minutes* offset = nullptr); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Attempts to parse the input stream \tcode{is} +into the \tcode{local_time} \tcode{tp} using +the format flags given in the NTCTS \tcode{fmt} +as specified in \ref{time.parse}. +If the parse fails to decode a valid date, +\tcode{is.setstate(ios_base::failbit)} shall be called +and \tcode{tp} shall not be modified. +If \tcode{\%Z} is used and successfully parsed, +that value will be assigned to \tcode{*abbrev} if \tcode{abbrev} is non-null. +If \tcode{\%z} (or a modified variant) is used and successfully parsed, +that value will be assigned to \tcode{*offset} if \tcode{offset} is non-null. + +\pnum +\returns \tcode{is}. +\end{itemdescr} + +\rSec3[time.clock.cast]{\tcode{time_point} conversions} + +\rSec4[time.clock.conv]{Class template \tcode{clock_time_conversion}} +\indexlibrary{\idxcode{clock_time_conversion}}% + +\begin{codeblock} +namespace std::chrono { + template + struct clock_time_conversion {}; +} +\end{codeblock} + +\pnum +\tcode{clock_time_conversion} serves as a trait +which can be used to specify how to convert +a source \tcode{time_point} of type +\tcode{time_point} +to a destination \tcode{time_point} of type +\tcode{time_point} +via a specialization: +\tcode{clock_time_conversion}. +A specialization of \tcode{clock_time_conversion} +shall provide a const-qualified \tcode{operator()} +that takes a parameter of type \tcode{time_point} +and returns a \tcode{time_point} +representing an equivalent point in time. +\tcode{OtherDuration} is a \tcode{chrono::duration} +whose specialization is computed from the input \tcode{Duration} +in a manner which can vary for each \tcode{clock_time_conversion} specialization. +A program may specialize \tcode{clock_time_conversion} +if at least one of the template parameters is a user-defined clock type. + +\pnum +Several specializations are provided by the implementation, +as described in +\ref{time.clock.cast.id}, +\ref{time.clock.cast.sys.utc}, +\ref{time.clock.cast.sys}, and +\ref{time.clock.cast.utc}. + +\rSec4[time.clock.cast.id]{Identity conversions} + +\begin{codeblock} +template +struct clock_time_conversion { + template + time_point + operator()(const time_point& t) const; +}; +\end{codeblock} + +\indexlibrarymember{operator()}{clock_time_conversion}% +\begin{itemdecl} +template + time_point + operator()(const time_point& t) const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{t}. +\end{itemdescr} + +\begin{codeblock} +template<> +struct clock_time_conversion { + template + sys_time + operator()(const sys_time& t) const; +}; +\end{codeblock} + +\indexlibrarymember{operator()}{clock_time_conversion}% +\begin{itemdecl} +template + sys_time + operator()(const sys_time& t) const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{t}. +\end{itemdescr} + +\begin{codeblock} +template<> +struct clock_time_conversion { + template + utc_time + operator()(const utc_time& t) const; +}; +\end{codeblock} + +\indexlibrarymember{operator()}{clock_time_conversion}% +\begin{itemdecl} +template + utc_time + operator()(const utc_time& t) const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{t}. +\end{itemdescr} + +\rSec4[time.clock.cast.sys.utc]{Conversions between \tcode{system_clock} and \tcode{utc_clock}} + +\begin{codeblock} +template<> +struct clock_time_conversion { + template + utc_time> + operator()(const sys_time& t) const; +}; +\end{codeblock} + +\indexlibrarymember{operator()}{clock_time_conversion}% +\begin{itemdecl} +template + utc_time> + operator()(const sys_time& t) const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{utc_clock::from_sys(t)}. +\end{itemdescr} + +\begin{codeblock} +template<> +struct clock_time_conversion { + template + sys_time> + operator()(const utc_time& t) const; +}; +\end{codeblock} + +\indexlibrarymember{operator()}{clock_time_conversion}% +\begin{itemdecl} +template + sys_time> + operator()(const utc_time& t) const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{utc_clock::to_sys(t)}. +\end{itemdescr} + +\rSec4[time.clock.cast.sys]{Conversions between \tcode{system_clock} and other clocks} + +\begin{codeblock} +template +struct clock_time_conversion { + template + auto operator()(const time_point& t) const + -> decltype(SourceClock::to_sys(t)); +}; +\end{codeblock} + +\indexlibrarymember{operator()}{clock_time_conversion}% +\begin{itemdecl} +template + auto operator()(const time_point& t) const + -> decltype(SourceClock::to_sys(t)); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +This function does not participate in overload resolution unless +\tcode{SourceClock::to_sys(t)} is well-formed. +If \tcode{SourceClock::to_sys(t)} +does not return \tcode{sys_time}, +where \tcode{Duration} is a valid \tcode{chrono::duration} specialization, +the program is ill-formed. + +\pnum +\returns \tcode{SourceClock::to_sys(t)}. +\end{itemdescr} + +\begin{codeblock} +template +struct clock_time_conversion { + template + auto operator()(const sys_time& t) const + -> decltype(DestClock::from_sys(t)); +}; +\end{codeblock} + +\indexlibrarymember{operator()}{clock_time_conversion}% +\begin{itemdecl} +template + auto operator()(const sys_time& t) const + -> decltype(DestClock::from_sys(t)); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +This function does not participate in overload resolution unless +\tcode{DestClock::from_sys(t)} is well-formed. +If \tcode{DestClock::from_sys(t)} does not return +\tcode{time_point}, +where \tcode{Duration} is a valid \tcode{chrono::duration} specialization, +the program is ill-formed. + +\pnum +\returns \tcode{DestClock::from_sys(t)}. +\end{itemdescr} + +\rSec4[time.clock.cast.utc]{Conversions between \tcode{utc_clock} and other clocks} + +\begin{codeblock} +template +struct clock_time_conversion { + template + auto operator()(const time_point& t) const + -> decltype(SourceClock::to_utc(t)); +}; +\end{codeblock} + +\indexlibrarymember{operator()}{clock_time_conversion}% +\begin{itemdecl} +template + auto operator()(const time_point& t) const + -> decltype(SourceClock::to_utc(t)); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +This function does not participate in overload resolution unless +\tcode{SourceClock::to_utc(t)} is well-formed. +If \tcode{SourceClock::to_utc(t)} does not return +\tcode{utc_time}, +where \tcode{Duration} is a valid \tcode{chrono::duration} specialization, +the program is ill-formed. + +\pnum +\returns \tcode{SourceClock::to_utc(t)}. +\end{itemdescr} + +\begin{codeblock} +template +struct clock_time_conversion { + template + auto operator()(const utc_time& t) const + -> decltype(DestClock::from_utc(t)); +}; +\end{codeblock} + +\indexlibrarymember{operator()}{clock_time_conversion}% +\begin{itemdecl} +template + auto operator()(const utc_time& t) const + -> decltype(DestClock::from_utc(t)); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +This function does not participate in overload resolution unless +\tcode{DestClock::from_utc(t)} is well-formed. +If \tcode{DestClock::from_utc(t)} does not return +\tcode{time_point}, +where \tcode{Duration} is a valid \tcode{chrono::duration} specialization, +the program is ill-formed. + +\pnum +\returns \tcode{DestClock::from_utc(t)}. +\end{itemdescr} + +\rSec4[time.clock.cast.fn]{Function template \tcode{clock_cast}} + +\indexlibrary{\idxcode{clock_cast}}% +\begin{itemdecl} +template + auto clock_cast(const time_point& t); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +This function does not participate in overload resolution unless +at least one of the following clock time conversion expressions +is well-formed: + +\begin{itemize} +\item +\begin{codeblock} +clock_time_conversion{}(t) +\end{codeblock} + +\item +\begin{codeblock} +clock_time_conversion{}( + clock_time_conversion{}(t)) +\end{codeblock} + +\item +\begin{codeblock} +clock_time_conversion{}( + clock_time_conversion{}(t)) +\end{codeblock} + +\item +\begin{codeblock} +clock_time_conversion{}( + clock_time_conversion{}( + clock_time_conversion{}(t))) +\end{codeblock} + +\item +\begin{codeblock} +clock_time_conversion{}( + clock_time_conversion{}( + clock_time_conversion{}(t))) +\end{codeblock} +\end{itemize} + +A clock time conversion expression is considered better than +another clock time conversion expression if it involves fewer +\tcode{operator()} calls on \tcode{clock_time_conversion} +specializations. +If, among the well-formed clock time conversion expressions +from the above list, there is not a unique best expression, +the \tcode{clock_cast} is ambiguous and the program is ill-formed. + +\pnum +\returns +The best well-formed clock time conversion expression in the above list. +\end{itemdescr} + +\rSec2[time.cal]{The civil calendar} + +\rSec3[time.cal.general]{In general} + +\pnum +The types in \ref{time.cal} describe the civil (Gregorian) calendar +and its relationship to \tcode{sys_days} and \tcode{local_days}. + +\rSec3[time.cal.last]{Class \tcode{last_spec}} +\indexlibrary{\idxcode{last_spec}}% + +\begin{codeblock} +namespace std::chrono { + struct last_spec { + explicit last_spec() = default; + }; +} +\end{codeblock} + +\pnum +The type \tcode{last_spec} is used +in conjunction with other calendar types +to specify the last in a sequence. +For example, depending on context, +it can represent the last day of a month, +or the last day of the week of a month. + +\rSec3[time.cal.day]{Class \tcode{day}} + +\rSec4[time.cal.day.overview]{Overview} +\indexlibrary{\idxcode{day}} + +\begin{codeblock} +namespace std::chrono { + class day { + unsigned char d_; // \expos + public: + day() = default; + explicit constexpr day(unsigned d) noexcept; + + constexpr day& operator++() noexcept; + constexpr day operator++(int) noexcept; + constexpr day& operator--() noexcept; + constexpr day operator--(int) noexcept; + + constexpr day& operator+=(const days& d) noexcept; + constexpr day& operator-=(const days& d) noexcept; + + explicit constexpr operator unsigned() const noexcept; + constexpr bool ok() const noexcept; + }; +} +\end{codeblock} + +\pnum +\tcode{day} represents a day of a month. +It normally holds values in the range 1 to 31, +but may hold non-negative values outside this range. +It can be constructed with any \tcode{unsigned} value, +which will be subsequently truncated to fit into \tcode{day}'s unspecified internal storage. +\tcode{day} is \tcode{EqualityComparable} (Table~\ref{tab:equalitycomparable}) +and \tcode{LessThanComparable} (Table~\ref{tab:lessthancomparable}), +and participates in basic arithmetic with \tcode{days} objects, +which represent a difference between two \tcode{day} objects. + +\pnum +\tcode{day} is a trivially copyable and standard-layout class type. + +\rSec4[time.cal.day.members]{Member functions} + +\indexlibrary{\idxcode{day}!constructor}% +\begin{itemdecl} +explicit constexpr day(unsigned d) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{day} by +initializing \tcode{d_} with \tcode{d}. +The value held is unspecified if \tcode{d} is not in the range \crange{0}{255}. +\end{itemdescr} + +\indexlibrarymember{operator++}{day}% +\begin{itemdecl} +constexpr day& operator++() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{++d_}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator++}{day}% +\begin{itemdecl} +constexpr day operator++(int) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{++(*this)}. + +\pnum +\returns A copy of \tcode{*this} as it existed on entry to this member function. +\end{itemdescr} + +\indexlibrarymember{operator--}{day}% +\begin{itemdecl} +constexpr day& operator--() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{--d_}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator--}{day}% +\begin{itemdecl} +constexpr day operator--(int) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{--(*this)}. + +\pnum +\returns A copy of \tcode{*this} as it existed on entry to this member function. +\end{itemdescr} + +\indexlibrarymember{operator+=}{day}% +\begin{itemdecl} +constexpr day& operator+=(const days& d) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this + d}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator-=}{day}% +\begin{itemdecl} +constexpr day& operator-=(const days& d) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this - d}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator unsigned}{day}% +\begin{itemdecl} +explicit constexpr operator unsigned() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{d_}. +\end{itemdescr} + +\indexlibrarymember{ok}{day}% +\begin{itemdecl} +constexpr bool ok() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{1 <= d_ \&\& d_ <= 31}. +\end{itemdescr} + +\rSec4[time.cal.day.nonmembers]{Non-member functions} + +\indexlibrarymember{operator==}{day}% +\begin{itemdecl} +constexpr bool operator==(const day& x, const day& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{unsigned\{x\} == unsigned\{y\}}. +\end{itemdescr} + +\indexlibrarymember{operator<}{day}% +\begin{itemdecl} +constexpr bool operator<(const day& x, const day& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{unsigned\{x\} < unsigned\{y\}}. +\end{itemdescr} + +\indexlibrarymember{operator+}{day}% +\begin{itemdecl} +constexpr day operator+(const day& x, const days& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{day(unsigned\{x\} + y.count())}. +\end{itemdescr} + +\indexlibrarymember{operator+}{day}% +\begin{itemdecl} +constexpr day operator+(const days& x, const day& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y + x}. +\end{itemdescr} + +\indexlibrarymember{operator-}{day}% +\begin{itemdecl} +constexpr day operator-(const day& x, const days& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x + -y}. +\end{itemdescr} + +\indexlibrarymember{operator-}{day}% +\begin{itemdecl} +constexpr days operator-(const day& x, const day& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{days\{int(unsigned\{x\}) - int(unsigned\{y\})}. +\end{itemdescr} + +\indexlibrarymember{operator<<}{day}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const day& d); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Inserts \tcode{format(fmt, d)} +where \tcode{fmt} is \tcode{"\%d"} widened to \tcode{charT}. +If \tcode{!d.ok()}, appends with \tcode{" is not a valid day"}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{to_stream}{day}% +\begin{itemdecl} +template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, const day& d); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Streams \tcode{d} into \tcode{os} using +the format specified by the NTCTS \tcode{fmt}. +\tcode{fmt} encoding follows the rules specified in \ref{time.format}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{from_stream}{day}% +\begin{itemdecl} +template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + day& d, basic_string* abbrev = nullptr, + minutes* offset = nullptr); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Attempts to parse the input stream \tcode{is} +into the \tcode{day} \tcode{d} using +the format flags given in the NTCTS \tcode{fmt} +as specified in \ref{time.parse}. +If the parse fails to decode a valid day, +\tcode{is.setstate(ios_base::failbit)} shall be called +and \tcode{d} shall not be modified. +If \tcode{\%Z} is used and successfully parsed, +that value will be assigned to \tcode{*abbrev} if \tcode{abbrev} is non-null. +If \tcode{\%z} (or a modified variant) is used and successfully parsed, +that value will be assigned to \tcode{*offset} if \tcode{offset} is non-null. + +\pnum +\returns \tcode{is}. +\end{itemdescr} + +\indexlibrarymember{operator""""d}{day}% +\begin{itemdecl} +constexpr day operator""d(unsigned long long d) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{day\{static_cast(d)\}}. +\end{itemdescr} + +\rSec3[time.cal.month]{Class \tcode{month}} + +\rSec4[time.cal.month.overview]{Overview} +\indexlibrary{\idxcode{month}} + +\begin{codeblock} +namespace std::chrono { + class month { + unsigned char m_; // \expos + public: + month() = default; + explicit constexpr month(unsigned m) noexcept; + + constexpr month& operator++() noexcept; + constexpr month operator++(int) noexcept; + constexpr month& operator--() noexcept; + constexpr month operator--(int) noexcept; + + constexpr month& operator+=(const months& m) noexcept; + constexpr month& operator-=(const months& m) noexcept; + + explicit constexpr operator unsigned() const noexcept; + constexpr bool ok() const noexcept; + }; +} +\end{codeblock} + +\pnum +\tcode{month} represents a month of a year. +It normally holds values in the range 1 to 12, +but may hold non-negative values outside this range. +It can be constructed with any \tcode{unsigned} value, +which will be subsequently truncated to fit into \tcode{month}'s unspecified internal storage. +\tcode{month} is \tcode{EqualityComparable} (Table~\ref{tab:equalitycomparable}) +and \tcode{LessThanComparable} (Table~\ref{tab:lessthancomparable}), +and participates in basic arithmetic with \tcode{months} objects, +which represent a difference between two \tcode{month} objects. + +\pnum +\tcode{month} is a trivially copyable and standard-layout class type. + +\rSec4[time.cal.month.members]{Member functions} + +\indexlibrary{\idxcode{month}!constructor}% +\begin{itemdecl} +explicit constexpr month(unsigned m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{month} by +initializing \tcode{m_} with \tcode{m}. +The value held is unspecified if \tcode{m} is not in the range \crange{0}{255}. +\end{itemdescr} + +\indexlibrarymember{operator++}{month}% +\begin{itemdecl} +constexpr month& month::operator++() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this += months\{1\}}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator++}{month}% +\begin{itemdecl} +constexpr month operator++(int) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{++(*this)}. + +\pnum +\returns A copy of \tcode{*this} as it existed on entry to this member function. +\end{itemdescr} + +\indexlibrarymember{operator--}{month}% +\begin{itemdecl} +constexpr month& operator--() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this -= months\{1\}}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator--}{month}% +\begin{itemdecl} +constexpr month operator--(int) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{--(*this)}. + +\pnum +\returns A copy of \tcode{*this} as it existed on entry to this member function. +\end{itemdescr} + +\indexlibrarymember{operator+=}{month}% +\begin{itemdecl} +constexpr month& operator+=(const months& m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this + m}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator-=}{month}% +\begin{itemdecl} +constexpr month& operator-=(const months& m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this - m}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator unsigned}{month}% +\begin{itemdecl} +explicit constexpr month::operator unsigned() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{m_}. +\end{itemdescr} + +\indexlibrarymember{ok}{month}% +\begin{itemdecl} +constexpr bool month::ok() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{1 <= m_ \&\& m_ <= 12}. +\end{itemdescr} + +\rSec4[time.cal.month.nonmembers]{Non-member functions} + +\indexlibrarymember{operator==}{month}% +\begin{itemdecl} +constexpr bool operator==(const month& x, const month& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{unsigned\{x\} == unsigned\{y\}}. +\end{itemdescr} + +\indexlibrarymember{operator<}{month}% +\begin{itemdecl} +constexpr bool operator<(const month& x, const month& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{unsigned\{x\} < unsigned\{y\}}. +\end{itemdescr} + +\indexlibrarymember{operator+}{month}% +\begin{itemdecl} +constexpr month operator+(const month& x, const months& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\begin{codeblock} +month{modulo(static_cast(unsigned{x}) + (y.count() - 1), 12) + 1} +\end{codeblock} +where \tcode{modulo(n, 12)} computes the remainder of \tcode{n} divided by 12 using Euclidean division. +\begin{note} +Given a divisor of 12, Euclidean division truncates towards negative infinity and +always produces a remainder in the range of \crange{0}{11}. +Assuming no overflow in the signed summation, +this operation results in a \tcode{month} holding a value in the range \crange{1}{12} even if \tcode{!x.ok()}. +\end{note} +\begin{example} +\tcode{February + months\{11\} == January}. +\end{example} +\end{itemdescr} + +\indexlibrarymember{operator+}{month}% +\begin{itemdecl} +constexpr month operator+(const months& x, const month& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y + x}. +\end{itemdescr} + +\indexlibrarymember{operator-}{month}% +\begin{itemdecl} +constexpr month operator-(const month& x, const months& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x + -y}. +\end{itemdescr} + +\indexlibrarymember{operator-}{month}% +\begin{itemdecl} +constexpr months operator-(const month& x, const month& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +If \tcode{x.ok() == true} +and \tcode{y.ok() == true}, +returns a value \tcode{m} +in the range \crange{months\{0\}}{months\{11\}} +satisfying \tcode{y + m == x}. +Otherwise the value returned is unspecified. +\begin{example} +\tcode{January - February == months\{11\}}. +\end{example} +\end{itemdescr} + +\indexlibrarymember{operator<<}{month}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const month& m); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +If \tcode{m.ok() == true} +inserts \tcode{format(os.getloc(), fmt, m)} +where fmt is \tcode{"\%b"} widened to \tcode{charT}. +Otherwise inserts \tcode{unsigned\{m\} << " is not a valid month"}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{to_stream}{month}% +\begin{itemdecl} +template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, const month& m); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Streams \tcode{m} into \tcode{os} using +the format specified by the NTCTS \tcode{fmt}. +\tcode{fmt} encoding follows the rules specified in \ref{time.format}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{from_stream}{month}% +\begin{itemdecl} +template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + month& m, basic_string* abbrev = nullptr, + minutes* offset = nullptr); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Attempts to parse the input stream \tcode{is} +into the \tcode{month} \tcode{m} using +the format flags given in the NTCTS \tcode{fmt} +as specified in \ref{time.parse}. +If the parse fails to decode a valid month, +\tcode{is.setstate(ios_base::failbit)} shall be called +and \tcode{m} shall not be modified. +If \tcode{\%Z} is used and successfully parsed, +that value will be assigned to \tcode{*abbrev} if \tcode{abbrev} is non-null. +If \tcode{\%z} (or a modified variant) is used and successfully parsed, +that value will be assigned to \tcode{*offset} if \tcode{offset} is non-null. + +\pnum +\returns \tcode{is}. +\end{itemdescr} + +\rSec3[time.cal.year]{Class \tcode{year}} + +\rSec4[time.cal.year.overview]{Overview} +\indexlibrary{\idxcode{year}} + +\begin{codeblock} +namespace std::chrono { + class year { + short y_; // \expos + public: + year() = default; + explicit constexpr year(int y) noexcept; + + constexpr year& operator++() noexcept; + constexpr year operator++(int) noexcept; + constexpr year& operator--() noexcept; + constexpr year operator--(int) noexcept; + + constexpr year& operator+=(const years& y) noexcept; + constexpr year& operator-=(const years& y) noexcept; + + constexpr year operator+() const noexcept; + constexpr year operator-() const noexcept; + + constexpr bool is_leap() const noexcept; + + explicit constexpr operator int() const noexcept; + constexpr bool ok() const noexcept; + + static constexpr year min() noexcept; + static constexpr year max() noexcept; + }; +} +\end{codeblock} + +\pnum +\tcode{year} represents a year in the civil calendar. +It can represent values in the range \crange{min()}{max()}. +It can be constructed with any \tcode{int} value, +which will be subsequently truncated to fit into \tcode{year}'s unspecified internal storage. +\tcode{year} is \tcode{EqualityComparable} (Table~\ref{tab:equalitycomparable}) +and \tcode{LessThanComparable} (Table~\ref{tab:lessthancomparable}), +and participates in basic arithmetic with \tcode{years} objects, +which represent a difference between two \tcode{year} objects. + +\pnum +\tcode{year} is a trivially copyable and standard-layout class type. + +\rSec4[time.cal.year.members]{Member functions} + +\indexlibrary{\idxcode{year}!constructor}% +\begin{itemdecl} +explicit constexpr year(int y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{year} by +initializing \tcode{y_} with \tcode{y}. +The value held is unspecified if \tcode{y} is not in the range \crange{-32767}{32767}. +\end{itemdescr} + +\indexlibrarymember{operator++}{year}% +\begin{itemdecl} +constexpr year& operator++() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{++y_}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator++}{year}% +\begin{itemdecl} +constexpr year operator++(int) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{++(*this)}. + +\pnum +\returns A copy of \tcode{*this} as it existed on entry to this member function. +\end{itemdescr} + +\indexlibrarymember{operator--}{year}% +\begin{itemdecl} +constexpr year& operator--() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{--y_}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator--}{year}% +\begin{itemdecl} +constexpr year operator--(int) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{--(*this)}. + +\pnum +\returns A copy of \tcode{*this} as it existed on entry to this member function. +\end{itemdescr} + +\indexlibrarymember{operator+=}{year}% +\begin{itemdecl} +constexpr year& operator+=(const years& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this + y}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator-=}{year}% +\begin{itemdecl} +constexpr year& operator-=(const years& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this - y}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator+}{year}% +\begin{itemdecl} +constexpr year operator+() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator-}{year}% +\begin{itemdecl} +constexpr year year::operator-() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{year\{-y_\}}. +\end{itemdescr} + +\indexlibrarymember{is_leap}{year}% +\begin{itemdecl} +constexpr bool is_leap() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y_ \% 4 == 0 \&\& (y_ \% 100 != 0 || y_ \% 400 == 0)}. +\end{itemdescr} + +\indexlibrarymember{operator int}{year}% +\begin{itemdecl} +explicit constexpr operator int() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y_}. +\end{itemdescr} + +\indexlibrarymember{ok}{year}% +\begin{itemdecl} +constexpr bool ok() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{min() <= y_ \&\& y_ <= max()}. +\end{itemdescr} + +\indexlibrarymember{min}{year}% +\begin{itemdecl} +static constexpr year min() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{year\{-32767\}}. +\end{itemdescr} + +\indexlibrarymember{max}{year}% +\begin{itemdecl} +static constexpr year max() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{year\{32767\}}. +\end{itemdescr} + +\rSec4[time.cal.year.nonmembers]{Non-member functions} + +\indexlibrarymember{operator==}{year}% +\begin{itemdecl} +constexpr bool operator==(const year& x, const year& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{int\{x\} == int\{y\}}. +\end{itemdescr} + +\indexlibrarymember{operator<}{year}% +\begin{itemdecl} +constexpr bool operator<(const year& x, const year& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{int\{x\} < int\{y\}}. +\end{itemdescr} + +\indexlibrarymember{operator+}{year}% +\begin{itemdecl} +constexpr year operator+(const year& x, const years& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{year\{int\{x\} + y.count()\}}. +\end{itemdescr} + +\indexlibrarymember{operator+}{year}% +\begin{itemdecl} +constexpr year operator+(const years& x, const year& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y + x}. +\end{itemdescr} + +\indexlibrarymember{operator-}{year}% +\begin{itemdecl} +constexpr year operator-(const year& x, const years& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x + -y}. +\end{itemdescr} + +\indexlibrarymember{operator-}{year}% +\begin{itemdecl} +constexpr years operator-(const year& x, const year& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{years\{int\{x\} - int\{y\}\}}. +\end{itemdescr} + +\indexlibrarymember{operator<<}{year}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const year& y); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Inserts \tcode{format(fmt, y)} where \tcode{fmt} is +\tcode{"\%Y"} widened to \tcode{charT}. +If \tcode{!y.ok()}, appends with \tcode{" is not a valid year"}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{to_stream}{year}% +\begin{itemdecl} +template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, const year& y); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Streams \tcode{y} into \tcode{os} using +the format specified by the NTCTS \tcode{fmt}. +\tcode{fmt} encoding follows the rules specified in \ref{time.format}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{from_stream}{year}% +\begin{itemdecl} +template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + year& y, basic_string* abbrev = nullptr, + minutes* offset = nullptr); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Attempts to parse the input stream \tcode{is} +into the \tcode{year} \tcode{y} using +the format flags given in the NTCTS \tcode{fmt} +as specified in \ref{time.parse}. +If the parse fails to decode a valid year, +\tcode{is.setstate(ios_base::failbit)} shall be called +and \tcode{y} shall not be modified. +If \tcode{\%Z} is used and successfully parsed, +that value will be assigned to \tcode{*abbrev} if \tcode{abbrev} is non-null. +If \tcode{\%z} (or a modified variant) is used and successfully parsed, +that value will be assigned to \tcode{*offset} if \tcode{offset} is non-null. + +\pnum +\returns \tcode{is}. +\end{itemdescr} + +\indexlibrarymember{operator""""y}{year}% +\begin{itemdecl} +constexpr year operator""y(unsigned long long y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{year\{static_cast(y)\}}. +\end{itemdescr} + +\rSec3[time.cal.wd]{Class \tcode{weekday}} + +\rSec4[time.cal.wd.overview]{Overview} +\indexlibrary{\idxcode{weekday}} + +\begin{codeblock} +namespace std::chrono { + class weekday { + unsigned char wd_; // \expos + public: + weekday() = default; + explicit constexpr weekday(unsigned wd) noexcept; + constexpr weekday(const sys_days& dp) noexcept; + explicit constexpr weekday(const local_days& dp) noexcept; + + constexpr weekday& operator++() noexcept; + constexpr weekday operator++(int) noexcept; + constexpr weekday& operator--() noexcept; + constexpr weekday operator--(int) noexcept; + + constexpr weekday& operator+=(const days& d) noexcept; + constexpr weekday& operator-=(const days& d) noexcept; + + explicit constexpr operator unsigned() const noexcept; + constexpr bool ok() const noexcept; + + constexpr weekday_indexed operator[](unsigned index) const noexcept; + constexpr weekday_last operator[](last_spec) const noexcept; + }; +} +\end{codeblock} + +\pnum +\tcode{weekday} represents a day of the week in the civil calendar. +It normally holds values in the range \tcode{0} to \tcode{6}, +corresponding to Sunday through Saturday, but +it may hold non-negative values outside this range. +It can be constructed with any \tcode{unsigned} value, +which will be subsequently truncated to fit into \tcode{weekday}'s unspecified internal storage. +\tcode{weekday} is \tcode{EqualityComparable} (Table~\ref{tab:equalitycomparable}). +\begin{note} +\tcode{weekday} is not +\tcode{LessThanComparable} +because there is no universal consensus on which day is the first day of the week. +\tcode{weekday}'s arithmetic operations treat the days of the week as a circular range, +with no beginning and no end. +\end{note} + +\pnum +\tcode{weekday} is a trivially copyable and standard-layout class type. + +\rSec4[time.cal.wd.members]{Member functions} + +\indexlibrary{\idxcode{weekday}!constructor}% +\begin{itemdecl} +explicit constexpr weekday(unsigned wd) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{weekday} by +initializing \tcode{wd_} with \tcode{wd}. +The value held is unspecified if \tcode{wd} is not in the range \crange{0}{255}. +\end{itemdescr} + +\indexlibrary{\idxcode{weekday}!constructor}% +\begin{itemdecl} +constexpr weekday(const sys_days& dp) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{weekday} by +computing what day of the week corresponds to the \tcode{sys_days} \tcode{dp}, +and representing that day of the week in \tcode{wd_}. + +\pnum +\begin{example} +If \tcode{dp} represents 1970-01-01, +the constructed \tcode{weekday} represents Thursday +by storing \tcode{4} in \tcode{wd_}. +\end{example} +\end{itemdescr} + +\indexlibrary{\idxcode{weekday}!constructor}% +\begin{itemdecl} +explicit constexpr weekday(const local_days& dp) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{weekday} by +computing what day of the week corresponds to the \tcode{local_days} \tcode{dp}, +and representing that day of the week in \tcode{wd_}. + +\pnum +\remarks +The value after construction is identical to that constructed from +\tcode{sys_days\{dp.time_since_epoch()\}}. +\end{itemdescr} + +\indexlibrarymember{operator++}{weekday}% +\begin{itemdecl} +constexpr weekday& operator++() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this += days\{1\}}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator++}{weekday}% +\begin{itemdecl} +constexpr weekday operator++(int) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{++(*this)}. + +\pnum +\returns A copy of \tcode{*this} as it existed on entry to this member function. +\end{itemdescr} + +\indexlibrarymember{operator--}{weekday}% +\begin{itemdecl} +constexpr weekday& operator--() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this -= days\{1\}}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator--}{weekday}% +\begin{itemdecl} +constexpr weekday operator--(int) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{--(*this)}. + +\pnum +\returns A copy of \tcode{*this} as it existed on entry to this member function. +\end{itemdescr} + +\indexlibrarymember{operator+=}{weekday}% +\begin{itemdecl} +constexpr weekday& operator+=(const days& d) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this + d}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator-=}{weekday}% +\begin{itemdecl} +constexpr weekday& operator-=(const days& d) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this - d}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator unsigned}{weekday}% +\begin{itemdecl} +explicit constexpr operator unsigned() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{wd_}. +\end{itemdescr} + +\indexlibrarymember{ok}{weekday}% +\begin{itemdecl} +constexpr bool ok() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{wd_ <= 6}. +\end{itemdescr} + +\indexlibrarymember{operator[]}{weekday}% +\begin{itemdecl} +constexpr weekday_indexed operator[](unsigned index) const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{\{*this, index\}}. +\end{itemdescr} + +\indexlibrarymember{operator[]}{weekday}% +\begin{itemdecl} +constexpr weekday_last operator[](last_spec) const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{weekday_last\{*this\}}. +\end{itemdescr} + +\rSec4[time.cal.wd.nonmembers]{Non-member functions} + +\indexlibrarymember{operator==}{weekday}% +\begin{itemdecl} +constexpr bool operator==(const weekday& x, const weekday& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{unsigned\{x\} == unsigned\{y\}}. +\end{itemdescr} + +\indexlibrarymember{operator+}{weekday}% +\begin{itemdecl} +constexpr weekday operator+(const weekday& x, const days& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\begin{codeblock} +weekday{modulo(static_cast(unsigned{x}) + y.count(), 7)} +\end{codeblock} +where \tcode{modulo(n, 7)} computes the remainder of \tcode{n} divided by 7 using Euclidean division. +\begin{note} +Given a divisor of 7, Euclidean division truncates towards negative infinity and +always produces a remainder in the range of \crange{0}{6}. +Assuming no overflow in the signed summation, +this operation results in a \tcode{weekday} holding a value in the range \crange{0}{6} even if \tcode{!x.ok()}. +\end{note} +\begin{example} +\tcode{Monday + days\{6\} == Sunday}. +\end{example} +\end{itemdescr} + +\indexlibrarymember{operator+}{weekday}% +\begin{itemdecl} +constexpr weekday operator+(const days& x, const weekday& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y + x}. +\end{itemdescr} + +\indexlibrarymember{operator-}{weekday}% +\begin{itemdecl} +constexpr weekday operator-(const weekday& x, const days& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x + -y}. +\end{itemdescr} + +\indexlibrarymember{operator-}{weekday}% +\begin{itemdecl} +constexpr days operator-(const weekday& x, const weekday& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +If \tcode{x.ok() == true} +and \tcode{y.ok() == true}, +returns a value \tcode{d} +in the range \crange{days\{0\}}{days\{6\}} +satisfying \tcode{y + d == x}. +Otherwise the value returned is unspecified. +\begin{example} +\tcode{Sunday - Monday == days\{6\}}. +\end{example} +\end{itemdescr} + +\indexlibrarymember{operator<<}{weekday}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const weekday& wd); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +If \tcode{wd.ok() == true} +inserts \tcode{format(os.getloc(), fmt, wd)} +where \tcode{fmt} is \tcode{"\%a"} widened to \tcode{charT}. +Otherwise inserts \tcode{unsigned\{wd\} << " is not a valid weekday"}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{to_stream}{weekday}% +\begin{itemdecl} +template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, const weekday& wd); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Streams \tcode{wd} into \tcode{os} using +the format specified by the NTCTS \tcode{fmt}. +\tcode{fmt} encoding follows the rules specified in \ref{time.format}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{from_stream}{weekday}% +\begin{itemdecl} +template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + weekday& wd, basic_string* abbrev = nullptr, + minutes* offset = nullptr); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Attempts to parse the input stream \tcode{is} +into the \tcode{weekday} \tcode{wd} using +the format flags given in the NTCTS \tcode{fmt} +as specified in \ref{time.parse}. +If the parse fails to decode a valid weekday, +\tcode{is.setstate(ios_base::failbit)} shall be called +and \tcode{wd} shall not be modified. +If \tcode{\%Z} is used and successfully parsed, +that value will be assigned to \tcode{*abbrev} if \tcode{abbrev} is non-null. +If \tcode{\%z} (or a modified variant) is used and successfully parsed, +that value will be assigned to \tcode{*offset} if \tcode{offset} is non-null. + +\pnum +\returns \tcode{is}. +\end{itemdescr} + +\rSec3[time.cal.wdidx]{Class \tcode{weekday_indexed}} + +\rSec4[time.cal.wdidx.overview]{Overview} +\indexlibrary{\idxcode{weekday_indexed}} + +\begin{codeblock} +namespace std::chrono { + class weekday_indexed { + chrono::weekday wd_; // \expos + unsigned char index_; // \expos + + public: + weekday_indexed() = default; + constexpr weekday_indexed(const chrono::weekday& wd, unsigned index) noexcept; + + constexpr chrono::weekday weekday() const noexcept; + constexpr unsigned index() const noexcept; + constexpr bool ok() const noexcept; + }; +} +\end{codeblock} + +\pnum +\tcode{weekday_indexed} represents a \tcode{weekday} +and a small index in the range 1 to 5. +This class is used to represent the +first, second, third, fourth, or fifth weekday of a month. + +\pnum +\begin{note} +A \tcode{weekday_indexed} object +can be constructed by indexing a \tcode{weekday} +with an \tcode{unsigned}. +\end{note} +\begin{example} +\begin{codeblock} +constexpr auto wdi = Sunday[2]; // \tcode{wdi} is the second Sunday of an as yet unspecified month +static_assert(wdi.weekday() == Sunday); +static_assert(wdi.index() == 2); +\end{codeblock} +\end{example} + +\pnum +\tcode{weekday_indexed} is a trivially copyable and standard-layout class type. + +\rSec4[time.cal.wdidx.members]{Member functions} + +\indexlibrary{\idxcode{weekday_indexed}!constructor}% +\begin{itemdecl} +constexpr weekday_indexed(const chrono::weekday& wd, unsigned index) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{weekday_indexed} by +initializing \tcode{wd_} with \tcode{wd} and \tcode{index_} with \tcode{index}. +The values held are unspecified if \tcode{!wd.ok()} or \tcode{index} is not in the range \crange{1}{5}. +\end{itemdescr} + +\indexlibrarymember{weekday}{weekday_indexed}% +\begin{itemdecl} +constexpr chrono::weekday weekday() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{wd_}. +\end{itemdescr} + +\indexlibrarymember{index}{weekday_indexed}% +\begin{itemdecl} +constexpr unsigned index() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{index_}. +\end{itemdescr} + +\indexlibrarymember{ok}{weekday_indexed}% +\begin{itemdecl} +constexpr bool ok() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{wd_.ok() \&\& 1 <= index_ \&\& index_ <= 5}. +\end{itemdescr} + +\rSec4[time.cal.wdidx.nonmembers]{Non-member functions} + +\indexlibrarymember{operator==}{weekday_indexed}% +\begin{itemdecl} +constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x.weekday() == y.weekday() \&\& x.index() == y.index()}. +\end{itemdescr} + +\indexlibrarymember{operator<<}{weekday_indexed}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const weekday_indexed& wdi); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +\tcode{os << wdi.weekday() << '[' << wdi.index()}. +If \tcode{wdi.index()} is in the range \crange{1}{5}, +appends with \tcode{']'}, +otherwise +appends with \tcode{" is not a valid index]"}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\rSec3[time.cal.wdlast]{Class \tcode{weekday_last}} + +\rSec4[time.cal.wdlast.overview]{Overview} +\indexlibrary{\idxcode{weekday_last}} + +\begin{codeblock} +namespace std::chrono { + class weekday_last { + chrono::weekday wd_; // \expos + + public: + explicit constexpr weekday_last(const chrono::weekday& wd) noexcept; + + constexpr chrono::weekday weekday() const noexcept; + constexpr bool ok() const noexcept; + }; +} +\end{codeblock} + +\pnum +\tcode{weekday_last} represents the last weekday of a month. + +\pnum +\begin{note} +A \tcode{weekday_last} object +can be constructed by indexing a \tcode{weekday} with \tcode{last}. +\end{note} +\begin{example} +\begin{codeblock} +constexpr auto wdl = Sunday[last]; // \tcode{wdl} is the last Sunday of an as yet unspecified month +static_assert(wdl.weekday() == Sunday); +\end{codeblock} +\end{example} + +\pnum +\tcode{weekday_last} is a trivially copyable and standard-layout class type. + +\rSec4[time.cal.wdlast.members]{Member functions} + +\indexlibrary{\idxcode{weekday_last}!constructor}% +\begin{itemdecl} +explicit constexpr weekday_last(const chrono::weekday& wd) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{weekday_last} by +initializing \tcode{wd_} with \tcode{wd}. +\end{itemdescr} + +\indexlibrarymember{weekday_last}{weekday}% +\begin{itemdecl} +constexpr chrono::weekday weekday() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{wd_}. +\end{itemdescr} + +\indexlibrarymember{ok}{weekday_last}% +\begin{itemdecl} +constexpr bool ok() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{wd_.ok()}. +\end{itemdescr} + +\rSec4[time.cal.wdlast.nonmembers]{Non-member functions} + +\indexlibrarymember{operator==}{weekday_last}% +\begin{itemdecl} +constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x.weekday() == y.weekday()}. +\end{itemdescr} + +\indexlibrarymember{operator<<}{weekday_last}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const weekday_last& wdl); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{os << wdl.weekday() << "[last]"}. +\end{itemdescr} + +\rSec3[time.cal.md]{Class \tcode{month_day}} + +\rSec4[time.cal.md.overview]{Overview} +\indexlibrary{\idxcode{month_day}} + +\begin{codeblock} +namespace std::chrono { + class month_day { + chrono::month m_; // \expos + chrono::day d_; // \expos + + public: + month_day() = default; + constexpr month_day(const chrono::month& m, const chrono::day& d) noexcept; + + constexpr chrono::month month() const noexcept; + constexpr chrono::day day() const noexcept; + constexpr bool ok() const noexcept; + }; +} +\end{codeblock} + +\pnum +\tcode{month_day} represents a specific day of a specific month, +but with an unspecified year. +\tcode{month_day} is \tcode{EqualityComparable} (Table~\ref{tab:equalitycomparable}) +and \tcode{LessThanComparable} (Table~\ref{tab:lessthancomparable}). + +\pnum +\tcode{month_day} is a trivially copyable and standard-layout class type. + +\rSec4[time.cal.md.members]{Member functions} + +\indexlibrary{\idxcode{month_day}!constructor}% +\begin{itemdecl} +constexpr month_day(const chrono::month& m, const chrono::day& d) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{month_day} by +initializing \tcode{m_} with \tcode{m}, and \tcode{d_} with \tcode{d}. +\end{itemdescr} + +\indexlibrarymember{month}{month_day}% +\begin{itemdecl} +constexpr chrono::month month() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{m_}. +\end{itemdescr} + +\indexlibrarymember{day}{month_day}% +\begin{itemdecl} +constexpr chrono::day day() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{d_}. +\end{itemdescr} + +\indexlibrarymember{ok}{month_day}% +\begin{itemdecl} +constexpr bool ok() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\tcode{true} if +\tcode{m_.ok()} is \tcode{true}, +\tcode{1d <= d_}, and +\tcode{d_} is less than or equal to the number of days in month \tcode{m_}; +otherwise returns \tcode{false}. +When \tcode{m_ == February}, +the number of days is considered to be 29. +\end{itemdescr} + +\rSec4[time.cal.md.nonmembers]{Non-member functions} + +\indexlibrarymember{operator==}{month_day}% +\begin{itemdecl} +constexpr bool operator==(const month_day& x, const month_day& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x.month() == y.month() \&\& x.day() == y.day()}. +\end{itemdescr} + +\indexlibrarymember{operator<}{month_day}% +\begin{itemdecl} +constexpr bool operator<(const month_day& x, const month_day& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +If \tcode{x.month() < y.month()} returns \tcode{true}. +Otherwise, if \tcode{x.month() > y.month()} returns \tcode{false}. +Otherwise, returns \tcode{x.day() < y.day()}. +\end{itemdescr} + +\indexlibrarymember{operator<<}{month_day}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const month_day& md); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{os << md.month() << '/' << md.day()}. +\end{itemdescr} + +\indexlibrarymember{to_stream}{month_day}% +\begin{itemdecl} +template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, const month_day& md); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Streams \tcode{md} into \tcode{os} using +the format specified by the NTCTS \tcode{fmt}. +\tcode{fmt} encoding follows the rules specified in \ref{time.format}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{from_stream}{month_day}% +\begin{itemdecl} +template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + month_day& md, basic_string* abbrev = nullptr, + minutes* offset = nullptr); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Attempts to parse the input stream \tcode{is} +into the \tcode{month_day} \tcode{md} using +the format flags given in the NTCTS \tcode{fmt} +as specified in \ref{time.parse}. +If the parse fails to decode a valid \tcode{month_day}, +\tcode{is.setstate(ios_base::failbit)} shall be called +and \tcode{md} shall not be modified. +If \tcode{\%Z} is used and successfully parsed, +that value will be assigned to \tcode{*abbrev} if \tcode{abbrev} is non-null. +If \tcode{\%z} (or a modified variant) is used and successfully parsed, +that value will be assigned to \tcode{*offset} if \tcode{offset} is non-null. + +\pnum +\returns \tcode{is}. +\end{itemdescr} + +\rSec3[time.cal.mdlast]{Class \tcode{month_day_last}} +\indexlibrary{\idxcode{month_day_last}} + +\begin{codeblock} +namespace std::chrono { + class month_day_last { + chrono::month m_; // \expos + + public: + explicit constexpr month_day_last(const chrono::month& m) noexcept; + + constexpr chrono::month month() const noexcept; + constexpr bool ok() const noexcept; + }; +} +\end{codeblock} + +\pnum +\tcode{month_day_last} represents the last day of a month. + +\pnum +\begin{note} +A \tcode{month_day_last} object +can be constructed using the expression \tcode{m/last} or \tcode{last/m}, +where \tcode{m} is an expression of type \tcode{month}. +\end{note} +\begin{example} +\begin{codeblock} +constexpr auto mdl = February/last; // \tcode{mdl} is the last day of February of an as yet unspecified year +static_assert(mdl.month() == February); +\end{codeblock} +\end{example} + +\pnum +\tcode{month_day_last} is a trivially copyable and standard-layout class type. + +\indexlibrary{\idxcode{month_day_last}!constructor}% +\begin{itemdecl} +explicit constexpr month_day_last(const chrono::month& m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{month_day_last} by +initializing \tcode{m_} with \tcode{m}. +\end{itemdescr} + +\indexlibrarymember{month}{month_day_last}% +\begin{itemdecl} +constexpr month month() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{m_}. +\end{itemdescr} + +\indexlibrarymember{ok}{month_day_last}% +\begin{itemdecl} +constexpr bool ok() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{m_.ok()}. +\end{itemdescr} + +\indexlibrarymember{operator==}{month_day_last}% +\begin{itemdecl} +constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x.month() == y.month()}. +\end{itemdescr} + +\indexlibrarymember{operator<}{month_day_last}% +\begin{itemdecl} +constexpr bool operator<(const month_day_last& x, const month_day_last& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x.month() < y.month()}. +\end{itemdescr} + +\indexlibrarymember{operator<<}{month_day_last}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const month_day_last& mdl); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{os << mdl.month() << "/last"}. +\end{itemdescr} + +\rSec3[time.cal.mwd]{Class \tcode{month_weekday}} + +\rSec4[time.cal.mwd.overview]{Overview} +\indexlibrary{\idxcode{month_weekday}} + +\begin{codeblock} +namespace std::chrono { + class month_weekday { + chrono::month m_; // \expos + chrono::weekday_indexed wdi_; // \expos + public: + constexpr month_weekday(const chrono::month& m, const chrono::weekday_indexed& wdi) noexcept; + + constexpr chrono::month month() const noexcept; + constexpr chrono::weekday_indexed weekday_indexed() const noexcept; + constexpr bool ok() const noexcept; + }; +} +\end{codeblock} + +\pnum +\tcode{month_weekday} represents the n$^\textrm{th}$ weekday of a month, +of an as yet unspecified year. +To do this the \tcode{month_weekday} stores a \tcode{month} and a \tcode{weekday_indexed}. + +\pnum +\begin{example} +\begin{codeblock} +constexpr auto mwd + = February/Tueday[3]; // \tcode{mwd} is the third Tuesday of February of an as yet unspecified year +static_assert(mwd.month() == February); +static_assert(mwd.weekday_indexed() == Tueday[3]); +\end{codeblock} +\end{example} + +\pnum +\tcode{month_weekday} is a trivially copyable and standard-layout class type. + +\rSec4[time.cal.mwd.members]{Member functions} + +\indexlibrary{\idxcode{month_weekday}!constructor}% +\begin{itemdecl} +constexpr month_weekday(const chrono::month& m, const chrono::weekday_indexed& wdi) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{month_weekday} by +initializing \tcode{m_} with \tcode{m}, and \tcode{wdi_} with \tcode{wdi}. +\end{itemdescr} + +\indexlibrarymember{month}{month_weekday}% +\begin{itemdecl} +constexpr chrono::month month() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{m_}. +\end{itemdescr} + +\indexlibrarymember{weekday_indexed}{month_weekday}% +\begin{itemdecl} +constexpr chrono::weekday_indexed weekday_indexed() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{wdi_}. +\end{itemdescr} + +\indexlibrarymember{ok}{month_weekday}% +\begin{itemdecl} +constexpr bool ok() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{m_.ok() \&\& wdi_.ok()}. +\end{itemdescr} + +\rSec4[time.cal.mwd.nonmembers]{Non-member functions} + +\indexlibrarymember{operator==}{month_weekday}% +\begin{itemdecl} +constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x.month() == y.month() \&\& x.weekday_indexed() == y.weekday_indexed()}. +\end{itemdescr} + +\indexlibrarymember{operator<<}{month_weekday}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const month_weekday& mwd); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{os << mwd.month() << '/' << mwd.weekday_indexed()}. +\end{itemdescr} + +\rSec3[time.cal.mwdlast]{Class \tcode{month_weekday_last}} + +\rSec4[time.cal.mwdlast.overview]{Overview} +\indexlibrary{\idxcode{month_weekday_last}} + +\begin{codeblock} +namespace std::chrono { + class month_weekday_last { + chrono::month m_; // \expos + chrono::weekday_last wdl_; // \expos + public: + constexpr month_weekday_last(const chrono::month& m, + const chrono::weekday_last& wdl) noexcept; + + constexpr chrono::month month() const noexcept; + constexpr chrono::weekday_last weekday_last() const noexcept; + constexpr bool ok() const noexcept; + }; +} +\end{codeblock} + +\pnum +\tcode{month_weekday_last} represents the last weekday of a month, +of an as yet unspecified year. +To do this the \tcode{month_weekday_last} stores a \tcode{month} and a \tcode{weekday_last}. + +\pnum +\begin{example} +\begin{codeblock} +constexpr auto mwd + = February/Tueday[last]; // \tcode{mwd} is the last Tuesday of February of an as yet unspecified year +static_assert(mwd.month() == February); +static_assert(mwd.weekday_last() == Tueday[last]); +\end{codeblock} +\end{example} + +\pnum +\tcode{month_weekday_last} is a trivially copyable and standard-layout class type. + +\rSec4[time.cal.mwdlast.members]{Member functions} + +\indexlibrary{\idxcode{month_weekday_last}!constructor}% +\begin{itemdecl} +constexpr month_weekday_last(const chrono::month& m, + const chrono::weekday_last& wdl) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{month_weekday_last} by +initializing \tcode{m_} with \tcode{m}, and \tcode{wdl_} with \tcode{wdl}. +\end{itemdescr} + +\indexlibrarymember{month}{month_weekday_last}% +\begin{itemdecl} +constexpr chrono::month month() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{m_}. +\end{itemdescr} + +\indexlibrarymember{weekday_last}{month_weekday_last}% +\begin{itemdecl} +constexpr chrono::weekday_last weekday_last() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{wdl_}. +\end{itemdescr} + +\indexlibrarymember{ok}{month_weekday_last}% +\begin{itemdecl} +constexpr bool ok() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{m_.ok() \&\& wdl_.ok()}. +\end{itemdescr} + +\rSec4[time.cal.mwdlast.nonmembers]{Non-member functions} + +\indexlibrarymember{operator==}{month_weekday_last}% +\begin{itemdecl} +constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x.month() == y.month() \&\& x.weekday_last() == y.weekday_last()}. +\end{itemdescr} + +\indexlibrarymember{operator<<}{month_weekday_last}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const month_weekday_last& mwdl); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{os << mwdl.month() << '/' << mwdl.weekday_last()}. +\end{itemdescr} + +\rSec3[time.cal.ym]{Class \tcode{year_month}} + +\rSec4[time.cal.ym.overview]{Overview} +\indexlibrary{\idxcode{year_month}} + +\begin{codeblock} +namespace std::chrono { + class year_month { + chrono::year y_; // \expos + chrono::month m_; // \expos + + public: + year_month() = default; + constexpr year_month(const chrono::year& y, const chrono::month& m) noexcept; + + constexpr chrono::year year() const noexcept; + constexpr chrono::month month() const noexcept; + + constexpr year_month& operator+=(const months& dm) noexcept; + constexpr year_month& operator-=(const months& dm) noexcept; + constexpr year_month& operator+=(const years& dy) noexcept; + constexpr year_month& operator-=(const years& dy) noexcept; + + constexpr bool ok() const noexcept; + }; +} +\end{codeblock} + +\pnum +\tcode{year_month} represents a specific month of a specific year, +but with an unspecified day. +\tcode{year_month} is a field-based time point with a resolution of \tcode{months}. +\tcode{year_month} is \tcode{EqualityComparable} (Table~\ref{tab:equalitycomparable}) +and \tcode{LessThanComparable} (Table~\ref{tab:lessthancomparable}). + +\pnum +\tcode{year_month} is a trivially copyable and standard-layout class type. + +\rSec4[time.cal.ym.members]{Member functions} + +\indexlibrary{\idxcode{year_month}!constructor}% +\begin{itemdecl} +constexpr year_month(const chrono::year& y, const chrono::month& m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{year_month} by +initializing \tcode{y_} with \tcode{y}, and \tcode{m_} with \tcode{m}. +\end{itemdescr} + +\indexlibrarymember{year}{year_month}% +\begin{itemdecl} +constexpr chrono::year year() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y_}. +\end{itemdescr} + +\indexlibrarymember{month}{year_month}% +\begin{itemdecl} +constexpr chrono::month month() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{m_}. +\end{itemdescr} + +\indexlibrarymember{operator+=}{year_month}% +\begin{itemdecl} +constexpr year_month& operator+=(const months& dm) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this + dm}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator-=}{year_month}% +\begin{itemdecl} +constexpr year_month& operator-=(const months& dm) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this - dm}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator+=}{year_month}% +\begin{itemdecl} +constexpr year_month& operator+=(const years& dy) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this + dy}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator-=}{year_month}% +\begin{itemdecl} +constexpr year_month& operator-=(const years& dy) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this - dy}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{ok}{year_month}% +\begin{itemdecl} +constexpr bool ok() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y_.ok() \&\& m_.ok()}. +\end{itemdescr} + +\rSec4[time.cal.ym.nonmembers]{Non-member functions} + +\indexlibrarymember{operator==}{year_month}% +\begin{itemdecl} +constexpr bool operator==(const year_month& x, const year_month& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x.year() == y.year() \&\& x.month() == y.month()}. +\end{itemdescr} + +\indexlibrarymember{operator<}{year_month}% +\begin{itemdecl} +constexpr bool operator<(const year_month& x, const year_month& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +If \tcode{x.year() < y.year()} returns \tcode{true}. +Otherwise, if \tcode{x.year() > y.year()} returns \tcode{false}. +Otherwise, returns \tcode{x.month() < y.month()}. +\end{itemdescr} + +\indexlibrarymember{operator+}{year_month}% +\begin{itemdecl} +constexpr year_month operator+(const year_month& ym, const months& dm) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns A \tcode{year_month} value \tcode{z} such that \tcode{z - ym == dm}. + +\complexity +\bigoh{1} with respect to the value of \tcode{dm}. +\end{itemdescr} + +\indexlibrarymember{operator+}{year_month}% +\begin{itemdecl} +constexpr year_month operator+(const months& dm, const year_month& ym) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{ym + dm}. +\end{itemdescr} + +\indexlibrarymember{operator-}{year_month}% +\begin{itemdecl} +constexpr year_month operator-(const year_month& ym, const months& dm) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{ym + -dm}. +\end{itemdescr} + +\indexlibrarymember{operator-}{year_month}% +\begin{itemdecl} +constexpr months operator-(const year_month& x, const year_month& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\begin{codeblock} +x.year() - y.year() + months{static_cast(unsigned{x.month()}) - + static_cast(unsigned{y.month()})} +\end{codeblock} +\end{itemdescr} + +\indexlibrarymember{operator+}{year_month}% +\begin{itemdecl} +constexpr year_month operator+(const year_month& ym, const years& dy) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{(ym.year() + dy) / ym.month()}. +\end{itemdescr} + +\indexlibrarymember{operator+}{year_month}% +\begin{itemdecl} +constexpr year_month operator+(const years& dy, const year_month& ym) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{ym + dy}. +\end{itemdescr} + +\indexlibrarymember{operator-}{year_month}% +\begin{itemdecl} +constexpr year_month operator-(const year_month& ym, const years& dy) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{ym + -dy}. +\end{itemdescr} + +\indexlibrarymember{operator<<}{year_month}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const year_month& ym); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{os << ym.year() << '/' << ym.month()}. +\end{itemdescr} + +\indexlibrarymember{to_stream}{year_month}% +\begin{itemdecl} +template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, const year_month& ym); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Streams \tcode{ym} into \tcode{os} using +the format specified by the NTCTS \tcode{fmt}. +\tcode{fmt} encoding follows the rules specified in \ref{time.format}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{from_stream}{year_month}% +\begin{itemdecl} +template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + year_month& ym, basic_string* abbrev = nullptr, + minutes* offset = nullptr); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Attempts to parse the input stream \tcode{is} +into the \tcode{year_month} \tcode{ym} using +the format flags given in the NTCTS \tcode{fmt} +as specified in \ref{time.parse}. +If the parse fails to decode a valid \tcode{year_month}, +\tcode{is.setstate(ios_base::failbit)} shall be called +and \tcode{ym} shall not be modified. +If \tcode{\%Z} is used and successfully parsed, +that value will be assigned to \tcode{*abbrev} if \tcode{abbrev} is non-null. +If \tcode{\%z} (or a modified variant) is used and successfully parsed, +that value will be assigned to \tcode{*offset} if \tcode{offset} is non-null. + +\pnum +\returns \tcode{is}. +\end{itemdescr} + +\rSec3[time.cal.ymd]{Class \tcode{year_month_day}} + +\rSec4[time.cal.ymd.overview]{Overview} +\indexlibrary{\idxcode{year_month_day}} + +\begin{codeblock} +namespace std::chrono { + class year_month_day { + chrono::year y_; // \expos + chrono::month m_; // \expos + chrono::day d_; // \expos + + public: + year_month_day() = default; + constexpr year_month_day(const chrono::year& y, const chrono::month& m, + const chrono::day& d) noexcept; + constexpr year_month_day(const year_month_day_last& ymdl) noexcept; + constexpr year_month_day(const sys_days& dp) noexcept; + explicit constexpr year_month_day(const local_days& dp) noexcept; + + constexpr year_month_day& operator+=(const months& m) noexcept; + constexpr year_month_day& operator-=(const months& m) noexcept; + constexpr year_month_day& operator+=(const years& y) noexcept; + constexpr year_month_day& operator-=(const years& y) noexcept; + + constexpr chrono::year year() const noexcept; + constexpr chrono::month month() const noexcept; + constexpr chrono::day day() const noexcept; + + constexpr operator sys_days() const noexcept; + explicit constexpr operator local_days() const noexcept; + constexpr bool ok() const noexcept; + }; +} +\end{codeblock} + +\pnum +\tcode{year_month_day} represents a specific year, month, and day. +\tcode{year_month_day} is a field-based time point with a resolution of \tcode{days}. +\begin{note} +\tcode{year_month_day} supports \tcode{years}- and \tcode{months}-oriented arithmetic, +but not \tcode{days}-oriented arithmetic. +For the latter, there is a conversion to \tcode{sys_days}, +which efficiently supports \tcode{days}-oriented arithmetic. +\end{note} +\tcode{year_month_day} is \tcode{EqualityComparable} (Table~\ref{tab:equalitycomparable}) +and \tcode{LessThanComparable} (Table~\ref{tab:lessthancomparable}), + +\pnum +\tcode{year_month_day} is a trivially copyable and standard-layout class type. + +\rSec4[time.cal.ymd.members]{Member functions} + +\indexlibrary{\idxcode{year_month_day}!constructor}% +\begin{itemdecl} +constexpr year_month_day(const chrono::year& y, const chrono::month& m, + const chrono::day& d) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{year_month_day} by +initializing +\tcode{y_} with \tcode{y}, +\tcode{m_} with \tcode{m}, and +\tcode{d_} with \tcode{d}. +\end{itemdescr} + +\indexlibrary{\idxcode{year_month_day}!constructor}% +\begin{itemdecl} +constexpr year_month_day(const year_month_day_last& ymdl) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{year_month_day} by +initializing +\tcode{y_} with \tcode{ymdl.year()}, +\tcode{m_} with \tcode{ymdl.month()}, and +\tcode{d_} with \tcode{ymdl.day()}. +\begin{note} +This conversion from \tcode{year_month_day_last} to \tcode{year_month_day} +may be more efficient than converting a \tcode{year_month_day_last} to a \tcode{sys_days}, +and then converting that \tcode{sys_days} to a \tcode{year_month_day}. +\end{note} +\end{itemdescr} + +\indexlibrary{\idxcode{year_month_day}!constructor}% +\begin{itemdecl} +constexpr year_month_day(const sys_days& dp) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{year_month_day} +that corresponds to the date represented by \tcode{dp}. + +\pnum +\remarks +For any value \tcode{ymd} of type \tcode{year_month_day} +for which \tcode{ymd.ok()} is \tcode{true}, +\tcode{ymd == year_month_day\{sys_days\{ymd\}\}} +is \tcode{true}. +\end{itemdescr} + +\indexlibrary{\idxcode{year_month_day}!constructor}% +\begin{itemdecl} +explicit constexpr year_month_day(const local_days& dp) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{year_month_day} +that corresponds to the date represented by \tcode{dp}. + +\pnum +\remarks +Equivalent to constructing with \tcode{sys_days\{dp.time_since_epoch()\}}. +\end{itemdescr} + +\indexlibrarymember{operator+=}{year_month_day}% +\begin{itemdecl} +constexpr year_month_day& operator+=(const months& m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this + m}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator-=}{year_month_day}% +\begin{itemdecl} +constexpr year_month_day& operator-=(const months& m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this - m}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator+=}{year_month_day}% +\begin{itemdecl} +constexpr year_month_day& year_month_day::operator+=(const years& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this + y}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator-=}{year_month_day}% +\begin{itemdecl} +constexpr year_month_day& year_month_day::operator-=(const years& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this - y}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{year}{year_month_day}% +\begin{itemdecl} +constexpr chrono::year year() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y_}. +\end{itemdescr} + +\indexlibrarymember{month}{year_month_day}% +\begin{itemdecl} +constexpr chrono::month month() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{m_}. +\end{itemdescr} + +\indexlibrarymember{day}{year_month_day}% +\begin{itemdecl} +constexpr chrono::day day() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{d_}. +\end{itemdescr} + +\indexlibrarymember{operator sys_days}{year_month_day}% +\begin{itemdecl} +constexpr operator sys_days() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +If \tcode{ok()}, +returns a \tcode{sys_days} +holding a count of days from the \tcode{sys_days} epoch to \tcode{*this} +(a negative value if \tcode{*this} represents a date prior to the \tcode{sys_days} epoch). +Otherwise, if \tcode{y_.ok() \&\& m_.ok()} is \tcode{true}, +returns a \tcode{sys_days} +which is offset from \tcode{sys_days\{y_/m_/last\}} +by the number of days \tcode{d_} is offset from \tcode{sys_days\{y_/m_/last\}.day()}. +Otherwise the value returned is unspecified. + +\pnum +\remarks +A \tcode{sys_days} in the range \crange{days\{-12687428\}}{days\{11248737\}} +which is converted to a \tcode{year_month_day} +shall have the same value when converted back to a \tcode{sys_days}. + +\pnum +\begin{example} +\begin{codeblock} +static_assert(year_month_day{sys_days{2017y/January/0}} == 2016y/December/31); +static_assert(year_month_day{sys_days{2017y/January/31}} == 2017y/January/31); +static_assert(year_month_day{sys_days{2017y/January/32}} == 2017y/February/1); +\end{codeblock} +\end{example} +\end{itemdescr} + +\indexlibrarymember{operator local_days}{year_month_day}% +\begin{itemdecl} +explicit constexpr operator local_days() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{local_days\{sys_days\{*this\}.time_since_epoch()\}}. +\end{itemdescr} + +\indexlibrarymember{ok}{year_month_day}% +\begin{itemdecl} +constexpr bool ok() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +If \tcode{y_.ok()} is \tcode{true}, +and \tcode{m_.ok()} is \tcode{true}, +and \tcode{d_} is in the range \crange{1d}{(y_/m_/last).day()}, +then returns \tcode{true}; otherwise returns \tcode{false}. +\end{itemdescr} + +\rSec4[time.cal.ymd.nonmembers]{Non-member functions} + +\indexlibrarymember{operator==}{year_month_day}% +\begin{itemdecl} +constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x.year() == y.year() \&\& x.month() == y.month() \&\& x.day() == y.day()}. +\end{itemdescr} + +\indexlibrarymember{operator<}{year_month_day}% +\begin{itemdecl} +constexpr bool operator<(const year_month_day& x, const year_month_day& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +If \tcode{x.year() < y.year()}, returns \tcode{true}. +Otherwise, if \tcode{x.year() > y.year()}, returns \tcode{false}. +Otherwise, if \tcode{x.month() < y.month()}, returns \tcode{true}. +Otherwise, if \tcode{x.month() > y.month()}, returns \tcode{false}. +Otherwise, returns \tcode{x.day() < y.day()}. +\end{itemdescr} + +\indexlibrarymember{operator+}{year_month_day}% +\begin{itemdecl} +constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{(ymd.year() / ymd.month() + dm) / ymd.day()}. + +\pnum +\begin{note} +If \tcode{ymd.day()} is in the range \crange{1d}{28d}, +\tcode{ok()} will return \tcode{true} for +the resultant \tcode{year_month_day}. +\end{note} +\end{itemdescr} + +\indexlibrarymember{operator+}{year_month_day}% +\begin{itemdecl} +constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{ymd + dm}. +\end{itemdescr} + +\indexlibrarymember{operator-}{year_month_day}% +\begin{itemdecl} +constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{ymd + (-dm)}. +\end{itemdescr} + +\indexlibrarymember{operator+}{year_month_day}% +\begin{itemdecl} +constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{(ymd.year() + dy) / ymd.month() / ymd.day()}. + +\pnum +\begin{note} +If \tcode{ymd.month()} is February +and \tcode{ymd.day()} is not in the range \crange{1d}{28d}, +\tcode{ok()} may return \tcode{false} for +the resultant \tcode{year_month_day}. +\end{note} +\end{itemdescr} + +\indexlibrarymember{operator+}{year_month_day}% +\begin{itemdecl} +constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{ymd + dy}. +\end{itemdescr} + +\indexlibrarymember{operator-}{year_month_day}% +\begin{itemdecl} +constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{ymd + (-dy)}. +\end{itemdescr} + +\indexlibrarymember{operator<<}{year_month_day}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const year_month_day& ymd); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Inserts \tcode{format(fmt, ymd)} +where \tcode{fmt} is \tcode{"\%F"} widened to \tcode{charT}. +If \tcode{!ymd.ok()}, appends with \tcode{" is not a valid date"}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{to_stream}{year_month_day}% +\begin{itemdecl} +template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, const year_month_day& ymd); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Streams \tcode{ymd} into \tcode{os} using +the format specified by the NTCTS \tcode{fmt}. +\tcode{fmt} encoding follows the rules specified in \ref{time.format}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{from_stream}{year_month_day}% +\begin{itemdecl} +template> + basic_istream& + from_stream(basic_istream& is, const charT* fmt, + year_month_day& ymd, basic_string* abbrev = nullptr, + minutes* offset = nullptr); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Attempts to parse the input stream \tcode{is} +into the \tcode{year_month_day} \tcode{ymd} using +the format flags given in the NTCTS \tcode{fmt} +as specified in \ref{time.parse}. +If the parse fails to decode a valid \tcode{year_month_day}, +\tcode{is.setstate(ios_base::failbit)} shall be called +and \tcode{ymd} shall not be modified. +If \tcode{\%Z} is used and successfully parsed, +that value will be assigned to \tcode{*abbrev} if \tcode{abbrev} is non-null. +If \tcode{\%z} (or a modified variant) is used and successfully parsed, +that value will be assigned to \tcode{*offset} if \tcode{offset} is non-null. + +\pnum +\returns \tcode{is}. +\end{itemdescr} + +\rSec3[time.cal.ymdlast]{Class \tcode{year_month_day_last}} + +\rSec4[time.cal.ymdlast.overview]{Overview} +\indexlibrary{\idxcode{year_month_day_last}} + +\begin{codeblock} +namespace std::chrono { + class year_month_day_last { + chrono::year y_; // \expos + chrono::month_day_last mdl_; // \expos + + public: + constexpr year_month_day_last(const chrono::year& y, + const chrono::month_day_last& mdl) noexcept; + + constexpr year_month_day_last& operator+=(const months& m) noexcept; + constexpr year_month_day_last& operator-=(const months& m) noexcept; + constexpr year_month_day_last& operator+=(const years& y) noexcept; + constexpr year_month_day_last& operator-=(const years& y) noexcept; + + constexpr chrono::year year() const noexcept; + constexpr chrono::month month() const noexcept; + constexpr chrono::month_day_last month_day_last() const noexcept; + constexpr chrono::day day() const noexcept; + + constexpr operator sys_days() const noexcept; + explicit constexpr operator local_days() const noexcept; + constexpr bool ok() const noexcept; + }; +} +\end{codeblock} + +\pnum +\tcode{year_month_day_last} represents the last day of a specific year and month. +\tcode{year_month_day_last} is a field-based time point with a resolution of \tcode{days}, +except that it is restricted to pointing to the last day of a year and month. +\begin{note} +\tcode{year_month_day_last} supports \tcode{years}- and \tcode{months}-oriented arithmetic, +but not \tcode{days}-oriented arithmetic. +For the latter, there is a conversion to \tcode{sys_days}, +which efficiently supports \tcode{days}-oriented arithmetic. +\end{note} +\tcode{year_month_day_last} is \tcode{EqualityComparable} (Table~\ref{tab:equalitycomparable}) +and \tcode{LessThanComparable} (Table~\ref{tab:lessthancomparable}), + +\pnum +\tcode{year_month_day_last} is a trivially copyable and standard-layout class type. + +\rSec4[time.cal.ymdlast.members]{Member functions} + +\indexlibrary{\idxcode{year_month_day_last}!constructor}% +\begin{itemdecl} +constexpr year_month_day_last(const chrono::year& y, + const chrono::month_day_last& mdl) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{year_month_day_last} by +initializing \tcode{y_} with \tcode{y} and \tcode{mdl_} with \tcode{mdl}. +\end{itemdescr} + +\indexlibrarymember{operator+=}{year_month_day_last}% +\begin{itemdecl} +constexpr year_month_day_last& operator+=(const months& m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this + m}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator-=}{year_month_day_last}% +\begin{itemdecl} +constexpr year_month_day_last& operator-=(const months& m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this - m}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator+=}{year_month_day_last}% +\begin{itemdecl} +constexpr year_month_day_last& operator+=(const years& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this + y}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator-=}{year_month_day_last}% +\begin{itemdecl} +constexpr year_month_day_last& operator-=(const years& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this - y}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{year}{year_month_day_last}% +\begin{itemdecl} +constexpr chrono::year year() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y_}. +\end{itemdescr} + +\indexlibrarymember{month}{year_month_day_last}% +\begin{itemdecl} +constexpr chrono::month month() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{mdl_.month()}. +\end{itemdescr} + +\indexlibrarymember{month_day_last}{year_month_day_last}% +\begin{itemdecl} +constexpr chrono::month_day_last month_day_last() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{mdl_}. +\end{itemdescr} + +\indexlibrarymember{day}{year_month_day_last}% +\begin{itemdecl} +constexpr chrono::day day() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +A \tcode{day} representing the last day of the (\tcode{year}, \tcode{month}) pair +represented by \tcode{*this}. + +\pnum +\begin{note} +This value may be computed on demand. +\end{note} +\end{itemdescr} + +\indexlibrarymember{operator sys_days}{year_month_day_last}% +\begin{itemdecl} +constexpr operator sys_days() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{sys_days\{year()/month()/day()\}}. +\end{itemdescr} + +\indexlibrarymember{operator local_days}{year_month_day_last}% +\begin{itemdecl} +explicit constexpr operator local_days() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{local_days\{sys_days\{*this\}.time_since_epoch()\}}. +\end{itemdescr} + +\indexlibrarymember{ok}{year_month_day_last}% +\begin{itemdecl} +constexpr bool ok() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y_.ok() \&\& mdl_.ok()}. +\end{itemdescr} + +\rSec4[time.cal.ymdlast.nonmembers]{Non-member functions} + +\indexlibrarymember{operator==}{year_month_day_last}% +\begin{itemdecl} +constexpr bool operator==(const year_month_day_last& x, const year_month_day_last& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x.year() == y.year() \&\& x.month_day_last() == y.month_day_last()}. +\end{itemdescr} + +\indexlibrarymember{operator<}{year_month_day_last}% +\begin{itemdecl} +constexpr bool operator<(const year_month_day_last& x, const year_month_day_last& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +If \tcode{x.year() < y.year()}, returns \tcode{true}. +Otherwise, if \tcode{x.year() > y.year()}, returns \tcode{false}. +Otherwise, returns \tcode{x.month_day_last() < y.month_day_last()}. +\end{itemdescr} + +\indexlibrarymember{operator+}{year_month_day_last}% +\begin{itemdecl} +constexpr year_month_day_last + operator+(const year_month_day_last& ymdl, const months& dm) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{(ymdl.year() / ymdl.month() + dm) / last}. +\end{itemdescr} + +\indexlibrarymember{operator+}{year_month_day_last}% +\begin{itemdecl} +constexpr year_month_day_last + operator+(const months& dm, const year_month_day_last& ymdl) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{ymdl + dm}. +\end{itemdescr} + +\indexlibrarymember{operator-}{year_month_day_last}% +\begin{itemdecl} +constexpr year_month_day_last + operator-(const year_month_day_last& ymdl, const months& dm) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{ymdl + (-dm)}. +\end{itemdescr} + +\indexlibrarymember{operator+}{year_month_day_last}% +\begin{itemdecl} +constexpr year_month_day_last + operator+(const year_month_day_last& ymdl, const years& dy) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{\{ymdl.year()+dy, ymdl.month_day_last()\}}. +\end{itemdescr} + +\indexlibrarymember{operator+}{year_month_day_last}% +\begin{itemdecl} +constexpr year_month_day_last + operator+(const years& dy, const year_month_day_last& ymdl) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{ymdl + dy}. +\end{itemdescr} + +\indexlibrarymember{operator-}{year_month_day_last}% +\begin{itemdecl} +constexpr year_month_day_last + operator-(const year_month_day_last& ymdl, const years& dy) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{ymdl + (-dy)}. +\end{itemdescr} + +\indexlibrarymember{operator<<}{year_month_day_last}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const year_month_day_last& ymdl); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{os << ymdl.year() << '/' << ymdl.month_day_last()}. +\end{itemdescr} + +\rSec3[time.cal.ymwd]{Class \tcode{year_month_weekday}} + +\rSec4[time.cal.ymwd.overview]{Overview} +\indexlibrary{\idxcode{year_month_weekday}} + +\begin{codeblock} +namespace std::chrono { + class year_month_weekday { + chrono::year y_; // \expos + chrono::month m_; // \expos + chrono::weekday_indexed wdi_; // \expos + + public: + year_month_weekday() = default; + constexpr year_month_weekday(const chrono::year& y, const chrono::month& m, + const chrono::weekday_indexed& wdi) noexcept; + constexpr year_month_weekday(const sys_days& dp) noexcept; + explicit constexpr year_month_weekday(const local_days& dp) noexcept; + + constexpr year_month_weekday& operator+=(const months& m) noexcept; + constexpr year_month_weekday& operator-=(const months& m) noexcept; + constexpr year_month_weekday& operator+=(const years& y) noexcept; + constexpr year_month_weekday& operator-=(const years& y) noexcept; + + constexpr chrono::year year() const noexcept; + constexpr chrono::month month() const noexcept; + constexpr chrono::weekday weekday() const noexcept; + constexpr unsigned index() const noexcept; + constexpr chrono::weekday_indexed weekday_indexed() const noexcept; + + constexpr operator sys_days() const noexcept; + explicit constexpr operator local_days() const noexcept; + constexpr bool ok() const noexcept; + }; +} +\end{codeblock} + +\pnum +\tcode{year_month_weekday} represents a specific year, month, +and n$^\textrm{th}$ weekday of the month. +\tcode{year_month_weekday} is a field-based time point with a resolution of \tcode{days}. +\begin{note} +\tcode{year_month_weekday} supports \tcode{years}- and \tcode{months}-oriented arithmetic, +but not \tcode{days}-oriented arithmetic. +For the latter, there is a conversion to \tcode{sys_days}, +which efficiently supports \tcode{days}-oriented arithmetic. +\end{note} +\tcode{year_month_weekday} is \tcode{EqualityComparable} (Table~\ref{tab:equalitycomparable}). + +\pnum +\tcode{year_month_weekday} is a trivially copyable and standard-layout class type. + +\rSec4[time.cal.ymwd.members]{Member functions} + +\indexlibrary{\idxcode{year_month_weekday}!constructor}% +\begin{itemdecl} +constexpr year_month_weekday(const chrono::year& y, const chrono::month& m, + const chrono::weekday_indexed& wdi) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{year_month_weekday} by +initializing \tcode{y_} with \tcode{y}, \tcode{m_} with \tcode{m}, and \tcode{wdi_} with \tcode{wdi}. +\end{itemdescr} + +\indexlibrary{\idxcode{year_month_weekday}!constructor}% +\begin{itemdecl} +constexpr year_month_weekday(const sys_days& dp) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{year_month_weekday} +which corresponds to the date represented by \tcode{dp}. + +\pnum +\remarks +For any value \tcode{ymdl} of type \tcode{year_month_weekday} +for which \tcode{ymdl.ok()} is \tcode{true}, +\tcode{ymdl == year_month_weekday\{sys_days\{ymdl\}\}} is \tcode{true}. +\end{itemdescr} + +\indexlibrary{\idxcode{year_month_weekday}!constructor}% +\begin{itemdecl} +explicit constexpr year_month_weekday(const local_days& dp) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{year_month_weekday} +that corresponds to the date represented by \tcode{dp}. + +\pnum +\remarks +Equivalent to constructing with \tcode{sys_days\{dp.time_since_epoch()\}}. +\end{itemdescr} + +\indexlibrarymember{operator+=}{year_month_weekday}% +\begin{itemdecl} +constexpr year_month_weekday& operator+=(const months& m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this + m}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator-=}{year_month_weekday}% +\begin{itemdecl} +constexpr year_month_weekday& operator-=(const months& m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this - m}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator+=}{year_month_weekday}% +\begin{itemdecl} +constexpr year_month_weekday& operator+=(const years& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this + y}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator-=}{year_month_weekday}% +\begin{itemdecl} +constexpr year_month_weekday& operator-=(const years& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this - y}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{year}{year_month_weekday}% +\begin{itemdecl} +constexpr chrono::year year() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y_}. +\end{itemdescr} + +\indexlibrarymember{month}{year_month_weekday}% +\begin{itemdecl} +constexpr chrono::month month() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{m_}. +\end{itemdescr} + +\indexlibrarymember{weekday}{year_month_weekday}% +\begin{itemdecl} +constexpr chrono::weekday weekday() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{wdi_.weekday()}. +\end{itemdescr} + +\indexlibrarymember{index}{year_month_weekday}% +\begin{itemdecl} +constexpr unsigned index() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{wdi_.index()}. +\end{itemdescr} + +\indexlibrarymember{weekday_indexed}{year_month_weekday}% +\begin{itemdecl} +constexpr chrono::weekday_indexed weekday_indexed() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{wdi_}. +\end{itemdescr} + +\indexlibrarymember{operator sys_days}{year_month_weekday}% +\begin{itemdecl} +constexpr operator sys_days() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +If \tcode{y_.ok() \&\& m_.ok() \&\& wdi_.weekday().ok()}, +returns a \tcode{sys_days} that +represents the date \tcode{(index() - 1) * 7} days after +the first \tcode{weekday()} of \tcode{year()/month()}. +If \tcode{index()} is 0 +the returned \tcode{sys_days} +represents the date 7 days prior to +the first \tcode{weekday()} of \tcode{year()/month()}. +Otherwise the returned value is unspecified. +\end{itemdescr} + +\indexlibrarymember{operator local_days}{year_month_weekday}% +\begin{itemdecl} +explicit constexpr operator local_days() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{local_days\{sys_days\{*this\}.time_since_epoch()\}}. +\end{itemdescr} + +\indexlibrarymember{ok}{year_month_weekday}% +\begin{itemdecl} +constexpr bool ok() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +If any of +\tcode{y_.ok()}, +\tcode{m_.ok()}, or +\tcode{wdi_.ok()} +is \tcode{false}, returns \tcode{false}. +Otherwise, if \tcode{*this} represents a valid date, +returns \tcode{true}. +Otherwise, returns \tcode{false}. +\end{itemdescr} + +\rSec4[time.cal.ymwd.nonmembers]{Non-member functions} + +\indexlibrarymember{operator==}{year_month_weekday}% +\begin{itemdecl} +constexpr bool operator==(const year_month_weekday& x, const year_month_weekday& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\begin{codeblock} +x.year() == y.year() && x.month() == y.month() && x.weekday_indexed() == y.weekday_indexed() +\end{codeblock} +\end{itemdescr} + +\indexlibrarymember{operator+}{year_month_weekday}% +\begin{itemdecl} +constexpr year_month_weekday operator+(const year_month_weekday& ymwd, const months& dm) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{(ymwd.year() / ymwd.month() + dm) / ymwd.weekday_indexed()}. +\end{itemdescr} + +\indexlibrarymember{operator+}{year_month_weekday}% +\begin{itemdecl} +constexpr year_month_weekday operator+(const months& dm, const year_month_weekday& ymwd) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{ymwd + dm}. +\end{itemdescr} + +\indexlibrarymember{operator-}{year_month_weekday}% +\begin{itemdecl} +constexpr year_month_weekday operator-(const year_month_weekday& ymwd, const months& dm) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{ymwd + (-dm)}. +\end{itemdescr} + +\indexlibrarymember{operator+}{year_month_weekday}% +\begin{itemdecl} +constexpr year_month_weekday operator+(const year_month_weekday& ymwd, const years& dy) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{\{ymwd.year()+dy, ymwd.month(), ymwd.weekday_indexed()\}}. +\end{itemdescr} + +\indexlibrarymember{operator+}{year_month_weekday}% +\begin{itemdecl} +constexpr year_month_weekday operator+(const years& dy, const year_month_weekday& ymwd) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{ymwd + dm}. +\end{itemdescr} + +\indexlibrarymember{operator-}{year_month_weekday}% +\begin{itemdecl} +constexpr year_month_weekday operator-(const year_month_weekday& ymwd, const years& dy) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{ymwd + (-dm)}. +\end{itemdescr} + +\indexlibrarymember{operator<<}{year_month_weekday}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const year_month_weekday& ymwd); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{os << ymwdi.year() << '/' << ymwdi.month() << '/' << ymwdi.weekday_indexed()}. +\end{itemdescr} + +\rSec3[time.cal.ymwdlast]{Class \tcode{year_month_weekday_last}} + +\rSec4[time.cal.ymwdlast.overview]{Overview} +\indexlibrary{\idxcode{year_month_weekday_last}} + +\begin{codeblock} +namespace std::chrono { + class year_month_weekday_last { + chrono::year y_; // \expos + chrono::month m_; // \expos + chrono::weekday_last wdl_; // \expos + + public: + constexpr year_month_weekday_last(const chrono::year& y, const chrono::month& m, + const chrono::weekday_last& wdl) noexcept; + + constexpr year_month_weekday_last& operator+=(const months& m) noexcept; + constexpr year_month_weekday_last& operator-=(const months& m) noexcept; + constexpr year_month_weekday_last& operator+=(const years& y) noexcept; + constexpr year_month_weekday_last& operator-=(const years& y) noexcept; + + constexpr chrono::year year() const noexcept; + constexpr chrono::month month() const noexcept; + constexpr chrono::weekday weekday() const noexcept; + constexpr chrono::weekday_last weekday_last() const noexcept; + + constexpr operator sys_days() const noexcept; + explicit constexpr operator local_days() const noexcept; + constexpr bool ok() const noexcept; + }; +} +\end{codeblock} + +\pnum +\tcode{year_month_weekday_last} represents a specific year, month, +and last weekday of the month. +\tcode{year_month_weekday_last} is a field-based time point with a resolution of \tcode{days}, +except that it is restricted to pointing to the last weekday of a year and month. +\begin{note} +\tcode{year_month_weekday_last} supports \tcode{years}- and \tcode{months}-oriented arithmetic, +but not \tcode{days}-oriented arithmetic. +For the latter, there is a conversion to \tcode{sys_days}, +which efficiently supports \tcode{days}-oriented arithmetic. +\end{note} +\tcode{year_month_weekday_last} is \tcode{EqualityComparable} (Table~\ref{tab:equalitycomparable}). + +\rSec4[time.cal.ymwdlast.members]{Member functions} + +\pnum +\tcode{year_month_weekday_last} is a trivially copyable and standard-layout class type. + +\indexlibrary{\idxcode{year_month_weekday_last}!constructor}% +\begin{itemdecl} +constexpr year_month_weekday_last(const chrono::year& y, const chrono::month& m, + const chrono::weekday_last& wdl) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{year_month_weekday_last} by +initializing \tcode{y_} with \tcode{y}, \tcode{m_} with \tcode{m}, and \tcode{wdl_} with \tcode{wdl}. +\end{itemdescr} + +\indexlibrarymember{operator+=}{year_month_weekday_last}% +\begin{itemdecl} +constexpr year_month_weekday_last& operator+=(const months& m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this + m}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator-=}{year_month_weekday_last}% +\begin{itemdecl} +constexpr year_month_weekday_last& operator-=(const months& m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this - m}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator+=}{year_month_weekday_last}% +\begin{itemdecl} +constexpr year_month_weekday_last& operator+=(const years& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this + y}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator-=}{year_month_weekday_last}% +\begin{itemdecl} +constexpr year_month_weekday_last& operator-=(const years& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{*this = *this - y}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{year}{year_month_weekday_last}% +\begin{itemdecl} +constexpr chrono::year year() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y_}. +\end{itemdescr} + +\indexlibrarymember{month}{year_month_weekday_last}% +\begin{itemdecl} +constexpr chrono::month month() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{m_}. +\end{itemdescr} + +\indexlibrarymember{weekday}{year_month_weekday_last}% +\begin{itemdecl} +constexpr chrono::weekday weekday() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{wdl_.weekday()}. +\end{itemdescr} + +\indexlibrarymember{weekday_last}{year_month_weekday_last}% +\begin{itemdecl} +constexpr chrono::weekday_last weekday_last() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{wdl_}. +\end{itemdescr} + +\indexlibrarymember{operator sys_days}{year_month_weekday_last}% +\begin{itemdecl} +constexpr operator sys_days() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +If \tcode{ok() == true}, +returns a \tcode{sys_days} that represents +the last \tcode{weekday()} of \tcode{year()/month()}. +Otherwise the returned value is unspecified. +\end{itemdescr} + +\indexlibrarymember{operator local_days}{year_month_weekday_last}% +\begin{itemdecl} +explicit constexpr operator local_days() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{local_days\{sys_days\{*this\}.time_since_epoch()\}}. +\end{itemdescr} + +\indexlibrarymember{ok}{year_month_weekday_last}% +\begin{itemdecl} +constexpr bool ok() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y_.ok() \&\& m_.ok() \&\& wdl_.ok()}. +\end{itemdescr} + +\rSec4[time.cal.ymwdlast.nonmembers]{Non-member functions} + +\indexlibrarymember{operator==}{year_month_weekday_last}% +\begin{itemdecl} +constexpr bool operator==(const year_month_weekday_last& x, + const year_month_weekday_last& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +\begin{codeblock} +x.year() == y.year() && x.month() == y.month() && x.weekday_last() == y.weekday_last() +\end{codeblock} +\end{itemdescr} + +\indexlibrarymember{operator+}{year_month_weekday_last}% +\begin{itemdecl} +constexpr year_month_weekday_last + operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{(ymwdl.year() / ymwdl.month() + dm) / ymwdl.weekday_last()}. +\end{itemdescr} + +\indexlibrarymember{operator+}{year_month_weekday_last}% +\begin{itemdecl} +constexpr year_month_weekday_last + operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{ymwdl + dm}. +\end{itemdescr} + +\indexlibrarymember{operator-}{year_month_weekday_last}% +\begin{itemdecl} +constexpr year_month_weekday_last + operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{ymwdl + (-dm)}. +\end{itemdescr} + +\indexlibrarymember{operator+}{year_month_weekday_last}% +\begin{itemdecl} +constexpr year_month_weekday_last + operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{\{ymwdl.year()+dy, ymwdl.month(), ymwdl.weekday_last()\}}. +\end{itemdescr} + +\indexlibrarymember{operator+}{year_month_weekday_last}% +\begin{itemdecl} +constexpr year_month_weekday_last + operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{ymwdl + dy}. +\end{itemdescr} + +\indexlibrarymember{operator-}{year_month_weekday_last}% +\begin{itemdecl} +constexpr year_month_weekday_last + operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{ymwdl + (-dy)}. +\end{itemdescr} + +\indexlibrarymember{operator<<}{year_month_weekday_last}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const year_month_weekday_last& ymwdl); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{os << ymwdl.year() << '/' << ymwdl.month() << '/' << ymwdl.weekday_last()}. +\end{itemdescr} + +\rSec3[time.cal.operators]{Conventional syntax operators} +\indexlibrary{\idxcode{operator/}!calendar types|(} + +\pnum +A set of overloaded \tcode{operator/} functions provides +a conventional syntax for the creation of civil calendar dates. + +\pnum +\begin{note} +The year, month, and day are accepted in any of the following 3 orders: + +\begin{codeblock} +@\tcode{\placeholder{year}}@/@\tcode{\placeholder{month}}@/@\tcode{\placeholder{day}}@ +@\tcode{\placeholder{month}}@/@\tcode{\placeholder{day}}@/@\tcode{\placeholder{year}}@ +@\tcode{\placeholder{day}}@/@\tcode{\placeholder{month}}@/@\tcode{\placeholder{year}}@ +\end{codeblock} + +Anywhere a \tcode{\placeholder{day}} is required, any of the following can also be specified: + +\begin{codeblock} +last +@\tcode{\placeholder{weekday}}@[@\tcode{\placeholder{i}}@] +@\tcode{\placeholder{weekday}}@[last] +\end{codeblock} +\end{note} + +\pnum +\begin{note} +Partial-date types such as \tcode{year_month} and \tcode{month_day} +can be created by not applying the second division operator +for any of the three orders. For example: + +\begin{codeblock} +year_month ym = 2015y/April; +month_day md1 = April/4; +month_day md2 = 4d/April; +\end{codeblock} +\end{note} + +\pnum +\begin{example} +\begin{codeblock} +auto a = 2015/4/4; // \tcode{a == int(125)} +auto b = 2015y/4/4; // \tcode{b == year_month_day\{year(2015), month(4), day(4)\}} +auto c = 2015y/4d/April; // error: no viable \tcode{operator/} for first \tcode{/} +auto d = 2015/April/4; // error: no viable \tcode{operator/} for first \tcode{/} +\end{codeblock} +\end{example} + +\begin{itemdecl} +constexpr year_month + operator/(const year& y, const month& m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{\{y, m\}}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month + operator/(const year& y, int m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y / month(m)}. +\end{itemdescr} + +\begin{itemdecl} +constexpr month_day + operator/(const month& m, const day& d) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{\{m, d\}}. +\end{itemdescr} + +\begin{itemdecl} +constexpr month_day + operator/(const month& m, int d) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{m / day(d)}. +\end{itemdescr} + +\begin{itemdecl} +constexpr month_day + operator/(int m, const day& d) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{month(m) / d}. +\end{itemdescr} + +\begin{itemdecl} +constexpr month_day + operator/(const day& d, const month& m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{m / d}. +\end{itemdescr} + +\begin{itemdecl} +constexpr month_day + operator/(const day& d, int m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{month(m) / d}. +\end{itemdescr} + +\begin{itemdecl} +constexpr month_day_last + operator/(const month& m, last_spec) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{month_day_last\{m\}}. +\end{itemdescr} + +\begin{itemdecl} +constexpr month_day_last + operator/(int m, last_spec) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{month(m) / last}. +\end{itemdescr} + +\begin{itemdecl} +constexpr month_day_last + operator/(last_spec, const month& m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{m / last}. +\end{itemdescr} + +\begin{itemdecl} +constexpr month_day_last + operator/(last_spec, int m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{month(m) / last}. +\end{itemdescr} + +\begin{itemdecl} +constexpr month_weekday + operator/(const month& m, const weekday_indexed& wdi) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{\{m, wdi\}}. +\end{itemdescr} + +\begin{itemdecl} +constexpr month_weekday + operator/(int m, const weekday_indexed& wdi) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{month(m) / wdi}. +\end{itemdescr} + +\begin{itemdecl} +constexpr month_weekday + operator/(const weekday_indexed& wdi, const month& m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{m / wdi}. +\end{itemdescr} + +\begin{itemdecl} +constexpr month_weekday + operator/(const weekday_indexed& wdi, int m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{month(m) / wdi}. +\end{itemdescr} + +\begin{itemdecl} +constexpr month_weekday_last + operator/(const month& m, const weekday_last& wdl) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{\{m, wdl\}}. +\end{itemdescr} + +\begin{itemdecl} +constexpr month_weekday_last + operator/(int m, const weekday_last& wdl) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{month(m) / wdl}. +\end{itemdescr} + +\begin{itemdecl} +constexpr month_weekday_last + operator/(const weekday_last& wdl, const month& m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{m / wdl}. +\end{itemdescr} + +\begin{itemdecl} +constexpr month_weekday_last + operator/(const weekday_last& wdl, int m) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{month(m) / wdl}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month_day + operator/(const year_month& ym, const day& d) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{\{ym.year(), ym.month(), d\}}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month_day + operator/(const year_month& ym, int d) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{ym / day(d)}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month_day + operator/(const year& y, const month_day& md) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y / md.month() / md.day()}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month_day + operator/(int y, const month_day& md) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{year(y) / md}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month_day + operator/(const month_day& md, const year& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y / md}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month_day + operator/(const month_day& md, int y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{year(y) / md}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month_day_last + operator/(const year_month& ym, last_spec) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{\{ym.year(), month_day_last\{ym.month()\}\}}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month_day_last + operator/(const year& y, const month_day_last& mdl) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{\{y, mdl\}}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month_day_last + operator/(int y, const month_day_last& mdl) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{year(y) / mdl}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month_day_last + operator/(const month_day_last& mdl, const year& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y / mdl}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month_day_last + operator/(const month_day_last& mdl, int y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{year(y) / mdl}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month_weekday + operator/(const year_month& ym, const weekday_indexed& wdi) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{\{ym.year(), ym.month(), wdi\}}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month_weekday + operator/(const year& y, const month_weekday& mwd) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{\{y, mwd.month(), mwd.weekday_indexed()\}}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month_weekday + operator/(int y, const month_weekday& mwd) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{year(y) / mwd}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month_weekday + operator/(const month_weekday& mwd, const year& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y / mwd}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month_weekday + operator/(const month_weekday& mwd, int y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{year(y) / mwd}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month_weekday_last + operator/(const year_month& ym, const weekday_last& wdl) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{\{ym.year(), ym.month(), wdl\}}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month_weekday_last + operator/(const year& y, const month_weekday_last& mwdl) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{\{y, mwdl.month(), mwdl.weekday_last()\}}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month_weekday_last + operator/(int y, const month_weekday_last& mwdl) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{year(y) / mwdl}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month_weekday_last + operator/(const month_weekday_last& mwdl, const year& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y / mwdl}. +\end{itemdescr} + +\begin{itemdecl} +constexpr year_month_weekday_last + operator/(const month_weekday_last& mwdl, int y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{year(y) / mwdl}. +\end{itemdescr} + +\indexlibrary{\idxcode{operator/}!calendar types|)} + +\rSec2[time.tod]{Class template \tcode{time_of_day}} + +\rSec3[time.tod.overview]{Overview} +\indexlibrary{\idxcode{time_of_day}} + +\begin{codeblock} +namespace std::chrono { + template class time_of_day; + + template<> class time_of_day; + template<> class time_of_day; + template<> class time_of_day; + template class time_of_day>; +} +\end{codeblock} + +\pnum +The \tcode{time_of_day} class template +splits a \tcode{duration} representing the time elapsed since midnight +into a ``broken down'' time of day such as +$hours$:$minutes$:$seconds$. +The \tcode{Duration} template parameter dictates +the precision to which the time is broken down. +\begin{note} +This can vary from a coarse precision of hours +to a very fine precision of nanoseconds. +\end{note} +A \tcode{time_of_day} object also tracks +whether it should be output +as a 12-hour time format or a 24-hour time format. + +\pnum +The primary \tcode{time_of_day} template is not defined. +Four specializations are provided to handle four different +levels of precision. + +\pnum +Each specialization of \tcode{time_of_day} is a trivially copyable +and standard-layout class type. + +\rSec3[time.tod.hours]{Hours precision} +\indexlibrary{\idxcode{time_of_day}} + +\begin{codeblock} +namespace std::chrono { + template<> + class time_of_day { + public: + using precision = chrono::hours; + + time_of_day() = default; + explicit constexpr time_of_day(chrono::hours since_midnight) noexcept; + + constexpr chrono::hours hours() const noexcept; + + explicit constexpr operator precision() const noexcept; + constexpr precision to_duration() const noexcept; + + constexpr void make24() noexcept; + constexpr void make12() noexcept; + }; +} +\end{codeblock} + +\pnum +\begin{note} +This specialization handles hours since midnight. +\end{note} + +\indexlibrary{\idxcode{time_of_day}!constructor}% +\begin{itemdecl} +explicit constexpr time_of_day(chrono::hours since_midnight) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{time_of_day} in 24-hour format +corresponding to \tcode{since_midnight} hours after 00:00:00. + +\pnum +\postconditions +\tcode{hours()} returns the integral number of hours \tcode{since_midnight} is after 00:00:00. +\end{itemdescr} + +\indexlibrarymember{hours}{time_of_day}% +\begin{itemdecl} +constexpr chrono::hours hours() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns The stored hour of \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator precision}{time_of_day}% +\begin{itemdecl} +explicit constexpr operator precision() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns The number of hours since midnight. +\end{itemdescr} + +\indexlibrarymember{to_duration}{time_of_day}% +\begin{itemdecl} +constexpr precision to_duration() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{precision\{*this\}}. +\end{itemdescr} + +\indexlibrarymember{make24}{time_of_day}% +\begin{itemdecl} +constexpr void make24() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +If \tcode{*this} is a 12-hour time, +converts to a 24-hour time. +Otherwise, no effects. +\end{itemdescr} + +\indexlibrarymember{make12}{time_of_day}% +\begin{itemdecl} +constexpr void make12() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +If \tcode{*this} is a 24-hour time, +converts to a 12-hour time. +Otherwise, no effects. +\end{itemdescr} + +\rSec3[time.tod.minutes]{Minutes precision} +\indexlibrary{\idxcode{time_of_day}} + +\begin{codeblock} +namespace std::chrono { + template<> + class time_of_day { + public: + using precision = chrono::minutes; + + time_of_day() = default; + explicit constexpr time_of_day(chrono::minutes since_midnight) noexcept; + + constexpr chrono::hours hours() const noexcept; + constexpr chrono::minutes minutes() const noexcept; + + explicit constexpr operator precision() const noexcept; + constexpr precision to_duration() const noexcept; + + constexpr void make24() noexcept; + constexpr void make12() noexcept; + }; +} +\end{codeblock} + +\pnum +\begin{note} +This specialization handles hours and minutes since midnight. +\end{note} + +\indexlibrary{\idxcode{time_of_day}!constructor}% +\begin{itemdecl} +explicit constexpr time_of_day(minutes since_midnight) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{time_of_day} +in 24-hour format +corresponding to \tcode{since_midnight} minutes after 00:00:00. + +\pnum +\postconditions +\tcode{hours()} returns the integral number of hours +\tcode{since_midnight} is after 00:00:00. +\tcode{minutes()} returns the integral number of minutes +\tcode{since_midnight} is after \tcode{(\textrm{00:00:00} + hours())}. +\end{itemdescr} + +\indexlibrarymember{hours}{time_of_day}% +\begin{itemdecl} +constexpr chrono::hours hours() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns The stored hour of \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{minutes}{time_of_day}% +\begin{itemdecl} +constexpr chrono::minutes minutes() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns The stored minute of \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator precision}{time_of_day}% +\begin{itemdecl} +explicit constexpr operator precision() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns The number of minutes since midnight. +\end{itemdescr} + +\indexlibrarymember{to_duration}{time_of_day}% +\begin{itemdecl} +constexpr precision to_duration() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{precision\{*this\}}. +\end{itemdescr} + +\indexlibrarymember{make24}{time_of_day}% +\begin{itemdecl} +constexpr void make24() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +If \tcode{*this} is a 12-hour time, +converts to a 24-hour time. +Otherwise, no effects. +\end{itemdescr} + +\indexlibrarymember{make12}{time_of_day}% +\begin{itemdecl} +constexpr void make12() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +If \tcode{*this} is a 24-hour time, +converts to a 12-hour time. +Otherwise, no effects. +\end{itemdescr} + +\rSec3[time.tod.seconds]{Seconds precision} +\indexlibrary{\idxcode{time_of_day}} + +\begin{codeblock} +namespace std::chrono { + template<> + class time_of_day { + public: + using precision = chrono::seconds; + + time_of_day() = default; + explicit constexpr time_of_day(chrono::seconds since_midnight) noexcept; + + constexpr chrono::hours hours() const noexcept; + constexpr chrono::minutes minutes() const noexcept; + constexpr chrono::seconds seconds() const noexcept; + + explicit constexpr operator precision() const noexcept; + constexpr precision to_duration() const noexcept; + + constexpr void make24() noexcept; + constexpr void make12() noexcept; + }; +} +\end{codeblock} + +\pnum +\begin{note} +This specialization handles hours, minutes, and seconds since midnight. +\end{note} + +\indexlibrary{\idxcode{time_of_day}!constructor}% +\begin{itemdecl} +explicit constexpr time_of_day(seconds since_midnight) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{time_of_day} +in 24-hour format +corresponding to \tcode{since_midnight} seconds after 00:00:00. + +\pnum +\postconditions +\tcode{hours()} returns the integral number of hours +\tcode{since_midnight} is after 00:00:00. +\tcode{minutes()} returns the integral number of minutes +\tcode{since_midnight} is after \tcode{(\textrm{00:00:00} + hours())}. +\tcode{seconds()} returns the integral number of seconds +\tcode{since_midnight} is after \tcode{(\textrm{00:00:00} + hours() + minutes())}. +\end{itemdescr} + +\indexlibrarymember{hours}{time_of_day}% +\begin{itemdecl} +constexpr chrono::hours hours() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +The stored hour of \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{minutes}{time_of_day}% +\begin{itemdecl} +constexpr chrono::minutes minutes() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +The stored minute of \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{seconds}{time_of_day}% +\begin{itemdecl} +constexpr chrono::seconds seconds() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +The stored second of \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator precision}{time_of_day}% +\begin{itemdecl} +explicit constexpr operator precision() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +The number of seconds since midnight. +\end{itemdescr} + +\indexlibrarymember{to_duration}{time_of_day}% +\begin{itemdecl} +constexpr precision to_duration() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{precision\{*this\}}. +\end{itemdescr} + +\indexlibrarymember{make24}{time_of_day}% +\begin{itemdecl} +constexpr void make24() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +If \tcode{*this} is a 12-hour time, +converts to a 24-hour time. +Otherwise, no effects. +\end{itemdescr} + +\indexlibrarymember{make12}{time_of_day}% +\begin{itemdecl} +constexpr void make12() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +If \tcode{*this} is a 24-hour time, +converts to a 12-hour time. +Otherwise, no effects. +\end{itemdescr} + +\rSec3[time.tod.subsecond]{Sub-second precision} +\indexlibrary{\idxcode{time_of_day<\placeholder{sub-second duration}>}} + +\begin{codeblock} +namespace std::chrono { + template + class time_of_day> { + public: + using precision = duration; + + time_of_day() = default; + explicit constexpr time_of_day(precision since_midnight) noexcept; + + constexpr chrono::hours hours() const noexcept; + constexpr chrono::minutes minutes() const noexcept; + constexpr chrono::seconds seconds() const noexcept; + constexpr precision subseconds() const noexcept; + + explicit constexpr operator precision() const noexcept; + constexpr precision to_duration() const noexcept; + + constexpr void make24() noexcept; + constexpr void make12() noexcept; + }; +} +\end{codeblock} + +\pnum +This specialization shall not exist unless +\tcode{treat_as_floating_point_v} is \tcode{false} +and +\tcode{duration} is not convertible to \tcode{seconds}. +\begin{note} +This specialization handles hours, minutes, seconds, and fractional seconds since midnight. +Typical uses are with \tcode{milliseconds}, \tcode{microseconds} and \tcode{nanoseconds}. +\end{note} + +\indexlibrary{\idxcode{time_of_day<\placeholder{sub-second duration}>}!constructor}% +\begin{itemdecl} +explicit constexpr time_of_day(precision since_midnight) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Constructs an object of type \tcode{time_of_day} +in 24-hour format +corresponding to \tcode{since_midnight} fractional seconds after 00:00:00. + +\pnum +\postconditions +\tcode{hours()} returns the integral number of hours +\tcode{since_midnight} is after 00:00:00. +\tcode{minutes()} returns the integral number of minutes +\tcode{since_midnight }is after \tcode{(\textrm{00:00:00} + hours())}. +\tcode{seconds()} returns the integral number of seconds +\tcode{since_midnight }is after \tcode{(\textrm{00:00:00} + hours() + minutes())}. +\tcode{subseconds()} returns the integral number of fractional seconds +\tcode{since_midnight} is after \tcode{(\textrm{00:00:00} + hours() + minutes() + seconds())}. +\end{itemdescr} + +\indexlibrarymember{hours}{time_of_day<\placeholder{sub-second duration}>}% +\begin{itemdecl} +constexpr chrono::hours hours() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +The stored hour of \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{minutes}{time_of_day<\placeholder{sub-second duration}>}% +\begin{itemdecl} +constexpr chrono::minutes minutes() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +The stored minute of \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{seconds}{time_of_day<\placeholder{sub-second duration}>}% +\begin{itemdecl} +constexpr chrono::seconds seconds() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +The stored second of \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{subseconds}{time_of_day<\placeholder{sub-second duration}>}% +\begin{itemdecl} +constexpr duration subseconds() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +The stored subsecond of \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator precision}{time_of_day<\placeholder{sub-second duration}>}% +\begin{itemdecl} +explicit constexpr operator precision() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +The number of subseconds since midnight. +\end{itemdescr} + +\indexlibrarymember{to_duration}{time_of_day<\placeholder{sub-second duration}>}% +\begin{itemdecl} +constexpr precision to_duration() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{precision\{*this\}}. +\end{itemdescr} + +\indexlibrarymember{make24}{time_of_day<\placeholder{sub-second duration}>}% +\begin{itemdecl} +constexpr void make24() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +If \tcode{*this} is a 12-hour time, +converts to a 24-hour time. +Otherwise, no effects. +\end{itemdescr} + +\indexlibrarymember{make12}{time_of_day<\placeholder{sub-second duration}>}% +\begin{itemdecl} +constexpr void make12() noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +If \tcode{*this} is a 24-hour time, +converts to a 12-hour time. +Otherwise, no effects. +\end{itemdescr} + +\rSec3[time.tod.io]{Formatted output} + +\indexlibrarymember{operator<<}{time_of_day}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const time_of_day& t); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +If \tcode{t} is a 24-hour time, +outputs to \tcode{os} according to the format +\tcode{"\%H00"}\iref{time.format}. +Otherwise +outputs to \tcode{os} according to the format +\tcode{"\%I\%p"}\iref{time.format}. + +\pnum +\returns \tcode{os}. + +\pnum +\begin{example} +\begin{codeblock} +for (hours h : {1h, 18h}) { + time_of_day tod(h); + os << tod << '\n'; + tod.make12() + os << tod << '\n'; +} +\end{codeblock} + +Produces the output: + +\begin{codeblock} +0100 +1am +1800 +6pm +\end{codeblock} +\end{example} +\end{itemdescr} + +\indexlibrarymember{operator<<}{time_of_day}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const time_of_day& t); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +If \tcode{t} is a 24-hour time, +outputs to \tcode{os} according to the format +\tcode{"\%H:\%M"}\iref{time.format}. +Otherwise +outputs to \tcode{os} according to the format +\tcode{"\%I:\%M\%p"}\iref{time.format}. + +\pnum +\returns \tcode{os}. + +\begin{example} +\begin{codeblock} +for (minutes m : {68min, 1095min}) { + time_of_day tod(m); + os << tod << '\n'; + tod.make12() + os << tod << '\n'; +} +\end{codeblock} + +Produces the output: + +\begin{codeblock} +01:08 +1:08am +18:15 +6:15pm +\end{codeblock} +\end{example} +\end{itemdescr} + +\indexlibrarymember{operator<<}{time_of_day}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const time_of_day& t); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +If \tcode{t} is a 24-hour time, +outputs to \tcode{os} according to the format +\tcode{"\%T"}\iref{time.format}. +Otherwise +outputs to \tcode{os} according to the format +\tcode{"\%I:\%M:\%S\%p"}\iref{time.format}. + +\pnum +\returns \tcode{os}. + +\begin{example} +\begin{codeblock} +for (seconds s : {4083s, 65745s}) { + time_of_day tod(s); + os << tod << '\n'; + tod.make12() + os << tod << '\n'; +} +\end{codeblock} + +Produces the output: + +\begin{codeblock} +01:08:03 +1:08:03am +18:15:45 +6:15:45pm +\end{codeblock} +\end{example} +\end{itemdescr} + +\indexlibrarymember{operator<<}{time_of_day<\placeholder{sub-second duration}>}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const time_of_day>& t); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +If \tcode{t} is a 24-hour time, +outputs to \tcode{os} according to the format +\tcode{"\%T"}\iref{time.format}. +Otherwise +outputs to \tcode{os} according to the format +\tcode{"\%I:\%M:\%S\%p"}\iref{time.format}. + +\pnum +\returns \tcode{os}. + +\begin{example} +\begin{codeblock} +for (milliseconds ms : {4083007ms, 65745123ms}) { + time_of_day tod(ms); + os << tod << '\n'; + tod.make12() + os << tod << '\n'; +} +\end{codeblock} + +Produces the output: + +\begin{codeblock} +01:08:03.007 +1:08:03.007am +18:15:45.123 +6:15:45.123pm +\end{codeblock} +\end{example} +\end{itemdescr} + +\rSec2[time.zone]{Time zones} + +\rSec3[time.zone.general]{In general} + +\pnum +\ref{time.zone} describes an interface for accessing +the IANA Time Zone database described in RFC 6557, +that interoperates with \tcode{sys_time} and \tcode{local_time}. +This interface provides time zone support to +both the civil calendar types\iref{time.cal} +and to user-defined calendars. + +\rSec3[time.zone.db]{Time zone database} + +\rSec4[time.zone.db.tzdb]{Class \tcode{tzdb}} +\indexlibrary{\idxcode{tzdb}} + +\begin{codeblock} +namespace std::chrono { + struct tzdb { + string version; + vector zones; + vector links; + vector leaps; + + const time_zone* locate_zone(string_view tz_name) const; + const time_zone* current_zone() const; + }; +} +\end{codeblock} + +\pnum +Each \tcode{vector} in a \tcode{tzdb} object +is sorted to enable fast lookup. + +\indexlibrarymember{locate_zone}{tzdb}% +\begin{itemdecl} +const time_zone* locate_zone(string_view tz_name) const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +If a \tcode{time_zone} is found +for which \tcode{name() == tz_name}, +returns a pointer to that \tcode{time_zone}. +Otherwise +if a \tcode{link} is found +for which \tcode{tz_name == link.name()}, +then a pointer is returned +to the \tcode{time_zone} for which \tcode{zone.name() == link.target()}. +\begin{note} +A \tcode{link} specifies an alternative name for a \tcode{time_zone}. +\end{note} + +\throws +If a \tcode{const time_zone*} cannot be found +as described in the \returns clause, +throws a \tcode{runtime_error}. +\begin{note} +On non-exceptional return, the return value is always a pointer to a valid \tcode{time_zone}. +\end{note} +\end{itemdescr} + +\indexlibrarymember{current_zone}{tzdb}% +\begin{itemdecl} +const time_zone* current_zone() const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +A pointer to the time zone which the computer has set as its local time zone. +\end{itemdescr} + +\rSec4[time.zone.db.list]{Class \tcode{tzdb_list}} +\indexlibrary{\idxcode{tzdb_list}} + +\begin{codeblock} +namespace std::chrono { + class tzdb_list { + public: + tzdb_list(const tzdb_list&) = delete; + tzdb_list& operator=(const tzdb_list&) = delete; + + // unspecified additional constructors + + class const_iterator; + + const tzdb& front() const noexcept; + + const_iterator erase_after(const_iterator p); + + const_iterator begin() const noexcept; + const_iterator end() const noexcept; + + const_iterator cbegin() const noexcept; + const_iterator cend() const noexcept; + }; +} +\end{codeblock} + +\pnum +The \tcode{tzdb_list} database is a singleton; +the unique object of type \tcode{tzdb_list} can be +accessed via the \tcode{get_tzdb_list()} function. +\begin{note} +This access is only needed for those applications +that need to have long uptimes and +have a need to update the time zone database while running. +Other applications can implicitly access the \tcode{front()} of this list +via the read-only namespace scope functions +\tcode{get_tzdb()}, +\tcode{locate_zone()}, and +\tcode{current_zone()}. +\end{note} +The \tcode{tzdb_list} object contains a list of \tcode{tzdb} objects. + +\pnum +\tcode{tzdb_list::const_iterator} is a constant iterator +which meets the forward iterator requirements +and has a value type of \tcode{tzdb}. + +\indexlibrarymember{front}{tzdb_list}% +\begin{itemdecl} +const tzdb& front() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +A reference to the first \tcode{tzdb} in the container. + +\pnum +\remarks +This operation is thread-safe with respect to \tcode{reload_tzdb()}. +\begin{note} +\tcode{reload_tzdb()} pushes a new \tcode{tzdb} +onto the front of this container. +\end{note} +\end{itemdescr} + +\indexlibrarymember{erase_after}{tzdb_list}% +\begin{itemdecl} +const_iterator erase_after(const_iterator p); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\requires +The iterator following \tcode{p} is dereferenceable. + +\pnum +\effects +Erases the \tcode{tzdb} referred to by the iterator following \tcode{p}. + +\pnum +\returns +An iterator pointing to the element following the one that was erased, +or \tcode{end()} if no such element exists. + +\pnum +\remarks +No pointers, references, or iterators are invalidated +except those referring to the erased \tcode{tzdb}. +\begin{note} +It is not possible to erase the \tcode{tzdb} +referred to by \tcode{begin()}. +\end{note} + +\pnum +\throws Nothing. +\end{itemdescr} + +\indexlibrarymember{begin}{tzdb_list}% +\begin{itemdecl} +const_iterator begin() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +An iterator referring to the first \tcode{tzdb} in the container. +\end{itemdescr} + +\indexlibrarymember{end}{tzdb_list}% +\begin{itemdecl} +const_iterator end() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +An iterator referring to the position one past the last \tcode{tzdb} in the container. +\end{itemdescr} + +\indexlibrarymember{cbegin}{tzdb_list}% +\begin{itemdecl} +const_iterator cbegin() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{begin()}. +\end{itemdescr} + +\indexlibrarymember{cend}{tzdb_list}% +\begin{itemdecl} +const_iterator cend() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{end()}. +\end{itemdescr} + +\rSec4[time.zone.db.access]{Time zone database access} + +\indexlibrary{\idxcode{get_tzdb_list}}% +\begin{itemdecl} +tzdb_list& get_tzdb_list(); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +If this is the first access to the time zone database, +initializes the database. +If this call initializes the database, +the resulting database will be a \tcode{tzdb_list} +holding a single initialized \tcode{tzdb}. + +\pnum +\returns +A reference to the database. + +\pnum +\remarks +It is safe to call this function from multiple threads at one time. + +\pnum +\throws +\tcode{runtime_error} if for any reason +a reference cannot be returned to a valid \tcode{tzdb_list} +containing one or more valid \tcode{tzdb}s. +\end{itemdescr} + +\indexlibrary{\idxcode{get_tzdb}}% +\begin{itemdecl} +const tzdb& get_tzdb(); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{get_tzdb_list().front()}. +\end{itemdescr} + +\indexlibrary{\idxcode{locate_zone}}% +\begin{itemdecl} +const time_zone* locate_zone(string_view tz_name); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{get_tzdb().locate_zone(tz_name)}. + +\pnum +\begin{note} +The time zone database will be initialized +if this is the first reference to the database. +\end{note} +\end{itemdescr} + +\indexlibrary{\idxcode{current_zone}}% +\begin{itemdecl} +const time_zone* current_zone(); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{get_tzdb().current_zone()}. +\end{itemdescr} + +\rSec4[time.zone.db.remote]{Remote time zone database support} + +\pnum +The local time zone database +is that supplied by the implementation +when the program first accesses the database, +for example via \tcode{current_zone()}. +While the program is running, +the implementation may choose to update the time zone database. +This update shall not impact the program in any way +unless the program calls the functions in this section. +This potentially updated time zone database +is referred to as the \defn{remote time zone database}. + +\indexlibrary{\idxcode{reload_tzdb}}% +\begin{itemdecl} +const tzdb& reload_tzdb(); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +This function first checks +the version of the remote time zone database. +If the versions of the local and remote databases are the same, +there are no effects. +Otherwise the remote database is pushed +to the front of the \tcode{tzdb_list} +accessed by \tcode{get_tzdb_list()}. + +\pnum +\returns \tcode{get_tzdb_list().front()}. + +\pnum +\remarks +No pointers, references, or iterators are invalidated. + +\pnum +\remarks +This function is thread-safe with respect to +\tcode{get_tzdb_list().front()} and \tcode{get_tzdb_list().erase_after()}. + +\pnum +\throws +\tcode{runtime_error} if for any reason +a reference cannot be returned to a valid \tcode{tzdb}. +\end{itemdescr} + +\indexlibrary{\idxcode{remote_version}}% +\begin{itemdecl} +string remote_version(); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns The latest remote database version. + +\begin{note} +This can be compared with \tcode{get_tzdb().version} +to discover if the local and remote databases are equivalent. +\end{note} +\end{itemdescr} + +\rSec3[time.zone.exception]{Exception classes} + +\rSec4[time.zone.exception.nonexist]{Class \tcode{nonexistent_local_time}} +\indexlibrary{\idxcode{nonexistent_local_time}} + +\begin{codeblock} +namespace std::chrono { + class nonexistent_local_time : public runtime_error { + public: + template + nonexistent_local_time(const local_time& tp, const local_info& i); + }; +} +\end{codeblock} + +\pnum +\tcode{nonexistent_local_time} is thrown when +an attempt is made +to convert a non-existent \tcode{local_time} to a \tcode{sys_time} +without specifying \tcode{choose::earliest} or \tcode{choose::latest}. + +\indexlibrary{\idxcode{nonexistent_local_time}!constructor}% +\begin{itemdecl} +template + nonexistent_local_time(const local_time& tp, const local_info& i); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\requires \tcode{i.result == local_info::nonexistent}. + +\pnum +\effects +Constructs a \tcode{nonexistent_local_time} +by initializing the base class with a sequence of \tcode{char} +equivalent to that produced by \tcode{os.str()} +initialized as shown below: + +\begin{codeblock} +ostringstream os; +os << tp << " is in a gap between\n" + << local_seconds{i.first.end.time_since_epoch()} + i.first.offset << ' ' + << i.first.abbrev << " and\n" + << local_seconds{i.second.begin.time_since_epoch()} + i.second.offset << ' ' + << i.second.abbrev + << " which are both equivalent to\n" + << i.first.end << " UTC"; +\end{codeblock} + +\pnum +\begin{example} +\begin{codeblock} +#include +#include + +int main() { + using namespace std::chrono; + try { + auto zt = zoned_time{"America/New_York", + local_days{Sunday[2]/March/2016} + 2h + 30min}; + } catch (const nonexistent_local_time& e) { + std::cout << e.what() << '\n'; + } +} +\end{codeblock} + +Produces the output: + +\begin{codeblock} +2016-03-13 02:30:00 is in a gap between +2016-03-13 02:00:00 EST and +2016-03-13 03:00:00 EDT which are both equivalent to +2016-03-13 07:00:00 UTC +\end{codeblock} +\end{example} +\end{itemdescr} + +\rSec4[time.zone.exception.ambig]{Class \tcode{ambiguous_local_time}} +\indexlibrary{\idxcode{ambiguous_local_time}} + +\begin{codeblock} +namespace std::chrono { + class ambiguous_local_time : public runtime_error { + public: + template + ambiguous_local_time(const local_time& tp, const local_info& i); + }; +} +\end{codeblock} + +\pnum +\tcode{ambiguous_local_time} is thrown when +an attempt is made +to convert an ambiguous \tcode{local_time} to a \tcode{sys_time} +without specifying \tcode{choose::earliest} or \tcode{choose::latest}. + +\indexlibrary{\idxcode{ambiguous_local_time}!constructor}% +\begin{itemdecl} +template + ambiguous_local_time(const local_time& tp, const local_info& i); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\requires \tcode{i.result == local_info::ambiguous}. + +\pnum +\effects +Constructs an \tcode{ambiguous_local_time} +by initializing the base class with a sequence of \tcode{char} +equivalent to that produced by \tcode{os.str()} +initialized as shown below: + +\begin{codeblock} +ostringstream os; +os << tp << " is ambiguous. It could be\n" + << tp << ' ' << i.first.abbrev << " == " + << tp - i.first.offset << " UTC or\n" + << tp << ' ' << i.second.abbrev << " == " + << tp - i.second.offset << " UTC"; +\end{codeblock} + +\pnum +\begin{example} +\begin{codeblock} +#include +#include + +int main() { + using namespace std::chrono; + try { + auto zt = zoned_time{"America/New_York", + local_days{Sunday[1]/November/2016} + 1h + 30min}; + } catch (const ambiguous_local_time& e) { + std::cout << e.what() << '\n'; + } +} +\end{codeblock} + +Produces the output: + +\begin{codeblock} +2016-11-06 01:30:00 is ambiguous. It could be +2016-11-06 01:30:00 EDT == 2016-11-06 05:30:00 UTC or +2016-11-06 01:30:00 EST == 2016-11-06 06:30:00 UTC +\end{codeblock} +\end{example} +\end{itemdescr} + +\rSec3[time.zone.info]{Information classes} + +\rSec4[time.zone.info.sys]{Class \tcode{sys_info}} +\indexlibrary{\idxcode{sys_info}} + +\begin{codeblock} +namespace std::chrono { + struct sys_info { + sys_seconds begin; + sys_seconds end; + seconds offset; + minutes save; + string abbrev; + }; +} +\end{codeblock} + +\pnum +A \tcode{sys_info} structure can be obtained +from the combination of a \tcode{time_zone} and +either a \tcode{sys_time} or \tcode{local_time}. +It can also be obtained from a \tcode{zoned_time}, +which is effectively a pair of a \tcode{time_zone} and \tcode{sys_time}. + +\pnum +\begin{note} +This type provides a low-level interface to time zone information. +Typical conversions from \tcode{sys_time} to \tcode{local_time} +will use this structure implicitly, not explicitly. +\end{note} + +\pnum +\indexlibrarymember{begin}{sys_info}% +\indexlibrarymember{end}{sys_info}% +The \tcode{begin} and \tcode{end} data members indicate that, +for the associated \tcode{time_zone} and \tcode{time_point}, +the \tcode{offset} and \tcode{abbrev} are in effect in the range \range{begin}{end}. +This information can be used to efficiently iterate the transitions of a \tcode{time_zone}. + +\pnum +\indexlibrarymember{offset}{sys_info}% +The \tcode{offset} data member indicates +the UTC offset in effect +for the associated \tcode{time_zone} and \tcode{time_point}. +The relationship between \tcode{local_time} and \tcode{sys_time} is: + +\begin{codeblock} +offset = local_time - sys_time +\end{codeblock} + +\pnum +\indexlibrarymember{save}{sys_info}% +The \tcode{save} data member is extra information not normally needed +for conversion between \tcode{local_time} and \tcode{sys_time}. +If \tcode{save != 0min}, this \tcode{sys_info} is said to be on ``daylight saving'' time, +and \tcode{offset - save} suggests what offset this \tcode{time_zone} might use +if it were off daylight saving time. +However, this information should not be taken as authoritative. +The only sure way to get such information +is to query the \tcode{time_zone} with a \tcode{time_point} +that returns a \tcode{sys_info} where \tcode{save == 0min}. +There is no guarantee what \tcode{time_point} might return such a \tcode{sys_info} +except that it is guaranteed not to be in the range \range{begin}{end} +(if \tcode{save != 0min} for this \tcode{sys_info}). + +\pnum +\indexlibrarymember{abbrev}{sys_info}% +The \tcode{abbrev} data member indicates +the current abbreviation used for the associated \tcode{time_zone} and \tcode{time_point}. +Abbreviations are not unique among the \tcode{time_zones}, +and so one cannot reliably map abbreviations back to a \tcode{time_zone} and UTC offset. + +\indexlibrarymember{operator<<}{sys_info} +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const sys_info& r); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Streams out the \tcode{sys_info} object \tcode{r} in an unspecified format. +\end{itemdescr} + +\rSec4[time.zone.info.local]{Class \tcode{local_info}} +\indexlibrary{\idxcode{local_info}} + +\indexlibrarymember{unique}{local_info}% +\indexlibrarymember{nonexistent}{local_info}% +\indexlibrarymember{ambiguous}{local_info}% +\indexlibrarymember{result}{local_info}% +\indexlibrarymember{first}{local_info}% +\indexlibrarymember{second}{local_info}% +\begin{codeblock} +namespace std::chrono { + struct local_info { + static constexpr int unique = 0; + static constexpr int nonexistent = 1; + static constexpr int ambiguous = 2; + + int result; + sys_info first; + sys_info second; + }; +} +\end{codeblock} + +\pnum +\begin{note} +This type provides a low-level interface to time zone information. +Typical conversions from \tcode{local_time} to \tcode{sys_time} +will use this structure implicitly, not explicitly. +\end{note} + +\pnum +Describes the result of converting a \tcode{local_time} to a \tcode{sys_time} +as follows: +\begin{itemize} +\item +When a \tcode{local_time} to \tcode{sys_time} conversion is unique, +\tcode{result == unique}, +\tcode{first} will be filled out with the correct \tcode{sys_info}, +and +\tcode{second} will be zero-initialized. + +\item +If the conversion stems from a nonexistent \tcode{local_time} +then \tcode{result == nonexistent}, +\tcode{first} will be filled out with the \tcode{sys_info} +that ends just prior to the \tcode{local_time}, +and +\tcode{second} will be filled out with the \tcode{sys_info} +that begins just after the \tcode{local_time}. + +\item +If the conversion stems from an ambiguous \tcode{local_time}, +then \tcode{result == ambiguous}, +\tcode{first} will be filled out with the \tcode{sys_info} +that ends just after the \tcode{local_time}, +and +\tcode{second} will be filled out with the \tcode{sys_info} +that starts just before the \tcode{local_time}. +\end{itemize} + +\indexlibrarymember{operator<<}{local_info}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, const local_info& r); +\end{itemdecl} + +\begin{itemdescr} +\pnum +Streams out the \tcode{local_info} object \tcode{r} in an unspecified format. +\end{itemdescr} + +\rSec3[time.zone.timezone]{Class \tcode{time_zone}} + +\rSec4[time.zone.overview]{Overview} +\indexlibrary{\idxcode{time_zone}} + +\begin{codeblock} +namespace std::chrono { + class time_zone { + public: + time_zone(time_zone&&) = default; + time_zone& operator=(time_zone&&) = default; + + // unspecified additional constructors + + string_view name() const noexcept; + + template sys_info get_info(const sys_time& st) const; + template local_info get_info(const local_time& tp) const; + + template + sys_time> + to_sys(const local_time& tp) const; + + template + sys_time> + to_sys(const local_time& tp, choose z) const; + + template + local_time> + to_local(const sys_time& tp) const; + }; +} +\end{codeblock} + +\pnum +A \tcode{time_zone} represents all time zone transitions +for a specific geographic area. +\tcode{time_zone} construction is unspecified, +and performed as part of database initialization. +\begin{note} +\tcode{const time_zone} objects can be accessed +via functions such as \tcode{locate_zone}. +\end{note} + +\rSec4[time.zone.members]{Member functions} + +\indexlibrarymember{name}{time_zone}% +\begin{itemdecl} +string_view name() const noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns The name of the \tcode{time_zone}. + +\pnum +\begin{example} +\tcode{"America/New_York"}. +\end{example} +\end{itemdescr} + +\indexlibrarymember{get_info}{time_zone}% +\begin{itemdecl} +template + sys_info get_info(const sys_time& st) const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +A \tcode{sys_info} \tcode{i} for which +\tcode{st} is in the range \range{i.begin}{i.end}. +\end{itemdescr} + +\indexlibrarymember{get_info}{time_zone}% +\begin{itemdecl} +template + local_info get_info(const local_time& tp) const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +A \tcode{local_info} for \tcode{tp}. +\end{itemdescr} + +\indexlibrarymember{to_sys}{time_zone}% +\begin{itemdecl} +template + sys_time> + to_sys(const local_time& tp) const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +A \tcode{sys_time} that is at least as fine as \tcode{seconds}, +and will be finer if the argument \tcode{tp} has finer precision. +This \tcode{sys_time} is the UTC equivalent of \tcode{tp} +according to the rules of this \tcode{time_zone}. + +\pnum +\throws +If the conversion from \tcode{tp} to a \tcode{sys_time} is ambiguous, +throws \tcode{ambiguous_local_time}. +If the \tcode{tp} represents a non-existent time between two UTC \tcode{time_points}, +throws \tcode{nonexistent_local_time}. +\end{itemdescr} + +\indexlibrarymember{to_sys}{time_zone}% +\begin{itemdecl} +template + sys_time> + to_sys(const local_time& tp, choose z) const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +A \tcode{sys_time} that is at least as fine as \tcode{seconds}, +and will be finer if the argument \tcode{tp} has finer precision. +This \tcode{sys_time} is the UTC equivalent of \tcode{tp} +according to the rules of this \tcode{time_zone}. +If the conversion from \tcode{tp} to a \tcode{sys_time} is ambiguous, +returns the earlier \tcode{sys_time} if \tcode{z == choose::earliest}, and +returns the later \tcode{sys_time} if \tcode{z == choose::latest}. +If the \tcode{tp} represents a non-existent time between two UTC \tcode{time_points}, +then the two UTC \tcode{time_points} will be the same, +and that UTC \tcode{time_point} will be returned. +\end{itemdescr} + +\indexlibrarymember{to_local}{time_zone}% +\begin{itemdecl} +template + local_time> + to_local(const sys_time& tp) const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +The \tcode{local_time} associated with \tcode{tp} and this \tcode{time_zone}. +\end{itemdescr} + +\rSec4[time.zone.nonmembers]{Non-member functions} + +\indexlibrarymember{operator==}{time_zone}% +\begin{itemdecl} +bool operator==(const time_zone& x, const time_zone& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x.name() == y.name()}. +\end{itemdescr} + +\indexlibrarymember{operator<}{time_zone}% +\begin{itemdecl} +bool operator<(const time_zone& x, const time_zone& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x.name() < y.name()}. +\end{itemdescr} + +\rSec3[time.zone.zonedtraits]{Class template \tcode{zoned_traits}} +\indexlibrary{\idxcode{zoned_traits}} + +\begin{codeblock} +namespace std::chrono { + template struct zoned_traits {}; +} +\end{codeblock} + +\pnum +\tcode{zoned_traits} provides a means for customizing +the behavior of \tcode{zoned_time} +for the \tcode{zoned_time} default constructor, +and constructors taking \tcode{string_view}. +A specialization for \tcode{const time_zone*} is provided by the implementation: + +\begin{codeblock} +namespace std::chrono { + template<> struct zoned_traits { + static const time_zone* default_zone(); + static const time_zone* locate_zone(string_view name); + }; +} +\end{codeblock} + +\indexlibrarymember{default_zone}{zoned_traits}% +\begin{itemdecl} +static const time_zone* default_zone(); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{std::chrono::locate_zone("UTC")}. +\end{itemdescr} + +\indexlibrarymember{locate_zone}{zoned_traits}% +\begin{itemdecl} +static const time_zone* locate_zone(string_view name); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{std::chrono::locate_zone(name)}. +\end{itemdescr} + +\rSec3[time.zone.zonedtime]{Class template \tcode{zoned_time}} + +\rSec4[time.zone.zonedtime.overview]{Overview} +\indexlibrary{\idxcode{zoned_time}} + +\begin{codeblock} +namespace std::chrono { + template + class zoned_time { + public: + using duration = common_type_t; + + private: + TimeZonePtr zone_; // \expos + sys_time tp_; // \expos + + using traits = zoned_traits; // \expos + + public: + zoned_time(); + zoned_time(const zoned_time&) = default; + zoned_time& operator=(const zoned_time&) = default; + + zoned_time(const sys_time& st); + explicit zoned_time(TimeZonePtr z); + explicit zoned_time(string_view name); + + template + zoned_time(const zoned_time& zt) noexcept; + + zoned_time(TimeZonePtr z, const sys_time& st); + zoned_time(string_view name, const sys_time& st); + + zoned_time(TimeZonePtr z, const local_time& tp); + zoned_time(string_view name, const local_time& tp); + zoned_time(TimeZonePtr z, const local_time& tp, choose c); + zoned_time(string_view name, const local_time& tp, choose c); + + template + zoned_time(TimeZonePtr z, const zoned_time& zt); + template + zoned_time(TimeZonePtr z, const zoned_time& zt, choose); + + zoned_time(string_view name, const zoned_time& zt); + zoned_time(string_view name, const zoned_time& zt, choose); + + zoned_time& operator=(const sys_time& st); + zoned_time& operator=(const local_time& ut); + + operator sys_time() const; + explicit operator local_time() const; + + TimeZonePtr get_time_zone() const; + local_time get_local_time() const; + sys_time get_sys_time() const; + sys_info get_info() const; + }; + + zoned_time() -> zoned_time; + + template + zoned_time(sys_time) + -> zoned_time>; + + template + zoned_time(TimeZonePtr, sys_time) + -> zoned_time, TimeZonePtr>; + + template + zoned_time(TimeZonePtr, local_time, choose = choose::earliest) + -> zoned_time, TimeZonePtr>; + + template + zoned_time(TimeZonePtr, zoned_time, choose = choose::earliest) + -> zoned_time, TimeZonePtr>; + + zoned_time(string_view) -> zoned_time; + + template + zoned_time(string_view, sys_time) + -> zoned_time>; + + template + zoned_time(string_view, local_time, choose = choose::earliest) + -> zoned_time>; + + template + zoned_time(TimeZonePtr, zoned_time, choose = choose::earliest) + -> zoned_time; +} +\end{codeblock} + +\pnum +\tcode{zoned_time} represents a logical pairing of +a \tcode{time_zone} and a \tcode{time_point} with precision \tcode{Duration}. +\tcode{zoned_time} maintains the invariant that +it always refers to a valid time zone and +represents a point in time that exists and is not ambiguous +in that time zone. + +\pnum +If \tcode{Duration} is not a specialization of \tcode{chrono::duration}, +the program is ill-formed. + +\rSec4[time.zone.zonedtime.ctor]{Constructors} + +\indexlibrary{\idxcode{zoned_time}!constructor|(}% +\begin{itemdecl} +zoned_time(); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +This constructor does not participate in overload resolution unless +\tcode{traits::default_zone()} is a well-formed expression. + +\pnum +\effects +Constructs a \tcode{zoned_time} by +initializing \tcode{zone_} with \tcode{traits::default_zone()} and +default constructing \tcode{tp_}. +\end{itemdescr} + +\begin{itemdecl} +zoned_time(const sys_time& st); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +This constructor does not participate in overload resolution unless +\tcode{traits::default_zone()} is a well-formed expression. + +\pnum +\effects +Constructs a \tcode{zoned_time} by +initializing \tcode{zone_} with \tcode{traits::default_zone()} and \tcode{tp_} with \tcode{st}. +\end{itemdescr} + +\begin{itemdecl} +explicit zoned_time(TimeZonePtr z); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\requires \tcode{z} refers to a time zone. + +\pnum +\effects Constructs a \tcode{zoned_time} by +initializing \tcode{zone_} with \tcode{std::move(z)}. +% FIXME: What about tp_? +\end{itemdescr} + +\begin{itemdecl} +explicit zoned_time(string_view name); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +This constructor does not participate in overload resolution unless +\tcode{traits::locate_zone(string_view\{\})} is a well-formed expression and +\tcode{zoned_time} is constructible from the return type of \tcode{traits::locate_zone(string_view\{\})}. + +\pnum +\effects +Constructs a \tcode{zoned_time} by +initializing \tcode{zone_} with \tcode{traits::locate_zone(name)} and +default constructing \tcode{tp_}. +\end{itemdescr} + +\begin{itemdecl} +template + zoned_time(const zoned_time& y) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +Does not participate in overload resolution unless +\tcode{sys_time} is implicitly convertible to \tcode{sys_time}. + +\pnum +\effects +Constructs a \tcode{zoned_time} by +initializing \tcode{zone_} with \tcode{y.zone_} and \tcode{tp_} with \tcode{y.tp_}. +\end{itemdescr} + +\begin{itemdecl} +zoned_time(TimeZonePtr z, const sys_time& st); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\requires \tcode{z} refers to a time zone. + +\pnum +\effects +Constructs a \tcode{zoned_time} by +initializing \tcode{zone_} with \tcode{std::move(z)} and \tcode{tp_} with \tcode{st}. +\end{itemdescr} + +\begin{itemdecl} +zoned_time(string_view name, const sys_time& st); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +This constructor does not participate in overload resolution unless +\tcode{zoned_time} is constructible from the return type of \tcode{traits::locate_zone(name)} and \tcode{st}. + +\pnum +\effects +Equivalent to construction with \tcode{\{traits::locate_zone(name), st\}}. +\end{itemdescr} + +\begin{itemdecl} +zoned_time(TimeZonePtr z, const local_time& tp); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\requires \tcode{z} refers to a time zone. + +\pnum +\remarks +This constructor does not participate in overload resolution unless +\begin{codeblock} +declval()->to_sys(local_time{}) +\end{codeblock} +is convertible to \tcode{sys_time}. + +\pnum +\effects +Constructs a \tcode{zoned_time} by +initializing \tcode{zone_} with \tcode{std::move(z)} and \tcode{tp_} with \tcode{zone_->to_sys(tp)}. +\end{itemdescr} + +\begin{itemdecl} +zoned_time(string_view name, const local_time& tp); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +This constructor does not participate in overload resolution unless +\tcode{zoned_time} is constructible from the return type of \tcode{traits::locate_zone(name)} and \tcode{tp}. + +\pnum +\effects +Equivalent to construction with \tcode{\{traits::locate_zone(name), tp\}}. +\end{itemdescr} + +\begin{itemdecl} +zoned_time(TimeZonePtr z, const local_time& tp, choose c); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\requires \tcode{z} refers to a time zone. + +\pnum +\remarks +This constructor does not participate in overload resolution unless +\begin{codeblock} +decltype(declval()->to_sys(local_time{}, choose::earliest)) +\end{codeblock} +is convertible to \tcode{sys_time}. + +\pnum +\effects +Constructs a \tcode{zoned_time} by +initializing \tcode{zone_} with \tcode{std::move(z)} and \tcode{tp_} with \tcode{zone_->to_sys(tp, c)}. +\end{itemdescr} + +\begin{itemdecl} +zoned_time(string_view name, const local_time& tp, choose c); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +This constructor does not participate in overload resolution unless +\tcode{zoned_time} is constructible from +the return type of \tcode{traits::locate_zone(name)}, \tcode{local_time}, and \tcode{choose}. + +\pnum +\effects +Equivalent to construction with \tcode{\{traits::locate_zone(name), tp, c\}}. +\end{itemdescr} + +\begin{itemdecl} +template + zoned_time(TimeZonePtr z, const zoned_time& y); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +Does not participate in overload resolution unless +\tcode{sys_time} is implicitly convertible to \tcode{sys_time}. + +\pnum +\requires \tcode{z} refers to a valid time zone. + +\pnum +\effects Constructs a \tcode{zoned_time} by +initializing \tcode{zone_} with \tcode{std::move(z)} and \tcode{tp_} with \tcode{y.tp_}. +\end{itemdescr} + +\begin{itemdecl} +template + zoned_time(TimeZonePtr z, const zoned_time& y, choose); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +Does not participate in overload resolution unless +\tcode{sys_time} is implicitly convertible to \tcode{sys_time}. + +\pnum +\requires \tcode{z} refers to a valid time zone. + +\pnum +\effects +Equivalent to construction with \tcode{\{z, y\}}. + +\pnum +\begin{note} +The \tcode{choose} parameter has no effect. +\end{note} +\end{itemdescr} + +\begin{itemdecl} +zoned_time(string_view name, const zoned_time& y); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +This constructor does not participate in overload resolution unless +\tcode{zoned_time} is constructible from the return type of \tcode{traits::locate_zone(name)} and \tcode{zoned_time}. + +\pnum +\effects +Equivalent to construction with \tcode{\{traits::locate_zone(name), y\}}. +\end{itemdescr} + +\begin{itemdecl} +zoned_time(string_view name, const zoned_time& y, choose c); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +This constructor does not participate in overload resolution unless +\tcode{zoned_time} is constructible from +the return type of \tcode{traits::locate_zone(name)}, \tcode{zoned_time}, and \tcode{choose}. + +\pnum +\effects +Equivalent to construction with \tcode{\{traits::locate_zone(name), y, c\}}. + +\pnum +\begin{note} +The \tcode{choose} parameter has no effect. +\end{note} +\end{itemdescr} +\indexlibrary{\idxcode{zoned_time}!constructor|)}% + +\rSec4[time.zone.zonedtime.members]{Member functions} + +\indexlibrarymember{operator=}{zoned_time}% +\begin{itemdecl} +zoned_time& operator=(const sys_time& st); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +After assignment, \tcode{get_sys_time() == st}. +This assignment has no effect on the return value of \tcode{get_time_zone()}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator=}{zoned_time}% +\begin{itemdecl} +zoned_time& operator=(const local_time& lt); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +After assignment, \tcode{get_local_time() == lt}. +This assignment has no effect on the return value of \tcode{get_time_zone()}. + +\pnum +\returns \tcode{*this}. +\end{itemdescr} + +\indexlibrarymember{operator sys_time}{zoned_time}% +\begin{itemdecl} +operator sys_time() const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{get_sys_time()}. +\end{itemdescr} + +\indexlibrarymember{operator local_time}{zoned_time}% +\begin{itemdecl} +explicit operator local_time() const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{get_local_time()}. +\end{itemdescr} + +\indexlibrarymember{get_time_zone}{zoned_time}% +\begin{itemdecl} +TimeZonePtr get_time_zone() const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{zone_}. +\end{itemdescr} + +\indexlibrarymember{get_local_time}{zoned_time}% +\begin{itemdecl} +local_time get_local_time() const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{zone_->to_local(tp_)}. +\end{itemdescr} + +\indexlibrarymember{get_sys_time}{zoned_time}% +\begin{itemdecl} +sys_time get_sys_time() const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{tp_}. +\end{itemdescr} + +\indexlibrarymember{get_info}{zoned_time}% +\begin{itemdecl} +sys_info get_info() const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{zone_->get_info(tp_)}. +\end{itemdescr} + +\rSec4[time.zone.zonedtime.nonmembers]{Non-member functions} + +\indexlibrarymember{operator==}{zoned_time}% +\begin{itemdecl} +template + bool operator==(const zoned_time& x, + const zoned_time& y); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x.zone_ == y.zone_ \&\& x.tp_ == y.tp_}. +\end{itemdescr} + +\indexlibrarymember{operator<<}{zoned_time}% +\begin{itemdecl} +template + basic_ostream& + operator<<(basic_ostream& os, + const zoned_time& t) +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +Streams +the value returned from \tcode{t.get_local_time()} +to \tcode{os} +using the format \tcode{"\%F \%T \%Z"}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\indexlibrarymember{to_stream}{zoned_time}% +\begin{itemdecl} +template + basic_ostream& + to_stream(basic_ostream& os, const charT* fmt, + const zoned_time& tp); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects +First obtains a \tcode{sys_info} via \tcode{tp.get_info()} +which for exposition purposes will be referred to as \tcode{info}. +Then calls \tcode{to_stream(os, fmt, tp.get_local_time(), \&info.abbrev, \&info.offset)}. + +\pnum +\returns \tcode{os}. +\end{itemdescr} + +\rSec3[time.zone.leap]{Class \tcode{leap}} + +\rSec4[time.zone.leap.overview]{Overview} +\indexlibrary{\idxcode{leap}} + +\begin{codeblock} +namespace std::chrono { + class leap { + public: + leap(const leap&) = default; + leap& operator=(const leap&) = default; + + // unspecified additional constructors + + constexpr sys_seconds date() const noexcept; + }; +} +\end{codeblock} + +\pnum +Objects of type \tcode{leap} representing +the date of the leap second insertions +are constructed and stored in the time zone database when initialized. + +\pnum +\begin{example} +\begin{codeblock} +for (auto& l : get_tzdb().leaps) + if (l <= 2018y/March/17d) + cout << l.date() << '\n'; +\end{codeblock} + +Produces the output: + +\begin{codeblock} +1972-07-01 00:00:00 +1973-01-01 00:00:00 +1974-01-01 00:00:00 +1975-01-01 00:00:00 +1976-01-01 00:00:00 +1977-01-01 00:00:00 +1978-01-01 00:00:00 +1979-01-01 00:00:00 +1980-01-01 00:00:00 +1981-07-01 00:00:00 +1982-07-01 00:00:00 +1983-07-01 00:00:00 +1985-07-01 00:00:00 +1988-01-01 00:00:00 +1990-01-01 00:00:00 +1991-01-01 00:00:00 +1992-07-01 00:00:00 +1993-07-01 00:00:00 +1994-07-01 00:00:00 +1996-01-01 00:00:00 +1997-07-01 00:00:00 +1999-01-01 00:00:00 +2006-01-01 00:00:00 +2009-01-01 00:00:00 +2012-07-01 00:00:00 +2015-07-01 00:00:00 +2017-01-01 00:00:00 +\end{codeblock} +\end{example} + +\rSec4[time.zone.leap.members]{Member functions} + +\indexlibrarymember{date}{leap}% +\begin{itemdecl} +constexpr sys_seconds date() const noexcept +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns The date and time at which the leap second was inserted. +\end{itemdescr} + +\rSec4[time.zone.leap.nonmembers]{Non-member functions} + +\indexlibrarymember{operator==}{leap}% +\begin{itemdecl} +constexpr bool operator==(const leap& x, const leap& y) noexcept +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x.date() == y.date()}. +\end{itemdescr} + +\indexlibrarymember{operator<}{leap}% +\begin{itemdecl} +constexpr bool operator<(const leap& x, const leap& y) noexcept +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x.date() < y.date()}. +\end{itemdescr} + +\indexlibrarymember{operator==}{leap}% +\indexlibrarymember{operator==}{sys_time}% +\begin{itemdecl} +template + constexpr bool operator==(const leap& x, const sys_time& y) noexcept +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x.date() == y}. +\end{itemdescr} + +\indexlibrarymember{operator==}{leap}% +\indexlibrarymember{operator==}{sys_time}% +\begin{itemdecl} +template + constexpr bool operator==(const sys_time& x, const leap& y) noexcept +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y == x}. +\end{itemdescr} + +\indexlibrarymember{operator"!=}{leap}% +\indexlibrarymember{operator"!=}{sys_time}% +\begin{itemdecl} +template + constexpr bool operator!=(const leap& x, const sys_time& y) noexcept +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{!(x == y)}. +\end{itemdescr} + +\indexlibrarymember{operator"!=}{leap}% +\indexlibrarymember{operator"!=}{sys_time}% +\begin{itemdecl} +template + constexpr bool operator!=(const sys_time& x, const leap& y) noexcept +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{!(x == y)}. +\end{itemdescr} + +\indexlibrarymember{operator<}{leap}% +\indexlibrarymember{operator<}{sys_time}% +\begin{itemdecl} +template + constexpr bool operator<(const leap& x, const sys_time& y) noexcept +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x.date() < y}. +\end{itemdescr} + +\indexlibrarymember{operator<}{leap}% +\indexlibrarymember{operator<}{sys_time}% +\begin{itemdecl} +template + constexpr bool operator<(const sys_time& x, const leap& y) noexcept +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x < y.date()}. +\end{itemdescr} + +\indexlibrarymember{operator>}{leap}% +\indexlibrarymember{operator>}{sys_time}% +\begin{itemdecl} +template + constexpr bool operator>(const leap& x, const sys_time& y) noexcept +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y < x}. +\end{itemdescr} + +\indexlibrarymember{operator>}{leap}% +\indexlibrarymember{operator>}{sys_time}% +\begin{itemdecl} +template + constexpr bool operator>(const sys_time& x, const leap& y) noexcept +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{y < x}. +\end{itemdescr} + +\indexlibrarymember{operator<=}{leap}% +\indexlibrarymember{operator<=}{sys_time}% +\begin{itemdecl} +template + constexpr bool operator<=(const leap& x, const sys_time& y) noexcept +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{!(y < x)}. +\end{itemdescr} + +\indexlibrarymember{operator<=}{leap}% +\indexlibrarymember{operator<=}{sys_time}% +\begin{itemdecl} +template + constexpr bool operator<=(const sys_time& x, const leap& y) noexcept +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{!(y < x)}. +\end{itemdescr} + +\indexlibrarymember{operator>=}{leap}% +\indexlibrarymember{operator>=}{sys_time}% +\begin{itemdecl} +template + constexpr bool operator>=(const leap& x, const sys_time& y) noexcept +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{!(x < y)}. +\end{itemdescr} + +\indexlibrarymember{operator>=}{leap}% +\indexlibrarymember{operator>=}{sys_time}% +\begin{itemdecl} +template + constexpr bool operator>=(const sys_time& x, const leap& y) noexcept +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{!(x < y)}. +\end{itemdescr} + +\rSec3[time.zone.link]{Class \tcode{link}} + +\rSec4[time.zone.link.overview]{Overview} +\indexlibrary{\idxcode{link}} + \begin{codeblock} namespace std::chrono { - class high_resolution_clock { + class link { public: - using rep = @\unspec@; - using period = ratio<@\unspecnc@, @\unspec{}@>; - using duration = chrono::duration; - using time_point = chrono::time_point<@\unspecnc@, duration>; - static constexpr bool is_steady = @\unspec@; + link(link&&) = default; + link& operator=(link&&) = default; - static time_point now() noexcept; + // unspecified additional constructors + + string_view name() const noexcept; + string_view target() const noexcept; }; } \end{codeblock} +\pnum +A \tcode{link} specifies an alternative name for a \tcode{time_zone}. +\tcode{link}s are constructed when the time zone database is initialized. + +\rSec4[time.zone.link.members]{Member functions} + +\indexlibrarymember{name}{link}% +\begin{itemdecl} +string_view name() const noexcept +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +The alternative name for the time zone. +\end{itemdescr} + +\indexlibrarymember{target}{link}% +\begin{itemdecl} +string_view target() const noexcept +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns +The name of the \tcode{time_zone} for which +this \tcode{link} provides an alternative name. +\end{itemdescr} + +\rSec4[time.zone.link.nonmembers]{Non-member functions} + +\indexlibrarymember{operator==}{link}% +\begin{itemdecl} +bool operator==(const link& x, const link& y) noexcept +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x.name() == y.name()}. +\end{itemdescr} + +\indexlibrarymember{operator<}{link}% +\begin{itemdecl} +bool operator<(const link& x, const link& y) noexcept +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{x.name() < y.name()}. +\end{itemdescr} + +\rSec2[time.format]{Formatting} + +\pnum +Each \tcode{format} overload specified in this subclause +calls \tcode{to_stream} unqualified, +so as to enable argument dependent lookup\iref{basic.lookup.argdep}. + +\indexlibrary{\idxcode{format}|(}% +\begin{itemdecl} +template + basic_string + format(const charT* fmt, const Streamable& s); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +This function shall not participate in overload resolution unless +\begin{codeblock} +to_stream(declval&>(), fmt, s) +\end{codeblock} +is a valid expression. + +\pnum +\effects +Constructs a local variable of type +\tcode{basic_ostringstream} +(named \tcode{os} for exposition purposes). +Executes \tcode{os.exceptions(ios::failbit | ios::badbit)}. +Then calls \tcode{to_stream(os, fmt, s)}. + +\pnum +\returns \tcode{os.str()}. +\end{itemdescr} + +\begin{itemdecl} +template + basic_string + format(const locale& loc, const charT* fmt, const Streamable& s); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +This function shall not participate in overload resolution unless +\begin{codeblock} +to_stream(declval&>(), fmt, s) +\end{codeblock} +is a valid expression. + +\pnum +\effects +Constructs a local variable of type +\tcode{basic_ostringstream} +(named \tcode{os} for exposition purposes). +Executes \tcode{os.exceptions(ios::failbit | ios::badbit)}. +Then calls \tcode{os.imbue(loc)}. +Then calls \tcode{to_stream(os, fmt, s)}. + +\pnum +\returns \tcode{os.str()}. +\end{itemdescr} + +\begin{itemdecl} +template + basic_string + format(const basic_string& fmt, const Streamable& s); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +This function shall not participate in overload resolution unless +\begin{codeblock} +to_stream(declval&>(), fmt.c_str(), s) +\end{codeblock} +is a valid expression. + +\pnum +\effects +Constructs a local variable of type +\tcode{basic_ostringstream} +(named \tcode{os} for exposition purposes). +Executes \tcode{os.exceptions(ios::failbit | ios::badbit)}. +Then calls \tcode{to_stream(os, fmt.c_str(), s)}. + +\pnum +\returns \tcode{os.str()}. +\end{itemdescr} + +\begin{itemdecl} +template + basic_string + format(const locale& loc, const basic_string& fmt, const Streamable& s); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +This function shall not participate in overload resolution unless +\begin{codeblock} +to_stream(declval&>(), fmt.c_str(), s) +\end{codeblock} +is a valid expression. + +\pnum +\effects +Constructs a local variable of type +\tcode{basic_ostringstream} +(named \tcode{os} for exposition purposes). +Then calls \tcode{os.imbue(loc)}. +Executes \tcode{os.exceptions(ios::failbit | ios::badbit)}. +Then calls \tcode{to_stream(os, fmt.c_str(), s)}. + +\pnum +\returns \tcode{os.str()}. +\end{itemdescr} + +\pnum +The \tcode{format} functions call a \tcode{to_stream} function with +a \tcode{basic_ostream}, +a formatting string specifier, +and a \tcode{Streamable} argument. +Each \tcode{to_stream} overload is customized for each \tcode{Streamable} type. +However all \tcode{to_stream} overloads +treat the formatting string specifier +according to the following specification: + +\pnum +The \tcode{fmt} string consists of zero or more conversion specifiers +and ordinary multibyte characters. +A conversion specifier consists of +a \tcode{\%} character, +possibly followed by an \tcode{E} or \tcode{O} modifier character (described below), +followed by a character that determines the behavior of the conversion specifier. +All ordinary multibyte characters (excluding the terminating null character) +are streamed unchanged into the \tcode{basic_ostream}. + +\pnum +Each conversion specifier is replaced by appropriate characters +as described in Table~\ref{tab:time.format.spec}. +Some of the conversion specifiers +depend on the locale which is imbued to the \tcode{basic_ostream}. +If the \tcode{Streamable} object does not contain +the information the conversion specifier refers to, +the value streamed to the \tcode{basic_ostream} is unspecified. + +\pnum +Unless explicitly specified, +\tcode{Streamable} types will not contain time zone abbreviation +and time zone offset information. +If available, +the conversion specifiers \tcode{\%Z} and \tcode{\%z} +will format this information (respectively). +If the information is not available, +and \tcode{\%Z} or \tcode{\%z} are contained in \tcode{fmt}, +\tcode{os.setstate(ios_base::failbit)} shall be called. + +\begin{LongTable}{Meaning of \tcode{format} conversion specifiers}{tab:time.format.spec}{lx{.8\hsize}} +\\ \topline +\lhdr{Specifier} & \rhdr{Replacement} \\ \capsep +\endfirsthead +\continuedcaption\\ +\hline +\lhdr{Specifier} & \rhdr{Replacement} \\ \capsep +\endhead +\tcode{\%a} & +The locale's abbreviated weekday name. +If the value does not contain a valid weekday, +\tcode{setstate(ios::failbit)} is called. +\\ \rowsep +\tcode{\%A} & +The locale's full weekday name. +If the value does not contain a valid weekday, +\tcode{setstate(ios::failbit)} is called. +\\ \rowsep +\tcode{\%b} & +The locale's abbreviated month name. +If the value does not contain a valid month, +\tcode{setstate(ios::failbit)} is called. +\\ \rowsep +\tcode{\%B} & +The locale's full month name. +If the value does not contain a valid month, +\tcode{setstate(ios::failbit)} is called. +\\ \rowsep +\tcode{\%c} & +The locale's date and time representation. +The modified command \tcode{\%Ec} produces +the locale's alternate date and time representation. +\\ \rowsep +\tcode{\%C} & +The year divided by 100 using floored division. +If the result is a single decimal digit, +it is prefixed with \tcode{0}. +The modified command \tcode{\%EC} produces +the locale's alternative representation of the century. +\\ \rowsep +\tcode{\%d} & +The day of month as a decimal number. +If the result is a single decimal digit, +it is prefixed with \tcode{0}. +The modified command \tcode{\%Od} produces +the locale's alternative representation. +\\ \rowsep +\tcode{\%D} & +Equivalent to \tcode{\%m/\%d/\%y}. +\\ \rowsep +\tcode{\%e} & +The day of month as a decimal number. +If the result is a single decimal digit, +it is prefixed with a space. +The modified command \tcode{\%Oe} produces +the locale's alternative representation. +\\ \rowsep +\tcode{\%F} & +Equivalent to \tcode{\%Y-\%m-\%d}. +\\ \rowsep +\tcode{\%g} & +The last two decimal digits of the ISO week-based year. +If the result is a single digit it is prefixed by \tcode{0}. +\\ \rowsep +\tcode{\%G} & +The ISO week-based year as a decimal number. +If the result is less than four digits +it is left-padded with \tcode{0} to four digits. +\\ \rowsep +\tcode{\%h} & +Equivalent to \tcode{\%b}. +\\ \rowsep +\tcode{\%H} & +The hour (24-hour clock) as a decimal number. +If the result is a single digit, +it is prefixed with \tcode{0}. +The modified command \tcode{\%OH} produces +the locale's alternative representation. +\\ \rowsep +\tcode{\%I} & +The hour (12-hour clock) as a decimal number. +If the result is a single digit, +it is prefixed with \tcode{0}. +The modified command \tcode{\%OI} produces +the locale's alternative representation. +\\ \rowsep +\tcode{\%j} & +The day of the year as a decimal number. +Jan 1 is \tcode{001}. +If the result is less than three digits, +it is left-padded with \tcode{0} to three digits. +\\ \rowsep +\tcode{\%m} & +The month as a decimal number. +Jan is \tcode{01}. +If the result is a single digit, it is prefixed with \tcode{0}. +The modified command \tcode{\%Om} produces +the locale's alternative representation. +\\ \rowsep +\tcode{\%M} & +The minute as a decimal number. +If the result is a single digit, it is prefixed with \tcode{0}. +The modified command \tcode{\%OM} produces +the locale's alternative representation. +\\ \rowsep +\tcode{\%n} & +A new-line character. +\\ \rowsep +\tcode{\%p} & +The locale's equivalent of the AM/PM designations associated with a 12-hour clock. +\\ \rowsep +\tcode{\%r} & +The locale's 12-hour clock time. +\\ \rowsep +\tcode{\%R} & +Equivalent to \tcode{\%H:\%M}. +\\ \rowsep +\tcode{\%S} & +Seconds as a decimal number. +If the number of seconds is less than \tcode{10}, the result is prefixed with \tcode{0}. +If the precision of the input cannot be exactly represented with seconds, +then the format is a decimal floating point number with a fixed format +and a precision matching that of the precision of the input +(or to a microseconds precision if the conversion to floating point decimal seconds +cannot be made within 18 fractional digits). +The character for the decimal point is localized according to the locale. +The modified command \tcode{\%OS} produces +the locale's alternative representation. +\\ \rowsep +\tcode{\%t} & +A horizontal-tab character. +\\ \rowsep +\tcode{\%T} & +Equivalent to \tcode{\%H:\%M:\%S}. +\\ \rowsep +\tcode{\%u} & +The ISO weekday as a decimal number (\tcode{1}-\tcode{7}), +where Monday is \tcode{1}. +The modified command \tcode{\%Ou} produces +the locale's alternative representation. +\\ \rowsep +\tcode{\%U} & +The week number of the year as a decimal number. +The first Sunday of the year is the first day of week \tcode{01}. +Days of the same year prior to that are in week \tcode{00}. +If the result is a single digit, it is prefixed with \tcode{0}. +The modified command \tcode{\%OU} produces +the locale's alternative representation. +\\ \rowsep +\tcode{\%V} & +The ISO week-based week number as a decimal number. +If the result is a single digit, it is prefixed with \tcode{0}. +The modified command \tcode{\%OV} produces +the locale's alternative representation. +\\ \rowsep +\tcode{\%w} & +The weekday as a decimal number (\tcode{0}-\tcode{6}), where Sunday is \tcode{0}. +The modified command \tcode{\%Ow} produces +the locale's alternative representation. +\\ \rowsep +\tcode{\%W} & +The week number of the year as a decimal number. +The first Monday of the year is the first day of week \tcode{01}. +Days of the same year prior to that are in week \tcode{00}. +If the result is a single digit, it is prefixed with \tcode{0}. +The modified command \tcode{\%OW} produces +the locale's alternative representation. +\\ \rowsep +\tcode{\%x} & +The locale's date representation. +The modified command \tcode{\%Ex} produces +the locale's alternate date representation. +\\ \rowsep +\tcode{\%X} & +The locale's time representation. +The modified command \tcode{\%EX} produces +the locale's alternate time representation. +\\ \rowsep +\tcode{\%y} & +The last two decimal digits of the year. +If the result is a single digit it is prefixed by \tcode{0}. +\\ \rowsep +\tcode{\%Y} & +The year as a decimal number. +If the result is less than four digits +it is left-padded with \tcode{0} to four digits. +\\ \rowsep +\tcode{\%z} & +The offset from UTC in the ISO 8601 format. +For example \tcode{-0430} refers to 4 hours 30 minutes behind UTC. +If the offset is zero, \tcode{+0000} is used. +The modified commands \tcode{\%Ez} and \tcode{\%Oz} +insert a \tcode{:} between the hours and minutes: \tcode{-04:30}. +If the offset information is not available, +\tcode{setstate(ios_base::failbit)} shall be called. +\\ \rowsep +\tcode{\%Z} & +The time zone abbreviation. +If the time zone abbreviation is not available, +\tcode{setstate(ios_base::failbit)} shall be called. +\\ \rowsep +\tcode{\%\%} & +A \tcode{\%} character. +\\ +\end{LongTable} + +\indexlibrary{\idxcode{format}|)}% + +\rSec2[time.parse]{Parsing} + +\indexlibrary{\idxcode{parse}|(}% + +\pnum +Each \tcode{parse} overload specified in this subclause +calls \tcode{from_stream} unqualified, +so as to enable argument dependent lookup\iref{basic.lookup.argdep}. + +\begin{itemdecl} +template + @\unspec@ + parse(const basic_string& fmt, Parsable& tp); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +This function shall not participate in overload resolution unless +\begin{codeblock} +from_stream(declval&>(), fmt.c_str(), tp) +\end{codeblock} +is a valid expression. + +\pnum +\returns +A manipulator that, when extracted from a +\tcode{basic_istream} \tcode{is}, +calls \tcode{from_stream(is, fmt.c_str(), tp)}. +\end{itemdescr} + +\begin{itemdecl} +template + @\unspec@ + parse(const basic_string& fmt, Parsable& tp, + basic_string& abbrev); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +This function shall not participate in overload resolution unless +\begin{codeblock} +from_stream(declval&>(), fmt.c_str(), tp, &abbrev) +\end{codeblock} +is a valid expression. + +\pnum +\returns +A manipulator that, when extracted from a +\tcode{basic_istream} \tcode{is}, +calls \tcode{from_stream(is, fmt.c_str(), tp, \&abbrev)}. +\end{itemdescr} + +\begin{itemdecl} +template + @\unspec@ + parse(const basic_string& fmt, Parsable& tp, + minutes& offset); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +This function shall not participate in overload resolution unless +\begin{codeblock} +from_stream(declval&>(), fmt.c_str(), tp, nullptr, &offset) +\end{codeblock} +is a valid expression. + +\pnum +\returns +A manipulator that, when extracted from a +\tcode{basic_istream} \tcode{is}, +calls \tcode{from_stream(is, fmt.c_str(), tp, nullptr, \&offset)}. +\end{itemdescr} + +\begin{itemdecl} +template + @\unspec@ + parse(const basic_string& fmt, Parsable& tp, + basic_string& abbrev, minutes& offset); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\remarks +This function shall not participate in overload resolution unless +\begin{codeblock} +from_stream(declval&>(), fmt.c_str(), tp, &abbrev, &offset) +\end{codeblock} +is a valid expression. + +\pnum +\returns +A manipulator that, when extracted from a +\tcode{basic_istream} \tcode{is}, +calls \tcode{from_stream(is, fmt.c_str(), tp, \&abbrev, \&offset)}. +\end{itemdescr} + +\pnum +All \tcode{from_stream} overloads behave as unformatted input functions, +except that they have an unspecified effect +on the value returned by subsequent calls to \tcode{basic_istream<>::gcount()}. +Each overload takes a format string containing ordinary characters +and flags which have special meaning. +Each flag begins with a \tcode{\%}. +Some flags can be modified by \tcode{E} or \tcode{O}. +During parsing each flag interprets characters as parts of date and time types +according to the table below. +Some flags can be modified by a width parameter +given as a positive decimal integer called out as \tcode{\placeholder{N}} below +which governs how many characters are parsed from the stream in interpreting the flag. +All characters in the format string that are not represented in the table below, +except for white space, are parsed unchanged from the stream. +A white space character matches zero or more white space characters in the input stream. + +\pnum +If the \tcode{from_stream} overload fails to parse +everything specified by the format string, +or if insufficient information is parsed to specify a complete +duration, time point, or calendrical data structure, +\tcode{setstate(ios_base::failbit)} +is called on the \tcode{basic_istream}. + +\begin{LongTable}{Meaning of \tcode{parse} flags}{tab:time.parse.spec}{lx{.8\hsize}} +\\ \topline +\lhdr{Flag} & \rhdr{Parsed value} \\ \capsep +\endfirsthead +\continuedcaption\\ +\hline +\lhdr{Flag} & \rhdr{Parsed value} \\ \capsep +\endhead +\tcode{\%a} & +The locale's full or abbreviated case-insensitive weekday name. +\\ \rowsep +\tcode{\%A} & +Equivalent to \tcode{\%a}. +\\ \rowsep +\tcode{\%b} & +The locale's full or abbreviated case-insensitive month name. +\\ \rowsep +\tcode{\%B} & +Equivalent to \tcode{\%b}. +\\ \rowsep +\tcode{\%c} & +The locale's date and time representation. +The modified command \tcode{\%Ec} interprets +the locale's alternate date and time representation. +\\ \rowsep +\tcode{\%C} & +The century as a decimal number. +The modified command \tcode{\%\placeholder{N}C} specifies +the maximum number of characters to read. +If \tcode{\placeholder{N}} is not specified, the default is 2. +Leading zeroes are permitted but not required. +The modified commands \tcode{\%EC} and \tcode{\%OC} interpret +the locale's alternative representation of the century. +\\ \rowsep +\tcode{\%d} & +The day of the month as a decimal number. +The modified command \tcode{\%\placeholder{N}d} specifies +the maximum number of characters to read. +If \tcode{\placeholder{N}} is not specified, the default is 2. +Leading zeroes are permitted but not required. +The modified command \tcode{\%Ed} interprets +the locale's alternative representation of the day of the month. +\\ \rowsep +\tcode{\%D} & +Equivalent to \tcode{\%m/\%d/\%y}. +\\ \rowsep +\tcode{\%e} & +Equivalent to \tcode{\%d} and can be modified like \tcode{\%d}. +\\ \rowsep +\tcode{\%F} & +Equivalent to \tcode{\%Y-\%m-\%d}. +If modified with a width \tcode{\placeholder{N}}, +the width is applied to only \tcode{\%Y}. +\\ \rowsep +\tcode{\%g} & +The last two decimal digits of the ISO week-based year. +The modified command \tcode{\%\placeholder{N}g} specifies +the maximum number of characters to read. +If \tcode{\placeholder{N}} is not specified, the default is 2. +Leading zeroes are permitted but not required. +\\ \rowsep +\tcode{\%G} & +The ISO week-based year as a decimal number. +The modified command \tcode{\%\placeholder{N}G} specifies +the maximum number of characters to read. +If \tcode{\placeholder{N}} is not specified, the default is 4. +Leading zeroes are permitted but not required. +\\ \rowsep +\tcode{\%h} & +Equivalent to \tcode{\%b}. +\\ \rowsep +\tcode{\%H} & +The hour (24-hour clock) as a decimal number. +The modified command \tcode{\%\placeholder{N}H} specifies +the maximum number of characters to read. +If \tcode{\placeholder{N}} is not specified, the default is 2. +Leading zeroes are permitted but not required. +The modified command \tcode{\%OH} interprets +the locale's alternative representation. +\\ \rowsep +\tcode{\%I} & +The hour (12-hour clock) as a decimal number. +The modified command \tcode{\%\placeholder{N}I} specifies +the maximum number of characters to read. +If \tcode{\placeholder{N}} is not specified, the default is 2. +Leading zeroes are permitted but not required. +\\ \rowsep +\tcode{\%j} & +The day of the year as a decimal number. +Jan 1 is \tcode{1}. +The modified command \tcode{\%\placeholder{N}j} specifies +the maximum number of characters to read. +If \tcode{\placeholder{N}} is not specified, the default is 3. +Leading zeroes are permitted but not required. +\\ \rowsep +\tcode{\%m} & +The month as a decimal number. +Jan is \tcode{1}. +The modified command \tcode{\%\placeholder{N}m} specifies +the maximum number of characters to read. +If \tcode{\placeholder{N}} is not specified, the default is 2. +Leading zeroes are permitted but not required. +The modified command \tcode{\%Om} interprets +the locale's alternative representation. +\\ \rowsep +\tcode{\%M} & +The minutes as a decimal number. +The modified command \tcode{\%\placeholder{N}M} specifies +the maximum number of characters to read. +If \tcode{\placeholder{N}} is not specified, the default is 2. +Leading zeroes are permitted but not required. +The modified command \tcode{\%OM} interprets +the locale's alternative representation. +\\ \rowsep +\tcode{\%n} & +Matches one white space character. +\begin{note} +\tcode{\%n}, \tcode{\%t}, and a space +can be combined to match a wide range of white-space patterns. +For example, +\tcode{"\%n "} matches one or more white space characters, and +\tcode{"\%n\%t\%t"} matches one to three white space characters. +\end{note} +\\ \rowsep +\tcode{\%p} & +The locale's equivalent of the AM/PM designations associated with a 12-hour clock. +The command \tcode{\%I} must precede \tcode{\%p} in the format string. +\\ \rowsep +\tcode{\%r} & +The locale's 12-hour clock time. +\\ \rowsep +\tcode{\%R} & +Equivalent to \tcode{\%H:\%M}. +\\ \rowsep +\tcode{\%S} & +The seconds as a decimal number. +The modified command \tcode{\%\placeholder{N}S} specifies +the maximum number of characters to read. +If \tcode{\placeholder{N}} is not specified, +the default is 2 if the input time has a precision convertible to seconds. +Otherwise the default width is determined by +the decimal precision of the input +and the field is interpreted as a \tcode{long double} in a fixed format. +If encountered, the locale determines the decimal point character. +Leading zeroes are permitted but not required. +The modified command \tcode{\%OS} interprets +the locale's alternative representation. +\\ \rowsep +\tcode{\%t} & +Matches zero or one white space characters. +\\ \rowsep +\tcode{\%T} & +Equivalent to \tcode{\%H:\%M:\%S}. +\\ \rowsep +\tcode{\%u} & +The ISO weekday as a decimal number (\tcode{1}-\tcode{7}), where Monday is \tcode{1}. +The modified command \tcode{\%\placeholder{N}u} specifies +the maximum number of characters to read. +If \tcode{\placeholder{N}} is not specified, the default is \tcode{1}. +Leading zeroes are permitted but not required. +The modified command \tcode{\%Ou} interprets +the locale's alternative representation. +\\ \rowsep +\tcode{\%U} & +The week number of the year as a decimal number. +The first Sunday of the year is the first day of week \tcode{01}. +Days of the same year prior to that are in week \tcode{00}. +The modified command \tcode{\%\placeholder{N}U} specifies +the maximum number of characters to read. +If \tcode{\placeholder{N}} is not specified, the default is 2. +Leading zeroes are permitted but not required. +\\ \rowsep +\tcode{\%V} & +The ISO week-based week number as a decimal number. +The modified command \tcode{\%\placeholder{N}V} specifies +the maximum number of characters to read. +If \tcode{\placeholder{N}} is not specified, the default is 2. +Leading zeroes are permitted but not required. +\\ \rowsep +\tcode{\%w} & +The weekday as a decimal number (\tcode{0}-\tcode{6}), where Sunday is \tcode{0}. +The modified command \tcode{\%\placeholder{N}w} specifies +the maximum number of characters to read. +If \tcode{\placeholder{N}} is not specified, the default is \tcode{1}. +Leading zeroes are permitted but not required. +The modified command \tcode{\%Ow} interprets +the locale's alternative representation. +\\ \rowsep +\tcode{\%W} & +The week number of the year as a decimal number. +The first Monday of the year is the first day of week \tcode{01}. +Days of the same year prior to that are in week \tcode{00}. +The modified command \tcode{\%\placeholder{N}W} specifies +the maximum number of characters to read. +If \tcode{\placeholder{N}} is not specified, the default is 2. +Leading zeroes are permitted but not required. +\\ \rowsep +\tcode{\%x} & +The locale's date representation. +The modified command \tcode{\%Ex} produces the locale's alternate date representation. +\\ \rowsep +\tcode{\%X} & +The locale's time representation. +The modified command \tcode{\%EX} produces the locale's alternate time representation. +\\ \rowsep +\tcode{\%y} & +The last two decimal digits of the year. +If the century is not otherwise specified +(e.g. with \tcode{\%C}), +values in the range \crange{69}{99} +are presumed to refer to the years 1969 to 1999, +and values in the range \crange{00}{68} +are presumed to refer to the years 2000 to 2068. +The modified command \tcode{\%\placeholder{N}y} specifies +the maximum number of characters to read. +If \tcode{\placeholder{N}} is not specified, the default is 2. +Leading zeroes are permitted but not required. +The modified commands \tcode{\%Ey} and \tcode{\%Oy} interpret +the locale's alternative representation. +\\ \rowsep +\tcode{\%Y} & +The year as a decimal number. +The modified command \tcode{\%\placeholder{N}Y} specifies +the maximum number of characters to read. +If \tcode{\placeholder{N}} is not specified, the default is 4. +Leading zeroes are permitted but not required. +The modified command \tcode{\%EY} interprets +the locale's alternative representation. +\\ \rowsep +\tcode{\%z} & +The offset from UTC in the format \tcode{[+|-]hh[mm]}. +For example \tcode{-0430} refers to 4 hours 30 minutes behind UTC, +and \tcode{04} refers to 4 hours ahead of UTC. +The modified commands \tcode{\%Ez} and \tcode{\%Oz} +parse a \tcode{:} between the hours and minutes +and render leading zeroes on the hour field optional: +\tcode{[+|-]h[h][:mm]}. +For example \tcode{-04:30} refers to 4 hours 30 minutes behind UTC, +and \tcode{4} refers to 4 hours ahead of UTC. +\\ \rowsep +\tcode{\%Z} & +The time zone abbreviation or name. +A single word is parsed. +This word can only contain characters +from the basic source character set\iref{lex.charset} +that are alphanumeric, or one of +\tcode{'_'}, \tcode{'/'}, \tcode{'-'}, or \tcode{'+'}. +\\ \rowsep +\tcode{\%\%} & +A \tcode{\%} character is extracted. +\\ +\end{LongTable} + +\indexlibrary{\idxcode{parse}|)} + \rSec2[ctime.syn]{Header \tcode{} synopsis} \indexhdr{ctime}% @@ -19131,7 +28678,7 @@ \tcode{localtime} are not required to avoid data races\iref{res.on.data.races}. -\xref ISO C 7.27 +\xrefc{7.27} \rSec1[type.index]{Class \tcode{type_index}} @@ -19522,6 +29069,10 @@ } \end{codeblock} +\pnum +The type \tcode{chars_format} is a bitmask type\iref{bitmask.types} +with elements \tcode{scientific}, \tcode{fixed}, and \tcode{hex}. + \rSec2[charconv.to.chars]{Primitive numeric output conversion} \pnum @@ -19669,7 +29220,7 @@ \throws Nothing. \end{itemdescr} -\xref ISO C 7.21.6.1 +\xrefc{7.21.6.1} \rSec2[charconv.from.chars]{Primitive numeric input conversion} @@ -19787,4 +29338,4 @@ \throws Nothing. \end{itemdescr} -\xref ISO C 7.22.1.3, 7.22.1.4 +\xrefc{7.22.1.3, 7.22.1.4} diff --git a/source/xrefdelta.tex b/source/xrefdelta.tex index 7690eecb32..a3e2b64a83 100644 --- a/source/xrefdelta.tex +++ b/source/xrefdelta.tex @@ -18,11 +18,14 @@ %\removedxref{removed.label} \removedxref{variant.traits} +% [facets.examples] was removed. +\removedxref{facets.examples} + % Renamed sections. %\movedxref{old.label}{new.label} %\movedxrefii{old.label}{new.label.1}{new.label.2} %\movedxrefiii{old.label}{new.label.1}{new.label.2}{new.label.3} -%\movedxrefs{old.label}{new place (eg Table~\ref{tab:blah})} +%\movedxrefs{old.label}{new place (eg \tref{blah})} % P0588 replaced function prototype scope with function parameter scope. \movedxref{basic.scope.proto}{basic.scope.param} @@ -49,8 +52,73 @@ % Contents of [util.smartptr] was integrated into the parent. \removedxref{util.smartptr} -% Deprecated free-function atomic access to shared pointers -\movedxref{util.smartptr.shared.atomic}{depr.util.smartptr.shared.atomic} +% Avoid duplication with synopsis. +\movedxref{re.regex.const}{re.regex} + +% Single-item [insert.iterators] subclauses were dissolved. +\movedxref{back.insert.iter.cons}{back.insert.iter.ops} +\movedxref{back.insert.iter.op=}{back.insert.iter.ops} +\movedxref{back.insert.iter.op*}{back.insert.iter.ops} +\movedxref{back.insert.iter.op++}{back.insert.iter.ops} + +\movedxref{front.insert.iter.cons}{front.insert.iter.ops} +\movedxref{front.insert.iter.op=}{front.insert.iter.ops} +\movedxref{front.insert.iter.op*}{front.insert.iter.ops} +\movedxref{front.insert.iter.op++}{front.insert.iter.ops} + +\movedxref{insert.iter.cons}{insert.iter.ops} +\movedxref{insert.iter.op=}{insert.iter.ops} +\movedxref{insert.iter.op*}{insert.iter.ops} +\movedxref{insert.iter.op++}{insert.iter.ops} + +\movedxref{insert.iter.cons}{insert.iter.ops} +\movedxref{insert.iter.op=}{insert.iter.ops} +\movedxref{insert.iter.op*}{insert.iter.ops} +\movedxref{insert.iter.op++}{insert.iter.ops} + +% Single-item [reverse.iterators] subclauses were dissolved. +\movedxref{reverse.iter.op=}{reverse.iter.cons} + +\movedxref{reverse.iter.op==}{reverse.iter.cmp} +\movedxref{reverse.iter.op<}{reverse.iter.cmp} +\movedxref{reverse.iter.op!=}{reverse.iter.cmp} +\movedxref{reverse.iter.op>}{reverse.iter.cmp} +\movedxref{reverse.iter.op>=}{reverse.iter.cmp} +\movedxref{reverse.iter.op<=}{reverse.iter.cmp} + +\movedxref{reverse.iter.op.star}{reverse.iter.elem} +\movedxref{reverse.iter.opref}{reverse.iter.elem} +\movedxref{reverse.iter.opindex}{reverse.iter.elem} + +\movedxref{reverse.iter.op+}{reverse.iter.nav} +\movedxref{reverse.iter.op-}{reverse.iter.nav} +\movedxref{reverse.iter.op++}{reverse.iter.nav} +\movedxref{reverse.iter.op+=}{reverse.iter.nav} +\movedxref{reverse.iter.op\dcr}{reverse.iter.nav} +\movedxref{reverse.iter.op-=}{reverse.iter.nav} + +\movedxref{reverse.iter.opdiff}{reverse.iter.nonmember} +\movedxref{reverse.iter.opsum}{reverse.iter.nonmember} +\movedxref{reverse.iter.make}{reverse.iter.nonmember} + +\removedxref{reverse.iter.ops} + +% Individual swap sections were removed. +\removedxref{deque.special} +\removedxref{forwardlist.special} +\removedxref{list.special} +\removedxref{vector.special} +\removedxref{map.special} +\removedxref{multimap.special} +\removedxref{set.special} +\removedxref{multiset.special} +\removedxref{unord.map.swap} +\removedxref{unord.multimap.swap} +\removedxref{unord.set.swap} +\removedxref{unord.multiset.swap} % Deprecated features. %\deprxref{old.label} (if moved to depr.old.label, otherwise use \movedxref) + +% Deprecated free-function atomic access to shared pointers +\deprxref{util.smartptr.shared.atomic}