diff --git a/README.rst b/README.rst index b3b2823624..b31fc6be82 100644 --- a/README.rst +++ b/README.rst @@ -24,7 +24,7 @@ Install the `MacTeX distribution `_. If you are on a slow network, you'll want to get the `BasicTeX package `_ instead, then run the following command to install the other packages that the draft requires: - sudo tlmgr install latexmk isodate substr relsize ulem fixme rsfs extract layouts enumitem + sudo tlmgr install latexmk isodate substr relsize ulem fixme rsfs extract layouts enumitem l3packages l3kernel --------------------------------------- Getting Started on Debian-based Systems @@ -40,7 +40,7 @@ Getting Started on Fedora Install the following packages: - dnf install latexmk texlive texlive-isodate texlive-relsize texlive-ulem texlive-fixme texlive-extract + dnf install latexmk texlive texlive-isodate texlive-relsize texlive-ulem texlive-fixme texlive-extract texlive-l3kernel texlive-l3packages ----------------------------- Getting Started on Arch Linux diff --git a/papers/n4799.html b/papers/n4799.html new file mode 100644 index 0000000000..25dc644168 --- /dev/null +++ b/papers/n4799.html @@ -0,0 +1,572 @@ +N4799 +

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

+ +

2019-01-21
+Richard Smith (editor) (Google Inc)
+Dawn Perchik (co-editor) (Bright Side Computing, LLC)
+Jens Maurer (co-editor)
+Thomas Köppe (co-editor) (Google DeepMind)
+<cxxeditor@gmail.com>

+ +

Acknowledgements

+ +

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

+ +

This revision contains only editorial changes relative to N4791.

+ +

Notable editorial changes

+ +

DECAY_COPY

+ +

DECAY_COPY has been renamed to decay-copy +for consistency with other exposition-only entities, +and moved from +[thread.decaycopy] to [expos.only.func].

+ +

Other changes to section labels

+ +

[iterator.container] has been merged into [iterator.range], and +[range.prim] has been merged into [range.access].

+ +

The parts of [range.adaptors] that create new ranges rather than adapting +existing ranges have been split into a separate [range.factories].

+ +

The parts of [dcl.init] relating to indeterminate values have been moved to a +new [basic.indet].

+ +

Minor editorial fixes

+ +

A log of editorial fixes made to the working draft since N4791 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 2831ba3b8e1862a8a0e52d540b61062e72e89d6d
+Author: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
+Date:   Mon Jan 14 11:15:11 2019 -0500
+
+    [depr.strstreambuf.virtuals] Hyphenate "implementation-defined"
+
+commit d333390f0dd56dc9143731c1be00f66bc3752479
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Dec 29 12:54:56 2018 +0100
+
+    [range.prim] merge into [range.access]
+
+commit dc3be11dd06a5edfa81061dce4b79fec2a8024df
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Dec 29 12:54:26 2018 +0100
+
+    [iterator.container] merge into [iterator.range]
+
+commit 75dde78fd9ac709ff4843d1d5572d5cbfe4ac6d2
+Author: S. B. Tam <cpplearner@outlook.com>
+Date:   Mon Jan 21 23:24:52 2019 +0800
+
+    [meta.const.eval] Fix typo in function name (#2650)
+
+commit 55577a76181134d1dd442af3f4eb36c4d861c7c9
+Author: kiroma <krzysio.kurek@wp.pl>
+Date:   Tue Jan 15 00:56:07 2019 +0100
+
+    [thread.condition] Improve description of efficiency of condition_variable.
+
+commit 281a8bd29f97b5249eae68fe0280e2dfda5ac714
+Author: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
+Date:   Mon Jan 7 18:37:20 2019 -0500
+
+    [ranges.syn] Fix a typo: "fowarding"
+
+commit 099022dbf1642541ab0d1c380ed26e8fb1244d86
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Jan 2 22:29:51 2019 +0100
+
+    [unreachable.sentinel] 'open interval' -> 'unbounded interval'
+
+commit a9fdd8589a51617d5d60bf59263d1567076718ba
+Author: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
+Date:   Tue Jan 1 21:40:09 2019 -0500
+
+    Fix some `operator<=>` declarations with the wrong number of parameters.
+
+    Also one `operator<` that should at least have been a const member function.
+
+commit d42648926f4131586943b7dccb7df41bfbd8df5b
+Author: Eelis van der Weegen <eelis@eelis.net>
+Date:   Tue Jan 1 14:56:43 2019 +0100
+
+    [expr.prim.id.dtor] Fix comment in example.
+
+    In translation phase 3, the "0.T" in the line of code is parsed as a (single) preprocessing-token.
+
+    In phase 7, this preprocessing token is converted into a user-defined-floating-literal whose ud-suffix component is "T".
+
+    At no point is the "0." partial token a floating-point literal. At most, it is the fractional-constant component in a bigger user-defined-floating-literal token.
+
+    Fixes #2630.
+
+commit bac5e8438a9238730ae76e7ecf0899a52ef20fe0
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Mon Dec 31 09:19:20 2018 +0100
+
+    [range.cmp] Deconfuse subclause heading.
+
+commit ede68b76f56ebb5bdf0692ab0ac2e5bcb68de96a
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sun Dec 30 10:45:33 2018 +0100
+
+    [description] Drop 'informative' from the heading.
+
+    This subclause contains many normative definitions
+    (e.g. [operators]); marking it as 'informative' is
+    misleading.
+
+commit 5884d91293055be8b1ab494ef2ee5e675caad00c
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sun Dec 30 10:41:21 2018 +0100
+
+    [expos.only.types] Exposition-only types apply more generally,
+
+    not just to capture language linkage.  For example,
+    'node-handle' is an entire exposition-only class.
+
+commit ce10ce47647e61ef8a308ad0aefcb2ff1094017a
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sun Dec 30 10:28:16 2018 +0100
+
+    [expos.only.func] New home for global exposition-only functions.
+
+    Also introduce the descriptive mechanism of an
+    exposition-only function.
+    Remove [thread.decaycopy] by moving its contents here.
+    Use the spelling 'decay-copy' (italics code font) instead of
+    introducing an intermediate meta-macro DECAY_COPY.
+
+commit 6833990f6e090644df012c11ebc55b26c7580565
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Dec 29 21:33:54 2018 +0100
+
+    [range.refinements] Rephrase heading to not use 'common range'
+
+    'Common range' means iterator and end marker have the same type;
+    see [range.req.general].  This is not what this subclause is about.
+
+commit 5874ecd6f82612873d4a40e14a3e93947b2ebab6
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Dec 29 13:27:54 2018 +0100
+
+    [special.mem.concepts] Use 'models ... only if' phrasing for semantic constraints.
+
+commit 1c3b991fac1b6668f42bde6824435f8ece037a10
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Dec 29 12:43:27 2018 +0100
+
+    [range.factories] New subclause, split off from [range.adaptors]
+
+    Range adaptors take a range and produce a new range;
+    range factories take something else (or nothing) and produce a range.
+
+commit 3afb777a04ddb2e31292c4cf011475db5b65a9fc
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Dec 28 00:25:45 2018 +0100
+
+    [dcl.typedef] Use 'redeclare', not 'redefine'
+
+commit e88e605f3561546ab47d327d1865a576c415bc7b
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Dec 28 00:12:18 2018 +0100
+
+    [basic.life] Adjust subclause heading
+
+    and clarify that references are treated as-if requiring storage.
+
+commit 5d35f0c24e0724aee7993cef6085108fdfcd4590
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Dec 21 20:44:23 2018 +0100
+
+    [iterators] Qualify declarator-id with sub-namespace.
+
+commit 4beab059b54b2fb859cc404b79682cbb71d76364
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Dec 21 00:42:42 2018 +0100
+
+    [expr.new] A new-expression might not invoke a constructor
+
+commit 90467df5ce5b0dd92058dd13b082f6ed3bc16efc
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Dec 21 00:37:06 2018 +0100
+
+    [over.ics.user,over.ics.rank] Reference binding is part of the second SCS
+
+commit 8909a8f20249435788fa4f43e5199f2595a1e623
+Author: Eelis van der Weegen <eelis@eelis.net>
+Date:   Mon Dec 17 18:54:04 2018 +0100
+
+    [diff.dcl] Capitalize sentence.
+
+commit 64f01ee78bfac1450c6ffefbfe345a65ce951da1
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Sun Dec 9 18:59:21 2018 -0400
+
+    [counted.iter.cmp] Add missing colon to specification element
+
+commit 3ff583af0448540f40e9db7cd07c30489696ecd7
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Mon Dec 10 15:14:50 2018 -0400
+
+    [istreambuf.iterator] Remove duplicated declarations
+
+commit 64d61459522873003f4af52d4abab65cac2f48c5
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Mon Dec 10 15:13:34 2018 -0400
+
+    [istream.iterator] Remove duplicated declarations
+
+commit 48acf476dedcb443407cadc189a79eb89f623097
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Sat Dec 8 15:26:39 2018 -0400
+
+    [insert.iterators] Remove duplicated declarations
+
+commit 45f889a3fe071cadc80f97d58e1f905e8213455b
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Sat Dec 8 14:14:55 2018 -0400
+
+    [iterator.synopsis] Drive-by add semantic breaks
+
+commit b72a3447c2a602aa6362fd0073c6683cedee2098
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Sat Dec 8 14:13:36 2018 -0400
+
+    [move.iterator] Remove duplicated declarations
+
+commit 0fd872506cf6d30101eacd654b2133a5e090b654
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Sat Dec 8 14:09:08 2018 -0400
+
+    [reverse.iterator] Remove duplicated declarations
+
+commit a1c3e9c0319f96e549fae711e616e41ff571cb6d
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Sat Dec 8 14:08:20 2018 -0400
+
+    [iterators] Move specialization to synopsis
+
+commit eb1067835df26c6eef46d006420be2129758d7d0
+Author: Nicolas Lesser <blitzrakete@gmail.com>
+Date:   Sat Dec 8 19:32:21 2018 +0100
+
+    [expr.and,expr.or,expr.xor] Add grouping sentence to the binary and/or/xor operators.
+
+commit 27d19661fbb0a5424f72330724d9809618efbb8b
+Author: Géry Ogam <gery.ogam@gmail.com>
+Date:   Sat Jan 19 00:59:08 2019 +0100
+
+    [basic.lval] clarify the contexts where void expressions can appear and their value category
+
+commit 9c3b921635b041895d44f378ea3f534145e05006
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Thu Oct 25 19:16:06 2018 +0200
+
+    [basic.lookup,over.call.func] Clarify lookup rules for function calls.
+
+    Also add cross-references to [class.member.lookup] when
+    talking about 'looked up in the class of the object expression'
+    in [basic.lookup.classref].
+
+commit 0cd2126ddab16740d38a302f0da7fee5658f5fbb
+Author: Jonathan Caves <joncaves@microsoft.com>
+Date:   Mon Dec 17 14:16:45 2018 -0800
+
+    [expr.prim.lambda.capture] Add missing semicolons after statements ending in lambda expressions
+
+commit 1111bf9d422ebd3765730d95155860aeda07234a
+Author: Casey Carter <Casey@Carter.net>
+Date:   Sun Jan 6 04:16:39 2019 -0800
+
+    [allocator.requirements] relocate example to end of subclause
+
+    and add paragraph number.
+
+    Fixes #2639.
+
+commit b4f5a7e426c8b55c08e414aee434fe85c41e2a48
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Sat Dec 29 21:01:42 2018 -0400
+
+    [ostreambuf.iterator] Remove tutorial-like sentence
+
+commit d902c5bfe137dc303fb5c7c54b6409cddac61cdc
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Sun Dec 9 23:13:07 2018 -0400
+
+    [ostreambuf.iterator] Move description before the synopsis
+
+commit 486e7a2f8308a5f4d8aca20a74dd7a1ed2974a84
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Sat Dec 29 20:59:51 2018 -0400
+
+    [istreambuf.iterator.proxy] Move description before class synopsis
+
+commit ca07d4deb68ffb9630d3f73a33f552d5040bab17
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Sun Dec 9 21:54:51 2018 -0400
+
+    [istreambuf.iterator] Use nullptr instead of 0
+
+commit f9995862feaf47b85aabf7ec63ead2d5b00d5573
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Sun Dec 9 21:49:56 2018 -0400
+
+    [ostream.iterator.ops] Check for non nullptr value implicitly
+
+commit b2cfef81694aa61a7c197ad58c96ee44f20f18ca
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Sun Dec 9 21:28:50 2018 -0400
+
+    [ostream.iterator.cons.des] Use nullptr instead of null
+
+commit a97f9c18edcbcfb3cf10149116f4126a422ce1fe
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Sat Dec 29 20:11:38 2018 -0400
+
+    [ostream.iterator] Remove redundant paragraph
+
+commit 8098533eabd9361b7798de7a44dea0277fc767e3
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Sat Dec 29 20:11:03 2018 -0400
+
+    [ostream.iterator] Remove tutorial-like description
+
+commit c3a5aa19594a534f8bb9adc9b83f0eb703870699
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Sun Dec 9 20:31:29 2018 -0400
+
+    [istream.iterator.ops] Unparenthesize return object name
+
+commit c84872ba9679e322ee2cded0b1a129d7b8faf2d0
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Sun Dec 9 19:43:59 2018 -0400
+
+    [istream.iterator] Use nullptr instead of 0
+
+commit 169f0c41b51ba081e2c3e662276e9a4061567eaa
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Dec 19 22:01:18 2018 +0100
+
+    [iterator.primitives] Rescue introductory sentence.
+
+commit 98f1e9f668cbe109511fd8cee1afc03c4bb9f007
+Author: JF Bastien <github@jfbastien.com>
+Date:   Thu Dec 20 11:27:51 2018 -0800
+
+    [optional.assign] use injected class name consistently
+
+commit 597b6900151f810acd776e452f08c1e2941857b9
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Dec 19 21:41:46 2018 +0100
+
+    [reverse.iterators] Use the public accessor function,
+
+    not the exposition-only member 'current', from non-member functions.
+
+commit 3d9f80e990daf459a85cff539bd2ce64c0986886
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Tue Dec 11 15:50:03 2018 -0400
+
+    [ranges.syn] Complete requires clause of view_interface
+
+commit a61eb25d048b96fd23b7544d12f43299ccf51026
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Tue Dec 11 20:23:37 2018 -0400
+
+    [ranges.syn] Complete requires clause of filter_view
+
+commit 687b718c431c67a80888552c5055b0903fb197ba
+Author: Casey Carter <Casey@Carter.net>
+Date:   Wed Dec 19 13:39:05 2018 -0800
+
+    [alg.min.max] Fix typo in returns element of ranges::minmax (#2600)
+
+    Also add linebreaks as appropriate after template-heads in declarations of `min`, `max`, and `minmax`.
+
+commit e7c5655a9a4746b895937aee4fdadfad30f02cfa
+Author: Alberto Barbati <2210776+iaanus@users.noreply.github.com>
+Date:   Tue Dec 18 16:02:35 2018 +0100
+
+    [dcl.constexpr] Add "consteval" to subclause heading (#2597)
+
+commit a88d02d8d77e730bbf2730b6988a8b63319496c3
+Author: Eelis van der Weegen <eelis@eelis.net>
+Date:   Wed Dec 12 16:43:21 2018 +0100
+
+    [temp.mem.func] Remove inappropriate parentheses in 'Array<T>::operator[]()'.
+
+commit 4d9447fb590bf7fdc302706eb1560e6a402eca95
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Sat Dec 8 10:09:29 2018 -0400
+
+    [reverse.iterator] Remove stray backslashes
+
+commit 54ddae362645af5028e622f92b795cd6d198c8a0
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Fri Dec 7 21:09:52 2018 -0400
+
+    [indirectcallable.general] Fix reference
+
+    Just 6 lines below, it is correct.
+
+commit 5aaec13ef8f29527e762f8e4bf8e2362c8b1419c
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Dec 7 23:03:51 2018 +0100
+
+    [basic.indet] Indeterminate values
+
+    Create a new section, moved from parts of [dcl.init].
+
+commit 9cf2dd2247af79721f4961c96dd9c57003556c94
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Fri Dec 7 16:06:05 2018 -0800
+
+    [lex.key] Fix relative order of 'do' and 'double' in keywords table.
+
+commit 607ec0d6d6ce7c6e72c1cae63d22bbdf40eebd2c
+Author: Johel Ernesto Guerrero Peña <johelegp@gmail.com>
+Date:   Fri Dec 7 19:28:30 2018 -0400
+
+    [iterator.concept.bidir] Add comma for clarity
+
diff --git a/papers/n4799.md b/papers/n4799.md new file mode 100644 index 0000000000..2d7736db33 --- /dev/null +++ b/papers/n4799.md @@ -0,0 +1,446 @@ +# N4799 Editors' Report -- Programming Languages -- C++ + +2019-01-21 +Richard Smith (editor) (Google Inc) +Dawn Perchik (co-editor) (Bright Side Computing, LLC) +Jens Maurer (co-editor) +Thomas Köppe (co-editor) (Google DeepMind) +`` + +## Acknowledgements + +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 + + * [N4800](http://wg21.link/n4800) is the current C++ working draft. It replaces [N4791](http://wg21.link/n4791). + * N4799 is this Editors' Report. + +## Motions incorporated into working draft + +This revision contains only editorial changes relative to N4791. + +## Notable editorial changes + +### `DECAY_COPY` + +`DECAY_COPY` has been renamed to *decay-copy* +for consistency with other exposition-only entities, +and moved from +[thread.decaycopy] to [expos.only.func]. + +### Other changes to section labels + +[iterator.container] has been merged into [iterator.range], and +[range.prim] has been merged into [range.access]. + +The parts of [range.adaptors] that create new ranges rather than adapting +existing ranges have been split into a separate [range.factories]. + +The parts of [dcl.init] relating to indeterminate values have been moved to a +new [basic.indet]. + +## Minor editorial fixes + +A log of editorial fixes made to the working draft since N4791 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/n4791...n4800). + + commit 2831ba3b8e1862a8a0e52d540b61062e72e89d6d + Author: Arthur O'Dwyer + Date: Mon Jan 14 11:15:11 2019 -0500 + + [depr.strstreambuf.virtuals] Hyphenate "implementation-defined" + + commit d333390f0dd56dc9143731c1be00f66bc3752479 + Author: Jens Maurer + Date: Sat Dec 29 12:54:56 2018 +0100 + + [range.prim] merge into [range.access] + + commit dc3be11dd06a5edfa81061dce4b79fec2a8024df + Author: Jens Maurer + Date: Sat Dec 29 12:54:26 2018 +0100 + + [iterator.container] merge into [iterator.range] + + commit 75dde78fd9ac709ff4843d1d5572d5cbfe4ac6d2 + Author: S. B. Tam + Date: Mon Jan 21 23:24:52 2019 +0800 + + [meta.const.eval] Fix typo in function name (#2650) + + commit 55577a76181134d1dd442af3f4eb36c4d861c7c9 + Author: kiroma + Date: Tue Jan 15 00:56:07 2019 +0100 + + [thread.condition] Improve description of efficiency of condition_variable. + + commit 281a8bd29f97b5249eae68fe0280e2dfda5ac714 + Author: Arthur O'Dwyer + Date: Mon Jan 7 18:37:20 2019 -0500 + + [ranges.syn] Fix a typo: "fowarding" + + commit 099022dbf1642541ab0d1c380ed26e8fb1244d86 + Author: Jens Maurer + Date: Wed Jan 2 22:29:51 2019 +0100 + + [unreachable.sentinel] 'open interval' -> 'unbounded interval' + + commit a9fdd8589a51617d5d60bf59263d1567076718ba + Author: Arthur O'Dwyer + Date: Tue Jan 1 21:40:09 2019 -0500 + + Fix some `operator<=>` declarations with the wrong number of parameters. + + Also one `operator<` that should at least have been a const member function. + + commit d42648926f4131586943b7dccb7df41bfbd8df5b + Author: Eelis van der Weegen + Date: Tue Jan 1 14:56:43 2019 +0100 + + [expr.prim.id.dtor] Fix comment in example. + + In translation phase 3, the "0.T" in the line of code is parsed as a (single) preprocessing-token. + + In phase 7, this preprocessing token is converted into a user-defined-floating-literal whose ud-suffix component is "T". + + At no point is the "0." partial token a floating-point literal. At most, it is the fractional-constant component in a bigger user-defined-floating-literal token. + + Fixes #2630. + + commit bac5e8438a9238730ae76e7ecf0899a52ef20fe0 + Author: Jens Maurer + Date: Mon Dec 31 09:19:20 2018 +0100 + + [range.cmp] Deconfuse subclause heading. + + commit ede68b76f56ebb5bdf0692ab0ac2e5bcb68de96a + Author: Jens Maurer + Date: Sun Dec 30 10:45:33 2018 +0100 + + [description] Drop 'informative' from the heading. + + This subclause contains many normative definitions + (e.g. [operators]); marking it as 'informative' is + misleading. + + commit 5884d91293055be8b1ab494ef2ee5e675caad00c + Author: Jens Maurer + Date: Sun Dec 30 10:41:21 2018 +0100 + + [expos.only.types] Exposition-only types apply more generally, + + not just to capture language linkage. For example, + 'node-handle' is an entire exposition-only class. + + commit ce10ce47647e61ef8a308ad0aefcb2ff1094017a + Author: Jens Maurer + Date: Sun Dec 30 10:28:16 2018 +0100 + + [expos.only.func] New home for global exposition-only functions. + + Also introduce the descriptive mechanism of an + exposition-only function. + Remove [thread.decaycopy] by moving its contents here. + Use the spelling 'decay-copy' (italics code font) instead of + introducing an intermediate meta-macro DECAY_COPY. + + commit 6833990f6e090644df012c11ebc55b26c7580565 + Author: Jens Maurer + Date: Sat Dec 29 21:33:54 2018 +0100 + + [range.refinements] Rephrase heading to not use 'common range' + + 'Common range' means iterator and end marker have the same type; + see [range.req.general]. This is not what this subclause is about. + + commit 5874ecd6f82612873d4a40e14a3e93947b2ebab6 + Author: Jens Maurer + Date: Sat Dec 29 13:27:54 2018 +0100 + + [special.mem.concepts] Use 'models ... only if' phrasing for semantic constraints. + + commit 1c3b991fac1b6668f42bde6824435f8ece037a10 + Author: Jens Maurer + Date: Sat Dec 29 12:43:27 2018 +0100 + + [range.factories] New subclause, split off from [range.adaptors] + + Range adaptors take a range and produce a new range; + range factories take something else (or nothing) and produce a range. + + commit 3afb777a04ddb2e31292c4cf011475db5b65a9fc + Author: Jens Maurer + Date: Fri Dec 28 00:25:45 2018 +0100 + + [dcl.typedef] Use 'redeclare', not 'redefine' + + commit e88e605f3561546ab47d327d1865a576c415bc7b + Author: Jens Maurer + Date: Fri Dec 28 00:12:18 2018 +0100 + + [basic.life] Adjust subclause heading + + and clarify that references are treated as-if requiring storage. + + commit 5d35f0c24e0724aee7993cef6085108fdfcd4590 + Author: Jens Maurer + Date: Fri Dec 21 20:44:23 2018 +0100 + + [iterators] Qualify declarator-id with sub-namespace. + + commit 4beab059b54b2fb859cc404b79682cbb71d76364 + Author: Jens Maurer + Date: Fri Dec 21 00:42:42 2018 +0100 + + [expr.new] A new-expression might not invoke a constructor + + commit 90467df5ce5b0dd92058dd13b082f6ed3bc16efc + Author: Jens Maurer + Date: Fri Dec 21 00:37:06 2018 +0100 + + [over.ics.user,over.ics.rank] Reference binding is part of the second SCS + + commit 8909a8f20249435788fa4f43e5199f2595a1e623 + Author: Eelis van der Weegen + Date: Mon Dec 17 18:54:04 2018 +0100 + + [diff.dcl] Capitalize sentence. + + commit 64f01ee78bfac1450c6ffefbfe345a65ce951da1 + Author: Johel Ernesto Guerrero Peña + Date: Sun Dec 9 18:59:21 2018 -0400 + + [counted.iter.cmp] Add missing colon to specification element + + commit 3ff583af0448540f40e9db7cd07c30489696ecd7 + Author: Johel Ernesto Guerrero Peña + Date: Mon Dec 10 15:14:50 2018 -0400 + + [istreambuf.iterator] Remove duplicated declarations + + commit 64d61459522873003f4af52d4abab65cac2f48c5 + Author: Johel Ernesto Guerrero Peña + Date: Mon Dec 10 15:13:34 2018 -0400 + + [istream.iterator] Remove duplicated declarations + + commit 48acf476dedcb443407cadc189a79eb89f623097 + Author: Johel Ernesto Guerrero Peña + Date: Sat Dec 8 15:26:39 2018 -0400 + + [insert.iterators] Remove duplicated declarations + + commit 45f889a3fe071cadc80f97d58e1f905e8213455b + Author: Johel Ernesto Guerrero Peña + Date: Sat Dec 8 14:14:55 2018 -0400 + + [iterator.synopsis] Drive-by add semantic breaks + + commit b72a3447c2a602aa6362fd0073c6683cedee2098 + Author: Johel Ernesto Guerrero Peña + Date: Sat Dec 8 14:13:36 2018 -0400 + + [move.iterator] Remove duplicated declarations + + commit 0fd872506cf6d30101eacd654b2133a5e090b654 + Author: Johel Ernesto Guerrero Peña + Date: Sat Dec 8 14:09:08 2018 -0400 + + [reverse.iterator] Remove duplicated declarations + + commit a1c3e9c0319f96e549fae711e616e41ff571cb6d + Author: Johel Ernesto Guerrero Peña + Date: Sat Dec 8 14:08:20 2018 -0400 + + [iterators] Move specialization to synopsis + + commit eb1067835df26c6eef46d006420be2129758d7d0 + Author: Nicolas Lesser + Date: Sat Dec 8 19:32:21 2018 +0100 + + [expr.and,expr.or,expr.xor] Add grouping sentence to the binary and/or/xor operators. + + commit 27d19661fbb0a5424f72330724d9809618efbb8b + Author: Géry Ogam + Date: Sat Jan 19 00:59:08 2019 +0100 + + [basic.lval] clarify the contexts where void expressions can appear and their value category + + commit 9c3b921635b041895d44f378ea3f534145e05006 + Author: Jens Maurer + Date: Thu Oct 25 19:16:06 2018 +0200 + + [basic.lookup,over.call.func] Clarify lookup rules for function calls. + + Also add cross-references to [class.member.lookup] when + talking about 'looked up in the class of the object expression' + in [basic.lookup.classref]. + + commit 0cd2126ddab16740d38a302f0da7fee5658f5fbb + Author: Jonathan Caves + Date: Mon Dec 17 14:16:45 2018 -0800 + + [expr.prim.lambda.capture] Add missing semicolons after statements ending in lambda expressions + + commit 1111bf9d422ebd3765730d95155860aeda07234a + Author: Casey Carter + Date: Sun Jan 6 04:16:39 2019 -0800 + + [allocator.requirements] relocate example to end of subclause + + and add paragraph number. + + Fixes #2639. + + commit b4f5a7e426c8b55c08e414aee434fe85c41e2a48 + Author: Johel Ernesto Guerrero Peña + Date: Sat Dec 29 21:01:42 2018 -0400 + + [ostreambuf.iterator] Remove tutorial-like sentence + + commit d902c5bfe137dc303fb5c7c54b6409cddac61cdc + Author: Johel Ernesto Guerrero Peña + Date: Sun Dec 9 23:13:07 2018 -0400 + + [ostreambuf.iterator] Move description before the synopsis + + commit 486e7a2f8308a5f4d8aca20a74dd7a1ed2974a84 + Author: Johel Ernesto Guerrero Peña + Date: Sat Dec 29 20:59:51 2018 -0400 + + [istreambuf.iterator.proxy] Move description before class synopsis + + commit ca07d4deb68ffb9630d3f73a33f552d5040bab17 + Author: Johel Ernesto Guerrero Peña + Date: Sun Dec 9 21:54:51 2018 -0400 + + [istreambuf.iterator] Use nullptr instead of 0 + + commit f9995862feaf47b85aabf7ec63ead2d5b00d5573 + Author: Johel Ernesto Guerrero Peña + Date: Sun Dec 9 21:49:56 2018 -0400 + + [ostream.iterator.ops] Check for non nullptr value implicitly + + commit b2cfef81694aa61a7c197ad58c96ee44f20f18ca + Author: Johel Ernesto Guerrero Peña + Date: Sun Dec 9 21:28:50 2018 -0400 + + [ostream.iterator.cons.des] Use nullptr instead of null + + commit a97f9c18edcbcfb3cf10149116f4126a422ce1fe + Author: Johel Ernesto Guerrero Peña + Date: Sat Dec 29 20:11:38 2018 -0400 + + [ostream.iterator] Remove redundant paragraph + + commit 8098533eabd9361b7798de7a44dea0277fc767e3 + Author: Johel Ernesto Guerrero Peña + Date: Sat Dec 29 20:11:03 2018 -0400 + + [ostream.iterator] Remove tutorial-like description + + commit c3a5aa19594a534f8bb9adc9b83f0eb703870699 + Author: Johel Ernesto Guerrero Peña + Date: Sun Dec 9 20:31:29 2018 -0400 + + [istream.iterator.ops] Unparenthesize return object name + + commit c84872ba9679e322ee2cded0b1a129d7b8faf2d0 + Author: Johel Ernesto Guerrero Peña + Date: Sun Dec 9 19:43:59 2018 -0400 + + [istream.iterator] Use nullptr instead of 0 + + commit 169f0c41b51ba081e2c3e662276e9a4061567eaa + Author: Jens Maurer + Date: Wed Dec 19 22:01:18 2018 +0100 + + [iterator.primitives] Rescue introductory sentence. + + commit 98f1e9f668cbe109511fd8cee1afc03c4bb9f007 + Author: JF Bastien + Date: Thu Dec 20 11:27:51 2018 -0800 + + [optional.assign] use injected class name consistently + + commit 597b6900151f810acd776e452f08c1e2941857b9 + Author: Jens Maurer + Date: Wed Dec 19 21:41:46 2018 +0100 + + [reverse.iterators] Use the public accessor function, + + not the exposition-only member 'current', from non-member functions. + + commit 3d9f80e990daf459a85cff539bd2ce64c0986886 + Author: Johel Ernesto Guerrero Peña + Date: Tue Dec 11 15:50:03 2018 -0400 + + [ranges.syn] Complete requires clause of view_interface + + commit a61eb25d048b96fd23b7544d12f43299ccf51026 + Author: Johel Ernesto Guerrero Peña + Date: Tue Dec 11 20:23:37 2018 -0400 + + [ranges.syn] Complete requires clause of filter_view + + commit 687b718c431c67a80888552c5055b0903fb197ba + Author: Casey Carter + Date: Wed Dec 19 13:39:05 2018 -0800 + + [alg.min.max] Fix typo in returns element of ranges::minmax (#2600) + + Also add linebreaks as appropriate after template-heads in declarations of `min`, `max`, and `minmax`. + + commit e7c5655a9a4746b895937aee4fdadfad30f02cfa + Author: Alberto Barbati <2210776+iaanus@users.noreply.github.com> + Date: Tue Dec 18 16:02:35 2018 +0100 + + [dcl.constexpr] Add "consteval" to subclause heading (#2597) + + commit a88d02d8d77e730bbf2730b6988a8b63319496c3 + Author: Eelis van der Weegen + Date: Wed Dec 12 16:43:21 2018 +0100 + + [temp.mem.func] Remove inappropriate parentheses in 'Array::operator[]()'. + + commit 4d9447fb590bf7fdc302706eb1560e6a402eca95 + Author: Johel Ernesto Guerrero Peña + Date: Sat Dec 8 10:09:29 2018 -0400 + + [reverse.iterator] Remove stray backslashes + + commit 54ddae362645af5028e622f92b795cd6d198c8a0 + Author: Johel Ernesto Guerrero Peña + Date: Fri Dec 7 21:09:52 2018 -0400 + + [indirectcallable.general] Fix reference + + Just 6 lines below, it is correct. + + commit 5aaec13ef8f29527e762f8e4bf8e2362c8b1419c + Author: Jens Maurer + Date: Fri Dec 7 23:03:51 2018 +0100 + + [basic.indet] Indeterminate values + + Create a new section, moved from parts of [dcl.init]. + + commit 9cf2dd2247af79721f4961c96dd9c57003556c94 + Author: Richard Smith + Date: Fri Dec 7 16:06:05 2018 -0800 + + [lex.key] Fix relative order of 'do' and 'double' in keywords table. + + commit 607ec0d6d6ce7c6e72c1cae63d22bbdf40eebd2c + Author: Johel Ernesto Guerrero Peña + Date: Fri Dec 7 19:28:30 2018 -0400 + + [iterator.concept.bidir] Add comma for clarity diff --git a/papers/n4800.pdf b/papers/n4800.pdf new file mode 100644 index 0000000000..39de74ca82 Binary files /dev/null and b/papers/n4800.pdf differ diff --git a/source/Makefile b/source/Makefile index aefaf3ed98..8215ae9d77 100644 --- a/source/Makefile +++ b/source/Makefile @@ -1,16 +1,5 @@ ### -*- mode: makefile-gmake -*- -# Note: If building on Mac OS X, and if you use MacPorts, the following ports -# should be installed: -# -# texlive-latex -# texlive-plain-extra -# texlive-latex-recommended -# texlive-latex-extra -# texlive-fonts-recommended -# texlive-fonts-extra -# texlive-generic-recommended - FIGURES = $(patsubst %.dot,%.pdf,$(wildcard *.dot)) STDPDF = pdflatex std | grep -v "^Overfull" diff --git a/source/algorithms.tex b/source/algorithms.tex index db62bcc009..4b61488ff1 100644 --- a/source/algorithms.tex +++ b/source/algorithms.tex @@ -25,18 +25,19 @@ \rSec1[algorithms.requirements]{Algorithms requirements} \pnum -All of the algorithms are separated from the particular implementations of data structures and are -parameterized by iterator types. -Because of this, they can work with program-defined data structures, as long -as these data structures have iterator types satisfying the assumptions on the algorithms. +All of the algorithms +are separated from the particular implementations of data structures and +are parameterized by iterator types. +Because of this, they can work with program-defined data structures, +as long as these data structures have iterator types +satisfying the assumptions on the algorithms. \pnum -The entities defined in the \tcode{std::ranges} namespace -in this Clause are not found by argument-dependent -name lookup\iref{basic.lookup.argdep}. When found by -unqualified\iref{basic.lookup.unqual} name lookup for the -\grammarterm{postfix-expression} in a function call\iref{expr.call}, they -inhibit argument-dependent name lookup. +The entities defined in the \tcode{std::ranges} namespace in this Clause +are not found by argument-dependent name lookup\iref{basic.lookup.argdep}. +When found by unqualified\iref{basic.lookup.unqual} name lookup +for the \grammarterm{postfix-expression} in a function call\iref{expr.call}, +they inhibit argument-dependent name lookup. \begin{example} \begin{codeblock} @@ -47,151 +48,129 @@ } \end{codeblock} The function call expression at \tcode{\#1} invokes \tcode{std::ranges::find}, -not \tcode{std::find}, despite that (a) the iterator type returned from \tcode{begin(vec)} -and \tcode{end(vec)} may be associated with namespace \tcode{std} and (b) -\tcode{std::find} is more specialized~(\ref{temp.func.order}) than -\tcode{std::ranges::find} since the former requires its first two parameters to -have the same type. +not \tcode{std::find}, despite that +(a) the iterator type returned from \tcode{begin(vec)} and \tcode{end(vec)} +may be associated with namespace \tcode{std} and +(b) \tcode{std::find} is more specialized\iref{temp.func.order} than +\tcode{std::ranges::find} since the former requires +its first two parameters to have the same type. \end{example} \pnum -For purposes of determining the existence of data races, algorithms shall -not modify objects referenced through an iterator argument unless the -specification requires such modification. +For purposes of determining the existence of data races, +algorithms shall not modify objects referenced through an iterator argument +unless the specification requires such modification. \pnum Throughout this Clause, where the template parameters are not constrained, -the names of template parameters -are used to express type requirements. +the names of template parameters are used to express type requirements. \begin{itemize} \item -If an algorithm's template parameter is named -\tcode{InputIterator}, -\tcode{InputIterator1}, -or -\tcode{Input\-Iterator2}, -the template argument shall satisfy the -\oldconcept{InputIterator} requirements\iref{input.iterators}. -\item -If an algorithm's template parameter is named -\tcode{OutputIterator}, -\tcode{OutputIterator1}, -or -\tcode{Output\-Iterator2}, -the template argument shall satisfy the -\oldconcept{OutputIterator} requirements\iref{output.iterators}. -\item -If an algorithm's template parameter is named -\tcode{ForwardIterator}, -\tcode{ForwardIterator1}, -or -\tcode{Forward\-Iterator2}, -the template argument shall satisfy the -\oldconcept{ForwardIterator} requirements\iref{forward.iterators}. -\item -If an algorithm's template parameter is named -\tcode{BidirectionalIterator}, -\tcode{Bidirectional\-Iterator1}, -or -\tcode{BidirectionalIterator2}, -the template argument shall satisfy the -\oldconcept{BidirectionalIterator} requirements\iref{bidirectional.iterators}. -\item -If an algorithm's template parameter is named -\tcode{RandomAccessIterator}, -\tcode{Random\-AccessIterator1}, -or -\tcode{RandomAccessIterator2}, -the template argument shall satisfy the -\oldconcept{RandomAccessIterator} requirements\iref{random.access.iterators}. + If an algorithm's template parameter is named + \tcode{InputIterator}, + \tcode{InputIterator1}, or + \tcode{Input\-Iterator2}, + the template argument shall satisfy the + \oldconcept{InputIterator} requirements\iref{input.iterators}. +\item + If an algorithm's template parameter is named + \tcode{OutputIterator}, + \tcode{OutputIterator1}, or + \tcode{Output\-Iterator2}, + the template argument shall satisfy the + \oldconcept{OutputIterator} requirements\iref{output.iterators}. +\item + If an algorithm's template parameter is named + \tcode{ForwardIterator}, + \tcode{ForwardIterator1}, or + \tcode{Forward\-Iterator2}, + the template argument shall satisfy the + \oldconcept{ForwardIterator} requirements\iref{forward.iterators}. +\item + If an algorithm's template parameter is named + \tcode{BidirectionalIterator}, + \tcode{Bidirectional\-Iterator1}, or + \tcode{BidirectionalIterator2}, + the template argument shall satisfy the + \oldconcept{BidirectionalIterator} requirements\iref{bidirectional.iterators}. +\item + If an algorithm's template parameter is named + \tcode{RandomAccessIterator}, + \tcode{Random\-AccessIterator1}, or + \tcode{RandomAccessIterator2}, + the template argument shall satisfy the + \oldconcept{RandomAccessIterator} requirements\iref{random.access.iterators}. \end{itemize} \pnum -If an algorithm's -\effects -element specifies that a value pointed to by any iterator passed -as an argument is modified, then that algorithm has an additional -type requirement: -The type of that argument shall satisfy the requirements -of a mutable iterator\iref{iterator.requirements}. +If an algorithm's \effects element specifies +that a value pointed to by any iterator passed as an argument is modified, +then that algorithm has an additional type requirement: +The type of that argument shall satisfy +the requirements of a mutable iterator\iref{iterator.requirements}. \begin{note} This requirement does not affect arguments that are named -\tcode{OutputIterator}, -\tcode{OutputIterator1}, -or -\tcode{OutputIterator2}, -because output iterators must always be mutable, nor does it affect -arguments that are constrained, for which mutability requirements are expressed -explicitly. +\tcode{OutputIterator}, \tcode{OutputIterator1}, or \tcode{OutputIterator2}, +because output iterators must always be mutable, nor +does it affect arguments that are constrained, +for which mutability requirements are expressed explicitly. \end{note} \pnum -Both in-place and copying versions are provided for certain -algorithms.\footnote{The decision whether to include a copying version was -usually based on complexity considerations. When the cost of doing the operation -dominates the cost of copy, the copying version is not included. For example, -\tcode{sort_copy} is not included because the cost of sorting is much more -significant, and users might as well do \tcode{copy} followed by \tcode{sort}.} +Both in-place and copying versions are provided for certain algorithms.% +\footnote{The decision whether to include a copying version was +usually based on complexity considerations. +When the cost of doing the operation dominates the cost of copy, +the copying version is not included. +For example, \tcode{sort_copy} is not included +because the cost of sorting is much more significant, +and users might as well do \tcode{copy} followed by \tcode{sort}.} When such a version is provided for \textit{algorithm} it is called -\textit{algorithm\tcode{_copy}}. Algorithms that take predicates end with the -suffix \tcode{_if} (which follows the suffix \tcode{_copy}). - -\pnum -When not otherwise constrained, the -\tcode{Predicate} -parameter is used whenever an algorithm expects a function object\iref{function.objects} -that, when applied to the result -of dereferencing the corresponding iterator, returns a value testable as -\tcode{true}. -In other words, if an algorithm -takes -\tcode{Predicate pred} -as its argument and \tcode{first} -as its iterator argument with value type \tcode{T}, +\textit{algorithm\tcode{_copy}}. +Algorithms that take predicates end with the suffix \tcode{_if} +(which follows the suffix \tcode{_copy}). + +\pnum +When not otherwise constrained, the \tcode{Predicate} parameter is used +whenever an algorithm expects a function object\iref{function.objects} that, +when applied to the result of dereferencing the corresponding iterator, +returns a value testable as \tcode{true}. +In other words, +if an algorithm takes \tcode{Predicate pred} as its argument and +\tcode{first} as its iterator argument with value type \tcode{T}, it should work correctly in the construct \tcode{pred(*first)} contextually converted to \tcode{bool}\iref{conv}. -The function object -\tcode{pred} -shall not apply any non-constant -function through the dereferenced iterator. -Given a glvalue \tcode{u} of type (possibly \tcode{const}) \tcode{T} that -designates the same object as \tcode{*first}, +The function object \tcode{pred} shall not apply any non-constant function +through the dereferenced iterator. +Given a glvalue \tcode{u} of type (possibly \tcode{const}) \tcode{T} +that designates the same object as \tcode{*first}, \tcode{pred(u)} shall be a valid expression that is equal to \tcode{pred(*first)}. \pnum -When not otherwise constrained, the -\tcode{BinaryPredicate} -parameter is used whenever an algorithm expects a function object that when applied to -the result of dereferencing two corresponding iterators or to dereferencing an -iterator and type -\tcode{T} -when -\tcode{T} -is part of the signature returns a value testable as -\tcode{true}. -In other words, if an algorithm takes -\tcode{BinaryPredicate binary_pred} -as its argument and \tcode{first1} and \tcode{first2} as -its iterator arguments with respective value types \tcode{T1} and \tcode{T2}, +When not otherwise constrained, the \tcode{BinaryPredicate} parameter is used +whenever an algorithm expects a function object that when applied +to the result of dereferencing two corresponding iterators or +to dereferencing an iterator and type \tcode{T} +when \tcode{T} is part of the signature +returns a value testable as \tcode{true}. +In other words, +if an algorithm takes \tcode{BinaryPredicate binary_pred} as its argument and +\tcode{first1} and \tcode{first2} as its iterator arguments +with respective value types \tcode{T1} and \tcode{T2}, it should work correctly in the construct \tcode{binary_pred(*first1, *first2)} contextually converted to \tcode{bool}\iref{conv}. Unless otherwise specified, -\tcode{BinaryPredicate} -always takes the first -iterator's \tcode{value_type} -as its first argument, that is, in those cases when -\tcode{T value} -is part of the signature, it should work -correctly in the -construct \tcode{binary_pred(*first1, value)} contextually converted to \tcode{bool}\iref{conv}. -\tcode{binary_pred} shall not -apply any non-constant function through the dereferenced iterators. -Given a glvalue \tcode{u} of type (possibly \tcode{const}) \tcode{T1} that -designates the same object as \tcode{*first1}, and -a glvalue \tcode{v} of type (possibly \tcode{const}) \tcode{T2} that -designates the same object as -\tcode{*first2}, +\tcode{BinaryPredicate} always takes the first iterator's \tcode{value_type} +as its first argument, that is, in those cases when \tcode{T value} +is part of the signature, it should work correctly in the construct +\tcode{binary_pred(*first1, value)} contextually converted to \tcode{bool}\iref{conv}. +\tcode{binary_pred} shall not apply any non-constant function +through the dereferenced iterators. +Given a glvalue \tcode{u} of type (possibly \tcode{const}) \tcode{T1} +that designates the same object as \tcode{*first1}, and +a glvalue \tcode{v} of type (possibly \tcode{const}) \tcode{T2} +that designates the same object as \tcode{*first2}, \tcode{binary_pred(u, *first2)}, \tcode{binary_pred(*first1, v)}, and \tcode{binary_pred(u, v)} @@ -213,33 +192,32 @@ \pnum \begin{note} Unless otherwise specified, algorithms that take function objects as arguments -are permitted to copy those function objects freely. Programmers for whom object -identity is important should consider using a wrapper class that points to a -noncopied implementation object such as \tcode{reference_wrapper}\iref{refwrap}, or some equivalent solution. +are permitted to copy those function objects freely. +Programmers for whom object identity is important should consider +using a wrapper class that points to a noncopied implementation object +such as \tcode{reference_wrapper}\iref{refwrap}, or some equivalent solution. \end{note} \pnum When the description of an algorithm gives an expression such as -\tcode{*first == value} -for a condition, the expression shall evaluate to -either \tcode{true} or \tcode{false} in boolean contexts. +\tcode{*first == value} for a condition, the expression +shall evaluate to either \tcode{true} or \tcode{false} in boolean contexts. \pnum In the description of the algorithms, operator \tcode{+} -is used for some of the iterator categories for which -it does not have to be defined. -In these cases the semantics of -\tcode{a + n} -are the same as those of +is used for some of the iterator categories +for which it does not have to be defined. +In these cases the semantics of \tcode{a + n} are the same as those of \begin{codeblock} auto tmp = a; for (; n < 0; ++n) --tmp; for (; n > 0; --n) ++tmp; return tmp; \end{codeblock} -Similarly, operator \tcode{-} is used for some -combinations of iterators and sentinel types for which -it does not have to be defined. If \range{a}{b} denotes a range, +Similarly, operator \tcode{-} is used +for some combinations of iterators and sentinel types +for which it does not have to be defined. +If \range{a}{b} denotes a range, the semantics of \tcode{b - a} in these cases are the same as those of \begin{codeblock} iter_difference_t> n = 0; @@ -254,103 +232,108 @@ \end{codeblock} \pnum -In the description of algorithm return values, a sentinel value \tcode{s} -denoting the end of a range \range{i}{s} is sometimes -returned where an iterator is expected. In these cases, the semantics are as -if the sentinel is converted into an iterator using +In the description of algorithm return values, +a sentinel value \tcode{s} denoting the end of a range \range{i}{s} +is sometimes returned where an iterator is expected. +In these cases, +the semantics are as if the sentinel is converted into an iterator using \tcode{ranges::next(i, s)}. \pnum Overloads of algorithms that take \libconcept{Range} arguments\iref{range.range} behave as if they are implemented by calling \tcode{ranges::begin} and -\tcode{ranges::end} on the \libconcept{Range}(s) and dispatching -to the overload in namespace \tcode{ranges} that takes -separate iterator and sentinel arguments. +\tcode{ranges::end} on the \libconcept{Range}(s) and +dispatching to the overload in namespace \tcode{ranges} +that takes separate iterator and sentinel arguments. \pnum The number and order of deducible template parameters for algorithm declarations are unspecified, except where explicitly stated otherwise. \begin{note} -Consequently, the algorithms may not be called with -explicitly-specified template argument lists. +Consequently, the algorithms may not +be called with explicitly-specified template argument lists. \end{note} \pnum -The class templates \tcode{binary_transform_result}, -\tcode{for_each_result}, \tcode{minmax_result}, \tcode{mismatch_result}, +The class templates +\tcode{binary_transform_result}, +\tcode{for_each_result}, +\tcode{minmax_result}, +\tcode{mismatch_result}, \tcode{copy_result}, and -\tcode{partition_copy_result} have the template parameters, data members, and -special members specified above. They have no base classes or members other than -those specified. +\tcode{partition_copy_result} +have the template parameters, data members, and special members specified above. +They have no base classes or members other than those specified. \rSec1[algorithms.parallel]{Parallel algorithms} \pnum -This subclause describes components that \Cpp{} programs may use to perform -operations on containers and other sequences in parallel. +This subclause describes components that \Cpp{} programs may use +to perform operations on containers and other sequences in parallel. \rSec2[algorithms.parallel.defns]{Terms and definitions} \pnum -A \defn{parallel algorithm} is a function template listed in this document with -a template parameter named \tcode{ExecutionPolicy}. +A \defn{parallel algorithm} is a function template listed in this document +with a template parameter named \tcode{ExecutionPolicy}. \pnum -Parallel algorithms access objects indirectly accessible via their arguments by -invoking the following functions: - +Parallel algorithms access objects indirectly accessible via their arguments +by invoking the following functions: \begin{itemize} \item -All operations of the categories of the iterators that the algorithm is -instantiated with. - + All operations of the categories of the iterators + that the algorithm is instantiated with. \item -Operations on those sequence elements that are required by its specification. - + Operations on those sequence elements that are required by its specification. \item -User-provided function objects to be applied during the execution of the -algorithm, if required by the specification. - + User-provided function objects + to be applied during the execution of the algorithm, + if required by the specification. \item -Operations on those function objects required by the specification. -\begin{note} See~\ref{algorithms.requirements}.\end{note} + Operations on those function objects required by the specification. +\begin{note} +See~\ref{algorithms.requirements}. +\end{note} \end{itemize} - These functions are herein called \defn{element access functions}. \begin{example} The \tcode{sort} function may invoke the following element access functions: - \begin{itemize} \item -Operations of the random-access iterator of the actual template argument -(as per \ref{random.access.iterators}), -as implied by the name of the template parameter \tcode{RandomAccessIterator}. - + Operations of the random-access iterator of the actual template argument + (as per \ref{random.access.iterators}), + as implied by the name of the template parameter \tcode{RandomAccessIterator}. \item -The \tcode{swap} function on the elements of the sequence (as per the -preconditions specified in \ref{sort}). - + The \tcode{swap} function on the elements of the sequence + (as per the preconditions specified in \ref{sort}). \item -The user-provided \tcode{Compare} function object. + The user-provided \tcode{Compare} function object. \end{itemize} \end{example} \rSec2[algorithms.parallel.user]{Requirements on user-provided function objects} \pnum -Unless otherwise specified, function objects passed into parallel algorithms as -objects of type \tcode{Predicate}, \tcode{BinaryPredicate}, \tcode{Compare}, -\tcode{UnaryOperation}, \tcode{BinaryOperation}, \tcode{BinaryOperation1}, -\tcode{BinaryOperation2}, and the operators used by the analogous overloads to -these parallel algorithms that could be formed by the invocation with the -specified default predicate or operation (where applicable) shall not directly -or indirectly modify objects via their arguments, nor shall they rely on the -identity of the provided objects. +Unless otherwise specified, +function objects passed into parallel algorithms as objects of type +\tcode{Predicate}, +\tcode{BinaryPredicate}, +\tcode{Compare}, +\tcode{UnaryOperation}, +\tcode{BinaryOperation}, +\tcode{BinaryOperation1}, +\tcode{BinaryOperation2}, and +the operators used by the analogous overloads to these parallel algorithms +that could be formed by the invocation +with the specified default predicate or operation (where applicable) +shall not directly or indirectly modify objects via their arguments, +nor shall they rely on the identity of the provided objects. \rSec2[algorithms.parallel.exec]{Effect of execution policies on algorithm execution} \pnum -Parallel algorithms have template parameters -named \tcode{ExecutionPolicy}\iref{execpol} +Parallel algorithms have +template parameters named \tcode{ExecutionPolicy}\iref{execpol} which describe the manner in which the execution of these algorithms may be parallelized and the manner in which they apply the element access functions. @@ -361,23 +344,28 @@ which are specified as modifying the object. \begin{note} For example, -\tcode{swap()}, \tcode{++}, \tcode{--}, \tcode{@=}, and assignments +\tcode{swap()}, +\tcode{++}, +\tcode{--}, +\tcode{@=}, and +assignments modify the object. -For the assignment and \tcode{@=} operators, -only the left argument is modified. +For the assignment and \tcode{@=} operators, only the left argument is modified. \end{note} \pnum Unless otherwise stated, implementations may make arbitrary copies of elements -(with type \tcode{T}) from sequences where \tcode{is_trivially_copy_constructible_v} +(with type \tcode{T}) from sequences +where \tcode{is_trivially_copy_constructible_v} and \tcode{is_trivially_destructible_v} are \tcode{true}. \begin{note} -This implies that user-supplied function objects should not rely on object -identity of arguments for such input sequences. Users for whom the object -identity of the arguments to these function objects is important should -consider using a wrapping iterator that returns a non-copied implementation -object such as \tcode{reference_wrapper}\iref{refwrap} or some equivalent -solution. +This implies that user-supplied function objects should not rely on +object identity of arguments for such input sequences. +Users for whom the object identity of the arguments to these function objects +is important should consider using a wrapping iterator +that returns a non-copied implementation object +such as \tcode{reference_wrapper}\iref{refwrap} +or some equivalent solution. \end{note} \pnum @@ -390,28 +378,30 @@ \pnum The invocations of element access functions in parallel algorithms invoked with -an execution policy object of type \tcode{execution::parallel_policy} are -permitted to execute in either the invoking thread of execution or in a -thread of execution implicitly -created by the library to support parallel algorithm execution. -If the threads of execution created by \tcode{thread}\iref{thread.thread.class} provide concurrent -forward progress guarantees\iref{intro.progress}, then a thread of execution -implicitly created by the library will provide parallel forward progress guarantees; +an execution policy object of type \tcode{execution::parallel_policy} +are permitted to execute +in either the invoking thread of execution or +in a thread of execution implicitly created by the library +to support parallel algorithm execution. +If the threads of execution created by \tcode{thread}\iref{thread.thread.class} +provide concurrent forward progress guarantees\iref{intro.progress}, +then a thread of execution implicitly created by the library will provide +parallel forward progress guarantees; otherwise, the provided forward progress guarantee is -\impldef{forward progress guarantees for implicit threads of parallel algorithms (if not defined for \tcode{thread})}. -Any such -invocations executing in the same thread of execution are indeterminately sequenced with -respect to each other. +\impldef{forward progress guarantees for +implicit threads of parallel algorithms (if not defined for \tcode{thread})}. +Any such invocations executing in the same thread of execution +are indeterminately sequenced with respect to each other. \begin{note} -It is the caller's responsibility to ensure that the -invocation does not introduce data races or deadlocks. +It is the caller's responsibility to ensure +that the invocation does not introduce data races or deadlocks. \end{note} \begin{example} \begin{codeblock} int a[] = {0,1}; std::vector v; std::for_each(std::execution::par, std::begin(a), std::end(a), [&](int i) { - v.push_back(i*2+1); // incorrect: data race + v.push_back(i*2+1); // incorrect: data race }); \end{codeblock} The program above has a data race because of the unsynchronized access to the @@ -428,8 +418,8 @@ }); \end{codeblock} The above example depends on the order of execution of the iterations, and -will not terminate if both iterations are executed sequentially on the same -thread of execution. +will not terminate if both iterations are executed sequentially +on the same thread of execution. \end{example} \begin{example} \begin{codeblock} @@ -441,38 +431,44 @@ ++x; }); \end{codeblock} -The above example synchronizes access to object \tcode{x} ensuring that it is -incremented correctly. +The above example synchronizes access to object \tcode{x} +ensuring that it is incremented correctly. \end{example} \pnum The invocations of element access functions in parallel algorithms invoked with an execution policy of type \tcode{execution::parallel_unsequenced_policy} are -permitted to execute in an unordered fashion in unspecified threads of execution, and +permitted to execute +in an unordered fashion in unspecified threads of execution, and unsequenced with respect to one another within each thread of execution. -These threads of execution are either the invoking thread of execution or threads of -execution implicitly created by the library; the latter will provide weakly parallel -forward progress guarantees. +These threads of execution are +either the invoking thread of execution +or threads of execution implicitly created by the library; +the latter will provide weakly parallel forward progress guarantees. \begin{note} -This means that multiple function object invocations may be interleaved on a -single thread of execution, which overrides the usual guarantee from \ref{intro.execution} +This means that multiple function object invocations may be interleaved +on a single thread of execution, +which overrides the usual guarantee from \ref{intro.execution} that function executions do not interleave with one another. \end{note} -Since \tcode{execution::parallel_unsequenced_policy} allows the execution of element -access functions to be interleaved on a single thread of execution, blocking synchronization, -including the use of mutexes, risks deadlock. Thus, the synchronization with -\tcode{execution::parallel_unsequenced_policy} is restricted as -follows: -A standard library function is \defn{vectorization-unsafe} if it is specified -to synchronize with another function invocation, or another function invocation -is specified to synchronize with it, and if it is not a memory allocation or -deallocation function. Vectorization-unsafe standard library functions may not -be invoked by user code called from \tcode{execution::parallel_unsequenced_policy} -algorithms. +Since \tcode{execution::parallel_unsequenced_policy} allows +the execution of element access functions +to be interleaved on a single thread of execution, +blocking synchronization, including the use of mutexes, risks deadlock. +Thus, the synchronization with \tcode{execution::parallel_unsequenced_policy} +is restricted as follows: +A standard library function is \defn{vectorization-unsafe} +if it is specified to synchronize with another function invocation, or +another function invocation is specified to synchronize with it, and +if it is not a memory allocation or deallocation function. +Vectorization-unsafe standard library functions may not be invoked by user code +called from \tcode{execution::parallel_unsequenced_policy} algorithms. \begin{note} -Implementations must ensure that internal synchronization inside standard -library functions does not prevent forward progress when those functions are -executed by threads of execution with weakly parallel forward progress guarantees. +Implementations must ensure +that internal synchronization inside standard library functions +does not prevent forward progress +when those functions are executed +by threads of execution with weakly parallel forward progress guarantees. \end{note} \begin{example} \begin{codeblock} @@ -484,77 +480,88 @@ ++x; }); \end{codeblock} -The above program may result in two consecutive calls to \tcode{m.lock()} on -the same thread of execution (which may deadlock), because the applications of the function -object are not guaranteed to run on different threads of execution. +The above program may result in two consecutive calls to \tcode{m.lock()} +on the same thread of execution (which may deadlock), +because the applications of the function object are not guaranteed +to run on different threads of execution. \end{example} \begin{note} -The semantics of the \tcode{execution::parallel_policy} or the -\tcode{execution::parallel_unsequenced_policy} invocation allow the implementation to -fall back to sequential execution if the system cannot parallelize an algorithm -invocation due to lack of resources. +The semantics of the \tcode{execution::parallel_policy} or +the \tcode{execution::parallel_unsequenced_policy} invocation +allow the implementation to fall back to sequential execution +if the system cannot parallelize an algorithm invocation +due to lack of resources. \end{note} \pnum -If an invocation of a parallel algorithm uses threads of execution implicitly -created by the library, then the invoking thread of execution will either - +If an invocation of a parallel algorithm uses threads of execution +implicitly created by the library, +then the invoking thread of execution will either \begin{itemize} -\item temporarily block with forward progress guarantee delegation\iref{intro.progress} - on the completion of these library-managed threads of execution, or -\item eventually execute an element access function; +\item + temporarily block + with forward progress guarantee delegation\iref{intro.progress} + on the completion of these library-managed threads of execution, or +\item + eventually execute an element access function; \end{itemize} - the thread of execution will continue to do so until the algorithm is finished. \begin{note} In blocking with forward progress guarantee delegation in this context, -a thread of execution created by the library is considered to have -finished execution as soon as it has finished the execution of the -particular element access function that the invoking thread of execution -logically depends on. +a thread of execution created by the library +is considered to have finished execution +as soon as it has finished the execution +of the particular element access function +that the invoking thread of execution logically depends on. \end{note} \pnum The semantics of parallel algorithms invoked with an execution policy object of -\impldef{additional execution policies supported by parallel algorithms} type are -\impldef{semantics of parallel algorithms invoked with +\impldef{additional execution policies supported by parallel algorithms} type +are \impldef{semantics of parallel algorithms invoked with imple\-men\-tation-defined execution policies}. \rSec2[algorithms.parallel.exceptions]{Parallel algorithm exceptions} \pnum -During the execution of a parallel algorithm, if temporary memory resources are -required for parallelization and none are available, the algorithm throws a -\tcode{bad_alloc} exception. +During the execution of a parallel algorithm, +if temporary memory resources are required for parallelization +and none are available, the algorithm throws a \tcode{bad_alloc} exception. \pnum -During the execution of a parallel algorithm, if the invocation of an element -access function exits via an uncaught exception, +During the execution of a parallel algorithm, +if the invocation of an element access function exits via an uncaught exception, the behavior is determined by the \tcode{ExecutionPolicy}. \rSec2[algorithms.parallel.overloads]{\tcode{ExecutionPolicy} algorithm overloads} \pnum -Parallel algorithms are algorithm overloads. Each parallel algorithm overload -has an additional template type parameter named \tcode{ExecutionPolicy}, which -is the first template parameter. -Additionally, each parallel algorithm overload has an additional function -parameter of type \tcode{ExecutionPolicy\&\&}, which is the first -function parameter. -\begin{note} Not all algorithms have parallel algorithm overloads.\end{note} +Parallel algorithms are algorithm overloads. +Each parallel algorithm overload +has an additional template type parameter named \tcode{ExecutionPolicy}, +which is the first template parameter. +Additionally, each parallel algorithm overload +has an additional function parameter of type \tcode{ExecutionPolicy\&\&}, +which is the first function parameter. +\begin{note} +Not all algorithms have parallel algorithm overloads. +\end{note} \pnum -Unless otherwise specified, the semantics of \tcode{ExecutionPolicy} algorithm -overloads are identical to their overloads without. +Unless otherwise specified, +the semantics of \tcode{ExecutionPolicy} algorithm overloads +are identical to their overloads without. \pnum -Unless otherwise specified, the complexity requirements of \tcode{ExecutionPolicy} -algorithm overloads are relaxed from the complexity requirements of the overloads -without as follows: -when the guarantee says ``at most \placeholder{expr}'' or ``exactly \placeholder{expr}'' -and does not specify the number of assignments or swaps, and \placeholder{expr} -is not already expressed with \bigoh{} notation, the complexity of the algorithm -shall be \bigoh{\placeholder{expr}}. +Unless otherwise specified, +the complexity requirements of \tcode{ExecutionPolicy} algorithm overloads +are relaxed from the complexity requirements of the overloads without +as follows: +when the guarantee says ``at most \placeholder{expr}'' or +``exactly \placeholder{expr}'' +and does not specify the number of assignments or swaps, and +\placeholder{expr} is not already expressed with \bigoh{} notation, +the complexity of the algorithm shall be \bigoh{\placeholder{expr}}. \pnum Parallel algorithms shall not participate in overload resolution unless @@ -2795,12 +2802,13 @@ \pnum \returns -\tcode{false} if $E$ is \tcode{false} for some iterator \tcode{i} in the -range \range{first}{last}, and \tcode{true} otherwise. +\tcode{false} if $E$ is \tcode{false} +for some iterator \tcode{i} in the range \range{first}{last}, and +\tcode{true} otherwise. \pnum -\complexity At most \tcode{last - first} applications of the predicate -and any projection. +\complexity +At most \tcode{last - first} applications of the predicate and any projection. \end{itemdescr} \rSec2[alg.any_of]{Any of} @@ -2827,6 +2835,7 @@ \pnum Let $E$ be \tcode{pred(*i)} and \tcode{invoke(pred, invoke(proj, *i))} for the overloads in namespace \tcode{std} and \tcode{std::ranges}, respectively. + \pnum \returns \tcode{true} if $E$ is \tcode{true} for some iterator \tcode{i} @@ -2864,12 +2873,13 @@ \pnum \returns -\tcode{false} if $E$ is \tcode{true} for some iterator \tcode{i} -in the range \range{first}{last}, and \tcode{true} otherwise. +\tcode{false} if $E$ is \tcode{true} +for some iterator \tcode{i} in the range \range{first}{last}, and +\tcode{true} otherwise. \pnum -\complexity At most \tcode{last - first} applications of the predicate -and any projection. +\complexity +At most \tcode{last - first} applications of the predicate and any projection. \end{itemdescr} \rSec2[alg.foreach]{For each} @@ -2882,23 +2892,23 @@ \begin{itemdescr} \pnum -\requires \tcode{Function} shall satisfy the -\oldconcept{MoveConstructible} requirements (\tref{moveconstructible}). -\begin{note} \tcode{Function} need not meet the requirements of -\oldconcept{CopyConstructible} (\tref{copyconstructible}). \end{note} +\requires +\tcode{Function} shall satisfy +the \oldconcept{MoveConstructible} requirements (\tref{moveconstructible}). +\begin{note} +\tcode{Function} need not meet the requirements of +\oldconcept{CopyConstructible} (\tref{copyconstructible}). +\end{note} \pnum \effects -Applies -\tcode{f} to the result of dereferencing every iterator in the range -\range{first}{last}, -starting from -\tcode{first} -and proceeding to -\tcode{last - 1}. -\begin{note} If the type of \tcode{first} satisfies the -requirements of a mutable iterator, \tcode{f} may apply non-constant -functions through the dereferenced iterator.\end{note} +Applies \tcode{f} to the result of dereferencing +every iterator in the range \range{first}{last}, +starting from \tcode{first} and proceeding to \tcode{last - 1}. +\begin{note} +If the type of \tcode{first} satisfies the requirements of a mutable iterator, +\tcode{f} may apply non-constant functions through the dereferenced iterator. +\end{note} \pnum \returns @@ -2906,10 +2916,7 @@ \pnum \complexity -Applies \tcode{f} -exactly -\tcode{last - first} -times. +Applies \tcode{f} exactly \tcode{last - first} times. \pnum \remarks @@ -2931,8 +2938,8 @@ \pnum \effects -Applies \tcode{f} to the result of dereferencing every iterator in the range -\range{first}{last}. +Applies \tcode{f} to the result of dereferencing +every iterator in the range \range{first}{last}. \begin{note} If the type of \tcode{first} satisfies the requirements of a mutable iterator, \tcode{f} may apply non-constant functions through the dereferenced iterator. @@ -2945,14 +2952,14 @@ \pnum \remarks If \tcode{f} returns a result, the result is ignored. -Implementations do not -have the freedom granted under \ref{algorithms.parallel.exec} to make arbitrary -copies of elements from the input sequence. +Implementations do not have +the freedom granted under \ref{algorithms.parallel.exec} +to make arbitrary copies of elements from the input sequence. \pnum \begin{note} -Does not return a copy of its \tcode{Function} parameter, since -parallelization may not permit efficient state accumulation. +Does not return a copy of its \tcode{Function} parameter, +since parallelization may not permit efficient state accumulation. \end{note} \end{itemdescr} @@ -2973,18 +2980,12 @@ \begin{itemdescr} \pnum \effects -Calls -\tcode{invoke(f, invoke(proj, *i))} for every iterator -\tcode{i} in the range -\range{first}{last}, -starting from -\tcode{first} -and proceeding to -\tcode{last - 1}. +Calls \tcode{invoke(f, invoke(proj, *i))} +for every iterator \tcode{i} in the range \range{first}{last}, +starting from \tcode{first} and proceeding to \tcode{last - 1}. \begin{note} -If the result of -\tcode{invoke(proj, *i)} is a mutable reference, \tcode{f} may apply -non-constant functions. +If the result of \tcode{invoke(proj, *i)} is a mutable reference, +\tcode{f} may apply non-constant functions. \end{note} \pnum @@ -2993,10 +2994,7 @@ \pnum \complexity -Applies \tcode{f} and \tcode{proj} -exactly -\tcode{last - first} -times. +Applies \tcode{f} and \tcode{proj} exactly \tcode{last - first} times. \pnum \remarks @@ -3004,8 +3002,8 @@ \pnum \begin{note} -The overloads in namespace \tcode{ranges} require \tcode{Fun} to model -\libconcept{CopyConstructible}. +The overloads in namespace \tcode{ranges} require +\tcode{Fun} to model \libconcept{CopyConstructible}. \end{note} \end{itemdescr} @@ -3019,8 +3017,10 @@ \pnum \requires \tcode{Function} shall satisfy the \oldconcept{MoveConstructible} requirements -\begin{note} \tcode{Function} need not meet the requirements of -\oldconcept{CopyConstructible}. \end{note} +\begin{note} +\tcode{Function} need not meet +the requirements of \oldconcept{CopyConstructible}. +\end{note} \pnum \requires @@ -3028,8 +3028,8 @@ \pnum \effects -Applies \tcode{f} to the result of dereferencing every iterator in the range -\range{first}{first + n} in order. +Applies \tcode{f} to the result of dereferencing +every iterator in the range \range{first}{first + n} in order. \begin{note} If the type of \tcode{first} satisfies the requirements of a mutable iterator, \tcode{f} may apply non-constant functions through the dereferenced iterator. @@ -3062,8 +3062,8 @@ \pnum \effects -Applies \tcode{f} to the result of dereferencing every iterator in the range -\range{first}{first + n}. +Applies \tcode{f} to the result of dereferencing +every iterator in the range \range{first}{first + n}. \begin{note} If the type of \tcode{first} satisfies the requirements of a mutable iterator, \tcode{f} may apply non-constant functions through the dereferenced iterator. @@ -3075,12 +3075,12 @@ \pnum \remarks -If \tcode{f} returns a result, the result is ignored. Implementations do not -have the freedom granted under \ref{algorithms.parallel.exec} to make arbitrary -copies of elements from the input sequence. +If \tcode{f} returns a result, the result is ignored. +Implementations do not have +the freedom granted under \ref{algorithms.parallel.exec} +to make arbitrary copies of elements from the input sequence. \end{itemdescr} - \rSec2[alg.find]{Find} \indexlibrary{\idxcode{find}}% @@ -3148,19 +3148,14 @@ \pnum \returns -The first iterator -\tcode{i} -in the range -\range{first}{last} -for which -$E$ is \tcode{true}. +The first iterator \tcode{i} in the range \range{first}{last} +for which $E$ is \tcode{true}. Returns \tcode{last} if no such iterator is found. \pnum \complexity -At most -\tcode{last - first} -applications of the corresponding predicate and any projection. +At most \tcode{last - first} applications +of the corresponding predicate and any projection. \end{itemdescr} \rSec2[alg.find.end]{Find end} @@ -3211,26 +3206,28 @@ \pnum Let: \begin{itemize} -\item \tcode{pred} be \tcode{equal_to\{\}} for the overloads with no parameter -\tcode{pred}. - -\item $E$ be: -\begin{itemize} -\item \tcode{pred(*(i + n), *(first2 + n))} -for the overloads in namespace \tcode{std}, - -\item \tcode{invoke(pred, invoke(proj1, *(i + n)), invoke(proj2, *(first2 + n)))} -for the overloads in namespace \tcode{ranges}. -\end{itemize} - -\item \tcode{i} be \tcode{last1} if \range{first2}{last2} is empty, -or if \tcode{(last2 - first2) > (last1 - first1)} is \tcode{true}, -or if there is no iterator -in the range \range{first1}{last1 - (last2 - first2)} -such that for every non-negative integer -\tcode{n < (last2 - first2)}, $E$ is \tcode{true}. -Otherwise \tcode{i} is the last such iterator -in \range{first1}{last1 - (last2 - first2)}. +\item + \tcode{pred} be \tcode{equal_to\{\}} + for the overloads with no parameter \tcode{pred}. +\item + $E$ be: + \begin{itemize} + \item + \tcode{pred(*(i + n), *(first2 + n))} + for the overloads in namespace \tcode{std}, + \item + \tcode{invoke(pred, invoke(proj1, *(i + n)), invoke(proj2, *(first2 + n)))} + for the overloads in namespace \tcode{ranges}. + \end{itemize} +\item + \tcode{i} be \tcode{last1} if \range{first2}{last2} is empty, + or if \tcode{(last2 - first2) > (last1 - first1)} is \tcode{true}, + or if there is no iterator + in the range \range{first1}{last1 - (last2 - first2)} + such that for every non-negative integer + \tcode{n < (last2 - first2)}, $E$ is \tcode{true}. + Otherwise \tcode{i} is the last such iterator + in \range{first1}{last1 - (last2 - first2)}. \end{itemize} \pnum @@ -3310,22 +3307,17 @@ \pnum \returns -The first iterator -\tcode{i} -in the range \range{first1}{last1} -such that for some -iterator -\tcode{j} -in the range \range{first2}{last2} $E$ holds. +The first iterator \tcode{i} in the range \range{first1}{last1} +such that for some iterator \tcode{j} in the range \range{first2}{last2} +$E$ holds. Returns \tcode{last1} if \range{first2}{last2} is empty or if no such iterator is found. \pnum \complexity -At most -\tcode{(last1-first1) * (last2-first2)} -applications of the corresponding predicate and any projections. +At most \tcode{(last1-first1) * (last2-first2)} applications +of the corresponding predicate and any projections. \end{itemdescr} \rSec2[alg.adjacent.find]{Adjacent find} @@ -3374,26 +3366,18 @@ \pnum \returns -The first iterator -\tcode{i} -such that both -\tcode{i} -and -\tcode{i + 1} -are in -the range -\range{first}{last} +The first iterator \tcode{i} +such that both \tcode{i} and \tcode{i + 1} are in the range \range{first}{last} for which $E$ holds. -Returns \tcode{last} -if no such iterator is found. +Returns \tcode{last} if no such iterator is found. \pnum \complexity -For the overloads with no \tcode{ExecutionPolicy}, exactly -\[ \min(\tcode{(i - first) + 1}, \ \tcode{(last - first) - 1}) \] -applications of the corresponding predicate, where \tcode{i} is -\tcode{adjacent_find}'s -return value. For the overloads with an \tcode{ExecutionPolicy}, +For the overloads with no \tcode{ExecutionPolicy}, +exactly \[ \min(\tcode{(i - first) + 1}, \ \tcode{(last - first) - 1}) \] +applications of the corresponding predicate, +where \tcode{i} is \tcode{adjacent_find}'s return value. +For the overloads with an \tcode{ExecutionPolicy}, \bigoh{\tcode{last - first}} applications of the corresponding predicate, and no more than twice as many applications of any projection. \end{itemdescr} @@ -3443,28 +3427,29 @@ \pnum Let $E$ be: \begin{itemize} -\item \tcode{*i == value} for the overloads +\item + \tcode{*i == value} for the overloads with no parameter \tcode{pred} or \tcode{proj}, -\item \tcode{pred(*i) != false} for the overloads +\item + \tcode{pred(*i) != false} for the overloads with a parameter \tcode{pred} but no parameter \tcode{proj}, -\item \tcode{invoke(proj, *i) == value} for the overloads +\item + \tcode{invoke(proj, *i) == value} for the overloads with a parameter \tcode{proj} but no parameter \tcode{pred}, -\item \tcode{invoke(pred, invoke(proj, *i)) != false} for the overloads +\item + \tcode{invoke(pred, invoke(proj, *i)) != false} for the overloads with both parameters \tcode{proj} and \tcode{pred}. \end{itemize} \pnum \effects -Returns the number of iterators -\tcode{i} -in the range \range{first}{last} +Returns the number of iterators \tcode{i} in the range \range{first}{last} for which $E$ holds. \pnum \complexity -Exactly -\tcode{last - first} -applications of the corresponding predicate and any projection. +Exactly \tcode{last - first} applications +of the corresponding predicate and any projection. \end{itemdescr} \rSec2[mismatch]{Mismatch} @@ -3537,27 +3522,35 @@ \begin{itemdescr} \pnum -Let \tcode{last2} be \tcode{first2 + (last1 - first1)} for the overloads with no parameter \tcode{last2} or \tcode{r2}. +Let \tcode{last2} be \tcode{first2 + (last1 - first1)} +for the overloads with no parameter \tcode{last2} or \tcode{r2}. \pnum Let $E$ be: \begin{itemize} \setlength{\emergencystretch}{1em} -\item \tcode{!(*(first1 + n) == *(first2 + n))} for the overloads with no parameter \tcode{pred}, -\item \tcode{pred(*(first1 + n), *(first2 + n)) == false} for the overloads with a parameter \tcode{pred} and no parameter \tcode{proj1}, -\item \tcode{!invoke(pred, invoke(proj1, *(first1 + n)), invoke(proj2, *(first2 + n)))} for the overloads with both parameters \tcode{pred} and \tcode{proj1}. +\item + \tcode{!(*(first1 + n) == *(first2 + n))} + for the overloads with no parameter \tcode{pred}, +\item + \tcode{pred(*(first1 + n), *(first2 + n)) == false} + for the overloads with a parameter \tcode{pred} and + no parameter \tcode{proj1}, +\item + \tcode{!invoke(pred, invoke(proj1, *(first1 + n)), invoke(proj2, *(first2 + n)))} + for the overloads with both parameters \tcode{pred} and \tcode{proj1}. \end{itemize} \pnum \returns -\tcode{\{ first1 + n, first2 + n \}}, where \tcode{n} is the smallest integer -such that $E$ holds, -or $\min(\tcode{last1 - first1}, \ \tcode{last2 - first2})$ if no such integer exists. +\tcode{\{ first1 + n, first2 + n \}}, +where \tcode{n} is the smallest integer such that $E$ holds, +or $\min(\tcode{last1 - first1}, \ \tcode{last2 - first2})$ +if no such integer exists. \pnum \complexity -At most -$\min(\tcode{last1 - first1}, \ \tcode{last2 - first2})$ +At most $\min(\tcode{last1 - first1}, \ \tcode{last2 - first2})$ applications of the corresponding predicate and any projections. \end{itemdescr} @@ -3622,57 +3615,56 @@ \pnum Let: \begin{itemize} -\item \tcode{last2} be \tcode{first2 + (last1 - first1)} for the overloads with no parameter \tcode{last2} or \tcode{r2}, - -\item \tcode{pred} be \tcode{equal_to\{\}} for the overloads with no parameter \tcode{pred}, - -\item $E$ be: -\begin{itemize} -\setlength{\emergencystretch}{1em} -\item \tcode{pred(*i, *(first2 + (i - first1)))} for the overloads with no parameter \tcode{proj1}, -\item \tcode{invoke(pred, invoke(proj1, *i), invoke(proj2, *(first2 + (i - first1))))} for the overloads with parameter \tcode{proj1}. -\end{itemize} +\item + \tcode{last2} be \tcode{first2 + (last1 - first1)} + for the overloads with no parameter \tcode{last2} or \tcode{r2}, +\item + \tcode{pred} be \tcode{equal_to\{\}} + for the overloads with no parameter \tcode{pred}, +\item + $E$ be: + \begin{itemize} + \setlength{\emergencystretch}{1em} + \item + \tcode{pred(*i, *(first2 + (i - first1)))} + for the overloads with no parameter \tcode{proj1}, + \item + \tcode{invoke(pred, invoke(proj1, *i), invoke(proj2, *(first2 + (i - first1))))} + for the overloads with parameter \tcode{proj1}. + \end{itemize} \end{itemize} \pnum \returns -If -\tcode{last1 - first1 != last2 - first2}, -return -\tcode{false}. -Otherwise return -\tcode{true} -if $E$ holds for every iterator -\tcode{i} -in the range \range{first1}{last1} -Otherwise, returns -\tcode{false}. +If \tcode{last1 - first1 != last2 - first2}, return \tcode{false}. +Otherwise return \tcode{true} +if $E$ holds for every iterator \tcode{i} in the range \range{first1}{last1} +Otherwise, returns \tcode{false}. \pnum \complexity If the types of \tcode{first1}, \tcode{last1}, \tcode{first2}, and \tcode{last2}: \begin{itemize} -\item meet the \oldconcept{RandomAccessIterator} - requirements\iref{random.access.iterators} +\item + meet the + \oldconcept{RandomAccessIterator} requirements\iref{random.access.iterators} for the overloads in namespace \tcode{std}, or -\item pairwise model \tcode{SizedSentinel}\iref{iterator.concept.sizedsentinel} for the -overloads in namespace \tcode{ranges}, +\item + pairwise model \tcode{SizedSentinel}\iref{iterator.concept.sizedsentinel} + for the overloads in namespace \tcode{ranges}, \end{itemize} -and -\tcode{last1 - first1 != last2 - first2}, -then -no applications of the corresponding predicate and each projection; otherwise, +and \tcode{last1 - first1 != last2 - first2}, +then no applications of the corresponding predicate and each projection; +otherwise, \begin{itemize} \item -For the overloads with no \tcode{ExecutionPolicy}, -at most -$\min(\tcode{last1 - first1}, \ \tcode{last2 - first2})$ -applications of the corresponding predicate and any projections. - + For the overloads with no \tcode{ExecutionPolicy}, + at most $\min(\tcode{last1 - first1}, \ \tcode{last2 - first2})$ + applications of the corresponding predicate and any projections. \item -For the overloads with an \tcode{ExecutionPolicy}, -\bigoh{\min(\tcode{last1 - first1}, \ \tcode{last2 - first2})} applications -of the corresponding predicate. + For the overloads with an \tcode{ExecutionPolicy}, + \bigoh{\min(\tcode{last1 - first1}, \ \tcode{last2 - first2})} + applications of the corresponding predicate. \end{itemize} \end{itemdescr} @@ -3699,30 +3691,40 @@ \begin{itemdescr} \pnum -\requires \tcode{ForwardIterator1} and \tcode{ForwardIterator2} shall have the same -value type. The comparison function shall be an equivalence relation. +\requires +\tcode{ForwardIterator1} and \tcode{ForwardIterator2} shall have +the same value type. +The comparison function shall be an equivalence relation. \pnum -\remarks If \tcode{last2} was not given in the argument list, it denotes -\tcode{first2 + (last1 - first1)} below. +\remarks +If \tcode{last2} was not given in the argument list, +it denotes \tcode{first2 + (last1 - first1)} below. \pnum -\returns If \tcode{last1 - first1 != last2 - first2}, return \tcode{false}. -Otherwise return \tcode{true} if there exists a permutation of the elements in the -range \range{first2}{first2 + (last1 - first1)}, beginning with \tcode{ForwardIterator2 -begin}, such that \tcode{equal(first1, last1, begin)} returns \tcode{true} or -\tcode{equal(first1, last1, begin, pred)} returns \tcode{true}; otherwise, returns -\tcode{false}. +\returns +If \tcode{last1 - first1 != last2 - first2}, return \tcode{false}. +Otherwise return \tcode{true} +if there exists a permutation of the elements +in the range \range{first2}{first2 + (last1 - first1)}, +beginning with \tcode{ForwardIterator2 begin}, +such that \tcode{equal(first1, last1, begin)} returns \tcode{true} or +\tcode{equal(first1, last1, begin, pred)} returns \tcode{true}; +otherwise, returns \tcode{false}. \pnum -\complexity No applications of the corresponding predicate if \tcode{ForwardIterator1} -and \tcode{Forward\-Iter\-ator2} meet the requirements of random access iterators and +\complexity +No applications of the corresponding predicate +if \tcode{ForwardIterator1} and \tcode{Forward\-Iter\-ator2} +meet the requirements of random access iterators and \tcode{last1 - first1 != last2 - first2}. -Otherwise, exactly \tcode{last1 - first1} applications of the -corresponding predicate if \tcode{equal(\brk{}first1, last1, first2, last2)} -would return \tcode{true} if \tcode{pred} was not given in the argument list -or \tcode{equal(first1, last1, first2, last2, pred)} would return \tcode{true} if pred was given in the argument list; otherwise, at -worst \bigoh{N^2}, where $N$ has the value \tcode{last1 - first1}. +Otherwise, exactly \tcode{last1 - first1} applications +of the corresponding predicate +if \tcode{equal(\brk{}first1, last1, first2, last2)} would return \tcode{true} +if \tcode{pred} was not given in the argument list or +\tcode{equal(first1, last1, first2, last2, pred)} would return \tcode{true} +if \tcode{pred} was given in the argument list; +otherwise, at worst \bigoh{N^2}, where $N$ has the value \tcode{last1 - first1}. \end{itemdescr} \indexlibrary{\idxcode{is_permutation}}% @@ -3745,10 +3747,13 @@ \begin{itemdescr} \pnum -\returns If \tcode{last1 - first1 != last2 - first2}, return \tcode{false}. -Otherwise return \tcode{true} if there exists a permutation of the elements in the -range \range{first2}{last2}, bounded by \range{pfirst}{plast}, such that -\tcode{ranges::equal(first1, last1, pfirst, plast, pred, proj1, proj2)} returns \tcode{true}; +\returns +If \tcode{last1 - first1 != last2 - first2}, return \tcode{false}. +Otherwise return \tcode{true} if there exists a permutation of the elements +in the range \range{first2}{last2}, bounded by \range{pfirst}{plast}, +such that +\tcode{ranges::equal(first1, last1, pfirst, plast, pred, proj1, proj2)} +returns \tcode{true}; otherwise, returns \tcode{false}. \pnum @@ -3759,11 +3764,11 @@ \item \tcode{S2} and \tcode{I2} model \libconcept{SizedSentinel}, and \item \tcode{last1 - first1 != last2 - first2}. \end{itemize} -Otherwise, exactly \tcode{last1 - first1} applications of the -corresponding predicate and projections if -\tcode{ranges::equal(\brk{}first1, last1, first2, last2, pred, proj1, proj2)} -would return \tcode{true}; otherwise, at -worst \bigoh{N^2}, where $N$ has the value \tcode{last1 - first1}. +Otherwise, exactly \tcode{last1 - first1} applications +of the corresponding predicate and projections +if \tcode{ranges::equal(\brk{}first1, last1, first2, last2, pred, proj1, proj2)} +would return \tcode{true}; +otherwise, at worst \bigoh{N^2}, where $N$ has the value \tcode{last1 - first1}. \end{itemdescr} \rSec2[alg.search]{Search} @@ -3798,25 +3803,18 @@ \begin{itemdescr} \pnum \returns -The first iterator -\tcode{i} -in the range \range{first1}{last1 - (last2-first2)} -such that for every non-negative integer -\tcode{n} -less than -\tcode{last2 - first2} +The first iterator \tcode{i} in the range \range{first1}{last1 - (last2-first2)} +such that +for every non-negative integer \tcode{n} less than \tcode{last2 - first2} the following corresponding conditions hold: \tcode{*(i + n) == *(first2 + n), pred(*(i + n), *(first2 + n)) != false}. -Returns \tcode{first1} -if \range{first2}{last2} is empty, -otherwise returns \tcode{last1} -if no such iterator is found. +Returns \tcode{first1} if \range{first2}{last2} is empty, +otherwise returns \tcode{last1} if no such iterator is found. \pnum \complexity -At most -\tcode{(last1 - first1) * (last2 - first2)} -applications of the corresponding predicate. +At most \tcode{(last1 - first1) * (last2 - first2)} applications +of the corresponding predicate. \end{itemdescr} \indexlibrary{\idxcode{search}}% @@ -3842,28 +3840,25 @@ \pnum \returns \begin{itemize} -\item \tcode{\{i, i + (last2 - first2)\}}, where \tcode{i} is -the first iterator in the range \range{first1}{last1 - (last2 - first2)} -such that for every non-negative integer -\tcode{n} -less than -\tcode{last2 - first2} -the condition +\item + \tcode{\{i, i + (last2 - first2)\}}, + where \tcode{i} is + the first iterator in the range \range{first1}{last1 - (last2 - first2)} + such that + for every non-negative integer \tcode{n} less than \tcode{last2 - first2} + the condition \begin{codeblock} bool(invoke(pred, invoke(proj1, *(i + n)), invoke(proj2, *(first2 + n)))) \end{codeblock} -is \tcode{true}: - -\item Returns -\tcode{\{last1, last1\}} -if no such iterator exists. + is \tcode{true}: +\item + Returns \tcode{\{last1, last1\}} if no such iterator exists. \end{itemize} \pnum \complexity -At most -\tcode{(last1 - first1) * (last2 - first2)} -applications of the corresponding predicate and projections. +At most \tcode{(last1 - first1) * (last2 - first2)} applications +of the corresponding predicate and projections. \end{itemdescr} \indexlibrary{\idxcode{search_n}}% @@ -3896,29 +3891,20 @@ \begin{itemdescr} \pnum \requires -The type -\tcode{Size} +The type \tcode{Size} shall be convertible to integral type~(\ref{conv.integral}, \ref{class.conv}). \pnum \returns -The first iterator -\tcode{i} -in the range \range{first}{last-count} -such that for every non-negative integer -\tcode{n} -less than -\tcode{count} +The first iterator \tcode{i} in the range \range{first}{last-count} +such that for every non-negative integer \tcode{n} less than \tcode{count} the following corresponding conditions hold: \tcode{*(i + n) == value, pred(*(i + n),value) != false}. -Returns \tcode{last} -if no such iterator is found. +Returns \tcode{last} if no such iterator is found. \pnum \complexity -At most -\tcode{last - first} -applications of the corresponding predicate. +At most \tcode{last - first} applications of the corresponding predicate. \end{itemdescr} \indexlibrary{\idxcode{search_n}}% @@ -3942,22 +3928,17 @@ \begin{itemdescr} \pnum \returns -\tcode{\{i, i + count\}} where \tcode{i} is the first iterator -in the range \range{first}{last - count} -such that for every non-negative integer -\tcode{n} -less than -\tcode{count}, +\tcode{\{i, i + count\}} +where \tcode{i} is the first iterator in the range \range{first}{last - count} +such that for every non-negative integer \tcode{n} less than \tcode{count}, the following condition holds: \tcode{invoke(pred, invoke(proj, *(i + n)), value)}. -Returns \tcode{\{last, last\}} -if no such iterator is found. +Returns \tcode{\{last, last\}} if no such iterator is found. \pnum \complexity -At most -\tcode{last - first} -applications of the corresponding predicate and projection. +At most \tcode{last - first} applications +of the corresponding predicate and projection. \end{itemdescr} \indexlibrary{\idxcode{search}}% @@ -3977,7 +3958,6 @@ \tcode{Searcher} need not meet the \oldconcept{CopyConstructible} requirements. \end{itemdescr} - \rSec1[alg.modifying.operations]{Mutating sequence operations} \rSec2[alg.copy]{Copy} @@ -4005,24 +3985,29 @@ Let $N$ be \tcode{last - first}. \pnum -\requires \tcode{result} shall not be in the range \range{first}{last}. +\requires +\tcode{result} shall not be in the range \range{first}{last}. \pnum -\effects Copies elements in the range \range{first}{last} into the range \range{result}{result + $N$} starting from \tcode{first} and proceeding to \tcode{last}. -For each non-negative integer $n < N$, performs \tcode{*(result + $n$) = *(first + $n$)}. +\effects +Copies elements in the range \range{first}{last} +into the range \range{result}{result + $N$} +starting from \tcode{first} and proceeding to \tcode{last}. +For each non-negative integer $n < N$, +performs \tcode{*(result + $n$) = *(first + $n$)}. \pnum \returns \begin{itemize} \item -\tcode{result + $N$} for the overload in namespace \tcode{std}, or + \tcode{result + $N$} for the overload in namespace \tcode{std}, or \item -\tcode{\{last, result + $N$\}} for the overloads in -namespace \tcode{ranges}. + \tcode{\{last, result + $N$\}} for the overloads in namespace \tcode{ranges}. \end{itemize} \pnum -\complexity Exactly $N$ assignments. +\complexity +Exactly $N$ assignments. \end{itemdescr} \indexlibrary{\idxcode{copy}}% @@ -4035,20 +4020,24 @@ \begin{itemdescr} \pnum -\requires The ranges \range{first}{last} and -\range{result}{result + (last - first)} shall not overlap. +\requires +The ranges \range{first}{last} and \range{result}{result + (last - first)} +shall not overlap. \pnum -\effects Copies elements in the range \range{first}{last} into -the range \range{result}{result + (last - first)}. +\effects +Copies elements in the range \range{first}{last} +into the range \range{result}{result + (last - first)}. For each non-negative integer \tcode{n < (last - first)}, performs \tcode{*(result + n) = *(first + n)}. \pnum -\returns \tcode{result + (last - first)}. +\returns +\tcode{result + (last - first)}. \pnum -\complexity Exactly \tcode{last - first} assignments. +\complexity +Exactly \tcode{last - first} assignments. \end{itemdescr} \indexlibrary{\idxcode{copy_n}}% @@ -4074,21 +4063,24 @@ Let $M$ be $\max(\tcode{n}, 0)$. \pnum -\effects For each non-negative integer -$i < M$, performs \tcode{*(result + i) = *(first + i)}. +\effects +For each non-negative integer $i < M$, +performs \tcode{*(result + i) = *(first + i)}. \pnum \returns \begin{itemize} \item -\tcode{result + $M$} for the overloads in namespace \tcode{std}, or + \tcode{result + $M$} + for the overloads in namespace \tcode{std}, or \item -\tcode{\{first + $M$, result + $M$\}} + \tcode{\{first + $M$, result + $M$\}} for the overload in namespace \tcode{ranges}. \end{itemize} \pnum -\complexity Exactly $M$ assignments. +\complexity +Exactly $M$ assignments. \end{itemdescr} \indexlibrary{\idxcode{copy_if}}% @@ -4120,38 +4112,52 @@ \pnum Let $E$ be: \begin{itemize} -\item \tcode{bool(pred(*i))} for the overloads in namespace \tcode{std}, or -\item \tcode{bool(invoke(pred, invoke(proj, *i)))} for the overloads in - namespace \tcode{ranges}. +\item + \tcode{bool(pred(*i))} + for the overloads in namespace \tcode{std}, or +\item + \tcode{bool(invoke(pred, invoke(proj, *i)))} + for the overloads in namespace \tcode{ranges}. \end{itemize} and $N$ be the number of iterators \tcode{i} in the range \range{first}{last} for which the condition $E$ holds. \pnum -\requires The ranges \range{first}{last} and \range{result}{result + (last - first)} shall not overlap. +\requires +The ranges \range{first}{last} and \range{result}{result + (last - first)} +shall not overlap. \begin{note} -For the overload with an \tcode{ExecutionPolicy}, there may be a performance -cost if \tcode{iterator_traits::value_type} is not -\oldconcept{\-Move\-Constructible} (\tref{moveconstructible}). +For the overload with an \tcode{ExecutionPolicy}, +there may be a performance cost +if \tcode{iterator_traits::value_type} +is not \oldconcept{\-Move\-Constructible} (\tref{moveconstructible}). \end{note} \pnum -\effects Copies all of the elements referred to by the iterator \tcode{i} in the range \range{first}{last} +\effects +Copies all of the elements referred to +by the iterator \tcode{i} in the range \range{first}{last} for which $E$ is \tcode{true}. \pnum \returns \begin{itemize} -\item \tcode{result + $N$} for the overloads in namespace \tcode{std}, or -\item \tcode{\{last, result + $N$\}} +\item + \tcode{result + $N$} + for the overloads in namespace \tcode{std}, or +\item + \tcode{\{last, result + $N$\}} for the overloads in namespace \tcode{ranges}. \end{itemize} \pnum -\complexity Exactly \tcode{last - first} applications of the corresponding predicate and any projection. +\complexity +Exactly \tcode{last - first} applications +of the corresponding predicate and any projection. \pnum -\remarks Stable\iref{algorithm.stable}. +\remarks +Stable\iref{algorithm.stable}. \end{itemdescr} \indexlibrary{\idxcode{copy_backward}}% @@ -4180,33 +4186,26 @@ \pnum \requires -\tcode{result} -shall not be in the range -\brange{first}{last}. +\tcode{result} shall not be in the range \brange{first}{last}. \pnum \effects Copies elements in the range \range{first}{last} -into the -range \range{result - $N$}{result} -starting from -\tcode{last - 1} -and proceeding to \tcode{first}.\footnote{\tcode{copy_backward} -should be used instead of copy when \tcode{last} -is in -the range -\range{result - $N$}{result}.} -For each positive integer -$n \le N$, -performs -\tcode{*(result - $n$) = *(last - $n$)}. +into the range \range{result - $N$}{result} +starting from \tcode{last - 1} and proceeding to \tcode{first}.% +\footnote{\tcode{copy_backward} should be used instead of copy +when \tcode{last} is in the range \range{result - $N$}{result}.} +For each positive integer $n \le N$, +performs \tcode{*(result - $n$) = *(last - $n$)}. \pnum \returns \begin{itemize} -\item \tcode{result - $N$} +\item + \tcode{result - $N$} for the overload in namespace \tcode{std}, or -\item \tcode{\{last, result - $N$\}} +\item + \tcode{\{last, result - $N$\}} for the overloads in namespace \tcode{ranges}. \end{itemize} @@ -4239,35 +4238,35 @@ \pnum Let $E$ be \begin{itemize} -\item \tcode{std::move(*(first + $n$))} for the overload in namespace \tcode{std}, or -\item \tcode{ranges::iter_move(first + $n$)} for the overloads in namespace \tcode{ranges}. +\item + \tcode{std::move(*(first + $n$))} + for the overload in namespace \tcode{std}, or +\item + \tcode{ranges::iter_move(first + $n$)} + for the overloads in namespace \tcode{ranges}. \end{itemize} Let $N$ be \tcode{last - first}. \pnum \requires -\tcode{result} -shall not be in the range -\range{first}{last}. +\tcode{result} shall not be in the range \range{first}{last}. \pnum \effects Moves elements in the range \range{first}{last} into the range \range{result}{result + $N$} starting from \tcode{first} and proceeding to \tcode{last}. -For each non-negative integer -$n < N$, -performs -\tcode{*(result + $n$) = $E$}. +For each non-negative integer $n < N$, performs \tcode{*(result + $n$) = $E$}. \pnum \returns \begin{itemize} \item -\tcode{result + $N$} for the overload in namespace \tcode{std}, or + \tcode{result + $N$} + for the overload in namespace \tcode{std}, or \item -\tcode{\{last, result + $N$\}} for the overloads in - namespace \tcode{ranges}. + \tcode{\{last, result + $N$\}} + for the overloads in namespace \tcode{ranges}. \end{itemize} \pnum @@ -4288,20 +4287,24 @@ Let $N$ be \tcode{last - first}. \pnum -\requires The ranges \range{first}{last} and -\range{result}{result + $N$} shall not overlap. +\requires +The ranges \range{first}{last} and \range{result}{result + $N$} +shall not overlap. \pnum -\effects Moves elements in the range \range{first}{last} into -the range \range{result}{result + $N$}. +\effects +Moves elements in the range \range{first}{last} +into the range \range{result}{result + $N$}. For each non-negative integer $n < N$, performs \tcode{*(result + $n$) = std::\brk{}move(*(first + $n$))}. \pnum -\returns \tcode{result + $N$}. +\returns +\tcode{result + $N$}. \pnum -\complexity Exactly $N$ assignments. +\complexity +Exactly $N$ assignments. \end{itemdescr} \indexlibrary{\idxcode{move_backward}}% @@ -4327,40 +4330,38 @@ \pnum Let $E$ be \begin{itemize} -\item \tcode{std::move(*(last - $n$))} for the overload in namespace \tcode{std}, or -\item \tcode{ranges::iter_move(last - $n$)} for the overloads in namespace \tcode{ranges}. +\item + \tcode{std::move(*(last - $n$))} + for the overload in namespace \tcode{std}, or +\item + \tcode{ranges::iter_move(last - $n$)} + for the overloads in namespace \tcode{ranges}. \end{itemize} Let $N$ be \tcode{last - first}. \pnum \requires -\tcode{result} -shall not be in the range -\brange{first}{last}. +\tcode{result} shall not be in the range \brange{first}{last}. \pnum \effects Moves elements in the range \range{first}{last} -into the -range \range{result - $N$}{result} -starting from -\tcode{last - 1} -and proceeding to \tcode{first}.\footnote{\tcode{move_backward} -should be used instead of move when last -is in -the range -\range{result - $N$}{result}.} -For each positive integer -$n \le N$, -performs -\tcode{*(result - $n$) = $E$}. +into the range \range{result - $N$}{result} +starting from \tcode{last - 1} and proceeding to \tcode{first}.% +\footnote{\tcode{move_backward} should be used instead of move +when \tcode{last} is in the range \range{result - $N$}{result}.} +For each positive integer $n \le N$, +performs \tcode{*(result - $n$) = $E$}. \pnum \returns \begin{itemize} -\item \tcode{result - $N$} for the overload in namespace \tcode{std}, or -\item \tcode{\{last, result - $N$\}} for the overloads - in namespace \tcode{ranges}. +\item + \tcode{result - $N$} + for the overload in namespace \tcode{std}, or +\item + \tcode{\{last, result - $N$\}} + for the overloads in namespace \tcode{ranges}. \end{itemize} \pnum @@ -4398,16 +4399,15 @@ \pnum Let: \begin{itemize} -\item \tcode{last2} be \tcode{first2 + (last1 - first1)} for the overloads with - no parameter named \tcode{last2}, and +\item + \tcode{last2} be \tcode{first2 + (last1 - first1)} + for the overloads with no parameter named \tcode{last2}, and \item $M$ be $\min(\tcode{last1 - first1}, \ \tcode{last2 - first2})$. \end{itemize} \pnum \requires -The two ranges \range{first1}{last1} -and -\range{first2}{last2} +The two ranges \range{first1}{last1} and \range{first2}{last2} shall not overlap. For the overloads in namespace \tcode{std}, \tcode{*(first1 + $n$)} shall be swappable with\iref{swappable.requirements} @@ -4415,20 +4415,24 @@ \pnum \effects -For each non-negative integer $n < M$ -performs: +For each non-negative integer $n < M$ performs: \begin{itemize} -\item \tcode{swap(*(first1 + $n$), *(first2 + $n$))} for the overloads in - namespace \tcode{std}, or -\item \tcode{ranges::iter_swap(first1 + $n$, first2 + $n$)} for the overloads - in namespace \tcode{ranges}. +\item + \tcode{swap(*(first1 + $n$), *(first2 + $n$))} + for the overloads in namespace \tcode{std}, or +\item + \tcode{ranges::iter_swap(first1 + $n$, first2 + $n$)} + for the overloads in namespace \tcode{ranges}. \end{itemize} \pnum \returns \begin{itemize} -\item \tcode{last2} for the overloads in namespace \tcode{std}, or -\item \tcode{\{first1 + $M$, first2 + $M$\}} +\item + \tcode{last2} + for the overloads in namespace \tcode{std}, or +\item + \tcode{\{first1 + $M$, first2 + $M$\}} for the overloads in namespace \tcode{ranges}. \end{itemize} @@ -4518,60 +4522,66 @@ Let: \begin{itemize} \setlength{\emergencystretch}{1em} -\item \tcode{last2} be \tcode{first2 + (last1 - first1)} for the overloads with - parameter \tcode{first2} but no parameter \tcode{last2}, -\item $N$ be \tcode{last1 - first1} for unary transforms, or +\item + \tcode{last2} be \tcode{first2 + (last1 - first1)} + for the overloads with parameter \tcode{first2} + but no parameter \tcode{last2}, +\item + $N$ be \tcode{last1 - first1} for unary transforms, or $\min(\tcode{last1 - first1}, \ \tcode{last2 - first2})$ for binary transforms, and -\item $E$ be +\item + $E$ be \begin{itemize} - \item \tcode{op(*(first1 + (i - result)))} for unary transforms defined in - namespace \tcode{std}, - \item \tcode{binary_op(*(first1 + (i - result)), *(first2 + (i - result)))} for - binary transforms defined in namespace \tcode{std}, - \item \tcode{invoke(op, invoke(proj, *(first1 + (i - result))))} for unary - transforms defined in namespace \tcode{ranges}, or - \item \tcode{invoke(binary_op, invoke(proj1, *(first1 + (i - result))), invoke(proj2,\linebreak *(first2 + (i - result))))} + \item + \tcode{op(*(first1 + (i - result)))} + for unary transforms defined in namespace \tcode{std}, + \item + \tcode{binary_op(*(first1 + (i - result)), *(first2 + (i - result)))} + for binary transforms defined in namespace \tcode{std}, + \item + \tcode{invoke(op, invoke(proj, *(first1 + (i - result))))} + for unary transforms defined in namespace \tcode{ranges}, or + \item + \tcode{invoke(binary_op, invoke(proj1, *(first1 + (i - result))), invoke(proj2,\linebreak *(first2 + (i - result))))} for binary transforms defined in namespace \tcode{ranges}. \end{itemize} \end{itemize} \pnum \requires -\tcode{op} and \tcode{binary_op} -shall not invalidate iterators or subranges, or modify elements in the ranges +\tcode{op} and \tcode{binary_op} shall not invalidate iterators or subranges, or +modify elements in the ranges \begin{itemize} \item \crange{first1}{first1 + $N$}, \item \crange{first2}{first2 + $N$}, and -\item \crange{result}{result + $N$}.\footnote{The use of fully -closed ranges is intentional.} +\item \crange{result}{result + $N$}.% +\footnote{The use of fully closed ranges is intentional.} \end{itemize} \pnum \effects -Assigns through every iterator -\tcode{i} -in the range -\range{result}{result + $N$} -a new -corresponding value equal to $E$. +Assigns through every iterator \tcode{i} +in the range \range{result}{result + $N$} +a new corresponding value equal to $E$. \pnum \returns \begin{itemize} -\item \tcode{result + $N$} +\item + \tcode{result + $N$} for the overloads defined in namespace \tcode{std}, -\item \tcode{\{first1 + $N$, result + $N$\}} for unary transforms - defined in namespace \tcode{ranges}, or -\item \tcode{\{first1 + $N$, first2 + $N$, result + $N$\}} for binary - transforms defined in namespace \tcode{ranges}. +\item + \tcode{\{first1 + $N$, result + $N$\}} + for unary transforms defined in namespace \tcode{ranges}, or +\item \tcode{\{first1 + $N$, first2 + $N$, result + $N$\}} + for binary transforms defined in namespace \tcode{ranges}. \end{itemize} \pnum \complexity -Exactly $N$ applications of -\tcode{op} or \tcode{binary_op}, and any projections. -This requirement also applies to the overload -with an \tcode{ExecutionPolicy} . +Exactly $N$ applications of \tcode{op} or \tcode{binary_op}, and +any projections. +This requirement also applies to the overload with an \tcode{ExecutionPolicy}. \pnum \remarks @@ -4634,16 +4644,12 @@ \pnum \requires -The expression -\tcode{*first = new_value} -shall be valid. +The expression \tcode{*first = new_value} shall be valid. \pnum \effects -Substitutes elements referred by the iterator -\tcode{i} -in the range \range{first}{last} -with \tcode{new_value}, +Substitutes elements referred by the iterator \tcode{i} +in the range \range{first}{last} with \tcode{new_value}, when $E$ is \tcode{true}. \pnum @@ -4652,9 +4658,8 @@ \pnum \complexity -Exactly -\tcode{last - first} -applications of the corresponding predicate and any projection. +Exactly \tcode{last - first} applications +of the corresponding predicate and any projection. \end{itemdescr} \indexlibrary{\idxcode{replace_copy}}% @@ -4733,46 +4738,34 @@ \pnum \requires -The results of the expressions -\tcode{*first} -and -\tcode{new_value} -shall be writable\iref{iterator.requirements.general} to the -\tcode{result} -output iterator. -The ranges -\range{first}{last} -and -\range{result}{result + (last - first)} +The results of the expressions \tcode{*first} and \tcode{new_value} +shall be writable\iref{iterator.requirements.general} +to the \tcode{result} output iterator. +The ranges \range{first}{last} and \range{result}{result + (last - first)} shall not overlap. \pnum \effects -Assigns to every iterator -\tcode{i} -in the -range -\range{result}{result + (last - first)} -either -\tcode{new_value} -or -\tcode{*\brk(first + (i - result))} +Assigns to every iterator \tcode{i} +in the range \range{result}{result + (last - first)} +either \tcode{new_value} or \tcode{*\brk(first + (i - result))} depending on whether $E$ holds. \pnum \returns \begin{itemize} -\item \tcode{result + (last - first)} for the overloads in - namespace \tcode{std}, or -\item \tcode{\{last, result + (last - first)\}} for the overloads in - namespace \tcode{ranges}. +\item + \tcode{result + (last - first)} + for the overloads in namespace \tcode{std}, or +\item + \tcode{\{last, result + (last - first)\}} + for the overloads in namespace \tcode{ranges}. \end{itemize} \pnum \complexity -Exactly -\tcode{last - first} -applications of the corresponding predicate and any projection. +Exactly \tcode{last - first} applications +of the corresponding predicate and any projection. \end{itemdescr} \rSec2[alg.fill]{Fill} @@ -4810,18 +4803,19 @@ \pnum \requires -The expression -\tcode{value} -shall be writable\iref{iterator.requirements.general} to the output iterator. The type -\tcode{Size} -shall be convertible to an integral type~(\ref{conv.integral}, \ref{class.conv}). +The expression \tcode{value} +shall be writable\iref{iterator.requirements.general} to the output iterator. +The type \tcode{Size} shall be convertible +to an integral type~(\ref{conv.integral}, \ref{class.conv}). \pnum \effects -Assigns \tcode{value} through all the iterators in the range \range{first}{first + $N$}. +Assigns \tcode{value} +through all the iterators in the range \range{first}{first + $N$}. \pnum -\returns \tcode{first + $N$}. +\returns +\tcode{first + $N$}. \pnum \complexity @@ -4867,8 +4861,8 @@ \pnum \requires -\tcode{Size} -shall be convertible to an integral type~(\ref{conv.integral}, \ref{class.conv}). +\tcode{Size} shall be convertible +to an integral type~(\ref{conv.integral}, \ref{class.conv}). \pnum \effects @@ -4937,37 +4931,35 @@ \pnum \requires -For the algorithms in namespace \tcode{std}, the type of -\tcode{*first} -shall meet the \oldconcept{MoveAssignable} -requirements (\tref{moveassignable}). +For the algorithms in namespace \tcode{std}, +the type of \tcode{*first} +shall meet the \oldconcept{MoveAssignable} requirements (\tref{moveassignable}). \pnum \effects -Eliminates all the elements referred to by iterator -\tcode{i} -in the range \range{first}{last} -for which $E$ holds. +Eliminates all the elements referred to by iterator \tcode{i} +in the range \range{first}{last} for which $E$ holds. \pnum \returns The end of the resulting range. \pnum -\remarks Stable\iref{algorithm.stable}. +\remarks +Stable\iref{algorithm.stable}. \pnum \complexity -Exactly -\tcode{last - first} -applications of the corresponding predicate and any projection. +Exactly \tcode{last - first} applications +of the corresponding predicate and any projection. \pnum \begin{note} -Each element in the range \range{ret}{last}, where \tcode{ret} is -the returned value, has a valid but unspecified state, because the algorithms -can eliminate elements by moving from elements that were originally -in that range. +Each element in the range \range{ret}{last}, +where \tcode{ret} is the returned value, +has a valid but unspecified state, +because the algorithms can eliminate elements +by moving from elements that were originally in that range. \end{note} \end{itemdescr} @@ -5032,28 +5024,24 @@ \end{itemize} \pnum -Let $N$ be the number of elements in \range{first}{last} for which $E$ is \tcode{false}. +Let $N$ be the number of elements in \range{first}{last} +for which $E$ is \tcode{false}. \pnum \requires -The ranges -\range{first}{last} -and -\range{result}{result + (last - first)} +The ranges \range{first}{last} and \range{result}{result + (last - first)} shall not overlap. The expression \tcode{*result = *first} shall be valid. \begin{note} -For the overloads with an \tcode{ExecutionPolicy}, there may be a performance -cost if \tcode{iterator_traits::value_type} does not meet the -\oldconcept{\-Move\-Constructible} (\tref{moveconstructible}) requirements. +For the overloads with an \tcode{ExecutionPolicy}, +there may be a performance cost +if \tcode{iterator_traits::value_type} does not meet +the \oldconcept{\-Move\-Constructible} (\tref{moveconstructible}) requirements. \end{note} \pnum \effects -Copies all the elements referred to by the iterator -\tcode{i} -in the range -\range{first}{last} -for which $E$ is \tcode{false}. +Copies all the elements referred to by the iterator \tcode{i} +in the range \range{first}{last} for which $E$ is \tcode{false}. \pnum \returns @@ -5064,12 +5052,12 @@ \pnum \complexity -Exactly -\tcode{last - first} -applications of the corresponding predicate and any projection. +Exactly \tcode{last - first} applications +of the corresponding predicate and any projection. \pnum -\remarks Stable\iref{algorithm.stable}. +\remarks +Stable\iref{algorithm.stable}. \end{itemdescr} \rSec2[alg.unique]{Unique} @@ -5104,13 +5092,16 @@ \begin{itemdescr} \pnum -Let \tcode{pred} be \tcode{equal_to\{\}} for the overloads with no -parameter \tcode{pred}, and let $E$ be +Let \tcode{pred} be \tcode{equal_to\{\}} +for the overloads with no parameter \tcode{pred}, and +let $E$ be \begin{itemize} \setlength{\emergencystretch}{1em} -\item \tcode{bool(pred(*(i - 1), *i))} +\item + \tcode{bool(pred(*(i - 1), *i))} for the overloads in namespace \tcode{std}, or -\item \tcode{bool(invoke(comp, invoke(proj, *(i - 1)), invoke(proj, *i)))} +\item + \tcode{bool(invoke(comp, invoke(proj, *(i - 1)), invoke(proj, *i)))} for the overloads in namespace \tcode{ranges}. \end{itemize} @@ -5118,16 +5109,14 @@ \requires For the overloads in namepace \tcode{std}, \tcode{pred} shall be an equivalence relation and -the type of \tcode{*first} shall meet the -\oldconcept{MoveAssignable} requirements (\tref{moveassignable}). +the type of \tcode{*first} shall meet +the \oldconcept{MoveAssignable} requirements (\tref{moveassignable}). \pnum \effects -For a nonempty range, eliminates all but the first element from every -consecutive group of equivalent elements referred to by the iterator -\tcode{i} -in the range -\range{first + 1}{last} +For a nonempty range, eliminates all but the first element +from every consecutive group of equivalent elements referred to +by the iterator \tcode{i} in the range \range{first + 1}{last} for which $E$ is \tcode{true}. \pnum @@ -5136,10 +5125,9 @@ \pnum \complexity -For nonempty ranges, exactly -\tcode{(last - first) - 1} -applications of the corresponding predicate -and no more than twice as many applications of any projection. +For nonempty ranges, exactly \tcode{(last - first) - 1} applications +of the corresponding predicate and +no more than twice as many applications of any projection. \end{itemdescr} \indexlibrary{\idxcode{unique_copy}}% @@ -5188,13 +5176,16 @@ \begin{itemdescr} \pnum -Let \tcode{pred} be \tcode{equal_to\{\}} for the overloads in -namespace \tcode{std} with no parameter \tcode{pred}, and let $E$ be +Let \tcode{pred} be \tcode{equal_to\{\}} for the overloads +in namespace \tcode{std} with no parameter \tcode{pred}, and +let $E$ be \begin{itemize} \setlength{\emergencystretch}{1em} -\item \tcode{bool(pred(*i, *(i - 1)))} +\item + \tcode{bool(pred(*i, *(i - 1)))} for the overloads in namespace \tcode{std}, or -\item \tcode{bool(invoke(comp, invoke(proj, *i), invoke(proj, *(i - 1))))} +\item + \tcode{bool(invoke(comp, invoke(proj, *i), invoke(proj, *(i - 1))))} for the overloads in namespace \tcode{ranges}. \end{itemize} @@ -5202,48 +5193,42 @@ \requires \begin{itemize} \item -The ranges -\range{first}{last} -and -\range{result}{result+(last-first)} -shall not overlap. - -\item -For the overloads in namespace \tcode{std}: -\begin{itemize} + The ranges \range{first}{last} and \range{result}{result+(last-first)} + shall not overlap. \item -The comparison function shall be an equivalence relation. - -\item -The expression -\tcode{*result = *first} -shall be valid. - -\item -For the overloads with no \tcode{ExecutionPolicy}, -let \tcode{T} be the value type of \tcode{InputIterator}. -If \tcode{InputIterator} meets the \oldconcept{ForwardIterator} requirements, -then there are no additional requirements for \tcode{T}. -Otherwise, if \tcode{OutputIterator} meets the \oldconcept{ForwardIterator} -requirements and its value type is the same as \tcode{T}, -then \tcode{T} shall meet the \oldconcept{CopyAssignable} (\tref{copyassignable}) requirements. -Otherwise, \tcode{T} shall meet both the -\oldconcept{CopyConstructible} (\tref{copyconstructible}) and \oldconcept{CopyAssignable} requirements. -\begin{note} -For the overloads with an \tcode{ExecutionPolicy}, there may be a performance -cost if the value type of \tcode{ForwardIterator1} dos not meet both the -\oldconcept{CopyConstructible} and \oldconcept{CopyAssignable} requirements. -\end{note} -\end{itemize} + For the overloads in namespace \tcode{std}: + \begin{itemize} + \item + The comparison function shall be an equivalence relation. + \item + The expression \tcode{*result = *first} shall be valid. + \item + For the overloads with no \tcode{ExecutionPolicy}, + let \tcode{T} be the value type of \tcode{InputIterator}. + If \tcode{InputIterator} meets + the \oldconcept{ForwardIterator} requirements, + then there are no additional requirements for \tcode{T}. + Otherwise, if \tcode{OutputIterator} meets + the \oldconcept{ForwardIterator} requirements and + its value type is the same as \tcode{T}, + then \tcode{T} shall meet + the \oldconcept{CopyAssignable} (\tref{copyassignable}) requirements. + Otherwise, \tcode{T} shall meet both + the \oldconcept{CopyConstructible} (\tref{copyconstructible}) and + \oldconcept{CopyAssignable} requirements. + \begin{note} + For the overloads with an \tcode{ExecutionPolicy}, + there may be a performance cost + if the value type of \tcode{ForwardIterator1} does not meet both the + \oldconcept{CopyConstructible} and \oldconcept{CopyAssignable} requirements. + \end{note} + \end{itemize} \end{itemize} \pnum \effects -Copies only the first element from every consecutive group of equal elements referred to by -the iterator -\tcode{i} -in the range -\range{first}{last} +Copies only the first element from every consecutive group of equal elements +referred to by the iterator \tcode{i} in the range \range{first}{last} for which $E$ holds. \pnum @@ -5255,10 +5240,9 @@ \pnum \complexity -Exactly -\tcode{last - first - 1} -applications of the corresponding predicate -and no more than twice as many applications of any projectionh. +Exactly \tcode{last - first - 1} applications +of the corresponding predicate +and no more than twice as many applications of any projection. \end{itemdescr} \rSec2[alg.reverse]{Reverse} @@ -5285,18 +5269,15 @@ \pnum \requires For the overloads in namespace \tcode{std}, -\tcode{BidirectionalIterator} shall meet the -\oldconcept{Value\-Swappable} requirements\iref{swappable.requirements}. +\tcode{BidirectionalIterator} shall meet +the \oldconcept{Value\-Swappable} requirements\iref{swappable.requirements}. \pnum \effects -For each non-negative integer -\tcode{i < (last - first) / 2}, -applies -\tcode{std::iter_swap}, or +For each non-negative integer \tcode{i < (last - first) / 2}, +applies \tcode{std::iter_swap}, or \tcode{ranges::\brk{}iter_swap} for the overloads in namespace \tcode{ranges}, -to all pairs of iterators -\tcode{first + i, (last - i) - 1}. +to all pairs of iterators \tcode{first + i, (last - i) - 1}. \pnum \returns @@ -5304,9 +5285,7 @@ \pnum \complexity -Exactly -\tcode{(last - first)/2} -swaps. +Exactly \tcode{(last - first)/2} swaps. \end{itemdescr} \indexlibrary{\idxcode{reverse_copy}}% @@ -5339,21 +5318,13 @@ \pnum \requires -The ranges -\range{first}{last} -and -\range{result}{result + $N$} +The ranges \range{first}{last} and \range{result}{result + $N$} shall not overlap. \pnum \effects -Copies the range -\range{first}{last} -to the range -\range{result}{result + $N$} -such that -for every non-negative integer -\tcode{i < $N$} +Copies the range \range{first}{last} to the range \range{result}{result + $N$} +such that for every non-negative integer \tcode{i < $N$} the following assignment takes place: \tcode{*(result + $N$ - 1 - i) = *(first + i)}. @@ -5361,10 +5332,9 @@ \returns \begin{itemize} \item -\tcode{result + $N$} for the overloads in namespace \tcode{std}, or + \tcode{result + $N$} for the overloads in namespace \tcode{std}, or \item -\tcode{\{last, result + $N$\}} for the overloads - in namespace \tcode{ranges}. + \tcode{\{last, result + $N$\}} for the overloads in namespace \tcode{ranges}. \end{itemize} \pnum @@ -5393,25 +5363,19 @@ \begin{itemdescr} \pnum \requires -\range{first}{middle} -and -\range{middle}{last} -shall be valid ranges. +\range{first}{middle} and \range{middle}{last} shall be valid ranges. For the overloads in namespace \tcode{std}, -\tcode{ForwardIterator} shall meet the -\oldconcept{ValueSwappable} requirements\iref{swappable.requirements}, and +\tcode{ForwardIterator} shall meet +the \oldconcept{ValueSwappable} requirements\iref{swappable.requirements}, and the type of \tcode{*first} shall meet the \oldconcept{MoveConstructible} (\tref{moveconstructible}) and \oldconcept{MoveAssignable} (\tref{moveassignable}) requirements. \pnum \effects -For each non-negative integer -\tcode{i < (last - first)}, -places the element from the position -\tcode{first + i} -into position -\tcode{first + (i + (last - middle)) \% (last - first)}. +For each non-negative integer \tcode{i < (last - first)}, +places the element from the position \tcode{first + i} +into position \tcode{first + (i + (last - middle)) \% (last - first)}. \begin{note} This is a left rotate. \end{note} @@ -5419,17 +5383,17 @@ \pnum \returns \begin{itemize} -\item \tcode{first + (last - middle)} for the overloads in - namespace \tcode{std}, or -\item \tcode{\{first + (last - middle), last\}} for the overload in - namespace \tcode{ranges}. +\item + \tcode{first + (last - middle)} + for the overloads in namespace \tcode{std}, or +\item + \tcode{\{first + (last - middle), last\}} + for the overload in namespace \tcode{ranges}. \end{itemize} \pnum \complexity -At most -\tcode{last - first} -swaps. +At most \tcode{last - first} swaps. \end{itemdescr} \begin{itemdecl} @@ -5442,7 +5406,8 @@ \begin{itemdescr} \pnum -\effects Equivalent to: +\effects +Equivalent to: \tcode{return ranges::rotate(ranges::begin(r), middle, ranges::end(r));} \end{itemdescr} @@ -5472,36 +5437,24 @@ \pnum \requires -\range{first}{middle} -and -\range{middle}{last} -shall be valid ranges. -The ranges -\range{first}{last} -and -\range{result}{result + $N$} +\range{first}{middle} and \range{middle}{last} shall be valid ranges. +The ranges \range{first}{last} and \range{result}{result + $N$} shall not overlap. \pnum \effects -Copies the range -\range{first}{last} -to the range -\range{result}{result + $N$} -such that for each non-negative integer -$i < N$ +Copies the range \range{first}{last} to the range \range{result}{result + $N$} +such that for each non-negative integer $i < N$ the following assignment takes place: -\tcode{*(result + $i$) = *(first + -($i$ + (middle - first)) \% $N$)}. +\tcode{*(result + $i$) = *(first + ($i$ + (middle - first)) \% $N$)}. \pnum \returns \begin{itemize} \item -\tcode{result + $N$} for the overloads in namespace \tcode{std}, or + \tcode{result + $N$} for the overloads in namespace \tcode{std}, or \item -\tcode{\{last, result + $N$\}} for the overload in - namespace \tcode{ranges}. + \tcode{\{last, result + $N$\}} for the overload in namespace \tcode{ranges}. \end{itemize} \pnum @@ -5520,7 +5473,8 @@ \begin{itemdescr} \pnum -\effects Equivalent to: +\effects +Equivalent to: \begin{codeblock} return ranges::rotate_copy(ranges::begin(r), middle, ranges::end(r), result); \end{codeblock} @@ -5542,22 +5496,27 @@ \requires \begin{itemize} \item -\tcode{PopulationIterator} shall satisfy the \oldconcept{InputIterator} requirements\iref{input.iterators}. + \tcode{PopulationIterator} shall satisfy + the \oldconcept{InputIterator} requirements\iref{input.iterators}. \item -\tcode{SampleIterator} shall satisfy the \oldconcept{OutputIterator} requirements\iref{output.iterators}. + \tcode{SampleIterator} shall satisfy + the \oldconcept{OutputIterator} requirements\iref{output.iterators}. \item -\tcode{SampleIterator} shall satisfy the \oldconcept{RandomAccessIterator} requirements\iref{random.access.iterators} -unless \tcode{Pop\-ulat\-ion\-Iter\-ator} satisfies the \oldconcept{ForwardIterator} requirements\iref{forward.iterators}. + \tcode{SampleIterator} shall satisfy + the \oldconcept{RandomAccessIterator} requirements\iref{random.access.iterators} + unless \tcode{Pop\-ulat\-ion\-Iter\-ator} satisfies + the \oldconcept{ForwardIterator} requirements\iref{forward.iterators}. \item -\tcode{PopulationIterator}'s value type shall be writable\iref{iterator.requirements.general} to \tcode{out}. + \tcode{PopulationIterator}'s value type shall be + writable\iref{iterator.requirements.general} to \tcode{out}. \item -\tcode{Distance} shall be an integer type. + \tcode{Distance} shall be an integer type. \item -\tcode{remove_reference_t} -shall satisfy the requirements of a uniform random bit generator type\iref{rand.req.urng} -whose return type is convertible to \tcode{Distance}. + \tcode{remove_reference_t} 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}. + \tcode{out} shall not be in the range \range{first}{last}. \end{itemize} \pnum @@ -5582,12 +5541,12 @@ \remarks \begin{itemize} \item -Stable if and only if \tcode{PopulationIterator} satisfies the -\oldconcept{ForwardIterator} requirements. + Stable if and only if \tcode{PopulationIterator} satisfies + the \oldconcept{ForwardIterator} requirements. \item -To the extent that the implementation of this function makes use of -random numbers, the object \tcode{g} shall serve as the -implementation's source of randomness. + To the extent that the implementation of this function makes use + of random numbers, the object \tcode{g} shall serve as + the implementation's source of randomness. \end{itemize} \end{itemdescr} @@ -5618,20 +5577,18 @@ For the overload in namespace \tcode{std}: \begin{itemize} \item -\tcode{RandomAccessIterator} shall meet the -\oldconcept{ValueSwappable} requirements\iref{swappable.requirements}. + \tcode{RandomAccessIterator} shall meet + the \oldconcept{ValueSwappable} requirements\iref{swappable.requirements}. \item -The type -\tcode{remove_reference_t} -shall meet the -uniform random bit generator\iref{rand.req.urng} requirements. + The type \tcode{remove_reference_t} shall meet + the uniform random bit generator\iref{rand.req.urng} requirements. \end{itemize} \pnum \effects -Permutes the elements in the range -\range{first}{last} -such that each possible permutation of those elements has equal probability of appearance. +Permutes the elements in the range \range{first}{last} +such that each possible permutation of those elements +has equal probability of appearance. \pnum \returns @@ -5639,16 +5596,13 @@ \pnum \complexity -Exactly -\tcode{(last - first) - 1} -swaps. +Exactly \tcode{(last - first) - 1} swaps. \pnum \remarks -To the extent that the implementation of this function makes use of random -numbers, the object referenced by \tcode{g} shall serve as the implementation's source of -randomness. - +To the extent that the implementation of this function makes use +of random numbers, the object referenced by \tcode{g} shall serve as +the implementation's source of randomness. \end{itemdescr} \rSec2[alg.shift]{Shift} @@ -5739,129 +5693,84 @@ \pnum The operations in~\ref{alg.sorting} defined directly in namespace \tcode{std} -have two versions: one that takes a function object of type -\tcode{Compare} -and one that uses an -\tcode{operator<}. - -\pnum -\tcode{Compare} -is a function object -type\iref{function.objects} -that meets the requirements for a template parameter named -\tcode{BinaryPredicate}~\iref{algorithms.requirements}. -The return value of the function call operation applied to -an object of type \tcode{Compare}, when contextually converted to -\tcode{bool}\iref{conv}, -yields \tcode{true} if the first argument of the call -is less than the second, and -\tcode{false} -otherwise. -\tcode{Compare comp} -is used throughout for algorithms assuming an ordering relation. - -\pnum -For all algorithms that take -\tcode{Compare}, -there is a version that uses -\tcode{operator<} -instead. -That is, -\tcode{comp(*i, *j) != false} -defaults to -\tcode{*i < *j != false}. +have two versions: +one that takes a function object of type \tcode{Compare} and +one that uses an \tcode{operator<}. + +\pnum +\tcode{Compare} is a function object type\iref{function.objects} +that meets the requirements for a template parameter +named \tcode{BinaryPredicate}~\iref{algorithms.requirements}. +The return value of the function call operation +applied to an object of type \tcode{Compare}, +when contextually converted to \tcode{bool}\iref{conv}, +yields \tcode{true} +if the first argument of the call is less than the second, and +\tcode{false} otherwise. +\tcode{Compare comp} is used throughout +for algorithms assuming an ordering relation. + +\pnum +For all algorithms that take \tcode{Compare}, +there is a version that uses \tcode{operator<} instead. +That is, \tcode{comp(*i, *j) != false} defaults to \tcode{*i < *j != false}. For algorithms other than those described in~\ref{alg.binary.search}, \tcode{comp} shall induce a strict weak ordering on the values. \pnum -The term -\term{strict} -refers to the -requirement of an irreflexive relation (\tcode{!comp(x, x)} for all \tcode{x}), -and the term -\term{weak} -to requirements that are not as strong as -those for a total ordering, -but stronger than those for a partial -ordering. -If we define -\tcode{equiv(a, b)} -as -\tcode{!comp(a, b) \&\& !comp(b, a)}, -then the requirements are that -\tcode{comp} -and -\tcode{equiv} -both be transitive relations: +The term \term{strict} refers to the requirement +of an irreflexive relation (\tcode{!comp(x, x)} for all \tcode{x}), +and the term \term{weak} to requirements +that are not as strong as those for a total ordering, +but stronger than those for a partial ordering. +If we define \tcode{equiv(a, b)} as \tcode{!comp(a, b) \&\& !comp(b, a)}, +then the requirements are that \tcode{comp} and \tcode{equiv} +both be transitive relations: \begin{itemize} -\item -\tcode{comp(a, b) \&\& comp(b, c)} -implies -\tcode{comp(a, c)} -\item -\tcode{equiv(a, b) \&\& equiv(b, c)} -implies -\tcode{equiv(a, c)} +\item \tcode{comp(a, b) \&\& comp(b, c)} implies \tcode{comp(a, c)} +\item \tcode{equiv(a, b) \&\& equiv(b, c)} implies \tcode{equiv(a, c)} \end{itemize} \begin{note} Under these conditions, it can be shown that \begin{itemize} \item -\tcode{equiv} -is an equivalence relation, + \tcode{equiv} is an equivalence relation, \item -\tcode{comp} -induces a well-defined relation on the equivalence -classes determined by -\tcode{equiv}, and + \tcode{comp} induces a well-defined relation + on the equivalence classes determined by \tcode{equiv}, and \item -the induced relation is a strict total ordering. + the induced relation is a strict total ordering. \end{itemize} \end{note} \pnum -A sequence is -\term{sorted with respect to a \tcode{comp} and \tcode{proj}} +A sequence is \term{sorted with respect to a \tcode{comp} and \tcode{proj}} for a comparator and projection \tcode{comp} and \tcode{proj} -if for every iterator -\tcode{i} -pointing to the sequence and every non-negative integer -\tcode{n} -such that -\tcode{i + n} -is a valid iterator pointing to an element of the sequence, +if for every iterator \tcode{i} pointing to the sequence and +every non-negative integer \tcode{n} +such that \tcode{i + n} is a valid iterator +pointing to an element of the sequence, \begin{codeblock} bool(invoke(comp, invoke(proj, *(i + n)), invoke(proj, *i))) \end{codeblock} is \tcode{false}. \pnum -A sequence -\range{start}{finish} -is -\term{partitioned with respect to an expression} -\tcode{f(e)} -if there exists an integer -\tcode{n} -such that for all -\tcode{0 <= i < (finish - start)}, -\tcode{f(*(start + i))} -is \tcode{true} if and only if -\tcode{i < n}. - -\pnum -In the descriptions of the functions that deal with ordering relationships we frequently use a notion of -equivalence to describe concepts such as stability. -The equivalence to which we refer is not necessarily an -\tcode{operator==}, +A sequence \range{start}{finish} is +\term{partitioned with respect to an expression} \tcode{f(e)} +if there exists an integer \tcode{n} +such that for all \tcode{0 <= i < (finish - start)}, +\tcode{f(*(start + i))} is \tcode{true} if and only if \tcode{i < n}. + +\pnum +In the descriptions of the functions that deal with ordering relationships +we frequently use a notion of equivalence to describe concepts +such as stability. +The equivalence to which we refer is not necessarily an \tcode{operator==}, but an equivalence relation induced by the strict weak ordering. -That is, two elements -\tcode{a} -and -\tcode{b} -are considered equivalent if and only if -\tcode{!(a < b) \&\& !(b < a)}. +That is, two elements \tcode{a} and \tcode{b} are considered equivalent +if and only if \tcode{!(a < b) \&\& !(b < a)}. \rSec2[alg.sort]{Sorting} @@ -5905,16 +5814,16 @@ \pnum \requires For the overloads in namespace \tcode{std}, -\tcode{RandomAccessIterator} shall meet the -\oldconcept{Value\-Swappable} requirements\iref{swappable.requirements} and -the type of \tcode{*first} shall meet the -\oldconcept{MoveConstructible} (\tref{moveconstructible}) and +\tcode{RandomAccessIterator} shall meet +the \oldconcept{Value\-Swappable} requirements\iref{swappable.requirements} and +the type of \tcode{*first} shall meet +the \oldconcept{MoveConstructible} (\tref{moveconstructible}) and \oldconcept{MoveAssignable} (\tref{moveassignable}) requirements. \pnum \effects -Sorts the elements in the range -\range{first}{last} with respect to \tcode{comp} and \tcode{proj}. +Sorts the elements in the range \range{first}{last} +with respect to \tcode{comp} and \tcode{proj}. \pnum \returns @@ -5965,10 +5874,10 @@ \pnum \requires For the overloads in namespace \tcode{std}, -\tcode{RandomAccessIterator} shall meet the -\oldconcept{Value\-Swappable} requirements\iref{swappable.requirements} and -the type of \tcode{*first} shall meet the -\oldconcept{MoveConstructible} (\tref{moveconstructible}) and +\tcode{RandomAccessIterator} shall meet +the \oldconcept{Value\-Swappable} requirements\iref{swappable.requirements} and +the type of \tcode{*first} shall meet +the \oldconcept{MoveConstructible} (\tref{moveconstructible}) and \oldconcept{MoveAssignable} (\tref{moveassignable}) requirements. \pnum @@ -5985,11 +5894,11 @@ Let $N$ be \tcode{last - first}. If enough extra memory is available, $N \log(N)$ comparisons. Otherwise, at most $N \log^2(N)$ comparisons. -In either case, twice as many projections as -the number of comparisons. +In either case, twice as many projections as the number of comparisons. \pnum -\remarks Stable\iref{algorithm.stable}. +\remarks +Stable\iref{algorithm.stable}. \end{itemdescr} \rSec3[partial.sort]{\tcode{partial_sort}} @@ -6037,22 +5946,19 @@ \requires \range{first}{middle} and \range{middle}{last} shall be valid ranges. For the overloads in namespace \tcode{std}, -\tcode{RandomAccessIterator} shall meet the -\oldconcept{ValueSwappable} requirements\iref{swappable.requirements} and -the type of \tcode{*first} shall meet the -\oldconcept{MoveConstructible} (\tref{moveconstructible}) and +\tcode{RandomAccessIterator} shall meet +the \oldconcept{ValueSwappable} requirements\iref{swappable.requirements} and +the type of \tcode{*first} shall meet +the \oldconcept{MoveConstructible} (\tref{moveconstructible}) and \oldconcept{MoveAssignable} (\tref{moveassignable}) requirements. \pnum \effects -Places the first -\tcode{middle - first} -elements from the range -\range{first}{last} as sorted with respect to \tcode{comp} and \tcode{proj} -into the range -\range{first}{middle}. -The rest of the elements in the range -\range{middle}{last} +Places the first \tcode{middle - first} elements +from the range \range{first}{last} +as sorted with respect to \tcode{comp} and \tcode{proj} +into the range \range{first}{middle}. +The rest of the elements in the range \range{middle}{last} are placed in an unspecified order. \indextext{unspecified}% @@ -6062,9 +5968,8 @@ \pnum \complexity -Approximately -\tcode{(last - first) * log(middle - first)} -comparisons, and twice as many projections. +Approximately \tcode{(last - first) * log(middle - first)} comparisons, and +twice as many projections. \end{itemdescr} \begin{itemdecl} @@ -6078,7 +5983,8 @@ \begin{itemdescr} \pnum -\effects Equivalent to: +\effects +Equivalent to: \begin{codeblock} return ranges::partial_sort(ranges::begin(r), middle, ranges::end(r), comp, proj); \end{codeblock} @@ -6146,10 +6052,10 @@ \pnum \requires For the overloads in namespace \tcode{std}, -\tcode{RandomAccessIterator} shall meet the -\oldconcept{Value\-Swappable} requirements\iref{swappable.requirements}, -the type of \tcode{*result_first} shall meet the -\oldconcept{MoveConstructible} (\tref{moveconstructible}) and +\tcode{RandomAccessIterator} shall meet +the \oldconcept{Value\-Swappable} requirements\iref{swappable.requirements}, +the type of \tcode{*result_first} shall meet +the \oldconcept{MoveConstructible} (\tref{moveconstructible}) and \oldconcept{\-Move\-Assignable} (\tref{moveassignable}) requirements, and the expression \tcode{*first} shall be writable\iref{iterator.requirements.general} to \tcode{result_first}. @@ -6162,8 +6068,7 @@ \begin{codeblock} bool(invoke(comp, invoke(proj1, *a1), invoke(proj2, *y2))). \end{codeblock} -Then, after evaluating the assignment \tcode{*x2 = *a1}, -$E$ is equal to +Then, after evaluating the assignment \tcode{*x2 = *a1}, $E$ is equal to \begin{codeblock} bool(invoke(comp, invoke(proj2, *x2), invoke(proj2, *y2))). \end{codeblock} @@ -6175,8 +6080,8 @@ \pnum \effects Places the first $N$ elements -as sorted with respect to \tcode{comp} and \tcode{proj2} into the range -\range{result_first}{result_first + $N$}. +as sorted with respect to \tcode{comp} and \tcode{proj2} +into the range \range{result_first}{result_first + $N$}. \pnum \returns @@ -6199,7 +6104,7 @@ \begin{itemdescr} \pnum \effects -Equivalent to: return \tcode{is_sorted_until(first, last) == last;} +Equivalent to: \tcode{return is_sorted_until(first, last) == last;} \end{itemdescr} \indexlibrary{\idxcode{is_sorted}}% @@ -6263,7 +6168,8 @@ \begin{itemdescr} \pnum -\effects Equivalent to: +\effects +Equivalent to: \tcode{return ranges::is_sorted_until(first, last, comp, proj) == last;} \end{itemdescr} @@ -6306,11 +6212,13 @@ \pnum \returns -The last iterator \tcode{i} in \crange{first}{last} for which the -range \range{first}{i} is sorted with respect to \tcode{comp} and \tcode{proj}. +The last iterator \tcode{i} in \crange{first}{last} +for which the range \range{first}{i} +is sorted with respect to \tcode{comp} and \tcode{proj}. \pnum -\complexity Linear. +\complexity +Linear. \end{itemdescr} \rSec2[alg.nth.element]{Nth element} @@ -6352,32 +6260,22 @@ \requires \range{first}{nth} and \range{nth}{last} shall be valid ranges. For the overloads in namespace \tcode{std}, -\tcode{RandomAccessIterator} shall meet the -\oldconcept{ValueSwappable} requirements\iref{swappable.requirements}, and -the type of \tcode{*first} shall meet the -\oldconcept{MoveConstructible} (\tref{moveconstructible}) and +\tcode{RandomAccessIterator} shall meet +the \oldconcept{ValueSwappable} requirements\iref{swappable.requirements}, and +the type of \tcode{*first} shall meet +the \oldconcept{MoveConstructible} (\tref{moveconstructible}) and \oldconcept{MoveAssignable} (\tref{moveassignable}) requirements. \pnum \effects -After -\tcode{nth_element} -the element in the position pointed to by \tcode{nth} -is the element that would be -in that position +After \tcode{nth_element} the element in the position pointed to by \tcode{nth} +is the element that would be in that position if the whole range were sorted with respect to \tcode{comp} and \tcode{proj}, unless \tcode{nth == last}. -Also for every iterator -\tcode{i} -in the range -\range{first}{nth} -and every iterator -\tcode{j} -in the range -\range{nth}{last} +Also for every iterator \tcode{i} in the range \range{first}{nth} +and every iterator \tcode{j} in the range \range{nth}{last} it holds that: -\tcode{bool(invoke(comp, invoke(proj, *j), invoke(proj, *i)))} -is \tcode{false}. +\tcode{bool(invoke(comp, invoke(proj, *j), invoke(proj, *i)))} is \tcode{false}. \pnum \returns @@ -6401,7 +6299,8 @@ \begin{itemdescr} \pnum -\effects Equivalent to: +\effects +Equivalent to: \begin{codeblock} return ranges::nth_element(ranges::begin(r), nth, ranges::end(r), comp, proj); \end{codeblock} @@ -6410,10 +6309,10 @@ \rSec2[alg.binary.search]{Binary search} \pnum -All of the algorithms in this subclause are versions of binary search -and assume that the sequence being searched is partitioned with respect to -an expression formed by binding the search key to an argument of the -comparison function. +All of the algorithms in this subclause are versions of binary search and +assume that the sequence being searched +is partitioned with respect to an expression +formed by binding the search key to an argument of the comparison function. They work on non-random access iterators minimizing the number of comparisons, which will be logarithmic for all types of iterators. They are especially appropriate for random access iterators, @@ -6456,30 +6355,19 @@ \pnum \requires -The elements -\tcode{e} -of -\range{first}{last} +The elements \tcode{e} of \range{first}{last} shall be partitioned with respect to the expression \tcode{bool(invoke(comp, invoke(proj, e), value))}. \pnum \returns -The furthermost iterator -\tcode{i} -in the range -\crange{first}{last} -such that for every iterator -\tcode{j} -in the range -\range{first}{i}, +The furthermost iterator \tcode{i} in the range \crange{first}{last} +such that for every iterator \tcode{j} in the range \range{first}{i}, \tcode{bool(invoke(comp, invoke(proj, *j), value))} is \tcode{true}. \pnum \complexity -At most -$\log_2(\tcode{last - first}) + \bigoh{1}$ -comparisons and projections. +At most $\log_2(\tcode{last - first}) + \bigoh{1}$ comparisons and projections. \end{itemdescr} \rSec3[upper.bound]{\tcode{upper_bound}} @@ -6516,30 +6404,19 @@ \pnum \requires -The elements -\tcode{e} -of -\range{first}{last} +The elements \tcode{e} of \range{first}{last} shall be partitioned with respect to the expression \tcode{!bool(invoke(comp, value, invoke(proj, e)))}. \pnum \returns -The furthermost iterator -\tcode{i} -in the range -\crange{first}{last} -such that for every iterator -\tcode{j} -in the range -\range{first}{i}, +The furthermost iterator \tcode{i} in the range \crange{first}{last} +such that for every iterator \tcode{j} in the range \range{first}{i}, \tcode{!bool(invoke(comp, value, invoke(proj, *j)))} is \tcode{true}. \pnum \complexity -At most -$\log_2(\tcode{last - first}) + \bigoh{1}$ -comparisons and projections. +At most $\log_2(\tcode{last - first}) + \bigoh{1}$ comparisons and projections. \end{itemdescr} \rSec3[equal.range]{\tcode{equal_range}} @@ -6578,18 +6455,11 @@ \pnum \requires -The elements -\tcode{e} -of -\range{first}{last} +The elements \tcode{e} of \range{first}{last} shall be partitioned with respect to the expressions -\tcode{bool(invoke(comp, invoke(proj, e), value))} -and +\tcode{bool(invoke(comp, invoke(proj, e), value))} and \tcode{!bool(invoke(comp, value, invoke(proj, e)))}. -Also, for all elements -\tcode{e} -of -\tcode{[first, last)}, +Also, for all elements \tcode{e} of \tcode{[first, last)}, \tcode{bool(comp(e, value))} shall imply \tcode{!bool(comp(\brk{}value, e))} for the overloads in namespace \tcode{std}. @@ -6611,8 +6481,7 @@ \pnum \complexity At most -$2 * \log_2(\tcode{last - first}) + \bigoh{1}$ -comparisons and projections. +$2 * \log_2(\tcode{last - first}) + \bigoh{1}$ comparisons and projections. \end{itemdescr} \rSec3[binary.search]{\tcode{binary_search}} @@ -6650,36 +6519,25 @@ \pnum \requires -The elements -\tcode{e} -of -\range{first}{last} +The elements \tcode{e} of \range{first}{last} shall be partitioned with respect to the expressions \tcode{bool(invoke(comp, invoke(proj, e), value))} and \tcode{!bool(invoke(comp, value, invoke(proj, e)))}. -Also, for all elements -\tcode{e} -of -\tcode{[first, last)}, -\tcode{bool(comp(e, value))} -shall imply -\tcode{!bool(comp(\brk{}value, e))} +Also, for all elements \tcode{e} of \tcode{[first, last)}, +\tcode{bool(comp(e, value))} shall imply \tcode{!bool(comp(\brk{}value, e))} for the overloads in namespace \tcode{std}. \pnum \returns -\tcode{true} -if and only if for some iterator -\tcode{i} -in the range -\range{first}{last}, -\tcode{!bool(invoke(comp, invoke(proj, *i), value)) \&\& !bool(invoke(comp, value, invoke(proj, *i)))} is \tcode{true}. +\tcode{true} if and only if +for some iterator \tcode{i} in the range \range{first}{last}, +\tcode{!bool(invoke(comp, invoke(proj, *i), value)) \&\& +!bool(invoke(comp, value, invoke(proj, *i)))} +is \tcode{true}. \pnum \complexity -At most -$\log_2(\tcode{last - first}) + \bigoh{1}$ -comparisons and projections. +At most $\log_2(\tcode{last - first}) + \bigoh{1}$ comparisons and projections. \end{itemdescr} \rSec2[alg.partitions]{Partitions} @@ -6704,18 +6562,19 @@ \begin{itemdescr} \pnum -Let \tcode{proj} be \tcode{identity\{\}} for -the overloads with no parameter named \tcode{proj}. +Let \tcode{proj} be \tcode{identity\{\}} +for the overloads with no parameter named \tcode{proj}. \pnum -\returns \tcode{true} if and only if -the elements \tcode{e} of -\range{first}{last} are partitioned with respect to the expression +\returns +\tcode{true} if and only if the elements \tcode{e} of \range{first}{last} +are partitioned with respect to the expression \tcode{bool(invoke(pred, invoke(proj, e)))}. \pnum -\complexity Linear. At most \tcode{last - first} applications of \tcode{pred} -and \tcode{proj}. +\complexity +Linear. +At most \tcode{last - first} applications of \tcode{pred} and \tcode{proj}. \end{itemdescr} \indexlibrary{\idxcode{partition}}% @@ -6743,38 +6602,42 @@ \begin{itemdescr} \pnum -Let \tcode{proj} be \tcode{identity\{\}} for the overloads -with no parameter named \tcode{proj} +Let \tcode{proj} be \tcode{identity\{\}} +for the overloads with no parameter named \tcode{proj} and let $E(x)$ be \tcode{bool(invoke(\brk{}pred, invoke(proj, $x$)))}. \pnum \requires For the overloads in namespace \tcode{std}, -\tcode{ForwardIterator} shall meet the -\oldconcept{ValueSwappable} requirements\iref{swappable.requirements}. +\tcode{ForwardIterator} shall meet +the \oldconcept{ValueSwappable} requirements\iref{swappable.requirements}. \pnum -\effects Places all the elements \tcode{e} in \range{first}{last} +\effects +Places all the elements \tcode{e} in \range{first}{last} that satisfy $E(\tcode{e})$ before all the elements that do not. \pnum -\returns An iterator \tcode{i} such that $E(\tcode{*j})$ is \tcode{true} -for every iterator \tcode{j} in -\range{first}{i} and \tcode{false} for every iterator \tcode{j} in -\range{i}{last}. +\returns +An iterator \tcode{i} such that $E(\tcode{*j})$ is +\tcode{true} for every iterator \tcode{j} in \range{first}{i} and +\tcode{false} for every iterator \tcode{j} in \range{i}{last}. \pnum \complexity Let $N = \tcode{last - first}$: \begin{itemize} -\item For the overload with no \tcode{ExecutionPolicy}, exactly $N$ applications -of the predicate and projection. At most $N / 2$ swaps if the type of \tcode{first} meets the -\oldconcept{BidirectionalIterator} requirements -for the overloads in namespace \tcode{std} or -models \libconcept{BidirectionalIterator} for the -overloads in namespace \tcode{ranges}, -and at most $N$ swaps otherwise. -\item For the overload with an \tcode{ExecutionPolicy}, -\bigoh{N \log N} swaps and \bigoh{N} applications of the predicate. +\item + For the overload with no \tcode{ExecutionPolicy}, + exactly $N$ applications of the predicate and projection. + At most $N / 2$ swaps if the type of \tcode{first} meets + the \oldconcept{BidirectionalIterator} requirements + for the overloads in namespace \tcode{std} or + models \libconcept{BidirectionalIterator} + for the overloads in namespace \tcode{ranges}, + and at most $N$ swaps otherwise. +\item + For the overload with an \tcode{ExecutionPolicy}, + \bigoh{N \log N} swaps and \bigoh{N} applications of the predicate. \end{itemize} \end{itemdescr} @@ -6803,52 +6666,44 @@ \begin{itemdescr} \pnum -\pnum -Let \tcode{proj} be \tcode{identity\{\}} for the overloads -with no parameter named \tcode{proj} +Let \tcode{proj} be \tcode{identity\{\}} +for the overloads with no parameter named \tcode{proj} and let $E(x)$ be \tcode{bool(invoke(\brk{}pred, invoke(proj, $x$)))}. \requires For the overloads in namespace \tcode{std}, -\tcode{BidirectionalIterator} shall meet the -\oldconcept{Value\-Swappable} requirements\iref{swappable.requirements} and -the type of \tcode{*first} shall meet the -\oldconcept{MoveConstructible} (\tref{moveconstructible}) and +\tcode{BidirectionalIterator} shall meet +the \oldconcept{Value\-Swappable} requirements\iref{swappable.requirements} and +the type of \tcode{*first} shall meet +the \oldconcept{MoveConstructible} (\tref{moveconstructible}) and \oldconcept{MoveAssignable} (\tref{moveassignable}) requirements. \pnum \effects Places all the elements \tcode{e} in \range{first}{last} -that satisfy $E(\tcode{e})$ before all the -elements that do not. +that satisfy $E(\tcode{e})$ before all the elements that do not. The relative order of the elements in both groups is preserved. \pnum \returns -An iterator -\tcode{i} -such that for every iterator -\tcode{j} -in -\range{first}{i}, +An iterator \tcode{i} +such that for every iterator \tcode{j} in \range{first}{i}, $E(\tcode{*j})$ is \tcode{true}, -and for every iterator -\tcode{j} -in the range -\range{i}{last}, +and for every iterator \tcode{j} in the range \range{i}{last}, $E(\tcode{*j})$ is \tcode{false}, \pnum \complexity Let $N$ = \tcode{last - first}: \begin{itemize} -\item For the overloads with no \tcode{ExecutionPolicy}, at most $N \log N$ swaps, -but only \bigoh{N} swaps if there is enough extra memory. Exactly $N$ -applications of the predicate and projection. -\item For the overload with an \tcode{ExecutionPolicy}, -\bigoh{N \log N} swaps and \bigoh{N} applications of the predicate. +\item + For the overloads with no \tcode{ExecutionPolicy}, at most $N \log N$ swaps, + but only \bigoh{N} swaps if there is enough extra memory. + Exactly $N$ applications of the predicate and projection. +\item + For the overload with an \tcode{ExecutionPolicy}, + \bigoh{N \log N} swaps and \bigoh{N} applications of the predicate. \end{itemize} - \end{itemdescr} \indexlibrary{\idxcode{partition_copy}}% @@ -6884,17 +6739,17 @@ \begin{itemdescr} \pnum -Let \tcode{proj} be \tcode{identity\{\}} for the overloads -with no parameter named \tcode{proj} -and let $E(x)$ be \tcode{bool(invoke(\brk{}pred, invoke(proj, $x$)))}. +Let \tcode{proj} be \tcode{identity\{\}} +for the overloads with no parameter named \tcode{proj} and +let $E(x)$ be \tcode{bool(invoke(\brk{}pred, invoke(proj, $x$)))}. \pnum \requires The input range and output ranges shall not overlap. For the overloads in namespace \tcode{std}, -the expression \tcode{*first} shall be -writable\iref{iterator.requirements.general} to -\tcode{out_true} and \tcode{out_false}. +the expression \tcode{*first} +shall be writable\iref{iterator.requirements.general} +to \tcode{out_true} and \tcode{out_false}. \begin{note} For the overload with an \tcode{ExecutionPolicy}, there may be a performance cost if \tcode{first}'s value type @@ -6903,7 +6758,10 @@ \pnum \effects -For each iterator \tcode{i} in \range{first}{last}, copies \tcode{*i} to the output range beginning with \tcode{out_true} if \tcode{$E(\tcode{*i})$} is \tcode{true}, or to the output range beginning with \tcode{out_false} otherwise. +For each iterator \tcode{i} in \range{first}{last}, +copies \tcode{*i} to the output range beginning with \tcode{out_true} +if \tcode{$E(\tcode{*i})$} is \tcode{true}, or +to the output range beginning with \tcode{out_false} otherwise. \pnum \returns @@ -6916,8 +6774,8 @@ \end{itemize} \pnum -\complexity Exactly \tcode{last - first} applications of \tcode{pred} -and \tcode{proj}. +\complexity +Exactly \tcode{last - first} applications of \tcode{pred} and \tcode{proj}. \end{itemdescr} \indexlibrary{\idxcode{partition_point}}% @@ -6939,8 +6797,8 @@ \begin{itemdescr} \pnum -Let \tcode{proj} be \tcode{identity\{\}} for the overloads -with no parameter named \tcode{proj} +Let \tcode{proj} be \tcode{identity\{\}} +for the overloads with no parameter named \tcode{proj} and let $E(x)$ be \tcode{bool(invoke(\brk{}pred, invoke(proj, $x$)))}. \pnum @@ -6950,14 +6808,15 @@ \pnum \returns -An iterator \tcode{mid} such that -$E(\tcode{*i})$ is \tcode{true} for all iterators \tcode{i} -in \range{first}{mid}, and +An iterator \tcode{mid} +such that $E(\tcode{*i})$ is \tcode{true} +for all iterators \tcode{i} in \range{first}{mid}, and \tcode{false} for all iterators \tcode{i} in \range{mid}{last} \pnum -\complexity \bigoh{\log(\tcode{last - first})} applications of \tcode{pred} -and \tcode{proj}. +\complexity +\bigoh{\log(\tcode{last - first})} applications +of \tcode{pred} and \tcode{proj}. \end{itemdescr} \rSec2[alg.merge]{Merge} @@ -7018,39 +6877,49 @@ for the overloads with no parameters by those names. \pnum -\requires The ranges \range{first1}{last1} and \range{first2}{last2} shall be -sorted with respect to \tcode{comp} and \tcode{proj1} or \tcode{proj2}, respectively. +\requires +The ranges \range{first1}{last1} and \range{first2}{last2} +shall be sorted with respect to \tcode{comp} and \tcode{proj1} or \tcode{proj2}, +respectively. The resulting range shall not overlap with either of the original ranges. \pnum -\effects Copies all the elements of the two ranges \range{first1}{last1} and -\range{first2}{last2} into the range \range{result}{result_last}, where \tcode{result_last} -is \tcode{result + $N$}. -If an element \tcode{a} precedes \tcode{b} in an input range, \tcode{a} is -copied into the output range before \tcode{b}. If \tcode{e1} is an element of -\range{first1}{last1} and \tcode{e2} of \range{first2}{last2}, \tcode{e2} is -copied into the output range before \tcode{e1} if and only if +\effects +Copies all the elements of the two ranges \range{first1}{last1} and +\range{first2}{last2} into the range \range{result}{result_last}, +where \tcode{result_last} is \tcode{result + $N$}. +If an element \tcode{a} precedes \tcode{b} in an input range, +\tcode{a} is copied into the output range before \tcode{b}. +If \tcode{e1} is an element of \range{first1}{last1} and +\tcode{e2} of \range{first2}{last2}, +\tcode{e2} is copied into the output range before \tcode{e1} if and only if \tcode{bool(invoke(comp, invoke(proj2, e2), invoke(proj1, e1)))} is \tcode{true}. \pnum \returns \begin{itemize} -\item \tcode{result_last} for the overloads in namespace \tcode{std}, or -\item \tcode{\{last1, last2, result_last\}} for the overloads in - namespace \tcode{ranges}. +\item + \tcode{result_last} + for the overloads in namespace \tcode{std}, or +\item + \tcode{\{last1, last2, result_last\}} + for the overloads in namespace \tcode{ranges}. \end{itemize} \pnum \complexity \begin{itemize} -\item For the overloads with no \tcode{ExecutionPolicy}, at most $N - 1$ comparisons -and applications of each projection. -\item For the overloads with an \tcode{ExecutionPolicy}, \bigoh{N} comparisons. +\item + For the overloads with no \tcode{ExecutionPolicy}, + at most $N - 1$ comparisons and applications of each projection. +\item + For the overloads with an \tcode{ExecutionPolicy}, \bigoh{N} comparisons. \end{itemize} \pnum -\remarks Stable\iref{algorithm.stable}. +\remarks +Stable\iref{algorithm.stable}. \end{itemdescr} \indexlibrary{\idxcode{inplace_merge}}% @@ -7094,20 +6963,17 @@ \range{first}{middle} and \range{middle}{last} shall be valid ranges sorted with respect to \tcode{comp} and \tcode{proj}. For the overloads in namespace \tcode{std}, -\tcode{BidirectionalIterator} shall meet the -\oldconcept{Value\-Swappable} requirements\iref{swappable.requirements} and -the type of \tcode{*first} shall meet the -\oldconcept{MoveConstructible} (\tref{moveconstructible}) and +\tcode{BidirectionalIterator} shall meet +the \oldconcept{Value\-Swappable} requirements\iref{swappable.requirements} and +the type of \tcode{*first} shall meet +the \oldconcept{MoveConstructible} (\tref{moveconstructible}) and \oldconcept{MoveAssignable} (\tref{moveassignable}) requirements. \pnum \effects Merges two sorted consecutive ranges -\range{first}{middle} -and -\range{middle}{last}, -putting the result of the merge into the range -\range{first}{last}. +\range{first}{middle} and \range{middle}{last}, +putting the result of the merge into the range \range{first}{last}. The resulting range is sorted with respect to \tcode{comp} and \tcode{proj}. \pnum @@ -7115,16 +6981,20 @@ \tcode{last} for the overload in namespace \tcode{ranges}. \pnum -\complexity Let $N = \tcode{last - first}$: +\complexity +Let $N = \tcode{last - first}$: \begin{itemize} -\item For the overloads with no \tcode{ExecutionPolicy}, and if enough additional -memory is available, exactly $N - 1$ comparisons. -\item Otherwise, \bigoh{N \log N} comparisons. +\item + For the overloads with no \tcode{ExecutionPolicy}, and + if enough additional memory is available, exactly $N - 1$ comparisons. +\item + Otherwise, \bigoh{N \log N} comparisons. \end{itemize} In either case, twice as many projections as comparisons. \pnum -\remarks Stable\iref{algorithm.stable}. +\remarks +Stable\iref{algorithm.stable}. \end{itemdescr} \begin{itemdecl} @@ -7138,7 +7008,8 @@ \begin{itemdescr} \pnum -\effects Equivalent to: +\effects +Equivalent to: \begin{codeblock} return ranges::inplace_merge(ranges::begin(r), middle, ranges::end(r), comp, proj); \end{codeblock} @@ -7148,16 +7019,12 @@ \pnum This subclause defines all the basic set operations on sorted structures. -They also work with -\tcode{multiset}s\iref{multiset} +They also work with \tcode{multiset}s\iref{multiset} containing multiple copies of equivalent elements. -The semantics of the set operations are generalized to -\tcode{multiset}s -in a standard way by defining -\tcode{set_union()} +The semantics of the set operations are generalized to \tcode{multiset}s +in a standard way by defining \tcode{set_union()} to contain the maximum number of occurrences of every element, -\tcode{set_intersection()} -to contain the minimum, and so on. +\tcode{set_intersection()} to contain the minimum, and so on. \rSec3[includes]{\tcode{includes}} @@ -7206,9 +7073,8 @@ \pnum \requires -The ranges \range{first1}{last1} and \range{first2}{last2} -shall be sorted with respect to \tcode{comp} -and \tcode{proj1} or \tcode{proj2}, respectively. +The ranges \range{first1}{last1} and \range{first2}{last2} shall be sorted +with respect to \tcode{comp} and \tcode{proj1} or \tcode{proj2}, respectively. \pnum \returns @@ -7222,8 +7088,7 @@ \pnum \complexity -At most -\tcode{2 * ((last1 - first1) + (last2 - first2)) - 1} +At most \tcode{2 * ((last1 - first1) + (last2 - first2)) - 1} comparisons and applications of each projection. \end{itemdescr} @@ -7284,9 +7149,8 @@ \pnum \requires -The ranges \range{first1}{last1} and \range{first2}{last2} shall be -sorted with respect to \tcode{comp} and -\tcode{proj1} or \tcode{proj2}, respectively. +The ranges \range{first1}{last1} and \range{first2}{last2} shall be sorted +with respect to \tcode{comp} and \tcode{proj1} or \tcode{proj2}, respectively. The resulting range shall not overlap with either of the original ranges. \pnum @@ -7299,25 +7163,30 @@ Let \tcode{result_last} be the end of the constructed range. Returns \begin{itemize} -\item \tcode{result_last} for the overloads in namespace \tcode{std}, or -\item \tcode{\{last1, last2, result_last\}} for the overloads in - namespace \tcode{ranges}. +\item + \tcode{result_last} + for the overloads in namespace \tcode{std}, or +\item + \tcode{\{last1, last2, result_last\}} + for the overloads in namespace \tcode{ranges}. \end{itemize} \pnum \complexity -At most -\tcode{2 * ((last1 - first1) + (last2 - first2)) - 1} +At most \tcode{2 * ((last1 - first1) + (last2 - first2)) - 1} comparisons and applications of each projection. \pnum \remarks Stable\iref{algorithm.stable}. -If \range{first1}{last1} contains $m$ elements that are equivalent to -each other and \range{first2}{last2} contains $n$ elements that are equivalent -to them, then all $m$ elements from the first range are copied to the output -range, in order, and then the final $\max(n - m, 0)$ elements from the second range are -copied to the output range, in order. +If \range{first1}{last1} contains $m$ elements +that are equivalent to each other and +\range{first2}{last2} contains $n$ elements +that are equivalent to them, +then all $m$ elements from the first range +are copied to the output range, in order, and +then the final $\max(n - m, 0)$ elements from the second range +are copied to the output range, in order. \end{itemdescr} \rSec3[set.intersection]{\tcode{set_intersection}} @@ -7377,9 +7246,8 @@ \pnum \requires -The ranges \range{first1}{last1} and \range{first2}{last2} shall be -sorted with respect to \tcode{comp} and -\tcode{proj1} or \tcode{proj2}, respectively. +The ranges \range{first1}{last1} and \range{first2}{last2} shall be sorted +with respect to \tcode{comp} and \tcode{proj1} or \tcode{proj2}, respectively. The resulting range shall not overlap with either of the original ranges. \pnum @@ -7392,24 +7260,28 @@ Let \tcode{result_last} be the end of the constructed range. Returns \begin{itemize} -\item \tcode{result_last} for the overloads in namespace \tcode{std}, or -\item \tcode{\{last1, last2, result_last\}} for the overloads in - namespace \tcode{ranges}. +\item + \tcode{result_last} + for the overloads in namespace \tcode{std}, or +\item + \tcode{\{last1, last2, result_last\}} + for the overloads in namespace \tcode{ranges}. \end{itemize} \pnum \complexity -At most -\tcode{2 * ((last1 - first1) + (last2 - first2)) - 1} +At most \tcode{2 * ((last1 - first1) + (last2 - first2)) - 1} comparisons and applications of each projection. \pnum \remarks Stable\iref{algorithm.stable}. -If \range{first1}{last1} contains $m$ elements that are equivalent to -each other and \range{first2}{last2} contains $n$ elements that are equivalent -to them, the first $\min(m, n)$ elements are copied from the first range -to the output range, in order. +If \range{first1}{last1} contains $m$ elements +that are equivalent to each other and +\range{first2}{last2} contains $n$ elements +that are equivalent to them, +the first $\min(m, n)$ elements +are copied from the first range to the output range, in order. \end{itemdescr} \rSec3[set.difference]{\tcode{set_difference}} @@ -7469,19 +7341,15 @@ \pnum \requires -The ranges \range{first1}{last1} and \range{first2}{last2} shall be -sorted with respect to \tcode{comp} and -\tcode{proj1} or \tcode{proj2}, respectively. +The ranges \range{first1}{last1} and \range{first2}{last2} shall be sorted +with respect to \tcode{comp} and \tcode{proj1} or \tcode{proj2}, respectively. The resulting range shall not overlap with either of the original ranges. \pnum \effects -Copies the elements of the range -\range{first1}{last1} -which are not present in the range -\range{first2}{last2} -to the range beginning at -\tcode{result}. +Copies the elements of the range \range{first1}{last1} +which are not present in the range \range{first2}{last2} +to the range beginning at \tcode{result}. The elements in the constructed range are sorted. \pnum @@ -7489,29 +7357,26 @@ Let \tcode{result_last} be the end of the constructed range. Returns \begin{itemize} -\item \tcode{result_last} for the overloads in namespace \tcode{std}, or -\item \tcode{\{last1, result_last\}} for the overloads in - namespace \tcode{ranges}. +\item + \tcode{result_last} + for the overloads in namespace \tcode{std}, or +\item + \tcode{\{last1, result_last\}} + for the overloads in namespace \tcode{ranges}. \end{itemize} \pnum \complexity -At most -\tcode{2 * ((last1 - first1) + (last2 - first2)) - 1} +At most \tcode{2 * ((last1 - first1) + (last2 - first2)) - 1} comparisons and applications of each projection. \pnum \remarks -If -\range{first1}{last1} -contains $m$ -elements that are equivalent to each other and -\range{first2}{last2} -contains $n$ -elements that are equivalent to them, the last -$\max(m - n, 0)$ -elements from -\range{first1}{last1} +If \range{first1}{last1} contains $m$ elements +that are equivalent to each other and +\range{first2}{last2} contains $n$ elements +that are equivalent to them, +the last $\max(m - n, 0)$ elements from \range{first1}{last1} is copied to the output range, in order. \end{itemdescr} @@ -7574,23 +7439,17 @@ \pnum \requires The resulting range shall not overlap with either of the original ranges. -The ranges \range{first1}{last1} and \range{first2}{last2} shall be -sorted with respect to \tcode{comp} and -\tcode{proj1} or \tcode{proj2}, respectively. +The ranges \range{first1}{last1} and \range{first2}{last2} shall be sorted +with respect to \tcode{comp} and \tcode{proj1} or \tcode{proj2}, respectively. The resulting range shall not overlap with either of the original ranges. \pnum \effects -Copies the elements of the range -\range{first1}{last1} -that are not present in the range -\range{first2}{last2}, -and the elements of the range -\range{first2}{last2} -that are not present in the range -\range{first1}{last1} -to the range beginning at -\tcode{result}. +Copies the elements of the range \range{first1}{last1} +that are not present in the range \range{first2}{last2}, +and the elements of the range \range{first2}{last2} +that are not present in the range \range{first1}{last1} +to the range beginning at \tcode{result}. The elements in the constructed range are sorted. \pnum @@ -7598,25 +7457,29 @@ Let \tcode{result_last} be the end of the constructed range. Returns \begin{itemize} -\item \tcode{result_last} for the overloads in namespace \tcode{std}, or -\item \tcode{\{last1, last2, result_last\}} for the overloads in - namespace \tcode{ranges}. +\item + \tcode{result_last} + for the overloads in namespace \tcode{std}, or +\item + \tcode{\{last1, last2, result_last\}} + for the overloads in namespace \tcode{ranges}. \end{itemize} \pnum \complexity -At most -\tcode{2 * ((last1 - first1) + (last2 - first2)) - 1} +At most \tcode{2 * ((last1 - first1) + (last2 - first2)) - 1} comparisons and applications of each projection. \pnum \remarks Stable\iref{algorithm.stable}. -If \range{first1}{last1} contains $m$ elements that are equivalent to each other and -\range{first2}{last2} contains $n$ elements that are equivalent to them, then -$|m - n|$ of those elements shall be copied to the output range: the last -$m - n$ of these elements from \range{first1}{last1} if $m > n$, and the last -$n - m$ of these elements from \range{first2}{last2} if $m < n$. +If \range{first1}{last1} contains $m$ elements +that are equivalent to each other and +\range{first2}{last2} contains $n$ elements +that are equivalent to them, +then $|m - n|$ of those elements shall be copied to the output range: +the last $m - n$ of these elements from \range{first1}{last1} if $m > n$, and +the last $n - m$ of these elements from \range{first2}{last2} if $m < n$. In either case, the elements are copied in order. \end{itemdescr} @@ -7630,27 +7493,22 @@ if its elements are organized such that: \begin{itemize} -\item With \tcode{$N$ = b - a}, for all $i$, $0 < i < N$, -\tcode{bool(invoke(comp, invoke(proj, a[$\left \lfloor{\frac{i - 1}{2}}\right \rfloor$]), invoke(\brk{}proj, a[$i$])))} -is \tcode{false}. -\item \tcode{*a} -may be removed by -\tcode{pop_heap}, -or a new element added by -\tcode{push_heap}, -in -\bigoh{\log N} -time. +\item + With \tcode{$N$ = b - a}, for all $i$, $0 < i < N$, + \tcode{bool(invoke(comp, invoke(proj, a[$\left \lfloor{\frac{i - 1}{2}}\right \rfloor$]), invoke(\brk{}proj, a[$i$])))} + is \tcode{false}. +\item + \tcode{*a} may be removed by \tcode{pop_heap}, or + a new element added by \tcode{push_heap}, + in \bigoh{\log N} time. \end{itemize} \pnum These properties make heaps useful as priority queues. \pnum -\tcode{make_heap} -converts a range into a heap and -\tcode{sort_heap} -turns a heap into a sorted sequence. +\tcode{make_heap} converts a range into a heap and +\tcode{sort_heap} turns a heap into a sorted sequence. \rSec3[push.heap]{\tcode{push_heap}} @@ -7684,22 +7542,17 @@ \pnum \requires -The range -\range{first}{last - 1} +The range \range{first}{last - 1} shall be a valid heap with respect to \tcode{comp} and \tcode{proj}. For the overloads in namespace \tcode{std}, the type of \tcode{*first} shall meet -the \oldconcept{MoveConstructible} requirements -(\tref{moveconstructible}) and the -\oldconcept{MoveAssignable} requirements -(\tref{moveassignable}). +the \oldconcept{MoveConstructible} requirements (\tref{moveconstructible}) and +the \oldconcept{MoveAssignable} requirements (\tref{moveassignable}). \pnum \effects -Places the value in the location -\tcode{last - 1} -into the resulting heap -\range{first}{last}. +Places the value in the location \tcode{last - 1} +into the resulting heap \range{first}{last}. \pnum \returns @@ -7707,9 +7560,7 @@ \pnum \complexity -At most -$\log(\tcode{last - first})$ -comparisons and twice as many projections. +At most $\log(\tcode{last - first})$ comparisons and twice as many projections. \end{itemdescr} \rSec3[pop.heap]{\tcode{pop_heap}} @@ -7744,14 +7595,13 @@ \pnum \requires -The range -\range{first}{last} +The range \range{first}{last} shall be a valid non-empty heap with respect to \tcode{comp} and \tcode{proj}. For the overloads in namespace \tcode{std}, -\tcode{RandomAccessIterator} shall meet the -\oldconcept{ValueSwappable} requirements\iref{swappable.requirements} and -the type of \tcode{*first} shall met the -\oldconcept{MoveConstructible} (\tref{moveconstructible}) and +\tcode{RandomAccessIterator} shall meet +the \oldconcept{ValueSwappable} requirements\iref{swappable.requirements} and +the type of \tcode{*first} shall meet +the \oldconcept{MoveConstructible} (\tref{moveconstructible}) and \oldconcept{MoveAssignable} (\tref{moveassignable}) requirements. \pnum @@ -7769,9 +7619,8 @@ \pnum \complexity -At most -$2 \log(\tcode{last - first})$ -comparisons and twice as many projections. +At most $2 \log(\tcode{last - first})$ comparisons and +twice as many projections. \end{itemdescr} \rSec3[make.heap]{\tcode{make_heap}} @@ -7808,15 +7657,13 @@ \requires For the overloads in namespace \tcode{std}, the type of \tcode{*first} shall meet -the \oldconcept{Move\-Constructible} -(\tref{moveconstructible}) and -\oldconcept{MoveAssignable} -(\tref{moveassignable}) requirements. +the \oldconcept{Move\-Constructible} (\tref{moveconstructible}) and +\oldconcept{MoveAssignable} (\tref{moveassignable}) requirements. \pnum \effects -Constructs a heap with respect to \tcode{comp} and \tcode{proj} out of the range -\range{first}{last}. +Constructs a heap with respect to \tcode{comp} and \tcode{proj} +out of the range \range{first}{last}. \pnum \returns @@ -7824,9 +7671,7 @@ \pnum \complexity -At most -$3(\tcode{last - first})$ -comparisons and twice as many projections. +At most $3(\tcode{last - first})$ comparisons and twice as many projections. \end{itemdescr} \rSec3[sort.heap]{\tcode{sort_heap}} @@ -7864,16 +7709,16 @@ The range \range{first}{last} shall be a valid heap with respect to \tcode{comp} and \tcode{proj}. For the overloads in namespace \tcode{std}, -\tcode{RandomAccessIterator} shall meet the -\oldconcept{ValueSwappable} requirements\iref{swappable.requirements} and -the type of \tcode{*first} shall meet the -\oldconcept{MoveConst\-ruct\-ible} (\tref{moveconstructible}) and +\tcode{RandomAccessIterator} shall meet +the \oldconcept{ValueSwappable} requirements\iref{swappable.requirements} and +the type of \tcode{*first} shall meet +the \oldconcept{MoveConst\-ruct\-ible} (\tref{moveconstructible}) and \oldconcept{MoveAssignable} (\tref{moveassignable}) requirements. \pnum \effects -Sorts elements in the heap -\range{first}{last} with respect to \tcode{comp} and \tcode{proj}. +Sorts elements in the heap \range{first}{last} +with respect to \tcode{comp} and \tcode{proj}. \pnum \returns @@ -7881,9 +7726,8 @@ \pnum \complexity -At most $2N \log N$ -comparisons, where -$N = \tcode{last - first}$, and twice as many projections. +At most $2N \log N$ comparisons, where $N = \tcode{last - first}$, and +twice as many projections. \end{itemdescr} \rSec3[is.heap]{\tcode{is_heap}} @@ -7916,7 +7760,6 @@ \end{codeblock} \end{itemdescr} - \indexlibrary{\idxcode{is_heap}}% \begin{itemdecl} template @@ -7961,7 +7804,8 @@ \begin{itemdescr} \pnum -\effects Equivalent to: +\effects +Equivalent to: \tcode{return ranges::is_heap_until(first, last, comp, proj) == last;} \end{itemdescr} @@ -8004,11 +7848,13 @@ \pnum \returns -The last iterator \tcode{i} in \crange{first}{last} for which the -range \range{first}{i} is a heap with respect to \tcode{comp} and \tcode{proj}. +The last iterator \tcode{i} in \crange{first}{last} +for which the range \range{first}{i} +is a heap with respect to \tcode{comp} and \tcode{proj}. \pnum -\complexity Linear. +\complexity +Linear. \end{itemdescr} @@ -8016,7 +7862,8 @@ \indexlibrary{\idxcode{min}}% \begin{itemdecl} -template constexpr const T& min(const T& a, const T& b); +template + constexpr const T& min(const T& a, const T& b); template constexpr const T& min(const T& a, const T& b, Compare comp); @@ -8040,8 +7887,8 @@ \pnum \remarks Returns the first argument when the arguments are equivalent. -An invocation may explicitly specify an argument -for the template parameter \tcode{T} +An invocation may explicitly specify +an argument for the template parameter \tcode{T} of the overloads in namespace \tcode{std}. \pnum @@ -8077,12 +7924,15 @@ For the first form, type \tcode{T} shall be \oldconcept{LessThanComparable}. \pnum -\returns The smallest value in the input range. +\returns +The smallest value in the input range. \pnum -\remarks Returns a copy of the leftmost element when several elements are equivalent to the smallest. -An invocation may explicitly specify an argument -for the template parameter \tcode{T} +\remarks +Returns a copy of the leftmost element +when several elements are equivalent to the smallest. +An invocation may explicitly specify +an argument for the template parameter \tcode{T} of the overloads in namespace \tcode{std}. \pnum @@ -8093,7 +7943,8 @@ \indexlibrary{\idxcode{max}}% \begin{itemdecl} -template constexpr const T& max(const T& a, const T& b); +template + constexpr const T& max(const T& a, const T& b); template constexpr const T& max(const T& a, const T& b, Compare comp); @@ -8117,8 +7968,8 @@ \pnum \remarks Returns the first argument when the arguments are equivalent. -An invocation may explicitly specify an argument -for the template parameter \tcode{T} +An invocation may explicitly specify +an argument for the template parameter \tcode{T} of the overloads in namespace \tcode{std}. \pnum @@ -8154,12 +8005,15 @@ For the first form, type \tcode{T} shall be \oldconcept{LessThanComparable}. \pnum -\returns The largest value in the input range. +\returns +The largest value in the input range. \pnum -\remarks Returns a copy of the leftmost element when several elements are equivalent to the largest. -An invocation may explicitly specify an argument -for the template parameter \tcode{T} +\remarks +Returns a copy of the leftmost element +when several elements are equivalent to the largest. +An invocation may explicitly specify +an argument for the template parameter \tcode{T} of the overloads in namespace \tcode{std}. \pnum @@ -8170,7 +8024,8 @@ \indexlibrary{\idxcode{minmax}}% \begin{itemdecl} -template constexpr pair minmax(const T& a, const T& b); +template + constexpr pair minmax(const T& a, const T& b); template constexpr pair minmax(const T& a, const T& b, Compare comp); @@ -8191,13 +8046,13 @@ \pnum \returns -\tcode{\{(b, a)\}} if \tcode{b} is smaller than \tcode{a}, and +\tcode{\{b, a\}} if \tcode{b} is smaller than \tcode{a}, and \tcode{\{a, b\}} otherwise. \pnum \remarks -An invocation may explicitly specify an argument -for the template parameter \tcode{T} +An invocation may explicitly specify +an argument for the template parameter \tcode{T} of the overloads in namespace \tcode{std}. \pnum @@ -8235,20 +8090,22 @@ \pnum \returns -Let \tcode{X} be the return type. Returns -\tcode{X{x, y}}, where \tcode{x} is a copy of the leftmost element with -the smallest and \tcode{y} a copy of the rightmost element with the -largest value in the input range. +Let \tcode{X} be the return type. +Returns \tcode{X{x, y}}, +where \tcode{x} is a copy of the leftmost element with the smallest and +\tcode{y} a copy of the rightmost element with the largest value +in the input range. \pnum \remarks -An invocation may explicitly specify an argument -for the template parameter \tcode{T} +An invocation may explicitly specify +an argument for the template parameter \tcode{T} of the overloads in namespace \tcode{std}. \pnum \complexity -At most $(3/2)\tcode{ranges::distance(r)}$ applications of the corresponding predicate +At most $(3/2)\tcode{ranges::distance(r)}$ applications +of the corresponding predicate and twice as many applications of the projection, if any. \end{itemdescr} @@ -8288,28 +8145,18 @@ \pnum \returns -The first iterator -\tcode{i} -in the range -\range{first}{last} -such that for every iterator -\tcode{j} -in the range -\range{first}{last}, +The first iterator \tcode{i} in the range \range{first}{last} +such that for every iterator \tcode{j} in the range \range{first}{last}, \begin{codeblock} bool(invoke(comp, invoke(proj, *j), invoke(proj, *i))) \end{codeblock} is \tcode{false}. -Returns -\tcode{last} -if -\tcode{first == last}. +Returns \tcode{last} if \tcode{first == last}. \pnum \complexity -Exactly -$\max(\tcode{last - first - 1}, 0)$ -comparisons and twice as many projections. +Exactly $\max(\tcode{last - first - 1}, 0)$ comparisons and +twice as many projections. \end{itemdescr} \indexlibrary{\idxcode{max_element}}% @@ -8347,28 +8194,18 @@ \pnum \returns -The first iterator -\tcode{i} -in the range -\range{first}{last} -such that for every iterator -\tcode{j} -in the range -\range{first}{last}, +The first iterator \tcode{i} in the range \range{first}{last} +such that for every iterator \tcode{j} in the range \range{first}{last}, \begin{codeblock} bool(invoke(comp, invoke(proj, *i), invoke(proj, *j))) \end{codeblock} is \tcode{false}. -Returns -\tcode{last} -if -\tcode{first == last}. +Returns \tcode{last} if \tcode{first == last}. \pnum \complexity -Exactly -$\max(\tcode{last - first - 1}, 0)$ -comparisons and twice as many projections. +Exactly $\max(\tcode{last - first - 1}, 0)$ comparisons and +twice as many projections. \end{itemdescr} \indexlibrary{\idxcode{minmax_element}}% @@ -8415,9 +8252,8 @@ \pnum \complexity Let $N$ be \tcode{last - first}. -At most -$\max(\bigl\lfloor{\frac{3}{2}} (N-1)\bigr\rfloor, 0)$ -comparisons and twice as many applications of the projection, if any. +At most $\max(\bigl\lfloor{\frac{3}{2}} (N-1)\bigr\rfloor, 0)$ comparisons and +twice as many applications of the projection, if any. \end{itemdescr} \rSec2[alg.clamp]{Bounded value} @@ -8501,28 +8337,26 @@ \begin{itemdescr} \pnum \returns -\tcode{true} -if and only if the sequence of elements defined by the range -\range{first1}{last1} -is lexicographically less than the sequence of elements defined by the range -\range{first2}{last2}. +\tcode{true} if and only if +the sequence of elements defined by the range \range{first1}{last1} +is lexicographically less than +the sequence of elements defined by the range \range{first2}{last2}. \pnum \complexity -At most -$2 \min(\tcode{last1 - first1}, \ \tcode{last2 - first2})$ -applications of the corresponding comparison and each projection, if any. +At most $2 \min(\tcode{last1 - first1}, \ \tcode{last2 - first2})$ applications +of the corresponding comparison and each projection, if any. \pnum \remarks -If two sequences have the same number of elements and their corresponding -elements (if any) are equivalent, then neither sequence is lexicographically -less than the other. -If one sequence is a proper prefix of the other, then the shorter sequence is -lexicographically less than the longer sequence. -Otherwise, the lexicographical comparison of the sequences yields the same -result as the comparison of the first corresponding pair of -elements that are not equivalent. +If two sequences have the same number of elements and +their corresponding elements (if any) are equivalent, +then neither sequence is lexicographically less than the other. +If one sequence is a proper prefix of the other, +then the shorter sequence is lexicographically less than the longer sequence. +Otherwise, the lexicographical comparison of the sequences yields +the same result as the comparison +of the first corresponding pair of elements that are not equivalent. \pnum \begin{example} @@ -8538,10 +8372,10 @@ \end{example} \pnum -\begin{note} An empty sequence is lexicographically less than any non-empty sequence, but -not less than any empty sequence. +\begin{note} +An empty sequence is lexicographically less than any non-empty sequence, +but not less than any empty sequence. \end{note} - \end{itemdescr} \rSec2[alg.3way]{Three-way comparison algorithms} @@ -8554,27 +8388,26 @@ \begin{itemdescr} \pnum \effects -Compares two values and produces a result of the strongest applicable -comparison category type: +Compares two values and produces a result +of the strongest applicable comparison category type: \begin{itemize} \item -Returns \tcode{a <=> b} if that expression is well-formed. + Returns \tcode{a <=> b} if that expression is well-formed. \item -Otherwise, if the expressions \tcode{a == b} and \tcode{a < b} -are each well-formed and convertible to \tcode{bool}, -returns \tcode{strong_ordering::equal} -when \tcode{a == b} is \tcode{true}, -otherwise returns \tcode{strong_ordering::less} -when \tcode{a < b} is \tcode{true}, -and otherwise returns \tcode{strong_ordering::greater}. + Otherwise, if the expressions \tcode{a == b} and \tcode{a < b} + are each well-formed and convertible to \tcode{bool}, + returns \tcode{strong_ordering::equal} + when \tcode{a == b} is \tcode{true}, + otherwise returns \tcode{strong_ordering::less} + when \tcode{a < b} is \tcode{true}, + and otherwise returns \tcode{strong_ordering::greater}. \item -Otherwise, if the expression \tcode{a == b} -is well-formed and convertible to \tcode{bool}, -returns \tcode{strong_equality::equal} -when \tcode{a == b} is \tcode{true}, -and otherwise returns \tcode{strong_equality::nonequal}. + Otherwise, if the expression \tcode{a == b} + is well-formed and convertible to \tcode{bool}, + returns \tcode{strong_equality::equal} when \tcode{a == b} is \tcode{true}, + and otherwise returns \tcode{strong_equality::nonequal}. \item -Otherwise, the function is defined as deleted. + Otherwise, the function is defined as deleted. \end{itemize} \end{itemdescr} @@ -8597,8 +8430,7 @@ \pnum \effects Lexicographically compares two ranges and -produces a result of the strongest applicable -comparison category type. +produces a result of the strongest applicable comparison category type. Equivalent to: \begin{codeblock} for ( ; b1 != e1 && b2 != e2; void(++b1), void(++b2) ) @@ -8665,16 +8497,15 @@ \pnum \requires For the overloads in namespace \tcode{std}, -\tcode{BidirectionalIterator} shall meet the -\oldconcept{Value\-Swappable} requirements\iref{swappable.requirements}. +\tcode{BidirectionalIterator} shall meet +the \oldconcept{Value\-Swappable} requirements\iref{swappable.requirements}. \pnum \effects -Takes a sequence defined by the range -\range{first}{last} +Takes a sequence defined by the range \range{first}{last} and transforms it into the next permutation. -The next permutation is found by assuming that the set of all permutations is -lexicographically sorted with respect to \tcode{comp} and \tcode{proj}. +The next permutation is found by assuming that the set of all permutations +is lexicographically sorted with respect to \tcode{comp} and \tcode{proj}. If no such permutation exists, transforms the sequence into the first permutation; that is, the ascendingly-sorted one. @@ -8685,9 +8516,7 @@ \pnum \complexity -At most -\tcode{(last - first) / 2} -swaps. +At most \tcode{(last - first) / 2} swaps. \end{itemdescr} \indexlibrary{\idxcode{prev_permutation}}% @@ -8723,16 +8552,15 @@ \pnum \requires For the overloads in namespace \tcode{std}, -\tcode{BidirectionalIterator} shall meet the -\oldconcept{Value\-Swappable} requirements\iref{swappable.requirements}. +\tcode{BidirectionalIterator} shall meet +the \oldconcept{Value\-Swappable} requirements\iref{swappable.requirements}. \pnum \effects -Takes a sequence defined by the range -\range{first}{last} +Takes a sequence defined by the range \range{first}{last} and transforms it into the previous permutation. -The previous permutation is found by assuming that the set of all permutations is -lexicographically sorted with respect to \tcode{comp} and \tcode{proj}. +The previous permutation is found by assuming that the set of all permutations +is lexicographically sorted with respect to \tcode{comp} and \tcode{proj}. If no such permutation exists, transforms the sequence into the last permutation; that is, the descendingly-sorted one. @@ -8743,9 +8571,7 @@ \pnum \complexity -At most -\tcode{(last - first) / 2} -swaps. +At most \tcode{(last - first) / 2} swaps. \end{itemdescr} \rSec1[numeric.ops.overview]{Header \tcode{} synopsis} @@ -8981,15 +8807,16 @@ \pnum \begin{note} -The use of closed ranges as well as semi-open ranges to specify requirements -throughout this subclause is intentional. +The use of closed ranges as well as semi-open ranges +to specify requirements throughout this subclause is intentional. \end{note} \rSec2[numerics.defns]{Definitions} \indexlibrary{generalized_noncommutative_sum@\tcode{\placeholder{GENERALIZED_NONCOMMUTATIVE_SUM}}}% \pnum -Define \tcode{\placeholdernc{GENERALIZED_NONCOMMUTATIVE_SUM}(op, a1, ..., aN)} as follows: +Define \tcode{\placeholdernc{GENERALIZED_NONCOMMUTATIVE_SUM}(op, a1, ..., aN)} +as follows: \begin{itemize} \item \tcode{a1} when \tcode{N} is \tcode{1}, otherwise @@ -9021,30 +8848,26 @@ \begin{itemdescr} \pnum \requires -\tcode{T} shall satisfy the \oldconcept{CopyConstructible} (\tref{copyconstructible}) +\tcode{T} shall satisfy +the \oldconcept{CopyConstructible} (\tref{copyconstructible}) and \oldconcept{CopyAssignable} (\tref{copyassignable}) requirements. -In the range -\crange{first}{last}, -\tcode{binary_op} -shall neither modify elements nor invalidate iterators or subranges.\footnote{The use of fully closed ranges is intentional.} +In the range \crange{first}{last}, +\tcode{binary_op} shall neither modify elements +nor invalidate iterators or subranges.% +\footnote{The use of fully closed ranges is intentional.} \pnum \effects -Computes its result by initializing the accumulator -\tcode{acc} -with the initial value -\tcode{init} +Computes its result by +initializing the accumulator \tcode{acc} with the initial value \tcode{init} and then modifies it with -\tcode{acc = std::move(acc) + *i} -or +\tcode{acc = std::move(acc) + *i} or \tcode{acc = binary_op(std::move(acc), *i)} -for every iterator -\tcode{i} -in the range \range{first}{last} -in order.\footnote{\tcode{accumulate} -is similar to the APL reduction operator and Common Lisp reduce function, but -it avoids the difficulty of defining the result of reduction on an empty -sequence by always requiring an initial value.} +for every iterator \tcode{i} in the range \range{first}{last} in order.% +\footnote{\tcode{accumulate} is similar +to the APL reduction operator and Common Lisp reduce function, +but it avoids the difficulty of defining the result of reduction +on an empty sequence by always requiring an initial value.} \end{itemdescr} \rSec2[reduce]{Reduce} @@ -9128,17 +8951,21 @@ \pnum \requires \begin{itemize} -\item \tcode{T} shall be \oldconcept{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}. -\item \tcode{binary_op} shall neither invalidate iterators or subranges, nor modify -elements in the range \crange{first}{last}. +\item + \tcode{T} shall be \oldconcept{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}. +\item + \tcode{binary_op} shall neither invalidate iterators or subranges, + nor modify elements in the range \crange{first}{last}. \end{itemize} \pnum \returns -\tcode{\placeholdernc{GENERALIZED_SUM}(binary_op, init, *i, ...)} for every \tcode{i} in \range{first}{last}. +\tcode{\placeholdernc{GENERALIZED_SUM}(binary_op, init, *i, ...)} +for every \tcode{i} in \range{first}{last}. \pnum \complexity @@ -9147,9 +8974,10 @@ \pnum \begin{note} The difference between \tcode{reduce} and \tcode{accumulate} is that -\tcode{reduce} applies \tcode{binary_op} in an unspecified order, which yields -a nondeterministic result for non-associative or non-commutative -\tcode{binary_op} such as floating-point addition. +\tcode{reduce} applies \tcode{binary_op} in an unspecified order, +which yields a nondeterministic result +for non-associative or non-commutative \tcode{binary_op} +such as floating-point addition. \end{note} \end{itemdescr} @@ -9171,34 +8999,24 @@ \begin{itemdescr} \pnum \requires -\tcode{T} shall satisfy the \oldconcept{CopyConstructible} (\tref{copyconstructible}) +\tcode{T} shall satisfy +the \oldconcept{CopyConstructible} (\tref{copyconstructible}) and \oldconcept{CopyAssignable} (\tref{copyassignable}) requirements. -In the ranges -\crange{first1}{last1} -and +In the ranges \crange{first1}{last1} and \crange{first2}{first2 + (last1 - first1)} -\tcode{binary_op1} -and -\tcode{binary_op2} -shall neither modify elements nor invalidate iterators or subranges.\footnote{The use of fully closed ranges is intentional.} +\tcode{binary_op1} and \tcode{binary_op2} +shall neither modify elements nor invalidate iterators or subranges.% +\footnote{The use of fully closed ranges is intentional.} \pnum \effects -Computes its result by initializing the accumulator -\tcode{acc} -with the initial value -\tcode{init} +Computes its result by +initializing the accumulator \tcode{acc} with the initial value \tcode{init} and then modifying it with -\tcode{acc = std::move(acc) + (*i1) * (*i2)} -or +\tcode{acc = std::move(acc) + (*i1) * (*i2)} or \tcode{acc = binary_op1(std::move(acc), binary_op2(*i1, *i2))} -for every iterator -\tcode{i1} -in the range \range{first1}{last1} -and iterator -\tcode{i2} -in the range -\range{first2}{first2 + (last1 - first1)} +for every iterator \tcode{i1} in the range \range{first1}{last1} +and iterator \tcode{i2} in the range \range{first2}{first2 + (last1 - first1)} in order. \end{itemdescr} @@ -9213,7 +9031,8 @@ \begin{itemdescr} \pnum -\effects Equivalent to: +\effects +Equivalent to: \begin{codeblock} return transform_reduce(first1, last1, first2, init, plus<>(), multiplies<>()); \end{codeblock} @@ -9231,7 +9050,8 @@ \begin{itemdescr} \pnum -\effects Equivalent to: +\effects +Equivalent to: \begin{codeblock} return transform_reduce(std::forward(exec), first1, last1, first2, init, plus<>(), multiplies<>()); @@ -9262,18 +9082,21 @@ \pnum \requires \begin{itemize} -\item \tcode{T} shall be \oldconcept{MoveConstructible} (\tref{moveconstructible}). -\item All of -\begin{itemize} -\item \tcode{binary_op1(init, init)}, -\item \tcode{binary_op1(init, binary_op2(*first1, *first2))}, -\item \tcode{binary_op1(binary_op2(*first1, *first2), init)}, and -\item \tcode{binary_op1(binary_op2(*first1, *first2), binary_op2(*first1, *first2))} -\end{itemize} -shall be convertible to \tcode{T}. -\item Neither \tcode{binary_op1} nor \tcode{binary_op2} shall invalidate -subranges, or modify elements in the ranges \crange{first1}{last1} and -\crange{first2}{first2 + (last1 - first1)}. +\item + \tcode{T} shall be \oldconcept{MoveConstructible} (\tref{moveconstructible}). +\item + All of + \begin{itemize} + \item \tcode{binary_op1(init, init)}, + \item \tcode{binary_op1(init, binary_op2(*first1, *first2))}, + \item \tcode{binary_op1(binary_op2(*first1, *first2), init)}, and + \item \tcode{binary_op1(binary_op2(*first1, *first2), binary_op2(*first1, *first2))} + \end{itemize} + shall be convertible to \tcode{T}. +\item + Neither \tcode{binary_op1} nor \tcode{binary_op2} + shall invalidate subranges, or modify elements in the ranges + \crange{first1}{last1} and \crange{first2}{first2 + (last1 - first1)}. \end{itemize} \pnum @@ -9284,8 +9107,9 @@ for every iterator \tcode{i} in \range{first1}{last1}. \pnum -\complexity \bigoh{\tcode{last1 - first1}} applications each of \tcode{binary_op1} and -\tcode{binary_op2}. +\complexity +\bigoh{\tcode{last1 - first1}} applications each +of \tcode{binary_op1} and \tcode{binary_op2}. \end{itemdescr} \indexlibrary{\idxcode{transform_reduce}}% @@ -9306,17 +9130,20 @@ \pnum \requires \begin{itemize} -\item \tcode{T} shall be \oldconcept{MoveConstructible} (\tref{moveconstructible}). -\item All of -\begin{itemize} -\item \tcode{binary_op(init, init)}, -\item \tcode{binary_op(init, unary_op(*first))}, -\item \tcode{binary_op(unary_op(*first), init)}, and -\item \tcode{binary_op(unary_op(*first), unary_op(*first))} -\end{itemize} -shall be convertible to \tcode{T}. -\item Neither \tcode{unary_op} nor \tcode{binary_op} shall invalidate subranges, -or modify elements in the range \crange{first}{last}. +\item + \tcode{T} shall be \oldconcept{MoveConstructible} (\tref{moveconstructible}). +\item + All of + \begin{itemize} + \item \tcode{binary_op(init, init)}, + \item \tcode{binary_op(init, unary_op(*first))}, + \item \tcode{binary_op(unary_op(*first), init)}, and + \item \tcode{binary_op(unary_op(*first), unary_op(*first))} + \end{itemize} + shall be convertible to \tcode{T}. +\item + Neither \tcode{unary_op} nor \tcode{binary_op} shall invalidate subranges, + or modify elements in the range \crange{first}{last}. \end{itemize} \pnum @@ -9354,24 +9181,28 @@ \begin{itemdescr} \pnum \requires -\tcode{InputIterator}'s value type shall be constructible from the type of \tcode{*first}. -The result of the expression \tcode{std::move(acc) + *i} or \tcode{binary_op(std::move(acc), *i)} shall be -implicitly convertible to \tcode{InputIterator}'s value type. \tcode{acc} -shall be writable\iref{iterator.requirements.general} to the \tcode{result} output iterator. -In the ranges -\crange{first}{last} -and -\crange{result}{result + (last - first)} -\tcode{binary_op} -shall neither modify elements nor invalidate iterators or subranges.\footnote{The use of fully closed ranges is intentional. -} +\tcode{InputIterator}'s value type shall be constructible +from the type of \tcode{*first}. +The result of the +expression \tcode{std::move(acc) + *i} or \tcode{binary_op(std::move(acc), *i)} +shall be implicitly convertible to \tcode{InputIterator}'s value type. +\tcode{acc} shall be writable\iref{iterator.requirements.general} to +the \tcode{result} output iterator. +In the ranges \crange{first}{last} and \crange{result}{result + (last - first)} +\tcode{binary_op} shall neither modify elements +nor invalidate iterators or subranges.% +\footnote{The use of fully closed ranges is intentional.} \pnum -\effects For a non-empty range, -the function creates an accumulator \tcode{acc} whose type is \tcode{InputIterator}'s -value type, initializes it with \tcode{*first}, -and assigns the result to \tcode{*result}. For every iterator \tcode{i} in \range{first + 1}{last} -in order, \tcode{acc} is then modified by \tcode{acc = std::move(acc) + *i} or \tcode{acc = binary_op(std::move(acc), *i)} +\effects +For a non-empty range, +the function creates an accumulator \tcode{acc} +whose type is \tcode{InputIterator}'s value type, +initializes it with \tcode{*first}, +and assigns the result to \tcode{*result}. +For every iterator \tcode{i} in \range{first + 1}{last} in order, +\tcode{acc} is then modified by +\tcode{acc = std::move(acc) + *i} or \tcode{acc = binary_op(std::move(acc), *i)} and the result is assigned to \tcode{*(result + (i - first))}. \pnum @@ -9380,16 +9211,11 @@ \pnum \complexity -Exactly -\tcode{(last - first) - 1} -applications of -the binary operation. +Exactly \tcode{(last - first) - 1} applications of the binary operation. \pnum \remarks -\tcode{result} -may be equal to -\tcode{first}. +\tcode{result} may be equal to \tcode{first}. \end{itemdescr} \rSec2[exclusive.scan]{Exclusive scan} @@ -9426,7 +9252,6 @@ \end{codeblock} \end{itemdescr} - \indexlibrary{\idxcode{exclusive_scan}}% \begin{itemdecl} template @@ -9443,11 +9268,18 @@ \pnum \requires \begin{itemize} -\item \tcode{T} shall be \oldconcept{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 -elements in the ranges \crange{first}{last} or \crange{result}{result + (last - first)}. +\item + \tcode{T} shall be \oldconcept{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 elements in + the ranges \crange{first}{last} or \crange{result}{result + (last - first)}. \end{itemize} \pnum @@ -9474,9 +9306,10 @@ \pnum \begin{note} The difference between \tcode{exclusive_scan} and \tcode{inclusive_scan} is -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. +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} @@ -9512,7 +9345,6 @@ \end{codeblock} \end{itemdescr} - \indexlibrary{\idxcode{inclusive_scan}}% \begin{itemdecl} template @@ -9538,18 +9370,23 @@ \pnum \requires \begin{itemize} -\item If \tcode{init} is provided, \tcode{T} shall be \oldconcept{MoveConstructible} -(\tref{moveconstructible}); otherwise, \tcode{ForwardIterator1}'s value -type shall be \oldconcept{MoveConstructible}. - -\item If \tcode{init} is provided, all of \tcode{binary_op(init, init)}, -\tcode{binary_op(init, *first)}, and \tcode{binary_op(*first, *first)} shall be -convertible to \tcode{T}; otherwise, \tcode{binary_op(*first, *first)} shall be -convertible to \tcode{ForwardIterator1}'s value type. - -\item \tcode{binary_op} shall neither invalidate iterators or subranges, nor -modify elements in the ranges \crange{first}{last} or -\crange{result}{result + (last - first)}. +\item + If \tcode{init} is provided, + \tcode{T} shall be \oldconcept{MoveConstructible} (\tref{moveconstructible}); + otherwise, \tcode{ForwardIterator1}'s value type + shall be \oldconcept{MoveConstructible}. +\item + If \tcode{init} is provided, all of + \tcode{binary_op(init, init)}, + \tcode{binary_op(init, *first)}, and + \tcode{binary_op(*first, *first)} + shall be convertible to \tcode{T}; + otherwise, \tcode{binary_op(*first, *first)} + shall be convertible to \tcode{ForwardIterator1}'s value type. +\item + \tcode{binary_op} shall neither invalidate iterators or subranges, + nor modify elements in + the ranges \crange{first}{last} or \crange{result}{result + (last - first)}. \end{itemize} \pnum @@ -9580,9 +9417,10 @@ \pnum \begin{note} The difference between \tcode{exclusive_scan} and \tcode{inclusive_scan} is -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. +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} @@ -9608,18 +9446,20 @@ \pnum \requires \begin{itemize} -\item \tcode{T} shall be \oldconcept{MoveConstructible} (\tref{moveconstructible}). -\item All of -\begin{itemize} -\item \tcode{binary_op(init, init)}, -\item \tcode{binary_op(init, unary_op(*first))}, and -\item \tcode{binary_op(unary_op(*first), unary_op(*first))} -\end{itemize} -shall be convertible to \tcode{T}. -\item Neither \tcode{unary_op} nor \tcode{binary_op} shall invalidate iterators or -subranges, or modify elements in the ranges -\crange{first}{last} or -\crange{result}{result + (last - first)}. +\item + \tcode{T} shall be \oldconcept{MoveConstructible} (\tref{moveconstructible}). +\item + All of + \begin{itemize} + \item \tcode{binary_op(init, init)}, + \item \tcode{binary_op(init, unary_op(*first))}, and + \item \tcode{binary_op(unary_op(*first), unary_op(*first))} + \end{itemize} + shall be convertible to \tcode{T}. +\item + Neither \tcode{unary_op} nor \tcode{binary_op} shall + invalidate iterators or subranges, or modify elements in + the ranges \crange{first}{last} or \crange{result}{result + (last - first)}. \end{itemize} \pnum @@ -9638,8 +9478,8 @@ \pnum \complexity -\bigoh{\tcode{last - first}} applications each of \tcode{unary_op} and -\tcode{binary_op}. +\bigoh{\tcode{last - first}} applications each +of \tcode{unary_op} and \tcode{binary_op}. \pnum \remarks @@ -9649,10 +9489,11 @@ \begin{note} The difference between \tcode{transform_exclusive_scan} and \tcode{transform_inclusive_scan} is that \tcode{transform_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{transform_exclusive_scan} -may be nondeterministic. \tcode{transform_exclusive_scan} does not apply -\tcode{unary_op} to \tcode{init}. +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{transform_exclusive_scan} may be nondeterministic. +\tcode{transform_exclusive_scan} +does not apply \tcode{unary_op} to \tcode{init}. \end{note} \end{itemdescr} @@ -9692,23 +9533,25 @@ \pnum \requires \begin{itemize} -\item If \tcode{init} is provided, \tcode{T} shall be \oldconcept{MoveConstructible} -(\tref{moveconstructible}); otherwise, \tcode{ForwardIterator1}'s value -type shall be \oldconcept{MoveConstructible}. - -\item If \tcode{init} is provided, all of -\begin{itemize} -\item \tcode{binary_op(init, init)}, -\item \tcode{binary_op(init, unary_op(*first))}, and -\item \tcode{binary_op(unary_op(*first), unary_op(*first))} -\end{itemize} -shall be convertible to -\tcode{T}; otherwise, \tcode{binary_op(unary_op(*first), unary_op(*first))} -shall be convertible to \tcode{ForwardIterator1}'s value type. - -\item Neither \tcode{unary_op} nor \tcode{binary_op} shall invalidate iterators -or subranges, nor modify elements in the ranges \crange{first}{last} or -\crange{result}{result + (last - first)}. +\item + If \tcode{init} is provided, \tcode{T} shall be + \oldconcept{MoveConstructible} (\tref{moveconstructible}); + otherwise, \tcode{ForwardIterator1}'s value type shall be + \oldconcept{MoveConstructible}. +\item + If \tcode{init} is provided, all of + \begin{itemize} + \item \tcode{binary_op(init, init)}, + \item \tcode{binary_op(init, unary_op(*first))}, and + \item \tcode{binary_op(unary_op(*first), unary_op(*first))} + \end{itemize} + shall be convertible to \tcode{T}; + otherwise, \tcode{binary_op(unary_op(*first), unary_op(*first))} + shall be convertible to \tcode{ForwardIterator1}'s value type. +\item + Neither \tcode{unary_op} nor \tcode{binary_op} shall + invalidate iterators or subranges, nor modify elements in + the ranges \crange{first}{last} or \crange{result}{result + (last - first)}. \end{itemize} \pnum @@ -9730,8 +9573,8 @@ \pnum \complexity -\bigoh{\tcode{last - first}} applications each of \tcode{unary_op} and -\tcode{binary_op}. +\bigoh{\tcode{last - first}} applications each +of \tcode{unary_op} and \tcode{binary_op}. \pnum \remarks @@ -9741,10 +9584,11 @@ \begin{note} The difference between \tcode{transform_exclusive_scan} and \tcode{transform_inclusive_scan} is that \tcode{transform_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{transform_inclusive_scan} -may be nondeterministic. \tcode{transform_inclusive_scan} does not apply -\tcode{unary_op} to \tcode{init}. +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{transform_inclusive_scan} may be nondeterministic. +\tcode{transform_inclusive_scan} does not +apply \tcode{unary_op} to \tcode{init}. \end{note} \end{itemdescr} @@ -9783,36 +9627,38 @@ \requires \begin{itemize} \item -For the overloads with no \tcode{ExecutionPolicy}, -\tcode{T} shall be \oldconcept{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{binary_op(val, std::move(acc))} shall be writable to the \tcode{result} output iterator. - + For the overloads with no \tcode{ExecutionPolicy}, + \tcode{T} shall be \oldconcept{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{binary_op(val, std::move(acc))} + shall be writable to the \tcode{result} output iterator. \item -For the overloads with an \tcode{ExecutionPolicy}, -the result of the expressions \tcode{binary_op(*first, *first)} and -\tcode{*first} shall be writable to \tcode{result}. - + For the overloads with an \tcode{ExecutionPolicy}, + the result of the expressions \tcode{binary_op(*first, *first)} and + \tcode{*first} shall be writable to \tcode{result}. \item -For all overloads, in the ranges -\crange{first}{last} -and -\crange{result}{result + (last - first)}, -\tcode{binary_op} -shall neither modify elements nor invalidate iterators or -subranges.\footnote{The use of fully closed ranges is intentional.} + For all overloads, in the ranges \crange{first}{last} + and \crange{result}{result + (last - first)}, + \tcode{binary_op} shall neither modify elements + nor invalidate iterators or subranges.% + \footnote{The use of fully closed ranges is intentional.} \end{itemize} \pnum -\effects For the overloads with no \tcode{ExecutionPolicy} and a non-empty range, +\effects +For the overloads with no \tcode{ExecutionPolicy} and a non-empty range, the function creates an accumulator \tcode{acc} of type \tcode{T}, initializes it with \tcode{*first}, -and assigns the result to \tcode{*result}. For every iterator \tcode{i} in \range{first + 1}{last} -in order, creates an object \tcode{val} whose type is \tcode{T}, initializes it -with \tcode{*i}, computes \tcode{binary_op(val, std::move(acc))}, assigns the result -to \tcode{*(result + (i - first))}, and move assigns from \tcode{val} to \tcode{acc}. +and assigns the result to \tcode{*result}. +For every iterator \tcode{i} in \range{first + 1}{last} in order, +creates an object \tcode{val} whose type is \tcode{T}, +initializes it with \tcode{*i}, +computes \tcode{binary_op(val, std::move(acc))}, +assigns the result to \tcode{*(result + (i - first))}, and +move assigns from \tcode{val} to \tcode{acc}. \pnum For the overloads with an \tcode{ExecutionPolicy} and a non-empty range, @@ -9826,16 +9672,15 @@ \pnum \complexity -Exactly -\tcode{(last - first) - 1} -applications of -the binary operation. +Exactly \tcode{(last - first) - 1} applications of the binary operation. \pnum \remarks -For the overloads with no \tcode{ExecutionPolicy}, \tcode{result} may be equal -to \tcode{first}. For the overloads with an \tcode{ExecutionPolicy}, the ranges -\range{first}{last} and \range{result}{result + (last - first)} shall not overlap. +For the overloads with no \tcode{ExecutionPolicy}, +\tcode{result} may be equal to \tcode{first}. +For the overloads with an \tcode{ExecutionPolicy}, +the ranges \range{first}{last} and \range{result}{result + (last - first)} +shall not overlap. \end{itemdescr} \rSec2[numeric.iota]{Iota} @@ -9848,17 +9693,21 @@ \begin{itemdescr} \pnum -\requires \tcode{T} shall be convertible to \tcode{ForwardIterator}'s value -type. The expression \tcode{++val}, where \tcode{val} has type \tcode{T}, shall -be well-formed. +\requires +\tcode{T} shall be convertible to \tcode{ForwardIterator}'s value type. +The expression \tcode{++val}, where \tcode{val} has type \tcode{T}, +shall be well-formed. \pnum -\effects For each element referred to by the iterator \tcode{i} in the range -\range{first}{last}, assigns \tcode{*i = value} and increments \tcode{value} as -if by \tcode{++value}. +\effects +For each element referred to by the iterator \tcode{i} +in the range \range{first}{last}, +assigns \tcode{*i = value} and increments \tcode{value} +as if by \tcode{++value}. \pnum -\complexity Exactly \tcode{last - first} increments and assignments. +\complexity +Exactly \tcode{last - first} increments and assignments. \end{itemdescr} \rSec2[numeric.ops.gcd]{Greatest common divisor} @@ -9872,10 +9721,13 @@ \begin{itemdescr} \pnum \requires -$|\tcode{m}|$ and $|\tcode{n}|$ shall -be representable as a value of \tcode{common_type_t}. -\begin{note} These requirements ensure, for example, -that $\tcode{gcd(m, m)} = |\tcode{m}|$ is representable as a value of type \tcode{M}. \end{note} +$|\tcode{m}|$ and $|\tcode{n}|$ +shall be representable as a value of \tcode{common_type_t}. +\begin{note} +These requirements ensure, for example, +that $\tcode{gcd(m, m)} = |\tcode{m}|$ +is representable as a value of type \tcode{M}. +\end{note} \pnum \remarks @@ -9884,8 +9736,8 @@ \pnum \returns -Zero when \tcode{m} and \tcode{n} are both zero. -Otherwise, returns the greatest common divisor of $|\tcode{m}|$ and $|\tcode{n}|$. +Zero when \tcode{m} and \tcode{n} are both zero. Otherwise, +returns the greatest common divisor of $|\tcode{m}|$ and $|\tcode{n}|$. \pnum \throws @@ -9903,8 +9755,8 @@ \begin{itemdescr} \pnum \requires -$|\tcode{m}|$ and $|\tcode{n}|$ shall -be representable as a value of \tcode{common_type_t}. +$|\tcode{m}|$ and $|\tcode{n}|$ +shall be representable as a value of \tcode{common_type_t}. The least common multiple of $|\tcode{m}|$ and $|\tcode{n}|$ shall be representable as a value of type \tcode{common_type_t}. @@ -9951,8 +9803,7 @@ \pnum \remarks The behavior is undefined -unless the objects in the array pointed to by \tcode{base} -are of trivial type. +unless the objects in the array pointed to by \tcode{base} are of trivial type. \pnum \throws diff --git a/source/basic.tex b/source/basic.tex index b6ff96acde..af3c0804d0 100644 --- a/source/basic.tex +++ b/source/basic.tex @@ -1209,8 +1209,8 @@ declaration used further in expression processing\iref{expr}. \pnum -A name ``looked up in the context of an expression'' is looked up as an -unqualified name in the scope where the expression is found. +A name ``looked up in the context of an expression'' is looked up +in the scope where the expression is found. \pnum The injected-class-name of a class\iref{class} is also @@ -2209,15 +2209,17 @@ followed by a \tcode{<}, the identifier must be looked up to determine whether the \tcode{<} is the beginning of a template argument list\iref{temp.names} or a less-than operator. The identifier is first -looked up in the class of the object expression. If the identifier is -not found, it is then looked up in the context of the entire +looked up in the class of the object expression\iref{class.member.lookup}. +If the identifier is not found, +it is then looked up in the context of the entire \grammarterm{postfix-expression} and shall name a class template. \pnum If the \grammarterm{id-expression} in a class member access\iref{expr.ref} is an \grammarterm{unqualified-id}, and the type of the object expression is of a class type \tcode{C}, the -\grammarterm{unqualified-id} is looked up in the scope of class \tcode{C}. +\grammarterm{unqualified-id} is looked up +in the scope of class \tcode{C}\iref{class.member.lookup}. \pnum If the \grammarterm{unqualified-id} is \tcode{\~}\grammarterm{type-name}, the @@ -2248,7 +2250,8 @@ \end{codeblock} the \tcode{\placeholder{class-name-or-namespace-name}} following the \tcode{.} or \tcode{->} operator is -first looked up in the class of the object expression and the name, if found, +first looked up in the class of the object expression\iref{class.member.lookup} +and the name, if found, is used. Otherwise it is looked up in the context of the entire \grammarterm{postfix-expression}. \begin{note} See~\ref{basic.lookup.qual}, which describes the lookup of a name before \tcode{::}, which will only find a type @@ -2271,7 +2274,9 @@ \pnum If the \grammarterm{id-expression} is a \grammarterm{conversion-function-id}, its \grammarterm{conversion-type-id} -is first looked up in the class of the object expression and the name, if +is first looked up +in the class of the object expression\iref{class.member.lookup} +and the name, if found, is used. Otherwise it is looked up in the context of the entire \grammarterm{postfix-expression}. In each of these lookups, only names that denote types or templates whose @@ -2826,7 +2831,7 @@ \end{note}% \indextext{object model|)} -\rSec2[basic.life]{Object lifetime} +\rSec2[basic.life]{Object and reference lifetime} \pnum \indextext{object lifetime|(}% @@ -2855,8 +2860,9 @@ \end{itemize} \pnum +\indextext{reference lifetime}% The lifetime of a reference begins when its initialization is complete. -The lifetime of a reference ends as if it were a scalar object. +The lifetime of a reference ends as if it were a scalar object requiring storage. \pnum \begin{note} \ref{class.base.init} @@ -3084,6 +3090,76 @@ thread without adequate synchronization. \end{note}% \indextext{object lifetime|)} +\rSec2[basic.indet]{Indeterminate values} + +\pnum +\indextext{value!indeterminate}% +\indextext{indeterminate value}% +When storage for an object with automatic or dynamic storage duration +is obtained, the object has an \defnadj{indeterminate}{value}, and if +no initialization is performed for the object, that object retains an +indeterminate value until that value is replaced\iref{expr.ass}. +\begin{note} +Objects with static or thread storage duration are zero-initialized, +see~\ref{basic.start.static}. +\end{note} + +\pnum +If an indeterminate value is produced by an evaluation, +the behavior is undefined except in the following cases: +\begin{itemize} +\item + If an indeterminate value of + unsigned ordinary character type\iref{basic.fundamental} + or \tcode{std::byte} type\iref{cstddef.syn} + is produced by the evaluation of: + \begin{itemize} + \item + the second or third operand of a conditional expression\iref{expr.cond}, + \item + the right operand of a comma expression\iref{expr.comma}, + \item + the operand of a cast or conversion~(\ref{conv.integral}, + \ref{expr.type.conv}, \ref{expr.static.cast}, \ref{expr.cast}) + to an unsigned ordinary character type + or \tcode{std::byte} type\iref{cstddef.syn}, or + \item + a discarded-value expression\iref{expr.context}, + \end{itemize} + then the result of the operation is an indeterminate value. +\item + If an indeterminate value of + unsigned ordinary character type or \tcode{std::byte} type + is produced by the evaluation of + the right operand of a simple assignment operator\iref{expr.ass} + whose first operand is an lvalue of + unsigned ordinary character type or \tcode{std::byte} type, + an indeterminate value replaces + the value of the object referred to by the left operand. +\item + If an indeterminate value of unsigned ordinary character type + is produced by the evaluation of the initialization expression + when initializing an object of unsigned ordinary character type, + that object is initialized to an indeterminate + value. +\item + If an indeterminate value of + unsigned ordinary character type or \tcode{std::byte} type + is produced by the evaluation of the initialization expression + when initializing an object of \tcode{std::byte} type, + that object is initialized to an indeterminate value. +\end{itemize} +\begin{example} +\begin{codeblock} + int f(bool b) { + unsigned char c; + unsigned char d = c; // OK, \tcode{d} has an indeterminate value + int e = d; // undefined behavior + return b ? d : 0; // undefined behavior if \tcode{b} is \tcode{true} + } +\end{codeblock} +\end{example} + \rSec2[basic.stc]{Storage duration} \pnum @@ -3649,7 +3725,7 @@ \item for certain unevaluated operands~(\ref{expr.typeid}, \ref{expr.sizeof}), and \item -when a prvalue appears as a discarded-value expression\iref{expr.prop}. +when a prvalue that has type other than \cv{}~\tcode{void} appears as a discarded-value expression\iref{expr.prop}. \end{itemize} \end{note} \begin{example} Consider the following code: diff --git a/source/classes.tex b/source/classes.tex index 2502e797ad..26432ad745 100644 --- a/source/classes.tex +++ b/source/classes.tex @@ -10,7 +10,7 @@ \indextext{\idxcode{\{\}}!class declaration}% \indextext{\idxcode{\{\}}!class definition}% \indextext{type!class and}% -\indextext{object class|seealso{class object}}% +\indextext{object class|see{class object}}% A class is a type. \indextext{name class|see{class name}}% Its name becomes a \grammarterm{class-name}\iref{class.name} within its @@ -6796,8 +6796,8 @@ \begin{codeblock} struct C { friend std::strong_equality operator<=>(const C&, const C&); - friend bool operator==(const C& x, const C& y) = default; // OK, returns \tcode{x <=> y == 0} - bool operator<(const C&) = default; // OK, function is deleted + friend bool operator==(const C&, const C&) = default; // OK, returns \tcode{x <=> y == 0} + bool operator<(const C&) const = default; // OK, function is deleted }; \end{codeblock} \end{example} diff --git a/source/compatibility.tex b/source/compatibility.tex index adb1ec3dfa..68745cc68e 100644 --- a/source/compatibility.tex +++ b/source/compatibility.tex @@ -249,7 +249,7 @@ \howwide Common. -\diffrefs{expr.post.incr}{expr.pre.incr} +\diffref{expr.post.incr,expr.pre.incr} \change Decrement operator is not allowed with \tcode{bool} operand. \rationale Feature with surprising semantics. @@ -257,7 +257,7 @@ a \tcode{bool} lvalue (for instance, via the C typedef in \tcode{}) is ill-formed in this International Standard. -\diffrefs{expr.sizeof}{expr.cast} +\diffref{expr.sizeof,expr.cast} \change Types must be defined in declarations, not in expressions.\\ In C, a sizeof expression or cast expression may define a new type. For example, @@ -275,7 +275,7 @@ \howwide Seldom. -\diffrefs{expr.cond}{expr.ass}, \ref{expr.comma} +\diffref{expr.cond,expr.ass,expr.comma} \indextext{conversion!lvalue-to-rvalue}% \indextext{rvalue!lvalue conversion to}% \indextext{lvalue}% @@ -306,7 +306,7 @@ \rSec2[diff.stat]{\ref{stmt.stmt}: statements} -\diffrefs{stmt.switch}{stmt.goto} +\diffref{stmt.switch,stmt.goto} \change It is now invalid to jump past a declaration with explicit or implicit initializer (except across entire block not entered). \rationale Constructors used in initializers may allocate @@ -423,7 +423,7 @@ Seldom. \diffref{dcl.type} [see also \ref{basic.link}] -\change const objects must be initialized in \Cpp{} but can be left uninitialized in C. +\change Const objects must be initialized in \Cpp{} but can be left uninitialized in C. \rationale A const object cannot be assigned to so it must be initialized to hold a useful value. @@ -446,7 +446,7 @@ In the following example, the left-hand column presents valid C; the right-hand column presents -equivalent \Cpp{} : +equivalent \Cpp{}: \begin{codeblock} void f(const parm); void f(const int parm); @@ -986,7 +986,7 @@ \rSec2[diff.cpp03.class]{\ref{class}: classes} -\diffrefs{class.default.ctor}{class.dtor}, \ref{class.copy.ctor}, \ref{class.copy.assign} +\diffref{class.default.ctor,class.dtor,class.copy.ctor,class.copy.assign} \change Implicitly-declared special member functions are defined as deleted when the implicit definition would have been ill-formed. \rationale Improves template argument deduction failure. @@ -1144,8 +1144,7 @@ that interacts with newer \Cpp{} code using regions declared reachable may have different runtime behavior. -\diffrefs{refwrap}{arithmetic.operations}, \ref{comparisons}, -\ref{logical.operations}, \ref{bitwise.operations} +\diffref{refwrap,arithmetic.operations,comparisons,logical.operations,bitwise.operations} \change Standard function object types no longer derived from \tcode{std::unary_function} or \tcode{std::binary_function}. \rationale Superseded by new feature; \tcode{unary_function} and @@ -1206,7 +1205,7 @@ Valid \CppIII{} code that attempts to explicitly instantiate a container using a user-defined type with no default constructor may fail to compile. -\diffrefs{sequence.reqmts}{associative.reqmts} +\diffref{sequence.reqmts,associative.reqmts} \change Signature changes: from \tcode{void} return types. \rationale Old signature threw away useful information that may be expensive to recalculate. @@ -1223,7 +1222,7 @@ (e.g., code that creates a pointer to member function that points to one of these functions) will fail to compile with this International Standard. -\diffrefs{sequence.reqmts}{associative.reqmts} +\diffref{sequence.reqmts,associative.reqmts} \change Signature changes: from \tcode{iterator} to \tcode{const_iterator} parameters. \rationale Overspecification. @@ -1244,7 +1243,7 @@ Valid \CppIII{} code that uses these functions may fail to compile with this International Standard. -\diffrefs{sequence.reqmts}{associative.reqmts} +\diffref{sequence.reqmts,associative.reqmts} \change Signature changes: \tcode{resize}. \rationale Performance, compatibility with move semantics. \effect @@ -1278,7 +1277,7 @@ \rSec2[diff.cpp03.input.output]{\ref{input.output}: input/output library} -\diffrefs{istream.sentry}{ostream.sentry}, \ref{iostate.flags} +\diffref{istream.sentry,ostream.sentry,iostate.flags} \change Specify use of \tcode{explicit} in existing boolean conversion functions. \rationale Clarify intentions, avoid workarounds. \effect @@ -1500,7 +1499,7 @@ \rSec2[diff.cpp14.expr]{\ref{expr}: expressions} -\diffrefs{expr.post.incr}{expr.pre.incr} +\diffref{expr.post.incr,expr.pre.incr} \change Remove increment operator with \tcode{bool} operand. \rationale Obsolete feature with occasionally surprising semantics. @@ -1509,7 +1508,7 @@ Note that this might occur when the lvalue has a type given by a template parameter. -\diffrefs{expr.new}{expr.delete} +\diffref{expr.new,expr.delete} \change Dynamic allocation mechanism for over-aligned types. \rationale Simplify use of over-aligned types. \effect In \CppXIV{} code that uses a \grammarterm{new-expression} @@ -1929,7 +1928,7 @@ \rSec2[diff.cpp17.class]{\ref{class}: classes} -\diffrefs{class.ctor}{class.conv.fct} +\diffref{class.ctor,class.conv.fct} \change The class name can no longer be used parenthesized immediately after an \tcode{explicit} \grammarterm{decl-specifier} @@ -1950,7 +1949,7 @@ }; \end{codeblock} -\diffrefs{class.ctor}{class.dtor} +\diffref{class.ctor,class.dtor} \change A \grammarterm{simple-template-id} is no longer valid as the \grammarterm{declarator-id} of a constructor or destructor. @@ -2030,6 +2029,7 @@ \tcode{}, \tcode{}, \tcode{}, +\tcode{}, \tcode{}, \tcode{}, and \tcode{}. @@ -2067,7 +2067,7 @@ \rSec2[diff.cpp17.containers]{\ref{containers}: containers library} -\diffrefs{forwardlist}{list} +\diffref{forwardlist,list} \change Return types of \tcode{remove}, \tcode{remove_if}, and \tcode{unique} changed from \tcode{void} to \tcode{container::size_type}. diff --git a/source/config.tex b/source/config.tex index 174d8ed223..5fa1de17ed 100644 --- a/source/config.tex +++ b/source/config.tex @@ -1,8 +1,8 @@ %!TEX root = std.tex %%-------------------------------------------------- %% Version numbers -\newcommand{\docno}{N4791} -\newcommand{\prevdocno}{N4778} +\newcommand{\docno}{N4800} +\newcommand{\prevdocno}{N4791} \newcommand{\cppver}{201703L} %% Release date diff --git a/source/containers.tex b/source/containers.tex index 0c392463a8..79ed5d63c1 100644 --- a/source/containers.tex +++ b/source/containers.tex @@ -2929,7 +2929,7 @@ of the \tcode{value_type}, to the predicate returned by \tcode{key_eq()}, and to the hasher returned by \tcode{hash_function()}) is proportional to $N$ in the average case and to $N^2$ in the worst case, where $N$ is -a.size(). For \tcode{unordered_multiset} and \tcode{unordered_multimap}, +\tcode{a.size()}. For \tcode{unordered_multiset} and \tcode{unordered_multimap}, the complexity of \tcode{operator==} is proportional to $\sum E_i^2$ in the average case and to $N^2$ in the worst case, where $N$ is \tcode{a.size()}, and $E_i$ is the size of the $i^\text{th}$ equivalent-key group in \tcode{a}. diff --git a/source/declarations.tex b/source/declarations.tex index 7a7b78af4b..591d7c5c4d 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -613,7 +613,7 @@ \pnum \indextext{redefinition!\idxcode{typedef}}% In a given non-class scope, a \tcode{typedef} specifier can be used to -redefine the name of any type declared in that scope to refer to the +redeclare the name of any type declared in that scope to refer to the type to which it already refers. \begin{example} @@ -627,7 +627,7 @@ \pnum In a given class scope, a \tcode{typedef} specifier can be used to -redefine any \grammarterm{class-name} declared in that scope that is not +redeclare any \grammarterm{class-name} declared in that scope that is not also a \grammarterm{typedef-name} to refer to the type to which it already refers. \begin{example} @@ -642,7 +642,7 @@ \end{example} \pnum -If a \tcode{typedef} specifier is used to redefine in a given scope an +If a \tcode{typedef} specifier is used to redeclare in a given scope an entity that can be referenced using an \grammarterm{elaborated-type-specifier}, the entity can continue to be referenced by an \grammarterm{elaborated-type-specifier} or as an enumeration or class name @@ -659,7 +659,7 @@ \pnum In a given scope, a \tcode{typedef} specifier shall not be used to -redefine the name of any type declared in that scope to refer to a +redeclare the name of any type declared in that scope to refer to a different type. \begin{example} \begin{codeblock} @@ -735,8 +735,9 @@ The \tcode{friend} specifier is used to specify access to class members; see~\ref{class.friend}. -\rSec2[dcl.constexpr]{The \tcode{constexpr} specifier}% +\rSec2[dcl.constexpr]{The \tcode{constexpr} and \tcode{consteval} specifiers}% \indextext{specifier!\idxcode{constexpr}} +\indextext{specifier!\idxcode{consteval}} \pnum The \tcode{constexpr} specifier shall be applied only to @@ -4280,72 +4281,7 @@ \end{note} \pnum -\indextext{value!indeterminate}% -\indextext{indeterminate value}% If no initializer is specified for an object, the object is default-initialized. -When storage for an object with automatic or dynamic storage duration -is obtained, the object has an \term{indeterminate value}, and if -no initialization is performed for the object, that object retains an -indeterminate value until that value is replaced\iref{expr.ass}. -\begin{note} Objects with static or thread storage duration are zero-initialized, -see~\ref{basic.start.static}. \end{note} -If an indeterminate value is produced by an evaluation, the behavior is -undefined except in the following cases: - -\begin{itemize} -\item -If an indeterminate value of -unsigned ordinary character type\iref{basic.fundamental} -or \tcode{std::byte} type\iref{cstddef.syn} -is produced by the evaluation of: -\begin{itemize} -\item the second or third operand of a conditional expression\iref{expr.cond}, -\item the right operand of a comma expression\iref{expr.comma}, -\item the operand of a cast or conversion~(\ref{conv.integral}, -\ref{expr.type.conv}, \ref{expr.static.cast}, \ref{expr.cast}) to an -unsigned ordinary character type -or \tcode{std::byte} type\iref{cstddef.syn}, or -\item a discarded-value expression\iref{expr.prop}, -\end{itemize} -then the result of the operation is an indeterminate value. - -\item -If an indeterminate value of -unsigned ordinary character type -or \tcode{std::byte} type -is produced by the evaluation of the right -operand of a simple assignment operator\iref{expr.ass} whose first operand -is an lvalue of -unsigned ordinary character type -or \tcode{std::byte} type, -an indeterminate value replaces -the value of the object referred to by the left operand. - -\item -If an indeterminate value of unsigned ordinary character type is produced by the -evaluation of the initialization expression when initializing an object of -unsigned ordinary character type, that object is initialized to an indeterminate -value. - -\item -If an indeterminate value of -unsigned ordinary character type -or \tcode{std::byte} type -is produced by the -evaluation of the initialization expression when initializing an object of -\tcode{std::byte} type, that object is initialized to an indeterminate -value. -\end{itemize} -\begin{example} -\begin{codeblock} - int f(bool b) { - unsigned char c; - unsigned char d = c; // OK, \tcode{d} has an indeterminate value - int e = d; // undefined behavior - return b ? d : 0; // undefined behavior if \tcode{b} is \tcode{true} - } -\end{codeblock} -\end{example} \pnum \indextext{initialization!class member}% @@ -5942,7 +5878,7 @@ storage duration that is implicitly defined (see~\ref{basic.scope.block}). \pnum -The function-local predefined variable \tcode{__func__} is +The function-local predefined variable \mname{func} is defined as if a definition of the form \begin{codeblock} static const char __func__[] = "@\placeholder{function-name}@"; @@ -5960,7 +5896,7 @@ S() : s(__func__) { } // OK const char* s; }; -void f(const char* s = __func__); // error: \tcode{__func__} is undeclared +void f(const char* s = __func__); // error: \mname{func} is undeclared \end{codeblock} \end{example} diff --git a/source/expressions.tex b/source/expressions.tex index a98f375a57..30f4eb6cf0 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -140,7 +140,8 @@ \item A \defn{glvalue} is an expression whose evaluation determines the identity of an object, bit-field, or function. \item A \defn{prvalue} is an expression whose evaluation initializes an object or a bit-field, or computes the value of an operand of an operator, -as specified by the context in which it appears. +as specified by the context in which it appears, +or an expression that has type \cv{}~\tcode{void}. \item An \defn{xvalue} is a glvalue that denotes an object or bit-field whose resources can be reused (usually because it is near the end of its lifetime). \item An \defn{lvalue} is a glvalue that is not an xvalue. \item An \defn{rvalue} is a prvalue or an xvalue. @@ -210,22 +211,23 @@ \end{example} \pnum +The \defnx{result}{result!glvalue} of a glvalue is the entity denoted by the expression. The \defnx{result}{result!prvalue} of a prvalue -is the value that the expression stores into its context. +is the value that the expression stores into its context; +a prvalue that has type \cv{}~\tcode{void} has no result. A prvalue whose result is the value \placeholder{V} is sometimes said to have or name the value \placeholder{V}. -The \defn{result object} of a prvalue -is the object initialized by the prvalue; +The \defn{result object} of a prvalue is the object initialized by the prvalue; a non-discarded prvalue -that is used to compute the value of an operand of a built-in operator or -that has type \cv{}~\tcode{void} +that is used to compute the value of an operand of a built-in operator +or a prvalue that has type \cv{}~\tcode{void} has no result object. \begin{note} Except when the prvalue is the operand of a \grammarterm{decltype-specifier}, a prvalue of class or array type always has a result object. -For a discarded prvalue, a temporary object is materialized; see \ref{expr.context}. +For a discarded prvalue that has type other than \cv{}~\tcode{void}, +a temporary object is materialized; see \ref{expr.context}. \end{note} -The \defnx{result}{result!glvalue} of a glvalue is the entity denoted by the expression. \pnum Whenever a glvalue appears as an operand of an operator that @@ -1509,7 +1511,7 @@ C().C::~C(); // undefined behavior: temporary of type \tcode{C} destroyed twice using T = int; 0 .T::~T(); // OK, no effect - 0.T::~T(); // error: \tcode{0.} is a floating-point literal\iref{lex.fcon} + 0.T::~T(); // error: \tcode{0.T} is a \grammarterm{user-defined-floating-literal}\iref{lex.ext} } \end{codeblock} \end{example} @@ -1687,17 +1689,18 @@ \grammarterm{parameter-declaration-clause} is followed by \tcode{consteval}. \begin{note} Names referenced in the \grammarterm{lambda-declarator} are looked up in the context in which the -\grammarterm{lambda-expression} appears. \end{note} +\grammarterm{lambda-expression} appears. +\end{note} \begin{example} \begin{codeblock} auto ID = [](auto a) { return a; }; -static_assert(ID(3) == 3); // OK +static_assert(ID(3) == 3); // OK struct NonLiteral { NonLiteral(int n) : n(n) { } int n; }; -static_assert(ID(NonLiteral{3}).n == 3); // ill-formed +static_assert(ID(NonLiteral{3}).n == 3); // ill-formed \end{codeblock} \end{example} @@ -1717,15 +1720,15 @@ }; constexpr auto zero = monoid(0); constexpr auto one = monoid(1); -static_assert(add(one)(zero)() == one()); // OK +static_assert(add(one)(zero)() == one()); // OK // Since \tcode{two} below is not declared \tcode{constexpr}, an evaluation of its \tcode{constexpr} member function call operator // cannot perform an lvalue-to-rvalue conversion on one of its subobjects (that represents its capture) // in a constant expression. auto two = monoid(2); assert(two() == 2); // OK, not a constant expression. -static_assert(add(one)(one)() == two()); // ill-formed: \tcode{two()} is not a constant expression -static_assert(add(one)(one)() == monoid(2)()); // OK +static_assert(add(one)(one)() == two()); // ill-formed: \tcode{two()} is not a constant expression +static_assert(add(one)(one)() == monoid(2)()); // OK \end{codeblock} \end{example} @@ -1813,18 +1816,18 @@ void f1(int (*)(int)) { } void f2(char (*)(int)) { } -void g(int (*)(int)) { } // \#1 -void g(char (*)(char)) { } // \#2 +void g(int (*)(int)) { } // \#1 +void g(char (*)(char)) { } // \#2 -void h(int (*)(int)) { } // \#3 -void h(char (*)(int)) { } // \#4 +void h(int (*)(int)) { } // \#3 +void h(char (*)(int)) { } // \#4 auto glambda = [](auto a) { return a; }; -f1(glambda); // OK -f2(glambda); // error: ID is not convertible -g(glambda); // error: ambiguous -h(glambda); // OK: calls \#3 since it is convertible from ID -int& (*fpi)(int*) = [](auto* a) -> auto& { return *a; }; // OK +f1(glambda); // OK +f2(glambda); // error: ID is not convertible +g(glambda); // error: ambiguous +h(glambda); // OK: calls \#3 since it is convertible from ID +int& (*fpi)(int*) = [](auto* a) -> auto& { return *a; }; // OK \end{codeblock} \end{example} @@ -1843,8 +1846,8 @@ \begin{example} \begin{codeblock} auto GL = [](auto a) { std::cout << a; return a; }; -int (*GL_int)(int) = GL; // OK: through conversion function template -GL_int(3); // OK: same as \tcode{GL(3)} +int (*GL_int)(int) = GL; // OK: through conversion function template +GL_int(3); // OK: same as \tcode{GL(3)} \end{codeblock} \end{example} @@ -1857,11 +1860,11 @@ auto Fwd = [](int (*fp)(int), auto a) { return fp(a); }; auto C = [](auto a) { return a; }; -static_assert(Fwd(C,3) == 3); // OK +static_assert(Fwd(C,3) == 3); // OK // No specialization of the function call operator template can be constexpr (due to the local static). auto NC = [](auto a) { static int s; return a; }; -static_assert(Fwd(NC,3) == 3); // ill-formed +static_assert(Fwd(NC,3) == 3); // ill-formed \end{codeblock} \end{example} @@ -1872,22 +1875,22 @@ \tcode{this}\iref{class.this} and transforming \grammarterm{id-expression}{s} referring to non-static class members into class member access expressions using \tcode{(*this)}~(\ref{class.mfct.non-static}), the \grammarterm{compound-statement} is -considered in the context of the \grammarterm{lambda-expression}. \begin{example} - +considered in the context of the \grammarterm{lambda-expression}. +\begin{example} \begin{codeblock} struct S1 { int x, y; int operator()(int); void f() { [=]()->int { - return operator()(this->x + y); // equivalent to \tcode{S1::operator()(this->x + (*this).y)} - // \tcode{this} has type \tcode{S1*} + return operator()(this->x + y); // equivalent to \tcode{S1::operator()(this->x + (*this).y)} + // \tcode{this} has type \tcode{S1*} }; } }; \end{codeblock} \end{example} -Further, a variable \tcode{__func__} is implicitly defined at the beginning of +Further, a variable \mname{func} is implicitly defined at the beginning of the \grammarterm{compound-statement} of the \grammarterm{lambda-expression}, with semantics as described in~\ref{dcl.fct.def.general}. @@ -1973,12 +1976,13 @@ ``\tcode{this}'', or ``\tcode{* this}''. \begin{note} The form \tcode{[\&,this]} is redundant but accepted -for compatibility with ISO \CppXIV{}. \end{note} +for compatibility with ISO \CppXIV{}. +\end{note} Ignoring appearances in \grammarterm{initializer}{s} of \grammarterm{init-capture}{s}, an identifier or \tcode{this} shall not appear more than once in a -\grammarterm{lambda-capture}. \begin{example} - +\grammarterm{lambda-capture}. +\begin{example} \begin{codeblock} struct S2 { void f(int i); }; void S2::f(int i) { @@ -2021,7 +2025,7 @@ \begin{codeblock} void f() { int x = 0; - auto g = [x](int x) { return 0; } // error: parameter and \grammarterm{simple-capture} have the same name + auto g = [x](int x) { return 0; }; // error: parameter and \grammarterm{simple-capture} have the same name } \end{codeblock} \end{example} @@ -2051,9 +2055,9 @@ auto y = [&r = x, x = x+1]()->int { r += 2; return x+2; - }(); // Updates \tcode{::x} to 6, and initializes \tcode{y} to 7. + }(); // Updates \tcode{::x} to 6, and initializes \tcode{y} to 7. -auto z = [a = 42](int a) { return 1; } // error: parameter and local variable have the same name +auto z = [a = 42](int a) { return 1; }; // error: parameter and local variable have the same name \end{codeblock} \end{example} @@ -2146,7 +2150,8 @@ or captures a structured binding (explicitly or implicitly), the program is -ill-formed. \begin{example} +ill-formed. +\begin{example} \indextext{Bond!James Bond}% \begin{codeblock} void f1(int i) { @@ -2182,7 +2187,7 @@ return [this] { return [*this] { return ohseven; // OK - } + }; }(); } auto g() { @@ -2196,8 +2201,8 @@ \pnum A \grammarterm{lambda-expression} appearing in a default argument shall not -implicitly or explicitly capture any entity. \begin{example} - +implicitly or explicitly capture any entity. +\begin{example} \begin{codeblock} void f2() { int i = 1; @@ -4096,7 +4101,7 @@ \indextext{expression!unary operator}% \indextext{operator!unary}% The unary \tcode{*} operator performs \defn{indirection}: -\indextext{dereferencing|seealso{indirection}}% +\indextext{dereferencing|see{indirection}}% the expression to which it is applied shall be a pointer to an object type, or a pointer to a function type and the result is an lvalue referring to the object or function to which the expression points. If @@ -4357,7 +4362,7 @@ \pnum \indextext{expression!\idxcode{new}}% \indextext{free store|seealso{\tcode{new}, \tcode{delete}}}% -\indextext{memory management|seealso{\tcode{new}, \tcode{delete}}}% +\indextext{memory management|see{\tcode{new}, \tcode{delete}}}% \indextext{storage management|see{\tcode{new}, \tcode{delete}}}% \indextext{\idxcode{new}}% The \grammarterm{new-expression} attempts to create an object of the @@ -4824,7 +4829,8 @@ If the \grammarterm{new-expression} creates an object or an array of objects of class type, access and ambiguity control are done for the allocation function, the deallocation function\iref{class.free}, and -the constructor\iref{class.ctor}. If the \grammarterm{new-expression} +the constructor\iref{class.ctor} selected for the initialization (if any). +If the \grammarterm{new-expression} creates an array of objects of class type, the destructor is potentially invoked\iref{class.dtor}. @@ -5982,6 +5988,7 @@ \end{bnf} \pnum +The \tcode{\&} operator groups left-to-right. The operands shall be of integral or unscoped enumeration type. The usual arithmetic conversions\iref{expr.arith.conv} are performed. Given the coefficients $\tcode{x}_i$ and $\tcode{y}_i$ @@ -6006,6 +6013,7 @@ \end{bnf} \pnum +The \tcode{\^} operator groups left-to-right. The operands shall be of integral or unscoped enumeration type. The usual arithmetic conversions\iref{expr.arith.conv} are performed. Given the coefficients $\tcode{x}_i$ and $\tcode{y}_i$ @@ -6031,6 +6039,7 @@ \end{bnf} \pnum +The \tcode{|} operator groups left-to-right. The operands shall be of integral or unscoped enumeration type. The usual arithmetic conversions\iref{expr.arith.conv} are performed. Given the coefficients $\tcode{x}_i$ and $\tcode{y}_i$ diff --git a/source/future.tex b/source/future.tex index 1fb805188a..a09031cb40 100644 --- a/source/future.tex +++ b/source/future.tex @@ -1018,7 +1018,8 @@ \begin{itemdescr} \pnum \effects -Implementation defined, except that +Behavior is \impldef{behavior of \tcode{strstreambuf::setbuf}}, +except that \tcode{setbuf(0, 0)} has no effect.% \end{itemdescr} diff --git a/source/iterators.tex b/source/iterators.tex index edf48d7992..a2bba557d6 100644 --- a/source/iterators.tex +++ b/source/iterators.tex @@ -25,13 +25,13 @@ \ref{predef.iterators} & Iterator adaptors & \\ \ref{stream.iterators} & Stream iterators & \\ \ref{iterator.range} & Range access & \\ -\ref{iterator.container} & Container and view access & \\ \end{libsumtab} \rSec1[iterator.synopsis]{Header \tcode{}\ synopsis} \indexhdr{iterator}% \indexlibrary{\idxcode{default_sentinel}}% +\indexlibrary{\idxcode{unreachable_sentinel}}% \begin{codeblock} #include @@ -65,10 +65,10 @@ namespace ranges { // \ref{iterator.cust}, customization points inline namespace @\unspec@ { - // \ref{iterator.cust.move}, \tcode{iter_move} + // \ref{iterator.cust.move}, \tcode{ranges::iter_move} inline constexpr @\unspec@ iter_move = @\unspec@; - // \ref{iterator.cust.swap}, \tcode{iter_swap} + // \ref{iterator.cust.swap}, \tcode{ranges::iter_swap} inline constexpr @\unspec@ iter_swap = @\unspec@; } } @@ -306,6 +306,11 @@ template constexpr reverse_iterator make_reverse_iterator(Iterator i); + template + requires (!SizedSentinel) + inline constexpr bool disable_sized_sentinel, + reverse_iterator> = true; + // \ref{insert.iterators}, insert iterators template class back_insert_iterator; template @@ -322,6 +327,7 @@ // \ref{move.iterators}, move iterators and sentinels template class move_iterator; + template constexpr bool operator==( const move_iterator& x, const move_iterator& y); @@ -348,6 +354,7 @@ template constexpr move_iterator operator+( typename move_iterator::difference_type n, const move_iterator& x); + template constexpr move_iterator make_move_iterator(Iterator i); @@ -429,7 +436,6 @@ template constexpr auto crbegin(const C& c) -> decltype(std::rbegin(c)); template constexpr auto crend(const C& c) -> decltype(std::rend(c)); - // \ref{iterator.container}, container access template constexpr auto size(const C& c) -> decltype(c.size()); template constexpr size_t size(const T (&array)[N]) noexcept; template [[nodiscard]] constexpr auto empty(const C& c) -> decltype(c.empty()); @@ -855,11 +861,11 @@ @\placeholder{cpp17-iterator}@ && EqualityComparable && requires(I i) { typename incrementable_traits::difference_type; typename readable_traits::value_type; - typename common_reference_t &&, - typename readable_traits::value_type &>; + typename common_reference_t&&, + typename readable_traits::value_type&>; *i++; - typename common_reference_t::value_type &>; + typename common_reference_t::value_type&>; requires SignedIntegral::difference_type>; }; @@ -1033,13 +1039,13 @@ \rSec2[iterator.cust]{Customization points} -\rSec3[iterator.cust.move]{\tcode{iter_move}} +\rSec3[iterator.cust.move]{\tcode{ranges::iter_move}} \indexlibrary{\idxcode{iter_move}}% \pnum -The name \tcode{iter_move} denotes +The name \tcode{ranges::iter_move} denotes a customization point object\iref{customization.point.object}. -The expression \tcode{ranges::iter_move(E)} for some subexpression \tcode{E} is +The expression \tcode{ranges::\-iter_move(E)} for some subexpression \tcode{E} is expression-equivalent to the following: \begin{itemize} @@ -1065,11 +1071,11 @@ If \tcode{ranges::iter_move(E)} is not equal to \tcode{*E}, the program is ill-formed with no diagnostic required. -\rSec3[iterator.cust.swap]{\tcode{iter_swap}} +\rSec3[iterator.cust.swap]{\tcode{ranges::iter_swap}} \indexlibrary{\idxcode{iter_swap}}% \pnum -The name \tcode{iter_swap} denotes +The name \tcode{ranges::iter_swap} denotes a customization point object\iref{customization.point.object} that exchanges the values\iref{concept.swappable} denoted by its arguments. @@ -1601,7 +1607,7 @@ \begin{itemize} \item \tcode{addressof(--a) == addressof(a)} \item \tcode{bool(a-- == b)} - \item after evaluating both \tcode{a--} and \tcode{--b} + \item after evaluating both \tcode{a--} and \tcode{--b}, \tcode{bool(a == b)} is still \tcode{true} \item \tcode{bool(++(--a) == b)} \end{itemize} @@ -2152,7 +2158,7 @@ \pnum There are several concepts that group requirements of algorithms that -take callable objects~(\ref{func.require}) as arguments. +take callable objects~(\ref{func.def}) as arguments. \rSec3[indirectcallable.indirectinvocable]{Indirect callables} @@ -2447,8 +2453,8 @@ \rSec1[iterator.primitives]{Iterator primitives} \pnum -To simplify the task of defining iterators, the library provides -several classes and functions: +To simplify the use of iterators, the library provides +several classes and functions. \rSec2[std.iterator.tags]{Standard iterator tags} @@ -2686,7 +2692,7 @@ \indexlibrary{\idxcode{advance}}% \begin{itemdecl} template - constexpr void advance(I& i, iter_difference_t n); + constexpr void ranges::advance(I& i, iter_difference_t n); \end{itemdecl} \begin{itemdescr} @@ -2709,7 +2715,7 @@ \indexlibrary{\idxcode{advance}}% \begin{itemdecl} template S> - constexpr void advance(I& i, S bound); + constexpr void ranges::advance(I& i, S bound); \end{itemdecl} \begin{itemdescr} @@ -2732,7 +2738,7 @@ \indexlibrary{\idxcode{advance}}% \begin{itemdecl} template S> - constexpr iter_difference_t advance(I& i, iter_difference_t n, S bound); + constexpr iter_difference_t ranges::advance(I& i, iter_difference_t n, S bound); \end{itemdecl} \begin{itemdescr} @@ -2774,7 +2780,7 @@ \indexlibrary{\idxcode{distance}}% \begin{itemdecl} template S> - constexpr iter_difference_t distance(I first, S last); + constexpr iter_difference_t ranges::distance(I first, S last); \end{itemdecl} \begin{itemdescr} @@ -2798,7 +2804,7 @@ \indexlibrary{\idxcode{distance}}% \begin{itemdecl} template - constexpr iter_difference_t> distance(R&& r); + constexpr iter_difference_t> ranges::distance(R&& r); \end{itemdecl} \begin{itemdescr} @@ -2819,7 +2825,7 @@ \indexlibrary{\idxcode{next}}% \begin{itemdecl} template - constexpr I next(I x); + constexpr I ranges::next(I x); \end{itemdecl} \begin{itemdescr} @@ -2830,7 +2836,7 @@ \indexlibrary{\idxcode{next}}% \begin{itemdecl} template - constexpr I next(I x, iter_difference_t n); + constexpr I ranges::next(I x, iter_difference_t n); \end{itemdecl} \begin{itemdescr} @@ -2841,7 +2847,7 @@ \indexlibrary{\idxcode{next}}% \begin{itemdecl} template S> - constexpr I next(I x, S bound); + constexpr I ranges::next(I x, S bound); \end{itemdecl} \begin{itemdescr} @@ -2852,7 +2858,7 @@ \indexlibrary{\idxcode{next}}% \begin{itemdecl} template S> - constexpr I next(I x, iter_difference_t n, S bound); + constexpr I ranges::next(I x, iter_difference_t n, S bound); \end{itemdecl} \begin{itemdescr} @@ -2864,7 +2870,7 @@ \indexlibrary{\idxcode{prev}}% \begin{itemdecl} template - constexpr I prev(I x); + constexpr I ranges::prev(I x); \end{itemdecl} \begin{itemdescr} @@ -2875,7 +2881,7 @@ \indexlibrary{\idxcode{prev}}% \begin{itemdecl} template - constexpr I prev(I x, iter_difference_t n); + constexpr I ranges::prev(I x, iter_difference_t n); \end{itemdecl} \begin{itemdescr} @@ -2886,7 +2892,7 @@ \indexlibrary{\idxcode{prev}}% \begin{itemdecl} template - constexpr I prev(I x, iter_difference_t n, I bound); + constexpr I ranges::prev(I x, iter_difference_t n, I bound); \end{itemdecl} \begin{itemdescr} @@ -2941,53 +2947,12 @@ iter_move(const reverse_iterator& i) noexcept(@\seebelow@); template Iterator2> friend constexpr void - iter_swap(const reverse_iterator\& x, - const reverse_iterator\& y) noexcept(@\seebelow@); + iter_swap(const reverse_iterator& x, + const reverse_iterator& y) noexcept(@\seebelow@); protected: Iterator current; }; - - template - constexpr bool operator==( - const reverse_iterator& x, - const reverse_iterator& y); - template - constexpr bool operator!=( - const reverse_iterator& x, - const reverse_iterator& y); - template - constexpr bool operator<( - const reverse_iterator& x, - const reverse_iterator& y); - template - constexpr bool operator>( - const reverse_iterator& x, - const reverse_iterator& y); - template - constexpr bool operator<=( - const reverse_iterator& x, - const reverse_iterator& y); - template - constexpr bool operator>=( - const reverse_iterator& x, - const reverse_iterator& y); - template - constexpr auto operator-( - const reverse_iterator& x, - const reverse_iterator& y) -> decltype(y.base() - x.base()); - template - constexpr reverse_iterator operator+( - typename reverse_iterator::difference_type n, - const reverse_iterator& x); - - template - constexpr reverse_iterator make_reverse_iterator(Iterator i); - - template - requires (!SizedSentinel) - inline constexpr bool disable_sized_sentinel, - reverse_iterator> = true; } \end{codeblock} @@ -3100,14 +3065,14 @@ \indexlibrarymember{operator=}{reverse_iterator}% \begin{itemdecl} template -constexpr reverse_iterator& - operator=(const reverse_iterator& u); + constexpr reverse_iterator& + operator=(const reverse_iterator& u); \end{itemdecl} \begin{itemdescr} \pnum \effects -Assigns \tcode{u.base()} to current. +Assigns \tcode{u.base()} to \tcode{current}. \pnum \returns @@ -3304,12 +3269,12 @@ \begin{itemdescr} \pnum \constraints -The expression \tcode{x.current == y.current} shall be valid and +The expression \tcode{x.base() == y.base()} shall be valid and convertible to \tcode{bool}. \pnum \returns -\tcode{x.current == y.current}. +\tcode{x.base() == y.base()}. \end{itemdescr} \indexlibrarymember{operator"!=}{reverse_iterator}% @@ -3323,12 +3288,12 @@ \begin{itemdescr} \pnum \constraints -The expression \tcode{x.current != y.current} shall be valid and +The expression \tcode{x.base() != y.base()} shall be valid and convertible to \tcode{bool}. \pnum \returns -\tcode{x.current != y.current}. +\tcode{x.base() != y.base()}. \end{itemdescr} \indexlibrarymember{operator<}{reverse_iterator}% @@ -3342,12 +3307,12 @@ \begin{itemdescr} \pnum \constraints -The expression \tcode{x.current > y.current} shall be valid and +The expression \tcode{x.base() > y.base()} shall be valid and convertible to \tcode{bool}. \pnum \returns -\tcode{x.current > y.current}. +\tcode{x.base() > y.base()}. \end{itemdescr} \indexlibrarymember{operator>}{reverse_iterator}% @@ -3361,12 +3326,12 @@ \begin{itemdescr} \pnum \constraints -The expression \tcode{x.current < y.current} shall be valid and +The expression \tcode{x.base() < y.base()} shall be valid and convertible to \tcode{bool}. \pnum \returns -\tcode{x.current < y.current}. +\tcode{x.base() < y.base()}. \end{itemdescr} \indexlibrarymember{operator<=}{reverse_iterator}% @@ -3380,12 +3345,12 @@ \begin{itemdescr} \pnum \constraints -The expression \tcode{x.current >= y.current} shall be valid and +The expression \tcode{x.base() >= y.base()} shall be valid and convertible to \tcode{bool}. \pnum \returns -\tcode{x.current >= y.current}. +\tcode{x.base() >= y.base()}. \end{itemdescr} \indexlibrarymember{operator>=}{reverse_iterator}% @@ -3399,12 +3364,12 @@ \begin{itemdescr} \pnum \constraints -The expression \tcode{x.current <= y.current} shall be valid and +The expression \tcode{x.base() <= y.base()} shall be valid and convertible to \tcode{bool}. \pnum \returns -\tcode{x.current <= y.current}. +\tcode{x.base() <= y.base()}. \end{itemdescr} \rSec3[reverse.iter.nonmember]{Non-member functions} @@ -3412,7 +3377,7 @@ \indexlibrarymember{operator-}{reverse_iterator}% \begin{itemdecl} template - constexpr auto operator-( + constexpr auto operator-( const reverse_iterator& x, const reverse_iterator& y) -> decltype(y.base() - x.base()); \end{itemdecl} @@ -3420,7 +3385,7 @@ \begin{itemdescr} \pnum \returns -\tcode{y.current - x.current}. +\tcode{y.base() - x.base()}. \end{itemdescr} \indexlibrarymember{operator+}{reverse_iterator}% @@ -3434,7 +3399,7 @@ \begin{itemdescr} \pnum \returns -\tcode{reverse_iterator (x.current - n)}. +\tcode{reverse_iterator(x.base() - n)}. \end{itemdescr} \indexlibrarymember{iter_move}{reverse_iterator}% @@ -3447,7 +3412,7 @@ \pnum \effects Equivalent to: \begin{codeblock} -auto tmp = i.current; +auto tmp = i.base(); return ranges::iter_move(--tmp); \end{codeblock} @@ -3471,8 +3436,8 @@ \pnum \effects Equivalent to: \begin{codeblock} -auto xtmp = x.current; -auto ytmp = y.current; +auto xtmp = x.base(); +auto ytmp = y.base(); ranges::iter_swap(--xtmp, --ytmp); \end{codeblock} @@ -3574,9 +3539,6 @@ constexpr back_insert_iterator& operator++(); constexpr back_insert_iterator operator++(int); }; - - template - constexpr back_insert_iterator back_inserter(Container& x); } \end{codeblock} @@ -3689,9 +3651,6 @@ constexpr front_insert_iterator& operator++(); constexpr front_insert_iterator operator++(int); }; - - template - constexpr front_insert_iterator front_inserter(Container& x); } \end{codeblock} @@ -3805,10 +3764,6 @@ constexpr insert_iterator& operator++(); constexpr insert_iterator& operator++(int); }; - - template - constexpr insert_iterator - inserter(Container& x, iterator_t i); } \end{codeblock} @@ -3993,35 +3948,6 @@ private: Iterator current; // \expos }; - - template - constexpr bool operator==( - const move_iterator& x, const move_iterator& y); - template - constexpr bool operator!=( - const move_iterator& x, const move_iterator& y); - template - constexpr bool operator<( - const move_iterator& x, const move_iterator& y); - template - constexpr bool operator>( - const move_iterator& x, const move_iterator& y); - template - constexpr bool operator<=( - const move_iterator& x, const move_iterator& y); - template - constexpr bool operator>=( - const move_iterator& x, const move_iterator& y); - - template - constexpr auto operator-(const move_iterator& x, - const move_iterator& y) - -> decltype(x.base() - y.base()); - template - constexpr move_iterator - operator+(iter_difference_t n, const move_iterator& x); - template - constexpr move_iterator make_move_iterator(Iterator i); } \end{codeblock} @@ -5480,7 +5406,7 @@ \pnum \begin{note} -The argument order in the \textit{Effects} element is reversed +The argument order in the \effects{} element is reversed because \tcode{length} counts down, not up. \end{note} \end{itemdescr} @@ -5554,11 +5480,10 @@ \rSec3[unreachable.sentinel]{Class \tcode{unreachable_sentinel_t}} \indexlibrary{\idxcode{unreachable_sentinel_t}}% -\indexlibrary{\idxcode{unreachable_sentinel}}% \pnum Class \tcode{unreachable_sentinel_t} can be used with any \libconcept{WeaklyIncrementable} type -to denote the ``upper bound'' of an open interval. +to denote the ``upper bound'' of an unbounded interval. \pnum \begin{example} @@ -5726,13 +5651,6 @@ basic_istream* in_stream; // \expos T value; // \expos }; - - template - bool operator==(const istream_iterator& x, - const istream_iterator& y); - template - bool operator!=(const istream_iterator& x, - const istream_iterator& y); } \end{codeblock} @@ -5752,7 +5670,7 @@ then these constructors are constexpr constructors. \pnum -\ensures \tcode{in_stream == 0}. +\ensures \tcode{in_stream == nullptr}. \end{itemdescr} @@ -5833,7 +5751,7 @@ \begin{itemdescr} \pnum -\requires \tcode{in_stream != 0}. +\requires \tcode{in_stream != nullptr}. \pnum \effects @@ -5851,7 +5769,7 @@ \begin{itemdescr} \pnum -\requires \tcode{in_stream != 0}. +\requires \tcode{in_stream != nullptr}. \pnum \effects @@ -5859,7 +5777,7 @@ \begin{codeblock} istream_iterator tmp = *this; *in_stream >> value; -return (tmp); +return tmp; \end{codeblock} \end{itemdescr} @@ -5918,17 +5836,6 @@ is written to the stream after every \tcode{T} is written. -It is not possible to get a value out of the output iterator. -Its only use is as an output iterator in situations like - -\begin{codeblock} -while (first != last) - *result++ = *first++; -\end{codeblock} - -\pnum -\tcode{ostream_iterator} -is defined as: \begin{codeblock} namespace std { @@ -5974,7 +5881,7 @@ \pnum \effects Initializes \tcode{out_stream} with \tcode{addressof(s)} and -\tcode{delim} with null. +\tcode{delim} with \tcode{nullptr}. \end{itemdescr} @@ -6026,7 +5933,7 @@ As if by: \begin{codeblock} *out_stream << value; -if (delim != 0) +if (delim) *out_stream << delim; return *this; \end{codeblock} @@ -6078,7 +5985,7 @@ The default constructor \tcode{istreambuf_iterator()} and the constructor -\tcode{istreambuf_iterator(0)} +\tcode{istreambuf_iterator(nullptr)} both construct an end-of-stream iterator object suitable for use as an end-of-range. All specializations of \tcode{istreambuf_iterator} shall have a trivial copy @@ -6111,7 +6018,7 @@ using streambuf_type = basic_streambuf; using istream_type = basic_istream; - class proxy; // \expos + class @\placeholder{proxy}@; // \expos constexpr istreambuf_iterator() noexcept; constexpr istreambuf_iterator(default_sentinel_t) noexcept; @@ -6119,11 +6026,11 @@ ~istreambuf_iterator() = default; istreambuf_iterator(istream_type& s) noexcept; istreambuf_iterator(streambuf_type* s) noexcept; - istreambuf_iterator(const proxy& p) noexcept; + istreambuf_iterator(const @\placeholder{proxy}@& p) noexcept; istreambuf_iterator& operator=(const istreambuf_iterator&) noexcept = default; charT operator*() const; istreambuf_iterator& operator++(); - proxy operator++(int); + @\placeholder{proxy}@ operator++(int); bool equal(const istreambuf_iterator& b) const; friend bool operator==(default_sentinel_t s, const istreambuf_iterator& i); @@ -6134,26 +6041,33 @@ private: streambuf_type* sbuf_; // \expos }; - - template - bool operator==(const istreambuf_iterator& a, - const istreambuf_iterator& b); - template - bool operator!=(const istreambuf_iterator& a, - const istreambuf_iterator& b); } \end{codeblock} -\rSec3[istreambuf.iterator.proxy]{Class \tcode{istreambuf_iterator::proxy}} +\rSec3[istreambuf.iterator.proxy]{Class \tcode{istreambuf_iterator::\placeholder{proxy}}} + +\pnum +Class +\tcode{istreambuf_iterator::\placeholder{proxy}} +is for exposition only. +An implementation is permitted to provide equivalent functionality without +providing a class with this name. +Class +\tcode{istreambuf_iterator::\placeholder{proxy}} +provides a temporary +placeholder as the return value of the post-increment operator +(\tcode{operator++}). +It keeps the character pointed to by the previous value +of the iterator for some possible future access to get the character. \indexlibrary{\idxcode{proxy}!\idxcode{istreambuf_iterator}}% \begin{codeblock} namespace std { template - class istreambuf_iterator::proxy { // \expos + class istreambuf_iterator::@\placeholder{proxy}@ { // \expos charT keep_; basic_streambuf* sbuf_; - proxy(charT c, basic_streambuf* sbuf) + @\placeholder{proxy}@(charT c, basic_streambuf* sbuf) : keep_(c), sbuf_(sbuf) { } public: charT operator*() { return keep_; } @@ -6161,20 +6075,6 @@ } \end{codeblock} -\pnum -Class -\tcode{istreambuf_iterator::proxy} -is for exposition only. -An implementation is permitted to provide equivalent functionality without -providing a class with this name. -Class -\tcode{istreambuf_iterator::proxy} -provides a temporary -placeholder as the return value of the post-increment operator -(\tcode{operator++}). -It keeps the character pointed to by the previous value -of the iterator for some possible future access to get the character. - \rSec3[istreambuf.iterator.cons]{Constructors} \pnum @@ -6222,7 +6122,7 @@ \indexlibrary{\idxcode{istreambuf_iterator}!constructor}% \begin{itemdecl} -istreambuf_iterator(const proxy& p) noexcept; +istreambuf_iterator(const @\placeholder{proxy}@& p) noexcept; \end{itemdecl} \begin{itemdescr} @@ -6264,13 +6164,13 @@ \indexlibrarymember{operator++}{istreambuf_iterator}% \begin{itemdecl} -proxy operator++(int); +@\placeholder{proxy}@ operator++(int); \end{itemdecl} \begin{itemdescr} \pnum \returns -\tcode{proxy(sbuf_->sbumpc(), sbuf_)}. +\tcode{\placeholder{proxy}(sbuf_->sbumpc(), sbuf_)}. \end{itemdescr} \indexlibrarymember{equal}{istreambuf_iterator}% @@ -6329,6 +6229,11 @@ \rSec2[ostreambuf.iterator]{Class template \tcode{ostreambuf_iterator}} +\pnum +The class template \tcode{ostreambuf_iterator} +writes successive \textit{characters} onto the output stream +from which it was constructed. + \indexlibrary{\idxcode{ostreambuf_iterator}}% \begin{codeblock} namespace std { @@ -6361,15 +6266,6 @@ } \end{codeblock} -\pnum -The -class template -\tcode{ostreambuf_iterator} -writes successive -\textit{characters} -onto the output stream from which it was constructed. -It is not possible to get a character value out of the output iterator. - \rSec3[ostreambuf.iter.cons]{Constructors} \indexlibrary{\idxcode{ostreambuf_iterator}!constructor}% @@ -6608,18 +6504,6 @@ \pnum \returns \tcode{std::rend(c)}. \end{itemdescr} -\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{}, \tcode{}, \tcode{}, and \tcode{}. -Each of these templates -is a designated customization point\iref{namespace.std}. - \indexlibrary{\idxcode{size(C\& c)}}% \begin{itemdecl} template constexpr auto size(const C& c) -> decltype(c.size()); diff --git a/source/lex.tex b/source/lex.tex index 4650f265c4..4e76e7152a 100644 --- a/source/lex.tex +++ b/source/lex.tex @@ -695,8 +695,8 @@ \tcode{decltype} \\ \tcode{default} \\ \tcode{delete} \\ -\tcode{double} \\ \tcode{do} \\ +\tcode{double} \\ \tcode{dynamic_cast} \\ \tcode{else} \\ \tcode{enum} \\ diff --git a/source/lib-intro.tex b/source/lib-intro.tex index 678d6dbc94..73eb33690a 100644 --- a/source/lib-intro.tex +++ b/source/lib-intro.tex @@ -421,7 +421,7 @@ \tcode{false}. \end{example} -\rSec1[description]{Method of description (Informative)} +\rSec1[description]{Method of description} \pnum This subclause describes the conventions used to specify the \Cpp{} standard @@ -700,6 +700,23 @@ implementation-defined types\iref{type.descriptions}, and member functions\iref{functions.within.classes}. +\rSec3[expos.only.func]{Exposition-only functions} + +\pnum +Several function templates +defined in \ref{\firstlibchapter} through \ref{\lastlibchapter} and \ref{depr} +are only defined for the purpose of exposition. +The declaration of such a function is followed by a comment ending in \expos. + +\pnum +The following function is defined for exposition only +to aid in the specification of the library: +\begin{codeblock} +template constexpr decay_t @\placeholdernc{decay-copy}@(T&& v) + noexcept(is_nothrow_convertible_v>) // \expos + { return std::forward(v); } +\end{codeblock} + \rSec3[type.descriptions]{Type descriptions} \rSec4[type.descriptions.general]{General} @@ -728,9 +745,8 @@ \pnum Several types defined in \ref{\firstlibchapter} through \ref{\lastlibchapter} -and \ref{depr} that are used as function parameter or return types are defined -for the purpose of exposition only in order to capture their language linkage. The -declarations of such types are followed by a comment ending in \textit{exposition only}. +and \ref{depr} are defined for the purpose of exposition. +The declaration of such a type is followed by a comment ending in \expos. \begin{example} \begin{codeblock} namespace std { @@ -2289,6 +2305,15 @@ called. If a type cannot be used with a particular allocator, the allocator class or the call to \tcode{construct} or \tcode{destroy} may fail to instantiate. +\pnum +If the alignment associated with a specific over-aligned type is not +supported by an allocator, instantiation of the allocator for that type may +fail. The allocator also may silently ignore the requested alignment. +\begin{note} Additionally, the member function \tcode{allocate} +for that type may fail by throwing an object of type +\tcode{bad_alloc}.\end{note} + +\pnum \begin{example} The following is an allocator class template supporting the minimal interface that satisfies the requirements of \tref{utilities.allocator.requirements}: @@ -2312,14 +2337,6 @@ \end{codeblock} \end{example} -\pnum -If the alignment associated with a specific over-aligned type is not -supported by an allocator, instantiation of the allocator for that type may -fail. The allocator also may silently ignore the requested alignment. -\begin{note} Additionally, the member function \tcode{allocate} -for that type may fail by throwing an object of type -\tcode{bad_alloc}.\end{note} - \rSec4[allocator.requirements.completeness]{Allocator completeness requirements} \pnum diff --git a/source/macros.tex b/source/macros.tex index 80806966b4..f50fbb775b 100644 --- a/source/macros.tex +++ b/source/macros.tex @@ -339,8 +339,23 @@ %% Change descriptions \newcommand{\diffhead}[1]{\textbf{#1:}\space} \newcommand{\diffdef}[1]{\hfill\break\diffhead{#1}} -\newcommand{\diffref}[1]{\pnum\textbf{Affected subclause:} \ref{#1}} -\newcommand{\diffrefs}[2]{\pnum\textbf{Affected subclauses:} \ref{#1}, \ref{#2}} +\ExplSyntaxOn +\NewDocumentCommand \diffref { m } { + \clist_set:Nx \l_tmpa_clist { #1 } + \pnum + \int_compare:nTF { \clist_count:N \l_tmpa_clist < 2 } { + \textbf{Affected~subclause:} ~ + } { + \textbf{Affected~subclauses:} ~ + } + \clist_map_inline:Nn \l_tmpa_clist { + \clist_put_right:Nn \g_tmpa_clist { \ref{##1} } + } + \clist_use:Nnnn \g_tmpa_clist { ~and~ } { ,~ } { ,~and~ } + \clist_clear:N \g_tmpa_clist +} +\cs_set_eq:NN \diffrefs \diffref +\ExplSyntaxOff % \nodiffref swallows a following \change and removes the preceding line break. \def\nodiffref\change{\pnum\diffhead{Change}} \newcommand{\change}{\diffdef{Change}} diff --git a/source/overloading.tex b/source/overloading.tex index 8fb11504ac..0602fc540a 100644 --- a/source/overloading.tex +++ b/source/overloading.tex @@ -772,8 +772,8 @@ operator and has the more general form of a \grammarterm{primary-expression}. The name is looked up in the context of the function -call following the normal rules for name lookup in function -calls\iref{basic.lookup}. +call following the normal rules for name lookup +in expressions\iref{basic.lookup}. The function declarations found by that lookup constitute the set of candidate functions. Because of the rules for name lookup, the set of candidate functions @@ -1794,10 +1794,10 @@ \begin{example} \begin{codeblock} struct S { - auto operator<=>(const S&, const S&) = default; // \#1 - bool operator<(const S&, const S&); // \#2 + friend auto operator<=>(const S&, const S&) = default; // \#1 + friend bool operator<(const S&, const S&); // \#2 }; -bool b = S() < S(); // calls \#2 +bool b = S() < S(); // calls \#2 \end{codeblock} \end{example} or, if not that, @@ -1810,10 +1810,10 @@ \begin{example} \begin{codeblock} struct S { - std::weak_ordering operator<=>(const S&, int); // \#1 - std::weak_ordering operator<=>(int, const S&); // \#2 + friend std::weak_ordering operator<=>(const S&, int); // \#1 + friend std::weak_ordering operator<=>(int, const S&); // \#2 }; -bool b = 1 < S(); // calls \#2 +bool b = 1 < S(); // calls \#2 \end{codeblock} \end{example} or, if not that @@ -2202,7 +2202,9 @@ \pnum The second standard conversion sequence converts the result of -the user-defined conversion to the target type for the sequence. +the user-defined conversion to the target type for the sequence; +any reference binding is included in the second standard +conversion sequence. Since an implicit conversion sequence is an initialization, the special rules for initialization by user-defined conversion apply when selecting the best user-defined conversion for a @@ -2609,7 +2611,7 @@ in the paragraph below, or, if not that, -\item \tcode{S1} and \tcode{S2} are reference bindings\iref{dcl.init.ref} and +\item \tcode{S1} and \tcode{S2} include reference bindings\iref{dcl.init.ref} and neither refers to an implicit object parameter of a non-static member function declared without a \grammarterm{ref-qualifier}, and \tcode{S1} binds an rvalue reference to an @@ -2643,7 +2645,7 @@ or, if not that, \item -\tcode{S1} and \tcode{S2} are reference bindings\iref{dcl.init.ref} and +\tcode{S1} and \tcode{S2} include reference bindings\iref{dcl.init.ref} and \tcode{S1} binds an lvalue reference to a function lvalue and \tcode{S2} binds an rvalue reference to a function lvalue \begin{example} @@ -2681,7 +2683,7 @@ \tcode{S1} and \tcode{S2} -are reference bindings\iref{dcl.init.ref}, and the types to which the references +include reference bindings\iref{dcl.init.ref}, and the types to which the references refer are the same type except for top-level cv-qualifiers, and the type to which the reference initialized by \tcode{S2} diff --git a/source/ranges.tex b/source/ranges.tex index 0bc5751273..6a1313fad0 100644 --- a/source/ranges.tex +++ b/source/ranges.tex @@ -15,17 +15,12 @@ \begin{libsumtab}{Ranges library summary}{tab:range.summary} \ref{range.access} & Range access & \tcode{} \\ - \ref{range.prim} & Range primitives & \\ \ref{range.req} & Requirements & \\ \ref{range.utility} & Range utilities & \\ + \ref{range.factories} & Range factories & \\ \ref{range.adaptors} & Range adaptors & \\ \end{libsumtab} -\pnum -Several places in this clause use the expression \tcode{\placeholdernc{DECAY_COPY}(x)} -with semantics as defined in \ref{thread.decaycopy}. - - \rSec1[ranges.syn]{Header \tcode{} synopsis} \indexlibrary{\idxhdr{ranges}}% @@ -45,7 +40,6 @@ inline constexpr @\unspec@ crbegin = @\unspec@; inline constexpr @\unspec@ crend = @\unspec@; - // \ref{range.prim}, range primitives inline constexpr @\unspec@ size = @\unspec@; inline constexpr @\unspec@ empty = @\unspec@; inline constexpr @\unspec@ data = @\unspec@; @@ -59,7 +53,7 @@ template using sentinel_t = decltype(ranges::end(declval())); - template<@\placeholder{fowarding-range}@ R> + template<@\placeholder{forwarding-range}@ R> using safe_iterator_t = iterator_t; template @@ -81,7 +75,7 @@ template concept View = @\seebelow@; - // \ref{range.refinements}, common range refinements + // \ref{range.refinements}, other range refinements template concept OutputRange = @\seebelow@; @@ -108,7 +102,7 @@ // \ref{view.interface}, class template \tcode{view_interface} template - requires is_class_v + requires is_class_v && Same> class view_interface; // \ref{range.subrange}, sub-ranges @@ -121,6 +115,30 @@ template<@\placeholder{forwarding-range}@ R> using safe_subrange_t = subrange>; + // \ref{range.empty}, empty view + template + requires is_object_v + class empty_view; + + namespace view { + template + inline constexpr empty_view empty{}; + } + + // \ref{range.single}, single view + template + requires is_object_v + class single_view; + + namespace view { inline constexpr @\unspec@ single = @\unspec@; } + + // \ref{range.iota}, iota view + template + requires @\placeholder{weakly-equality-comparable-with}@ + class iota_view; + + namespace view { inline constexpr @\unspec@ iota = @\unspec@; } + // \ref{range.all}, all view namespace view { inline constexpr @\unspec@ all = @\unspec@; } @@ -129,7 +147,7 @@ // \ref{range.filter}, filter view template> Pred> - requires View + requires View && is_object_v class filter_view; namespace view { inline constexpr @\unspec@ filter = @\unspec@; } @@ -142,13 +160,6 @@ namespace view { inline constexpr @\unspec@ transform = @\unspec@; } - // \ref{range.iota}, iota view - template - requires @\placeholder{weakly-equality-comparable-with}@ - class iota_view; - - namespace view { inline constexpr @\unspec@ iota = @\unspec@; } - // \ref{range.take}, take view template class take_view; @@ -163,23 +174,6 @@ namespace view { inline constexpr @\unspec@ join = @\unspec@; } - // \ref{range.empty}, empty view - template - requires is_object_v - class empty_view; - - namespace view { - template - inline constexpr empty_view empty {}; - } - - // \ref{range.single}, single view - template - requires is_object_v - class single_view; - - namespace view { inline constexpr @\unspec@ single = @\unspec@; } - // \ref{range.split}, split view template concept @\placeholder{tiny-range}@ = @\seebelow@; // \expos @@ -247,11 +241,11 @@ \item Otherwise, if \tcode{E} is an lvalue, - \tcode{\placeholdernc{DECAY_COPY}(E.begin())} + \tcode{\placeholdernc{decay-copy}(E.begin())} if it is a valid expression and its type \tcode{I} models \tcode{Iterator}. \item - Otherwise, \tcode{\placeholdernc{DECAY_COPY}(begin(E))} if it is a + Otherwise, \tcode{\placeholdernc{decay-copy}(begin(E))} if it is a valid expression and its type \tcode{I} models \tcode{Iterator} with overload resolution performed in a context that includes the declarations: \begin{codeblock} @@ -289,12 +283,12 @@ \item Otherwise, if \tcode{E} is an lvalue, - \tcode{\placeholdernc{DECAY_COPY}(E.end())} + \tcode{\placeholdernc{decay-copy}(E.end())} if it is a valid expression and its type \tcode{S} models \tcode{Sentinel}. \item - Otherwise, \tcode{\placeholdernc{DECAY_COPY}(end(E))} if it is a valid + Otherwise, \tcode{\placeholdernc{decay-copy}(end(E))} if it is a valid expression and its type \tcode{S} models \tcode{Sentinel} with overload resolution performed in a context that includes the declarations: @@ -367,11 +361,11 @@ \begin{itemize} \item - If \tcode{E} is an lvalue, \tcode{\placeholdernc{DECAY_COPY}(E.rbegin())} + If \tcode{E} is an lvalue, \tcode{\placeholdernc{decay-copy}(E.rbegin())} if it is a valid expression and its type \tcode{I} models \tcode{Iterator}. \item - Otherwise, \tcode{\placeholdernc{DECAY_COPY}(rbegin(E))} if it is a valid + Otherwise, \tcode{\placeholdernc{decay-copy}(rbegin(E))} if it is a valid expression and its type \tcode{I} models \tcode{Iterator} with overload resolution performed in a context that includes the declaration: \begin{codeblock} @@ -409,12 +403,12 @@ \begin{itemize} \item - If \tcode{E} is an lvalue, \tcode{\placeholdernc{DECAY_COPY}(E.rend())} + If \tcode{E} is an lvalue, \tcode{\placeholdernc{decay-copy}(E.rend())} if it is a valid expression and its type \tcode{S} models \tcode{Sentinel<\brk{}decltype(ranges::rbegin(E))>}. \item - Otherwise, \tcode{\placeholdernc{DECAY_COPY}(rend(E))} if it is a valid + Otherwise, \tcode{\placeholdernc{decay-copy}(rend(E))} if it is a valid expression and its type \tcode{S} models \tcode{Sentinel} with overload resolution performed in a context that includes the declaration: @@ -484,14 +478,7 @@ model \libconcept{Sentinel}. \end{note} -\rSec1[range.prim]{Range primitives} - -\pnum -In addition to being available via inclusion of the \tcode{} header, -the customization point objects in \ref{range.prim} are available -when \tcode{} is included. - -\rSec2[range.prim.size]{\tcode{size}} +\rSec2[range.prim.size]{\tcode{ranges::size}} \pnum The name \tcode{size} denotes a customization point object\iref{customization.point.object}. The expression @@ -500,7 +487,7 @@ \begin{itemize} \item - \tcode{\placeholdernc{DECAY_COPY}(extent_v)} if \tcode{T} is an array + \tcode{\placeholdernc{decay-copy}(extent_v)} if \tcode{T} is an array type\iref{basic.compound}. \item @@ -509,12 +496,12 @@ is \tcode{false}: \begin{itemize} \item - \tcode{\placeholdernc{DECAY_COPY}(E.size())} + \tcode{\placeholdernc{decay-copy}(E.size())} if it is a valid expression and its type \tcode{I} models \libconcept{Integral}. \item - Otherwise, \tcode{\placeholdernc{DECAY_COPY}(size(E))} + Otherwise, \tcode{\placeholdernc{decay-copy}(size(E))} if it is a valid expression and its type \tcode{I} models \libconcept{Integral} with overload resolution performed in a context that includes @@ -549,7 +536,7 @@ type models \libconcept{Integral}. \end{note} -\rSec2[range.prim.empty]{\tcode{empty}} +\rSec2[range.prim.empty]{\tcode{ranges::empty}} \pnum The name \tcode{empty} denotes a customization point object\iref{customization.point.object}. The expression @@ -584,7 +571,7 @@ it has type \tcode{bool}. \end{note} -\rSec2[range.prim.data]{\tcode{data}} +\rSec2[range.prim.data]{\tcode{ranges::data}} \pnum The name \tcode{data} denotes a customization point object\iref{customization.point.object}. The expression @@ -593,7 +580,7 @@ \begin{itemize} \item - If \tcode{E} is an lvalue, \tcode{\placeholdernc{DECAY_COPY}(E.data())} + If \tcode{E} is an lvalue, \tcode{\placeholdernc{decay-copy}(E.data())} if it is a valid expression of pointer to object type. \item @@ -619,7 +606,7 @@ has pointer to object type. \end{note} -\rSec2[range.prim.cdata]{\tcode{cdata}} +\rSec2[range.prim.cdata]{\tcode{ranges::cdata}} \pnum The name \tcode{cdata} denotes a customization point object\iref{customization.point.object}. The expression @@ -895,7 +882,7 @@ and \tcode{false} for types which do not. \end{itemdescr} -\rSec2[range.refinements]{Common range refinements} +\rSec2[range.refinements]{Other range refinements} \pnum The \tcode{OutputRange} concept specifies requirements of a @@ -986,17 +973,17 @@ \begin{codeblock} template - concept @\placeholder{simple-view}@ = + concept @\placeholder{simple-view}@ = // \expos View && Range && Same, iterator_t> && Same, sentinel_t>; template - concept @\placeholder{has-arrow}@ = + concept @\placeholder{has-arrow}@ = // \expos is_pointer_v || requires(I i) { i.operator->(); }; template - concept @\placeholder{not-same-as}@ = + concept @\placeholder{not-same-as}@ = // \expos !Same, remove_cvref_t>; \end{codeblock} @@ -1138,7 +1125,7 @@ template concept @\placeholdernc{pair-like}@ = // \expos !is_reference_v && requires(T t) { - typename tuple_size::type; // ensures tuple_size is complete + typename tuple_size::type; // ensures \tcode{tuple_size} is complete requires DerivedFrom, integral_constant>; typename tuple_element_t<0, remove_const_t>; typename tuple_element_t<1, remove_const_t>; @@ -1449,447 +1436,478 @@ \end{codeblock} \end{itemdescr} - -\rSec1[range.adaptors]{Range adaptors} +\rSec1[range.factories]{Range factories} \pnum -This subclause defines \term{range adaptors}, which are utilities that transform a -\libconcept{Range} into a \libconcept{View} with custom behaviors. These -adaptors can be chained to create pipelines of range transformations that -evaluate lazily as the resulting view is iterated. +This subclause defines \term{range factories}, +which are utilities to create a \libconcept{View}. \pnum -Range adaptors are declared in namespace \tcode{std::ranges::view}. +Range factories are declared in namespace \tcode{std::ranges::view}. + +\rSec2[range.empty]{Empty view} + +\rSec3[range.empty.overview]{Overview} \pnum -The bitwise \logop{OR} operator is overloaded for the purpose of creating adaptor chain -pipelines. The adaptors also support function call syntax with equivalent -semantics. +\tcode{empty_view} produces a \libconcept{View} of no elements of +a particular type. \pnum \begin{example} \begin{codeblock} -vector ints{0,1,2,3,4,5}; -auto even = [](int i){ return 0 == i % 2; }; -auto square = [](int i) { return i * i; }; -for (int i : ints | view::filter(even) | view::transform(square)) { - cout << i << ' '; // prints: 0 4 16 -} -assert(ranges::equal(ints | view::filter(even), view::filter(ints, even))); +empty_view e; +static_assert(ranges::empty(e)); +static_assert(0 == e.size()); \end{codeblock} \end{example} -\rSec2[range.adaptor.object]{Range adaptor objects} - -\pnum -A \term{range adaptor closure object} is a unary function object that accepts -a \libconcept{ViewableRange} argument and returns a \libconcept{View}. For -a range adaptor closure object \tcode{C} and an expression \tcode{R} such that -\tcode{decltype((R))} models \libconcept{ViewableRange}, the following -expressions are equivalent and yield a \libconcept{View}: +\rSec3[range.empty.view]{Class template \tcode{empty_view}} \begin{codeblock} -C(R) -R | C -\end{codeblock} - -Given an additional range adaptor closure object \tcode{D}, -the expression \tcode{C | D} is well-formed and produces another range adaptor -closure object such that the following two expressions are equivalent: +namespace std::ranges { + template + requires is_object_v + class empty_view : public view_interface> { + public: + static constexpr T* begin() noexcept { return nullptr; } + static constexpr T* end() noexcept { return nullptr; } + static constexpr T* data() noexcept { return nullptr; } + static constexpr ptrdiff_t size() noexcept { return 0; } + static constexpr bool empty() noexcept { return true; } -\begin{codeblock} -R | C | D -R | (C | D) + friend constexpr T* begin(empty_view) noexcept { return nullptr; } + friend constexpr T* end(empty_view) noexcept { return nullptr; } + }; +} \end{codeblock} -\pnum -A \term{range adaptor object} is a -customization point object\iref{customization.point.object} -that accepts a \libconcept{ViewableRange} as its first argument and returns a -\libconcept{View}. +\rSec2[range.single]{Single view} -\pnum -If a range adaptor object accepts only one argument, -then it is a range adaptor closure object. +\rSec3[range.single.overview]{Overview} \pnum -If a range adaptor object accepts more than one argument, -then the following expressions are equivalent: - -\begin{codeblock} -@\placeholdernc{adaptor}@(range, args...) -@\placeholdernc{adaptor}@(args...)(range) -range | @\placeholdernc{adaptor}@(args...) -\end{codeblock} - -In this case, \tcode{\placeholdernc{adaptor}(args...)} is a range adaptor -closure object. - -\rSec2[range.semi.wrap]{Semiregular wrapper} +\tcode{single_view} produces a \libconcept{View} that contains +exactly one element of a specified value. \pnum -Many of the types in this subclause are specified in terms of -an exposition-only class template \tcode{\placeholder{semiregular}}. -\tcode{\placeholder{semiregular}} behaves exactly like \tcode{optional} -with the following differences: - -\begin{itemize} -\item \tcode{\placeholder{semiregular}} constrains -its type parameter \tcode{T} with -\tcode{\libconcept{CopyConstructible} \&\& is_object_v}. - -\item If \tcode{T} models \libconcept{DefaultConstructible}, the default -constructor of \tcode{\placeholder{semiregular}} is equivalent to: +\begin{example} \begin{codeblock} -constexpr @\placeholder{semiregular}@() noexcept(is_nothrow_default_constructible_v) - : @\placeholder{semiregular}@{in_place} -{ } +single_view s{4}; +for (int i : s) + cout << i; // prints 4 \end{codeblock} +\end{example} -\item If \tcode{\libconcept{Assignable}} is not -satisfied, the copy assignment operator is equivalent to: -\begin{codeblock} -@\placeholder{semiregular}@& operator=(const @\placeholder{semiregular}@& that) - noexcept(is_nothrow_copy_constructible_v) -{ - if (that) emplace(*that); - else reset(); - return *this; -} -\end{codeblock} +\rSec3[range.single.view]{Class template \tcode{single_view}} -\item If \tcode{\libconcept{Assignable}} is not satisfied, -the move assignment operator is equivalent to: \begin{codeblock} -@\placeholder{semiregular}@& operator=(@\placeholder{semiregular}@&& that) - noexcept(is_nothrow_move_constructible_v) -{ - if (that) emplace(std::move(*that)); - else reset(); - return *this; +namespace std::ranges { + template + requires is_object_v + class single_view : public view_interface> { + private: + @\placeholdernc{semiregular}@ value_; // \expos + public: + single_view() = default; + constexpr explicit single_view(const T& t); + constexpr explicit single_view(T&& t); + template + requires Constructible + constexpr single_view(in_place_t, Args&&... args); + + constexpr T* begin() noexcept; + constexpr const T* begin() const noexcept; + constexpr T* end() noexcept; + constexpr const T* end() const noexcept; + static constexpr ptrdiff_t size() noexcept; + constexpr T* data() noexcept; + constexpr const T* data() const noexcept; + }; } \end{codeblock} -\end{itemize} -\rSec2[range.all]{All view} +\indexlibrary{\idxcode{single_view}!\idxcode{single_view}}% +\begin{itemdecl} +constexpr explicit single_view(const T& t); +\end{itemdecl} +\begin{itemdescr} \pnum -\tcode{view::all} returns a \libconcept{View} that includes all elements of -its \libconcept{Range} argument. +\effects Initializes \tcode{value_} with \tcode{t}. +\end{itemdescr} + +\indexlibrary{\idxcode{single_view}!\idxcode{single_view}}% +\begin{itemdecl} +constexpr explicit single_view(T&& t); +\end{itemdecl} +\begin{itemdescr} \pnum -The name \tcode{view::all} denotes a -range adaptor object\iref{range.adaptor.object}. -For some subexpression \tcode{E}, the expression -\tcode{view::all(E)} is expression-equivalent to: +\effects Initializes \tcode{value_} with \tcode{std::move(t)}. +\end{itemdescr} -\begin{itemize} -\item \tcode{\placeholdernc{DECAY_COPY}(E)} if the decayed type of \tcode{E} -models \libconcept{View}. +\indexlibrary{\idxcode{single_view}!\idxcode{single_view}}% +\begin{itemdecl} +template +constexpr single_view(in_place_t, Args&&... args); +\end{itemdecl} -\item Otherwise, \tcode{\placeholder{ref-view}\{E\}} if that -expression is well-formed, where \tcode{\placeholder{ref-view}} -is the exposition-only \libconcept{View} specified below. +\begin{itemdescr} +\pnum +\effects Initializes \tcode{value_} as if by +\tcode{value_\{in_place, std::forward(args)...\}}. +\end{itemdescr} -\item Otherwise, \tcode{subrange\{E\}}. -\end{itemize} +\indexlibrary{\idxcode{begin}!\idxcode{single_view}}% +\begin{itemdecl} +constexpr T* begin() noexcept; +constexpr const T* begin() const noexcept; +\end{itemdecl} -\rSec3[range.view.ref]{\placeholder{ref-view}} +\begin{itemdescr} +\pnum +\effects Equivalent to: \tcode{return data();} +\end{itemdescr} -\begin{codeblock} -namespace std::ranges { - template - requires is_object_v - class @\placeholder{ref-view}@ : public view_interface<@\placeholder{ref-view}@> { - private: - R* r_ = nullptr; // \expos - public: - constexpr @\placeholdernc{ref-view}@() noexcept = default; - - template<@\placeholder{not-same-as}@<@\placeholder{ref-view}@> T> - requires @\seebelow@ - constexpr @\placeholder{ref-view}@(T&& t); - - constexpr R& base() const { return *r_; } - - constexpr iterator_t begin() const { return ranges::begin(*r_); } - constexpr sentinel_t end() const { return ranges::end(*r_); } - - constexpr bool empty() const - requires requires { ranges::empty(*r_); } - { return ranges::empty(*r_); } - - constexpr auto size() const requires SizedRange - { return ranges::size(*r_); } - - constexpr auto data() const requires ContiguousRange - { return ranges::data(*r_); } - - friend constexpr iterator_t begin(@\placeholder{ref-view}@ r) - { return r.begin(); } +\indexlibrary{\idxcode{end}!\idxcode{single_view}}% +\begin{itemdecl} +constexpr T* end() noexcept; +constexpr const T* end() const noexcept; +\end{itemdecl} - friend constexpr sentinel_t end(@\placeholder{ref-view}@ r) - { return r.end(); } - }; -} -\end{codeblock} +\begin{itemdescr} +\pnum +\effects Equivalent to: \tcode{return data() + 1;} +\end{itemdescr} -\indexlibrary{\idxcode{\placeholder{ref-view}}!\idxcode{\placeholder{ref-view}}}% +\indexlibrary{\idxcode{size}!\idxcode{single_view}}% \begin{itemdecl} -template<@\placeholder{not-same-as}@<@\placeholder{ref-view}@> T> - requires @\seebelow@ -constexpr @\placeholder{ref-view}@(T&& t); +static constexpr ptrdiff_t size() noexcept; \end{itemdecl} \begin{itemdescr} \pnum -\remarks Let \tcode{\placeholder{FUN}} denote the exposition-only functions -\begin{codeblock} -void @\placeholder{FUN}@(R&); -void @\placeholder{FUN}@(R&&) = delete; -\end{codeblock} -The expression in the \grammarterm{requires-clause} is equivalent to -\begin{codeblock} -ConvertibleTo && requires { @\placeholder{FUN}@(declval()); } -\end{codeblock} +\effects Equivalent to: \tcode{return 1;} +\end{itemdescr} + +\indexlibrary{\idxcode{data}!\idxcode{single_view}}% +\begin{itemdecl} +constexpr T* data() noexcept; +constexpr const T* data() const noexcept; +\end{itemdecl} +\begin{itemdescr} \pnum -\effects -Initializes \tcode{r_} with -\tcode{addressof(static_cast(std::forward(t)))}. +\effects Equivalent to: \tcode{return value_.operator->();} \end{itemdescr} +\rSec3[range.single.adaptor]{\tcode{view::single}} -\rSec2[range.filter]{Filter view} +\pnum +The name \tcode{view::single} denotes a +customization point object\iref{customization.point.object}. +For some subexpression \tcode{E}, the expression +\tcode{view::single(E)} is expression-equivalent to +\tcode{single_view\{E\}}. -\rSec3[range.filter.overview]{Overview} +\rSec2[range.iota]{Iota view} + +\rSec3[range.iota.overview]{Overview} \pnum -\tcode{filter_view} presents a \libconcept{View} of an underlying sequence -without the elements that fail to satisfy a predicate. +\tcode{iota_view} generates a +sequence of elements by repeatedly incrementing an initial value. \pnum \begin{example} \begin{codeblock} -vector is{ 0, 1, 2, 3, 4, 5, 6 }; -filter_view evens{is, [](int i) { return 0 == i % 2; }}; -for (int i : evens) - cout << i << ' '; // prints: 0 2 4 6 +for (int i : iota_view{1, 10}) + cout << i << ' '; // prints: 1 2 3 4 5 6 7 8 9 \end{codeblock} \end{example} -\rSec3[range.filter.view]{Class template \tcode{filter_view}} +\rSec3[range.iota.view]{Class template \tcode{iota_view}} \begin{codeblock} namespace std::ranges { - template> Pred> - requires View && is_object_v - class filter_view : public view_interface> { - private: - V base_ = V(); // \expos - @\placeholdernc{semiregular}@ pred_; // \expos - - class iterator; // \expos - class sentinel; // \expos + template + concept @\placeholdernc{Decrementable}@ = // \expos + @\seebelow@; + template + concept @\placeholdernc{Advanceable}@ = // \expos + @\seebelow@; + template + requires @\placeholdernc{weakly-equality-comparable-with}@ + class iota_view : public view_interface> { + private: + struct iterator; // \expos + struct sentinel; // \expos + W value_ = W(); // \expos + Bound bound_ = Bound(); // \expos public: - filter_view() = default; - constexpr filter_view(V base, Pred pred); - template - requires ViewableRange && Constructible> - constexpr filter_view(R&& r, Pred pred); + iota_view() = default; + constexpr explicit iota_view(W value); + constexpr iota_view(type_identity_t value, + type_identity_t bound); - constexpr V base() const; + constexpr iterator begin() const; + constexpr sentinel end() const; + constexpr iterator end() const requires Same; - constexpr iterator begin(); - constexpr auto end() { - if constexpr (CommonRange) - return iterator{*this, ranges::end(base_)}; - else - return sentinel{*this}; - } + constexpr auto size() const + requires (Same && @\placeholdernc{Advanceable}@) || + (Integral && Integral) || + SizedSentinel + { return bound_ - value_; } }; - template - filter_view(R&&, Pred) -> filter_view, Pred>; + template + requires (!Integral || !Integral || is_signed_v == is_signed_v) + iota_view(W, Bound) -> iota_view; } \end{codeblock} -\indexlibrary{\idxcode{filter_view}!\idxcode{filter_view}}% +\pnum +The exposition-only \tcode{\placeholder{Decrementable}} concept is equivalent to: \begin{itemdecl} -constexpr filter_view(V base, Pred pred); +template + concept @\placeholder{Decrementable}@ = + Incrementable && requires(I i) { + { --i } -> Same; + { i-- } -> Same; + }; \end{itemdecl} \begin{itemdescr} \pnum -\effects Initializes \tcode{base_} with \tcode{std::move(base)} and initializes -\tcode{pred_} with \tcode{std::move(pred)}. +When an object is in the domain of both pre- and post-decrement, +the object is said to be \term{decrementable}. + +\pnum +Let \tcode{a} and \tcode{b} be equal objects of type \tcode{I}. +\tcode{I} models \tcode{\placeholdernc{Decrementable}} only if +\begin{itemize} +\item If \tcode{a} and \tcode{b} are decrementable, + then the following are all true: + \begin{itemize} + \item \tcode{addressof(--a) == addressof(a)} + \item \tcode{bool(a-- == b)} + \item \tcode{bool(((void)a--, a) == --b)} + \item \tcode{bool(++(--a) == b)}. + \end{itemize} +\item If \tcode{a} and \tcode{b} are incrementable, + then \tcode{bool(--(++a) == b)}. +\end{itemize} \end{itemdescr} -\indexlibrary{\idxcode{filter_view}!\idxcode{filter_view}}% +\pnum +The exposition-only \tcode{\placeholder{Advanceable}} concept is equivalent to: \begin{itemdecl} -template - requires ViewableRange && Constructible> -constexpr filter_view(R&& r, Pred pred); +template + concept @\placeholder{Advanceable}@ = + @\placeholdernc{Decrementable}@ && StrictTotallyOrdered && + requires(I i, const I j, const iter_difference_t n) { + { i += n } -> Same; + { i -= n } -> Same; + { j + n } -> Same; + { n + j } -> Same; + { j - n } -> Same; + { j - j } -> Same>; + }; \end{itemdecl} -\begin{itemdescr} -\pnum -\effects Initializes \tcode{base_} with \tcode{view::all(std::forward(r))} -and initializes \tcode{pred_} with \tcode{std::\brk{}move(pred)}. -\end{itemdescr} +Let \tcode{a} and \tcode{b} be objects of type \tcode{I} such that +\tcode{b} is reachable from \tcode{a} +after \tcode{n} applications of \tcode{++a}, +for some value \tcode{n} of type \tcode{iter_difference_t}, +and let \tcode{D} be \tcode{iter_difference_t}. +\tcode{I} models \tcode{\placeholdernc{Advanceable}} only if +\begin{itemize} +\item \tcode{(a += n)} is equal to \tcode{b}. +\item \tcode{addressof(a += n)} is equal to \tcode{addressof(a)}. +\item \tcode{(a + n)} is equal to \tcode{(a += n)}. +\item For any two positive values + \tcode{x} and \tcode{y} of type \tcode{D}, + if \tcode{(a + D(x + y))} is well-defined, then + \tcode{(a + D(x + y))} is equal to \tcode{((a + x) + y)}. +\item \tcode{(a + D(0))} is equal to \tcode{a}. +\item If \tcode{(a + D(n - 1))} is well-defined, then + \tcode{(a + n)} is equal to \tcode{++(a + D(n - 1))}. +\item \tcode{(b += -n)} is equal to \tcode{a}. +\item \tcode{(b -= n)} is equal to \tcode{a}. +\item \tcode{addressof(b -= n)} is equal to \tcode{addressof(b)}. +\item \tcode{(b - n)} is equal to \tcode{(b -= n)}. +\item \tcode{(b - a)} is equal to \tcode{n}. +\item \tcode{(a - b)} is equal to \tcode{-n}. +\item \tcode{bool(a <= b)} is \tcode{true}. +\end{itemize} -\indexlibrary{\idxcode{base}!\idxcode{filter_view}}% +\indexlibrary{\idxcode{iota_view}!\idxcode{iota_view}}% \begin{itemdecl} -constexpr V base() const; +constexpr explicit iota_view(W value); \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return base_;} +\expects +\tcode{Bound} denotes \tcode{unreachable_sentinel_t} or +\tcode{Bound()} is reachable from \tcode{value}. + +\pnum +\effects Initializes \tcode{value_} with \tcode{value}. \end{itemdescr} -\indexlibrary{\idxcode{begin}!\idxcode{filter_view}}% +\indexlibrary{\idxcode{iota_view}!\idxcode{iota_view}}% \begin{itemdecl} -constexpr iterator begin(); +constexpr iota_view(type_identity_t value, type_identity_t bound); \end{itemdecl} \begin{itemdescr} \pnum \expects -\tcode{pred_.has_value()}. +\tcode{Bound} denotes \tcode{unreachable_sentinel_t} or +\tcode{bound} is reachable from \tcode{value}. \pnum -\returns -\tcode{\{*this, ranges::find_if(base_, ref(*pred_))\}}. +\effects Initializes \tcode{value_} with \tcode{value} and +\tcode{bound_} with \tcode{bound}. +\end{itemdescr} + +\indexlibrary{\idxcode{begin}!\idxcode{iota_view}}% +\begin{itemdecl} +constexpr iterator begin() const; +\end{itemdecl} +\begin{itemdescr} \pnum -\remarks In order to provide the amortized constant time complexity required by -the \libconcept{Range} concept, this function caches the result within the -\tcode{filter_view} for use on subsequent calls. +\effects Equivalent to: \tcode{return iterator\{value_\};} \end{itemdescr} -\rSec3[range.filter.iterator]{Class \tcode{filter_view::iterator}} +\indexlibrary{\idxcode{end}!\idxcode{iota_view}}% +\begin{itemdecl} +constexpr sentinel end() const; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects Equivalent to: \tcode{return sentinel\{bound_\};} +\end{itemdescr} + +\indexlibrary{\idxcode{end}!\idxcode{iota_view}}% +\begin{itemdecl} +constexpr iterator end() const requires Same; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects Equivalent to: \tcode{return iterator\{bound_\};} +\end{itemdescr} + +\rSec3[range.iota.iterator]{Class \tcode{iota_view::iterator}} -\indexlibrary{\idxcode{iterator}!\idxcode{filter_view}}% \begin{codeblock} namespace std::ranges { - template - class filter_view::iterator { + template + struct iota_view::iterator { private: - iterator_t current_ = iterator_t(); // \expos - filter_view* parent_ = nullptr; // \expos + W value_ = W(); // \expos public: - using iterator_concept = @\seebelow@; using iterator_category = @\seebelow@; - using value_type = iter_value_t>; - using difference_type = iter_difference_t>; + using value_type = W; + using difference_type = iter_difference_t; iterator() = default; - constexpr iterator(filter_view& parent, iterator_t current); + constexpr explicit iterator(W value); - constexpr iterator_t base() const; - constexpr iter_reference_t> operator*() const; - constexpr iterator_t operator->() const - requires @\placeholder{has-arrow}@>; + constexpr W operator*() const noexcept(is_nothrow_copy_constructible_v); constexpr iterator& operator++(); constexpr void operator++(int); - constexpr iterator operator++(int) requires ForwardRange; + constexpr iterator operator++(int) requires Incrementable; - constexpr iterator& operator--() requires BidirectionalRange; - constexpr iterator operator--(int) requires BidirectionalRange; + constexpr iterator& operator--() requires @\placeholdernc{Decrementable}@; + constexpr iterator operator--(int) requires @\placeholdernc{Decrementable}@; + + constexpr iterator& operator+=(difference_type n) + requires @\placeholdernc{Advanceable}@; + constexpr iterator& operator-=(difference_type n) + requires @\placeholdernc{Advanceable}@; + constexpr W operator[](difference_type n) const + requires @\placeholdernc{Advanceable}@; friend constexpr bool operator==(const iterator& x, const iterator& y) - requires EqualityComparable>; + requires EqualityComparable; friend constexpr bool operator!=(const iterator& x, const iterator& y) - requires EqualityComparable>; + requires EqualityComparable; - friend constexpr iter_rvalue_reference_t> iter_move(const iterator& i) - noexcept(noexcept(ranges::iter_move(i.current_))); - friend constexpr void iter_swap(const iterator& x, const iterator& y) - noexcept(noexcept(ranges::iter_swap(x.current_, y.current_))) - requires IndirectlySwappable>; + friend constexpr bool operator<(const iterator& x, const iterator& y) + requires StrictTotallyOrdered; + friend constexpr bool operator>(const iterator& x, const iterator& y) + requires StrictTotallyOrdered; + friend constexpr bool operator<=(const iterator& x, const iterator& y) + requires StrictTotallyOrdered; + friend constexpr bool operator>=(const iterator& x, const iterator& y) + requires StrictTotallyOrdered; + + friend constexpr iterator operator+(iterator i, difference_type n) + requires @\placeholdernc{Advanceable}@; + friend constexpr iterator operator+(difference_type n, iterator i) + requires @\placeholdernc{Advanceable}@; + + friend constexpr iterator operator-(iterator i, difference_type n) + requires @\placeholdernc{Advanceable}@; + friend constexpr difference_type operator-(const iterator& x, const iterator& y) + requires @\placeholdernc{Advanceable}@; }; } \end{codeblock} -\pnum -Modification of the element a \tcode{filter_view::iterator} denotes is -permitted, but results in undefined behavior if the resulting value does not -satisfy the filter predicate. - -\pnum -\tcode{iterator::iterator_concept} is defined as follows: -\begin{itemize} -\item If \tcode{V} models \libconcept{BidirectionalRange}, then -\tcode{iterator_concept} denotes \tcode{bidirectional_iterator_tag}. - -\item Otherwise, if \tcode{V} models \libconcept{ForwardRange}, then -\tcode{iterator_concept} denotes \tcode{forward_iterator_tag}. - -\item Otherwise, \tcode{iterator_concept} denotes \tcode{input_iterator_tag}. -\end{itemize} - \pnum \tcode{iterator::iterator_category} is defined as follows: \begin{itemize} -\item Let \tcode{C} denote the type -\tcode{iterator_traits>::iterator_category}. - -\item If \tcode{C} models \tcode{DerivedFrom}, -then \tcode{iterator_category} denotes \tcode{bi\-directional_iterator_tag}. - -\item Otherwise, if \tcode{C} models \tcode{DerivedFrom}, -then \tcode{iterator_category} denotes \tcode{forward_iterator_tag}. - -\item Otherwise, \tcode{iterator_category} denotes \tcode{input_iterator_tag}. +\item If \tcode{W} models \tcode{\placeholder{Advanceable}}, then +\tcode{iterator_category} is \tcode{random_access_iterator_tag}. +\item Otherwise, if \tcode{W} models \tcode{\placeholder{Decrementable}}, then +\tcode{iterator_category} is \tcode{bidirectional_iterator_tag}. +\item Otherwise, if \tcode{W} models \libconcept{Incrementable}, then +\tcode{iterator_category} is \tcode{forward_iterator_tag}. +\item Otherwise, \tcode{iterator_category} is \tcode{input_iterator_tag}. \end{itemize} -\indexlibrary{\idxcode{iterator}!\idxcode{filter_view::iterator}}% -\begin{itemdecl} -constexpr iterator(filter_view& parent, iterator_t current); -\end{itemdecl} - -\begin{itemdescr} \pnum -\effects Initializes \tcode{current_} with \tcode{current} and -\tcode{parent_} with \tcode{addressof(parent)}. -\end{itemdescr} +\begin{note} +Overloads for \tcode{iter_move} and \tcode{iter_swap} are omitted intentionally. +\end{note} -\indexlibrary{\idxcode{base}!\idxcode{filter_view::iterator}}% +\indexlibrary{\idxcode{iterator}!\idxcode{iota_view::iterator}} \begin{itemdecl} -constexpr iterator_t base() const; +constexpr explicit iterator(W value); \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return current_;} +\effects Initializes \tcode{value_} with \tcode{value}. \end{itemdescr} -\indexlibrary{\idxcode{operator*}!\idxcode{filter_view::iterator}}% +\indexlibrary{\idxcode{operator*}!\idxcode{iota_view::iterator}} \begin{itemdecl} -constexpr iter_reference_t> operator*() const; +constexpr W operator*() const noexcept(is_nothrow_copy_constructible_v); \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return *current_;} -\end{itemdescr} - -\indexlibrary{\idxcode{operator->}!\idxcode{filter_view::iterator}}% -\begin{itemdecl} -constexpr iterator_t operator->() const - requires @\placeholder{has-arrow}@>; -\end{itemdecl} +\effects Equivalent to: \tcode{return value_;} -\begin{itemdescr} \pnum -\effects -Equivalent to: \tcode{return current_;} +\begin{note} +The \tcode{noexcept} clause is needed by the default \tcode{iter_move} +implementation. +\end{note} \end{itemdescr} -\indexlibrary{\idxcode{operator++}!\idxcode{filter_view::iterator}}% +\indexlibrary{\idxcode{operator++}!\idxcode{iota_view::iterator}} \begin{itemdecl} constexpr iterator& operator++(); \end{itemdecl} @@ -1898,12 +1916,12 @@ \pnum \effects Equivalent to: \begin{codeblock} -current_ = ranges::find_if(++current_, ranges::end(parent_->base_), ref(*parent_->pred_)); +++value_; return *this; \end{codeblock} \end{itemdescr} -\indexlibrary{\idxcode{operator++}!\idxcode{filter_view::iterator}}% +\indexlibrary{\idxcode{operator++}!\idxcode{iota_view::iterator}} \begin{itemdecl} constexpr void operator++(int); \end{itemdecl} @@ -1913,9 +1931,9 @@ \effects Equivalent to \tcode{++*this}. \end{itemdescr} -\indexlibrary{\idxcode{operator++}!\idxcode{filter_view::iterator}}% +\indexlibrary{\idxcode{operator++}!\idxcode{iota_view::iterator}} \begin{itemdecl} -constexpr iterator operator++(int) requires ForwardRange; +constexpr iterator operator++(int) requires Incrementable; \end{itemdecl} \begin{itemdescr} @@ -1928,25 +1946,23 @@ \end{codeblock} \end{itemdescr} -\indexlibrary{\idxcode{operator\dcr}!\idxcode{filter_view::iterator}}% +\indexlibrary{\idxcode{operator\dcr}!\idxcode{iota_view::iterator}} \begin{itemdecl} -constexpr iterator& operator--() requires BidirectionalRange; +constexpr iterator& operator--() requires @\placeholdernc{Decrementable}@; \end{itemdecl} \begin{itemdescr} \pnum \effects Equivalent to: \begin{codeblock} -do - --current_; -while (!invoke(*parent_->pred_, *current_)); +--value_; return *this; \end{codeblock} \end{itemdescr} -\indexlibrary{\idxcode{operator\dcr}!\idxcode{filter_view::iterator}}% +\indexlibrary{\idxcode{operator\dcr}!\idxcode{iota_view::iterator}} \begin{itemdecl} -constexpr iterator operator--(int) requires BidirectionalRange; +constexpr iterator operator--(int) requires @\placeholdernc{Decrementable}@; \end{itemdecl} \begin{itemdescr} @@ -1959,422 +1975,610 @@ \end{codeblock} \end{itemdescr} -\indexlibrary{\idxcode{operator==}!\idxcode{filter_view::iterator}}% +\indexlibrary{\idxcode{operator+=}!\idxcode{iota_view::iterator}} \begin{itemdecl} -friend constexpr bool operator==(const iterator& x, const iterator& y) - requires EqualityComparable>; +constexpr iterator& operator+=(difference_type n) + requires @\placeholdernc{Advanceable}@; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return x.current_ == y.current_;} +\effects Equivalent to: +\begin{codeblock} +value_ += n; +return *this; +\end{codeblock} \end{itemdescr} -\indexlibrary{\idxcode{operator!=}!\idxcode{filter_view::iterator}}% +\indexlibrary{\idxcode{operator-=}!\idxcode{iota_view::iterator}} \begin{itemdecl} -friend constexpr bool operator!=(const iterator& x, const iterator& y) - requires EqualityComparable>; +constexpr iterator& operator-=(difference_type n) + requires @\placeholdernc{Advanceable}@; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return !(x == y);} +\effects Equivalent to: +\begin{codeblock} +value_ -= n; +return *this; +\end{codeblock} \end{itemdescr} -\indexlibrary{\idxcode{iter_move}!\idxcode{filter_view::iterator}}% +\indexlibrary{\idxcode{operator[]}!\idxcode{iota_view::iterator}} \begin{itemdecl} -friend constexpr iter_rvalue_reference_t> iter_move(const iterator& i) - noexcept(noexcept(ranges::iter_move(i.current_))); +constexpr W operator[](difference_type n) const + requires @\placeholdernc{Advanceable}@; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return ranges::iter_move(i.current_);} +\effects Equivalent to: \tcode{return value_ + n;} \end{itemdescr} -\indexlibrary{\idxcode{iter_swap}!\idxcode{filter_view::iterator}}% +\indexlibrary{\idxcode{operator==}!\idxcode{iota_view::iterator}} \begin{itemdecl} -friend constexpr void iter_swap(const iterator& x, const iterator& y) - noexcept(noexcept(ranges::iter_swap(x.current_, y.current_))) - requires IndirectlySwappable>; +friend constexpr bool operator==(const iterator& x, const iterator& y) + requires EqualityComparable; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to \tcode{ranges::iter_swap(x.current_, y.current_)}. +\effects Equivalent to: \tcode{return x.value_ == y.value_;} \end{itemdescr} -\rSec3[range.filter.sentinel]{Class \tcode{filter_view::sentinel}} - -\indexlibrary{\idxcode{sentinel}!\idxcode{filter_view}}% -\begin{codeblock} -namespace std::ranges { - template - class filter_view::sentinel { - private: - sentinel_t end_ = sentinel_t(); // \expos - public: - sentinel() = default; - constexpr explicit sentinel(filter_view& parent); - - constexpr sentinel_t base() const; - - friend constexpr bool operator==(const iterator& x, const sentinel& y); - friend constexpr bool operator==(const sentinel& x, const iterator& y); - friend constexpr bool operator!=(const iterator& x, const sentinel& y); - friend constexpr bool operator!=(const sentinel& x, const iterator& y); - }; -} -\end{codeblock} - -\indexlibrary{\idxcode{sentinel}!\idxcode{filter_view::sentinel}}% +\indexlibrary{\idxcode{operator!=}!\idxcode{iota_view::iterator}} \begin{itemdecl} -constexpr explicit sentinel(filter_view& parent); +friend constexpr bool operator!=(const iterator& x, const iterator& y) + requires EqualityComparable; \end{itemdecl} \begin{itemdescr} \pnum -\effects Initializes \tcode{end_} with \tcode{ranges::end(parent)}. +\effects Equivalent to: \tcode{return !(x == y);} \end{itemdescr} -\indexlibrary{\idxcode{base}!\idxcode{filter_view::sentinel}}% +\indexlibrary{\idxcode{operator<}!\idxcode{iota_view::iterator}} \begin{itemdecl} -constexpr sentinel_t base() const; +friend constexpr bool operator<(const iterator& x, const iterator& y) + requires StrictTotallyOrdered; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return end_;} +\effects Equivalent to: \tcode{return x.value_ < y.value_;} \end{itemdescr} -\indexlibrary{\idxcode{operator==}!\idxcode{filter_view::sentinel}}% +\indexlibrary{\idxcode{operator>}!\idxcode{iota_view::iterator}} \begin{itemdecl} -friend constexpr bool operator==(const iterator& x, const sentinel& y); +friend constexpr bool operator>(const iterator& x, const iterator& y) + requires StrictTotallyOrdered; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return x.current_ == y.end_;} +\effects Equivalent to: \tcode{return y < x;} \end{itemdescr} -\indexlibrary{\idxcode{operator==}!\idxcode{filter_view::sentinel}}% +\indexlibrary{\idxcode{operator<=}!\idxcode{iota_view::iterator}} \begin{itemdecl} -friend constexpr bool operator==(const sentinel& x, const iterator& y); +friend constexpr bool operator<=(const iterator& x, const iterator& y) + requires StrictTotallyOrdered; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return y == x;} +\effects Equivalent to: \tcode{return !(y < x);} \end{itemdescr} -\indexlibrary{\idxcode{operator!=}!\idxcode{filter_view::sentinel}}% +\indexlibrary{\idxcode{operator>=}!\idxcode{iota_view::iterator}} \begin{itemdecl} -friend constexpr bool operator!=(const iterator& x, const sentinel& y); +friend constexpr bool operator>=(const iterator& x, const iterator& y) + requires StrictTotallyOrdered; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return !(x == y);} +\effects Equivalent to: \tcode{return !(x < y);} \end{itemdescr} -\indexlibrary{\idxcode{operator!=}!\idxcode{filter_view::sentinel}}% +\indexlibrary{\idxcode{operator+}!\idxcode{iota_view::iterator}} \begin{itemdecl} -friend constexpr bool operator!=(const sentinel& x, const iterator& y); +friend constexpr iterator operator+(iterator i, difference_type n) + requires @\placeholdernc{Advanceable}@; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return !(y == x);} +\effects Equivalent to: \tcode{return iterator\{i.value_ + n\};} \end{itemdescr} -\rSec3[range.filter.adaptor]{\tcode{view::filter}} +\indexlibrary{\idxcode{operator+}!\idxcode{iota_view::iterator}} +\begin{itemdecl} +friend constexpr iterator operator+(difference_type n, iterator i) + requires @\placeholdernc{Advanceable}@; +\end{itemdecl} +\begin{itemdescr} \pnum -The name \tcode{view::filter} denotes a -range adaptor object\iref{range.adaptor.object}. -For some subexpressions \tcode{E} and \tcode{P}, -the expression \tcode{view::filter(E, P)} is expression-equivalent to -\tcode{filter_view\{E, P\}}. - - -\rSec2[range.transform]{Transform view} +\effects Equivalent to: \tcode{return i + n;} +\end{itemdescr} -\rSec3[range.transform.overview]{Overview} +\indexlibrary{\idxcode{operator-}!\idxcode{iota_view::iterator}} +\begin{itemdecl} +friend constexpr iterator operator-(iterator i, difference_type n) + requires @\placeholdernc{Advanceable}@; +\end{itemdecl} +\begin{itemdescr} \pnum -\tcode{transform_view} presents -a \libconcept{View} of an underlying sequence after -applying a transformation function to each element. +\effects Equivalent to: \tcode{return i + -n;} +\end{itemdescr} +\indexlibrary{\idxcode{operator-}!\idxcode{iota_view::iterator}} +\begin{itemdecl} +friend constexpr difference_type operator-(const iterator& x, const iterator& y) + requires @\placeholdernc{Advanceable}@; +\end{itemdecl} + +\begin{itemdescr} \pnum -\begin{example} -\begin{codeblock} -vector is{ 0, 1, 2, 3, 4 }; -transform_view squares{is, [](int i) { return i * i; }}; -for (int i : squares) - cout << i << ' '; // prints: 0 1 4 9 16 -\end{codeblock} -\end{example} +\effects Equivalent to: \tcode{return x.value_ - y.value_;} +\end{itemdescr} -\rSec3[range.transform.view]{Class template \tcode{transform_view}} +\rSec3[range.iota.sentinel]{Class \tcode{iota_view::sentinel}} \begin{codeblock} namespace std::ranges { - template - requires View && is_object_v && - RegularInvocable>> - class transform_view : public view_interface> { + template + struct iota_view::sentinel { private: - template struct iterator; // \expos - template struct sentinel; // \expos - - V base_ = V(); // \expos - @\placeholdernc{semiregular}@ fun_; // \expos - + Bound bound_ = Bound(); // \expos public: - transform_view() = default; - constexpr transform_view(V base, F fun); - template - requires ViewableRange && Constructible> - constexpr transform_view(R&& r, F fun); - - constexpr V base() const; - - constexpr iterator begin(); - constexpr iterator begin() const - requires Range && - RegularInvocable>>; - - constexpr sentinel end(); - constexpr iterator end() requires CommonRange; - constexpr sentinel end() const - requires Range && - RegularInvocable>>; - constexpr iterator end() const - requires CommonRange && - RegularInvocable>>; + sentinel() = default; + constexpr explicit sentinel(Bound bound); - constexpr auto size() requires SizedRange { return ranges::size(base_); } - constexpr auto size() const requires SizedRange - { return ranges::size(base_); } + friend constexpr bool operator==(const iterator& x, const sentinel& y); + friend constexpr bool operator==(const sentinel& x, const iterator& y); + friend constexpr bool operator!=(const iterator& x, const sentinel& y); + friend constexpr bool operator!=(const sentinel& x, const iterator& y); }; - - template - transform_view(R&&, F) -> transform_view, F>; } \end{codeblock} -\indexlibrary{\idxcode{transform_view}!\idxcode{transform_view}}% +\indexlibrary{\idxcode{sentinel}!\idxcode{iota_view::sentinel}} \begin{itemdecl} -constexpr transform_view(V base, F fun); +constexpr explicit sentinel(Bound bound); \end{itemdecl} \begin{itemdescr} \pnum -\effects Initializes \tcode{base_} with \tcode{std::move(base)} and -\tcode{fun_} with \tcode{std::move(fun)}. +\effects Initializes \tcode{bound_} with \tcode{bound}. \end{itemdescr} -\indexlibrary{\idxcode{transform_view}!\idxcode{transform_view}}% +\indexlibrary{\idxcode{operator==}!\idxcode{iota_view::sentinel}} \begin{itemdecl} -template - requires ViewableRange && Constructible> -constexpr transform_view(R&& r, F fun); +friend constexpr bool operator==(const iterator& x, const sentinel& y); \end{itemdecl} \begin{itemdescr} \pnum -\effects Initializes \tcode{base_} with \tcode{view::all(std::forward(r))} -and \tcode{fun_} with \tcode{std::move(fun)}. +\effects Equivalent to: \tcode{return x.value_ == y.bound_;} \end{itemdescr} -\indexlibrary{\idxcode{base}!\idxcode{transform_view}}% +\indexlibrary{\idxcode{operator==}!\idxcode{iota_view::sentinel}} \begin{itemdecl} -constexpr V base() const; +friend constexpr bool operator==(const sentinel& x, const iterator& y); \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return base_;} +\effects Equivalent to: \tcode{return y == x;} \end{itemdescr} -\indexlibrary{\idxcode{begin}!\idxcode{transform_view}}% +\indexlibrary{\idxcode{operator!=}!\idxcode{iota_view::sentinel}} \begin{itemdecl} -constexpr iterator begin(); +friend constexpr bool operator!=(const iterator& x, const sentinel& y); \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: +\effects Equivalent to: \tcode{return !(x == y);} +\end{itemdescr} + +\indexlibrary{\idxcode{operator!=}!\idxcode{iota_view::sentinel}} +\begin{itemdecl} +friend constexpr bool operator!=(const sentinel& x, const iterator& y); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects Equivalent to: \tcode{return !(y == x);} +\end{itemdescr} + +\rSec3[range.iota.adaptor]{\tcode{view::iota}} + +\pnum +The name \tcode{view::iota} denotes a +customization point object\iref{customization.point.object}. +For some subexpressions \tcode{E} and \tcode{F}, the expressions +\tcode{view::iota(E)} and \tcode{view::iota(E, F)} +are expression-equivalent to +\tcode{iota_view\{E\}} and \tcode{iota_view\{E, F\}}, respectively. + +\rSec1[range.adaptors]{Range adaptors} + +\pnum +This subclause defines \term{range adaptors}, which are utilities that transform a +\libconcept{Range} into a \libconcept{View} with custom behaviors. These +adaptors can be chained to create pipelines of range transformations that +evaluate lazily as the resulting view is iterated. + +\pnum +Range adaptors are declared in namespace \tcode{std::ranges::view}. + +\pnum +The bitwise \logop{OR} operator is overloaded for the purpose of creating adaptor chain +pipelines. The adaptors also support function call syntax with equivalent +semantics. + +\pnum +\begin{example} \begin{codeblock} -return iterator{*this, ranges::begin(base_)}; +vector ints{0,1,2,3,4,5}; +auto even = [](int i){ return 0 == i % 2; }; +auto square = [](int i) { return i * i; }; +for (int i : ints | view::filter(even) | view::transform(square)) { + cout << i << ' '; // prints: 0 4 16 +} +assert(ranges::equal(ints | view::filter(even), view::filter(ints, even))); \end{codeblock} -\end{itemdescr} +\end{example} -\indexlibrary{\idxcode{begin}!\idxcode{transform_view}}% +\rSec2[range.adaptor.object]{Range adaptor objects} + +\pnum +A \term{range adaptor closure object} is a unary function object that accepts +a \libconcept{ViewableRange} argument and returns a \libconcept{View}. For +a range adaptor closure object \tcode{C} and an expression \tcode{R} such that +\tcode{decltype((R))} models \libconcept{ViewableRange}, the following +expressions are equivalent and yield a \libconcept{View}: + +\begin{codeblock} +C(R) +R | C +\end{codeblock} + +Given an additional range adaptor closure object \tcode{D}, +the expression \tcode{C | D} is well-formed and produces another range adaptor +closure object such that the following two expressions are equivalent: + +\begin{codeblock} +R | C | D +R | (C | D) +\end{codeblock} + +\pnum +A \term{range adaptor object} is a +customization point object\iref{customization.point.object} +that accepts a \libconcept{ViewableRange} as its first argument and returns a +\libconcept{View}. + +\pnum +If a range adaptor object accepts only one argument, +then it is a range adaptor closure object. + +\pnum +If a range adaptor object accepts more than one argument, +then the following expressions are equivalent: + +\begin{codeblock} +@\placeholdernc{adaptor}@(range, args...) +@\placeholdernc{adaptor}@(args...)(range) +range | @\placeholdernc{adaptor}@(args...) +\end{codeblock} + +In this case, \tcode{\placeholdernc{adaptor}(args...)} is a range adaptor +closure object. + +\rSec2[range.semi.wrap]{Semiregular wrapper} + +\pnum +Many of the types in this subclause are specified in terms of +an exposition-only class template \tcode{\placeholder{semiregular}}. +\tcode{\placeholder{semiregular}} behaves exactly like \tcode{optional} +with the following differences: + +\begin{itemize} +\item \tcode{\placeholder{semiregular}} constrains +its type parameter \tcode{T} with +\tcode{\libconcept{CopyConstructible} \&\& is_object_v}. + +\item If \tcode{T} models \libconcept{DefaultConstructible}, the default +constructor of \tcode{\placeholder{semiregular}} is equivalent to: +\begin{codeblock} +constexpr @\placeholder{semiregular}@() noexcept(is_nothrow_default_constructible_v) + : @\placeholder{semiregular}@{in_place} +{ } +\end{codeblock} + +\item If \tcode{\libconcept{Assignable}} is not +satisfied, the copy assignment operator is equivalent to: +\begin{codeblock} +@\placeholder{semiregular}@& operator=(const @\placeholder{semiregular}@& that) + noexcept(is_nothrow_copy_constructible_v) +{ + if (that) emplace(*that); + else reset(); + return *this; +} +\end{codeblock} + +\item If \tcode{\libconcept{Assignable}} is not satisfied, +the move assignment operator is equivalent to: +\begin{codeblock} +@\placeholder{semiregular}@& operator=(@\placeholder{semiregular}@&& that) + noexcept(is_nothrow_move_constructible_v) +{ + if (that) emplace(std::move(*that)); + else reset(); + return *this; +} +\end{codeblock} +\end{itemize} + +\rSec2[range.all]{All view} + +\pnum +\tcode{view::all} returns a \libconcept{View} that includes all elements of +its \libconcept{Range} argument. + +\pnum +The name \tcode{view::all} denotes a +range adaptor object\iref{range.adaptor.object}. +For some subexpression \tcode{E}, the expression +\tcode{view::all(E)} is expression-equivalent to: + +\begin{itemize} +\item \tcode{\placeholdernc{decay-copy}(E)} if the decayed type of \tcode{E} +models \libconcept{View}. + +\item Otherwise, \tcode{\placeholder{ref-view}\{E\}} if that +expression is well-formed, where \tcode{\placeholder{ref-view}} +is the exposition-only \libconcept{View} specified below. + +\item Otherwise, \tcode{subrange\{E\}}. +\end{itemize} + +\rSec3[range.view.ref]{\placeholder{ref-view}} + +\begin{codeblock} +namespace std::ranges { + template + requires is_object_v + class @\placeholder{ref-view}@ : public view_interface<@\placeholder{ref-view}@> { + private: + R* r_ = nullptr; // \expos + public: + constexpr @\placeholdernc{ref-view}@() noexcept = default; + + template<@\placeholder{not-same-as}@<@\placeholder{ref-view}@> T> + requires @\seebelow@ + constexpr @\placeholder{ref-view}@(T&& t); + + constexpr R& base() const { return *r_; } + + constexpr iterator_t begin() const { return ranges::begin(*r_); } + constexpr sentinel_t end() const { return ranges::end(*r_); } + + constexpr bool empty() const + requires requires { ranges::empty(*r_); } + { return ranges::empty(*r_); } + + constexpr auto size() const requires SizedRange + { return ranges::size(*r_); } + + constexpr auto data() const requires ContiguousRange + { return ranges::data(*r_); } + + friend constexpr iterator_t begin(@\placeholder{ref-view}@ r) + { return r.begin(); } + + friend constexpr sentinel_t end(@\placeholder{ref-view}@ r) + { return r.end(); } + }; +} +\end{codeblock} + +\indexlibrary{\idxcode{\placeholder{ref-view}}!\idxcode{\placeholder{ref-view}}}% \begin{itemdecl} -constexpr iterator begin() const - requires Range && - RegularInvocable>>; +template<@\placeholder{not-same-as}@<@\placeholder{ref-view}@> T> + requires @\seebelow@ +constexpr @\placeholder{ref-view}@(T&& t); \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: +\remarks Let \tcode{\placeholder{FUN}} denote the exposition-only functions \begin{codeblock} -return iterator{*this, ranges::begin(base_)}; +void @\placeholder{FUN}@(R&); +void @\placeholder{FUN}@(R&&) = delete; +\end{codeblock} +The expression in the \grammarterm{requires-clause} is equivalent to +\begin{codeblock} +ConvertibleTo && requires { @\placeholder{FUN}@(declval()); } +\end{codeblock} + +\pnum +\effects +Initializes \tcode{r_} with +\tcode{addressof(static_cast(std::forward(t)))}. +\end{itemdescr} + + +\rSec2[range.filter]{Filter view} + +\rSec3[range.filter.overview]{Overview} + +\pnum +\tcode{filter_view} presents a \libconcept{View} of an underlying sequence +without the elements that fail to satisfy a predicate. + +\pnum +\begin{example} +\begin{codeblock} +vector is{ 0, 1, 2, 3, 4, 5, 6 }; +filter_view evens{is, [](int i) { return 0 == i % 2; }}; +for (int i : evens) + cout << i << ' '; // prints: 0 2 4 6 +\end{codeblock} +\end{example} + +\rSec3[range.filter.view]{Class template \tcode{filter_view}} + +\begin{codeblock} +namespace std::ranges { + template> Pred> + requires View && is_object_v + class filter_view : public view_interface> { + private: + V base_ = V(); // \expos + @\placeholdernc{semiregular}@ pred_; // \expos + + class iterator; // \expos + class sentinel; // \expos + + public: + filter_view() = default; + constexpr filter_view(V base, Pred pred); + template + requires ViewableRange && Constructible> + constexpr filter_view(R&& r, Pred pred); + + constexpr V base() const; + + constexpr iterator begin(); + constexpr auto end() { + if constexpr (CommonRange) + return iterator{*this, ranges::end(base_)}; + else + return sentinel{*this}; + } + }; + + template + filter_view(R&&, Pred) -> filter_view, Pred>; +} \end{codeblock} -\end{itemdescr} -\indexlibrary{\idxcode{end}!\idxcode{transform_view}}% +\indexlibrary{\idxcode{filter_view}!\idxcode{filter_view}}% \begin{itemdecl} -constexpr sentinel end(); +constexpr filter_view(V base, Pred pred); \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: -\begin{codeblock} -return sentinel{ranges::end(base_)}; -\end{codeblock} +\effects Initializes \tcode{base_} with \tcode{std::move(base)} and initializes +\tcode{pred_} with \tcode{std::move(pred)}. \end{itemdescr} -\indexlibrary{\idxcode{end}!\idxcode{transform_view}}% +\indexlibrary{\idxcode{filter_view}!\idxcode{filter_view}}% \begin{itemdecl} -constexpr iterator end() requires CommonRange; +template + requires ViewableRange && Constructible> +constexpr filter_view(R&& r, Pred pred); \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: -\begin{codeblock} -return iterator{*this, ranges::end(base_)}; -\end{codeblock} +\effects Initializes \tcode{base_} with \tcode{view::all(std::forward(r))} +and initializes \tcode{pred_} with \tcode{std::\brk{}move(pred)}. \end{itemdescr} -\indexlibrary{\idxcode{end}!\idxcode{transform_view}}% +\indexlibrary{\idxcode{base}!\idxcode{filter_view}}% \begin{itemdecl} -constexpr sentinel end() const - requires Range && - RegularInvocable>>; +constexpr V base() const; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: -\begin{codeblock} -return sentinel{ranges::end(base_)}; -\end{codeblock} +\effects Equivalent to: \tcode{return base_;} \end{itemdescr} -\indexlibrary{\idxcode{end}!\idxcode{transform_view}}% +\indexlibrary{\idxcode{begin}!\idxcode{filter_view}}% \begin{itemdecl} -constexpr iterator end() const - requires CommonRange && - RegularInvocable>>; +constexpr iterator begin(); \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: -\begin{codeblock} -return iterator{*this, ranges::end(base_)}; -\end{codeblock} +\expects +\tcode{pred_.has_value()}. + +\pnum +\returns +\tcode{\{*this, ranges::find_if(base_, ref(*pred_))\}}. + +\pnum +\remarks In order to provide the amortized constant time complexity required by +the \libconcept{Range} concept, this function caches the result within the +\tcode{filter_view} for use on subsequent calls. \end{itemdescr} -\rSec3[range.transform.iterator]{Class template \tcode{transform_view::iterator}} +\rSec3[range.filter.iterator]{Class \tcode{filter_view::iterator}} +\indexlibrary{\idxcode{iterator}!\idxcode{filter_view}}% \begin{codeblock} namespace std::ranges { - template - template - class transform_view::iterator { + template + class filter_view::iterator { private: - using Parent = // \expos - conditional_t; - using Base = // \expos - conditional_t; - iterator_t current_ = // \expos - iterator_t(); - Parent* parent_ = nullptr; // \expos + iterator_t current_ = iterator_t(); // \expos + filter_view* parent_ = nullptr; // \expos public: using iterator_concept = @\seebelow@; using iterator_category = @\seebelow@; - using value_type = - remove_cvref_t>>>; - using difference_type = iter_difference_t>; + using value_type = iter_value_t>; + using difference_type = iter_difference_t>; iterator() = default; - constexpr iterator(Parent& parent, iterator_t current); - constexpr iterator(iterator i) - requires Const && ConvertibleTo, iterator_t>; + constexpr iterator(filter_view& parent, iterator_t current); - constexpr iterator_t base() const; - constexpr decltype(auto) operator*() const - { return invoke(*parent_->fun_, *current_); } + constexpr iterator_t base() const; + constexpr iter_reference_t> operator*() const; + constexpr iterator_t operator->() const + requires @\placeholder{has-arrow}@>; constexpr iterator& operator++(); constexpr void operator++(int); - constexpr iterator operator++(int) requires ForwardRange; - - constexpr iterator& operator--() requires BidirectionalRange; - constexpr iterator operator--(int) requires BidirectionalRange; + constexpr iterator operator++(int) requires ForwardRange; - constexpr iterator& operator+=(difference_type n) - requires RandomAccessRange; - constexpr iterator& operator-=(difference_type n) - requires RandomAccessRange; - constexpr decltype(auto) operator[](difference_type n) const - requires RandomAccessRange - { return invoke(*parent_->fun_, current_[n]); } + constexpr iterator& operator--() requires BidirectionalRange; + constexpr iterator operator--(int) requires BidirectionalRange; friend constexpr bool operator==(const iterator& x, const iterator& y) - requires EqualityComparable>; + requires EqualityComparable>; friend constexpr bool operator!=(const iterator& x, const iterator& y) - requires EqualityComparable>; - - friend constexpr bool operator<(const iterator& x, const iterator& y) - requires RandomAccessRange; - friend constexpr bool operator>(const iterator& x, const iterator& y) - requires RandomAccessRange; - friend constexpr bool operator<=(const iterator& x, const iterator& y) - requires RandomAccessRange; - friend constexpr bool operator>=(const iterator& x, const iterator& y) - requires RandomAccessRange; - - friend constexpr iterator operator+(iterator i, difference_type n) - requires RandomAccessRange; - friend constexpr iterator operator+(difference_type n, iterator i) - requires RandomAccessRange; - - friend constexpr iterator operator-(iterator i, difference_type n) - requires RandomAccessRange; - friend constexpr difference_type operator-(const iterator& x, const iterator& y) - requires RandomAccessRange; - - friend constexpr decltype(auto) iter_move(const iterator& i) - noexcept(noexcept(invoke(*i.parent_->fun_, *i.current_))) - { - if constexpr (is_lvalue_reference_v) - return std::move(*i); - else - return *i; - } + requires EqualityComparable>; + friend constexpr iter_rvalue_reference_t> iter_move(const iterator& i) + noexcept(noexcept(ranges::iter_move(i.current_))); friend constexpr void iter_swap(const iterator& x, const iterator& y) noexcept(noexcept(ranges::iter_swap(x.current_, y.current_))) - requires IndirectlySwappable>; + requires IndirectlySwappable>; }; } \end{codeblock} +\pnum +Modification of the element a \tcode{filter_view::iterator} denotes is +permitted, but results in undefined behavior if the resulting value does not +satisfy the filter predicate. + \pnum \tcode{iterator::iterator_concept} is defined as follows: \begin{itemize} -\item If \tcode{V} models \libconcept{RandomAccessRange}, then -\tcode{iterator_concept} denotes \tcode{random_access_iterator_tag}. - -\item Otherwise, if \tcode{V} models \libconcept{BidirectionalRange}, then +\item If \tcode{V} models \libconcept{BidirectionalRange}, then \tcode{iterator_concept} denotes \tcode{bidirectional_iterator_tag}. \item Otherwise, if \tcode{V} models \libconcept{ForwardRange}, then @@ -2384,250 +2588,171 @@ \end{itemize} \pnum -Let \tcode{C} denote the type -\tcode{iterator_traits>::iterator_category}. -If \tcode{C} models \tcode{\libconcept{Derived\-From}}, -then \tcode{iterator_category} denotes -\tcode{random_access_iterator_tag}; otherwise, -\tcode{iterator_category} denotes \tcode{C}. - -\indexlibrary{\idxcode{iterator}!\idxcode{transform_view::iterator}} -\begin{itemdecl} -constexpr iterator(Parent& parent, iterator_t current); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects Initializes \tcode{current_} with \tcode{current} and -\tcode{parent_} with \tcode{addressof(parent)}. -\end{itemdescr} - -\indexlibrary{\idxcode{iterator}!\idxcode{transform_view::iterator}}% -\begin{itemdecl} -constexpr iterator(iterator i) - requires Const && ConvertibleTo, iterator_t>; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects Initializes \tcode{current_} with \tcode{std::move(i.current_)} and -\tcode{parent_} with \tcode{i.parent_}. -\end{itemdescr} - -\indexlibrary{\idxcode{base}!\idxcode{transform_view::iterator}} -\begin{itemdecl} -constexpr iterator_t base() const; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects Equivalent to: \tcode{return current_;} -\end{itemdescr} - -\indexlibrary{\idxcode{operator++}!\idxcode{transform_view::iterator}} -\begin{itemdecl} -constexpr iterator& operator++(); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects Equivalent to: -\begin{codeblock} -++current_; -return *this; -\end{codeblock} -\end{itemdescr} - -\indexlibrary{\idxcode{operator++}!\idxcode{transform_view::iterator}} -\begin{itemdecl} -constexpr void operator++(int); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects Equivalent to \tcode{++current_}. -\end{itemdescr} - -\indexlibrary{\idxcode{operator++}!\idxcode{transform_view::iterator}} -\begin{itemdecl} -constexpr iterator operator++(int) requires ForwardRange; -\end{itemdecl} +\tcode{iterator::iterator_category} is defined as follows: +\begin{itemize} +\item Let \tcode{C} denote the type +\tcode{iterator_traits>::iterator_category}. -\begin{itemdescr} -\pnum -\effects Equivalent to: -\begin{codeblock} -auto tmp = *this; -++*this; -return tmp; -\end{codeblock} -\end{itemdescr} +\item If \tcode{C} models \tcode{DerivedFrom}, +then \tcode{iterator_category} denotes \tcode{bi\-directional_iterator_tag}. -\indexlibrary{\idxcode{operator\dcr}!\idxcode{transform_view::iterator}} -\begin{itemdecl} -constexpr iterator& operator--() requires BidirectionalRange; -\end{itemdecl} +\item Otherwise, if \tcode{C} models \tcode{DerivedFrom}, +then \tcode{iterator_category} denotes \tcode{forward_iterator_tag}. -\begin{itemdescr} -\pnum -\effects Equivalent to: -\begin{codeblock} ---current_; -return *this; -\end{codeblock} -\end{itemdescr} +\item Otherwise, \tcode{iterator_category} denotes \tcode{input_iterator_tag}. +\end{itemize} -\indexlibrary{\idxcode{operator\dcr}!\idxcode{transform_view::iterator}} +\indexlibrary{\idxcode{iterator}!\idxcode{filter_view::iterator}}% \begin{itemdecl} -constexpr iterator operator--(int) requires BidirectionalRange; +constexpr iterator(filter_view& parent, iterator_t current); \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: -\begin{codeblock} -auto tmp = *this; ---*this; -return tmp; -\end{codeblock} +\effects Initializes \tcode{current_} with \tcode{current} and +\tcode{parent_} with \tcode{addressof(parent)}. \end{itemdescr} -\indexlibrary{\idxcode{operator+=}!\idxcode{transform_view::iterator}} +\indexlibrary{\idxcode{base}!\idxcode{filter_view::iterator}}% \begin{itemdecl} -constexpr iterator& operator+=(difference_type n) - requires RandomAccessRange; +constexpr iterator_t base() const; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: -\begin{codeblock} -current_ += n; -return *this; -\end{codeblock} +\effects Equivalent to: \tcode{return current_;} \end{itemdescr} -\indexlibrary{\idxcode{operator-=}!\idxcode{transform_view::iterator}}% +\indexlibrary{\idxcode{operator*}!\idxcode{filter_view::iterator}}% \begin{itemdecl} -constexpr iterator& operator-=(difference_type n) - requires RandomAccessRange; +constexpr iter_reference_t> operator*() const; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: -\begin{codeblock} -current_ -= n; -return *this; -\end{codeblock} +\effects Equivalent to: \tcode{return *current_;} \end{itemdescr} -\indexlibrary{\idxcode{operator==}!\idxcode{transform_view::iterator}} +\indexlibrary{\idxcode{operator->}!\idxcode{filter_view::iterator}}% \begin{itemdecl} -friend constexpr bool operator==(const iterator& x, const iterator& y) - requires EqualityComparable>; +constexpr iterator_t operator->() const + requires @\placeholder{has-arrow}@>; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return x.current_ == y.current_;} +\effects +Equivalent to: \tcode{return current_;} \end{itemdescr} -\indexlibrary{\idxcode{operator!=}!\idxcode{transform_view::iterator}}% +\indexlibrary{\idxcode{operator++}!\idxcode{filter_view::iterator}}% \begin{itemdecl} -friend constexpr bool operator!=(const iterator& x, const iterator& y) - requires EqualityComparable>; +constexpr iterator& operator++(); \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return !(x == y);} +\effects Equivalent to: +\begin{codeblock} +current_ = ranges::find_if(++current_, ranges::end(parent_->base_), ref(*parent_->pred_)); +return *this; +\end{codeblock} \end{itemdescr} -\indexlibrary{\idxcode{operator<}!\idxcode{transform_view::iterator}}% +\indexlibrary{\idxcode{operator++}!\idxcode{filter_view::iterator}}% \begin{itemdecl} -friend constexpr bool operator<(const iterator& x, const iterator& y) - requires RandomAccessRange; +constexpr void operator++(int); \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return x.current_ < y.current_;} +\effects Equivalent to \tcode{++*this}. \end{itemdescr} -\indexlibrary{\idxcode{operator>}!\idxcode{transform_view::iterator}}% +\indexlibrary{\idxcode{operator++}!\idxcode{filter_view::iterator}}% \begin{itemdecl} -friend constexpr bool operator>(const iterator& x, const iterator& y) - requires RandomAccessRange; +constexpr iterator operator++(int) requires ForwardRange; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return y < x;} +\effects Equivalent to: +\begin{codeblock} +auto tmp = *this; +++*this; +return tmp; +\end{codeblock} \end{itemdescr} -\indexlibrary{\idxcode{operator<=}!\idxcode{transform_view::iterator}}% +\indexlibrary{\idxcode{operator\dcr}!\idxcode{filter_view::iterator}}% \begin{itemdecl} -friend constexpr bool operator<=(const iterator& x, const iterator& y) - requires RandomAccessRange; +constexpr iterator& operator--() requires BidirectionalRange; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return !(y < x);} +\effects Equivalent to: +\begin{codeblock} +do + --current_; +while (!invoke(*parent_->pred_, *current_)); +return *this; +\end{codeblock} \end{itemdescr} -\indexlibrary{\idxcode{operator>=}!\idxcode{transform_view::iterator}}% +\indexlibrary{\idxcode{operator\dcr}!\idxcode{filter_view::iterator}}% \begin{itemdecl} -friend constexpr bool operator>=(const iterator& x, const iterator& y) - requires RandomAccessRange; +constexpr iterator operator--(int) requires BidirectionalRange; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return !(x < y);} +\effects Equivalent to: +\begin{codeblock} +auto tmp = *this; +--*this; +return tmp; +\end{codeblock} \end{itemdescr} -\indexlibrary{\idxcode{operator+}!\idxcode{transform_view::iterator}} +\indexlibrary{\idxcode{operator==}!\idxcode{filter_view::iterator}}% \begin{itemdecl} -friend constexpr iterator operator+(iterator i, difference_type n) - requires RandomAccessRange; -friend constexpr iterator operator+(difference_type n, iterator i) - requires RandomAccessRange; +friend constexpr bool operator==(const iterator& x, const iterator& y) + requires EqualityComparable>; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return iterator\{*i.parent_, i.current_ + n\};} +\effects Equivalent to: \tcode{return x.current_ == y.current_;} \end{itemdescr} -\indexlibrary{\idxcode{operator-}!\idxcode{transform_view::iterator}}% +\indexlibrary{\idxcode{operator!=}!\idxcode{filter_view::iterator}}% \begin{itemdecl} -friend constexpr iterator operator-(iterator i, difference_type n) - requires RandomAccessRange; +friend constexpr bool operator!=(const iterator& x, const iterator& y) + requires EqualityComparable>; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return iterator\{*i.parent_, i.current_ - n\};} +\effects Equivalent to: \tcode{return !(x == y);} \end{itemdescr} -\indexlibrary{\idxcode{operator-}!\idxcode{transform_view::iterator}}% +\indexlibrary{\idxcode{iter_move}!\idxcode{filter_view::iterator}}% \begin{itemdecl} -friend constexpr difference_type operator-(const iterator& x, const iterator& y) - requires RandomAccessRange; +friend constexpr iter_rvalue_reference_t> iter_move(const iterator& i) + noexcept(noexcept(ranges::iter_move(i.current_))); \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return x.current_ - y.current_;} +\effects Equivalent to: \tcode{return ranges::iter_move(i.current_);} \end{itemdescr} -\indexlibrary{\idxcode{iter_swap}!\idxcode{transform_view::iterator}} +\indexlibrary{\idxcode{iter_swap}!\idxcode{filter_view::iterator}}% \begin{itemdecl} friend constexpr void iter_swap(const iterator& x, const iterator& y) noexcept(noexcept(ranges::iter_swap(x.current_, y.current_))) - requires IndirectlySwappable>; + requires IndirectlySwappable>; \end{itemdecl} \begin{itemdescr} @@ -2635,66 +2760,42 @@ \effects Equivalent to \tcode{ranges::iter_swap(x.current_, y.current_)}. \end{itemdescr} +\rSec3[range.filter.sentinel]{Class \tcode{filter_view::sentinel}} -\rSec3[range.transform.sentinel]{Class template \tcode{transform_view::sentinel}} - +\indexlibrary{\idxcode{sentinel}!\idxcode{filter_view}}% \begin{codeblock} namespace std::ranges { - template - template - class transform_view::sentinel { + template + class filter_view::sentinel { private: - using Parent = // \expos - conditional_t; - using Base = conditional_t; // \expos - sentinel_t end_ = sentinel_t(); // \expos + sentinel_t end_ = sentinel_t(); // \expos public: sentinel() = default; - constexpr explicit sentinel(sentinel_t end); - constexpr sentinel(sentinel i) - requires Const && ConvertibleTo, sentinel_t>; - - constexpr sentinel_t base() const; + constexpr explicit sentinel(filter_view& parent); - friend constexpr bool operator==(const iterator& x, const sentinel& y); - friend constexpr bool operator==(const sentinel& x, const iterator& y); - friend constexpr bool operator!=(const iterator& x, const sentinel& y); - friend constexpr bool operator!=(const sentinel& x, const iterator& y); + constexpr sentinel_t base() const; - friend constexpr iter_difference_t> - operator-(const iterator& x, const sentinel& y) - requires SizedSentinel, iterator_t>; - friend constexpr iter_difference_t> - operator-(const sentinel& y, const iterator& x) - requires SizedSentinel, iterator_t>; + friend constexpr bool operator==(const iterator& x, const sentinel& y); + friend constexpr bool operator==(const sentinel& x, const iterator& y); + friend constexpr bool operator!=(const iterator& x, const sentinel& y); + friend constexpr bool operator!=(const sentinel& x, const iterator& y); }; } \end{codeblock} -\indexlibrary{\idxcode{sentinel}!\idxcode{transform_view::sentinel}} -\begin{itemdecl} -constexpr explicit sentinel(sentinel_t end); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects Initializes \tcode{end_} with \tcode{end}. -\end{itemdescr} - -\indexlibrary{\idxcode{sentinel}!\idxcode{transform_view::sentinel}} +\indexlibrary{\idxcode{sentinel}!\idxcode{filter_view::sentinel}}% \begin{itemdecl} -constexpr sentinel(sentinel i) - requires Const && ConvertibleTo, sentinel_t>; +constexpr explicit sentinel(filter_view& parent); \end{itemdecl} \begin{itemdescr} \pnum -\effects Initializes \tcode{end_} with \tcode{std::move(i.end_)}. +\effects Initializes \tcode{end_} with \tcode{ranges::end(parent)}. \end{itemdescr} -\indexlibrary{\idxcode{base}!\idxcode{transform_view::sentinel}} +\indexlibrary{\idxcode{base}!\idxcode{filter_view::sentinel}}% \begin{itemdecl} -constexpr sentinel_t base() const; +constexpr sentinel_t base() const; \end{itemdecl} \begin{itemdescr} @@ -2702,9 +2803,9 @@ \effects Equivalent to: \tcode{return end_;} \end{itemdescr} -\indexlibrary{\idxcode{operator==}!\idxcode{transform_view::sentinel}} +\indexlibrary{\idxcode{operator==}!\idxcode{filter_view::sentinel}}% \begin{itemdecl} -friend constexpr bool operator==(const iterator& x, const sentinel& y); +friend constexpr bool operator==(const iterator& x, const sentinel& y); \end{itemdecl} \begin{itemdescr} @@ -2712,9 +2813,9 @@ \effects Equivalent to: \tcode{return x.current_ == y.end_;} \end{itemdescr} -\indexlibrary{\idxcode{operator==}!\idxcode{transform_view::sentinel}} +\indexlibrary{\idxcode{operator==}!\idxcode{filter_view::sentinel}}% \begin{itemdecl} -friend constexpr bool operator==(const sentinel& x, const iterator& y); +friend constexpr bool operator==(const sentinel& x, const iterator& y); \end{itemdecl} \begin{itemdescr} @@ -2722,9 +2823,9 @@ \effects Equivalent to: \tcode{return y == x;} \end{itemdescr} -\indexlibrary{\idxcode{operator!=}!\idxcode{transform_view::sentinel}}% +\indexlibrary{\idxcode{operator!=}!\idxcode{filter_view::sentinel}}% \begin{itemdecl} -friend constexpr bool operator!=(const iterator& x, const sentinel& y); +friend constexpr bool operator!=(const iterator& x, const sentinel& y); \end{itemdecl} \begin{itemdescr} @@ -2732,9 +2833,9 @@ \effects Equivalent to: \tcode{return !(x == y);} \end{itemdescr} -\indexlibrary{\idxcode{operator!=}!\idxcode{transform_view::sentinel}}% +\indexlibrary{\idxcode{operator!=}!\idxcode{filter_view::sentinel}}% \begin{itemdecl} -friend constexpr bool operator!=(const sentinel& x, const iterator& y); +friend constexpr bool operator!=(const sentinel& x, const iterator& y); \end{itemdecl} \begin{itemdescr} @@ -2742,337 +2843,344 @@ \effects Equivalent to: \tcode{return !(y == x);} \end{itemdescr} -\indexlibrary{\idxcode{operator!=}!\idxcode{transform_view::sentinel}}% -\begin{itemdecl} -friend constexpr iter_difference_t> - operator-(const iterator& x, const sentinel& y) - requires SizedSentinel, iterator_t>; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects Equivalent to: \tcode{return x.current_ - y.end_;} -\end{itemdescr} - -\indexlibrary{\idxcode{operator!=}!\idxcode{transform_view::sentinel}}% -\begin{itemdecl} -friend constexpr iter_difference_t> - operator-(const sentinel& y, const iterator& x) - requires SizedSentinel, iterator_t>; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects Equivalent to: \tcode{return x.end_ - y.current_;} -\end{itemdescr} - -\rSec3[range.transform.adaptor]{\tcode{view::transform}} +\rSec3[range.filter.adaptor]{\tcode{view::filter}} \pnum -The name \tcode{view::transform} denotes a +The name \tcode{view::filter} denotes a range adaptor object\iref{range.adaptor.object}. -For some subexpressions \tcode{E} and \tcode{F}, the expression -\tcode{view::transform(E, F)} is expression-equivalent to -\tcode{transform_view\{E, F\}}. +For some subexpressions \tcode{E} and \tcode{P}, +the expression \tcode{view::filter(E, P)} is expression-equivalent to +\tcode{filter_view\{E, P\}}. -\rSec2[range.iota]{Iota view} +\rSec2[range.transform]{Transform view} -\rSec3[range.iota.overview]{Overview} +\rSec3[range.transform.overview]{Overview} \pnum -\tcode{iota_view} generates a -sequence of elements by repeatedly incrementing an initial value. +\tcode{transform_view} presents +a \libconcept{View} of an underlying sequence after +applying a transformation function to each element. \pnum \begin{example} \begin{codeblock} -for (int i : iota_view{1, 10}) - cout << i << ' '; // prints: 1 2 3 4 5 6 7 8 9 +vector is{ 0, 1, 2, 3, 4 }; +transform_view squares{is, [](int i) { return i * i; }}; +for (int i : squares) + cout << i << ' '; // prints: 0 1 4 9 16 \end{codeblock} \end{example} -\rSec3[range.iota.view]{Class template \tcode{iota_view}} - -\begin{codeblock} -namespace std::ranges { - template - concept @\placeholdernc{Decrementable}@ = // \expos - @\seebelow@; - template - concept @\placeholdernc{Advanceable}@ = // \expos - @\seebelow@; - - template - requires @\placeholdernc{weakly-equality-comparable-with}@ - class iota_view : public view_interface> { +\rSec3[range.transform.view]{Class template \tcode{transform_view}} + +\begin{codeblock} +namespace std::ranges { + template + requires View && is_object_v && + RegularInvocable>> + class transform_view : public view_interface> { private: - struct iterator; // \expos - struct sentinel; // \expos - W value_ = W(); // \expos - Bound bound_ = Bound(); // \expos + template struct iterator; // \expos + template struct sentinel; // \expos + + V base_ = V(); // \expos + @\placeholdernc{semiregular}@ fun_; // \expos + public: - iota_view() = default; - constexpr explicit iota_view(W value); - constexpr iota_view(type_identity_t value, - type_identity_t bound); + transform_view() = default; + constexpr transform_view(V base, F fun); + template + requires ViewableRange && Constructible> + constexpr transform_view(R&& r, F fun); - constexpr iterator begin() const; - constexpr sentinel end() const; - constexpr iterator end() const requires Same; + constexpr V base() const; - constexpr auto size() const - requires (Same && @\placeholdernc{Advanceable}@) || - (Integral && Integral) || - SizedSentinel - { return bound_ - value_; } + constexpr iterator begin(); + constexpr iterator begin() const + requires Range && + RegularInvocable>>; + + constexpr sentinel end(); + constexpr iterator end() requires CommonRange; + constexpr sentinel end() const + requires Range && + RegularInvocable>>; + constexpr iterator end() const + requires CommonRange && + RegularInvocable>>; + + constexpr auto size() requires SizedRange { return ranges::size(base_); } + constexpr auto size() const requires SizedRange + { return ranges::size(base_); } }; - template - requires (!Integral || !Integral || is_signed_v == is_signed_v) - iota_view(W, Bound) -> iota_view; + template + transform_view(R&&, F) -> transform_view, F>; } \end{codeblock} -\pnum -The exposition-only \tcode{\placeholder{Decrementable}} concept is equivalent to: +\indexlibrary{\idxcode{transform_view}!\idxcode{transform_view}}% \begin{itemdecl} -template - concept @\placeholder{Decrementable}@ = - Incrementable && requires(I i) { - { --i } -> Same; - { i-- } -> Same; - }; +constexpr transform_view(V base, F fun); \end{itemdecl} \begin{itemdescr} \pnum -When an object is in the domain of both pre- and post-decrement, -the object is said to be \term{decrementable}. - -\pnum -Let \tcode{a} and \tcode{b} be equal objects of type \tcode{I}. -\tcode{I} models \tcode{\placeholdernc{Decrementable}} only if -\begin{itemize} -\item If \tcode{a} and \tcode{b} are decrementable, - then the following are all true: - \begin{itemize} - \item \tcode{addressof(--a) == addressof(a)} - \item \tcode{bool(a-- == b)} - \item \tcode{bool(((void)a--, a) == --b)} - \item \tcode{bool(++(--a) == b)}. - \end{itemize} -\item If \tcode{a} and \tcode{b} are incrementable, - then \tcode{bool(--(++a) == b)}. -\end{itemize} +\effects Initializes \tcode{base_} with \tcode{std::move(base)} and +\tcode{fun_} with \tcode{std::move(fun)}. \end{itemdescr} -\pnum -The exposition-only \tcode{\placeholder{Advanceable}} concept is equivalent to: +\indexlibrary{\idxcode{transform_view}!\idxcode{transform_view}}% \begin{itemdecl} -template - concept @\placeholder{Advanceable}@ = - @\placeholdernc{Decrementable}@ && StrictTotallyOrdered && - requires(I i, const I j, const iter_difference_t n) { - { i += n } -> Same; - { i -= n } -> Same; - { j + n } -> Same; - { n + j } -> Same; - { j - n } -> Same; - { j - j } -> Same>; - }; +template + requires ViewableRange && Constructible> +constexpr transform_view(R&& r, F fun); \end{itemdecl} -Let \tcode{a} and \tcode{b} be objects of type \tcode{I} such that -\tcode{b} is reachable from \tcode{a} -after \tcode{n} applications of \tcode{++a}, -for some value \tcode{n} of type \tcode{iter_difference_t}, -and let \tcode{D} be \tcode{iter_difference_t}. -\tcode{I} models \tcode{\placeholdernc{Advanceable}} only if -\begin{itemize} -\item \tcode{(a += n)} is equal to \tcode{b}. -\item \tcode{addressof(a += n)} is equal to \tcode{addressof(a)}. -\item \tcode{(a + n)} is equal to \tcode{(a += n)}. -\item For any two positive values - \tcode{x} and \tcode{y} of type \tcode{D}, - if \tcode{(a + D(x + y))} is well-defined, then - \tcode{(a + D(x + y))} is equal to \tcode{((a + x) + y)}. -\item \tcode{(a + D(0))} is equal to \tcode{a}. -\item If \tcode{(a + D(n - 1))} is well-defined, then - \tcode{(a + n)} is equal to \tcode{++(a + D(n - 1))}. -\item \tcode{(b += -n)} is equal to \tcode{a}. -\item \tcode{(b -= n)} is equal to \tcode{a}. -\item \tcode{addressof(b -= n)} is equal to \tcode{addressof(b)}. -\item \tcode{(b - n)} is equal to \tcode{(b -= n)}. -\item \tcode{(b - a)} is equal to \tcode{n}. -\item \tcode{(a - b)} is equal to \tcode{-n}. -\item \tcode{bool(a <= b)} is \tcode{true}. -\end{itemize} +\begin{itemdescr} +\pnum +\effects Initializes \tcode{base_} with \tcode{view::all(std::forward(r))} +and \tcode{fun_} with \tcode{std::move(fun)}. +\end{itemdescr} -\indexlibrary{\idxcode{iota_view}!\idxcode{iota_view}}% +\indexlibrary{\idxcode{base}!\idxcode{transform_view}}% \begin{itemdecl} -constexpr explicit iota_view(W value); +constexpr V base() const; \end{itemdecl} \begin{itemdescr} \pnum -\expects -\tcode{Bound} denotes \tcode{unreachable_sentinel_t} or -\tcode{Bound()} is reachable from \tcode{value}. +\effects Equivalent to: \tcode{return base_;} +\end{itemdescr} + +\indexlibrary{\idxcode{begin}!\idxcode{transform_view}}% +\begin{itemdecl} +constexpr iterator begin(); +\end{itemdecl} +\begin{itemdescr} \pnum -\effects Initializes \tcode{value_} with \tcode{value}. +\effects Equivalent to: +\begin{codeblock} +return iterator{*this, ranges::begin(base_)}; +\end{codeblock} \end{itemdescr} -\indexlibrary{\idxcode{iota_view}!\idxcode{iota_view}}% +\indexlibrary{\idxcode{begin}!\idxcode{transform_view}}% \begin{itemdecl} -constexpr iota_view(type_identity_t value, type_identity_t bound); +constexpr iterator begin() const + requires Range && + RegularInvocable>>; \end{itemdecl} \begin{itemdescr} \pnum -\expects -\tcode{Bound} denotes \tcode{unreachable_sentinel_t} or -\tcode{bound} is reachable from \tcode{value}. +\effects Equivalent to: +\begin{codeblock} +return iterator{*this, ranges::begin(base_)}; +\end{codeblock} +\end{itemdescr} + +\indexlibrary{\idxcode{end}!\idxcode{transform_view}}% +\begin{itemdecl} +constexpr sentinel end(); +\end{itemdecl} +\begin{itemdescr} \pnum -\effects Initializes \tcode{value_} with \tcode{value} and -\tcode{bound_} with \tcode{bound}. +\effects Equivalent to: +\begin{codeblock} +return sentinel{ranges::end(base_)}; +\end{codeblock} \end{itemdescr} -\indexlibrary{\idxcode{begin}!\idxcode{iota_view}}% +\indexlibrary{\idxcode{end}!\idxcode{transform_view}}% \begin{itemdecl} -constexpr iterator begin() const; +constexpr iterator end() requires CommonRange; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return iterator\{value_\};} +\effects Equivalent to: +\begin{codeblock} +return iterator{*this, ranges::end(base_)}; +\end{codeblock} \end{itemdescr} -\indexlibrary{\idxcode{end}!\idxcode{iota_view}}% +\indexlibrary{\idxcode{end}!\idxcode{transform_view}}% \begin{itemdecl} -constexpr sentinel end() const; +constexpr sentinel end() const + requires Range && + RegularInvocable>>; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return sentinel\{bound_\};} +\effects Equivalent to: +\begin{codeblock} +return sentinel{ranges::end(base_)}; +\end{codeblock} \end{itemdescr} -\indexlibrary{\idxcode{end}!\idxcode{iota_view}}% +\indexlibrary{\idxcode{end}!\idxcode{transform_view}}% \begin{itemdecl} -constexpr iterator end() const requires Same; +constexpr iterator end() const + requires CommonRange && + RegularInvocable>>; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return iterator\{bound_\};} +\effects Equivalent to: +\begin{codeblock} +return iterator{*this, ranges::end(base_)}; +\end{codeblock} \end{itemdescr} -\rSec3[range.iota.iterator]{Class \tcode{iota_view::iterator}} +\rSec3[range.transform.iterator]{Class template \tcode{transform_view::iterator}} \begin{codeblock} namespace std::ranges { - template - struct iota_view::iterator { + template + template + class transform_view::iterator { private: - W value_ = W(); // \expos + using Parent = // \expos + conditional_t; + using Base = // \expos + conditional_t; + iterator_t current_ = // \expos + iterator_t(); + Parent* parent_ = nullptr; // \expos public: + using iterator_concept = @\seebelow@; using iterator_category = @\seebelow@; - using value_type = W; - using difference_type = iter_difference_t; + using value_type = + remove_cvref_t>>>; + using difference_type = iter_difference_t>; iterator() = default; - constexpr explicit iterator(W value); + constexpr iterator(Parent& parent, iterator_t current); + constexpr iterator(iterator i) + requires Const && ConvertibleTo, iterator_t>; - constexpr W operator*() const noexcept(is_nothrow_copy_constructible_v); + constexpr iterator_t base() const; + constexpr decltype(auto) operator*() const + { return invoke(*parent_->fun_, *current_); } constexpr iterator& operator++(); constexpr void operator++(int); - constexpr iterator operator++(int) requires Incrementable; + constexpr iterator operator++(int) requires ForwardRange; - constexpr iterator& operator--() requires @\placeholdernc{Decrementable}@; - constexpr iterator operator--(int) requires @\placeholdernc{Decrementable}@; + constexpr iterator& operator--() requires BidirectionalRange; + constexpr iterator operator--(int) requires BidirectionalRange; constexpr iterator& operator+=(difference_type n) - requires @\placeholdernc{Advanceable}@; - constexpr iterator& operator-=(difference_type n) - requires @\placeholdernc{Advanceable}@; - constexpr W operator[](difference_type n) const - requires @\placeholdernc{Advanceable}@; + requires RandomAccessRange; + constexpr iterator& operator-=(difference_type n) + requires RandomAccessRange; + constexpr decltype(auto) operator[](difference_type n) const + requires RandomAccessRange + { return invoke(*parent_->fun_, current_[n]); } friend constexpr bool operator==(const iterator& x, const iterator& y) - requires EqualityComparable; + requires EqualityComparable>; friend constexpr bool operator!=(const iterator& x, const iterator& y) - requires EqualityComparable; + requires EqualityComparable>; friend constexpr bool operator<(const iterator& x, const iterator& y) - requires StrictTotallyOrdered; + requires RandomAccessRange; friend constexpr bool operator>(const iterator& x, const iterator& y) - requires StrictTotallyOrdered; + requires RandomAccessRange; friend constexpr bool operator<=(const iterator& x, const iterator& y) - requires StrictTotallyOrdered; + requires RandomAccessRange; friend constexpr bool operator>=(const iterator& x, const iterator& y) - requires StrictTotallyOrdered; + requires RandomAccessRange; friend constexpr iterator operator+(iterator i, difference_type n) - requires @\placeholdernc{Advanceable}@; + requires RandomAccessRange; friend constexpr iterator operator+(difference_type n, iterator i) - requires @\placeholdernc{Advanceable}@; + requires RandomAccessRange; friend constexpr iterator operator-(iterator i, difference_type n) - requires @\placeholdernc{Advanceable}@; + requires RandomAccessRange; friend constexpr difference_type operator-(const iterator& x, const iterator& y) - requires @\placeholdernc{Advanceable}@; + requires RandomAccessRange; + + friend constexpr decltype(auto) iter_move(const iterator& i) + noexcept(noexcept(invoke(*i.parent_->fun_, *i.current_))) + { + if constexpr (is_lvalue_reference_v) + return std::move(*i); + else + return *i; + } + + friend constexpr void iter_swap(const iterator& x, const iterator& y) + noexcept(noexcept(ranges::iter_swap(x.current_, y.current_))) + requires IndirectlySwappable>; }; } \end{codeblock} \pnum -\tcode{iterator::iterator_category} is defined as follows: +\tcode{iterator::iterator_concept} is defined as follows: \begin{itemize} -\item If \tcode{W} models \tcode{\placeholder{Advanceable}}, then -\tcode{iterator_category} is \tcode{random_access_iterator_tag}. -\item Otherwise, if \tcode{W} models \tcode{\placeholder{Decrementable}}, then -\tcode{iterator_category} is \tcode{bidirectional_iterator_tag}. -\item Otherwise, if \tcode{W} models \libconcept{Incrementable}, then -\tcode{iterator_category} is \tcode{forward_iterator_tag}. -\item Otherwise, \tcode{iterator_category} is \tcode{input_iterator_tag}. +\item If \tcode{V} models \libconcept{RandomAccessRange}, then +\tcode{iterator_concept} denotes \tcode{random_access_iterator_tag}. + +\item Otherwise, if \tcode{V} models \libconcept{BidirectionalRange}, then +\tcode{iterator_concept} denotes \tcode{bidirectional_iterator_tag}. + +\item Otherwise, if \tcode{V} models \libconcept{ForwardRange}, then +\tcode{iterator_concept} denotes \tcode{forward_iterator_tag}. + +\item Otherwise, \tcode{iterator_concept} denotes \tcode{input_iterator_tag}. \end{itemize} \pnum -\begin{note} -Overloads for \tcode{iter_move} and \tcode{iter_swap} are omitted intentionally. -\end{note} +Let \tcode{C} denote the type +\tcode{iterator_traits>::iterator_category}. +If \tcode{C} models \tcode{\libconcept{Derived\-From}}, +then \tcode{iterator_category} denotes +\tcode{random_access_iterator_tag}; otherwise, +\tcode{iterator_category} denotes \tcode{C}. -\indexlibrary{\idxcode{iterator}!\idxcode{iota_view::iterator}} +\indexlibrary{\idxcode{iterator}!\idxcode{transform_view::iterator}} \begin{itemdecl} -constexpr explicit iterator(W value); +constexpr iterator(Parent& parent, iterator_t current); \end{itemdecl} \begin{itemdescr} \pnum -\effects Initializes \tcode{value_} with \tcode{value}. +\effects Initializes \tcode{current_} with \tcode{current} and +\tcode{parent_} with \tcode{addressof(parent)}. \end{itemdescr} -\indexlibrary{\idxcode{operator*}!\idxcode{iota_view::iterator}} +\indexlibrary{\idxcode{iterator}!\idxcode{transform_view::iterator}}% \begin{itemdecl} -constexpr W operator*() const noexcept(is_nothrow_copy_constructible_v); +constexpr iterator(iterator i) + requires Const && ConvertibleTo, iterator_t>; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return value_;} +\effects Initializes \tcode{current_} with \tcode{std::move(i.current_)} and +\tcode{parent_} with \tcode{i.parent_}. +\end{itemdescr} + +\indexlibrary{\idxcode{base}!\idxcode{transform_view::iterator}} +\begin{itemdecl} +constexpr iterator_t base() const; +\end{itemdecl} +\begin{itemdescr} \pnum -\begin{note} -The \tcode{noexcept} clause is needed by the default \tcode{iter_move} -implementation. -\end{note} +\effects Equivalent to: \tcode{return current_;} \end{itemdescr} -\indexlibrary{\idxcode{operator++}!\idxcode{iota_view::iterator}} +\indexlibrary{\idxcode{operator++}!\idxcode{transform_view::iterator}} \begin{itemdecl} constexpr iterator& operator++(); \end{itemdecl} @@ -3081,24 +3189,24 @@ \pnum \effects Equivalent to: \begin{codeblock} -++value_; +++current_; return *this; \end{codeblock} \end{itemdescr} -\indexlibrary{\idxcode{operator++}!\idxcode{iota_view::iterator}} +\indexlibrary{\idxcode{operator++}!\idxcode{transform_view::iterator}} \begin{itemdecl} constexpr void operator++(int); \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to \tcode{++*this}. +\effects Equivalent to \tcode{++current_}. \end{itemdescr} -\indexlibrary{\idxcode{operator++}!\idxcode{iota_view::iterator}} +\indexlibrary{\idxcode{operator++}!\idxcode{transform_view::iterator}} \begin{itemdecl} -constexpr iterator operator++(int) requires Incrementable; +constexpr iterator operator++(int) requires ForwardRange; \end{itemdecl} \begin{itemdescr} @@ -3111,23 +3219,23 @@ \end{codeblock} \end{itemdescr} -\indexlibrary{\idxcode{operator\dcr}!\idxcode{iota_view::iterator}} +\indexlibrary{\idxcode{operator\dcr}!\idxcode{transform_view::iterator}} \begin{itemdecl} -constexpr iterator& operator--() requires @\placeholdernc{Decrementable}@; +constexpr iterator& operator--() requires BidirectionalRange; \end{itemdecl} \begin{itemdescr} \pnum \effects Equivalent to: \begin{codeblock} ---value_; +--current_; return *this; \end{codeblock} \end{itemdescr} -\indexlibrary{\idxcode{operator\dcr}!\idxcode{iota_view::iterator}} +\indexlibrary{\idxcode{operator\dcr}!\idxcode{transform_view::iterator}} \begin{itemdecl} -constexpr iterator operator--(int) requires @\placeholdernc{Decrementable}@; +constexpr iterator operator--(int) requires BidirectionalRange; \end{itemdecl} \begin{itemdescr} @@ -3140,62 +3248,51 @@ \end{codeblock} \end{itemdescr} -\indexlibrary{\idxcode{operator+=}!\idxcode{iota_view::iterator}} +\indexlibrary{\idxcode{operator+=}!\idxcode{transform_view::iterator}} \begin{itemdecl} constexpr iterator& operator+=(difference_type n) - requires @\placeholdernc{Advanceable}@; + requires RandomAccessRange; \end{itemdecl} \begin{itemdescr} \pnum \effects Equivalent to: \begin{codeblock} -value_ += n; +current_ += n; return *this; \end{codeblock} \end{itemdescr} -\indexlibrary{\idxcode{operator-=}!\idxcode{iota_view::iterator}} +\indexlibrary{\idxcode{operator-=}!\idxcode{transform_view::iterator}}% \begin{itemdecl} constexpr iterator& operator-=(difference_type n) - requires @\placeholdernc{Advanceable}@; + requires RandomAccessRange; \end{itemdecl} \begin{itemdescr} \pnum \effects Equivalent to: \begin{codeblock} -value_ -= n; +current_ -= n; return *this; \end{codeblock} \end{itemdescr} -\indexlibrary{\idxcode{operator[]}!\idxcode{iota_view::iterator}} -\begin{itemdecl} -constexpr W operator[](difference_type n) const - requires @\placeholdernc{Advanceable}@; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects Equivalent to: \tcode{return value_ + n;} -\end{itemdescr} - -\indexlibrary{\idxcode{operator==}!\idxcode{iota_view::iterator}} +\indexlibrary{\idxcode{operator==}!\idxcode{transform_view::iterator}} \begin{itemdecl} friend constexpr bool operator==(const iterator& x, const iterator& y) - requires EqualityComparable; + requires EqualityComparable>; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return x.value_ == y.value_;} +\effects Equivalent to: \tcode{return x.current_ == y.current_;} \end{itemdescr} -\indexlibrary{\idxcode{operator!=}!\idxcode{iota_view::iterator}} +\indexlibrary{\idxcode{operator!=}!\idxcode{transform_view::iterator}}% \begin{itemdecl} friend constexpr bool operator!=(const iterator& x, const iterator& y) - requires EqualityComparable; + requires EqualityComparable>; \end{itemdecl} \begin{itemdescr} @@ -3203,21 +3300,21 @@ \effects Equivalent to: \tcode{return !(x == y);} \end{itemdescr} -\indexlibrary{\idxcode{operator<}!\idxcode{iota_view::iterator}} +\indexlibrary{\idxcode{operator<}!\idxcode{transform_view::iterator}}% \begin{itemdecl} friend constexpr bool operator<(const iterator& x, const iterator& y) - requires StrictTotallyOrdered; + requires RandomAccessRange; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return x.value_ < y.value_;} +\effects Equivalent to: \tcode{return x.current_ < y.current_;} \end{itemdescr} -\indexlibrary{\idxcode{operator>}!\idxcode{iota_view::iterator}} +\indexlibrary{\idxcode{operator>}!\idxcode{transform_view::iterator}}% \begin{itemdecl} friend constexpr bool operator>(const iterator& x, const iterator& y) - requires StrictTotallyOrdered; + requires RandomAccessRange; \end{itemdecl} \begin{itemdescr} @@ -3225,10 +3322,10 @@ \effects Equivalent to: \tcode{return y < x;} \end{itemdescr} -\indexlibrary{\idxcode{operator<=}!\idxcode{iota_view::iterator}} +\indexlibrary{\idxcode{operator<=}!\idxcode{transform_view::iterator}}% \begin{itemdecl} friend constexpr bool operator<=(const iterator& x, const iterator& y) - requires StrictTotallyOrdered; + requires RandomAccessRange; \end{itemdecl} \begin{itemdescr} @@ -3236,10 +3333,10 @@ \effects Equivalent to: \tcode{return !(y < x);} \end{itemdescr} -\indexlibrary{\idxcode{operator>=}!\idxcode{iota_view::iterator}} +\indexlibrary{\idxcode{operator>=}!\idxcode{transform_view::iterator}}% \begin{itemdecl} friend constexpr bool operator>=(const iterator& x, const iterator& y) - requires StrictTotallyOrdered; + requires RandomAccessRange; \end{itemdecl} \begin{itemdescr} @@ -3247,129 +3344,192 @@ \effects Equivalent to: \tcode{return !(x < y);} \end{itemdescr} -\indexlibrary{\idxcode{operator+}!\idxcode{iota_view::iterator}} +\indexlibrary{\idxcode{operator+}!\idxcode{transform_view::iterator}} \begin{itemdecl} friend constexpr iterator operator+(iterator i, difference_type n) - requires @\placeholdernc{Advanceable}@; + requires RandomAccessRange; +friend constexpr iterator operator+(difference_type n, iterator i) + requires RandomAccessRange; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return iterator\{i.value_ + n\};} +\effects Equivalent to: \tcode{return iterator\{*i.parent_, i.current_ + n\};} \end{itemdescr} -\indexlibrary{\idxcode{operator+}!\idxcode{iota_view::iterator}} +\indexlibrary{\idxcode{operator-}!\idxcode{transform_view::iterator}}% +\begin{itemdecl} +friend constexpr iterator operator-(iterator i, difference_type n) + requires RandomAccessRange; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects Equivalent to: \tcode{return iterator\{*i.parent_, i.current_ - n\};} +\end{itemdescr} + +\indexlibrary{\idxcode{operator-}!\idxcode{transform_view::iterator}}% +\begin{itemdecl} +friend constexpr difference_type operator-(const iterator& x, const iterator& y) + requires RandomAccessRange; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects Equivalent to: \tcode{return x.current_ - y.current_;} +\end{itemdescr} + +\indexlibrary{\idxcode{iter_swap}!\idxcode{transform_view::iterator}} +\begin{itemdecl} +friend constexpr void iter_swap(const iterator& x, const iterator& y) + noexcept(noexcept(ranges::iter_swap(x.current_, y.current_))) + requires IndirectlySwappable>; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects Equivalent to \tcode{ranges::iter_swap(x.current_, y.current_)}. +\end{itemdescr} + + +\rSec3[range.transform.sentinel]{Class template \tcode{transform_view::sentinel}} + +\begin{codeblock} +namespace std::ranges { + template + template + class transform_view::sentinel { + private: + using Parent = // \expos + conditional_t; + using Base = conditional_t; // \expos + sentinel_t end_ = sentinel_t(); // \expos + public: + sentinel() = default; + constexpr explicit sentinel(sentinel_t end); + constexpr sentinel(sentinel i) + requires Const && ConvertibleTo, sentinel_t>; + + constexpr sentinel_t base() const; + + friend constexpr bool operator==(const iterator& x, const sentinel& y); + friend constexpr bool operator==(const sentinel& x, const iterator& y); + friend constexpr bool operator!=(const iterator& x, const sentinel& y); + friend constexpr bool operator!=(const sentinel& x, const iterator& y); + + friend constexpr iter_difference_t> + operator-(const iterator& x, const sentinel& y) + requires SizedSentinel, iterator_t>; + friend constexpr iter_difference_t> + operator-(const sentinel& y, const iterator& x) + requires SizedSentinel, iterator_t>; + }; +} +\end{codeblock} + +\indexlibrary{\idxcode{sentinel}!\idxcode{transform_view::sentinel}} +\begin{itemdecl} +constexpr explicit sentinel(sentinel_t end); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects Initializes \tcode{end_} with \tcode{end}. +\end{itemdescr} + +\indexlibrary{\idxcode{sentinel}!\idxcode{transform_view::sentinel}} \begin{itemdecl} -friend constexpr iterator operator+(difference_type n, iterator i) - requires @\placeholdernc{Advanceable}@; +constexpr sentinel(sentinel i) + requires Const && ConvertibleTo, sentinel_t>; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return i + n;} +\effects Initializes \tcode{end_} with \tcode{std::move(i.end_)}. \end{itemdescr} -\indexlibrary{\idxcode{operator-}!\idxcode{iota_view::iterator}} +\indexlibrary{\idxcode{base}!\idxcode{transform_view::sentinel}} \begin{itemdecl} -friend constexpr iterator operator-(iterator i, difference_type n) - requires @\placeholdernc{Advanceable}@; +constexpr sentinel_t base() const; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return i + -n;} +\effects Equivalent to: \tcode{return end_;} \end{itemdescr} -\indexlibrary{\idxcode{operator-}!\idxcode{iota_view::iterator}} +\indexlibrary{\idxcode{operator==}!\idxcode{transform_view::sentinel}} \begin{itemdecl} -friend constexpr difference_type operator-(const iterator& x, const iterator& y) - requires @\placeholdernc{Advanceable}@; +friend constexpr bool operator==(const iterator& x, const sentinel& y); \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return x.value_ - y.value_;} +\effects Equivalent to: \tcode{return x.current_ == y.end_;} \end{itemdescr} -\rSec3[range.iota.sentinel]{Class \tcode{iota_view::sentinel}} - -\begin{codeblock} -namespace std::ranges { - template - struct iota_view::sentinel { - private: - Bound bound_ = Bound(); // \expos - public: - sentinel() = default; - constexpr explicit sentinel(Bound bound); - - friend constexpr bool operator==(const iterator& x, const sentinel& y); - friend constexpr bool operator==(const sentinel& x, const iterator& y); - friend constexpr bool operator!=(const iterator& x, const sentinel& y); - friend constexpr bool operator!=(const sentinel& x, const iterator& y); - }; -} -\end{codeblock} - -\indexlibrary{\idxcode{sentinel}!\idxcode{iota_view::sentinel}} +\indexlibrary{\idxcode{operator==}!\idxcode{transform_view::sentinel}} \begin{itemdecl} -constexpr explicit sentinel(Bound bound); +friend constexpr bool operator==(const sentinel& x, const iterator& y); \end{itemdecl} \begin{itemdescr} \pnum -\effects Initializes \tcode{bound_} with \tcode{bound}. +\effects Equivalent to: \tcode{return y == x;} \end{itemdescr} -\indexlibrary{\idxcode{operator==}!\idxcode{iota_view::sentinel}} +\indexlibrary{\idxcode{operator!=}!\idxcode{transform_view::sentinel}}% \begin{itemdecl} -friend constexpr bool operator==(const iterator& x, const sentinel& y); +friend constexpr bool operator!=(const iterator& x, const sentinel& y); \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return x.value_ == y.bound_;} +\effects Equivalent to: \tcode{return !(x == y);} \end{itemdescr} -\indexlibrary{\idxcode{operator==}!\idxcode{iota_view::sentinel}} +\indexlibrary{\idxcode{operator!=}!\idxcode{transform_view::sentinel}}% \begin{itemdecl} -friend constexpr bool operator==(const sentinel& x, const iterator& y); +friend constexpr bool operator!=(const sentinel& x, const iterator& y); \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return y == x;} +\effects Equivalent to: \tcode{return !(y == x);} \end{itemdescr} -\indexlibrary{\idxcode{operator!=}!\idxcode{iota_view::sentinel}} +\indexlibrary{\idxcode{operator!=}!\idxcode{transform_view::sentinel}}% \begin{itemdecl} -friend constexpr bool operator!=(const iterator& x, const sentinel& y); +friend constexpr iter_difference_t> + operator-(const iterator& x, const sentinel& y) + requires SizedSentinel, iterator_t>; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return !(x == y);} +\effects Equivalent to: \tcode{return x.current_ - y.end_;} \end{itemdescr} -\indexlibrary{\idxcode{operator!=}!\idxcode{iota_view::sentinel}} +\indexlibrary{\idxcode{operator!=}!\idxcode{transform_view::sentinel}}% \begin{itemdecl} -friend constexpr bool operator!=(const sentinel& x, const iterator& y); +friend constexpr iter_difference_t> + operator-(const sentinel& y, const iterator& x) + requires SizedSentinel, iterator_t>; \end{itemdecl} \begin{itemdescr} \pnum -\effects Equivalent to: \tcode{return !(y == x);} +\effects Equivalent to: \tcode{return x.end_ - y.current_;} \end{itemdescr} -\rSec3[range.iota.adaptor]{\tcode{view::iota}} +\rSec3[range.transform.adaptor]{\tcode{view::transform}} \pnum -The name \tcode{view::iota} denotes a -customization point object\iref{customization.point.object}. -For some subexpressions \tcode{E} and \tcode{F}, the expressions -\tcode{view::iota(E)} and \tcode{view::iota(E, F)} -are expression-equivalent to -\tcode{iota_view\{E\}} and \tcode{iota_view\{E, F\}}, respectively. +The name \tcode{view::transform} denotes a +range adaptor object\iref{range.adaptor.object}. +For some subexpressions \tcode{E} and \tcode{F}, the expression +\tcode{view::transform(E, F)} is expression-equivalent to +\tcode{transform_view\{E, F\}}. \rSec2[range.take]{Take view} @@ -4105,175 +4265,6 @@ \tcode{view::join(E)} is expression-equivalent to \tcode{join_view\{E\}}. - -\rSec2[range.empty]{Empty view} - -\rSec3[range.empty.overview]{Overview} - -\pnum -\tcode{empty_view} produces a \libconcept{View} of no elements of -a particular type. - -\pnum -\begin{example} -\begin{codeblock} -empty_view e; -static_assert(ranges::empty(e)); -static_assert(0 == e.size()); -\end{codeblock} -\end{example} - -\rSec3[range.empty.view]{Class template \tcode{empty_view}} - -\begin{codeblock} -namespace std::ranges { - template - requires is_object_v - class empty_view : public view_interface> { - public: - static constexpr T* begin() noexcept { return nullptr; } - static constexpr T* end() noexcept { return nullptr; } - static constexpr T* data() noexcept { return nullptr; } - static constexpr ptrdiff_t size() noexcept { return 0; } - static constexpr bool empty() noexcept { return true; } - - friend constexpr T* begin(empty_view) noexcept { return nullptr; } - friend constexpr T* end(empty_view) noexcept { return nullptr; } - }; -} -\end{codeblock} - - -\rSec2[range.single]{Single view} - -\rSec3[range.single.overview]{Overview} - -\pnum -\tcode{single_view} produces a \libconcept{View} that contains -exactly one element of a specified value. - -\pnum -\begin{example} -\begin{codeblock} -single_view s{4}; -for (int i : s) - cout << i; // prints 4 -\end{codeblock} -\end{example} - -\rSec3[range.single.view]{Class template \tcode{single_view}} - -\begin{codeblock} -namespace std::ranges { - template - requires is_object_v - class single_view : public view_interface> { - private: - @\placeholdernc{semiregular}@ value_; // \expos - public: - single_view() = default; - constexpr explicit single_view(const T& t); - constexpr explicit single_view(T&& t); - template - requires Constructible - constexpr single_view(in_place_t, Args&&... args); - - constexpr T* begin() noexcept; - constexpr const T* begin() const noexcept; - constexpr T* end() noexcept; - constexpr const T* end() const noexcept; - static constexpr ptrdiff_t size() noexcept; - constexpr T* data() noexcept; - constexpr const T* data() const noexcept; - }; -} -\end{codeblock} - -\indexlibrary{\idxcode{single_view}!\idxcode{single_view}}% -\begin{itemdecl} -constexpr explicit single_view(const T& t); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects Initializes \tcode{value_} with \tcode{t}. -\end{itemdescr} - -\indexlibrary{\idxcode{single_view}!\idxcode{single_view}}% -\begin{itemdecl} -constexpr explicit single_view(T&& t); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects Initializes \tcode{value_} with \tcode{std::move(t)}. -\end{itemdescr} - -\indexlibrary{\idxcode{single_view}!\idxcode{single_view}}% -\begin{itemdecl} -template -constexpr single_view(in_place_t, Args&&... args); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects Initializes \tcode{value_} as if by -\tcode{value_\{in_place, std::forward(args)...\}}. -\end{itemdescr} - -\indexlibrary{\idxcode{begin}!\idxcode{single_view}}% -\begin{itemdecl} -constexpr T* begin() noexcept; -constexpr const T* begin() const noexcept; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects Equivalent to: \tcode{return data();} -\end{itemdescr} - -\indexlibrary{\idxcode{end}!\idxcode{single_view}}% -\begin{itemdecl} -constexpr T* end() noexcept; -constexpr const T* end() const noexcept; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects Equivalent to: \tcode{return data() + 1;} -\end{itemdescr} - -\indexlibrary{\idxcode{size}!\idxcode{single_view}}% -\begin{itemdecl} -static constexpr ptrdiff_t size() noexcept; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects Equivalent to: \tcode{return 1;} -\end{itemdescr} - -\indexlibrary{\idxcode{data}!\idxcode{single_view}}% -\begin{itemdecl} -constexpr T* data() noexcept; -constexpr const T* data() const noexcept; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects Equivalent to: \tcode{return value_.operator->();} -\end{itemdescr} - -\rSec3[range.single.adaptor]{\tcode{view::single}} - -\pnum -The name \tcode{view::single} denotes a -customization point object\iref{customization.point.object}. -For some subexpression \tcode{E}, the expression -\tcode{view::single(E)} is expression-equivalent to -\tcode{single_view\{E\}}. - - \rSec2[range.split]{Split view} \rSec3[range.split.overview]{Overview} diff --git a/source/std.tex b/source/std.tex index 95c2062163..a87c75c129 100644 --- a/source/std.tex +++ b/source/std.tex @@ -44,6 +44,8 @@ ]{hyperref} \usepackage{memhfixc} % fix interactions between hyperref and memoir \usepackage[active,header=false,handles=false,copydocumentclass=false,generate=std-gram.ext,extract-cmdline={gramSec},extract-env={bnf,simplebnf}]{extract} % Grammar extraction +\usepackage{expl3} +\usepackage{xparse} \pdfminorversion=5 \pdfcompresslevel=9 diff --git a/source/templates.tex b/source/templates.tex index a6d04e7b27..8ce5e969de 100644 --- a/source/templates.tex +++ b/source/templates.tex @@ -1221,7 +1221,7 @@ \item a temporary object\iref{class.temporary}, \item a string literal\iref{lex.string}, \item the result of a \tcode{typeid} expression\iref{expr.typeid}, or -\item a predefined \tcode{__func__} variable\iref{dcl.fct.def.general}. +\item a predefined \mname{func} variable\iref{dcl.fct.def.general}. \end{itemize} \begin{note} @@ -1280,7 +1280,7 @@ struct A { constexpr A(const char*) {} - auto operator<=>(A, A) = default; + friend auto operator<=>(const A&, const A&) = default; }; X z; // OK, string literal is a constructor argument to \tcode{A} @@ -2220,7 +2220,7 @@ The \grammarterm{template-argument} for -\tcode{Array::operator[]()} +\tcode{Array::operator[]} will be determined by the \tcode{Array} to which the subscripting operation is applied. @@ -2229,8 +2229,8 @@ Array v1(20); Array v2(30); -v1[3] = 7; // \tcode{Array::operator[]()} -v2[3] = dcomplex(7,8); // \tcode{Array::operator[]()} +v1[3] = 7; // \tcode{Array::operator[]} +v2[3] = dcomplex(7,8); // \tcode{Array::operator[]} \end{codeblock} \end{example} @@ -5075,7 +5075,7 @@ \item the \grammarterm{identifier} -\tcode{__func__}\iref{dcl.fct.def.general}, where any enclosing function is a +\mname{func}\iref{dcl.fct.def.general}, where any enclosing function is a template, a member of a class template, or a generic lambda, \item diff --git a/source/threads.tex b/source/threads.tex index 323ce3fc3b..c2ddd2b54c 100644 --- a/source/threads.tex +++ b/source/threads.tex @@ -272,22 +272,6 @@ \returns \tcode{true} if the lock was acquired, \tcode{false} otherwise. \end{itemdescr} -\rSec2[thread.decaycopy]{\tcode{decay_copy}} - -\pnum -In several places in this Clause the operation -\indextext{DECAY_COPY@\tcode{\placeholder{DECAY_COPY}}}% -\indexlibrary{DECAY_COPY@\tcode{\placeholder{DECAY_COPY}}}% -{\tcode{\placeholdernc{DECAY_COPY}(x)}} is used. All -such uses mean call the function \tcode{decay_copy(x)} and use the -result, where \tcode{decay_copy} is defined as follows: - -\begin{codeblock} -template constexpr decay_t decay_copy(T&& v) - noexcept(is_nothrow_convertible_v>) - { return std::forward(v); } -\end{codeblock} - \rSec1[thread.threads]{Threads} \pnum @@ -526,11 +510,9 @@ \oldconcept{MoveConstructible} requirements. \tcode{% \placeholdernc{INVOKE}(\brk{}% -\placeholdernc{DECAY_COPY}(\brk{}% -std::forward(f)), -\placeholdernc{DECAY_COPY}(\brk{}% -std::forward(\brk{}args))...)}\iref{func.require} shall be -a va\-lid expression. +\placeholdernc{decay-copy}(std::forward(f)),% +\placeholdernc{decay-copy}(std::forward({}args))...)}\iref{func.require} +shall be a valid expression. \pnum \remarks @@ -541,19 +523,19 @@ \effects\ Constructs an object of type \tcode{thread}. The new thread of execution executes \tcode{% \placeholdernc{INVOKE}(\brk{}% -\placeholdernc{DECAY_COPY}(\brk{}% +\placeholdernc{decay-copy}(\brk{}% std::forward(f)), -\placeholdernc{DECAY_COPY}(\brk{}% +\placeholdernc{decay-copy}(\brk{}% std::forward(\brk{}args))...)} with the calls to -\tcode{\placeholder{DECAY_COPY}} being evaluated in the constructing thread. Any return value from this invocation +\tcode{\placeholder{decay-copy}} being evaluated in the constructing thread. Any return value from this invocation is ignored. \begin{note} This implies that any exceptions not thrown from the invocation of the copy of \tcode{f} will be thrown in the constructing thread, not the new thread. \end{note} If the invocation of \tcode{% \placeholdernc{INVOKE}(\brk{}% -\placeholdernc{DECAY_COPY}(\brk{}% +\placeholdernc{decay-copy}(\brk{}% std::forward(f)), -\placeholdernc{DECAY_COPY}(\brk{}% +\placeholdernc{decay-copy}(\brk{}% std::forward(args))...)} termi\-nates with an uncaught exception, \tcode{terminate} shall be called. @@ -2848,9 +2830,9 @@ Condition variables provide synchronization primitives used to block a thread until notified by some other thread that some condition is met or until a system time is reached. Class \tcode{condition_variable} provides a condition variable that can only -wait on an object of type \tcode{unique_lock}, allowing maximum efficiency on some -platforms. Class \tcode{condition_variable_any} provides a general condition variable -that can wait on objects of user-supplied lock types. +wait on an object of type \tcode{unique_lock}, allowing the implementation +to be more efficient. Class \tcode{condition_variable_any} provides a general +condition variable that can wait on objects of user-supplied lock types. \pnum Condition variables permit concurrent invocation of the \tcode{wait}, \tcode{wait_for}, @@ -4798,8 +4780,8 @@ satisfy the \oldconcept{MoveConstructible} requirements, and \begin{codeblock} -@\placeholdernc{INVOKE}@(@\placeholdernc{DECAY_COPY}@(std::forward(f)), - @\placeholdernc{DECAY_COPY}@(std::forward(args))...) // see \ref{func.require}, \ref{thread.thread.constr} +@\placeholdernc{INVOKE}@(@\placeholdernc{decay-copy}@(std::forward(f)), + @\placeholdernc{decay-copy}@(std::forward(args))...) // see \ref{func.require}, \ref{thread.thread.constr} \end{codeblock} shall be a valid expression. @@ -4819,17 +4801,17 @@ \begin{itemize} \item If \tcode{launch::async} is set in \tcode{policy}, calls -\tcode{\placeholdernc{INVOKE}(\placeholdernc{DECAY_COPY}(std::forward(f)),} -\tcode{\placeholdernc{DECAY_COPY}(std::forward(args))...)} +\tcode{\placeholdernc{INVOKE}(\placeholdernc{decay-copy}(std::forward(f)),} +\tcode{\placeholdernc{decay-\brk{}copy}(std::forward(args))...)} (\ref{func.require}, \ref{thread.thread.constr}) as if in a new thread of execution represented by a \tcode{thread} object -with the calls to \tcode{\placeholder{DECAY_COPY}} being evaluated in the thread that called \tcode{async}. +with the calls to \tcode{\placeholder{decay-copy}} being evaluated in the thread that called \tcode{async}. Any return value is stored as the result in the shared state. Any exception propagated from the execution of -\tcode{\placeholdernc{INVOKE}(\placeholdernc{DECAY_COPY}(std::forward(f)), -\placeholdernc{DECAY_COPY}(std::forward(args))...)} +\tcode{\placeholdernc{INVOKE}(\placeholdernc{decay-copy}(std::forward(f)), +\placeholdernc{decay-copy}(std::forward\brk{}(args))...)} is stored as the exceptional result in the shared state. The \tcode{thread} object is stored in the shared state @@ -4838,13 +4820,13 @@ \item If \tcode{launch::deferred} is set in \tcode{policy}, -stores \tcode{\placeholdernc{DECAY_COPY}(std::forward(f))} and -\tcode{\placeholdernc{DECAY_COPY}(std::forward(args))...} +stores \tcode{\placeholdernc{decay-copy}(std::forward(f))} and +\tcode{\placeholdernc{decay-\brk{}copy}(std::forward(args))...} in the shared state. These copies of \tcode{f} and \tcode{args} constitute a \defn{deferred function}. Invocation of the deferred function evaluates \tcode{\placeholdernc{INVOKE}(std::move(g), std::move(xyz))} where \tcode{g} is the stored value of -\tcode{\placeholdernc{DECAY_COPY}(std::forward(f))} and \tcode{xyz} is the stored copy of -\tcode{\placeholdernc{DECAY_COPY}(std::forward(args))...}. +\tcode{\placeholdernc{decay-copy}(std::forward(f))} and \tcode{xyz} is the stored copy of +\tcode{\placeholdernc{decay-copy}(std::forward(args))...}. Any return value is stored as the result in the shared state. Any exception propagated diff --git a/source/utilities.tex b/source/utilities.tex index 67562258ff..cf2505cf07 100644 --- a/source/utilities.tex +++ b/source/utilities.tex @@ -2621,7 +2621,7 @@ \indexlibrarymember{operator=}{optional}% \begin{itemdecl} -constexpr optional& operator=(optional&& rhs) noexcept(@\seebelow@); +constexpr optional& operator=(optional&& rhs) noexcept(@\seebelow@); \end{itemdecl} \begin{itemdescr} @@ -8125,7 +8125,8 @@ \begin{itemdescr} \pnum -No exceptions are thrown from increment, +A type \tcode{I} models \tcode{\placeholder{no-throw-input-iterator}} only if +no exceptions are thrown from increment, copy construction, move construction, copy assignment, move assignment, or indirection through valid iterators. @@ -8144,7 +8145,8 @@ \begin{itemdescr} \pnum -No exceptions are thrown from copy construction, move construction, +Types \tcode{S} and \tcode{I} model \tcode{\placeholder{no-throw-sentinel}} +only if no exceptions are thrown from copy construction, move construction, copy assignment, move assignment, or comparisons between valid values of type \tcode{I} and \tcode{S}. @@ -8164,7 +8166,9 @@ \end{itemdecl} \begin{itemdescr} -\pnum No exceptions are thrown from calls to \tcode{ranges::begin} and +\pnum +A type \tcode{R} models \tcode{\placeholder{no-throw-input-range}} only if +no exceptions are thrown from calls to \tcode{ranges::begin} and \tcode{ranges::end} on an object of type \tcode{R}. \end{itemdescr} @@ -13790,7 +13794,7 @@ inline constexpr int is_placeholder_v = is_placeholder::value; namespace ranges { - // \ref{range.cmp}, range comparisons + // \ref{range.cmp}, concept-constrained comparisons template requires @\seebelow@ struct equal_to; @@ -14674,7 +14678,7 @@ \pnum\returns \tcode{std::forward(t) <= std::forward(u)}. \end{itemdescr} -\rSec2[range.cmp]{Range comparisons} +\rSec2[range.cmp]{Concept-constrained comparisons} \pnum In this subclause, \tcode{\placeholdernc{BUILTIN_PTR_CMP}(T, $op$, U)} for types \tcode{T} @@ -18475,7 +18479,7 @@ \rSec2[meta.const.eval]{Constant evaluation context} \begin{itemdecl} -constexpr bool is_constant_evaluation() noexcept; +constexpr bool is_constant_evaluated() noexcept; \end{itemdecl} \begin{itemdescr} diff --git a/source/xrefdelta.tex b/source/xrefdelta.tex index 3f49fbf2b0..c77de6bc85 100644 --- a/source/xrefdelta.tex +++ b/source/xrefdelta.tex @@ -194,6 +194,10 @@ \movedxref{ios::seekdir}{ios.seekdir} \movedxref{ios::Init}{ios.init} +\movedxref{thread.decaycopy}{expos.only.func} + +\movedxref{iterator.container}{iterator.range} + % Deprecated features. %\deprxref{old.label} (if moved to depr.old.label, otherwise use \movedxref)