diff --git a/papers/.gitattributes b/papers/.gitattributes new file mode 100644 index 0000000000..0afd26b375 --- /dev/null +++ b/papers/.gitattributes @@ -0,0 +1 @@ +*.pdf -diff diff --git a/papers/n4639.html b/papers/n4639.html new file mode 100644 index 0000000000..6fb30b381b --- /dev/null +++ b/papers/n4639.html @@ -0,0 +1,1370 @@ +N4639 +

N4639 Editors' Report -- Working Draft, Standard for Programming Language C++

+ +

2016-02-06
+Richard Smith (editor) (Google Inc)
+Dawn Perchik (co-editor) (Embarcadero Technologies Inc)
+Thomas Köppe (co-editor) (Google DeepMind)
+<cxxeditor@gmail.com>

+ +

Acknowledgements

+ +

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

+ +

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 N4618.

+ +

Notable editorial changes

+ + + +

Minor editorial fixes

+ +

A log of editorial fixes made since N4618 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 f77a2b27e9e68eacedb23d675d2d257125f3a7e7
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Mon Feb 6 19:54:31 2017 +0100
+
+    Define 'object type' only once. (#1268)
+
+    There were only a few references to the definition in
+    1.8 [intro.object], so drop that definition and refer
+    to 'type of an object' instead.
+
+    Fixes #511.
+
+commit fec48d5db12705f1fcec4be6a9ceb3a067c305cd
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Mon Feb 6 03:09:41 2017 +0100
+
+    [valarray.access] 'evaluates as' -> 'evaluates to'. (#1337)
+
+commit b79c41937b0150569e1428d1093d9504762f15dd
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Mon Feb 6 02:02:39 2017 +0100
+
+    [numarray] Add standard description elements. (#1215)
+
+    Partially addresses #1071.
+
+commit 1f8ab13005ff2820d4044c6707a1dabfebce2c1b
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Mon Feb 6 02:01:59 2017 +0100
+
+    [dcl.init.aggr] Add example for array of unknown bound (#1270)
+
+    * Consistently refer to 'array of unknown bound'
+    not 'array of unknown size'; see [dcl.array].
+
+    * [dcl.init.aggr] Add example for array of unknown bound
+    as non-static data member.
+
+    Addresses core issue 1985.
+
+    Fixes #396.
+
+commit ec9f102dec2e4624750f01cdebc6f7132361edaa
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sun Feb 5 17:39:12 2017 +0000
+
+    [cinttypes.syn] Add missing 'the', capitalize sentence
+
+commit e23a5df2f8819c88b87e3392d6522b747481e381
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sun Feb 5 17:13:46 2017 +0000
+
+    [iostream.format] Minor rewording to be more accurate and fit the lines better
+
+commit 1a0dd180eb3ea3af05cdf1f573eb6f69b0f1b152
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sun Feb 5 14:51:08 2017 +0000
+
+    Format "i^th" consistently.
+
+    Fixes #653, see also #974.
+
+commit 24900a40ed833ccebb1f3760efe366e4ba73109a
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sun Feb 5 14:26:33 2017 +0000
+
+    [cpp] Swap "control-line" and "if-section".
+
+    With the increased vertical grammar spacing, it is expedient to put the presentation of "control-line" onto the first page so as not to require a huge gap.
+
+commit 4935ed404aa4819e63c560aa2104dbfa70d18f40
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sun Feb 5 13:09:48 2017 +0000
+
+    [ratio.{syn,comparison}] Mild reformatting for consistency.
+
+    Fixes #1402.
+
+commit 50353bd3bb69d770d00e2fb9236bc913994b96c7
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sun Feb 5 13:03:56 2017 +0000
+
+    [associative.set.syn] Fix cross-reference link for 'multiset'
+
+    Fixes #1424.
+
+commit 766792134b9edb507c569ead9745d12c56735115
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sun Feb 5 12:20:50 2017 +0000
+
+    [algorithms.parallel] Add missing \pnum
+
+    Fixes #1432.
+
+commit e88d2343b441b399673aa934de766323c68353f5
+Author: Marshall Clow <marshall@idio.com>
+Date:   Sat Feb 4 20:48:13 2017 -0800
+
+    [string.view.template] Change the `reference`, `pointer` etc typedefs in `string_view` to use `value_type` rather than `charT` (#1416)
+
+    This is a cut down version of https://github.com/cplusplus/draft/pull/141, to ensure that it is editorial
+
+commit 04fa63d98ac28457ea038b75fa05f49d14d8ab5b
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sun Feb 5 05:12:58 2017 +0100
+
+    Use 'base class subobject', not 'base subobject' (#1382)
+
+    Fixes #1379.
+
+commit 2de42d5a857886ee1200990ce40f7d8e61eb2293
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sun Feb 5 04:07:38 2017 +0000
+
+    [func.bind.is{bind,place}] Don't begin sentences with code.
+
+commit 7b704e1759cb09b65c0443c9f63b4773b153d000
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Sun Feb 5 04:46:40 2017 +0100
+
+    Capitalize examples where appropriate. (#1356)
+
+commit 1e00bc3e8addc7b263ecbc7b2f5a510c904b876c
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sun Feb 5 04:45:13 2017 +0100
+
+    [class.temporary] Use 'Clause~\ref{class.access}' (#1348)
+
+    Fixes #1347.
+
+commit 73b2294ca033dee878d678d5c79adc62e352559e
+Author: Billy O'Neal <billy.oneal@gmail.com>
+Date:   Sat Feb 4 19:44:16 2017 -0800
+
+    [atomics.syn] Don't describe function template overloads as "partial specializations"
+
+commit 41c6bac2314892f1b51b0ef4d22fd7aedb9562a5
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Sun Feb 5 04:43:14 2017 +0100
+
+    [string.io] Don't refer to sentry by name it was not given. (#1333)
+
+commit 4408f4667327fffa4e527995a1b73f674e459927
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sun Feb 5 04:42:14 2017 +0100
+
+    [lib] Replace pre: and post: in requirements tables (#1284)
+
+    with \requires and \postcondition, respectively.
+
+    Also replace yields: with \returns and effect: with \effects.
+
+    Fixes #1281.
+
+commit cf2241bd976a3759a1a036e239471ceda48fb06c
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Sun Feb 5 04:38:27 2017 +0100
+
+    [conv.lval] Split off description of conversion result into dedicated paragraph. (#1318)
+
+commit a665fddad337ac8316695c06730a59e2051eaa5d
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sun Feb 5 04:36:14 2017 +0100
+
+    Harmonize formatting of 'main' function. (#1308)
+
+    Consistently use \tcode{main}.
+    Add cross-references to [basic.start.main].
+
+    Fixes #1304.
+
+commit 6841997d7c36b2a4c14d638de00c1804d018c844
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Sun Feb 5 04:34:59 2017 +0100
+
+    [expr] Split off definition of 'composite pointer type' into dedicated paragraph. (#1300)
+
+commit 7fcb601a9ee72dd45f7df8001c23b9f7cb8b0aca
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Sun Feb 5 04:33:04 2017 +0100
+
+    [strings] Remove remarks that repeat what was stated a few lines before. (#1289)
+
+commit bc106e5f01563337b4069998c6e149b795b65111
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sun Feb 5 03:31:13 2017 +0000
+
+    [tuple.creation] Simplify the introductory notation, and then use notation that matches the introduction. (#1251)
+
+commit e5674e1d47bbd87ecd4caefb3f37c4c3cb3551df
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sun Feb 5 04:30:31 2017 +0100
+
+    [func.bind.bind] Reformat to use math-style indexing. (#1285)
+
+    Partially addresses #1139.
+
+commit 9a5c34e6a8c86a93167724aa5061415f1df8a069
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sun Feb 5 03:30:12 2017 +0100
+
+    [stmt.dcl] Clarify footnote about deadlock avoidance. (#1266)
+
+    Fixes #849.
+
+commit 4b0d533134e61f713a877dadbe6df92f64291d6a
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Dec 16 16:25:04 2016 +0100
+
+    [lib] Harmonize casing for 'shall meet the requirements of ... iterator'.
+
+    Also cross-reference the sections, not the tables, for
+    iterator requirements.
+
+    Fixes #696.
+
+commit 03c356f9d764a8230323bf2fdc77495b98032780
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Dec 16 16:17:02 2016 +0100
+
+    [time.point] Fix cross-reference to clock requirements.
+
+commit 55a498202fb5b558cd93635a63ed111931634b0a
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sun Feb 5 02:01:30 2017 +0100
+
+    [lex.literal] Avoid references to plain 'literal' (#1277)
+
+    unless the \grammarterm is intended.
+
+    Fixes #322.
+
+commit 469e9f021fe65774b5845350be3cff4a12d40680
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Feb 4 21:12:04 2017 +0100
+
+    [namespace.udecl] Clarify error in example. (#1254)
+
+commit 26e92b499f7a41c7b65c7e2828a1608021adf695
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Feb 4 21:02:59 2017 +0100
+
+    [temp.deduct] Avoid talking about 'side effect' and 'evaluation' (#1252)
+
+    when discussing template instantiations.
+
+commit 43c20dbebf207d985f8d051d2994ce22108049e4
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Feb 4 20:52:06 2017 +0100
+
+    [alg.partitions] Move entire subclause to [alg.sorting]. (#1245)
+
+    The non-modifying operation is_partitioned doesn't fit into
+    'mutating sequence operations', and partitioning can be
+    considered a weak sort.
+
+    Fixes #289.
+
+commit 42578d91450b0b563e076151427b6deff4647f6d
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sat Feb 4 19:44:57 2017 +0000
+
+    [macros, styles] Remove minipages from BNF environments and use a custom enumitem list for spacing. (#1170)
+
+    BNF entries are now spaced like normal paragraphs. Individual paragraphs are kept on a single page by setting a high widow penalty.
+
+    It is now immaterial whether multiple nontermdefs are contained in a single bnf environment, or whether each def is in its own environment. Pages can break between elements, not within.
+
+commit 23d739974007c3f827ad2e55da60cb4358681773
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Feb 4 20:19:51 2017 +0100
+
+    [lib] Replace 'Notes:' elements with regular [ Note: ... -- end note] (#1160)
+
+    Remove the \realnotes and \realnote macros.
+    No longer mention 'Notes:' in [structure.specifications].
+
+    Fixes #492.
+
+commit 5a1d430e6c09099ba7e420db733bcf116e8ca868
+Author: Jonathan Wakely <github@kayari.org>
+Date:   Sat Feb 4 19:08:19 2017 +0000
+
+    [streambuf.virt.get] use half-open ranges in underflow effects (#1157)
+
+commit a50661aa098dca6cb7b34061e2d30fd541999cd4
+Author: Jonathan Wakely <github@kayari.org>
+Date:   Sat Feb 4 19:00:02 2017 +0000
+
+    [locale.time.get] change undefined term "record" to "object" (#1412)
+
+commit 3f0133279c6852aa7e7c20c2b5e97f32d80847a8
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Feb 4 19:59:31 2017 +0100
+
+    [support.types] Properly describe <cstddef> header (#1415)
+
+    After the synopsis for <cstddef>, add a sentence (cloned from cstdlib.syn)
+    that the contents are the same as <stddef.h> except for wchar_t,
+    [support.types.nullptr], and [support.types.layout].
+
+    Fixes #1404.
+
+commit 06c788de055ef33fa8aae1d479b01600c399a86b
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Sat Feb 4 19:51:51 2017 +0100
+
+    Don't parenthesize \refs after 'in'/'of'/'notwithstanding'. (#1420)
+
+commit 0f8ca3d7da39bd290062408ca2b2572c40994e9a
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Sat Feb 4 19:50:25 2017 +0100
+
+    [lex.phases] Remove stray period. (#1421)
+
+commit 25fb80b3521531d71bb45c677ed9eace5b39f7ae
+Author: Jonathan Wakely <cxx@kayari.org>
+Date:   Fri Feb 3 18:49:37 2017 +0000
+
+    [forwardlist.ops] Add comma
+
+commit 019585eb4da447ff6a41fa766056b4febff08c25
+Author: timsong-cpp <rs2740@gmail.com>
+Date:   Wed Feb 1 08:17:03 2017 +0800
+
+    [locale.facet] add missing backslash in \defn (#1418)
+
+commit ed8dbf4c0bce4adf96307c1d427dde0685f7dbdf
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Mon Jan 30 13:43:20 2017 +0100
+
+    [dcl.enum] Italicize 'unscoped enumeration' in its definition. (#1410)
+
+commit c7f6a9139872aad48a944d018ce5e4b3de15ce81
+Author: Axel Naumann <github@axel-naumann.de>
+Date:   Thu Jan 26 17:04:41 2017 +0100
+
+    [thread.lock.algorithm] Change '0-based' to 'zero-based'.
+
+    Conforming with other occurrences in the standard.
+
+commit b63d68ab7bc08f5e969a5b44b000941e6e82eb2e
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Sun Jan 22 21:26:37 2017 +0100
+
+    [basic.ios.cons] Remove stray semicolon. (#1397)
+
+commit 701df7eac2474300d2b602700a3c32a51ef439a7
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Sun Jan 22 18:35:35 2017 +0100
+
+    Add missing \pnums. (#1396)
+
+commit 5ce8ed130a43ffc17b1d05d349e9568831016891
+Author: Jonathan Wakely <cxx@kayari.org>
+Date:   Fri Jan 20 17:54:09 2017 +0000
+
+    [special] Add comma.
+
+commit 03c99a1b516a85000456841b061d5b1f17b32e48
+Author: Jonathan Wakely <cxx@kayari.org>
+Date:   Fri Jan 20 17:52:52 2017 +0000
+
+    [optional.ctor] add missing \pnum
+
+commit 4bbb3ba2e4e7065900c12b97710db3e398c6ee2d
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Fri Jan 20 18:48:20 2017 +0100
+
+    [cpp.pragma.op] Add missing \pnums and remove unwanted paragraph breaks. (#1387)
+
+commit d2263429a07205edf8d2ffcd6d41cfe5d61544f8
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Thu Jan 19 00:17:04 2017 +0100
+
+    [dcl.link] Index implementation-defined behavior. (#1330)
+
+    Fixes #1326.
+
+commit 61c4f655ac96e2eba807f8e13f9adae1405bdf49
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Wed Jan 18 23:24:39 2017 +0100
+
+    [dcl.ambig.res] Describe example ambiguous case more clearly. (#1371)
+
+commit 94c7fdf49d51898a10c846bb0409bf07ba66256c
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Wed Jan 18 23:23:57 2017 +0100
+
+    Consistently use 'this International Standard'. (#1380)
+
+commit 95977f18c0594a12a90ca050ec5f8006b4b7bf53
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Wed Jan 18 22:59:08 2017 +0100
+
+    Add missing hyphen in 'floating-point'. (#1319)
+
+commit 2001a03014df142f5f9a5974c64fc2ff96d4f2cd
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Jan 18 22:47:23 2017 +0100
+
+    'floating-point something', not 'floating point something' (#1384)
+
+    Adjust occurrences that spanned a line break in the LaTeX
+    source and were therefore missed in commit
+    cd3deb891cee5436a64ff9a8f7bb304a4fcc6c00.
+
+commit c8295e3a928f93cff021d88b7b1532b5a58d5114
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Jan 18 22:45:41 2017 +0100
+
+    [stmt.stmt], [dcl.attr.deprecated] Remove hyphen in 're-declared' (#1381)
+
+    Fixes #1378.
+
+commit 2b0db35833f8ccce30744b46465e609e4b109366
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Wed Jan 18 14:57:38 2017 +0000
+
+    [utilities.general] Update reference to bitset section and add missing \rowsep
+
+commit 417d713d341911e3e366610c85761d246785f02f
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Wed Jan 18 00:33:11 2017 +0000
+
+    [over.match.best, over.ics.rank] Remove premature ends of sentences.
+
+    This addresses a major part of #90.
+
+commit d76a411d35b1ed933cb5d11dc492ab4489cb239e
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Tue Jan 17 23:48:02 2017 +0000
+
+    [over.ics.rank] Replace self-referential reference with 'this subclause'
+
+commit ee154f9dd08d93124455f408f69030862acca9eb
+Author: Alisdair Meredith <public@alisdairm.net>
+Date:   Mon Jan 16 07:25:43 2017 -0500
+
+    Fix remaining uses of \Cpp macro (#1366)
+
+    I believe this patch catches the last two places in the current
+    draft that should be using a variant of the \Cpp macros to
+    better render the 'C++' string.
+
+commit 4e6dc965fc2a2f562d8bd62cafe5a1d51745a79d
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Fri Jan 13 14:32:39 2017 +0000
+
+    [re] Move long pieces of code into codeblocks and remove redundant "the result of" from return statements
+
+    This fixes overfull hboxes, see #693.
+
+commit ab8f2c7c0331efbb9713a46d4c940df94a0e48f7
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Tue Jan 10 11:04:16 2017 +0100
+
+    [mem.res.pool], [mem.res.monotonic.buffer] Do not define the otherwise unused term 'owns'. (#1260)
+
+    Fixes #1257.
+
+commit 3acb49d296ba7efdc7542e943262138dc0eb9b74
+Author: Jonathan Wakely <cxx@kayari.org>
+Date:   Fri Jan 6 19:21:45 2017 +0000
+
+    [string.insert] Change "pos1" to "pos" for overloads taking one position
+
+    Also make argument names in synopsis consistent.
+
+    Fixes #1338
+
+commit 732fd444a33043bce3caf6d6d939f6e81fb56ddd
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Thu Jan 5 13:04:01 2017 +0100
+
+    [rand.adapt.shuf] Show exposition-only members in the order in which initialization is described. (#1332)
+
+    Fixes #1331.
+
+commit b9081cc3d7a314ac336695166e0123cdb1da6623
+Author: Kazutoshi SATODA <k_satoda@f2.dion.ne.jp>
+Date:   Wed Jan 4 23:31:49 2017 +0900
+
+    [dcl.init] Fix a typo in definition of const-default-constructible (#1327)
+
+commit 10452d174140fbcf0bfc1fab37dbdbd63913be79
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Wed Jan 4 11:45:00 2017 +0100
+
+    [complex.ops] Don't repeat declaration in "Effects:" element. (#1324)
+
+commit 94c2fbabdc1057d7bc7cdb83d1585d24de3fd146
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Tue Jan 3 18:05:03 2017 +0100
+
+    [re.submatch.op] Remove excessive parentheses in "Returns:" element. (#1323)
+
+commit 3b81b0b9cafacee9d23b47d1a8862a9d0eee6ab7
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Tue Jan 3 16:58:58 2017 +0100
+
+    [sf.cmath] Fix 'where' associations of Greek variable names. (#1317)
+
+    Fixes #1291.
+
+commit 2416d453c28a821076a1046bec1b13d6dd8ee7d7
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Tue Jan 3 16:05:27 2017 +0100
+
+    [util.smartptr.enab] Remove leftover postcondition after P0033R1. (#1314)
+
+    Fixes #1299.
+
+commit 0effa034c24cc78f5128d36327f0d30047531b89
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Tue Jan 3 16:02:08 2017 +0100
+
+    [class.derived] Avoid \pnum inside examples. (#1265)
+
+    Fixes #781.
+
+commit 2163ad27876b6e0423650c71b01646a8daca6cdc
+Author: timsong-cpp <rs2740@gmail.com>
+Date:   Tue Jan 3 07:36:29 2017 -0500
+
+    [meta.trans.other] add missing cv for common_type (#1292)
+
+    P0435R1 says 'cv void', but the cv part was dropped.
+
+commit 09e6e6de2e92c33daa53ee1013847df68c99ad52
+Author: alexanderkscott <k878208@mvrht.com>
+Date:   Sat Dec 31 14:06:51 2016 +0000
+
+    [iterators, numerics] Replace 'sub-clause' by 'subclause' (#1302)
+
+commit 2168e10fb3608d4ab84190d3d0c8cd5101dc52b9
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Fri Dec 30 16:46:18 2016 +0100
+
+    Capitalize notes that consist of complete sentences. (#1297)
+
+commit 3681e72ce5b8d0f09e15bfb4fef11bd230951cc6
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Wed Dec 21 18:58:54 2016 +0000
+
+    [conv.qual] Consistent notation for indexed types T_1, T_2
+
+commit 3e2b77aed27438f6751ad59ca75fc90bde79993b
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Dec 21 19:55:02 2016 +0100
+
+    Mechanically harmonize indexed types to $\tcode{T}_i$. (#1283)
+
+    Replace \tcode{T}$_i$  and $T_i$ with $\tcode{T}_i$.
+
+commit 0b9f60c4c373e57cda055b7aba64afb674db1fff
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Wed Dec 21 18:14:54 2016 +0100
+
+    [string.view.find] Add missing 'be' (#1282)
+
+commit d49359badc2115b010dcf978d86067f1a2cfb331
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Tue Dec 20 16:47:32 2016 +0100
+
+    [containers] Replace pre: and post: in requirements tables with \requires and \postcondition, respectively. (#1273)
+
+    Fixes #792.
+
+commit 9fe30c8353b264318a1c90d2ce817347e1f6738c
+Author: Casey Carter <Casey@Carter.net>
+Date:   Sun Dec 18 15:34:21 2016 -0800
+
+    Fix typos in [mem.poly.allocator.mem]/9.1 and /9.5 (#1269)
+
+    (There is no "T" in scope.)
+
+commit 666886e51092f447e9ecb6f26a2965a8c03da667
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Mon Dec 19 00:31:51 2016 +0100
+
+    [associative.reqmts] Harmonize capitalization. (#1271)
+
+    Older entries seem to start with a lowercase letter and only
+    have a full stop if a second sentence follows.  For newer
+    entries (initializer lists, node_handle functions), apply
+    that style, too.
+
+    Fixes #328.
+
+commit a3afbc8daaa557cc0cd1f76e40158032ca6f097f
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Dec 16 15:47:47 2016 +0100
+
+    Avoid \pnum inside examples. (#1262)
+
+    With the exception of [facets.examples].
+
+    Fixes #781.
+
+commit 5d129b232ac55abeb508a8f890d478a45eab5554
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Dec 16 12:43:55 2016 +0100
+
+    [dcl.array], [temp.deduct.type] Split notes spanning numbered paragraphs. (#1261)
+
+    Partially addresses #781.
+
+commit 3750b234c1699d2c7b0f83e2c52fbd65d74c4299
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Thu Dec 15 17:43:32 2016 +0100
+
+    [unique.ptr.single.modifiers] Use 'if and only if' when calling deleter. (#1255)
+
+    Fixes #248.
+
+commit 8e64a085cdcd7c41b3f4d4298933cb52b6572420
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Thu Dec 15 17:42:24 2016 +0100
+
+    [sf.math] Promote parenthesized parts of function names to un-parenthesized. (#1256)
+
+    Fixes #1250.
+
+commit f8904bd946650f240a6af76193f406377e2fb1b7
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Nov 30 19:50:31 2016 +0100
+
+    [support.limits] Rearrange section 'Implementation properties'
+
+     - Change order of subsections.
+     - Remove [limits] and [c.limits] subsection headings.
+     - Move descriptions of numeric_limits members and specializations as
+       subsections under the description of the primary class template.
+     - Add sectioning comments to the <limits> synopsis.
+
+    Fixes #785.
+
+commit 9a6d4c3a14d77eaea17044e3b52942582d65eac8
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Thu Dec 15 00:29:13 2016 +0000
+
+    [forward] Remove mid-example paragraph breaks
+
+commit 7f7e757693b3173d9490e63e28f384fbba7dcd91
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Wed Dec 14 23:49:59 2016 +0000
+
+    Change a few stray headings to sentence case
+
+    Fixes #1200 and #1201.
+
+commit 32026a5b490a8f0b310530425108247694968def
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Mon Nov 21 22:45:55 2016 +0100
+
+    [class.copy] Rephrase rule preferring a move constructor
+    in a throw-expression or a return statement.
+
+    Fixes #712.
+
+commit 19a0c06093e39f5b0a85316f2564312c9e52b129
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Wed Dec 7 20:02:50 2016 +0000
+
+    [temp.class] Reorganize examples into a separate paragraph
+
+commit 64e5cffbef31b7a00175d969fae2cf5f70c27f48
+Author: W-E-Brown <webrown.cpp@gmail.com>
+Date:   Wed Dec 14 17:03:23 2016 -0600
+
+    s/(possibly cv-qualified)/\\cv{}~/ and allied changes (#1142)
+
+    Applied across the entire standard.
+
+commit 571a258bd4d59725e1bbbb69febaffb3d3a513ed
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Wed Dec 14 22:55:05 2016 +0000
+
+    [input.output] Add references to inclusions in a synopsis
+
+commit eacf4129776df8481599ec44e0c256590aed1ccb
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sat Dec 10 17:56:41 2016 +0000
+
+    [{ex,in}clusive.scan, transform.{ex,in}clusive.scan]: Rephase 'for each *j' in terms of indexes
+
+    Addresses #693 for this part, but is also clearer.
+
+commit c39761a36fed573e369ccccd81f54ee2c9f69930
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Dec 14 21:13:57 2016 +0100
+
+    [iostream.forward.overview] Promote introductory
+    sentences to normative text.
+
+    Fixes #494.
+
+commit 5f0f4df6ab6dfa566d394da9c4321c1015f63747
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Wed Dec 14 12:21:10 2016 -0800
+
+    [basic.def.odr] Clarify that the "not an odr use" requirement for using
+    an internal linkage constant within an inline function (etc) only
+    applies to odr-uses within that inline function, and not uses elsewhere
+    in the program.
+
+commit 2f3c3b8c3a401fd6d8f081b608db6572be01b7e0
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Dec 14 18:46:51 2016 +0100
+
+    [temp] Add variable templates to the definition of 'template'. (#1225)
+
+    Fixes #593.
+
+commit f32e068898a371b94a27f895f3863a810186e70e
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Dec 14 18:38:09 2016 +0100
+
+    [unord] Use 'key equality predicate' consistently. (#1241)
+
+    Replaces occasional uses of 'key equality function'.
+
+    Fixes #630.
+
+commit b54f2507ffc23c0e573f4637217003b4074c33aa
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Wed Dec 14 18:37:20 2016 +0100
+
+    [strings, algorithms, diff] Replace 'routine' with 'function'. (#1217)
+
+commit 7b087da9cd6867fd6b8b499c6ec766499db48772
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Wed Dec 14 17:58:47 2016 +0100
+
+    [class.derived] Don't bother splitting last remark in note off into separate paragraph. (#1240)
+
+commit c6d00d91a0c464c528c6cd38c442ad6a11036aa7
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Wed Dec 14 17:22:14 2016 +0100
+
+    [dcl.init, class.directory_iterator, fs.op.current_path] Split multiparagraph notes into multiple note paragraphs.
+
+    The paragraphs are unrelated and don't belong into a single note.
+
+commit f66fb79c44dc6051aa83d6489fee707a584ebe82
+Author: Johannes Laire <johannes@laire.fi>
+Date:   Wed Dec 14 15:46:57 2016 +0000
+
+    [lib] Fix capitalization and punctuation in itemdescrs. (#1238)
+
+commit 6407d69c8e98e5d94e623c4cf84b1419ae12de62
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Wed Dec 14 15:56:12 2016 +0100
+
+    [path.non-member] Structure multi-paragraph note using an itemization instead. (#1236)
+
+commit edd2c5fb29b2feb6a6acc23f843d351a8f06b2ec
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Wed Dec 14 14:35:44 2016 +0000
+
+    [cstdint.syn] Add cross reference to C
+
+commit 122b2d896fe4049e30afb498b0e59be399dc0e45
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Wed Dec 14 02:53:47 2016 +0000
+
+    [temp] Misc tweaks: tcode, ellipses, capitalization, comment spacing
+
+commit 4da0a38a1982e4cb65a06848051ca4c5a43b04bd
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Dec 14 14:52:36 2016 +0100
+
+    [string.view.hash] Add a note about equality to string hashes. (#1235)
+
+    From http://lists.isocpp.org/lib/2016/12/1531.php.
+
+commit 776fd05bf781b265cfc96711d2abfd49a781ea20
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Wed Dec 14 02:15:49 2016 +0000
+
+    Use \commentellip macro in a few more places
+
+commit 81eea5e1b5a477404b39176f71699f7b87a2dc01
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Wed Dec 14 01:22:29 2016 +0000
+
+    [over.match.best] Convert footnote into ordinary note and remove overly tutorialisque explanations
+
+    Fixes #1232.
+
+commit 93631694be2ac0cd0aade763e50a49bef8f9c4b4
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Dec 14 00:54:29 2016 +0100
+
+    [localization] Add numbered headings for synopses. (#1229)
+
+    Also remove use of \synopsis for class template definitions.
+
+    Partially addresses #566.
+
+commit 93ccb079c2a809aded1d71a21e783560be019492
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Dec 14 00:49:33 2016 +0100
+
+    [algorithms] Add numbered heading for synopsis. (#1230)
+
+    Partially addresses #566.
+
+commit e6b9e3124c58f91f8d624f3d512f1f786e1f5adb
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Dec 14 00:22:55 2016 +0100
+
+    [input.output] Add numbered headings for synopses. (#1228)
+
+    Remove now-empty 'Overview' sections.
+
+    Partially addresses #566.
+
+commit c9688d7dc5e4471868d84f92d98c43a01e7465e2
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Tue Dec 13 23:31:04 2016 +0100
+
+    [mem.res.monotonic.buffer.ctor] Spell reference to a parameter correctly. (#1226)
+
+    Fixes #1055.
+
+commit a3f3773d4ca287c252a485c343348c729f60c82d
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Tue Dec 13 23:06:39 2016 +0100
+
+    [lib] Use 'comparison function', not 'comparison operator'. (#1224)
+
+    When talking about an operator function, use the term defined in
+    [defns.comparison].
+
+    Fixes #612.
+
+commit 8b1f6cc8d73eec0306db1dec66f2da52a03ea274
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Tue Dec 13 22:28:40 2016 +0100
+
+    [any] Rename the ValueType template parameter to T. (#1220)
+
+    The parameter has a confusing name: It is not actually the value type
+    contained in the 'any'.
+    Where the new T clashes with an existing use of T, rename the latter to VT,
+    since this is actually the value type of the 'any'.
+
+    Fixes #1202.
+
+commit e4bc84c405ac09ff7a5aa5b8df39d5e1f5b7bd39
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Tue Dec 13 21:56:10 2016 +0100
+
+    [dcl.init.ref] Replace 'type qualifier' with 'cv-qualifier' in example. (#1222)
+
+    Fixes #1219.
+
+commit 1894a77ec88dd28d87985e162ef57c45580a9ad2
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Tue Dec 13 21:53:28 2016 +0100
+
+    [list.ops] Move effects to 'Effects' element. (#1221)
+
+    Also reorder the elements so that 'Requires' is before 'Effects'.
+
+    Fixes #796.
+
+commit aefc83c6c66013c5053f4c184c4fd7bf400e96fe
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Tue Dec 13 18:20:02 2016 +0100
+
+    [utility], [bitset] Introduce a separate heading for the synopsis. (#1213)
+
+    Partially addresses #566.
+
+commit 0a3f38c33d4fb7459fb507faf88591bc1828b31c
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Tue Dec 13 18:19:08 2016 +0100
+
+    [bitset.members] Adjust confusing index entries for 'set' and 'any'. (#1218)
+
+    Fixes #743.
+
+commit bc42416f97adb35907af7af8fe407d3a445a1824
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Mon Dec 12 23:56:13 2016 +0100
+
+    [thread] Add numbered headings for synopses. (#1214)
+
+    Partially addresses #566.
+
+commit 546a162c06881491f8394babb4147941f2af53ee
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Mon Dec 12 16:45:28 2016 +0100
+
+    [pairs.spec], [tuple.creation] Avoid 'equality' of types phrasing. (#1212)
+
+    Fixes #491.
+
+commit 5ec123d3e037fc3b85542ea2f31b86c6375d7c06
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Mon Dec 12 16:25:47 2016 +0100
+
+    [class.temporary] Add paragraph number and split off example into its own paragraph. (#1211)
+
+commit a8a89d9144a9050b85b8bfe780340a763193a1f4
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Mon Dec 12 14:46:31 2016 +0000
+
+    [pairs.pair, tuple.cnstr] Replace 'The constructor initializes' with just 'Initializes', which is how we say it in many other places. (#1206)
+
+commit 3c6ba0621a8e23c474f77fbee24b06d76b125dd3
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Mon Dec 12 01:50:27 2016 +0000
+
+    [special] Capitalize notes and examples that are complete sentences.
+
+commit 3a0d1be2ccd055f6bef1e91ebc2ca7ee19f3638e
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Mon Dec 12 01:33:44 2016 +0000
+
+    [class.cdtor] Clarify presentation of example
+
+    Seperate the hypothetical alternative case from the real code with newlines and describe in irrealis mood.
+
+commit 33375c726c64c4e602b52269708441f5cdccfa77
+Author: Sergey Zubkov <cubbi@cubbi.com>
+Date:   Sun Dec 11 07:20:28 2016 -0500
+
+    [mem.res.syn] Call polymorphic_allocator a 'class template' (#1209)
+
+commit fdb5d1a7ed71add105ee5eca4307d9a6a042ba75
+Author: Sergey Zubkov <cubbi@cubbi.com>
+Date:   Sun Dec 11 07:11:28 2016 -0500
+
+    [variant.bad.access] Use 'override' instead of 'virtual' in synopsis (#1208)
+
+commit edba6d4a097e9de2caa79461341b3c3476941790
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sat Dec 10 19:50:28 2016 +0000
+
+    [diff.cpp03.special] Use the more correct "call function f" rather than "call function f()" to resolve overfull line and fulfil compulsion for pedantry.
+
+commit 3c6d91088e58e56e295419efdd47ddc8a4628196
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sat Dec 10 17:10:54 2016 +0000
+
+    [func.not_fn] Clean-up not_fun
+
+    Use placeholder macros. Reformat class synopsis in our usual style. Reorder private members. Use codeblocks for long descriptions.
+
+    Addresses #693.
+
+commit 2b17f472d2c1fcfb96f5f9d4f5f7d799c6d336ae
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sat Dec 10 17:09:25 2016 +0000
+
+    [mem.res.pool.mem] Reorder and reflow do_is_equal descriptions.
+
+    Addresses #693 for that section.
+
+commit f9ce3d269eb5bd2ffd3bb74f79ba1298da1d83bc
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sat Dec 10 16:34:41 2016 +0000
+
+    [tuple.helper, variant.helper] Change "specialization of *class*" to "specialization of *template*".
+
+    The containing lines were too long (cf. #693), and the change is a mild increase in pedantic correctness.
+
+commit faaf054bd237780b3999c4efdbbcc2b6bf88721b
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Dec 9 23:32:42 2016 +0100
+
+    [limits] Use 'subnormal number' as defined by IEEE 754-2008 = ISO 60559. (#1203)
+
+    Also add index entries for 'denormalized value' and 'value,
+    denormalized', pointing to 'number, subnormal'.
+
+    Fixes #1017.
+
+commit 4f182cba568b3f753d2bdeb61c349bd65b8bf241
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Thu Dec 8 23:02:33 2016 +0100
+
+    [util.smartptr.shared.atomic] Merge duplicate description items.
+
+    Partially addresses #288.
+
+commit b22cda3a831508a362930f6eb25d1f839f0f8ea8
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Thu Dec 8 22:57:32 2016 +0100
+
+    [alg.lex.comparison] Remove duplicate 'Remarks:' item and comfort lone codeblock
+
+    Partially addresses #288.
+
+commit faecbe8a6f3db2bd411b64428c1f3345b1677550
+Author: Johannes Laire <johannes@laire.fi>
+Date:   Thu Dec 8 15:19:45 2016 +0000
+
+    [rand.req.adapt] Fix syntax error (#1194)
+
+commit a9159bdbf9b6baa096f2c51d9129cd03431d03bd
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Thu Dec 8 16:08:58 2016 +0100
+
+    [numeric.special] Remove redundant 'inline' specifiers in example. (#1192)
+
+commit ff36dc5f586abb837a3963b1b8815a245bdbc741
+Author: Johannes Laire <johannes@laire.fi>
+Date:   Thu Dec 8 10:47:07 2016 +0000
+
+    [depr] Add missing parentheses around bitwise expressions (#1191)
+
+commit b6d625f215dbac299982094cf54e4fed0999e873
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Thu Dec 8 10:06:47 2016 +0000
+
+    Hyphenate 'implementation-defined' in a few residual cases
+
+commit 77f36805a4adc0a5d145264fc5e5e6ab11b5e8f2
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Fri Dec 2 02:58:22 2016 +0000
+
+    [dcl.align] Touch up error comments
+
+commit 6d082aa3bed44e5342e55d19453d9669671063fa
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Dec 7 23:07:21 2016 +0100
+
+    [intseq.general] Remove example not quite mirroring a standard function. (#1187)
+
+    Fixes #1176.
+
+commit 426dd1880198d5aaa51ae189d3e1d3780d3da1ce
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Dec 7 22:28:33 2016 +0100
+
+    [containers, alg.transform] Minor presentation fixes. (#1184)
+
+    Harmonize the punctuation in complexity requirements where a definition
+    for N is introduced.
+    Add a missing closing parenthesis.
+    Add a full stop.
+
+    Fixes #191.
+
+commit ff91738d4f67123fa944a76506826f7a3c14b3e2
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Dec 7 21:25:39 2016 +0100
+
+    [class.virtual] Remove awkward 'but'. (#1182)
+
+    Fixes #170.
+
+commit 4975167baaed59b6b3aab9d93ea14682c45a6217
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Dec 7 20:44:25 2016 +0100
+
+    [function.objects] Introduce a new subsection for the <functional> synopsis. (#1179)
+
+    Also add a cross-reference from [unord.hash] to the synopsis, which
+    is the only place where the primary template is declared.
+
+    Fixes #192.
+
+commit d4c17ce01bf7b1419b330e798119b838ab8f1380
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Dec 7 20:07:18 2016 +0100
+
+    [pairs.pair] Further harmonize spelling of template parameters for pair<U1, U2>. (#1178)
+
+    Fixes #125.
+
+commit 10ae5c39b0d4065486974c1c80d338b904a9f013
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Wed Dec 7 12:13:32 2016 +0100
+
+    Capitalize examples outside sentences. (#1174)
+
+commit 5301db44da7db8839114f9c032e7fe293da31879
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Wed Dec 7 11:25:11 2016 +0100
+
+    Capitalize notes. (#1173)
+
+commit d2a69983b30ba4a3dec9bece774cb11fe50353c1
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Wed Dec 7 01:37:27 2016 +0000
+
+    [stmt.stmt] Align comments to customary columns and reflow some very narrow comments
+
+commit 1fe866912ad07ea76353bb08723aad8552620f7c
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Dec 7 01:55:54 2016 +0100
+
+    [utility] Harmonize spelling of template parameters for std::pair<T1,T2>. (#1172)
+
+    Addresses #125.
+
+commit 99c6b4c6d08b99b36a10a50127b43ab461fd2f57
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sat Dec 3 00:43:13 2016 +0000
+
+    [expr] Use same notation for collections of cv-qualification signatures as in [conv.qual]
+
+commit 2df5c6df7ee8cd884da607897b229cc8e1913ecb
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Tue Nov 29 02:47:55 2016 +0000
+
+    [basic] Reflow comments to be more compact; use math set notation for sets
+
+commit 28b0897221d9b641ef8439cfd29ef81b7d1f81b6
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Dec 2 00:40:17 2016 +0100
+
+    [headers, depr.c.headers] Avoid brittle counts of headers. (#1167)
+
+    Fixes #766.
+
+commit cf522b9177c01511a8c0b7197d9e48aa2224512d
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Thu Dec 1 23:58:40 2016 +0100
+
+    [utilities] Do not use CamelCase for 'BaseCharacteristic'. (#1164)
+
+    This is a regular English phrase used as a technical term.
+
+    Fixes #1154.
+
+commit 69d8903278277e96779c8435fedad0018fe10ee4
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Thu Dec 1 23:52:01 2016 +0100
+
+    [re.regex] Add missing 'multiline' constant. (#1162)
+
+    Fixes #1129.
+
+commit 19dc0aa5c8b8b53f0bfe17724fb26795c187c10a
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Fri Oct 21 11:39:17 2016 -0700
+
+    [dcl.init.aggr] Wording simplification. Aggregate elements are only
+    defined for purposes of aggregate initialization; we don't need to
+    repeat that every time we use the term.
+
+commit cca5257d60abcf9a62f545e9c146fe2c367f843a
+Author: Johannes Laire <johannes@laire.fi>
+Date:   Wed Nov 30 00:03:04 2016 +0000
+
+    Move punctuation outside quotation marks according to logical nesting (#1148)
+
+commit a69d5beeaf1041c064cbad97db9b05a7e6ce079c
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Tue Nov 29 23:57:44 2016 +0000
+
+    [expr.prim.lambda] Move first paragraph below grammar.
+
+    Text before the main grammar needs to be very short; this first paragraph was getting out of hand.
+
+commit c58e854d79a71d7494c6c1bcf496c6795f10821b
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Tue Nov 29 21:47:05 2016 +0000
+
+    [string.classes] Turn <string> synopsis into numbered subclause
+
+    In pursuit of issue #566.
+
+commit 30e55475c622cdda9274f5d3af79eae416b650ef
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Tue Nov 29 21:38:41 2016 +0000
+
+    [tuple, variant] Turn synopses into numbered subclauses
+
+    In pursuit of issue #566.
+
+commit 48efdfe014549e6d116ce12ca427f7df0e0f8c70
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Tue Nov 29 19:58:48 2016 +0000
+
+    [pairs.pair], [tuple.tuple] Tidy up presentation of member functions (order elements consistently; use better index notation)
+
+    Also fixes issue #1117 and partially addresses issue #653.
+
+commit 807e6f951e19e418cbc379797d1c32e4b8a49dca
+Author: Johannes Laire <johannes@laire.fi>
+Date:   Tue Nov 29 12:37:17 2016 -0500
+
+    [library] Capitalize headings
+
+commit bcd2eb6e3cfd68d90b4b761df8dd0728e4e0629b
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Tue Nov 29 02:52:44 2016 +0000
+
+    [basic.def.odf] Clarify example by adding a variable that actually odr-uses D()
+
diff --git a/papers/n4639.md b/papers/n4639.md new file mode 100644 index 0000000000..291425caff --- /dev/null +++ b/papers/n4639.md @@ -0,0 +1,1243 @@ +# N4639 Editors' Report -- Working Draft, Standard for Programming Language C++ + +2016-02-06 +Richard Smith (editor) (Google Inc) +Dawn Perchik (co-editor) (Embarcadero Technologies Inc) +Thomas Köppe (co-editor) (Google DeepMind) +`` + +## Acknowledgements + +Special thanks to +Jens Maurer +for performing many of the editorial fixes since N4618. + +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 + + * N4639 is this Editors' Report. + * [N4640](http://wg21.link/n4640) is the current working draft. It replaces [N4618](http://wg21.link/n4618). + +### Motions incorporated into working draft + +This revision contains only editorial changes relative to N4618. + +## Notable editorial changes + + * Jens Maurer performed a cleanup of the `valarray` wording, converting it + to use the standard formatting style and descriptive elements for library + wording. Thanks also to Jonathan Wakely and Marshall Clow for verifying + that this change preserves the normative meaning. + + * [alg.partitions] is now nested under [alg.sorting] rather than + [alg.modifying.operations]. This is a better fit because `partition` is a + partial sort (just like `nth_element` is), and `is_partitioned` is not a + mutating sequecne operation. + +## Minor editorial fixes + +A log of editorial fixes made since N4618 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/n4618...n4640). + + commit f77a2b27e9e68eacedb23d675d2d257125f3a7e7 + Author: Jens Maurer + Date: Mon Feb 6 19:54:31 2017 +0100 + + Define 'object type' only once. (#1268) + + There were only a few references to the definition in + 1.8 [intro.object], so drop that definition and refer + to 'type of an object' instead. + + Fixes #511. + + commit fec48d5db12705f1fcec4be6a9ceb3a067c305cd + Author: Eelis + Date: Mon Feb 6 03:09:41 2017 +0100 + + [valarray.access] 'evaluates as' -> 'evaluates to'. (#1337) + + commit b79c41937b0150569e1428d1093d9504762f15dd + Author: Jens Maurer + Date: Mon Feb 6 02:02:39 2017 +0100 + + [numarray] Add standard description elements. (#1215) + + Partially addresses #1071. + + commit 1f8ab13005ff2820d4044c6707a1dabfebce2c1b + Author: Jens Maurer + Date: Mon Feb 6 02:01:59 2017 +0100 + + [dcl.init.aggr] Add example for array of unknown bound (#1270) + + * Consistently refer to 'array of unknown bound' + not 'array of unknown size'; see [dcl.array]. + + * [dcl.init.aggr] Add example for array of unknown bound + as non-static data member. + + Addresses core issue 1985. + + Fixes #396. + + commit ec9f102dec2e4624750f01cdebc6f7132361edaa + Author: Thomas Köppe + Date: Sun Feb 5 17:39:12 2017 +0000 + + [cinttypes.syn] Add missing 'the', capitalize sentence + + commit e23a5df2f8819c88b87e3392d6522b747481e381 + Author: Thomas Köppe + Date: Sun Feb 5 17:13:46 2017 +0000 + + [iostream.format] Minor rewording to be more accurate and fit the lines better + + commit 1a0dd180eb3ea3af05cdf1f573eb6f69b0f1b152 + Author: Thomas Köppe + Date: Sun Feb 5 14:51:08 2017 +0000 + + Format "i^th" consistently. + + Fixes #653, see also #974. + + commit 24900a40ed833ccebb1f3760efe366e4ba73109a + Author: Thomas Köppe + Date: Sun Feb 5 14:26:33 2017 +0000 + + [cpp] Swap "control-line" and "if-section". + + With the increased vertical grammar spacing, it is expedient to put the presentation of "control-line" onto the first page so as not to require a huge gap. + + commit 4935ed404aa4819e63c560aa2104dbfa70d18f40 + Author: Thomas Köppe + Date: Sun Feb 5 13:09:48 2017 +0000 + + [ratio.{syn,comparison}] Mild reformatting for consistency. + + Fixes #1402. + + commit 50353bd3bb69d770d00e2fb9236bc913994b96c7 + Author: Thomas Köppe + Date: Sun Feb 5 13:03:56 2017 +0000 + + [associative.set.syn] Fix cross-reference link for 'multiset' + + Fixes #1424. + + commit 766792134b9edb507c569ead9745d12c56735115 + Author: Thomas Köppe + Date: Sun Feb 5 12:20:50 2017 +0000 + + [algorithms.parallel] Add missing \pnum + + Fixes #1432. + + commit e88d2343b441b399673aa934de766323c68353f5 + Author: Marshall Clow + Date: Sat Feb 4 20:48:13 2017 -0800 + + [string.view.template] Change the `reference`, `pointer` etc typedefs in `string_view` to use `value_type` rather than `charT` (#1416) + + This is a cut down version of https://github.com/cplusplus/draft/pull/141, to ensure that it is editorial + + commit 04fa63d98ac28457ea038b75fa05f49d14d8ab5b + Author: Jens Maurer + Date: Sun Feb 5 05:12:58 2017 +0100 + + Use 'base class subobject', not 'base subobject' (#1382) + + Fixes #1379. + + commit 2de42d5a857886ee1200990ce40f7d8e61eb2293 + Author: Thomas Köppe + Date: Sun Feb 5 04:07:38 2017 +0000 + + [func.bind.is{bind,place}] Don't begin sentences with code. + + commit 7b704e1759cb09b65c0443c9f63b4773b153d000 + Author: Eelis + Date: Sun Feb 5 04:46:40 2017 +0100 + + Capitalize examples where appropriate. (#1356) + + commit 1e00bc3e8addc7b263ecbc7b2f5a510c904b876c + Author: Jens Maurer + Date: Sun Feb 5 04:45:13 2017 +0100 + + [class.temporary] Use 'Clause~\ref{class.access}' (#1348) + + Fixes #1347. + + commit 73b2294ca033dee878d678d5c79adc62e352559e + Author: Billy O'Neal + Date: Sat Feb 4 19:44:16 2017 -0800 + + [atomics.syn] Don't describe function template overloads as "partial specializations" + + commit 41c6bac2314892f1b51b0ef4d22fd7aedb9562a5 + Author: Eelis + Date: Sun Feb 5 04:43:14 2017 +0100 + + [string.io] Don't refer to sentry by name it was not given. (#1333) + + commit 4408f4667327fffa4e527995a1b73f674e459927 + Author: Jens Maurer + Date: Sun Feb 5 04:42:14 2017 +0100 + + [lib] Replace pre: and post: in requirements tables (#1284) + + with \requires and \postcondition, respectively. + + Also replace yields: with \returns and effect: with \effects. + + Fixes #1281. + + commit cf2241bd976a3759a1a036e239471ceda48fb06c + Author: Eelis + Date: Sun Feb 5 04:38:27 2017 +0100 + + [conv.lval] Split off description of conversion result into dedicated paragraph. (#1318) + + commit a665fddad337ac8316695c06730a59e2051eaa5d + Author: Jens Maurer + Date: Sun Feb 5 04:36:14 2017 +0100 + + Harmonize formatting of 'main' function. (#1308) + + Consistently use \tcode{main}. + Add cross-references to [basic.start.main]. + + Fixes #1304. + + commit 6841997d7c36b2a4c14d638de00c1804d018c844 + Author: Eelis + Date: Sun Feb 5 04:34:59 2017 +0100 + + [expr] Split off definition of 'composite pointer type' into dedicated paragraph. (#1300) + + commit 7fcb601a9ee72dd45f7df8001c23b9f7cb8b0aca + Author: Eelis + Date: Sun Feb 5 04:33:04 2017 +0100 + + [strings] Remove remarks that repeat what was stated a few lines before. (#1289) + + commit bc106e5f01563337b4069998c6e149b795b65111 + Author: Thomas Köppe + Date: Sun Feb 5 03:31:13 2017 +0000 + + [tuple.creation] Simplify the introductory notation, and then use notation that matches the introduction. (#1251) + + commit e5674e1d47bbd87ecd4caefb3f37c4c3cb3551df + Author: Jens Maurer + Date: Sun Feb 5 04:30:31 2017 +0100 + + [func.bind.bind] Reformat to use math-style indexing. (#1285) + + Partially addresses #1139. + + commit 9a5c34e6a8c86a93167724aa5061415f1df8a069 + Author: Jens Maurer + Date: Sun Feb 5 03:30:12 2017 +0100 + + [stmt.dcl] Clarify footnote about deadlock avoidance. (#1266) + + Fixes #849. + + commit 4b0d533134e61f713a877dadbe6df92f64291d6a + Author: Jens Maurer + Date: Fri Dec 16 16:25:04 2016 +0100 + + [lib] Harmonize casing for 'shall meet the requirements of ... iterator'. + + Also cross-reference the sections, not the tables, for + iterator requirements. + + Fixes #696. + + commit 03c356f9d764a8230323bf2fdc77495b98032780 + Author: Jens Maurer + Date: Fri Dec 16 16:17:02 2016 +0100 + + [time.point] Fix cross-reference to clock requirements. + + commit 55a498202fb5b558cd93635a63ed111931634b0a + Author: Jens Maurer + Date: Sun Feb 5 02:01:30 2017 +0100 + + [lex.literal] Avoid references to plain 'literal' (#1277) + + unless the \grammarterm is intended. + + Fixes #322. + + commit 469e9f021fe65774b5845350be3cff4a12d40680 + Author: Jens Maurer + Date: Sat Feb 4 21:12:04 2017 +0100 + + [namespace.udecl] Clarify error in example. (#1254) + + commit 26e92b499f7a41c7b65c7e2828a1608021adf695 + Author: Jens Maurer + Date: Sat Feb 4 21:02:59 2017 +0100 + + [temp.deduct] Avoid talking about 'side effect' and 'evaluation' (#1252) + + when discussing template instantiations. + + commit 43c20dbebf207d985f8d051d2994ce22108049e4 + Author: Jens Maurer + Date: Sat Feb 4 20:52:06 2017 +0100 + + [alg.partitions] Move entire subclause to [alg.sorting]. (#1245) + + The non-modifying operation is_partitioned doesn't fit into + 'mutating sequence operations', and partitioning can be + considered a weak sort. + + Fixes #289. + + commit 42578d91450b0b563e076151427b6deff4647f6d + Author: Thomas Köppe + Date: Sat Feb 4 19:44:57 2017 +0000 + + [macros, styles] Remove minipages from BNF environments and use a custom enumitem list for spacing. (#1170) + + BNF entries are now spaced like normal paragraphs. Individual paragraphs are kept on a single page by setting a high widow penalty. + + It is now immaterial whether multiple nontermdefs are contained in a single bnf environment, or whether each def is in its own environment. Pages can break between elements, not within. + + commit 23d739974007c3f827ad2e55da60cb4358681773 + Author: Jens Maurer + Date: Sat Feb 4 20:19:51 2017 +0100 + + [lib] Replace 'Notes:' elements with regular [ Note: ... -- end note] (#1160) + + Remove the \realnotes and \realnote macros. + No longer mention 'Notes:' in [structure.specifications]. + + Fixes #492. + + commit 5a1d430e6c09099ba7e420db733bcf116e8ca868 + Author: Jonathan Wakely + Date: Sat Feb 4 19:08:19 2017 +0000 + + [streambuf.virt.get] use half-open ranges in underflow effects (#1157) + + commit a50661aa098dca6cb7b34061e2d30fd541999cd4 + Author: Jonathan Wakely + Date: Sat Feb 4 19:00:02 2017 +0000 + + [locale.time.get] change undefined term "record" to "object" (#1412) + + commit 3f0133279c6852aa7e7c20c2b5e97f32d80847a8 + Author: Jens Maurer + Date: Sat Feb 4 19:59:31 2017 +0100 + + [support.types] Properly describe header (#1415) + + After the synopsis for , add a sentence (cloned from cstdlib.syn) + that the contents are the same as except for wchar_t, + [support.types.nullptr], and [support.types.layout]. + + Fixes #1404. + + commit 06c788de055ef33fa8aae1d479b01600c399a86b + Author: Eelis + Date: Sat Feb 4 19:51:51 2017 +0100 + + Don't parenthesize \refs after 'in'/'of'/'notwithstanding'. (#1420) + + commit 0f8ca3d7da39bd290062408ca2b2572c40994e9a + Author: Eelis + Date: Sat Feb 4 19:50:25 2017 +0100 + + [lex.phases] Remove stray period. (#1421) + + commit 25fb80b3521531d71bb45c677ed9eace5b39f7ae + Author: Jonathan Wakely + Date: Fri Feb 3 18:49:37 2017 +0000 + + [forwardlist.ops] Add comma + + commit 019585eb4da447ff6a41fa766056b4febff08c25 + Author: timsong-cpp + Date: Wed Feb 1 08:17:03 2017 +0800 + + [locale.facet] add missing backslash in \defn (#1418) + + commit ed8dbf4c0bce4adf96307c1d427dde0685f7dbdf + Author: Eelis + Date: Mon Jan 30 13:43:20 2017 +0100 + + [dcl.enum] Italicize 'unscoped enumeration' in its definition. (#1410) + + commit c7f6a9139872aad48a944d018ce5e4b3de15ce81 + Author: Axel Naumann + Date: Thu Jan 26 17:04:41 2017 +0100 + + [thread.lock.algorithm] Change '0-based' to 'zero-based'. + + Conforming with other occurrences in the standard. + + commit b63d68ab7bc08f5e969a5b44b000941e6e82eb2e + Author: Eelis + Date: Sun Jan 22 21:26:37 2017 +0100 + + [basic.ios.cons] Remove stray semicolon. (#1397) + + commit 701df7eac2474300d2b602700a3c32a51ef439a7 + Author: Eelis + Date: Sun Jan 22 18:35:35 2017 +0100 + + Add missing \pnums. (#1396) + + commit 5ce8ed130a43ffc17b1d05d349e9568831016891 + Author: Jonathan Wakely + Date: Fri Jan 20 17:54:09 2017 +0000 + + [special] Add comma. + + commit 03c99a1b516a85000456841b061d5b1f17b32e48 + Author: Jonathan Wakely + Date: Fri Jan 20 17:52:52 2017 +0000 + + [optional.ctor] add missing \pnum + + commit 4bbb3ba2e4e7065900c12b97710db3e398c6ee2d + Author: Eelis + Date: Fri Jan 20 18:48:20 2017 +0100 + + [cpp.pragma.op] Add missing \pnums and remove unwanted paragraph breaks. (#1387) + + commit d2263429a07205edf8d2ffcd6d41cfe5d61544f8 + Author: Jens Maurer + Date: Thu Jan 19 00:17:04 2017 +0100 + + [dcl.link] Index implementation-defined behavior. (#1330) + + Fixes #1326. + + commit 61c4f655ac96e2eba807f8e13f9adae1405bdf49 + Author: Eelis + Date: Wed Jan 18 23:24:39 2017 +0100 + + [dcl.ambig.res] Describe example ambiguous case more clearly. (#1371) + + commit 94c7fdf49d51898a10c846bb0409bf07ba66256c + Author: Eelis + Date: Wed Jan 18 23:23:57 2017 +0100 + + Consistently use 'this International Standard'. (#1380) + + commit 95977f18c0594a12a90ca050ec5f8006b4b7bf53 + Author: Eelis + Date: Wed Jan 18 22:59:08 2017 +0100 + + Add missing hyphen in 'floating-point'. (#1319) + + commit 2001a03014df142f5f9a5974c64fc2ff96d4f2cd + Author: Jens Maurer + Date: Wed Jan 18 22:47:23 2017 +0100 + + 'floating-point something', not 'floating point something' (#1384) + + Adjust occurrences that spanned a line break in the LaTeX + source and were therefore missed in commit + cd3deb891cee5436a64ff9a8f7bb304a4fcc6c00. + + commit c8295e3a928f93cff021d88b7b1532b5a58d5114 + Author: Jens Maurer + Date: Wed Jan 18 22:45:41 2017 +0100 + + [stmt.stmt], [dcl.attr.deprecated] Remove hyphen in 're-declared' (#1381) + + Fixes #1378. + + commit 2b0db35833f8ccce30744b46465e609e4b109366 + Author: Thomas Köppe + Date: Wed Jan 18 14:57:38 2017 +0000 + + [utilities.general] Update reference to bitset section and add missing \rowsep + + commit 417d713d341911e3e366610c85761d246785f02f + Author: Thomas Köppe + Date: Wed Jan 18 00:33:11 2017 +0000 + + [over.match.best, over.ics.rank] Remove premature ends of sentences. + + This addresses a major part of #90. + + commit d76a411d35b1ed933cb5d11dc492ab4489cb239e + Author: Thomas Köppe + Date: Tue Jan 17 23:48:02 2017 +0000 + + [over.ics.rank] Replace self-referential reference with 'this subclause' + + commit ee154f9dd08d93124455f408f69030862acca9eb + Author: Alisdair Meredith + Date: Mon Jan 16 07:25:43 2017 -0500 + + Fix remaining uses of \Cpp macro (#1366) + + I believe this patch catches the last two places in the current + draft that should be using a variant of the \Cpp macros to + better render the 'C++' string. + + commit 4e6dc965fc2a2f562d8bd62cafe5a1d51745a79d + Author: Thomas Köppe + Date: Fri Jan 13 14:32:39 2017 +0000 + + [re] Move long pieces of code into codeblocks and remove redundant "the result of" from return statements + + This fixes overfull hboxes, see #693. + + commit ab8f2c7c0331efbb9713a46d4c940df94a0e48f7 + Author: Jens Maurer + Date: Tue Jan 10 11:04:16 2017 +0100 + + [mem.res.pool], [mem.res.monotonic.buffer] Do not define the otherwise unused term 'owns'. (#1260) + + Fixes #1257. + + commit 3acb49d296ba7efdc7542e943262138dc0eb9b74 + Author: Jonathan Wakely + Date: Fri Jan 6 19:21:45 2017 +0000 + + [string.insert] Change "pos1" to "pos" for overloads taking one position + + Also make argument names in synopsis consistent. + + Fixes #1338 + + commit 732fd444a33043bce3caf6d6d939f6e81fb56ddd + Author: Jens Maurer + Date: Thu Jan 5 13:04:01 2017 +0100 + + [rand.adapt.shuf] Show exposition-only members in the order in which initialization is described. (#1332) + + Fixes #1331. + + commit b9081cc3d7a314ac336695166e0123cdb1da6623 + Author: Kazutoshi SATODA + Date: Wed Jan 4 23:31:49 2017 +0900 + + [dcl.init] Fix a typo in definition of const-default-constructible (#1327) + + commit 10452d174140fbcf0bfc1fab37dbdbd63913be79 + Author: Eelis + Date: Wed Jan 4 11:45:00 2017 +0100 + + [complex.ops] Don't repeat declaration in "Effects:" element. (#1324) + + commit 94c2fbabdc1057d7bc7cdb83d1585d24de3fd146 + Author: Eelis + Date: Tue Jan 3 18:05:03 2017 +0100 + + [re.submatch.op] Remove excessive parentheses in "Returns:" element. (#1323) + + commit 3b81b0b9cafacee9d23b47d1a8862a9d0eee6ab7 + Author: Jens Maurer + Date: Tue Jan 3 16:58:58 2017 +0100 + + [sf.cmath] Fix 'where' associations of Greek variable names. (#1317) + + Fixes #1291. + + commit 2416d453c28a821076a1046bec1b13d6dd8ee7d7 + Author: Jens Maurer + Date: Tue Jan 3 16:05:27 2017 +0100 + + [util.smartptr.enab] Remove leftover postcondition after P0033R1. (#1314) + + Fixes #1299. + + commit 0effa034c24cc78f5128d36327f0d30047531b89 + Author: Jens Maurer + Date: Tue Jan 3 16:02:08 2017 +0100 + + [class.derived] Avoid \pnum inside examples. (#1265) + + Fixes #781. + + commit 2163ad27876b6e0423650c71b01646a8daca6cdc + Author: timsong-cpp + Date: Tue Jan 3 07:36:29 2017 -0500 + + [meta.trans.other] add missing cv for common_type (#1292) + + P0435R1 says 'cv void', but the cv part was dropped. + + commit 09e6e6de2e92c33daa53ee1013847df68c99ad52 + Author: alexanderkscott + Date: Sat Dec 31 14:06:51 2016 +0000 + + [iterators, numerics] Replace 'sub-clause' by 'subclause' (#1302) + + commit 2168e10fb3608d4ab84190d3d0c8cd5101dc52b9 + Author: Eelis + Date: Fri Dec 30 16:46:18 2016 +0100 + + Capitalize notes that consist of complete sentences. (#1297) + + commit 3681e72ce5b8d0f09e15bfb4fef11bd230951cc6 + Author: Thomas Köppe + Date: Wed Dec 21 18:58:54 2016 +0000 + + [conv.qual] Consistent notation for indexed types T_1, T_2 + + commit 3e2b77aed27438f6751ad59ca75fc90bde79993b + Author: Jens Maurer + Date: Wed Dec 21 19:55:02 2016 +0100 + + Mechanically harmonize indexed types to $\tcode{T}_i$. (#1283) + + Replace \tcode{T}$_i$ and $T_i$ with $\tcode{T}_i$. + + commit 0b9f60c4c373e57cda055b7aba64afb674db1fff + Author: Eelis + Date: Wed Dec 21 18:14:54 2016 +0100 + + [string.view.find] Add missing 'be' (#1282) + + commit d49359badc2115b010dcf978d86067f1a2cfb331 + Author: Jens Maurer + Date: Tue Dec 20 16:47:32 2016 +0100 + + [containers] Replace pre: and post: in requirements tables with \requires and \postcondition, respectively. (#1273) + + Fixes #792. + + commit 9fe30c8353b264318a1c90d2ce817347e1f6738c + Author: Casey Carter + Date: Sun Dec 18 15:34:21 2016 -0800 + + Fix typos in [mem.poly.allocator.mem]/9.1 and /9.5 (#1269) + + (There is no "T" in scope.) + + commit 666886e51092f447e9ecb6f26a2965a8c03da667 + Author: Jens Maurer + Date: Mon Dec 19 00:31:51 2016 +0100 + + [associative.reqmts] Harmonize capitalization. (#1271) + + Older entries seem to start with a lowercase letter and only + have a full stop if a second sentence follows. For newer + entries (initializer lists, node_handle functions), apply + that style, too. + + Fixes #328. + + commit a3afbc8daaa557cc0cd1f76e40158032ca6f097f + Author: Jens Maurer + Date: Fri Dec 16 15:47:47 2016 +0100 + + Avoid \pnum inside examples. (#1262) + + With the exception of [facets.examples]. + + Fixes #781. + + commit 5d129b232ac55abeb508a8f890d478a45eab5554 + Author: Jens Maurer + Date: Fri Dec 16 12:43:55 2016 +0100 + + [dcl.array], [temp.deduct.type] Split notes spanning numbered paragraphs. (#1261) + + Partially addresses #781. + + commit 3750b234c1699d2c7b0f83e2c52fbd65d74c4299 + Author: Jens Maurer + Date: Thu Dec 15 17:43:32 2016 +0100 + + [unique.ptr.single.modifiers] Use 'if and only if' when calling deleter. (#1255) + + Fixes #248. + + commit 8e64a085cdcd7c41b3f4d4298933cb52b6572420 + Author: Jens Maurer + Date: Thu Dec 15 17:42:24 2016 +0100 + + [sf.math] Promote parenthesized parts of function names to un-parenthesized. (#1256) + + Fixes #1250. + + commit f8904bd946650f240a6af76193f406377e2fb1b7 + Author: Jens Maurer + Date: Wed Nov 30 19:50:31 2016 +0100 + + [support.limits] Rearrange section 'Implementation properties' + + - Change order of subsections. + - Remove [limits] and [c.limits] subsection headings. + - Move descriptions of numeric_limits members and specializations as + subsections under the description of the primary class template. + - Add sectioning comments to the synopsis. + + Fixes #785. + + commit 9a6d4c3a14d77eaea17044e3b52942582d65eac8 + Author: Thomas Köppe + Date: Thu Dec 15 00:29:13 2016 +0000 + + [forward] Remove mid-example paragraph breaks + + commit 7f7e757693b3173d9490e63e28f384fbba7dcd91 + Author: Thomas Köppe + Date: Wed Dec 14 23:49:59 2016 +0000 + + Change a few stray headings to sentence case + + Fixes #1200 and #1201. + + commit 32026a5b490a8f0b310530425108247694968def + Author: Jens Maurer + Date: Mon Nov 21 22:45:55 2016 +0100 + + [class.copy] Rephrase rule preferring a move constructor + in a throw-expression or a return statement. + + Fixes #712. + + commit 19a0c06093e39f5b0a85316f2564312c9e52b129 + Author: Thomas Köppe + Date: Wed Dec 7 20:02:50 2016 +0000 + + [temp.class] Reorganize examples into a separate paragraph + + commit 64e5cffbef31b7a00175d969fae2cf5f70c27f48 + Author: W-E-Brown + Date: Wed Dec 14 17:03:23 2016 -0600 + + s/(possibly cv-qualified)/\\cv{}~/ and allied changes (#1142) + + Applied across the entire standard. + + commit 571a258bd4d59725e1bbbb69febaffb3d3a513ed + Author: Thomas Köppe + Date: Wed Dec 14 22:55:05 2016 +0000 + + [input.output] Add references to inclusions in a synopsis + + commit eacf4129776df8481599ec44e0c256590aed1ccb + Author: Thomas Köppe + Date: Sat Dec 10 17:56:41 2016 +0000 + + [{ex,in}clusive.scan, transform.{ex,in}clusive.scan]: Rephase 'for each *j' in terms of indexes + + Addresses #693 for this part, but is also clearer. + + commit c39761a36fed573e369ccccd81f54ee2c9f69930 + Author: Jens Maurer + Date: Wed Dec 14 21:13:57 2016 +0100 + + [iostream.forward.overview] Promote introductory + sentences to normative text. + + Fixes #494. + + commit 5f0f4df6ab6dfa566d394da9c4321c1015f63747 + Author: Richard Smith + Date: Wed Dec 14 12:21:10 2016 -0800 + + [basic.def.odr] Clarify that the "not an odr use" requirement for using + an internal linkage constant within an inline function (etc) only + applies to odr-uses within that inline function, and not uses elsewhere + in the program. + + commit 2f3c3b8c3a401fd6d8f081b608db6572be01b7e0 + Author: Jens Maurer + Date: Wed Dec 14 18:46:51 2016 +0100 + + [temp] Add variable templates to the definition of 'template'. (#1225) + + Fixes #593. + + commit f32e068898a371b94a27f895f3863a810186e70e + Author: Jens Maurer + Date: Wed Dec 14 18:38:09 2016 +0100 + + [unord] Use 'key equality predicate' consistently. (#1241) + + Replaces occasional uses of 'key equality function'. + + Fixes #630. + + commit b54f2507ffc23c0e573f4637217003b4074c33aa + Author: Eelis + Date: Wed Dec 14 18:37:20 2016 +0100 + + [strings, algorithms, diff] Replace 'routine' with 'function'. (#1217) + + commit 7b087da9cd6867fd6b8b499c6ec766499db48772 + Author: Eelis + Date: Wed Dec 14 17:58:47 2016 +0100 + + [class.derived] Don't bother splitting last remark in note off into separate paragraph. (#1240) + + commit c6d00d91a0c464c528c6cd38c442ad6a11036aa7 + Author: Eelis + Date: Wed Dec 14 17:22:14 2016 +0100 + + [dcl.init, class.directory_iterator, fs.op.current_path] Split multiparagraph notes into multiple note paragraphs. + + The paragraphs are unrelated and don't belong into a single note. + + commit f66fb79c44dc6051aa83d6489fee707a584ebe82 + Author: Johannes Laire + Date: Wed Dec 14 15:46:57 2016 +0000 + + [lib] Fix capitalization and punctuation in itemdescrs. (#1238) + + commit 6407d69c8e98e5d94e623c4cf84b1419ae12de62 + Author: Eelis + Date: Wed Dec 14 15:56:12 2016 +0100 + + [path.non-member] Structure multi-paragraph note using an itemization instead. (#1236) + + commit edd2c5fb29b2feb6a6acc23f843d351a8f06b2ec + Author: Thomas Köppe + Date: Wed Dec 14 14:35:44 2016 +0000 + + [cstdint.syn] Add cross reference to C + + commit 122b2d896fe4049e30afb498b0e59be399dc0e45 + Author: Thomas Köppe + Date: Wed Dec 14 02:53:47 2016 +0000 + + [temp] Misc tweaks: tcode, ellipses, capitalization, comment spacing + + commit 4da0a38a1982e4cb65a06848051ca4c5a43b04bd + Author: Jens Maurer + Date: Wed Dec 14 14:52:36 2016 +0100 + + [string.view.hash] Add a note about equality to string hashes. (#1235) + + From http://lists.isocpp.org/lib/2016/12/1531.php. + + commit 776fd05bf781b265cfc96711d2abfd49a781ea20 + Author: Thomas Köppe + Date: Wed Dec 14 02:15:49 2016 +0000 + + Use \commentellip macro in a few more places + + commit 81eea5e1b5a477404b39176f71699f7b87a2dc01 + Author: Thomas Köppe + Date: Wed Dec 14 01:22:29 2016 +0000 + + [over.match.best] Convert footnote into ordinary note and remove overly tutorialisque explanations + + Fixes #1232. + + commit 93631694be2ac0cd0aade763e50a49bef8f9c4b4 + Author: Jens Maurer + Date: Wed Dec 14 00:54:29 2016 +0100 + + [localization] Add numbered headings for synopses. (#1229) + + Also remove use of \synopsis for class template definitions. + + Partially addresses #566. + + commit 93ccb079c2a809aded1d71a21e783560be019492 + Author: Jens Maurer + Date: Wed Dec 14 00:49:33 2016 +0100 + + [algorithms] Add numbered heading for synopsis. (#1230) + + Partially addresses #566. + + commit e6b9e3124c58f91f8d624f3d512f1f786e1f5adb + Author: Jens Maurer + Date: Wed Dec 14 00:22:55 2016 +0100 + + [input.output] Add numbered headings for synopses. (#1228) + + Remove now-empty 'Overview' sections. + + Partially addresses #566. + + commit c9688d7dc5e4471868d84f92d98c43a01e7465e2 + Author: Jens Maurer + Date: Tue Dec 13 23:31:04 2016 +0100 + + [mem.res.monotonic.buffer.ctor] Spell reference to a parameter correctly. (#1226) + + Fixes #1055. + + commit a3f3773d4ca287c252a485c343348c729f60c82d + Author: Jens Maurer + Date: Tue Dec 13 23:06:39 2016 +0100 + + [lib] Use 'comparison function', not 'comparison operator'. (#1224) + + When talking about an operator function, use the term defined in + [defns.comparison]. + + Fixes #612. + + commit 8b1f6cc8d73eec0306db1dec66f2da52a03ea274 + Author: Jens Maurer + Date: Tue Dec 13 22:28:40 2016 +0100 + + [any] Rename the ValueType template parameter to T. (#1220) + + The parameter has a confusing name: It is not actually the value type + contained in the 'any'. + Where the new T clashes with an existing use of T, rename the latter to VT, + since this is actually the value type of the 'any'. + + Fixes #1202. + + commit e4bc84c405ac09ff7a5aa5b8df39d5e1f5b7bd39 + Author: Jens Maurer + Date: Tue Dec 13 21:56:10 2016 +0100 + + [dcl.init.ref] Replace 'type qualifier' with 'cv-qualifier' in example. (#1222) + + Fixes #1219. + + commit 1894a77ec88dd28d87985e162ef57c45580a9ad2 + Author: Jens Maurer + Date: Tue Dec 13 21:53:28 2016 +0100 + + [list.ops] Move effects to 'Effects' element. (#1221) + + Also reorder the elements so that 'Requires' is before 'Effects'. + + Fixes #796. + + commit aefc83c6c66013c5053f4c184c4fd7bf400e96fe + Author: Jens Maurer + Date: Tue Dec 13 18:20:02 2016 +0100 + + [utility], [bitset] Introduce a separate heading for the synopsis. (#1213) + + Partially addresses #566. + + commit 0a3f38c33d4fb7459fb507faf88591bc1828b31c + Author: Jens Maurer + Date: Tue Dec 13 18:19:08 2016 +0100 + + [bitset.members] Adjust confusing index entries for 'set' and 'any'. (#1218) + + Fixes #743. + + commit bc42416f97adb35907af7af8fe407d3a445a1824 + Author: Jens Maurer + Date: Mon Dec 12 23:56:13 2016 +0100 + + [thread] Add numbered headings for synopses. (#1214) + + Partially addresses #566. + + commit 546a162c06881491f8394babb4147941f2af53ee + Author: Jens Maurer + Date: Mon Dec 12 16:45:28 2016 +0100 + + [pairs.spec], [tuple.creation] Avoid 'equality' of types phrasing. (#1212) + + Fixes #491. + + commit 5ec123d3e037fc3b85542ea2f31b86c6375d7c06 + Author: Jens Maurer + Date: Mon Dec 12 16:25:47 2016 +0100 + + [class.temporary] Add paragraph number and split off example into its own paragraph. (#1211) + + commit a8a89d9144a9050b85b8bfe780340a763193a1f4 + Author: Thomas Köppe + Date: Mon Dec 12 14:46:31 2016 +0000 + + [pairs.pair, tuple.cnstr] Replace 'The constructor initializes' with just 'Initializes', which is how we say it in many other places. (#1206) + + commit 3c6ba0621a8e23c474f77fbee24b06d76b125dd3 + Author: Thomas Köppe + Date: Mon Dec 12 01:50:27 2016 +0000 + + [special] Capitalize notes and examples that are complete sentences. + + commit 3a0d1be2ccd055f6bef1e91ebc2ca7ee19f3638e + Author: Thomas Köppe + Date: Mon Dec 12 01:33:44 2016 +0000 + + [class.cdtor] Clarify presentation of example + + Seperate the hypothetical alternative case from the real code with newlines and describe in irrealis mood. + + commit 33375c726c64c4e602b52269708441f5cdccfa77 + Author: Sergey Zubkov + Date: Sun Dec 11 07:20:28 2016 -0500 + + [mem.res.syn] Call polymorphic_allocator a 'class template' (#1209) + + commit fdb5d1a7ed71add105ee5eca4307d9a6a042ba75 + Author: Sergey Zubkov + Date: Sun Dec 11 07:11:28 2016 -0500 + + [variant.bad.access] Use 'override' instead of 'virtual' in synopsis (#1208) + + commit edba6d4a097e9de2caa79461341b3c3476941790 + Author: Thomas Köppe + Date: Sat Dec 10 19:50:28 2016 +0000 + + [diff.cpp03.special] Use the more correct "call function f" rather than "call function f()" to resolve overfull line and fulfil compulsion for pedantry. + + commit 3c6d91088e58e56e295419efdd47ddc8a4628196 + Author: Thomas Köppe + Date: Sat Dec 10 17:10:54 2016 +0000 + + [func.not_fn] Clean-up not_fun + + Use placeholder macros. Reformat class synopsis in our usual style. Reorder private members. Use codeblocks for long descriptions. + + Addresses #693. + + commit 2b17f472d2c1fcfb96f5f9d4f5f7d799c6d336ae + Author: Thomas Köppe + Date: Sat Dec 10 17:09:25 2016 +0000 + + [mem.res.pool.mem] Reorder and reflow do_is_equal descriptions. + + Addresses #693 for that section. + + commit f9ce3d269eb5bd2ffd3bb74f79ba1298da1d83bc + Author: Thomas Köppe + Date: Sat Dec 10 16:34:41 2016 +0000 + + [tuple.helper, variant.helper] Change "specialization of *class*" to "specialization of *template*". + + The containing lines were too long (cf. #693), and the change is a mild increase in pedantic correctness. + + commit faaf054bd237780b3999c4efdbbcc2b6bf88721b + Author: Jens Maurer + Date: Fri Dec 9 23:32:42 2016 +0100 + + [limits] Use 'subnormal number' as defined by IEEE 754-2008 = ISO 60559. (#1203) + + Also add index entries for 'denormalized value' and 'value, + denormalized', pointing to 'number, subnormal'. + + Fixes #1017. + + commit 4f182cba568b3f753d2bdeb61c349bd65b8bf241 + Author: Jens Maurer + Date: Thu Dec 8 23:02:33 2016 +0100 + + [util.smartptr.shared.atomic] Merge duplicate description items. + + Partially addresses #288. + + commit b22cda3a831508a362930f6eb25d1f839f0f8ea8 + Author: Jens Maurer + Date: Thu Dec 8 22:57:32 2016 +0100 + + [alg.lex.comparison] Remove duplicate 'Remarks:' item and comfort lone codeblock + + Partially addresses #288. + + commit faecbe8a6f3db2bd411b64428c1f3345b1677550 + Author: Johannes Laire + Date: Thu Dec 8 15:19:45 2016 +0000 + + [rand.req.adapt] Fix syntax error (#1194) + + commit a9159bdbf9b6baa096f2c51d9129cd03431d03bd + Author: Eelis + Date: Thu Dec 8 16:08:58 2016 +0100 + + [numeric.special] Remove redundant 'inline' specifiers in example. (#1192) + + commit ff36dc5f586abb837a3963b1b8815a245bdbc741 + Author: Johannes Laire + Date: Thu Dec 8 10:47:07 2016 +0000 + + [depr] Add missing parentheses around bitwise expressions (#1191) + + commit b6d625f215dbac299982094cf54e4fed0999e873 + Author: Thomas Köppe + Date: Thu Dec 8 10:06:47 2016 +0000 + + Hyphenate 'implementation-defined' in a few residual cases + + commit 77f36805a4adc0a5d145264fc5e5e6ab11b5e8f2 + Author: Thomas Köppe + Date: Fri Dec 2 02:58:22 2016 +0000 + + [dcl.align] Touch up error comments + + commit 6d082aa3bed44e5342e55d19453d9669671063fa + Author: Jens Maurer + Date: Wed Dec 7 23:07:21 2016 +0100 + + [intseq.general] Remove example not quite mirroring a standard function. (#1187) + + Fixes #1176. + + commit 426dd1880198d5aaa51ae189d3e1d3780d3da1ce + Author: Jens Maurer + Date: Wed Dec 7 22:28:33 2016 +0100 + + [containers, alg.transform] Minor presentation fixes. (#1184) + + Harmonize the punctuation in complexity requirements where a definition + for N is introduced. + Add a missing closing parenthesis. + Add a full stop. + + Fixes #191. + + commit ff91738d4f67123fa944a76506826f7a3c14b3e2 + Author: Jens Maurer + Date: Wed Dec 7 21:25:39 2016 +0100 + + [class.virtual] Remove awkward 'but'. (#1182) + + Fixes #170. + + commit 4975167baaed59b6b3aab9d93ea14682c45a6217 + Author: Jens Maurer + Date: Wed Dec 7 20:44:25 2016 +0100 + + [function.objects] Introduce a new subsection for the synopsis. (#1179) + + Also add a cross-reference from [unord.hash] to the synopsis, which + is the only place where the primary template is declared. + + Fixes #192. + + commit d4c17ce01bf7b1419b330e798119b838ab8f1380 + Author: Jens Maurer + Date: Wed Dec 7 20:07:18 2016 +0100 + + [pairs.pair] Further harmonize spelling of template parameters for pair. (#1178) + + Fixes #125. + + commit 10ae5c39b0d4065486974c1c80d338b904a9f013 + Author: Eelis + Date: Wed Dec 7 12:13:32 2016 +0100 + + Capitalize examples outside sentences. (#1174) + + commit 5301db44da7db8839114f9c032e7fe293da31879 + Author: Eelis + Date: Wed Dec 7 11:25:11 2016 +0100 + + Capitalize notes. (#1173) + + commit d2a69983b30ba4a3dec9bece774cb11fe50353c1 + Author: Thomas Köppe + Date: Wed Dec 7 01:37:27 2016 +0000 + + [stmt.stmt] Align comments to customary columns and reflow some very narrow comments + + commit 1fe866912ad07ea76353bb08723aad8552620f7c + Author: Jens Maurer + Date: Wed Dec 7 01:55:54 2016 +0100 + + [utility] Harmonize spelling of template parameters for std::pair. (#1172) + + Addresses #125. + + commit 99c6b4c6d08b99b36a10a50127b43ab461fd2f57 + Author: Thomas Köppe + Date: Sat Dec 3 00:43:13 2016 +0000 + + [expr] Use same notation for collections of cv-qualification signatures as in [conv.qual] + + commit 2df5c6df7ee8cd884da607897b229cc8e1913ecb + Author: Thomas Köppe + Date: Tue Nov 29 02:47:55 2016 +0000 + + [basic] Reflow comments to be more compact; use math set notation for sets + + commit 28b0897221d9b641ef8439cfd29ef81b7d1f81b6 + Author: Jens Maurer + Date: Fri Dec 2 00:40:17 2016 +0100 + + [headers, depr.c.headers] Avoid brittle counts of headers. (#1167) + + Fixes #766. + + commit cf522b9177c01511a8c0b7197d9e48aa2224512d + Author: Jens Maurer + Date: Thu Dec 1 23:58:40 2016 +0100 + + [utilities] Do not use CamelCase for 'BaseCharacteristic'. (#1164) + + This is a regular English phrase used as a technical term. + + Fixes #1154. + + commit 69d8903278277e96779c8435fedad0018fe10ee4 + Author: Jens Maurer + Date: Thu Dec 1 23:52:01 2016 +0100 + + [re.regex] Add missing 'multiline' constant. (#1162) + + Fixes #1129. + + commit 19dc0aa5c8b8b53f0bfe17724fb26795c187c10a + Author: Richard Smith + Date: Fri Oct 21 11:39:17 2016 -0700 + + [dcl.init.aggr] Wording simplification. Aggregate elements are only + defined for purposes of aggregate initialization; we don't need to + repeat that every time we use the term. + + commit cca5257d60abcf9a62f545e9c146fe2c367f843a + Author: Johannes Laire + Date: Wed Nov 30 00:03:04 2016 +0000 + + Move punctuation outside quotation marks according to logical nesting (#1148) + + commit a69d5beeaf1041c064cbad97db9b05a7e6ce079c + Author: Thomas Köppe + Date: Tue Nov 29 23:57:44 2016 +0000 + + [expr.prim.lambda] Move first paragraph below grammar. + + Text before the main grammar needs to be very short; this first paragraph was getting out of hand. + + commit c58e854d79a71d7494c6c1bcf496c6795f10821b + Author: Thomas Köppe + Date: Tue Nov 29 21:47:05 2016 +0000 + + [string.classes] Turn synopsis into numbered subclause + + In pursuit of issue #566. + + commit 30e55475c622cdda9274f5d3af79eae416b650ef + Author: Thomas Köppe + Date: Tue Nov 29 21:38:41 2016 +0000 + + [tuple, variant] Turn synopses into numbered subclauses + + In pursuit of issue #566. + + commit 48efdfe014549e6d116ce12ca427f7df0e0f8c70 + Author: Thomas Köppe + Date: Tue Nov 29 19:58:48 2016 +0000 + + [pairs.pair], [tuple.tuple] Tidy up presentation of member functions (order elements consistently; use better index notation) + + Also fixes issue #1117 and partially addresses issue #653. + + commit 807e6f951e19e418cbc379797d1c32e4b8a49dca + Author: Johannes Laire + Date: Tue Nov 29 12:37:17 2016 -0500 + + [library] Capitalize headings + + commit bcd2eb6e3cfd68d90b4b761df8dd0728e4e0629b + Author: Thomas Köppe + Date: Tue Nov 29 02:52:44 2016 +0000 + + [basic.def.odf] Clarify example by adding a variable that actually odr-uses D() diff --git a/papers/n4640.pdf b/papers/n4640.pdf new file mode 100644 index 0000000000..e28b707bff Binary files /dev/null and b/papers/n4640.pdf differ diff --git a/source/access.tex b/source/access.tex index f84fd8b4d0..77ccc72669 100644 --- a/source/access.tex +++ b/source/access.tex @@ -116,8 +116,9 @@ the class appearing outside the class's \grammarterm{member-specification}{.} \begin{note} This access also applies to implicit references to constructors, conversion functions, and destructors. \end{note} -\begin{example} +\pnum +\begin{example} \begin{codeblock} class A { typedef int I; // private member @@ -140,7 +141,6 @@ struct D: A::B, A { }; \end{codeblock} -\pnum Here, all the uses of \tcode{A::I} are well-formed because @@ -165,7 +165,7 @@ \end{example} \pnum -\indextext{argument!access checking~and default}% +\indextext{argument!access checking and default}% \indextext{access control!default argument}% The names in a default argument~(\ref{dcl.fct.default}) are bound at the point of declaration, and access is checked at that @@ -187,12 +187,12 @@ template class D : public U { }; -D >* d; // access error, C::TT is protected +D >* d; // access error, \tcode{C::TT} is protected \end{codeblock} \end{example} \rSec1[class.access.spec]{Access specifiers}% -\indextext{access~specifier} +\indextext{access specifier} \pnum Member declarations can be labeled by an @@ -279,11 +279,11 @@ \end{example} \rSec1[class.access.base]{Accessibility of base classes and base class members}% -\indextext{access control!base~class}% -\indextext{access~specifier}% -\indextext{base~class!\idxcode{private}}% -\indextext{base~class!\idxcode{protected}}% -\indextext{base~class!\idxcode{public}} +\indextext{access control!base class}% +\indextext{access specifier}% +\indextext{base class!\idxcode{private}}% +\indextext{base class!\idxcode{protected}}% +\indextext{base class!\idxcode{public}} \pnum If a class is declared to be a base class (Clause~\ref{class.derived}) for another class using the @@ -336,15 +336,15 @@ \begin{example} \begin{codeblock} -class B { /* ... */ }; -class D1 : private B { /* ... */ }; -class D2 : public B { /* ... */ }; -class D3 : B { /* ... */ }; // \tcode{B} private by default -struct D4 : public B { /* ... */ }; -struct D5 : private B { /* ... */ }; -struct D6 : B { /* ... */ }; // \tcode{B} public by default -class D7 : protected B { /* ... */ }; -struct D8 : protected B { /* ... */ }; +class B { @\commentellip@ }; +class D1 : private B { @\commentellip@ }; +class D2 : public B { @\commentellip@ }; +class D3 : B { @\commentellip@ }; // \tcode{B} private by default +struct D4 : public B { @\commentellip@ }; +struct D5 : private B { @\commentellip@ }; +struct D6 : B { @\commentellip@ }; // \tcode{B} public by default +class D7 : protected B { @\commentellip@ }; +struct D8 : protected B { @\commentellip@ }; \end{codeblock} Here @@ -464,9 +464,8 @@ class N: private S { void f() { - B* p = this; // OK because class \tcode{S} satisfies the fourth condition - // above: \tcode{B} is a base class of \tcode{N} accessible in \tcode{f()} because - // \tcode{B} is an accessible base class of \tcode{S} and \tcode{S} is an accessible + B* p = this; // OK because class \tcode{S} satisfies the fourth condition above: \tcode{B} is a base class of \tcode{N} + // accessible in \tcode{f()} because \tcode{B} is an accessible base class of \tcode{S} and \tcode{S} is an accessible // base class of \tcode{N}. } }; @@ -570,8 +569,7 @@ }; class B : public A { }; void f(B* p) { - p->i = 1; // OK: \tcode{B*} can be implicitly converted to \tcode{A*}, - // and \tcode{f} has access to \tcode{i} in \tcode{A} + p->i = 1; // OK: \tcode{B*} can be implicitly converted to \tcode{A*}, and \tcode{f} has access to \tcode{i} in \tcode{A} } \end{codeblock} \end{example} @@ -602,11 +600,11 @@ Such declarations give special access rights to the friends, but they do not make the nominated friends members of the befriending class. \begin{example} -the following example illustrates the differences between +The following example illustrates the differences between members and friends: -\indextext{friend function!member~function~and}% +\indextext{friend function!member function and}% \indextext{example!friend function}% -\indextext{example!member~function}% +\indextext{example!member function}% \begin{codeblock} class X { @@ -628,7 +626,7 @@ \end{example} \pnum -\indextext{friend!class access~and}% +\indextext{friend!class access and}% Declaring a class to be a friend implies that the names of private and protected members from the class granting friendship can be accessed in the \grammarterm{base-specifier}{s} and member declarations of the befriended @@ -640,10 +638,10 @@ friend class X; }; -struct X : A::B { // OK: \tcode{A::B} accessible to friend - A::B mx; // OK: \tcode{A::B} accessible to member of friend +struct X : A::B { // OK: \tcode{A::B} accessible to friend + A::B mx; // OK: \tcode{A::B} accessible to member of friend class Y { - A::B my; // OK: \tcode{A::B} accessible to nested member of friend + A::B my; // OK: \tcode{A::B} accessible to nested member of friend }; }; \end{codeblock} @@ -657,11 +655,11 @@ }; class Y { - int v[X::a]; // OK, \tcode{Y} is a friend of \tcode{X} + int v[X::a]; // OK, \tcode{Y} is a friend of \tcode{X} }; class Z { - int v[X::a]; // error: \tcode{X::a} is private + int v[X::a]; // error: \tcode{X::a} is private }; \end{codeblock} \end{example} @@ -669,7 +667,7 @@ A class shall not be defined in a friend declaration. \begin{example} \begin{codeblock} class A { - friend class B { }; // error: cannot define class in friend declaration + friend class B { }; // error: cannot define class in friend declaration }; \end{codeblock} \end{example} @@ -696,32 +694,32 @@ typedef C Ct; class X1 { - friend C; // OK: \tcode{class C} is a friend + friend C; // OK: \tcode{class C} is a friend }; class X2 { - friend Ct; // OK: \tcode{class C} is a friend - friend D; // error: no type-name \tcode{D} in scope - friend class D; // OK: elaborated-type-specifier declares new class + friend Ct; // OK: \tcode{class C} is a friend + friend D; // error: no type-name \tcode{D} in scope + friend class D; // OK: elaborated-type-specifier declares new class }; template class R { friend T; }; -R rc; // \tcode{class C} is a friend of \tcode{R} -R Ri; // OK: \tcode{"friend int;"} is ignored +R rc; // \tcode{class C} is a friend of \tcode{R} +R Ri; // OK: \tcode{"friend int;"} is ignored \end{codeblock} \end{example} \pnum -\indextext{friend function!linkage~of}% +\indextext{friend function!linkage of}% A function first declared in a friend declaration has the linkage of the namespace of which it is a member~(\ref{basic.link}). Otherwise, the function retains its previous linkage~(\ref{dcl.stc}). \pnum -\indextext{declaration!overloaded~name~and \tcode{friend}}% +\indextext{declaration!overloaded name and \tcode{friend}}% When a \tcode{friend} declaration refers to an overloaded name or operator, only the function specified @@ -773,7 +771,7 @@ of a friend declaration. \pnum -\indextext{friend!access~specifier~and}% +\indextext{friend!access specifier and}% A name nominated by a friend declaration shall be accessible in the scope of the class containing the friend declaration. The meaning of the friend declaration is the same whether the friend declaration @@ -786,7 +784,7 @@ \grammarterm{member-specification}. \pnum -\indextext{friend!inheritance~and}% +\indextext{friend!inheritance and}% Friendship is neither inherited nor transitive. \begin{example} @@ -802,23 +800,21 @@ class C { void f(A* p) { - p->a++; // error: \tcode{C} is not a friend of \tcode{A} - // despite being a friend of a friend + p->a++; // error: \tcode{C} is not a friend of \tcode{A} despite being a friend of a friend } }; class D : public B { void f(A* p) { - p->a++; // error: \tcode{D} is not a friend of \tcode{A} - // despite being derived from a friend + p->a++; // error: \tcode{D} is not a friend of \tcode{A} despite being derived from a friend } }; \end{codeblock} \end{example} \pnum -\indextext{local~class!friend}% -\indextext{friend!local~class~and}% +\indextext{local class!friend}% +\indextext{friend!local class and}% If a friend declaration appears in a local class~(\ref{class.local}) and the name specified is an unqualified name, a prior declaration is looked up without considering scopes that are outside the innermost enclosing @@ -890,8 +886,7 @@ pb->i = 1; // ill-formed p1->i = 2; // ill-formed p2->i = 3; // OK (access through a \tcode{D2}) - p2->B::i = 4; // OK (access through a \tcode{D2}, even though - // naming class is \tcode{B}) + p2->B::i = 4; // OK (access through a \tcode{D2}, even though naming class is \tcode{B}) int B::* pmi_B = &B::i; // ill-formed int B::* pmi_B2 = &D2::i; // OK (type of \tcode{\&D2::i} is \tcode{int B::*}) B::j = 5; // ill-formed (not a friend of naming class \tcode{B}) @@ -941,8 +936,7 @@ B* pb = &d; D* pd = &d; - pb->f(); // OK: \tcode{B::f()} is public, - // \tcode{D::f()} is invoked + pb->f(); // OK: \tcode{B::f()} is public, \tcode{D::f()} is invoked pd->f(); // error: \tcode{D::f()} is private } \end{codeblock} @@ -974,7 +968,6 @@ }; \end{codeblock} -\pnum Since \tcode{W::f()} is available to @@ -993,7 +986,7 @@ The members of an enclosing class have no special access to members of a nested class; the usual access rules (Clause~\ref{class.access}) shall be obeyed. \begin{example} -\indextext{example!nested~class definition}% +\indextext{example!nested class definition}% \begin{codeblock} class E { diff --git a/source/algorithms.tex b/source/algorithms.tex index c8ee2fa8fb..9c74d5dfbb 100644 --- a/source/algorithms.tex +++ b/source/algorithms.tex @@ -22,7 +22,8 @@ \ref{alg.c.library} & C library algorithms & \tcode{} \\ \hline \end{libsumtab} -\synopsis{Header \tcode{} synopsis} +\rSec1[algorithm.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{algorithm}}% \indexlibrary{\idxhdr{algorithm}}% \begin{codeblock} @@ -286,7 +287,7 @@ template ForwardIterator search(ForwardIterator first, ForwardIterator last, - const Searcher &searcher); + const Searcher& searcher); // \ref{alg.modifying.operations}, modifying sequence operations // \ref{alg.copy}, copy @@ -1023,6 +1024,7 @@ } \end{codeblock} +\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. @@ -1196,12 +1198,13 @@ \rSec1[algorithms.parallel]{Parallel algorithms} +\pnum This section 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 standard with +A \defn{parallel algorithm} is a function template listed in this International Standard with a template parameter named \tcode{ExecutionPolicy}. \pnum @@ -1351,7 +1354,7 @@ algorithms. \begin{note} Implementations must ensure that internal synchronization inside standard -library routines does not prevent forward progress when those routines are +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} @@ -1571,8 +1574,10 @@ If \tcode{f} returns a result, the result is ignored. \pnum -\realnotes Does not return a copy of its \tcode{Function} parameter, since +\begin{note} +Does not return a copy of its \tcode{Function} parameter, since parallelization may not permit efficient state accumulation. +\end{note} \end{itemdescr} \indexlibrary{\idxcode{for_each_n}}% @@ -2280,7 +2285,6 @@ OutputIterator result); \end{itemdecl} - \begin{itemdescr} \pnum \effects For each non-negative integer @@ -2304,7 +2308,6 @@ OutputIterator result, Predicate pred); \end{itemdecl} - \begin{itemdescr} \pnum \requires The ranges \range{first}{last} and \range{result}{result + (last - first)} shall not overlap. @@ -2323,7 +2326,6 @@ \remarks Stable~(\ref{algorithm.stable}). \end{itemdescr} - \indexlibrary{\idxcode{copy_backward}}% \begin{itemdecl} template @@ -2373,11 +2375,9 @@ \indexlibrary{\idxcode{move}!algorithm}% \begin{itemdecl} template - OutputIterator move(InputIterator first, InputIterator last, - OutputIterator result); + OutputIterator move(InputIterator first, InputIterator last, OutputIterator result); \end{itemdecl} - \begin{itemdescr} \pnum \requires @@ -2409,8 +2409,8 @@ \indexlibrary{\idxcode{move}!algorithm}% \begin{itemdecl} template - OutputIterator move(ExecutionPolicy&& policy, InputIterator first, InputIterator last, - OutputIterator result); + OutputIterator move(ExecutionPolicy&& policy, + InputIterator first, InputIterator last, OutputIterator result); \end{itemdecl} \begin{itemdescr} @@ -2422,7 +2422,7 @@ \effects Moves 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) = std::move(\linebreak{}*(first + n))}. +performs \tcode{*(result + n) = std::\brk{}move(*(first + n))}. \pnum \returns \tcode{result + (last - first)}. @@ -2440,7 +2440,6 @@ BidirectionalIterator2 result); \end{itemdecl} - \begin{itemdescr} \pnum \requires @@ -2476,7 +2475,7 @@ assignments. \end{itemdescr} -\rSec2[alg.swap]{swap} +\rSec2[alg.swap]{Swap} \indexlibrary{\idxcode{swap_ranges}}% \begin{itemdecl} @@ -2491,7 +2490,6 @@ ForwardIterator2 first2); \end{itemdecl} - \begin{itemdescr} \pnum \requires @@ -2588,7 +2586,7 @@ \range{result}{result + (last1 - first1)} a new corresponding value equal to -\tcode{op(*(first1 + (i - result))} +\tcode{op(*(first1 + (i - result)))} or \tcode{binary_op(*(first1 + (i - result)), *(first2 + (i - result)))}. @@ -2876,10 +2874,12 @@ applications of the corresponding predicate. \pnum -\realnote each element in the range \range{ret}{last}, where \tcode{ret} is +\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. +\end{note} \end{itemdescr} \indexlibrary{\idxcode{remove_copy}}% @@ -3342,171 +3342,6 @@ \end{itemdescr} -\rSec2[alg.partitions]{Partitions} - -\indexlibrary{\idxcode{is_partitioned}}% -\begin{itemdecl} -template - bool is_partitioned(InputIterator first, InputIterator last, Predicate pred); -template - bool is_partitioned(ExecutionPolicy&& exec, - InputIterator first, InputIterator last, Predicate pred); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\requires \tcode{InputIterator}'s value type shall be convertible to \tcode{Predicate}'s argument type. - -\pnum -\returns \tcode{true} if -\range{first}{last} is empty or if -\range{first}{last} is partitioned by \tcode{pred}, i.e. if all elements that satisfy \tcode{pred} appear before those that do not. - -\pnum -\complexity Linear. At most \tcode{last - first} applications of \tcode{pred}. -\end{itemdescr} - -\indexlibrary{\idxcode{partition}}% -\begin{itemdecl} -template - ForwardIterator - partition(ForwardIterator first, ForwardIterator last, Predicate pred); -template - ForwardIterator - partition(ExecutionPolicy&& exec, - ForwardIterator first, ForwardIterator last, Predicate pred); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\requires -\tcode{ForwardIterator} shall satisfy the requirements of -\tcode{ValueSwappable}~(\ref{swappable.requirements}). - -\pnum -\effects Places all the elements in the range \range{first}{last} that satisfy \tcode{pred} before all the elements that do not satisfy it. - -\pnum -\returns An iterator \tcode{i} such that for every iterator \tcode{j} in the range -\range{first}{i} \tcode{pred(*j) != false}, and for every iterator \tcode{k} in the -range \range{i}{last}, \tcode{pred(*k) == false}. - -\pnum -\complexity If \tcode{ForwardIterator} meets the requirements for a \tcode{BidirectionalIterator}, at most -\tcode{(last - first) / 2} swaps are done; otherwise at most \tcode{last - first} swaps -are done. Exactly \tcode{last - first} applications of the predicate are done. -\end{itemdescr} - -\indexlibrary{\idxcode{stable_partition}}% -\begin{itemdecl} -template - BidirectionalIterator - stable_partition(BidirectionalIterator first, BidirectionalIterator last, - Predicate pred); -template - BidirectionalIterator - stable_partition(ExecutionPolicy&& exec, - BidirectionalIterator first, BidirectionalIterator last, - Predicate pred); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\requires -\tcode{BidirectionalIterator} shall satisfy the requirements of -\tcode{ValueSwappable}~(\ref{swappable.requirements}). The type -of \tcode{*first} shall satisfy the requirements of -\tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) and of -\tcode{MoveAssignable} (Table~\ref{tab:moveassignable}). - -\pnum -\effects -Places all the elements in the range -\range{first}{last} -that satisfy \tcode{pred} before all the -elements that do not satisfy it. - -\pnum -\returns -An iterator -\tcode{i} -such that for every iterator -\tcode{j} -in the range -\range{first}{i}, -\tcode{pred(*j) != false}, -and for every iterator -\tcode{k} -in the range -\range{i}{last}, -\tcode{pred(*k) == false}. -The relative order of the elements in both groups is preserved. - -\pnum -\complexity -At most $N \log(N)$ swaps, where $N = \tcode{last - first}$, -but only \bigoh{N} swaps if there is enough extra memory. -Exactly -\tcode{last - first} -applications of the predicate. -\end{itemdescr} - -\indexlibrary{\idxcode{partition_copy}}% -\begin{itemdecl} -template - pair - partition_copy(InputIterator first, InputIterator last, - OutputIterator1 out_true, OutputIterator2 out_false, - Predicate pred); -template - pair - partition_copy(ExecutionPolicy&& exec, - InputIterator first, InputIterator last, - OutputIterator1 out_true, OutputIterator2 out_false, - Predicate pred); -\end{itemdecl} - - -\begin{itemdescr} -\pnum -\requires \tcode{InputIterator}'s value type shall be \tcode{CopyAssignable}, and shall be -writable~(\ref{iterator.requirements.general}) to the \tcode{out_true} and \tcode{out_false} \tcode{OutputIterator}s, and shall be -convertible to \tcode{Predicate}'s argument type. The input range shall not overlap with -either of the output ranges. - -\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{pred(*i)} is \tcode{true}, or to the output range beginning with \tcode{out_false} otherwise. - -\pnum -\returns A pair \tcode{p} such that \tcode{p.first} is the end of the output range beginning at \tcode{out_true} and \tcode{p.second} is the end of the output range beginning at \tcode{out_false}. - -\pnum -\complexity Exactly \tcode{last - first} applications of \tcode{pred}. -\end{itemdescr} - -\indexlibrary{\idxcode{partition_point}}% -\begin{itemdecl} -template - ForwardIterator partition_point(ForwardIterator first, - ForwardIterator last, - Predicate pred); -\end{itemdecl} - - -\begin{itemdescr} -\pnum -\requires \tcode{ForwardIterator}'s value type shall be convertible to \tcode{Predicate}'s argument type. \range{first}{last} shall be partitioned by \tcode{pred}, i.e. all elements that satisfy \tcode{pred} shall appear before those that do not. - -\pnum -\returns An iterator \tcode{mid} such that \tcode{all_of(first, mid, pred)} and \tcode{none_of(mid, last, pred)} are both \tcode{true}. - -\pnum -\complexity \bigoh{\log(\tcode{last - first})} applications of \tcode{pred}. -\end{itemdescr} - - \rSec1[alg.sorting]{Sorting and related operations} \pnum @@ -4204,6 +4039,170 @@ comparisons. \end{itemdescr} +\rSec2[alg.partitions]{Partitions} + +\indexlibrary{\idxcode{is_partitioned}}% +\begin{itemdecl} +template + bool is_partitioned(InputIterator first, InputIterator last, Predicate pred); +template + bool is_partitioned(ExecutionPolicy&& exec, + InputIterator first, InputIterator last, Predicate pred); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\requires \tcode{InputIterator}'s value type shall be convertible to \tcode{Predicate}'s argument type. + +\pnum +\returns \tcode{true} if +\range{first}{last} is empty or if +\range{first}{last} is partitioned by \tcode{pred}, i.e. if all elements that satisfy \tcode{pred} appear before those that do not. + +\pnum +\complexity Linear. At most \tcode{last - first} applications of \tcode{pred}. +\end{itemdescr} + +\indexlibrary{\idxcode{partition}}% +\begin{itemdecl} +template + ForwardIterator + partition(ForwardIterator first, ForwardIterator last, Predicate pred); +template + ForwardIterator + partition(ExecutionPolicy&& exec, + ForwardIterator first, ForwardIterator last, Predicate pred); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\requires +\tcode{ForwardIterator} shall satisfy the requirements of +\tcode{ValueSwappable}~(\ref{swappable.requirements}). + +\pnum +\effects Places all the elements in the range \range{first}{last} that satisfy \tcode{pred} before all the elements that do not satisfy it. + +\pnum +\returns An iterator \tcode{i} such that for every iterator \tcode{j} in the range +\range{first}{i} \tcode{pred(*j) != false}, and for every iterator \tcode{k} in the +range \range{i}{last}, \tcode{pred(*k) == false}. + +\pnum +\complexity If \tcode{ForwardIterator} meets the requirements for a \tcode{BidirectionalIterator}, at most +\tcode{(last - first) / 2} swaps are done; otherwise at most \tcode{last - first} swaps +are done. Exactly \tcode{last - first} applications of the predicate are done. +\end{itemdescr} + +\indexlibrary{\idxcode{stable_partition}}% +\begin{itemdecl} +template + BidirectionalIterator + stable_partition(BidirectionalIterator first, BidirectionalIterator last, + Predicate pred); +template + BidirectionalIterator + stable_partition(ExecutionPolicy&& exec, + BidirectionalIterator first, BidirectionalIterator last, + Predicate pred); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\requires +\tcode{BidirectionalIterator} shall satisfy the requirements of +\tcode{ValueSwappable}~(\ref{swappable.requirements}). The type +of \tcode{*first} shall satisfy the requirements of +\tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) and of +\tcode{MoveAssignable} (Table~\ref{tab:moveassignable}). + +\pnum +\effects +Places all the elements in the range +\range{first}{last} +that satisfy \tcode{pred} before all the +elements that do not satisfy it. + +\pnum +\returns +An iterator +\tcode{i} +such that for every iterator +\tcode{j} +in the range +\range{first}{i}, +\tcode{pred(*j) != false}, +and for every iterator +\tcode{k} +in the range +\range{i}{last}, +\tcode{pred(*k) == false}. +The relative order of the elements in both groups is preserved. + +\pnum +\complexity +At most $N \log(N)$ swaps, where $N = \tcode{last - first}$, +but only \bigoh{N} swaps if there is enough extra memory. +Exactly +\tcode{last - first} +applications of the predicate. +\end{itemdescr} + +\indexlibrary{\idxcode{partition_copy}}% +\begin{itemdecl} +template + pair + partition_copy(InputIterator first, InputIterator last, + OutputIterator1 out_true, OutputIterator2 out_false, + Predicate pred); +template + pair + partition_copy(ExecutionPolicy&& exec, + InputIterator first, InputIterator last, + OutputIterator1 out_true, OutputIterator2 out_false, + Predicate pred); +\end{itemdecl} + + +\begin{itemdescr} +\pnum +\requires \tcode{InputIterator}'s value type shall be \tcode{CopyAssignable}, and shall be +writable~(\ref{iterator.requirements.general}) to the \tcode{out_true} and \tcode{out_false} \tcode{OutputIterator}s, and shall be +convertible to \tcode{Predicate}'s argument type. The input range shall not overlap with +either of the output ranges. + +\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{pred(*i)} is \tcode{true}, or to the output range beginning with \tcode{out_false} otherwise. + +\pnum +\returns A pair \tcode{p} such that \tcode{p.first} is the end of the output range beginning at \tcode{out_true} and \tcode{p.second} is the end of the output range beginning at \tcode{out_false}. + +\pnum +\complexity Exactly \tcode{last - first} applications of \tcode{pred}. +\end{itemdescr} + +\indexlibrary{\idxcode{partition_point}}% +\begin{itemdecl} +template + ForwardIterator partition_point(ForwardIterator first, + ForwardIterator last, + Predicate pred); +\end{itemdecl} + + +\begin{itemdescr} +\pnum +\requires \tcode{ForwardIterator}'s value type shall be convertible to \tcode{Predicate}'s argument type. \range{first}{last} shall be partitioned by \tcode{pred}, i.e. all elements that satisfy \tcode{pred} shall appear before those that do not. + +\pnum +\returns An iterator \tcode{mid} such that \tcode{all_of(first, mid, pred)} and \tcode{none_of(mid, last, pred)} are both \tcode{true}. + +\pnum +\complexity \bigoh{\log(\tcode{last - first})} applications of \tcode{pred}. +\end{itemdescr} + \rSec2[alg.merge]{Merge} \indexlibrary{\idxcode{merge}}% @@ -4240,7 +4239,7 @@ \begin{itemdescr} \pnum \requires The ranges \range{first1}{last1} and \range{first2}{last2} shall be -sorted with respect to \tcode{operator<} or \tcode{comp}. +sorted with respect to \tcode{oper\-ator<} or \tcode{comp}. The resulting range shall not overlap with either of the original ranges. \pnum @@ -4671,7 +4670,7 @@ or a new element added by \tcode{push_heap()}, in -$\mathcal{O}(\log(N))$ +\bigoh{\log(N)} time. \end{itemize} @@ -4876,7 +4875,10 @@ \begin{itemdescr} \pnum -\returns \tcode{is_heap_until(std::forward(exec), first, last, comp) == last} +\returns +\begin{codeblock} +is_heap_until(std::forward(exec), first, last, comp) == last +\end{codeblock} \end{itemdescr} @@ -5272,7 +5274,7 @@ \pnum \remarks If two sequences have the same number of elements and their corresponding -elements are equivalent, then neither sequence is lexicographically +elements (if any) are equivalent, then neither sequence is lexicographically less than the other. If one sequence is a prefix of the other, then the shorter sequence is lexicographically less than the longer sequence. @@ -5280,6 +5282,9 @@ result as the comparison of the first corresponding pair of elements that are not equivalent. +\pnum +\begin{example} +The following sample implementation satisfies these requirements: \begin{codeblock} for ( ; first1 != last1 && first2 != last2 ; ++first1, (void) ++first2) { if (*first1 < *first2) return true; @@ -5287,10 +5292,12 @@ } return first1 == last1 && first2 != last2; \end{codeblock} +\end{example} \pnum -\remarks\ An empty sequence is lexicographically less than any non-empty sequence, but +\begin{note} An empty sequence is lexicographically less than any non-empty sequence, but not less than any empty sequence. +\end{note} \end{itemdescr} @@ -5384,6 +5391,7 @@ \pnum \indextext{\idxhdr{cstdlib}}% +\indexlibrary{\idxhdr{cstdlib}}% \begin{note} The header \tcode{}~(\ref{cstdlib.syn}) declares the functions described in this subclause. diff --git a/source/atomics.tex b/source/atomics.tex index 1b19da5af8..5be09daa19 100644 --- a/source/atomics.tex +++ b/source/atomics.tex @@ -28,6 +28,7 @@ \rSec1[atomics.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{atomic}}% \indexlibrary{\idxhdr{atomic}}% \begin{codeblock} namespace std { @@ -153,7 +154,7 @@ @\placeholdernc{integral}@ atomic_fetch_xor_explicit(volatile @\placeholder{atomic-integral}@*@\itcorr[-1]@, @\placeholdernc{integral}@, memory_order) noexcept; @\placeholdernc{integral}@ atomic_fetch_xor_explicit(@\placeholder{atomic-integral}@*@\itcorr[-1]@, @\placeholdernc{integral}@, memory_order) noexcept; - // \ref{atomics.types.operations.pointer}, partial specializations for pointers + // \ref{atomics.types.operations.pointer}, non-member overloads for atomic template T* atomic_fetch_add(volatile atomic*, ptrdiff_t) noexcept; template @@ -796,8 +797,8 @@ \indexlibrary{\idxcode{atomic}}% \pnum -The implementation shall provide the function template specializations -identified as ``partial specializations for pointers'' in~\ref{atomics.syn}. +The implementation shall provide the function templates identified as +``non-member overloads for atomic'' in~\ref{atomics.syn}. \rSec2[atomics.types.operations.req]{Requirements for operations on atomic types} @@ -1368,7 +1369,7 @@ Operations on an object of type \tcode{atomic_flag} shall be lock-free. \begin{note} Hence the operations should also be address-free. No other type requires lock-free operations, so the \tcode{atomic_flag} type is the minimum hardware-implemented type needed to -conform to this International standard. The remaining types can be emulated with +conform to this International Standard. The remaining types can be emulated with \tcode{atomic_flag}, though with less than ideal properties. \end{note} \pnum @@ -1496,11 +1497,11 @@ signal handler executed in the same thread. \pnum -\realnote \tcode{atomic_signal_fence} can be used to specify the order in which actions +\begin{note} +\tcode{atomic_signal_fence} can be used to specify the order in which actions performed by the thread become visible to the signal handler. - -\pnum -\realnote compiler optimizations and reorderings of loads and stores are inhibited in +Compiler optimizations and reorderings of loads and stores are inhibited in the same way as with \tcode{atomic_thread_fence}, but the hardware fence instructions that \tcode{atomic_thread_fence} would have inserted are not emitted. +\end{note} \end{itemdescr} diff --git a/source/basic.tex b/source/basic.tex index b55f567c0e..1692459c63 100644 --- a/source/basic.tex +++ b/source/basic.tex @@ -23,7 +23,7 @@ \pnum \indextext{type}% \indextext{object}% -\indextext{storage~class}% +\indextext{storage class}% \indextext{scope}% \indextext{linkage}% \indextext{region!declarative}% @@ -83,7 +83,7 @@ \rSec1[basic.def]{Declarations and definitions} \pnum -\indextext{declaration!definition~versus}% +\indextext{declaration!definition versus}% \indextext{declaration}% \indextext{declaration!name}% A declaration (Clause~\ref{dcl.dcl}) may introduce @@ -127,11 +127,11 @@ and the variable was defined within the class with the \tcode{constexpr} specifier (this usage is deprecated; see \ref{depr.static_constexpr}), \item -\indextext{declaration!class~name}% +\indextext{declaration!class name}% it is a class name declaration~(\ref{class.name}), \item it is an -\indextext{declaration!opaque~enum}% +\indextext{declaration!opaque enum}% \grammarterm{opaque-enum-declaration}~(\ref{dcl.enum}), \item it is a @@ -171,7 +171,7 @@ an explicit specialization~(\ref{temp.expl.spec}) whose \grammarterm{declaration} is not a definition. \end{itemize} -\begin{example} all but one of the following are definitions: +\begin{example} All but one of the following are definitions: \indextext{example!definition}% \begin{codeblock} int a; // defines \tcode{a} @@ -213,7 +213,7 @@ copy assignment operator~(\ref{class.copy}), move assignment operator~(\ref{class.copy}), or destructor~(\ref{class.dtor}) member functions. \end{note} -\begin{example} given +\begin{example} Given \begin{codeblock} #include @@ -261,7 +261,7 @@ \indextext{function!definition}% \indextext{class!definition}% \indextext{enumerator!definition}% -\indextext{one-definition~rule|(}% +\indextext{one-definition rule|(}% \rSec1[basic.def.odr]{One-definition rule} \pnum @@ -306,8 +306,7 @@ struct S { static const int x = 0; }; const int &f(const int &r); int n = b ? (1, S::x) // \tcode{S::x} is not odr-used here - : f(S::x); // \tcode{S::x} is odr-used here, so - // a definition is required + : f(S::x); // \tcode{S::x} is odr-used here, so a definition is required \end{codeblock} \end{example} \end{note} @@ -376,7 +375,7 @@ \indextext{type!incomplete}% Exactly one definition of a class is required in a translation unit if the class is used in a way that requires the class type to be complete. -\begin{example} the following complete translation unit is well-formed, +\begin{example} The following complete translation unit is well-formed, even though it never defines \tcode{X}: \begin{codeblock} @@ -392,7 +391,7 @@ \item an object of type \tcode{T} is defined~(\ref{basic.def}), or \item a non-static class data member of type \tcode{T} is declared~(\ref{class.mem}), or -\item \tcode{T} is used as the object type or array element type in a +\item \tcode{T} is used as the allocated type or array element type in a \grammarterm{new-expression}~(\ref{expr.new}), or \item an lvalue-to-rvalue conversion is applied to a glvalue referring @@ -401,7 +400,7 @@ type \tcode{T} (Clause~\ref{conv}, \ref{expr.type.conv}, \ref{expr.dynamic.cast}, \ref{expr.static.cast}, \ref{expr.cast}), or \item an expression that is not a null pointer constant, and has type -other than \cv{} \tcode{void*}, is converted to the type pointer to \tcode{T} +other than \cv{}~\tcode{void*}, is converted to the type pointer to \tcode{T} or reference to \tcode{T} using a standard conversion (Clause~\ref{conv}), a \tcode{dynamic_cast}~(\ref{expr.dynamic.cast}) or a \tcode{static_cast}~(\ref{expr.static.cast}), or @@ -450,7 +449,7 @@ \begin{itemize} \item has the same literal type in all definitions of \tcode{D}, \item is initialized with a constant expression~(\ref{expr.const}), -\item is not odr-used, and +\item is not odr-used in any definition of \tcode{D}, and \item has the same value in all definitions of \tcode{D}, \end{itemize} or @@ -495,7 +494,7 @@ class D { X x = 0; }; -D d2; // \tcode{X(int, int)} called by \tcode{D()} +D d1; // \tcode{X(int, int)} called by \tcode{D()} // translation unit 2: struct X { @@ -505,9 +504,9 @@ X::X(int, int = 0, int = 0) { } class D { X x = 0; -}; // \tcode{X(int, int, int)} called by \tcode{D()}; - // \tcode{D()}'s implicit definition - // violates the ODR +}; +D d2; // \tcode{X(int, int, int)} called by \tcode{D()}; + // \tcode{D()}'s implicit definition violates the ODR \end{codeblock} \end{example} \end{itemize} @@ -520,7 +519,7 @@ as if there were a single definition of \tcode{D}. If the definitions of \tcode{D} do not satisfy these requirements, then the behavior is undefined.% -\indextext{one-definition~rule|)} +\indextext{one-definition rule|)} \rSec1[basic.scope]{Scope}% \indextext{scope|(} @@ -529,7 +528,7 @@ \indextext{scope!declarations and|(} \pnum -\indextext{name!scope~of}% +\indextext{name!scope of}% Every name is introduced in some portion of program text called a \indextext{region!declarative}% \indextext{scope!potential}% @@ -548,7 +547,7 @@ \pnum \begin{example} -in +In \begin{codeblock} int j = 24; @@ -611,7 +610,7 @@ \rSec2[basic.scope.pdecl]{Point of declaration} \pnum -\indextext{name!point~of declaration}% +\indextext{name!point of declaration}% The \defn{point of declaration} for a name is immediately after its complete declarator (Clause~\ref{dcl.decl}) and before its \grammarterm{initializer} (if any), except as noted below. \begin{example} @@ -626,7 +625,7 @@ \pnum \begin{note} -\indextext{name~hiding}% +\indextext{name hiding}% a name from an outer scope remains visible up to the point of declaration of the name that hides it. \begin{example} @@ -654,7 +653,7 @@ constructor is immediately after the \grammarterm{using-declarator}~(\ref{namespace.udecl}). \pnum -\indextext{declaration!enumerator point~of}% +\indextext{declaration!enumerator point of}% The point of declaration for an enumerator is immediately after its \grammarterm{enumerator-definition}. \begin{example} @@ -670,7 +669,7 @@ After the point of declaration of a class member, the member name can be looked up in the scope of its class. \begin{note} \indextext{type!incomplete}% -this is true even if the class is an incomplete class. For example, +This is true even if the class is an incomplete class. For example, \begin{codeblock} struct X { @@ -755,7 +754,7 @@ \pnum \indextext{scope!block}% -\indextext{local~scope|see{block scope}}% +\indextext{local scope|see{block scope}}% A name declared in a block~(\ref{stmt.block}) is local to that block; it has \defn{block scope}. Its potential scope begins at its point of @@ -763,7 +762,7 @@ A variable declared at block scope is a \defn{local variable}. \pnum -\indextext{parameter!scope~of}% +\indextext{parameter!scope of}% The potential scope of a function parameter name (including one appearing in a \grammarterm{lambda-declarator}) @@ -780,7 +779,7 @@ with a \grammarterm{function-try-block}. \pnum -\indextext{scope!exception~declaration}% +\indextext{scope!exception declaration}% The name declared in an \grammarterm{exception-declaration} is local to the \grammarterm{handler} and shall not be redeclared in the outermost block of the @@ -799,8 +798,8 @@ \rSec2[basic.scope.proto]{Function prototype scope} \pnum -\indextext{scope!function~prototype}% -\indextext{function~prototype}% +\indextext{scope!function prototype}% +\indextext{function prototype}% In a function declaration, or in any function declarator except the declarator of a function definition~(\ref{dcl.fct.def}), names of parameters (if supplied) have function prototype scope, which terminates @@ -809,7 +808,7 @@ \rSec2[basic.funscope]{Function scope} \pnum -\indextext{label!scope~of}% +\indextext{label!scope of}% Labels~(\ref{stmt.label}) have \defnx{function scope}{scope!function} and may be used anywhere in the function in which they are declared. Only labels have function scope. @@ -839,8 +838,7 @@ void q(); } namespace { int l=1; } -// the potential scope of \tcode{l} is from its point of declaration -// to the end of the translation unit +// the potential scope of \tcode{l} is from its point of declaration to the end of the translation unit namespace N { int g(char a) { // overloads \tcode{N::g(int)} @@ -917,8 +915,7 @@ enum { i = 1 }; class X { - char v[i]; // error: \tcode{i} refers to \tcode{::i} - // but when reevaluated is \tcode{X::i} + char v[i]; // error: \tcode{i} refers to \tcode{::i} but when reevaluated is \tcode{X::i} int f() { return sizeof(c); } // OK: \tcode{X::c} char c; enum { i = 2 }; @@ -926,8 +923,7 @@ typedef char* T; struct Y { - T a; // error: \tcode{T} refers to \tcode{::T} - // but when reevaluated is \tcode{Y::T} + T a; // error: \tcode{T} refers to \tcode{::T} but when reevaluated is \tcode{Y::T} typedef long T; T b; }; @@ -963,8 +959,8 @@ \grammarterm{enum-specifier}. \rSec2[basic.scope.temp]{Template parameter scope}% -\indextext{template~parameter~scope}% -\indextext{scope!template~parameter}% +\indextext{template parameter scope}% +\indextext{scope!template parameter}% \pnum The declarative region of the name of a template parameter of a template @@ -990,7 +986,7 @@ \end{codeblock} The declarative regions of \tcode{T}, \tcode{U} and \tcode{V} are the -\grammarterm{template-declaration}{s} on lines \tcode{\#1}, \tcode{\#2} and \tcode{\#3}, +\grammarterm{template-declaration}{s} on lines \#1, \#2, and \#3, respectively. But the names \tcode{A}, \tcode{f}, \tcode{g} and \tcode{C} all belong to the same declarative region --- namely, the \grammarterm{namespace-body} of \tcode{N}. (\tcode{g} is still considered to belong to this declarative region in spite of its @@ -1006,7 +1002,7 @@ default arguments. For example, \begin{codeblock} -template class X { /* ... */ }; +template class X { @\commentellip@ }; template void f(T* p = new T); \end{codeblock} @@ -1014,8 +1010,8 @@ specification of base classes. For example, \begin{codeblock} -template class X : public Array { /* ... */ }; -template class Y : public T { /* ... */ }; +template class X : public Array { @\commentellip@ }; +template class Y : public T { @\commentellip@ }; \end{codeblock} The use of a template parameter as a base class implies that a class used as a template @@ -1046,14 +1042,14 @@ \rSec2[basic.scope.hiding]{Name hiding} \pnum -\indextext{scope~name~hiding~and}% -\indextext{name~hiding}% +\indextext{scope name hiding and}% +\indextext{name hiding}% \indextext{hiding|see{name hiding}}% A name can be hidden by an explicit declaration of that same name in a nested declarative region or derived class~(\ref{class.member.lookup}). \pnum -\indextext{name~hiding}% +\indextext{name hiding}% A class name~(\ref{class.name}) or enumeration name~(\ref{dcl.enum}) can be hidden by the name of a variable, data member, function, or enumerator declared in the same scope. If a class or enumeration name and a variable, data member, function, @@ -1082,7 +1078,7 @@ \indextext{scope|)} \rSec1[basic.lookup]{Name lookup}% -\indextext{scope!name~lookup~and|(}% +\indextext{scope!name lookup and|(}% \indextext{lookup!name|(}% \pnum @@ -1121,7 +1117,7 @@ \rSec2[basic.lookup.unqual]{Unqualified name lookup} \pnum -\indextext{lookup!unqualified~name}% +\indextext{lookup!unqualified name}% \indextext{name!unqualified}% In all the cases listed in~\ref{basic.lookup.unqual}, the scopes are searched for a declaration in the order listed in each of the respective @@ -1153,8 +1149,7 @@ friend void f(A &); operator int(); void g(A a) { - int i = f(a); // \tcode{f} is the typedef, not the friend - // function: equivalent to \tcode{int(a)} + int i = f(a); // \tcode{f} is the typedef, not the friend function: equivalent to \tcode{int(a)} } }; } @@ -1219,11 +1214,11 @@ \item if \tcode{X} is a nested class of class \tcode{Y}~(\ref{class.nest}), before the definition of \tcode{X} in \tcode{Y}, or shall be a member of a base class of \tcode{Y} (this -lookup applies in turn to \tcode{Y} 's enclosing classes, starting with +lookup applies in turn to \tcode{Y}'s enclosing classes, starting with the innermost enclosing class),\footnote{This lookup applies whether the definition of \tcode{X} is nested within \tcode{Y}'s definition or whether \tcode{X}'s definition -appears in a namespace scope enclosing \tcode{Y} 's +appears in a namespace scope enclosing \tcode{Y}'s definition~(\ref{class.nest}).} or \item if \tcode{X} is a local class~(\ref{class.local}) or is a nested @@ -1233,7 +1228,7 @@ class of a class that is a member of \tcode{N}, or is a local class or a nested class within a local class of a function that is a member of \tcode{N}, before the definition of class \tcode{X} in namespace -\tcode{N} or in one of \tcode{N} 's enclosing namespaces. +\tcode{N} or in one of \tcode{N}'s enclosing namespaces. \end{itemize} \begin{example} \begin{codeblock} @@ -1309,7 +1304,7 @@ class of a class that is a member of \tcode{N}, or is a local class or a nested class within a local class of a function that is a member of \tcode{N}, before the use of the name, in namespace \tcode{N} -or in one of \tcode{N} 's enclosing namespaces. +or in one of \tcode{N}'s enclosing namespaces. \end{itemize} \begin{example} \begin{codeblock} @@ -1420,7 +1415,7 @@ int i = 2; -int N::j = i; // \tcode{N::j == 4} +int N::j = i; // \tcode{N::j == 4} \end{codeblock} \end{example} @@ -1453,7 +1448,6 @@ (and for template template arguments, the namespace of the template argument). \begin{example} - \begin{codeblock} namespace N { struct S { }; @@ -1462,12 +1456,10 @@ void g() { N::S s; - f(s); // OK: calls \tcode{N::f} - (f)(s); // error: \tcode{N::f} not considered; parentheses - // prevent argument-dependent lookup + f(s); // OK: calls \tcode{N::f} + (f)(s); // error: \tcode{N::f} not considered; parentheses prevent argument-dependent lookup } \end{codeblock} - \end{example} \pnum @@ -1585,7 +1577,7 @@ \rSec2[basic.lookup.qual]{Qualified name lookup} \pnum -\indextext{lookup!qualified~name|(}% +\indextext{lookup!qualified name|(}% \indextext{name!qualified}% \indextext{qualification!explicit}% The name of a class or namespace member @@ -1635,14 +1627,14 @@ static X arr[number]; }; X C::arr[number]; // ill-formed: - // equivalent to: \tcode{::X} \tcode{C::arr[C::number];} - // not to: \tcode{C::X} \tcode{C::arr[C::number];} + // equivalent to \tcode{::X} \tcode{C::arr[C::number];} + // and not to \tcode{C::X} \tcode{C::arr[C::number];} \end{codeblock} \end{example} \pnum -\indextext{operator!scope~resolution}% -\indextext{scope~resolution~operator|see{operator, scope~resolution}}% +\indextext{operator!scope resolution}% +\indextext{scope resolution operator|see{operator, scope resolution}}% A name prefixed by the unary scope operator \tcode{::}~(\ref{expr.prim}) is looked up in global scope, in the translation unit where it is used. The name shall be declared in global namespace scope or shall be a name @@ -1678,8 +1670,7 @@ extern int* p; extern int* q; p->C::I::~I(); // \tcode{I} is looked up in the scope of \tcode{C} -q->I1::~I2(); // \tcode{I2} is looked up in the scope of - // the postfix-expression +q->I1::~I2(); // \tcode{I2} is looked up in the scope of the postfix-expression struct A { ~A(); @@ -1696,7 +1687,7 @@ \rSec3[class.qual]{Class members} \pnum -\indextext{lookup!class~member}% +\indextext{lookup!class member}% If the \grammarterm{nested-name-specifier} of a \grammarterm{qualified-id} nominates a class, the name specified after the \grammarterm{nested-name-specifier} is looked up in the scope of the @@ -1770,7 +1761,7 @@ \rSec3[namespace.qual]{Namespace members} \pnum -\indextext{lookup!namespace~member}% +\indextext{lookup!namespace member}% If the \grammarterm{nested-name-specifier} of a \grammarterm{qualified-id} nominates a namespace (including the case where the \grammarterm{nested-name-specifier} is \tcode{::}, i.e., nominating @@ -1833,36 +1824,32 @@ void h() { - AB::g(); // \tcode{g} is declared directly in \tcode{AB,} - // therefore \tcode{S} is \{ \tcode{AB::g()} \} and \tcode{AB::g()} is chosen - AB::f(1); // \tcode{f} is not declared directly in \tcode{AB} so the rules are - // applied recursively to \tcode{A} and \tcode{B;} - // namespace \tcode{Y} is not searched and \tcode{Y::f(float)} - // is not considered; - // \tcode{S} is \{ \tcode{A::f(int)}, \tcode{B::f(char)} \} and overload - // resolution chooses \tcode{A::f(int)} + AB::g(); // \tcode{g} is declared directly in \tcode{AB}, therefore \tcode{S} is $\{ \tcode{AB::g()} \}$ and \tcode{AB::g()} is chosen + + AB::f(1); // \tcode{f} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}; + // namespace \tcode{Y} is not searched and \tcode{Y::f(float)} is not considered; + // \tcode{S} is $\{ \tcode{A::f(int)}, \tcode{B::f(char)} \}$ and overload resolution chooses \tcode{A::f(int)} + AB::f('c'); // as above but resolution chooses \tcode{B::f(char)} - AB::x++; // \tcode{x} is not declared directly in \tcode{AB}, and - // is not declared in \tcode{A} or \tcode{B} , so the rules are - // applied recursively to \tcode{Y} and \tcode{Z}, - // \tcode{S} is \{ \} so the program is ill-formed - AB::i++; // \tcode{i} is not declared directly in \tcode{AB} so the rules are - // applied recursively to \tcode{A} and \tcode{B}, - // \tcode{S} is \{ \tcode{A::i} , \tcode{B::i} \} so the use is ambiguous - // and the program is ill-formed - AB::h(16.8); // \tcode{h} is not declared directly in \tcode{AB} and - // not declared directly in \tcode{A} or \tcode{B} so the rules are - // applied recursively to \tcode{Y} and \tcode{Z}, - // \tcode{S} is \{ \tcode{Y::h(int)}, \tcode{Z::h(double)} \} and overload - // resolution chooses \tcode{Z::h(double)} + AB::x++; // \tcode{x} is not declared directly in \tcode{AB}, and is not declared in \tcode{A} or \tcode{B}, so the rules + // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \}$ so the program is ill-formed + + AB::i++; // \tcode{i} is not declared directly in \tcode{AB} so the rules are applied recursively to \tcode{A} and \tcode{B}, + // \tcode{S} is $\{ \tcode{A::i}, \tcode{B::i} \}$ so the use is ambiguous and the program is ill-formed + + AB::h(16.8); // \tcode{h} is not declared directly in \tcode{AB} and not declared directly in \tcode{A} or \tcode{B} so the rules + // are applied recursively to \tcode{Y} and \tcode{Z}, \tcode{S} is $\{ \tcode{Y::h(int)}, \tcode{Z::h(double)} \}$ and + // overload resolution chooses \tcode{Z::h(double)} } \end{codeblock} +\end{example} \pnum +\begin{note} The same declaration found more than once is not an ambiguity (because -it is still a unique declaration). For example: - +it is still a unique declaration). +\begin{example} \begin{codeblock} namespace A { int a; @@ -1883,7 +1870,7 @@ void f() { - BC::a++; // OK: \tcode{S} is \{ \tcode{A::a}, \tcode{A::a} \} + BC::a++; // OK: \tcode{S} is $\{ \tcode{A::a}, \tcode{A::a} \}$ } namespace D { @@ -1897,11 +1884,14 @@ void g() { - BD::a++; // OK: S is \{ \tcode{ A::a}, \tcode{ A::a} \} + BD::a++; // OK: \tcode{S} is $\{ \tcode{A::a}, \tcode{A::a} \}$ } \end{codeblock} +\end{example} +\end{note} \pnum +\begin{example} Because each referenced namespace is searched at most once, the following is well-defined: @@ -1921,10 +1911,10 @@ void f() { - A::a++; // OK: \tcode{a} declared directly in \tcode{A}, \tcode{S} is \{\tcode{A::a}\} - B::a++; // OK: both \tcode{A} and \tcode{B} searched (once), \tcode{S} is \{\tcode{A::a}\} - A::b++; // OK: both \tcode{A} and \tcode{B} searched (once), \tcode{S} is \{\tcode{B::b}\} - B::b++; // OK: \tcode{b} declared directly in \tcode{B}, \tcode{S} is \{\tcode{B::b}\} + A::a++; // OK: \tcode{a} declared directly in \tcode{A}, \tcode{S} is $\{ \tcode{A::a} \}$ + B::a++; // OK: both \tcode{A} and \tcode{B} searched (once), \tcode{S} is $\{ \tcode{A::a} \}$ + A::b++; // OK: both \tcode{A} and \tcode{B} searched (once), \tcode{S} is $\{ \tcode{B::b} \}$ + B::b++; // OK: \tcode{b} declared directly in \tcode{B}, \tcode{S} is $\{ \tcode{B::b} \}$ } \end{codeblock} \end{example} @@ -1953,7 +1943,7 @@ namespace C { using namespace A; using namespace B; - int i = C::x; // OK, \tcode{A::x} (of type \tcode{int} ) + int i = C::x; // OK, \tcode{A::x} (of type \tcode{int}) int j = C::y; // ambiguous, \tcode{A::y} or \tcode{B::y} } \end{codeblock} @@ -2007,11 +1997,11 @@ void B::f1(int){ } // OK, defines \tcode{A::B::f1(int)} \end{codeblock} \end{example} -\indextext{lookup!qualified~name|)}% +\indextext{lookup!qualified name|)}% \rSec2[basic.lookup.elab]{Elaborated type specifiers}% -\indextext{lookup!elaborated~type~specifier|(}% -\indextext{type~specifier!elaborated} +\indextext{lookup!elaborated type specifier|(}% +\indextext{type specifier!elaborated} \pnum An \grammarterm{elaborated-type-specifier}~(\ref{dcl.type.elab}) may be @@ -2065,11 +2055,9 @@ struct Data { struct Node* Node; // OK: Refers to \tcode{Node} at global scope - friend struct ::Glob; // error: \tcode{Glob} is not declared - // cannot introduce a qualified type~(\ref{dcl.type.elab}) - friend struct Glob; // OK: Refers to (as yet) undeclared \tcode{Glob} - // at global scope. - /* ... */ + friend struct ::Glob; // error: \tcode{Glob} is not declared, cannot introduce a qualified type~(\ref{dcl.type.elab}) + friend struct Glob; // OK: Refers to (as yet) undeclared \tcode{Glob} at global scope. + @\commentellip@ }; struct Base { @@ -2078,7 +2066,7 @@ struct Base::Data* thisData; // OK: Refers to nested \tcode{Data} friend class ::Data; // OK: global \tcode{Data} is a friend friend class Data; // OK: nested \tcode{Data} is a friend - struct Data @\tcode{\{ /* ... */ \};}@ // Defines nested \tcode{Data} + struct Data { @\commentellip@ }; // Defines nested \tcode{Data} }; struct Data; // OK: Redeclares \tcode{Data} at global scope @@ -2088,7 +2076,7 @@ struct Base::Data* pBase; // OK: refers to nested \tcode{Data} \end{codeblock} \end{example} % -\indextext{lookup!elaborated~type~specifier|)}% +\indextext{lookup!elaborated type specifier|)}% \rSec2[basic.lookup.classref]{Class member access} @@ -2118,8 +2106,7 @@ \grammarterm{postfix-expression}. If the type \tcode{T} of the object expression is of a class type \tcode{C}, the \grammarterm{type-name} is also looked up in the scope of class \tcode{C}. At least one of the -lookups shall find a name that refers to (possibly cv-qualified) -\tcode{T}. \begin{example} +lookups shall find a name that refers to \cv{}~\tcode{T}. \begin{example} \begin{codeblock} struct A { }; @@ -2190,14 +2177,14 @@ \rSec2[basic.lookup.udir]{Using-directives and namespace aliases} \pnum -\indextext{lookup!using-directives~and}% -\indextext{lookup!namespace~aliases~and}% +\indextext{lookup!using-directives and}% +\indextext{lookup!namespace aliases and}% In a \grammarterm{using-directive} or \grammarterm{namespace-alias-definition}, during the lookup for a \grammarterm{namespace-name} or for a name in a \grammarterm{nested-name-specifier}{} only namespace names are considered.% \indextext{lookup!name|)}% -\indextext{scope!name~lookup~and|)} +\indextext{scope!name lookup and|)} \rSec1[basic.link]{Program and linkage}% \indextext{linkage|(} @@ -2237,12 +2224,12 @@ \end{itemize} \pnum -\indextext{linkage!\idxcode{static}~and}% -\indextext{\idxcode{static}!linkage~of}% -\indextext{linkage!\idxcode{const}~and}% -\indextext{\idxcode{const}!linkage~of}% -\indextext{linkage!\idxcode{inline}~and}% -\indextext{\idxcode{inline}!linkage~of}% +\indextext{linkage!\idxcode{static} and}% +\indextext{\idxcode{static}!linkage of}% +\indextext{linkage!\idxcode{const} and}% +\indextext{\idxcode{const}!linkage of}% +\indextext{linkage!\idxcode{inline} and}% +\indextext{\idxcode{inline}!linkage of}% A name having namespace scope~(\ref{basic.scope.namespace}) has internal linkage if it is the name of \begin{itemize} @@ -2266,11 +2253,11 @@ \begin{itemize} \item a variable; or \item a function; or -\item \indextext{class!linkage~of}% +\item \indextext{class!linkage of}% a named class (Clause~\ref{class}), or an unnamed class defined in a typedef declaration in which the class has the typedef name for linkage purposes~(\ref{dcl.typedef}); or -\item \indextext{enumeration!linkage~of}% +\item \indextext{enumeration!linkage of}% a named enumeration~(\ref{dcl.enum}), or an unnamed enumeration defined in a typedef declaration in which the enumeration has the typedef name for linkage purposes~(\ref{dcl.typedef}); or @@ -2310,10 +2297,10 @@ There are three objects named \tcode{i} in this program. The object with internal linkage introduced by the declaration in global scope (line -\tcode{\#1} ), the object with automatic storage duration and no linkage -introduced by the declaration on line \tcode{\#2}, and the object with +\#1), the object with automatic storage duration and no linkage +introduced by the declaration on line \#2, and the object with static storage duration and external linkage introduced by the -declaration on line \tcode{\#3}. \end{example} +declaration on line \#3. \end{example} \pnum When a block scope declaration of an entity with linkage is not found to @@ -2332,10 +2319,10 @@ q(); // error: \tcode{q} not yet declared } - void q() @\tcode{\{ /* ... */ \}}@ // definition of \tcode{X::q} + void q() { @\commentellip@ } // definition of \tcode{X::q} } -void q() @\tcode{\{ /* ... */ \}}@ // some other, unrelated \tcode{q} +void q() { @\commentellip@ } // some other, unrelated \tcode{q} \end{codeblock} \end{example} @@ -2440,11 +2427,11 @@ \rSec1[basic.start]{Start and termination} -\rSec2[basic.start.main]{Main function} +\rSec2[basic.start.main]{\tcode{main} function} +\indextext{\idxcode{main} function|(} \pnum \indextext{program!start|(}% -\indextext{\idxcode{main()}}% A program shall contain a global function called \tcode{main}, which is the designated start of the program. It is \impldef{defining \tcode{main} in freestanding environment} whether a program in a freestanding environment is required to define a \tcode{main} @@ -2459,7 +2446,7 @@ function shall not be overloaded. Its type shall have \Cpp language linkage and it shall have a declared return type of type \tcode{int}, but otherwise its type is \impldef{parameters to \tcode{main}}. -\indextext{\idxcode{main()}!implementation-defined parameters~to}% +\indextext{\idxcode{main} function!implementation-defined parameters to}% An implementation shall allow both \begin{itemize} \item a function of \tcode{()} returning \tcode{int} and @@ -2469,7 +2456,7 @@ \indextext{\idxcode{argc}}% \indextext{\idxcode{argv}}% as the type of \tcode{main}~(\ref{dcl.fct}). -\indextext{\idxcode{main()}!parameters~to}% +\indextext{\idxcode{main} function!parameters to}% \indextext{environment!program}% In the latter form, for purposes of exposition, the first function parameter is called \tcode{argc} and the second function parameter is @@ -2489,7 +2476,7 @@ \pnum The function \tcode{main} shall not be used within a program. -\indextext{\idxcode{main()}!implementation-defined linkage~of}% +\indextext{\idxcode{main} function!implementation-defined linkage of}% The linkage~(\ref{basic.link}) of \tcode{main} is \impldef{linkage of \tcode{main}}. A program that defines \tcode{main} as deleted or that declares \tcode{main} to be @@ -2499,7 +2486,7 @@ declares a variable \tcode{main} at global scope or that declares the name \tcode{main} with C language linkage (in any namespace) is ill-formed. The name \tcode{main} is -not otherwise reserved. \begin{example} member functions, classes, and +not otherwise reserved. \begin{example} Member functions, classes, and enumerations can be called \tcode{main}, as can entities in other namespaces. \end{example} @@ -2517,7 +2504,7 @@ \pnum \indextext{termination!program}% -\indextext{\idxcode{main()}!return from}% +\indextext{\idxcode{main} function!return from}% A return statement in \tcode{main} has the effect of leaving the main function (destroying any objects with automatic storage duration) and calling \tcode{std::exit} with the return value as the argument. @@ -2525,6 +2512,7 @@ the \grammarterm{compound-statement} of \tcode{main}, the effect is equivalent to a \tcode{return} with operand \tcode{0} (see also \ref{except.handle}). +\indextext{\idxcode{main} function|)} \rSec2[basic.start.static]{Static initialization} @@ -2540,7 +2528,7 @@ \indextext{initialization!\idxcode{static object}}% \indextext{initialization!constant}% A \defn{constant initializer} for an object \tcode{o} is an expression that is a -constant expression, except that it may also invoke \tcode{constexpr} constructors +constant expression, except that it may also invoke constexpr constructors for \tcode{o} and its subobjects even if those objects are of non-literal class types. \begin{note} Such a class may have a non-trivial destructor. \end{note} \defnx{Constant initialization}{constant initialization} is performed: @@ -2613,9 +2601,9 @@ \rSec2[basic.start.dynamic]{Dynamic initialization of non-local variables} \pnum -\indextext{initialization!dynamic~non-local}% +\indextext{initialization!dynamic non-local}% \indextext{start!program}% -\indextext{initialization!order~of}% +\indextext{initialization!order of}% Dynamic initialization of a non-local variable with static storage duration is unordered if the variable is an implicitly or explicitly instantiated specialization, is partially-ordered if the variable @@ -2655,7 +2643,7 @@ \end{note} \pnum -\indextext{evaluation!unspecified order~of}% +\indextext{evaluation!unspecified order of}% It is \impldef{dynamic initialization of static variables before \tcode{main}} whether the dynamic initialization of a non-local non-inline variable with static storage duration happens before the first statement of \tcode{main}. If the initialization is deferred to @@ -2733,7 +2721,7 @@ \pnum \indextext{program!termination|(}% \indextext{object!destructor static}% -\indextext{\idxcode{main()}!return from}% +\indextext{\idxcode{main} function!return from}% Destructors~(\ref{class.dtor}) for initialized objects (that is, objects whose lifetime~(\ref{basic.life}) has begun) with static storage duration @@ -2810,8 +2798,8 @@ \rSec1[basic.stc]{Storage duration} \pnum -\indextext{storage~duration|(}% -The \defnx{storage duration}{storage~duration} is the property of an object that defines the minimum +\indextext{storage duration|(}% +The \defn{storage duration} is the property of an object that defines the minimum potential lifetime of the storage containing the object. The storage duration is determined by the construct used to create the object and is one of the following: @@ -2824,10 +2812,10 @@ \end{itemize} \pnum -\indextext{storage~duration!static}% -\indextext{storage~duration!thread}% -\indextext{storage~duration!automatic}% -\indextext{storage~duration!dynamic}% +\indextext{storage duration!static}% +\indextext{storage duration!thread}% +\indextext{storage duration!automatic}% +\indextext{storage duration!dynamic}% Static, thread, and automatic storage durations are associated with objects introduced by declarations~(\ref{basic.def}) and implicitly created by the implementation~(\ref{class.temporary}). The dynamic storage duration @@ -2854,7 +2842,7 @@ \rSec2[basic.stc.static]{Static storage duration} \pnum -\indextext{storage~duration!static}% +\indextext{storage duration!static}% All variables which do not have dynamic storage duration, do not have thread storage duration, and are not local have \defn{static storage duration}. The @@ -2882,7 +2870,7 @@ \rSec2[basic.stc.thread]{Thread storage duration} \pnum -\indextext{storage~duration!thread}% +\indextext{storage duration!thread}% All variables declared with the \tcode{thread_local} keyword have \defn{thread storage duration}. The storage for these entities shall last for the duration of the thread in which they are created. There is a distinct object or reference @@ -2896,8 +2884,8 @@ \rSec2[basic.stc.auto]{Automatic storage duration} \pnum -\indextext{storage~duration!automatic}% -\indextext{storage~duration!local object}% +\indextext{storage duration!automatic}% +\indextext{storage duration!local object}% Block-scope variables not explicitly declared \tcode{static}, \tcode{thread_local}, or \tcode{extern} have \defn{automatic storage duration}. The storage @@ -2916,7 +2904,7 @@ specified in~\ref{class.copy}. \rSec2[basic.stc.dynamic]{Dynamic storage duration}% -\indextext{storage~duration!dynamic|(} +\indextext{storage duration!dynamic|(} \pnum Objects can be created dynamically during program @@ -3072,7 +3060,7 @@ in global scope. \pnum -\indextext{\idxcode{delete}!overloading~and}% +\indextext{\idxcode{delete}!overloading and}% Each deallocation function shall return \tcode{void} and its first parameter shall be \tcode{void*}. A deallocation function may have more than one parameter. @@ -3121,7 +3109,7 @@ \pnum \indextext{pointer!safely-derived|(}% -\indextext{pointer!to~traceable~object}% +\indextext{pointer!to traceable object}% A \defn{traceable pointer object} is \begin{itemize} \item an object of an object pointer @@ -3207,25 +3195,25 @@ \impldef{whether an implementation has relaxed or strict pointer safety} whether an implementation has relaxed or strict pointer safety.% \indextext{pointer!safely-derived|)}% -\indextext{storage~duration!dynamic|)} +\indextext{storage duration!dynamic|)} \rSec2[basic.stc.inherit]{Duration of subobjects} \pnum -\indextext{storage~duration!class member}% +\indextext{storage duration!class member}% The storage duration of subobjects and reference members is that of their complete object~(\ref{intro.object}). -\indextext{storage~duration|)}% +\indextext{storage duration|)}% \rSec1[basic.life]{Object lifetime} \pnum -\indextext{object~lifetime|(}% +\indextext{object lifetime|(}% The \defn{lifetime} of an object or reference is a runtime property of the object or reference. An object is said to have \defnx{non-vacuous initialization}{initialization!non-vacuous} if it is of a class or aggregate type and it or one of its subobjects is initialized by a constructor -other than a trivial default constructor. \begin{note} initialization by a +other than a trivial default constructor. \begin{note} Initialization by a trivial copy/move constructor is non-vacuous initialization. \end{note} The lifetime of an object of type \tcode{T} begins when: \begin{itemize} @@ -3307,9 +3295,9 @@ \item the pointer is used as the operand of a \tcode{static_cast}~(\ref{expr.static.cast}), except when the conversion - is to pointer to \cv{} \tcode{void}, or to pointer to \cv{} - \tcode{void} and subsequently to pointer to either \cv{} - \tcode{char} or \cv{} \tcode{unsigned char}, or + is to pointer to \cv{}~\tcode{void}, or to pointer to \cv{}~\tcode{void} + and subsequently to pointer to either \cv{}~\tcode{char} + or \cv{}~\tcode{unsigned char}, or \item the pointer is used as the operand of a \tcode{dynamic_cast}~(\ref{expr.dynamic.cast}). @@ -3462,7 +3450,7 @@ void h() { b.~B(); - new (const_cast(&b)) const B; // undefined behavior + new (const_cast(&b)) const B; // undefined behavior } \end{codeblock} \end{example} @@ -3472,7 +3460,7 @@ relation~(\ref{intro.multithread}). \begin{note} Therefore, undefined behavior results if an object that is being constructed in one thread is referenced from another thread without adequate synchronization. \end{note}% -\indextext{object~lifetime|)} +\indextext{object lifetime|)} \rSec1[basic.types]{Types}% \indextext{type|(} @@ -3489,8 +3477,8 @@ \end{note} \pnum -\indextext{object!byte~copying~and|(}% -\indextext{type!trivially~copyable}% +\indextext{object!byte copying and|(}% +\indextext{type!trivially copyable}% For any object (other than a base-class subobject) of trivially copyable type \tcode{T}, whether or not the object holds a valid value of type \tcode{T}, the underlying bytes~(\ref{intro.memory}) making up the @@ -3500,15 +3488,12 @@ If the content of the array of \tcode{char} or \tcode{unsigned} \tcode{char} is copied back into the object, the object shall subsequently hold its original value. \begin{example} - \begin{codeblock} #define N sizeof(T) char buf[N]; T obj; // \tcode{obj} initialized to its original value -std::memcpy(buf, &obj, N); // between these two calls to \tcode{std::memcpy}, - // \tcode{obj} might be modified -std::memcpy(&obj, buf, N); // at this point, each subobject of \tcode{obj} of scalar type - // holds its original value +std::memcpy(buf, &obj, N); // between these two calls to \tcode{std::memcpy}, \tcode{obj} might be modified +std::memcpy(&obj, buf, N); // at this point, each subobject of \tcode{obj} of scalar type holds its original value \end{codeblock} \end{example} @@ -3531,7 +3516,7 @@ // the same value as the corresponding subobject in \tcode{*t2p} \end{codeblock} \end{example}% -\indextext{object!byte~copying~and|)} +\indextext{object!byte copying and|)} \pnum The \defn{object representation} @@ -3554,11 +3539,11 @@ \indextext{type!incompletely-defined object}% A class that has been declared but not defined, an enumeration type in certain contexts~(\ref{dcl.enum}), or an array of unknown -size or of incomplete element type, is an +bound or of incomplete element type, is an \defnx{incompletely-defined object type}{object type!incompletely-defined}.% \footnote{The size and layout of an instance of an incompletely-defined object type is unknown.} -Incompletely-defined object types and \cv{} \tcode{void} are +Incompletely-defined object types and \cv{}~\tcode{void} are \defnx{incomplete types}{type!incomplete}~(\ref{basic.fundamental}). Objects shall not be defined to have an incomplete type. @@ -3575,10 +3560,10 @@ point in a translation unit and complete later on; the array types at those two points (``array of unknown bound of \tcode{T}'' and ``array of \tcode{N} \tcode{T}'') are different types. The type of a pointer to array of -unknown size, or of a type defined by a \tcode{typedef} declaration to -be an array of unknown size, cannot be completed. \begin{example} +unknown bound, or of a type defined by a \tcode{typedef} declaration to +be an array of unknown bound, cannot be completed. \begin{example} -\indextext{type!example~of incomplete}% +\indextext{type!example of incomplete}% \begin{codeblock} class X; // \tcode{X} is an incomplete type extern X* xp; // \tcode{xp} is a pointer to an incomplete type @@ -3611,9 +3596,8 @@ contexts incomplete types are prohibited. \end{note} \pnum -\indextext{object~type}% An \defn{object type} is a (possibly cv-qualified) type that is not -a function type, not a reference type, and not \cv{} \tcode{void}. +a function type, not a reference type, and not \cv{}~\tcode{void}. \pnum Arithmetic types~(\ref{basic.fundamental}), enumeration types, pointer @@ -3622,7 +3606,7 @@ and cv-qualified versions of these types~(\ref{basic.type.qualifier}) are collectively called -\defnx{scalar types}{scalar~type}. Scalar types, +\defnx{scalar types}{scalar type}. Scalar types, POD classes (Clause~\ref{class}), arrays of such types and cv-qualified versions of these types~(\ref{basic.type.qualifier}) are collectively called @@ -3652,7 +3636,7 @@ \item it has a trivial destructor, \item it is either a closure type~(\ref{expr.prim.lambda}), an aggregate type~(\ref{dcl.init.aggr}), or -has at least one \tcode{constexpr} constructor or constructor template +has at least one constexpr constructor or constructor template (possibly inherited~(\ref{namespace.udecl}) from a base class) that is not a copy or move constructor, \item if it is a union, at least one of its non-static data members is @@ -3663,7 +3647,7 @@ \end{itemize} \pnum -\indextext{layout-compatible~type}% +\indextext{layout-compatible type}% Two types \cvqual{cv1} \tcode{T1} and \cvqual{cv2} \tcode{T2} are \defn{layout-compatible} types if \tcode{T1} and \tcode{T2} are the same type, @@ -3686,7 +3670,7 @@ value of that character object is equal to the value of the single character literal form of that character. It is \impldef{signedness of \tcode{char}} whether a \tcode{char} object can hold negative values. -\indextext{\idxcode{char}!implementation-defined sign~of}% +\indextext{\idxcode{char}!implementation-defined sign of}% \indextext{type!\idxcode{signed char}}% \indextext{type!\idxcode{unsigned char}}% Characters can be explicitly declared \tcode{unsigned} or @@ -3719,8 +3703,8 @@ \placeholder{j} to \tcode{unsigned char} is \placeholder{i}. \pnum -\indextext{type!standard~signed~integer}% -There are five \defnx{standard signed integer types}{standard~signed~integer~type} : +\indextext{type!standard signed integer}% +There are five \defnx{standard signed integer types}{standard signed integer type} : \indextext{type!\idxcode{signed char}}% \indextext{type!\idxcode{short}}% \indextext{type!\idxcode{int}}% @@ -3730,14 +3714,14 @@ ``\tcode{long int}'', and ``\tcode{long} \tcode{long} \tcode{int}''. In this list, each type provides at least as much storage as those preceding it in the list. -\indextext{type!extended~signed~integer}% -\indextext{type!signed~integer}% +\indextext{type!extended signed integer}% +\indextext{type!signed integer}% There may also be \impldef{extended signed integer types} -\defnx{extended signed integer types}{extended~signed~integer~type}. +\defnx{extended signed integer types}{extended signed integer type}. The standard and extended signed integer types are collectively called -\defnx{signed integer types}{signed~integer~type}. -\indextext{integral~type!implementation-defined @\tcode{sizeof}}% +\defnx{signed integer types}{signed integer type}. +\indextext{integral type!implementation-defined @\tcode{sizeof}}% Plain \tcode{int}s have the natural size suggested by the architecture of the execution environment% @@ -3751,8 +3735,8 @@ \indextext{type!\idxcode{unsigned}}% For each of the standard signed integer types, there exists a corresponding (but different) -\indextext{type!standard~unsigned~integer}% -\defnx{standard unsigned integer type}{standard~unsigned~integer~type}: +\indextext{type!standard unsigned integer}% +\defn{standard unsigned integer type}: \indextext{type!\idxcode{unsigned char}}% \indextext{type!\idxcode{unsigned short}}% \indextext{type!\idxcode{unsigned int}}% @@ -3767,24 +3751,25 @@ the sequences of \grammarterm{type-specifier}{s} that designate them.}; that is, each signed integer type has the same object representation as its corresponding unsigned integer type. -\indextext{type!extended~unsigned~integer}% -\indextext{type!unsigned~integer}% +\indextext{type!extended unsigned integer}% +\indextext{type!unsigned integer}% Likewise, for each of the extended signed integer types there exists a corresponding -\defnx{extended unsigned integer type}{extended~unsigned~integer~type} with the same amount of storage and alignment +\defn{extended unsigned integer type} with the same amount of storage and alignment requirements. The standard and extended unsigned integer types are -collectively called \defnx{unsigned integer types}{unsigned~integer~type}. The range of non-negative +collectively called \defnx{unsigned integer types}{unsigned integer type}. The range of non-negative values of a signed integer type is a subrange of the corresponding unsigned integer type, and the value representation of each corresponding signed/unsigned type shall be the same. -\indextext{type!standard~integer}% -\indextext{type!extended~integer}% +\indextext{type!standard integer}% +\indextext{type!extended integer}% The standard signed integer types and standard unsigned integer types -are collectively called the \defnx{standard integer types}{standard~integer~type}, and the extended +are collectively called the \defnx{standard integer types}{standard integer type}, and the extended signed integer types and extended -unsigned integer types are collectively called the \defnx{extended -integer types}{extended~integer~type}. The signed and unsigned integer types shall satisfy +unsigned integer types are collectively called the +\defnx{extended integer types}{extended integer type}. +The signed and unsigned integer types shall satisfy the constraints given in the C standard, section 5.2.4.2.1. \pnum @@ -3804,7 +3789,7 @@ \indextext{type!\idxcode{char16_t}}% \indextext{type!\idxcode{char32_t}}% \indextext{type!\idxcode{wchar_t}}% -\indextext{underlying~type|see{type, underlying}}% +\indextext{underlying type|see{type, underlying}}% \indextext{type!underlying!\idxcode{char16_t}}% \indextext{type!underlying!\idxcode{char32_t}}% Type \tcode{wchar_t} is a distinct type whose values can represent @@ -3818,10 +3803,10 @@ respectively, in \tcode{}, called the underlying types. \pnum -\indextext{Boolean~type}% +\indextext{Boolean type}% Values of type \tcode{bool} are either \tcode{true} or \tcode{false}.\footnote{Using a \tcode{bool} value in ways described by this International -Standard as ``undefined,'' such as by examining the value of an +Standard as ``undefined'', such as by examining the value of an uninitialized automatic object, might cause it to behave as if it is neither \tcode{true} nor \tcode{false}.} \begin{note} There are no \tcode{signed}, \tcode{unsigned}, \tcode{short}, @@ -3832,26 +3817,26 @@ Types \tcode{bool}, \tcode{char}, \tcode{char16_t}, \tcode{char32_t}, \tcode{wchar_t}, and the signed and unsigned integer types are collectively called -\defnx{integral}{integral~type} types.\footnote{Therefore, enumerations~(\ref{dcl.enum}) are not integral; however, +\defnx{integral}{integral type} types.\footnote{Therefore, enumerations~(\ref{dcl.enum}) are not integral; however, enumerations can be promoted to integral types as specified in~\ref{conv.prom}.} A synonym for integral type is \indextext{signed integer representation!ones' complement}% \indextext{signed integer representation!two's complement}% \indextext{signed integer representation!signed magnitude}% -\defnx{integer type}{integer~type}. The representations of integral types shall +\defn{integer type}. The representations of integral types shall define values by use of a pure binary numeration system.\footnote{A positional representation for integers that uses the binary digits 0 and 1, in which the values represented by successive bits are additive, begin with 1, and are multiplied by successive integral power of 2, except perhaps for the bit with the highest position. (Adapted from the \doccite{American National Dictionary for Information Processing Systems}.)} -\begin{example} this International Standard permits two's complement, +\begin{example} This International Standard permits two's complement, ones' complement and signed magnitude representations for integral types. \end{example} \pnum -There are three \defnx{floating-point}{floating~point~type} types: +There are three \defnx{floating-point}{floating-point type} types: \indextext{type!\idxcode{float}}% \tcode{float}, \indextext{type!\idxcode{double}}% @@ -3866,10 +3851,10 @@ of the set of values of the type \tcode{long} \tcode{double}. The value representation of floating-point types is \impldef{value representation of floating-point types}. -\indextext{floating~point~type!implementation-defined}% +\indextext{floating-point type!implementation-defined}% \begin{note} This International Standard imposes no requirements on the accuracy of -floating-point operations; see also~\ref{limits}. +floating-point operations; see also~\ref{support.limits}. \end{note} Integral and floating types are collectively called \defnx{arithmetic}{type!arithmetic} types. @@ -3881,19 +3866,19 @@ \pnum \indextext{type!\idxcode{void}}% -A type \cv{} \tcode{void} +A type \cv{}~\tcode{void} is an incomplete type that cannot be completed; such a type has an empty set of values. It is used as the return type for functions that do not return a value. Any expression can be -explicitly converted to type \cv{} \tcode{void}~(\ref{expr.cast}). -An expression of type \cv{} \tcode{void} shall +explicitly converted to type \cv{}~\tcode{void}~(\ref{expr.cast}). +An expression of type \cv{}~\tcode{void} shall be used only as an expression statement~(\ref{stmt.expr}), as an operand of a comma expression~(\ref{expr.comma}), as a second or third operand of \tcode{?:}~(\ref{expr.cond}), as the operand of \tcode{typeid}, \tcode{noexcept}, or \tcode{decltype}, as the expression in a return statement~(\ref{stmt.return}) for a function -with the return type \cv{} \tcode{void}, or as the operand of an explicit conversion -to type \cv{} \tcode{void}. +with the return type \cv{}~\tcode{void}, or as the operand of an explicit conversion +to type \cv{}~\tcode{void}. \pnum A value of type \tcode{std::nullptr_t} is a null pointer @@ -3918,7 +3903,7 @@ \item \defnx{functions}{type!function}, which have parameters of given types and return \tcode{void} or references or objects of a given type,~\ref{dcl.fct}; -\item \defnx{pointers}{type!pointer} to \cv{} \tcode{void} or objects or functions (including +\item \defnx{pointers}{type!pointer} to \cv{}~\tcode{void} or objects or functions (including static members of classes) of a given type,~\ref{dcl.ptr}; \item % @@ -3927,8 +3912,8 @@ \defnx{references}{reference} to objects or functions of a given type,~\ref{dcl.ref}. There are two types of references: \begin{itemize} -\item \defnx{lvalue reference}{lvalue~reference} -\item \defnx{rvalue reference}{rvalue~reference} +\item \defn{lvalue reference} +\item \defn{rvalue reference} \end{itemize} \item @@ -3946,8 +3931,8 @@ Each distinct enumeration constitutes a different \defnx{enumerated type}{type!enumerated},~\ref{dcl.enum}; -\item \indextext{member~pointer~to|see{pointer to member}}% -\defnx{pointers to non-static class members}{pointer~to~member},% +\item \indextext{member pointer to|see{pointer to member}}% +\defnx{pointers to non-static class members}{pointer to member},% \footnote{Static class members are objects or functions, and pointers to them are ordinary pointers to objects or functions.} which identify members of a given @@ -3963,14 +3948,14 @@ \pnum \indextext{terminology!pointer}% -The type of a pointer to \cv{} \tcode{void} or a pointer to an object type is +The type of a pointer to \cv{}~\tcode{void} or a pointer to an object type is called an \defn{object pointer type}. \begin{note} A pointer to \tcode{void} does not have a pointer-to-object type, however, because \tcode{void} is not an object type. \end{note} The type of a pointer that can designate a function is called a \defn{function pointer type}. A pointer to objects of type \tcode{T} is referred to as a ``pointer to -\tcode{T}''. \begin{example} a pointer to an object of type \tcode{int} is -referred to as ``pointer to \tcode{int} '' and a pointer to an object of +\tcode{T}''. \begin{example} A pointer to an object of type \tcode{int} is +referred to as ``pointer to \tcode{int}'' and a pointer to an object of class \tcode{X} is called a ``pointer to \tcode{X}''. \end{example} Except for pointers to static members, text referring to ``pointers'' does not apply to pointers to members. Pointers to incomplete types are @@ -4013,7 +3998,7 @@ a pointer past the end of the last element of an array \tcode{x} of $n$ elements is considered to be equivalent to -a pointer to a hypothetical element $\mathtt{x[}n\mathtt{]}$. +a pointer to a hypothetical element \tcode{x[$n$]}. The value representation of pointer types is \impldef{value representation of pointer types}. Pointers to layout-compatible types shall @@ -4058,9 +4043,9 @@ \tcode{void} can be used to point to objects of unknown type. Such a pointer shall be able to hold any object pointer. -An object of type \cv{} -\tcode{void*} shall have the same representation and alignment -requirements as \cv{} \tcode{char*}. +An object of type \cv{}~\tcode{void*} +shall have the same representation and alignment +requirements as \cv{}~\tcode{char*}. \rSec2[basic.type.qualifier]{CV-qualifiers} @@ -4074,8 +4059,8 @@ \tcode{void}~(\ref{basic.types}) has three corresponding cv-qualified versions of its type: a \defn{const-qualified} version, a \defn{volatile-qualified} version, and a -\defn{const-volatile-qualified} version. The term -\term{object type}~(\ref{intro.object}) includes the cv-qualifiers +\defn{const-volatile-qualified} version. The +type of an object~(\ref{intro.object}) includes the \grammarterm{cv-qualifier}{s} specified in the \grammarterm{decl-specifier-seq}~(\ref{dcl.spec}), \grammarterm{declarator} (Clause~\ref{dcl.decl}), \grammarterm{type-id}~(\ref{dcl.name}), or @@ -4134,7 +4119,7 @@ represents an arbitrary set of cv-qualifiers, i.e., one of \{\tcode{const}\}, \{\tcode{volatile}\}, \{\tcode{const}, \tcode{volatile}\}, or the empty set. -For a type \cv{} \tcode{T}, the \defnx{top-level cv-qualifiers}{cv-qualifier!top-level} +For a type \cv{}~\tcode{T}, the \defnx{top-level cv-qualifiers}{cv-qualifier!top-level} of that type are those denoted by \cv. \begin{example} The type corresponding to the \grammarterm{type-id} @@ -4152,11 +4137,10 @@ \pnum Cv-qualifiers applied to an array type attach to the underlying element type, so the notation -``\cv{} \tcode{T}'', where \tcode{T} is an array type, refers to +``\cv{}~\tcode{T}'', where \tcode{T} is an array type, refers to an array whose elements are so-qualified. An array type whose elements are cv-qualified is also considered to have the same cv-qualifications -as its elements.% -\indextext{type|)} +as its elements. \begin{example} \begin{codeblock} typedef char CA[5]; @@ -4167,7 +4151,8 @@ The type of both \tcode{arr1} and \tcode{arr2} is ``array of 5 \tcode{const char}'', and the array type is considered to be const-qualified. -\end{example} +\end{example}% +\indextext{type|)} \rSec1[basic.lval]{Lvalues and rvalues} \pnum @@ -4220,7 +4205,7 @@ is the object initialized by the prvalue; a prvalue that is used to compute the value of an operand of an operator or -that has type (possibly cv-qualified) \tcode{void} +that has type \cv{}~\tcode{void} has no result object. \begin{note} Except when the prvalue is the operand of a \grammarterm{decltype-specifier}, @@ -4256,7 +4241,7 @@ \pnum Unless otherwise indicated~(\ref{expr.call}), a prvalue shall always have complete type or the \tcode{void} type. -A glvalue shall not have type \cv{} \tcode{void}. +A glvalue shall not have type \cv{}~\tcode{void}. \begin{note} A glvalue may have complete or incomplete non-\tcode{void} type. Class and array prvalues can have cv-qualified types; other prvalues @@ -4304,7 +4289,7 @@ \rSec1[basic.align]{Alignment} \pnum -Object types have \defnx{alignment requirements}{alignment~requirement!implementation-defined} (\ref{basic.fundamental},~\ref{basic.compound}) +Object types have \defnx{alignment requirements}{alignment requirement!implementation-defined} (\ref{basic.fundamental},~\ref{basic.compound}) which place restrictions on the addresses at which an object of that type may be allocated. An \defn{alignment} is an \impldef{alignment} integer value representing the number of bytes between successive addresses @@ -4314,7 +4299,7 @@ \pnum \indextext{alignment!fundamental}% -A \defnx{fundamental alignment}{fundamental~alignment} is represented by an alignment +A \defn{fundamental alignment} is represented by an alignment less than or equal to the greatest alignment supported by the implementation in all contexts, which is equal to \tcode{alignof(std::max_align_t)}~(\ref{support.types}). @@ -4336,14 +4321,14 @@ \pnum \indextext{alignment!extended}% \indextext{alignment!new-extended}% -\indextext{over-aligned~type}% +\indextext{over-aligned type}% \indextext{type!over-aligned}% An \defn{extended alignment} is represented by an alignment greater than \tcode{alignof(std::max_align_t)}. It is \impldef{support for extended alignments} whether any extended alignments are supported and the contexts in which they are supported~(\ref{dcl.align}). A type having an extended alignment requirement is an \grammarterm{over-aligned type}. \begin{note} -every over-aligned type is or contains a class type +Every over-aligned type is or contains a class type to which extended alignment applies (possibly through a non-static data member). \end{note} A \defn{new-extended alignment} is represented by diff --git a/source/classes.tex b/source/classes.tex index d14f8a8009..bd45a647f8 100644 --- a/source/classes.tex +++ b/source/classes.tex @@ -9,10 +9,10 @@ \pnum \indextext{\idxcode{\{\}}!class declaration}% \indextext{\idxcode{\{\}}!class definition}% -\indextext{type!class~and}% -\indextext{object~class|seealso{class~object}}% +\indextext{type!class and}% +\indextext{object class|seealso{class object}}% A class is a type. -\indextext{name~class|see{class~name}}% +\indextext{name class|see{class name}}% Its name becomes a \grammarterm{class-name}~(\ref{class.name}) within its scope. @@ -110,9 +110,9 @@ \end{note} \pnum -\indextext{\idxcode{struct}!\tcode{class}~versus}% +\indextext{\idxcode{struct}!\tcode{class} versus}% \indextext{structure}% -\indextext{\idxcode{union}!\tcode{class}~versus}% +\indextext{\idxcode{union}!\tcode{class} versus}% A \term{union} is a class defined with the \grammarterm{class-key} \tcode{union}; \indextext{access control!\idxcode{union} default member}% @@ -122,7 +122,7 @@ \end{note} \indextext{class!trivial}% -\indextext{trivial~class}% +\indextext{trivial class}% \indextext{class!trivially copyable}% \pnum A \defn{trivially copyable class} is a class: @@ -144,7 +144,7 @@ virtual functions or virtual base classes.\end{note} \indextext{class!standard-layout}% -\indextext{standard-layout~class}% +\indextext{standard-layout class}% \pnum A class \tcode{S} is a \grammarterm{standard-layout class} if it: \begin{itemize} @@ -213,9 +213,9 @@ \end{example} \indextext{struct!standard-layout}% -\indextext{standard-layout~struct}% +\indextext{standard-layout struct}% \indextext{union!standard-layout}% -\indextext{standard-layout~union}% +\indextext{standard-layout union}% \pnum A \grammarterm{standard-layout struct} is a standard-layout class defined with the \grammarterm{class-key} \tcode{struct} or the @@ -282,8 +282,8 @@ definition shall not begin with a \grammarterm{decltype-specifier}. \rSec1[class.name]{Class names} -\indextext{definition!class~name~as type}% -\indextext{structure~tag|see{class~name}}% +\indextext{definition!class name as type}% +\indextext{structure tag|see{class name}}% \indextext{equivalence!type}% \pnum @@ -325,10 +325,10 @@ \end{example} \pnum -\indextext{definition!scope~of class}% -\indextext{class~name!scope~of}% +\indextext{definition!scope of class}% +\indextext{class name!scope of}% A class declaration introduces the class name into the scope where -\indextext{name~hiding!class definition}% +\indextext{name hiding!class definition}% it is declared and hides any class, variable, function, or other declaration of that name in an enclosing scope~(\ref{basic.scope}). If a class name is declared in a @@ -337,38 +337,33 @@ referred to only using an \grammarterm{elaborated-type-specifier}~(\ref{basic.lookup.elab}). \begin{example} - \begin{codeblock} struct stat { // ... }; -stat gstat; // use plain \tcode{stat} to - // define variable +stat gstat; // use plain \tcode{stat} to define variable int stat(struct stat*); // redeclare \tcode{stat} as function void f() { - struct stat* ps; // \tcode{struct} prefix needed - // to name \tcode{struct stat} + struct stat* ps; // \tcode{struct} prefix needed to name \tcode{struct stat} stat(ps); // call \tcode{stat()} } \end{codeblock} \end{example} -\indextext{class~name!elaborated}% +\indextext{class name!elaborated}% \indextext{declaration!forward class}% -A \grammarterm{declaration} consisting solely of \grammarterm{class-key -identifier;} is either a redeclaration of the name in the current scope +A \grammarterm{declaration} consisting solely of \grammarterm{class-key} +\grammarterm{identifier}\tcode{;} is either a redeclaration of the name in the current scope or a forward declaration of the identifier as a class name. It introduces the class name into the current scope. \begin{example} - \begin{codeblock} struct s { int a; }; void g() { - struct s; // hide global \tcode{struct s} - // with a block-scope declaration + struct s; // hide global \tcode{struct s} with a block-scope declaration s* p; // refer to local \tcode{struct s} struct s { char* p; }; // define local \tcode{struct s} struct s; // redeclaration, has no effect @@ -379,7 +374,6 @@ Such declarations allow definition of classes that refer to each other. \indextext{example!friend}% \begin{example} - \begin{codeblock} class Vector; @@ -393,15 +387,14 @@ friend Vector operator*(const Matrix&, const Vector&); }; \end{codeblock} - Declaration of \tcode{friend}s is described in~\ref{class.friend}, operator functions in~\ref{over.oper}. \end{example} \end{note} \pnum -\indextext{class~name!elaborated}% -\indextext{elaborated~type~specifier|see{class name, elaborated}}% +\indextext{class name!elaborated}% +\indextext{elaborated type specifier|see{class name, elaborated}}% \begin{note} An \grammarterm{elaborated-type-specifier}~(\ref{dcl.type.elab}) can also be used as a \grammarterm{type-specifier} as part of a declaration. It @@ -421,7 +414,7 @@ \end{example} \pnum -\indextext{class~name!point~of declaration}% +\indextext{class name!point of declaration}% \begin{note} The declaration of a class name takes effect immediately after the \grammarterm{identifier} is seen in the class definition or @@ -438,7 +431,7 @@ \end{note} \pnum -\indextext{class~name!\idxcode{typedef}}% +\indextext{class name!\idxcode{typedef}}% A \grammarterm{typedef-name}~(\ref{dcl.typedef}) that names a class type, or a cv-qualified version thereof, is also a \grammarterm{class-name}. If a \grammarterm{typedef-name} that names a cv-qualified class type is used @@ -448,7 +441,7 @@ \rSec1[class.mem]{Class members}% \indextext{declaration!member}% -\indextext{data~member|see{member}} +\indextext{data member|see{member}} \begin{bnf} \nontermdef{member-specification}\br @@ -572,7 +565,7 @@ \end{note} \pnum -\indextext{completely~defined}% +\indextext{completely defined}% A class is considered a completely-defined object type~(\ref{basic.types}) (or complete type) at the closing \tcode{\}} of the \grammarterm{class-specifier}. @@ -608,7 +601,7 @@ see~\ref{class.static.data}; for non-static data members, see~\ref{class.base.init} and~\ref{dcl.init.aggr}). A \grammarterm{brace-or-equal-initializer} for a non-static data member -\indextext{member!default~initializer}% +\indextext{member!default initializer}% specifies a \defn{default member initializer} for the member, and shall not directly or indirectly cause the implicit definition of a defaulted default constructor for the enclosing class or the @@ -616,7 +609,7 @@ \pnum A member shall not be declared with the \tcode{extern} -\nonterminal{storage-class-specifier}. Within a class definition, a member shall not be declared with the \tcode{thread_local} \nonterminal{storage-class-specifier} unless also declared \tcode{static}. +\grammarterm{storage-class-specifier}. Within a class definition, a member shall not be declared with the \tcode{thread_local} \grammarterm{storage-class-specifier} unless also declared \tcode{static}. \pnum The \grammarterm{decl-specifier-seq} may be omitted in constructor, destructor, @@ -644,7 +637,7 @@ function~(\ref{class.virtual}). \pnum -\indextext{class~object!member}% +\indextext{class object!member}% Non-static data members shall not have incomplete types. In particular, a class \tcode{C} shall not contain a non-static member of class \tcode{C}, but it can contain a pointer or @@ -664,7 +657,7 @@ \end{note} \pnum -\indextext{example!class~definition}% +\indextext{example!class definition}% \begin{example} A simple example of a class definition is @@ -694,7 +687,7 @@ \end{example} \pnum -\indextext{layout!class~object}% +\indextext{layout!class object}% Non-static data members of a (non-union) class with the same access control (Clause~\ref{class.access}) are allocated so that later @@ -782,8 +775,8 @@ struct T2 { int c; double d; }; union U { T1 t1; T2 t2; }; int f() { - U u = { { 1, 2 } }; // active member is \tcode{t1} - return u.t2.c; // OK, as if \tcode{u.t1.a} were nominated + U u = { { 1, 2 } }; // active member is \tcode{t1} + return u.t2.c; // OK, as if \tcode{u.t1.a} were nominated } \end{codeblock} \end{example} @@ -810,7 +803,7 @@ \pnum \indextext{member function!inline}% -\indextext{definition!member~function}% +\indextext{definition!member function}% A member function may be defined~(\ref{dcl.fct.def}) in its class definition, in which case it is an \term{inline} member function~(\ref{dcl.fct.spec}), or it may be defined outside of its class @@ -843,7 +836,7 @@ \end{note} \pnum -\indextext{operator!scope~resolution}% +\indextext{operator!scope resolution}% If the definition of a member function is lexically outside its class definition, the member function name shall be qualified by its class name using the \tcode{::} operator. @@ -883,7 +876,7 @@ Previously declared member functions may be mentioned in \tcode{friend} declarations. \pnum -\indextext{local~class!member~function~in}% +\indextext{local class!member function in}% Member functions of a local class shall be defined inline in their class definition, if they are defined at all. @@ -958,7 +951,7 @@ \grammarterm{nested-name-specifier} names the class of the member function. These transformations do not apply in the template definition context~(\ref{temp.dep.type}). -\indextext{example!member~function}% +\indextext{example!member function}% \begin{example} \begin{codeblock} @@ -1030,11 +1023,11 @@ \indextext{member function!\idxcode{this}} \pnum -\indextext{this pointer@\tcode{this}~pointer|see{\tcode{this}}}% +\indextext{this pointer@\tcode{this} pointer|see{\tcode{this}}}% In the body of a non-static~(\ref{class.mfct}) member function, the keyword \tcode{this} is a prvalue expression whose value is the address of the object for which the function is called. -\indextext{\idxcode{this}!type~of}% +\indextext{\idxcode{this}!type of}% The type of \tcode{this} in a member function of a class \tcode{X} is \tcode{X*}. \indextext{member function!\idxcode{const}}% @@ -1046,7 +1039,7 @@ is declared \tcode{const} \tcode{volatile}, the type of \tcode{this} is \tcode{const} \tcode{volatile} \tcode{X*}. \indextext{member function!\idxcode{const}}% -\begin{note} thus in a \tcode{const} member function, the object for which the function is +\begin{note} Thus in a \tcode{const} member function, the object for which the function is called is accessed through a \tcode{const} access path. \end{note} \begin{example} @@ -1094,10 +1087,10 @@ \end{example} \pnum -\indextext{\idxcode{const}!constructor~and}% -\indextext{\idxcode{const}!destructor~and}% -\indextext{\idxcode{volatile}!constructor~and}% -\indextext{\idxcode{volatile}!destructor~and}% +\indextext{\idxcode{const}!constructor and}% +\indextext{\idxcode{const}!destructor and}% +\indextext{\idxcode{volatile}!constructor and}% +\indextext{\idxcode{volatile}!destructor and}% Constructors~(\ref{class.ctor}) and destructors~(\ref{class.dtor}) shall not be declared \tcode{const}, \tcode{volatile} or \tcode{const} \tcode{volatile}. \begin{note} However, these functions can be invoked to @@ -1198,7 +1191,7 @@ \tcode{volatile}, or \tcode{const volatile}. \rSec3[class.static.data]{Static data members} -\indextext{member~data!static}% +\indextext{member data!static}% \pnum A static data member is not part of the subobjects of a class. If a @@ -1213,11 +1206,11 @@ The declaration of a non-inline static data member in its class definition is not a definition and may be of an incomplete type other than -\cv{} \tcode{void}. The definition for a static data +\cv{}~\tcode{void}. The definition for a static data member that is not defined inline in the class definition shall appear in a namespace scope enclosing the member's class definition. -\indextext{operator~use!scope~resolution}% +\indextext{operator use!scope resolution}% In the definition at namespace scope, the name of the static data member shall be qualified by its class name using the \tcode{::} operator. The \grammarterm{initializer} expression in the definition of a @@ -1249,7 +1242,7 @@ Once the static data member has been defined, it exists even if no objects of its class have been created. \begin{example} -in the example above, \tcode{run_chain} and \tcode{running} exist even +In the example above, \tcode{run_chain} and \tcode{running} exist even if no objects of class \tcode{process} are created by the program. \end{example} \end{note} @@ -1304,7 +1297,7 @@ identifier\opt attribute-specifier-seq\opt{} \terminal{:} constant-expression \end{ncbnftab} -\indextext{\idxcode{:}!field declaration}% +\indextext{\idxcode{:}!bit-field declaration}% \indextext{declaration!bit-field}% specifies a bit-field; its length is set off from the bit-field name by a colon. The optional \grammarterm{attribute-specifier-seq} appertains to the entity being declared. The bit-field @@ -1316,10 +1309,10 @@ representation~(\ref{basic.types}) of the bit-field's type; in such cases the extra bits are used as padding bits and do not participate in the value representation~(\ref{basic.types}) of the bit-field. -\indextext{allocation!implementation~defined bit-field}% +\indextext{allocation!implementation-defined bit-field}% Allocation of bit-fields within a class object is \impldef{allocation of bit-fields within a class object}. -\indextext{bit-field!implementation~defined alignment~of}% +\indextext{bit-field!implementation-defined alignment of}% Alignment of bit-fields is \impldef{alignment of bit-fields within a class object}. \indextext{layout!bit-field}% Bit-fields are packed into some addressable allocation unit. @@ -1338,26 +1331,26 @@ An unnamed bit-field is useful for padding to conform to externally-imposed layouts. \end{note} -\indextext{bit-field!zero~width~of}% -\indextext{bit-field!alignment~of}% +\indextext{bit-field!zero width of}% +\indextext{bit-field!alignment of}% As a special case, an unnamed bit-field with a width of zero specifies alignment of the next bit-field at an allocation unit boundary. Only when declaring an unnamed bit-field may the value of the \grammarterm{constant-expression} be equal to zero. \pnum -\indextext{bit-field!type~of}% +\indextext{bit-field!type of}% A bit-field shall not be a static member. A bit-field shall have integral or enumeration type~(\ref{basic.fundamental}). \indextext{Boolean}% A \tcode{bool} value can successfully be stored in a bit-field of any nonzero size. -\indextext{bit-field!address~of}% +\indextext{bit-field!address of}% The address-of operator \tcode{\&} shall not be applied to a bit-field, so there are no pointers to bit-fields. \indextext{restriction!bit-field}% -\indextext{restriction!address~of bit-field}% -\indextext{restriction!pointer~to bit-field}% +\indextext{restriction!address of bit-field}% +\indextext{restriction!pointer to bit-field}% A non-const reference shall not be bound to a bit-field~(\ref{dcl.init.ref}). \begin{note} @@ -1387,28 +1380,28 @@ void f() { a.b = TRUE; if (a.b == TRUE) // yields \tcode{true} - { /* ... */ } + { @\commentellip@ } } \end{codeblock} \end{example} \rSec2[class.nest]{Nested class declarations}% -\indextext{definition!nested~class}% -\indextext{class~local|see{local~class}}% -\indextext{class~nested|see{nested~class}} +\indextext{definition!nested class}% +\indextext{class local|see{local class}}% +\indextext{class nested|see{nested class}} \pnum A class can be declared within another class. A class declared within another is called a \grammarterm{nested} class. The name of a nested class is local to its enclosing class. -\indextext{nested~class!scope~of}% +\indextext{nested class!scope of}% The nested class is in the scope of its enclosing class. \begin{note} See~\ref{expr.prim} for restrictions on the use of non-static data members and non-static member functions. \end{note} -\indextext{example!nested~class}% +\indextext{example!nested class}% \begin{example} \begin{codeblock} @@ -1440,7 +1433,7 @@ \pnum Member functions and static data members of a nested class can be defined in a namespace scope enclosing the definition of their class. -\indextext{example!nested~class definition}% +\indextext{example!nested class definition}% \begin{example} \begin{codeblock} @@ -1453,7 +1446,7 @@ int enclose::inner::x = 1; -void enclose::inner::f(int i) { /* ... */ } +void enclose::inner::f(int i) { @\commentellip@ } \end{codeblock} \end{example} @@ -1462,7 +1455,7 @@ \tcode{Y} may be declared in class \tcode{X} and later defined in the definition of class \tcode{X} or be later defined in a namespace scope enclosing the definition of class \tcode{X}. -\indextext{example!nested~class forward~declaration}% +\indextext{example!nested class forward declaration}% \begin{example} \begin{codeblock} @@ -1476,7 +1469,7 @@ \end{example} \pnum -\indextext{friend~function!nested~class}% +\indextext{friend function!nested class}% Like a member function, a friend function~(\ref{class.friend}) defined within a nested class is in the lexical scope of that class; it obeys the same rules for name binding as a static member function of that @@ -1484,8 +1477,8 @@ members of an enclosing class. \rSec2[class.nested.type]{Nested type names} -\indextext{type~name!nested}% -\indextext{type~name!nested!scope of}% +\indextext{type name!nested}% +\indextext{type name!nested!scope of}% \pnum Type names obey exactly the same scope rules as other names. In @@ -1493,11 +1486,11 @@ outside their class without qualification. \begin{example} -\indextext{example!nested type~name}% +\indextext{example!nested type name}% \begin{codeblock} struct X { typedef int I; - class Y { /* ... */ }; + class Y { @\commentellip@ }; I a; }; @@ -1629,21 +1622,21 @@ struct B { A a; }; union C { B b; int k; }; int f() { - C c; // does not start lifetime of any union member - c.b.a.y[3] = 4; // OK: $S($\tcode{c.b.a.y[3]}$)$ contains \tcode{c.b} and \tcode{c.b.a.y}; - // creates objects to hold union members \tcode{c.b} and \tcode{c.b.a.y} - return c.b.a.y[3]; // OK: \tcode{c.b.a.y} refers to newly created object (see \ref{basic.life}) + C c; // does not start lifetime of any union member + c.b.a.y[3] = 4; // OK: $S($\tcode{c.b.a.y[3]}$)$ contains \tcode{c.b} and \tcode{c.b.a.y}; + // creates objects to hold union members \tcode{c.b} and \tcode{c.b.a.y} + return c.b.a.y[3]; // OK: \tcode{c.b.a.y} refers to newly created object (see \ref{basic.life}) } struct X { const int a; int b; }; union Y { X x; int k; }; void g() { - Y y = { { 1, 2 } }; // OK, \tcode{y.x} is active union member (\ref{class.mem}) + Y y = { { 1, 2 } }; // OK, \tcode{y.x} is active union member (\ref{class.mem}) int n = y.x.a; - y.k = 4; // OK: ends lifetime of \tcode{y.x}, \tcode{y.k} is active member of union - y.x.b = n; // undefined behavior: \tcode{y.x.b} modified outside its lifetime, - // $S($\tcode{y.x.b}$)$ is empty because \tcode{X}'s default constructor is deleted, - // so union member \tcode{y.x}'s lifetime does not implicitly start + y.k = 4; // OK: ends lifetime of \tcode{y.x}, \tcode{y.k} is active member of union + y.x.b = n; // undefined behavior: \tcode{y.x.b} modified outside its lifetime, + // $S($\tcode{y.x.b}$)$ is empty because \tcode{X}'s default constructor is deleted, + // so union member \tcode{y.x}'s lifetime does not implicitly start } \end{codeblock} \end{example} @@ -1704,7 +1697,7 @@ \pnum \indextext{\idxcode{union}!global anonymous}% -\indextext{scope!anonymous \tcode{union}~at namespace}% +\indextext{scope!anonymous \tcode{union} at namespace}% Anonymous unions declared in a named namespace or in the global namespace shall be declared \tcode{static}. Anonymous unions declared at block scope shall be declared with any storage class allowed for a @@ -1723,8 +1716,8 @@ \begin{codeblock} void f() { union { int aa; char* p; } obj, *ptr = &obj; - aa = 1; // error - ptr->aa = 1; // OK + aa = 1; // error + ptr->aa = 1; // OK } \end{codeblock} @@ -1734,20 +1727,19 @@ \end{example} \begin{note} Initialization of unions with no user-declared constructors is described -in~(\ref{dcl.init.aggr}). +in~\ref{dcl.init.aggr}. \end{note} \pnum \indextext{class!union-like}% -\indextext{class!variant~member~of}% +\indextext{class!variant member of}% A \defn{union-like class} is a union or a class that has an anonymous union as a direct -member. A union-like class \tcode{X} has a set of \defn{variant member}{s}. +member. A union-like class \tcode{X} has a set of \defnx{variant members}{variant member}. If \tcode{X} is a union, a non-static data member of \tcode{X} that is not an anonymous union is a variant member of \tcode{X}. In addition, a non-static data member of an anonymous union that is a member of \tcode{X} is also a variant member of \tcode{X}. At most one variant member of a union may have a default member initializer. \begin{example} - \begin{codeblock} union U { int x = 0; @@ -1756,22 +1748,21 @@ }; union { int z; - int y = 1; // error: initialization for second variant member of \tcode{U} + int y = 1; // error: initialization for second variant member of \tcode{U} }; }; \end{codeblock} - \end{example} \rSec1[class.local]{Local class declarations} -\indextext{declaration!local~class}% -\indextext{definition!local~class}% +\indextext{declaration!local class}% +\indextext{definition!local class}% \pnum A class can be declared within a function definition; such a class is called a \grammarterm{local} class. The name of a local class is local to its enclosing scope. -\indextext{local~class!scope~of}% +\indextext{local class!scope of}% The local class is in the scope of the enclosing scope, and has the same access to names outside the function as does the enclosing function. Declarations in a local class @@ -1779,7 +1770,7 @@ duration from an enclosing scope. \begin{example} -\indextext{example!local~class}% +\indextext{example!local class}% \begin{codeblock} int x; void f() { @@ -1805,20 +1796,20 @@ \pnum An enclosing function has no special access to members of the local class; it obeys the usual access rules (Clause~\ref{class.access}). -\indextext{member function!local~class}% +\indextext{member function!local class}% Member functions of a local class shall be defined within their class definition, if they are defined at all. \pnum -\indextext{nested~class!local~class}% +\indextext{nested class!local class}% If class \tcode{X} is a local class a nested class \tcode{Y} may be declared in class \tcode{X} and later defined in the definition of class \tcode{X} or be later defined in the same scope as the definition of class \tcode{X}. -\indextext{restriction!local~class}% +\indextext{restriction!local class}% A class nested within a local class is a local class. \pnum -\indextext{restriction!static member local~class}% +\indextext{restriction!static member local class}% A local class shall not have static data members. diff --git a/source/compatibility.tex b/source/compatibility.tex index 00ac9c389d..0570090df6 100644 --- a/source/compatibility.tex +++ b/source/compatibility.tex @@ -4,7 +4,7 @@ \rSec1[diff.iso]{\Cpp and ISO C} \pnum -\indextext{summary!compatibility~with ISO C}% +\indextext{summary!compatibility with ISO C}% This subclause lists the differences between \Cpp and ISO C, by the chapters of this document. @@ -162,10 +162,10 @@ \howwide Seldom. -\ref{basic.start} +\ref{basic.start.main} \change The \tcode{main} function cannot be called recursively and cannot have its address taken. \rationale -The main function may require special actions. +The \tcode{main} function may require special actions. \effect Deletion of semantically well-defined feature. \difficulty @@ -275,9 +275,8 @@ Seldom. \ref{expr.cond}, \ref{expr.ass}, \ref{expr.comma} - \indextext{conversion!lvalue-to-rvalue}% -\indextext{rvalue!lvalue conversion~to}% +\indextext{rvalue!lvalue conversion to}% \indextext{lvalue}% \change The result of a conditional expression, an assignment expression, or a comma expression may be an lvalue. \rationale @@ -398,8 +397,8 @@ Example: \begin{codeblock} -typedef struct name1 { /*...*/ } name1; // valid C and \Cpp -struct name { /*...*/ }; +typedef struct name1 { @\commentellip@ } name1; // valid C and \Cpp +struct name { @\commentellip@ }; typedef int name; // valid C, invalid \Cpp \end{codeblock} @@ -410,7 +409,7 @@ Example: \begin{codeblock} -class name { /*...*/ }; +class name { @\commentellip@ }; name i; // \tcode{i} has type \tcode{class name} \end{codeblock} @@ -452,7 +451,7 @@ void f(const parm); void f(const int parm); const n = 3; const int n = 3; main() int main() - /* ... */ /* ... */ + @\commentellip@ @\commentellip@ \end{codeblock} \rationale @@ -518,7 +517,7 @@ enum e { A }; sizeof(A) == sizeof(int) // in C sizeof(A) == sizeof(e) // in \Cpp -/* @\textit{\textrm{and \tcode{sizeof(int)} is not necessarily equal to \tcode{sizeof(e)}}}@ */ +/* and @sizeof(int)@ is not necessarily equal to @sizeof(e)@ */ \end{codeblock} \rationale @@ -591,7 +590,7 @@ \ref{dcl.fct.def} \change In \Cpp, the syntax for function definition excludes the ``old-style'' C function. -In C, ``old-style'' syntax is allowed, but deprecated as ``obsolescent.'' +In C, ``old-style'' syntax is allowed, but deprecated as ``obsolescent''. \rationale Prototypes are essential to type safety. \effect @@ -614,7 +613,7 @@ \end{codeblock} \rationale When these non-terminated arrays are manipulated by standard -string routines, there is potential for major catastrophe. +string functions, there is potential for major catastrophe. \effect Deletion of semantically well-defined feature. \difficulty @@ -639,8 +638,8 @@ int x[99]; void f() { struct x { int a; }; - sizeof(x); /* @\textit{\textrm{size of the array in C}}@ */ - /* @\textit{\textrm{size of the struct in \Cpp}}@ */ + sizeof(x); /* size of the array in C */ + /* size of the struct in @\textit{\textrm{\Cpp}}@ */ } \end{codeblock} \rationale @@ -668,7 +667,7 @@ \ref{class.bit} \change -\indextext{bit-field!implementation-defined sign~of}% +\indextext{bit-field!implementation-defined sign of}% Bit-fields of type plain \tcode{int} are signed. \rationale Leaving the choice of signedness to implementations could lead to @@ -690,7 +689,7 @@ \begin{codeblock} struct X { - struct Y { /* ... */ } y; + struct Y { @\commentellip@ } y; }; struct Y yy; // valid C, invalid \Cpp \end{codeblock} @@ -716,7 +715,7 @@ \begin{codeblock} struct Y; // \tcode{struct Y} and \tcode{struct X} are at the same scope struct X { - struct Y { /* ... */ } y; + struct Y { @\commentellip@ } y; }; \end{codeblock} @@ -822,7 +821,7 @@ \rSec1[diff.cpp03]{\Cpp and ISO \CppIII} \pnum -\indextext{summary!compatibility~with ISO \CppIII}% +\indextext{summary!compatibility with ISO \CppIII}% This subclause lists the differences between \Cpp and ISO \CppIII (ISO/IEC 14882:2003, \doccite{Programming Languages --- \Cpp}), by the chapters of this document. @@ -968,8 +967,8 @@ \rationale Clarification of destructor requirements. \effect Valid \CppIII code may execute differently in this International Standard. In -particular, destructors that throw exceptions will call \tcode{std::terminate()} -(without calling \tcode{std::unexpected()}) if their exception specification is +particular, destructors that throw exceptions will call \tcode{std::terminate} +(without calling \tcode{std::unexpected}) if their exception specification is non-throwing. \rSec2[diff.cpp03.temp]{Clause \ref{temp}: templates} @@ -990,9 +989,9 @@ Change to semantics of well-defined expression. A valid \CppIII expression containing a right angle bracket (``\tcode{>}'') followed immediately by another right angle bracket may now be treated as closing two templates. -For example, the following code is valid in \CppIII because ``\tcode{\shr}'' +For example, the following code is valid in \CppIII because ``\tcode{>>}'' is a right-shift operator, but invalid in this International Standard because -``\tcode{\shr}'' closes two templates. +``\tcode{>>}'' closes two templates. \begin{codeblock} template struct X { }; @@ -1279,7 +1278,7 @@ binary representation of the required template specializations of \tcode{std::complex} may not be compatible with this International Standard. -\rSec2[diff.cpp03.input.output]{Clause \ref{input.output}: Input/output library} +\rSec2[diff.cpp03.input.output]{Clause \ref{input.output}: input/output library} \ref{istream::sentry}, \ref{ostream::sentry}, @@ -1331,7 +1330,7 @@ \rSec1[diff.cpp11]{\Cpp and ISO \CppXI} \pnum -\indextext{summary!compatibility~with ISO \CppXI}% +\indextext{summary!compatibility with ISO \CppXI}% This subclause lists the differences between \Cpp and ISO \CppXI (ISO/IEC 14882:2011, \doccite{Programming Languages --- \Cpp}), by the chapters of this document. @@ -1470,7 +1469,7 @@ \rSec1[diff.cpp14]{\Cpp and ISO \CppXIV} \pnum -\indextext{summary!compatibility~with ISO \CppXIV}% +\indextext{summary!compatibility with ISO \CppXIV}% This subclause lists the differences between \Cpp and ISO \CppXIV (ISO/IEC 14882:2014, \doccite{Programming Languages --- \Cpp}), by the chapters of this document. @@ -1501,7 +1500,7 @@ \begin{codeblock} #define F(a) b ## a -int b0p = F(0p+0); // ill-formed; equivalent to ``\tcode{int b0p = b0p + 0;}\!'' in C++ 2014 +int b0p = F(0p+0); // ill-formed; equivalent to ``\tcode{int b0p = b0p + 0;}\!'' in \CppXIV \end{codeblock} \rSec2[diff.cpp14.expr]{Clause \ref{expr}: expressions} @@ -1667,7 +1666,7 @@ Valid \CppXIV code that uses such a top-level namespace, e.g., \tcode{std2}, may be invalid in this International Standard. -\rSec2[diff.cpp14.utilities]{Clause \ref{utilities}: General utilities library} +\rSec2[diff.cpp14.utilities]{Clause \ref{utilities}: general utilities library} \ref{func.wrap} \change Constructors taking allocators removed. @@ -1778,8 +1777,8 @@ nor are the C headers themselves part of \Cpp. \pnum -The headers \tcode{}\indextext{\idxhdr{ccomplex}}~(\ref{ccomplex.syn}) -and \tcode{}\indextext{\idxhdr{ctgmath}}~(\ref{ctgmath.syn}), as well +The headers \tcode{}\indextext{\idxhdr{ccomplex}} (\ref{ccomplex.syn}) +and \tcode{}\indextext{\idxhdr{ctgmath}} (\ref{ctgmath.syn}), as well as their corresponding C headers \tcode{}\indextext{\idxhdr{complex.h}} and \tcode{}\indextext{\idxhdr{tgmath.h}}, do not contain any of the content from the C standard library and instead merely include other headers diff --git a/source/config.tex b/source/config.tex index e56d161432..c3e390cbc7 100644 --- a/source/config.tex +++ b/source/config.tex @@ -1,8 +1,8 @@ %!TEX root = std.tex %%-------------------------------------------------- %% Version numbers -\newcommand{\docno}{N4618} -\newcommand{\prevdocno}{N4606} +\newcommand{\docno}{N4640} +\newcommand{\prevdocno}{N4618} \newcommand{\cppver}{201402L} %% Release date diff --git a/source/containers.tex b/source/containers.tex index 3f72105dd4..ac57a3f52b 100644 --- a/source/containers.tex +++ b/source/containers.tex @@ -56,11 +56,10 @@ \pnum For the components affected by this subclause that declare an \tcode{allocator_type}, -objects stored in these components shall be constructed using the -\tcode{allocator_traits::rebind_traits::construct} function -and destroyed using the -\tcode{allocator_traits::rebind_traits::destroy} -function~(\ref{allocator.traits.members}), +objects stored in these components shall be constructed using the function +\tcode{allocator_traits::rebind_traits::\brk{}construct} +and destroyed using the function +\tcode{allocator_traits::rebind_traits::\brk{}destroy}~(\ref{allocator.traits.members}), where \tcode{U} is either \tcode{allocator_type::value_type} or an internal type used by the container. These functions are called only for the @@ -143,20 +142,20 @@ \tcode{X u;} & & & - post: \tcode{u.empty()} & + \postconditions \tcode{u.empty()} & constant \\ \rowsep \tcode{X()} & & & - post: \tcode{X().empty()} & + \postconditions \tcode{X().empty()} & constant \\ \rowsep \tcode{X(a)} & & & \requires \tcode{T} is \tcode{CopyInsertable} - into \tcode{X} (see below).\br post: \tcode{a == X(a)}. & + into \tcode{X} (see below).\br \postconditions \tcode{a == X(a)}. & linear \\ \rowsep \tcode{X u(a);}\br @@ -165,14 +164,14 @@ & \requires \tcode{T} is \tcode{CopyInsertable} into \tcode{X} (see below).\br - post: \tcode{u == a} & + \postconditions \tcode{u == a} & linear \\ \rowsep \tcode{X u(rv);}\br \tcode{X u = rv;} & & & - post: \tcode{u} shall be equal to the value that \tcode{rv} had before this construction + \postconditions \tcode{u} shall be equal to the value that \tcode{rv} had before this construction & (Note B) \\ \rowsep @@ -245,7 +244,7 @@ \tcode{r = a} & \tcode{X\&} & & - post: \tcode{r == a}. & + \postconditions \tcode{r == a}. & linear \\ \rowsep \tcode{a.size()} & @@ -272,13 +271,13 @@ \end{libreqtab5} -Notes: the algorithm -\tcode{equal()} -is defined in Clause~\ref{algorithms}. Those entries marked ``(Note A)'' or ``(Note B)'' have linear complexity for \tcode{array} and have constant complexity for all other standard containers. - +\begin{note} +The algorithm \tcode{equal()} is defined in Clause~\ref{algorithms}. +\end{note} + \pnum The member function \tcode{size()} returns the number of elements in the container. The number of elements is defined by the rules of @@ -488,7 +487,7 @@ \tcode{a < b} & convertible to \tcode{bool} & \tcode{lexicographical_compare( a.begin(), a.end(), b.begin(), b.end())} & - pre: \tcode{<} is defined for values of \tcode{T}. \tcode{<} is a total ordering relationship. & + \requires \tcode{<} is defined for values of \tcode{T}. \tcode{<} is a total ordering relationship. & linear \\ \rowsep \tcode{a > b} & @@ -515,7 +514,7 @@ \end{note} \pnum -All of the containers defined in this Clause and in~(\ref{basic.string}) except \tcode{array} +All of the containers defined in this Clause and in~\ref{basic.string} except \tcode{array} meet the additional requirements of an allocator-aware container, as described in Table~\ref{tab:containers.allocatoraware}. @@ -639,13 +638,13 @@ \tcode{X u;} & & \requires\ \tcode{A} is \tcode{DefaultConstructible}.\br - post: \tcode{u.empty()} returns \tcode{true}, + \postconditions \tcode{u.empty()} returns \tcode{true}, \tcode{u.get_allocator() == A()} & constant \\ \rowsep \tcode{X(m)} & & -post: \tcode{u.empty()} returns \tcode{true}, & +\postconditions \tcode{u.empty()} returns \tcode{true}, & constant \\ \tcode{X u(m);} & & @@ -656,14 +655,14 @@ \tcode{X u(t, m);} & & \requires\ \tcode{T} is \tcode{CopyInsertable} into \tcode{X}.\br -post: \tcode{u == t}, \tcode{u.get_allocator() == m} & +\postconditions \tcode{u == t}, \tcode{u.get_allocator() == m} & linear \\ \rowsep \tcode{X(rv)}\br \tcode{X u(rv);} & & - post: \tcode{u} shall have the same elements as \tcode{rv} had before this + \postconditions \tcode{u} shall have the same elements as \tcode{rv} had before this construction; the value of \tcode{u.get_allocator()} shall be the same as the value of \tcode{rv.get_allocator()} before this construction. & constant \\ \rowsep @@ -673,7 +672,7 @@ & \requires\ \tcode{T} is \tcode{MoveInsertable} into \tcode{X}.\br - post: \tcode{u} shall have the same elements, + \postconditions \tcode{u} shall have the same elements, or copies of the elements, that \tcode{rv} had before this construction, \tcode{u.get_allocator() == m} & constant if \tcode{m ==} \tcode{rv.get_allocator()}, otherwise linear \\ \rowsep @@ -683,7 +682,7 @@ \requires\ \tcode{T} is \tcode{CopyInsertable} into \tcode{X} and \tcode{CopyAssignable}.\br - post: \tcode{a == t} & + \postconditions \tcode{a == t} & linear \\ \rowsep \tcode{a = rv} & @@ -696,7 +695,7 @@ \tcode{MoveInsertable} into \tcode{X} and \tcode{MoveAssignable}. All existing elements of \tcode{a} are either move assigned to or destroyed.\br - post: \tcode{a} shall be equal to the value that \tcode{rv} had before + \postconditions \tcode{a} shall be equal to the value that \tcode{rv} had before this assignment. & linear \\ \rowsep @@ -717,7 +716,7 @@ associative or unordered associative containers, \tcode{operator[]}. \pnum -Notwithstanding~(\ref{res.on.data.races}), implementations are required to avoid data +Notwithstanding~\ref{res.on.data.races}, implementations are required to avoid data races when the contents of the contained object in different elements in the same container, excepting \tcode{vector}, are modified concurrently. @@ -806,7 +805,7 @@ & \requires\ \tcode{T} shall be \tcode{CopyInsertable} into \tcode{X}.\br - post: \tcode{distance(begin(), end()) == n}\br + \postconditions \tcode{distance(begin(), end()) == n}\br Constructs a sequence container with \tcode{n} copies of \tcode{t} \\ \rowsep \tcode{X(i, j)}\br @@ -818,7 +817,7 @@ shall also be \tcode{MoveInsertable} into \tcode{X}. Each iterator in the range \range{i}{j} shall be dereferenced exactly once.\br - post: \tcode{distance(begin(), end()) ==} + \postconditions \tcode{distance(begin(), end()) ==} \tcode{distance(i, j)}\br Constructs a sequence container equal to the range \tcode{[i, j)} \\ \rowsep @@ -872,7 +871,7 @@ \tcode{MoveInsertable} into \tcode{X}, \tcode{MoveConstructible}, \tcode{MoveAssignable}, and swappable~(\ref{swappable.requirements}). Each iterator in the range \range{i}{j} shall be dereferenced exactly once.\br - pre: \tcode{i} and \tcode{j} are not iterators into \tcode{a}.\br + \requires \tcode{i} and \tcode{j} are not iterators into \tcode{a}.\br Inserts copies of elements in \tcode{[i, j)} before \tcode{p} \\ \rowsep \tcode{a.insert(p, il)} & @@ -895,7 +894,7 @@ \tcode{void} & Destroys all elements in \tcode{a}. Invalidates all references, pointers, and iterators referring to the elements of \tcode{a} and may invalidate the past-the-end iterator.\br - post: \tcode{a.empty()} returns \tcode{true}.\br + \postconditions \tcode{a.empty()} returns \tcode{true}.\br \complexity Linear. \\ \rowsep \tcode{a.assign(i,j)} & @@ -906,7 +905,7 @@ shall also be \tcode{MoveInsertable} into \tcode{X}.\br Each iterator in the range \range{i}{j} shall be dereferenced exactly once.\br - pre: \tcode{i}, \tcode{j} are not iterators into \tcode{a}.\br + \requires \tcode{i}, \tcode{j} are not iterators into \tcode{a}.\br Replaces elements in \tcode{a} with a copy of \tcode{[i, j)}.\br Invalidates all references, pointers and iterators referring to the elements of \tcode{a}. @@ -922,7 +921,7 @@ \requires\ \tcode{T} shall be \tcode{CopyInsertable} into \tcode{X} and \tcode{CopyAssignable}.\br - pre: \tcode{t} is not a reference into \tcode{a}.\br + \requires \tcode{t} is not a reference into \tcode{a}.\br Replaces elements in \tcode{a} with \tcode{n} copies of \tcode{t}.\br Invalidates all references, pointers and iterators referring to the elements of \tcode{a}. @@ -970,7 +969,7 @@ \pnum The iterator returned by -\tcode{a.erase(q1,q2)} +\tcode{a.erase(q1, q2)} points to the element pointed to by \tcode{q2} prior to any elements being erased. @@ -980,33 +979,30 @@ \pnum For every sequence container defined in this Clause and in Clause~\ref{strings}: - \begin{itemize} \item If the constructor - \begin{codeblock} template -X(InputIterator first, InputIterator last, - const allocator_type& alloc = allocator_type()); + X(InputIterator first, InputIterator last, + const allocator_type& alloc = allocator_type()); \end{codeblock} - is called with a type \tcode{InputIterator} that does not qualify as an input iterator, then the constructor shall not participate in overload resolution. \item If the member functions of the forms: - \begin{codeblock} -template // such as insert() - rt fx1(const_iterator p, InputIterator first, InputIterator last); +template + @\placeholdernc{return-type}@ @\placeholdernc{F}@(const_iterator p, + InputIterator first, InputIterator last); // such as \tcode{insert} -template // such as append(), assign() - rt fx2(InputIterator first, InputIterator last); +template + @\placeholdernc{return-type}@ @\placeholdernc{F}@(InputIterator first, InputIterator last); // such as \tcode{append}, \tcode{assign} -template // such as replace() - rt fx3(const_iterator i1, const_iterator i2, InputIterator first, InputIterator last); +template + @\placeholdernc{return-type}@ @\placeholdernc{F}@(const_iterator i1, const_iterator i2, + InputIterator first, InputIterator last); // such as \tcode{replace} \end{codeblock} - are called with a type \tcode{InputIterator} that does not qualify as an input iterator, then these functions shall not participate in overload resolution. @@ -1230,36 +1226,42 @@ \begin{codeblock} template<@\unspecnc@> -class @\textit{node_handle}@ { -public: - // These type declarations are described in Tables \ref{tab:containers.associative.requirements} and \ref{tab:HashRequirements} - using value_type = @\seebelownc{}@; // Not present for map containers - using key_type = @\seebelownc{}@; // Not present for set containers - using mapped_type = @\seebelownc{}@; // Not present for set containers - using allocator_type = @\seebelownc{}@; - -private: - using container_node_type = @\unspecnc@; - using ator_traits = allocator_traits; - typename ator_traits::rebind_traits::pointer ptr_; - optional alloc_; - -public: - constexpr @\textit{node_handle}@() noexcept : ptr_(), alloc_() {} - ~@\textit{node_handle}@(); - @\textit{node_handle}@(@\textit{node_handle}@&&) noexcept; - @\textit{node_handle}@& operator=(@\textit{node_handle}@&&); - value_type& value() const; // Not present for map containers - key_type& key() const; // Not present for set containers - mapped_type& mapped() const; // Not present for set containers - allocator_type get_allocator() const; - explicit operator bool() const noexcept; - bool empty() const noexcept; - void swap(@\textit{node_handle}@&) - noexcept(ator_traits::propagate_on_container_swap::value || - ator_traits::is_always_equal::value); - friend void swap(@\textit{node_handle}@& x, @\textit{node_handle}@& y) noexcept(noexcept(x.swap(y))) - { x.swap(y); } + class @\textit{node_handle}@ { + public: + // These type declarations are described in Tables \ref{tab:containers.associative.requirements} and \ref{tab:HashRequirements}. + using value_type = @\seebelownc{}@; // not present for map containers + using key_type = @\seebelownc{}@; // not present for set containers + using mapped_type = @\seebelownc{}@; // not present for set containers + using allocator_type = @\seebelownc{}@; + + private: + using container_node_type = @\unspecnc@; + using ator_traits = allocator_traits; + + typename ator_traits::rebind_traits::pointer ptr_; + optional alloc_; + + public: + constexpr @\textit{node_handle}@() noexcept : ptr_(), alloc_() {} + ~@\textit{node_handle}@(); + @\textit{node_handle}@(@\textit{node_handle}@&&) noexcept; + @\textit{node_handle}@& operator=(@\textit{node_handle}@&&); + + value_type& value() const; // not present for map containers + key_type& key() const; // not present for set containers + mapped_type& mapped() const; // not present for set containers + + allocator_type get_allocator() const; + explicit operator bool() const noexcept; + bool empty() const noexcept; + + void swap(@\textit{node_handle}@&) + noexcept(ator_traits::propagate_on_container_swap::value || + ator_traits::is_always_equal::value); + + friend void swap(@\textit{node_handle}@& x, @\textit{node_handle}@& y) noexcept(noexcept(x.swap(y))) { + x.swap(y); + } }; \end{codeblock} @@ -1345,7 +1347,7 @@ \pnum \returns A non-const reference to the \tcode{key_type} member of the -\tcode{value_type} subobject in the \tcode{container_node_type} object +\tcode{value_type} subobject in the \tcode{contain\-er_node_type} object pointed to by \tcode{ptr_}. \pnum @@ -1655,7 +1657,7 @@ \requires\ \tcode{value_type} is \tcode{EmplaceConstructible} into \tcode{X} from \tcode{*i}.\br \effects\ Constructs an empty container and inserts elements from the range \tcode{[i, j)} into it; uses \tcode{c} as a comparison object. & - $N \log N$ in general ($N$ has the value \tcode{distance(i, j)}); + $N \log N$ in general, where $N$ has the value \tcode{distance(i, j)}; linear if \tcode{[i, j)} is sorted with \tcode{value_comp()} \\ \rowsep \tcode{X(i,j)}\br\tcode{X~u(i,j);} & @@ -1667,13 +1669,13 @@ \tcode{X(il)} & & - Same as \tcode{X(il.begin(), il.end())}. & - Same as \tcode{X(il.begin(), il.end())}. \\ \rowsep + same as \tcode{X(il.begin(), il.end())} & + same as \tcode{X(il.begin(), il.end())} \\ \rowsep \tcode{X(il,c)} & & - Same as \tcode{X(il.begin(), il.end(), c)}. & - Same as \tcode{X(il.begin(), il.end(), c)}. \\ \rowsep + same as \tcode{X(il.begin(), il.end(), c)} & + same as \tcode{X(il.begin(), il.end(), c)} \\ \rowsep \tcode{a = il} & \tcode{X\&} & @@ -1682,8 +1684,8 @@ and \tcode{CopyAssignable}.\br \effects Assigns the range \range{il.begin()}{il.end()} into \tcode{a}. All existing elements of \tcode{a} are either assigned to or destroyed. & - $N \log N$ in general (where $N$ has the value \tcode{il.size() + a.size()}); - linear if \range{il.begin()}{il.end()} is sorted with \tcode{value_comp()}. + $N \log N$ in general, where $N$ has the value \tcode{il.size() + a.size()}; + linear if \range{il.begin()}{il.end()} is sorted with \tcode{value_comp()} \\ \rowsep \tcode{b.key_comp()} & @@ -1772,26 +1774,26 @@ \tcode{i, j)} & \tcode{void} & \requires\ \tcode{value_type} shall be \tcode{EmplaceConstructible} into \tcode{X} from \tcode{*i}.\br - pre: \tcode{i}, \tcode{j} are not iterators into \tcode{a}. + \requires \tcode{i}, \tcode{j} are not iterators into \tcode{a}. inserts each element from the range \range{i}{j} if and only if there is no element with key equivalent to the key of that element in containers with unique keys; always inserts that element in containers with equivalent keys. & - $N\log (\tcode{a.size()} + N)$ ($N$ has the value \tcode{distance(i, j)}) \\ \rowsep + $N\log (\tcode{a.size()} + N)$, where $N$ has the value \tcode{distance(i, j)} \\ \rowsep \tcode{a.insert(il)} & \tcode{void} & - Equivalent to \tcode{a.insert(il.begin(), il.end())}. & + equivalent to \tcode{a.insert(il.begin(), il.end())} & \\ \rowsep \tcode{a_uniq.}\br \tcode{insert(nh)} & \tcode{insert_return_type} & - pre: \tcode{nh} is empty or + \requires \tcode{nh} is empty or \tcode{a_uniq.get_allocator() == nh.get_allocator()}.\br \effects{} If \tcode{nh} is empty, has no effect. Otherwise, inserts the element owned by \tcode{nh} if and only if there is no element in the container with a key equivalent to \tcode{nh.key()}.\br - post: If \tcode{nh} is empty, \tcode{inserted} is \tcode{false}, + \postconditions If \tcode{nh} is empty, \tcode{inserted} is \tcode{false}, \tcode{position} is \tcode{end()}, and \tcode{node} is empty. Otherwise if the insertion took place, \tcode{inserted} is \tcode{true}, \tcode{position} points to the inserted element, and \tcode{node} is empty; @@ -1803,19 +1805,19 @@ \tcode{a_eq.}\br \tcode{insert(nh)} & \tcode{iterator} & - pre: \tcode{nh} is empty or + \requires \tcode{nh} is empty or \tcode{a_eq.get_allocator() == nh.get_allocator()}.\br \effects{} If \tcode{nh} is empty, has no effect and returns \tcode{a_eq.end()}. Otherwise, inserts the element owned by \tcode{nh} and returns an iterator pointing to the newly inserted element. If a range containing elements with keys equivalent to \tcode{nh.key()} exists in \tcode{a_eq}, the element is inserted at the end of that range.\br - post: \tcode{nh} is empty. & + \postconditions \tcode{nh} is empty. & logarithmic \\ \rowsep \tcode{a.insert(p, nh)} & \tcode{iterator} & - pre: \tcode{nh} is empty or + \requires \tcode{nh} is empty or \tcode{a.get_allocator() == nh.get_allocator()}.\br \effects{} If \tcode{nh} is empty, has no effect and returns \tcode{a.end()}. Otherwise, inserts the element owned by \tcode{nh} if and only if there @@ -1824,36 +1826,36 @@ with equivalent keys. Always returns the iterator pointing to the element with key equivalent to \tcode{nh.key()}. The element is inserted as close as possible to the position just prior to \tcode{p}.\br - post: \tcode{nh} is empty if insertion succeeds, unchanged if insertion fails. & + \postconditions \tcode{nh} is empty if insertion succeeds, unchanged if insertion fails. & logarithmic in general, but amortized constant if the element is inserted right before \tcode{p}. \\ \rowsep \tcode{a.extract(k)} & \tcode{node_type} & - Removes the first element in the container with key equivalent to \tcode{k}. + removes the first element in the container with key equivalent to \tcode{k}. Returns a \tcode{node_type} owning the element if found, otherwise an empty \tcode{node_type}. & $\log (\tcode{a.size()})$ \\ \rowsep \tcode{a.extract(q)} & \tcode{node_type} & - Removes the element pointed to by \tcode{q}. + removes the element pointed to by \tcode{q}. Returns a \tcode{node_type} owning that element. & amortized constant \\ \rowsep \tcode{a.merge(a2)} & \tcode{void} & - pre: \tcode{a.get_allocator() == a2.get_allocator()}.\br + \requires \tcode{a.get_allocator() == a2.get_allocator()}.\br Attempts to extract each element in \tcode{a2} and insert it into \tcode{a} using the comparison object of \tcode{a}. In containers with unique keys, if there is an element in \tcode{a} with key equivalent to the key of an element from \tcode{a2}, then that element is not extracted from \tcode{a2}.\br - post: Pointers and references to the transferred elements of \tcode{a2} + \postconditions Pointers and references to the transferred elements of \tcode{a2} refer to those same elements but as members of \tcode{a}. Iterators referring to the transferred elements will continue to refer to their elements, but they now behave as iterators into \tcode{a}, not into \tcode{a2}.\br \throws{} Nothing unless the comparison object throws. & - $N \log(\tcode{a.size()+} N)$ where $N$ has the value \tcode{a2.size()}. \\ \rowsep + $N \log(\tcode{a.size()+} N)$, where $N$ has the value \tcode{a2.size()}. \\ \rowsep \tcode{a.erase(k)} & \tcode{size_type} & @@ -1881,12 +1883,12 @@ erases all the elements in the range \range{q1}{q2}. Returns an iterator pointing to the element pointed to by \tcode{q2} prior to any elements being erased. If no such element exists, \tcode{a.end()} is returned. & - $\log(\tcode{a.size()}) + N$ where $N$ has the value \tcode{distance(q1, q2)}. \\ \rowsep + $\log(\tcode{a.size()}) + N$, where $N$ has the value \tcode{distance(q1, q2)}. \\ \rowsep \tcode{a.clear()} & \tcode{void} & \tcode{a.erase(a.begin(),a.end())}\br - post: \tcode{a.empty()} returns \tcode{true} & + \postconditions \tcode{a.empty()} returns \tcode{true}. & linear in \tcode{a.size()}. \\ \rowsep \tcode{b.find(k)} & @@ -2035,7 +2037,6 @@ that exception is thrown by the swap of the container's \tcode{Compare} object (if any). -\indextext{unordered associative containers|(} \indextext{associative containers!unordered|see{unordered associative containers}} \indextext{hash tables|see{unordered associative containers}} \rSec2[unord.req]{Unordered associative containers} @@ -2050,7 +2051,7 @@ \tcode{unordered_multimap}. \pnum -\indextext{unordered associative containers!lack of comparison operators}% +\indextext{unordered associative containers!lack of comparison functions}% \indextext{unordered associative containers!requirements}% \indextext{requirements!container!not required for unordered associated containers}% Unordered associative containers conform to the requirements for @@ -2104,7 +2105,7 @@ elements with equivalent keys are adjacent to each other in the iteration order of the container. Thus, although the absolute order of elements in an unordered container is not specified, its elements are -grouped into \defn{equivalent-key group}{s} such that all elements of each +grouped into \defnx{equivalent-key groups}{equivalent-key group} such that all elements of each group have equivalent keys. Mutating operations on unordered containers shall preserve the relative order of elements within each equivalent-key group unless otherwise specified. @@ -2184,13 +2185,13 @@ {Unordered associative container requirements (in addition to container)} {tab:HashRequirements} \\ \topline -\lhdr{Expression} & \chdr{Return type} -& \chdr{Assertion/note pre-/post-condition} -& \rhdr{Complexity} \\ \capsep +\lhdr{Expression} & \chdr{Return type} & \chdr{Assertion/note} & \rhdr{Complexity} \\ + & & \chdr{pre-/post-condition} & \\ \capsep \endfirsthead \continuedcaption\\ \hline -\lhdr{Expression} & \chdr{Return type} & \chdr{Assertion/note pre-/post-condition} & \rhdr{Complexity} \\ \capsep +\lhdr{Expression} & \chdr{Return type} & \chdr{Assertion/note} & \rhdr{Complexity} \\ + & & \chdr{pre-/post-condition} & \\ \capsep \endhead %% \tcode{X::key_type} & @@ -2489,7 +2490,7 @@ \tcode{a.insert(i, j)} & \tcode{void} & \requires\ \tcode{value_type} shall be \tcode{EmplaceConstructible} into \tcode{X} from \tcode{*i}.\br - Pre: \tcode{i} and \tcode{j} are not iterators in \tcode{a}. + \requires \tcode{i} and \tcode{j} are not iterators in \tcode{a}. Equivalent to \tcode{a.insert(t)} for each element in \tcode{[i,j)}.% \indextext{unordered associative containers!\idxcode{insert}}% \indextext{\idxcode{insert}!unordered associative containers}% @@ -2506,12 +2507,12 @@ \tcode{a_uniq.}\br \tcode{insert(nh)} & \tcode{insert_return_type} & - Pre: \tcode{nh} is empty or + \requires \tcode{nh} is empty or \tcode{a_uniq.get_allocator() == nh.get_allocator()}.\br \effects{} If \tcode{nh} is empty, has no effect. Otherwise, inserts the element owned by \tcode{nh} if and only if there is no element in the container with a key equivalent to \tcode{nh.key()}.\br - post: If \tcode{nh} is empty, \tcode{inserted} is \tcode{false}, + \postconditions If \tcode{nh} is empty, \tcode{inserted} is \tcode{false}, \tcode{position} is \tcode{end()}, and \tcode{node} is empty. Otherwise if the insertion took place, \tcode{inserted} is \tcode{true}, \tcode{position} points to the inserted element, and \tcode{node} is empty; @@ -2523,17 +2524,17 @@ \tcode{a_eq.}\br \tcode{insert(nh)} & \tcode{iterator} & - Pre: \tcode{nh} is empty or + \requires \tcode{nh} is empty or \tcode{a_eq.get_allocator() == nh.get_allocator()}.\br \effects{} If \tcode{nh} is empty, has no effect and returns \tcode{a_eq.end()}. Otherwise, inserts the element owned by \tcode{nh} and returns an iterator pointing to the newly inserted element.\br - Post: \tcode{nh} is empty. & + \postconditions \tcode{nh} is empty. & Average case \bigoh{1}, worst case \bigoh{\tcode{a_eq.size()}}. \\ \rowsep % \tcode{a.insert(q, nh)} & \tcode{iterator} & - Pre: \tcode{nh} is empty or + \requires \tcode{nh} is empty or \tcode{a.get_allocator() == nh.get_allocator()}.\br \effects{} If \tcode{nh} is empty, has no effect and returns \tcode{a.end()}. Otherwise, inserts the element owned by \tcode{nh} if and only if there @@ -2543,7 +2544,7 @@ with key equivalent to \tcode{nh.key()}. The iterator \tcode{q} is a hint pointing to where the search should start. Implementations are permitted to ignore the hint.\br - Post: \tcode{nh} is empty if insertion succeeds, unchanged if insertion fails. & + \postconditions \tcode{nh} is empty if insertion succeeds, unchanged if insertion fails. & Average case \bigoh{1}, worst case \bigoh{\tcode{a.size()}}. \\ \rowsep % \tcode{a.extract(k)} & @@ -2561,13 +2562,13 @@ % \tcode{a.merge(a2)} & \tcode{void} & - Pre: \tcode{a.get_allocator() == a2.get_allocator()}.\br + \requires \tcode{a.get_allocator() == a2.get_allocator()}.\br Attempts to extract each element in \tcode{a2} and insert it into \tcode{a} using the hash function and key equality predicate of \tcode{a}. In containers with unique keys, if there is an element in \tcode{a} with key equivalent to the key of an element from \tcode{a2}, then that element is not extracted from \tcode{a2}.\par - Post: Pointers and references to the transferred elements of \tcode{a2} + \postconditions Pointers and references to the transferred elements of \tcode{a2} refer to those same elements but as members of \tcode{a}. Iterators referring to the transferred elements and all iterators referring to \tcode{a} will be invalidated, but iterators to elements remaining in \tcode{a2} will @@ -2616,7 +2617,7 @@ \tcode{a.clear()} & \tcode{void} & Erases all elements in the container. - Post: \tcode{a.empty()} returns \tcode{true}% + \postconditions \tcode{a.empty()} returns \tcode{true}% \indextext{unordered associative containers!\idxcode{clear}}% \indextext{\idxcode{clear}!unordered associative containers}% & Linear in \tcode{a.size()}. @@ -2671,10 +2672,10 @@ \tcode{b.bucket(k)} & \tcode{size_type} & - Pre: \tcode{b.bucket_count() > 0}.\br + \requires \tcode{b.bucket_count() > 0}.\br Returns the index of the bucket in which elements with keys equivalent to \tcode{k} would be found, if any such element existed. - Post: the return value shall be in the range \tcode{[0, b.bucket_count())}.% + \postconditions the return value shall be in the range \tcode{[0, b.bucket_count())}.% \indextext{unordered associative containers!\idxcode{bucket}}% \indextext{\idxcode{bucket}!unordered associative containers}% & Constant @@ -2682,7 +2683,7 @@ % \tcode{b.bucket_size(n)} & \tcode{size_type} -& Pre: \tcode{n} shall be in the range \tcode{[0, b.bucket_count())}. +& \requires \tcode{n} shall be in the range \tcode{[0, b.bucket_count())}. Returns the number of elements in the $\texttt{n}^{\textrm{ th}}$ bucket.% \indextext{unordered associative containers!\idxcode{bucket_size}}% \indextext{\idxcode{bucket_size}!unordered associative containers}% @@ -2692,7 +2693,7 @@ \tcode{b.begin(n)} & \tcode{local_iterator}; \br \tcode{const_local_iterator} for const \tcode{b}. -& Pre: \tcode{n} shall be in the range \tcode{[0, b.bucket_count())}. +& \requires \tcode{n} shall be in the range \tcode{[0, b.bucket_count())}. \tcode{b.begin(n)} returns an iterator referring to the first element in the bucket. If the bucket is empty, then \tcode{b.begin(n) == b.end(n)}.% @@ -2704,7 +2705,7 @@ \tcode{b.end(n)} & \tcode{local_iterator}; \br \tcode{const_local_iterator} for const \tcode{b}. -& Pre: \tcode{n} shall be in the range \tcode{[0, b.bucket_count())}. +& \requires \tcode{n} shall be in the range \tcode{[0, b.bucket_count())}. \tcode{b.end(n)} returns an iterator which is the past-the-end value for the bucket.% \indextext{unordered associative containers!\idxcode{end}}% @@ -2714,7 +2715,7 @@ % \tcode{b.cbegin(n)} & \tcode{const_local_iterator} -& Pre: \tcode{n} shall be in the range \tcode{[0, b.bucket_count())}. +& \requires \tcode{n} shall be in the range \tcode{[0, b.bucket_count())}. Note: \tcode{[b.cbegin(n), b.cend(n))} is a valid range containing all of the elements in the $\texttt{n}^{\textrm{ th}}$ bucket.% \indextext{unordered associative containers!\idxcode{cbegin}}% @@ -2724,7 +2725,7 @@ % \tcode{b.cend(n)} & \tcode{const_local_iterator} -& Pre: \tcode{n} shall be in the range \tcode{[0, b.bucket_count())}.% +& \requires \tcode{n} shall be in the range \tcode{[0, b.bucket_count())}.% \indextext{unordered associative containers!\idxcode{cend}}% \indextext{\idxcode{cend}!unordered associative containers}% & Constant @@ -2751,14 +2752,14 @@ % \tcode{a.max_load_factor(z)} & \tcode{void} -& Pre: \tcode{z} shall be positive. +& \requires \tcode{z} shall be positive. May change the container's maximum load factor, using \tcode{z} as a hint.% & Constant \\ \rowsep % \tcode{a.rehash(n)} & \tcode{void} -& Post: \tcode{a.bucket_count() >= a.size() / a.max_load_factor()} and +& \postconditions \tcode{a.bucket_count() >= a.size() / a.max_load_factor()} and \tcode{a.bucket_count() >= n}.% \indextext{unordered associative containers!\idxcode{rehash}}% \indextext{\idxcode{rehash}!unordered associative containers}% @@ -2786,7 +2787,7 @@ 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^{th}$ equivalent-key group in \tcode{a}. +and $E_i$ is the size of the $i^\text{th}$ equivalent-key group in \tcode{a}. However, if the respective elements of each corresponding pair of equivalent-key groups $Ea_i$ and $Eb_i$ are arranged in the same order (as is commonly the case, e.g., if \tcode{a} and \tcode{b} are unmodified copies @@ -2796,7 +2797,7 @@ a pathologically bad hash function). The behavior of a program that uses \tcode{operator==} or \tcode{operator!=} on unordered containers is undefined unless the \tcode{Hash} and \tcode{Pred} function objects respectively have -the same behavior for both containers and the equality comparison operator +the same behavior for both containers and the equality comparison function for \tcode{Key} is a refinement\footnote{Equality comparison is a refinement of partitioning if no two objects that compare equal fall into different partitions.} @@ -2875,6 +2876,7 @@ \rSec2[array.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{array}}% \indexlibrary{\idxhdr{array}}% \begin{codeblock} #include @@ -2916,7 +2918,8 @@ \rSec2[deque.syn]{Header \tcode{} synopsis} -\indexlibrary{\idxhdr{deque}} +\indextext{\idxhdr{deque}}% +\indexlibrary{\idxhdr{deque}}% \begin{codeblock} #include @@ -2949,7 +2952,8 @@ \rSec2[forward_list.syn]{Header \tcode{} synopsis} -\indexlibrary{\idxhdr{forward_list}} +\indextext{\idxhdr{forward_list}}% +\indexlibrary{\idxhdr{forward_list}}% \begin{codeblock} #include @@ -2982,7 +2986,8 @@ \rSec2[list.syn]{Header \tcode{} synopsis} -\indexlibrary{\idxhdr{list}} +\indextext{\idxhdr{list}}% +\indexlibrary{\idxhdr{list}}% \begin{codeblock} #include @@ -3015,7 +3020,8 @@ \rSec2[vector.syn]{Header \tcode{} synopsis} -\indexlibrary{\idxhdr{vector}} +\indextext{\idxhdr{vector}}% +\indexlibrary{\idxhdr{vector}}% \begin{codeblock} #include @@ -3191,7 +3197,7 @@ \end{itemdecl} \begin{itemdescr} -\pnum\returns \tcode{N} +\pnum\returns \tcode{N}. \end{itemdescr} \rSec3[array.data]{\tcode{array::data}} @@ -3228,15 +3234,14 @@ \begin{itemdescr} \pnum -\effects As if by \tcode{swap_ranges(begin(), end(), y.begin())}. - -\pnum -\throws Nothing unless one of the element-wise swap calls throws an exception. +\effects Equivalent to \tcode{swap_ranges(begin(), end(), y.begin())}. \pnum -\realnote Unlike the \tcode{swap} function for other containers, \tcode{array::swap} +\begin{note} +Unlike the \tcode{swap} function for other containers, \tcode{array::swap} takes linear time, may exit via an exception, and does not cause iterators to become associated with the other container. +\end{note} \end{itemdescr} \rSec3[array.zero]{Zero sized arrays} @@ -4347,7 +4352,7 @@ \pnum \effects Sorts the list according to the \tcode{operator<} or the \tcode{comp} function object. -If an exception is thrown the order of the elements in \tcode{*this} is unspecified. +If an exception is thrown, the order of the elements in \tcode{*this} is unspecified. Does not affect the validity of iterators and references. \pnum @@ -4826,6 +4831,12 @@ \end{itemdecl} \begin{itemdescr} +\pnum +\requires +\tcode{i} +is a valid dereferenceable iterator of +\tcode{x}. + \pnum \effects Inserts an element pointed to by @@ -4852,12 +4863,6 @@ not into \tcode{x}. -\pnum -\requires -\tcode{i} -is a valid dereferenceable iterator of -\tcode{x}. - \pnum \throws Nothing. @@ -4875,15 +4880,6 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\effects -Inserts elements in the range -\range{first}{last} -before -\tcode{position} -and removes the elements from -\tcode{x}. - \pnum \requires \tcode{[first, last)} @@ -4893,6 +4889,15 @@ \tcode{position} is an iterator in the range \range{first}{last}. + +\pnum +\effects +Inserts elements in the range +\range{first}{last} +before +\tcode{position} +and removes the elements from +\tcode{x}. Pointers and references to the moved elements of \tcode{x} now refer to those same elements but as members of @@ -5768,6 +5773,7 @@ \rSec2[associative.map.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{map}}% \indexlibrary{\idxhdr{map}}% \begin{codeblock} #include @@ -5840,7 +5846,9 @@ \end{codeblock} \rSec2[associative.set.syn]{Header \tcode{} synopsis}% -\indexlibrary{\idxhdr{set}} + +\indextext{\idxhdr{set}}% +\indexlibrary{\idxhdr{set}}% \begin{codeblock} #include @@ -5873,7 +5881,7 @@ set& y) noexcept(noexcept(x.swap(y))); - // \ref{set}, class template multiset + // \ref{multiset}, class template multiset template , class Allocator = allocator> class multiset; @@ -5930,13 +5938,13 @@ an associative container~(\ref{associative.reqmts}), and of an allocator-aware container (Table~\ref{tab:containers.allocatoraware}). A \tcode{map} -also provides most operations described in~(\ref{associative.reqmts}) +also provides most operations described in~\ref{associative.reqmts} for unique keys. This means that a \tcode{map} supports the \tcode{a_uniq} -operations in~(\ref{associative.reqmts}) +operations in~\ref{associative.reqmts} but not the \tcode{a_eq} operations. @@ -6463,13 +6471,13 @@ (Table~\ref{tab:containers.allocatoraware}). A \tcode{multimap} -also provides most operations described in~(\ref{associative.reqmts}) +also provides most operations described in~\ref{associative.reqmts} for equal keys. This means that a \tcode{multimap} supports the \tcode{a_eq} -operations in~(\ref{associative.reqmts}) +operations in~\ref{associative.reqmts} but not the \tcode{a_uniq} operations. @@ -6773,13 +6781,13 @@ (Table~\ref{tab:containers.allocatoraware}). A \tcode{set} -also provides most operations described in~(\ref{associative.reqmts}) +also provides most operations described in~\ref{associative.reqmts} for unique keys. This means that a \tcode{set} supports the \tcode{a_uniq} -operations in~(\ref{associative.reqmts}) +operations in~\ref{associative.reqmts} but not the \tcode{a_eq} operations. @@ -7041,13 +7049,13 @@ container~(\ref{associative.reqmts}), and of an allocator-aware container (Table~\ref{tab:containers.allocatoraware}). \tcode{multiset} -also provides most operations described in~(\ref{associative.reqmts}) +also provides most operations described in~\ref{associative.reqmts} for duplicate keys. This means that a \tcode{multiset} supports the \tcode{a_eq} -operations in~(\ref{associative.reqmts}) +operations in~\ref{associative.reqmts} but not the \tcode{a_uniq} operations. @@ -7299,6 +7307,7 @@ \tcode{unordered_set} and \tcode{unordered_multiset}. \rSec2[unord.map.syn]{Header \tcode{} synopsis}% +\indextext{\idxhdr{unordered_map}}% \indexlibrary{\idxhdr{unordered_map}}% \indexlibrary{\idxcode{unordered_map}}% \indexlibrary{\idxcode{unordered_multimap}}% @@ -7366,6 +7375,7 @@ \end{codeblock} \rSec2[unord.set.syn]{Header \tcode{} synopsis}% +\indextext{\idxhdr{unordered_set}}% \indexlibrary{\idxhdr{unordered_set}}% \indexlibrary{\idxcode{unordered_set}}% \indexlibrary{\idxcode{unordered_multiset}}% @@ -7659,7 +7669,7 @@ \begin{itemdescr} \pnum \effects Constructs an empty \tcode{unordered_map} using the -specified hash function, key equality function, and allocator, and +specified hash function, key equality predicate, and allocator, and using at least \tcode{n} buckets. For the default constructor, the number of buckets is \impldef{default number of buckets in \tcode{unordered_map}}. @@ -7687,7 +7697,7 @@ \begin{itemdescr} \pnum \effects Constructs an empty \tcode{unordered_map} using the -specified hash function, key equality function, and allocator, and +specified hash function, key equality predicate, and allocator, and using at least \tcode{n} buckets. If \tcode{n} is not provided, the number of buckets is \impldef{default number of buckets in \tcode{unordered_map}}. Then @@ -8152,7 +8162,7 @@ \begin{itemdescr} \pnum \effects Constructs an empty \tcode{unordered_multimap} using the -specified hash function, key equality function, and allocator, and +specified hash function, key equality predicate, and allocator, and using at least \tcode{n} buckets. For the default constructor, the number of buckets is \impldef{default number of buckets in \tcode{unordered_multimap}}. @@ -8180,7 +8190,7 @@ \begin{itemdescr} \pnum \effects Constructs an empty \tcode{unordered_multimap} using the -specified hash function, key equality function, and allocator, and +specified hash function, key equality predicate, and allocator, and using at least \tcode{n} buckets. If \tcode{n} is not provided, the number of buckets is \impldef{default number of buckets in \tcode{unordered_multimap}}. Then @@ -8447,7 +8457,7 @@ \begin{itemdescr} \pnum \effects Constructs an empty \tcode{unordered_set} using the -specified hash function, key equality function, and allocator, and +specified hash function, key equality predicate, and allocator, and using at least \tcode{n} buckets. For the default constructor, the number of buckets is \impldef{default number of buckets in \tcode{unordered_set}}. @@ -8475,7 +8485,7 @@ \begin{itemdescr} \pnum \effects Constructs an empty \tcode{unordered_set} using the -specified hash function, key equality function, and allocator, and +specified hash function, key equality predicate, and allocator, and using at least \tcode{n} buckets. If \tcode{n} is not provided, the number of buckets is \impldef{default number of buckets in \tcode{unordered_set}}. Then @@ -8714,7 +8724,7 @@ \begin{itemdescr} \pnum \effects Constructs an empty \tcode{unordered_multiset} using the -specified hash function, key equality function, and allocator, and +specified hash function, key equality predicate, and allocator, and using at least \tcode{n} buckets. For the default constructor, the number of buckets is \impldef{default number of buckets in \tcode{unordered_multiset}}. @@ -8742,7 +8752,7 @@ \begin{itemdescr} \pnum\effects Constructs an empty \tcode{unordered_multiset} using the -specified hash function, key equality function, and allocator, and +specified hash function, key equality predicate, and allocator, and using at least \tcode{n} buckets. If \tcode{n} is not provided, the number of buckets is \impldef{default number of buckets in \tcode{unordered_multiset}}. Then @@ -8768,8 +8778,6 @@ \pnum\effects As if by \tcode{x.swap(y)}. \end{itemdescr} -\indextext{unordered associative containers|)} - \rSec1[container.adaptors]{Container adaptors} \rSec2[container.adaptors.general]{In general} @@ -8793,6 +8801,7 @@ \tcode{Compare} object (if any). \rSec2[queue.syn]{Header \tcode{} synopsis}% +\indextext{\idxhdr{queue}}% \indexlibrary{\idxhdr{queue}} \begin{codeblock} @@ -8826,6 +8835,7 @@ \end{codeblock} \rSec2[stack.syn]{Header \tcode{} synopsis}% +\indextext{\idxhdr{stack}}% \indexlibrary{\idxhdr{stack}} \begin{codeblock} diff --git a/source/conversions.tex b/source/conversions.tex index c262bc9608..5fed124708 100644 --- a/source/conversions.tex +++ b/source/conversions.tex @@ -1,7 +1,7 @@ %!TEX root = std.tex \rSec0[conv]{Standard conversions} -\indextext{implicit~conversion|see{conversion, implicit}} +\indextext{implicit conversion|see{conversion, implicit}} \indextext{contextually converted to bool|see{conversion, contextual}} \indextext{rvalue!lvalue conversion to|see{conversion, lvalue to rvalue}}% @@ -20,8 +20,8 @@ conversion. \item Zero or one conversion from the following set: integral -promotions, floating-point promotion, integral conversions, floating -point conversions, floating-integral conversions, pointer conversions, +promotions, floating-point promotion, integral conversions, floating-point +conversions, floating-integral conversions, pointer conversions, pointer to member conversions, and boolean conversions. \item Zero or one function pointer conversion. @@ -153,16 +153,18 @@ return [&](bool b) { return (b ? y : x).n; }; } auto g = f(); -int m = g(false); // undefined behavior due to access of \tcode{x.n} outside its lifetime -int n = g(true); // OK, does not access \tcode{y.n} +int m = g(false); // undefined behavior due to access of \tcode{x.n} outside its lifetime +int n = g(true); // OK, does not access \tcode{y.n} \end{codeblock} \end{example} + +\pnum The result of the conversion is determined according to the following rules: \begin{itemize} -\item If \tcode{T} is (possibly cv-qualified) \tcode{std::nullptr_t}, the result is a +\item If \tcode{T} is \cv{}~\tcode{std::nullptr_t}, the result is a null pointer constant~(\ref{conv.ptr}). \begin{note} Since no value is fetched from memory, @@ -231,7 +233,7 @@ \begin{example} \begin{codeblock} struct X { int n; }; -int k = X().n; // OK, \tcode{X()} prvalue is converted to xvalue +int k = X().n; // OK, \tcode{X()} prvalue is converted to xvalue \end{codeblock} \end{example} @@ -268,23 +270,23 @@ \pnum \indextext{type!similar|see{similar types}}% -Two types \tcode{T1} and \tcode{T2} are \defnx{similar}{similar types} if +Two types $\tcode{T}_1$ and $\tcode{T}_2$ are \defnx{similar}{similar types} if they have cv-decompositions with the same $n$ such that corresponding $P_i$ components are the same and the types denoted by \tcode{U} are the same. \pnum -A prvalue expression of type \tcode{T1} -can be converted to type \tcode{T2} +A prvalue expression of type $\tcode{T}_1$ +can be converted to type $\tcode{T}_2$ if the following conditions are satisfied, % NB: forbid line break between 'where' and 'cv' % to stop superscript j from running into % descender of p on the previous line. -where~$cv_i^j$ denotes the cv-qualifiers in the cv-qualification signature of $T_j$% -\footnote{These rules ensure that const-safety is preserved by the conversion.}: +where~$cv_i^j$ denotes the cv-qualifiers in the cv-qualification signature of $\tcode{T}_j$:% +\footnote{These rules ensure that const-safety is preserved by the conversion.} \begin{itemize} -\item \tcode{T1} and \tcode{T2} are similar. +\item $\tcode{T}_1$ and $\tcode{T}_2$ are similar. \item For every $i > 0$, if \tcode{const} is in $\mathit{cv}_i^1$ then \tcode{const} is in $\mathit{cv}_i^2$, and similarly for \tcode{volatile}. @@ -294,9 +296,9 @@ \begin{note} If a program could assign a pointer of type \tcode{T**} to a pointer of -type \tcode{const} \tcode{T**} (that is, if line \tcode{\#1} below were +type \tcode{const} \tcode{T**} (that is, if line \#1 below were allowed), a program could inadvertently modify a \tcode{const} object -(as it is done on line \tcode{\#2}). For example, +(as it is done on line \#2). For example, \begin{codeblock} int main() { @@ -358,7 +360,7 @@ A prvalue of an unscoped enumeration type whose underlying type is not fixed~(\ref{dcl.enum}) can be converted to a prvalue of the first of the following types that can represent all the values of the enumeration (i.e., the values in the -range $b_\mathit{min}$ to $b_\mathit{max}$ as described in~\ref{dcl.enum}): \tcode{int}, +range $b_\text{min}$ to $b_\text{max}$ as described in~\ref{dcl.enum}): \tcode{int}, \tcode{unsigned int}, \tcode{long} \tcode{int}, \tcode{unsigned long} \tcode{int}, \tcode{long long int}, or \tcode{unsigned long long int}. If none of the types in that list can represent all the values of the enumeration, a prvalue of an unscoped @@ -395,7 +397,7 @@ \rSec1[conv.fpprom]{Floating-point promotion} \pnum -\indextext{promotion!floating~point}% +\indextext{promotion!floating-point}% A prvalue of type \tcode{float} can be converted to a prvalue of type \tcode{double}. The value is unchanged. @@ -440,7 +442,7 @@ \rSec1[conv.double]{Floating-point conversions} \pnum -\indextext{conversion!floating~point}% +\indextext{conversion!floating-point}% A prvalue of floating-point type can be converted to a prvalue of another floating-point type. If the source value can be exactly represented in the destination type, the result of the conversion is @@ -456,7 +458,7 @@ \rSec1[conv.fpint]{Floating-integral conversions} \pnum -\indextext{conversion!floating~to~integral}% +\indextext{conversion!floating to integral}% A prvalue of a floating-point type can be converted to a prvalue of an integer type. The conversion truncates; that is, the fractional part is discarded. @@ -468,7 +470,7 @@ \end{note} \pnum -\indextext{conversion!integral~to~floating}% +\indextext{conversion!integral to floating}% \indextext{truncation}% \indextext{rounding}% A prvalue of an integer type or of an unscoped enumeration type can be converted to diff --git a/source/declarations.tex b/source/declarations.tex index 29cc15925c..5e023e9f62 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -111,7 +111,7 @@ \grammarterm{declarator-id} for that declaration. \end{note} \begin{example} \begin{codeblock} -[[noreturn]] void f [[noreturn]] (); // OK +[[noreturn]] void f [[noreturn]] (); // OK \end{codeblock} \end{example} @@ -151,10 +151,9 @@ the program, or shall redeclare a name introduced by a previous declaration. \begin{example} - \begin{codeblock} enum { }; // ill-formed -typedef class { }; // ill-formed +typedef class { }; // ill-formed \end{codeblock} \end{example} @@ -217,13 +216,13 @@ an \term{object declaration} otherwise. \pnum -\indextext{definition!declaration~as}% +\indextext{definition!declaration as}% Syntactic components beyond those found in the general form of declaration are added to a function declaration to make a \grammarterm{function-definition}. An object declaration, however, is also a definition unless it contains the \tcode{extern} specifier and has no initializer~(\ref{basic.def}). -\indextext{initialization!definition~and}% +\indextext{initialization!definition and}% A definition causes the appropriate amount of storage to be reserved and any appropriate initialization~(\ref{dcl.init}) to be done. @@ -283,12 +282,10 @@ The sequence shall be self-consistent as described below. \begin{example} - \begin{codeblock} typedef char* Pc; static Pc; // error: name missing \end{codeblock} - Here, the declaration \tcode{static} \tcode{Pc} is ill-formed because no name was specified for the static variable of type \tcode{Pc}. To get a variable called \tcode{Pc}, a \grammarterm{type-specifier} (other than @@ -296,7 +293,6 @@ the \grammarterm{typedef-name} \tcode{Pc} is the name being (re)declared, rather than being part of the \grammarterm{decl-specifier} sequence. For another example, - \begin{codeblock} void f(const Pc); // \tcode{void f(char* const)} (not \tcode{const char*}) void g(const int Pc); // \tcode{void g(const int)} @@ -304,16 +300,15 @@ \end{example} \pnum -\indextext{\idxcode{signed}!typedef@\tcode{typedef}~and}% -\indextext{\idxcode{unsigned}!typedef@\tcode{typedef}~and}% -\indextext{\idxcode{long}!typedef@\tcode{typedef}~and}% -\indextext{\idxcode{short}!typedef@\tcode{typedef}~and}% +\indextext{\idxcode{signed}!typedef@\tcode{typedef} and}% +\indextext{\idxcode{unsigned}!typedef@\tcode{typedef} and}% +\indextext{\idxcode{long}!typedef@\tcode{typedef} and}% +\indextext{\idxcode{short}!typedef@\tcode{typedef} and}% \begin{note} Since \tcode{signed}, \tcode{unsigned}, \tcode{long}, and \tcode{short} by default imply \tcode{int}, a \grammarterm{type-name} appearing after one of those specifiers is treated as the name being (re)declared. \begin{example} - \begin{codeblock} void h(unsigned Pc); // \tcode{void h(unsigned int)} void k(unsigned int Pc); // \tcode{void k(unsigned int)} @@ -322,8 +317,8 @@ \end{note} \rSec2[dcl.stc]{Storage class specifiers}% -\indextext{specifier!storage~class}% -\indextext{declaration!storage~class}% +\indextext{specifier!storage class}% +\indextext{declaration!storage class}% \indextext{\idxcode{static}}% \indextext{\idxcode{thread_local}}% \indextext{\idxcode{extern}}% @@ -391,7 +386,7 @@ storage duration~(\ref{basic.stc.thread}). A \tcode{static} specifier can be used in declarations of class members;~\ref{class.static} describes its effect. -\indextext{\idxcode{static}!linkage~of}% +\indextext{\idxcode{static}!linkage of}% For the linkage of a name declared with a \tcode{static} specifier, see~\ref{basic.link}. @@ -400,15 +395,15 @@ The \tcode{extern} specifier can be applied only to the names of variables and functions. The \tcode{extern} specifier cannot be used in the declaration of class members or function parameters. -\indextext{\idxcode{extern}!linkage~of}% +\indextext{\idxcode{extern}!linkage of}% \indextext{consistency!linkage}% For the linkage of a name declared with an \tcode{extern} specifier, see~\ref{basic.link}. \begin{note} The \tcode{extern} keyword can also be used in -\nonterminal{explicit-instantiation}s and -\nonterminal{linkage-specification}s, but it is not a -\nonterminal{storage-class-specifier} in such contexts. +\grammarterm{explicit-instantiation}s and +\grammarterm{linkage-specification}s, but it is not a +\grammarterm{storage-class-specifier} in such contexts. \end{note} \pnum @@ -419,15 +414,14 @@ can have a different linkage, however. \begin{example} \indextext{example!linkage consistency}% - \begin{codeblock} static char* f(); // \tcode{f()} has internal linkage char* f() // \tcode{f()} still has internal linkage - { /* ... */ } + { @\commentellip@ } char* g(); // \tcode{g()} has external linkage static char* g() // error: inconsistent linkage - { /* ... */ } + { @\commentellip@ } void h(); inline void h(); // external linkage @@ -461,7 +455,6 @@ \tcode{extern} declaration. Such a declaration can only be used in ways that do not require a complete class type. \begin{example} - \begin{codeblock} struct S; extern S a; @@ -480,7 +473,6 @@ a non-static data member~(\ref{class.mem}) whose type is neither const-qualified nor a reference type. \begin{example} - \begin{codeblock} class X { mutable const int* p; // OK @@ -497,7 +489,7 @@ \rSec2[dcl.fct.spec]{Function specifiers}% \indextext{specifier!function}% -\indextext{function|seealso{friend function; member~function; inline~function; virtual~function}} +\indextext{function|seealso{friend function; member function; inline function; virtual function}} \pnum \grammarterm{Function-specifiers} @@ -548,15 +540,15 @@ \grammarterm{typedef-name} is syntactically equivalent to a keyword and names the type associated with the identifier in the way described in Clause~\ref{dcl.decl}. -\indextext{declaration!typedef@\tcode{typedef}~as type}% +\indextext{declaration!typedef@\tcode{typedef} as type}% \indextext{equivalence!type}% -\indextext{synonym!type~name~as}% +\indextext{synonym!type name as}% A \grammarterm{typedef-name} is thus a synonym for another type. A \grammarterm{typedef-name} does not introduce a new type the way a class declaration~(\ref{class.name}) or enum declaration does. \begin{example} \indextext{example!\idxcode{typedef}}% -after +After \begin{codeblock} typedef int MILES, *KLICKSP; @@ -605,7 +597,7 @@ \begin{example} \begin{codeblock} -typedef struct s { /* ... */ } s; +typedef struct s { @\commentellip@ } s; typedef int I; typedef int I; typedef I I; @@ -649,9 +641,8 @@ redefine the name of any type declared in that scope to refer to a different type. \begin{example} - \begin{codeblock} -class complex { /* ... */ }; +class complex { @\commentellip@ }; typedef int complex; // error: redefinition \end{codeblock} \end{example} @@ -662,16 +653,15 @@ declared in that scope and refers to a type other than the class or enumeration itself. \begin{example} - \begin{codeblock} typedef int complex; -class complex @\tcode{\{ /* ... */ \}}@; // error: redefinition +class complex { @\commentellip@ }; // error: redefinition \end{codeblock} \end{example} \pnum \begin{note} -\indextext{class~name!\idxcode{typedef}}% +\indextext{class name!\idxcode{typedef}}% A \grammarterm{typedef-name} that names a class type, or a cv-qualified version thereof, is also a \grammarterm{class-name}~(\ref{class.name}). If a \grammarterm{typedef-name} is used to identify the subject of an @@ -696,8 +686,8 @@ \end{example} \pnum -\indextext{class~name!\idxcode{typedef}}% -\indextext{enum~name!\idxcode{typedef}}% +\indextext{class name!\idxcode{typedef}}% +\indextext{enum name!\idxcode{typedef}}% \indextext{class!unnamed}% If the typedef declaration defines an unnamed class (or enum), the first \grammarterm{typedef-name} declared by the declaration to be that class @@ -771,7 +761,7 @@ \pnum \indextext{specifier!\idxcode{constexpr}!function} \indextext{constexpr function} -The definition of a \tcode{constexpr} function shall satisfy the following +The definition of a constexpr function shall satisfy the following requirements: \begin{itemize} @@ -838,7 +828,7 @@ \pnum \indextext{specifier!\idxcode{constexpr}!constructor}% -The definition of a \tcode{constexpr} constructor shall satisfy the +The definition of a constexpr constructor shall satisfy the following requirements: \begin{itemize} \item @@ -861,7 +851,7 @@ \item either its \grammarterm{function-body} shall be \tcode{= default}, or the \grammarterm{compound-statement} of its \grammarterm{function-body} shall satisfy the requirements for a \grammarterm{function-body} of a -\tcode{constexpr} function; +constexpr function; \item every non-variant non-static data member and base class subobject @@ -877,7 +867,7 @@ \item for a non-delegating constructor, every constructor selected to initialize non-static -data members and base class subobjects shall be a \tcode{constexpr} constructor; +data members and base class subobjects shall be a constexpr constructor; \item for a delegating constructor, the target constructor shall be a \tcode{constexpr} @@ -895,7 +885,7 @@ \end{example} \pnum -For a \tcode{constexpr} function or \tcode{constexpr} constructor +For a constexpr function or constexpr constructor that is neither defaulted nor a template, if no argument values exist such that an invocation of the function or constructor could be an evaluated subexpression of a core @@ -905,41 +895,40 @@ \begin{example} \begin{codeblock} constexpr int f(bool b) - { return b ? throw 0 : 0; } // OK -constexpr int f() { return f(true); } // ill-formed, no diagnostic required + { return b ? throw 0 : 0; } // OK +constexpr int f() { return f(true); } // ill-formed, no diagnostic required struct B { - constexpr B(int x) : i(0) { } // \tcode{x} is unused + constexpr B(int x) : i(0) { } // \tcode{x} is unused int i; }; int global; struct D : B { - constexpr D() : B(global) { } // ill-formed, no diagnostic required - // lvalue-to-rvalue conversion on non-constant \tcode{global} + constexpr D() : B(global) { } // ill-formed, no diagnostic required + // lvalue-to-rvalue conversion on non-constant \tcode{global} }; \end{codeblock} - \end{example} \pnum -If the instantiated template specialization of a \tcode{constexpr} function +If the instantiated template specialization of a constexpr function template or member function of a class template would fail to satisfy the requirements for a \tcode{constexpr} -function or \tcode{constexpr} constructor, -that specialization is still a \tcode{constexpr} function or \tcode{constexpr} +function or constexpr constructor, +that specialization is still a constexpr function or \tcode{constexpr} constructor, even though a call to such a function cannot appear in a constant expression. If no specialization of the template would satisfy the -requirements for a \tcode{constexpr} function or \tcode{constexpr} constructor +requirements for a constexpr function or constexpr constructor when considered as a non-template function or constructor, the template is ill-formed; no diagnostic required. \pnum -A call to a \tcode{constexpr} function produces the same result as a call to an equivalent -non-\tcode{constexpr} function in all respects except that +A call to a constexpr function produces the same result as a call to an equivalent +non-constexpr function in all respects except that \begin{itemize} \item a call to a \tcode{constexpr} @@ -950,12 +939,12 @@ \pnum The \tcode{constexpr} specifier has no -effect on the type of a \tcode{constexpr} function or a \tcode{constexpr} constructor. \begin{example} +effect on the type of a constexpr function or a constexpr constructor. \begin{example} \begin{codeblock} -constexpr int bar(int x, int y) // OK +constexpr int bar(int x, int y) // OK { return x + y + x*y; } // ... -int bar(int x, int y) // error: redefinition of \tcode{bar} +int bar(int x, int y) // error: redefinition of \tcode{bar} { return x * 2 + 3 * y; } \end{codeblock} \end{example} @@ -974,8 +963,8 @@ struct pixel { int x, y; }; -constexpr pixel ur = { 1294, 1024 };// OK -constexpr pixel origin; // error: initializer missing +constexpr pixel ur = { 1294, 1024 }; // OK +constexpr pixel origin; // error: initializer missing \end{codeblock} \end{example} @@ -988,7 +977,7 @@ \pnum \indextext{specifier!\idxcode{inline}}% -\indextext{inline~function}% +\indextext{inline function}% A function declaration~(\ref{dcl.fct},~\ref{class.mfct}, \ref{class.friend}) with an \tcode{inline} specifier declares an \term{inline function}. The inline specifier indicates to @@ -1036,7 +1025,7 @@ \end{note} \rSec2[dcl.type]{Type specifiers}% -\indextext{specifier!type|see{type~specifier}} +\indextext{specifier!type|see{type specifier}} \pnum The type-specifiers are @@ -1135,8 +1124,8 @@ \rSec3[dcl.type.cv]{The \grammarterm{cv-qualifiers}}% \indextext{specifier!cv-qualifier}% \indextext{initialization!\idxcode{const}}% -\indextext{type~specifier!\idxcode{const}}% -\indextext{type~specifier!\idxcode{volatile}} +\indextext{type specifier!\idxcode{const}}% +\indextext{type specifier!\idxcode{volatile}} \pnum There are two \grammarterm{cv-qualifiers}, \tcode{const} and @@ -1173,23 +1162,23 @@ \end{note} \pnum -\indextext{const~object@\tcode{const}-object!undefined change~to}% +\indextext{const object@\tcode{const}-object!undefined change to}% Except that any class member declared \tcode{mutable}~(\ref{dcl.stc}) can be modified, any attempt to modify a \tcode{const} object during its lifetime~(\ref{basic.life}) results in undefined behavior. \begin{example} \begin{codeblock} -const int ci = 3; // cv-qualified (initialized as required) -ci = 4; // ill-formed: attempt to modify \tcode{const} +const int ci = 3; // cv-qualified (initialized as required) +ci = 4; // ill-formed: attempt to modify \tcode{const} -int i = 2; // not cv-qualified -const int* cip; // pointer to \tcode{const int} -cip = &i; // OK: cv-qualified access path to unqualified -*cip = 4; // ill-formed: attempt to modify through ptr to \tcode{const} +int i = 2; // not cv-qualified +const int* cip; // pointer to \tcode{const int} +cip = &i; // OK: cv-qualified access path to unqualified +*cip = 4; // ill-formed: attempt to modify through ptr to \tcode{const} int* ip; -ip = const_cast(cip); // cast needed to convert \tcode{const int*} to \tcode{int*} -*ip = 4; // defined: \tcode{*ip} points to \tcode{i}, a non-\tcode{const} object +ip = const_cast(cip); // cast needed to convert \tcode{const int*} to \tcode{int*} +*ip = 4; // defined: \tcode{*ip} points to \tcode{i}, a non-\tcode{const} object const int* ciq = new const int (3); // initialized as required int* iq = const_cast(ciq); // cast required @@ -1207,11 +1196,11 @@ }; const Y y; -y.x.i++; // well-formed: \tcode{mutable} member can be modified -y.x.j++; // ill-formed: const-qualified member modified -Y* p = const_cast(&y); // cast away const-ness of \tcode{y} -p->x.i = 99; // well-formed: \tcode{mutable} member can be modified -p->x.j = 99; // undefined: modifies a \tcode{const} member +y.x.i++; // well-formed: \tcode{mutable} member can be modified +y.x.j++; // ill-formed: const-qualified member modified +Y* p = const_cast(&y); // cast away const-ness of \tcode{y} +p->x.i = 99; // well-formed: \tcode{mutable} member can be modified +p->x.j = 99; // undefined: modifies a \tcode{const} member \end{codeblock} \end{example} @@ -1223,7 +1212,7 @@ non-volatile-qualified type, the behavior is undefined. \pnum -\indextext{type~specifier!\idxcode{volatile}}% +\indextext{type specifier!\idxcode{volatile}}% \indextext{\idxcode{volatile}!implementation-defined}% \begin{note} \tcode{volatile} is a hint to the implementation to avoid aggressive @@ -1237,7 +1226,7 @@ \end{note} \rSec3[dcl.type.simple]{Simple type specifiers}% -\indextext{type~specifier!simple} +\indextext{type specifier!simple} \pnum The simple type specifiers are @@ -1279,21 +1268,21 @@ \end{bnf} \pnum -\indextext{type~specifier!\idxcode{char}}% -\indextext{type~specifier!\idxcode{char16_t}}% -\indextext{type~specifier!\idxcode{char32_t}}% -\indextext{type~specifier!\idxcode{wchar_t}}% -\indextext{type~specifier!\idxcode{bool}}% -\indextext{type~specifier!\idxcode{short}}% -\indextext{type~specifier!\idxcode{int}}% -\indextext{type~specifier!\idxcode{long}}% -\indextext{type~specifier!\idxcode{signed}}% -\indextext{type~specifier!\idxcode{unsigned}}% -\indextext{type~specifier!\idxcode{float}}% -\indextext{type~specifier!\idxcode{double}}% -\indextext{type~specifier!\idxcode{void}}% -\indextext{type~specifier!\idxcode{auto}}% -\indextext{type~specifier!\idxcode{decltype}}% +\indextext{type specifier!\idxcode{char}}% +\indextext{type specifier!\idxcode{char16_t}}% +\indextext{type specifier!\idxcode{char32_t}}% +\indextext{type specifier!\idxcode{wchar_t}}% +\indextext{type specifier!\idxcode{bool}}% +\indextext{type specifier!\idxcode{short}}% +\indextext{type specifier!\idxcode{int}}% +\indextext{type specifier!\idxcode{long}}% +\indextext{type specifier!\idxcode{signed}}% +\indextext{type specifier!\idxcode{unsigned}}% +\indextext{type specifier!\idxcode{float}}% +\indextext{type specifier!\idxcode{double}}% +\indextext{type specifier!\idxcode{void}}% +\indextext{type specifier!\idxcode{auto}}% +\indextext{type specifier!\idxcode{decltype}}% \indextext{\idxgram{type-name}}% \indextext{\idxgram{lambda-introducer}}% The \grammarterm{simple-type-specifier} \tcode{auto} is a placeholder for a type to be @@ -1377,7 +1366,7 @@ \end{note} \pnum -\indextext{type~specifier!\idxcode{decltype}}% +\indextext{type specifier!\idxcode{decltype}}% For an expression \tcode{e}, the type denoted by \tcode{decltype(e)} is defined as follows: \begin{itemize} @@ -1451,23 +1440,22 @@ template auto i(T) // identity -> T; template auto f(T) // \#1 - -> decltype(i(h())); // forces completion of \tcode{A} and implicitly uses - // \tcode{A::\~{}A()} for the temporary introduced by the - // use of \tcode{h()}. (A temporary is not introduced - // as a result of the use of \tcode{i()}.) + -> decltype(i(h())); // forces completion of \tcode{A} and implicitly uses \tcode{A::\~{}A()} + // for the temporary introduced by the use of \tcode{h()}. + // (A temporary is not introduced as a result of the use of \tcode{i()}.) template auto f(T) // \#2 -> void; auto g() -> void { - f(42); // OK: calls \#2. (\#1 is not a viable candidate: type - // deduction fails~(\ref{temp.deduct}) because \tcode{A::\tilde{}A()} - // is implicitly used in its \grammarterm{decltype-specifier}) + f(42); // OK: calls \#2. (\#1 is not a viable candidate: type deduction + // fails~(\ref{temp.deduct}) because \tcode{A::\tilde{}A()} is implicitly used in its + // \grammarterm{decltype-specifier}) } template auto q(T) - -> decltype((h())); // does not force completion of \tcode{A}; \tcode{A::\~{}A()} is - // not implicitly used within the context of this \grammarterm{decltype-specifier} + -> decltype((h())); // does not force completion of \tcode{A}; \tcode{A::\~{}A()} is not implicitly + // used within the context of this \grammarterm{decltype-specifier} void r() { - q(42); // Error: deduction against \tcode{q} succeeds, so overload resolution - // selects the specialization ``\tcode{q(T) -> decltype((h())) [with T=int]}''. + q(42); // Error: deduction against \tcode{q} succeeds, so overload resolution selects + // the specialization ``\tcode{q(T) -> decltype((h())) [with T=int]}''. // The return type is \tcode{A}, so a temporary is introduced and its // destructor is used, so the program is ill-formed. } @@ -1475,9 +1463,9 @@ \end{example} \rSec3[dcl.type.elab]{Elaborated type specifiers}% -\indextext{type~specifier!elaborated}% +\indextext{type specifier!elaborated}% \indextext{\idxcode{typename}}% -\indextext{type~specifier!\idxcode{enum}} +\indextext{type specifier!\idxcode{enum}} \begin{bnf} \nontermdef{elaborated-type-specifier}\br @@ -1488,7 +1476,7 @@ \end{bnf} \pnum -\indextext{class~name!elaborated}% +\indextext{class name!elaborated}% \indextext{name!elaborated!\idxcode{enum}}% An \grammarterm{attribute-specifier-seq} shall not appear in an \grammarterm{elaborated-type-specifier} unless the latter is the sole constituent of a declaration. @@ -1559,7 +1547,7 @@ \end{example} \rSec3[dcl.spec.auto]{The \tcode{auto} specifier}% -\indextext{type~specifier!\idxcode{auto}} +\indextext{type specifier!\idxcode{auto}} \pnum The \tcode{auto} and \tcode{decltype(auto)} \grammarterm{type-specifier}{s} @@ -1592,7 +1580,7 @@ \indextext{generic lambda!definition of}% lambda is a \term{generic lambda}~(\ref{expr.prim.lambda}). \begin{example} \begin{codeblock} -auto glambda = [](int i, auto a) { return i; }; // OK: a generic lambda +auto glambda = [](int i, auto a) { return i; }; // OK: a generic lambda \end{codeblock} \end{example} @@ -1601,7 +1589,7 @@ deduced from its initializer. This use is allowed when declaring variables in a block~(\ref{stmt.block}), in namespace scope~(\ref{basic.scope.namespace}), and in an -\nonterminal{init-statement} (Clause~\ref{stmt.stmt}). +\grammarterm{init-statement} (Clause~\ref{stmt.stmt}). \tcode{auto} or \tcode{decltype(auto)} shall appear as one of the \grammarterm{decl-specifier}{s} in the \grammarterm{decl-specifier-seq} and the @@ -1616,29 +1604,28 @@ the \grammarterm{expression-list} shall be a single \grammarterm{assignment-expression}. - \begin{example} \begin{codeblock} -auto x = 5; // OK: \tcode{x} has type \tcode{int} -const auto *v = &x, u = 6; // OK: \tcode{v} has type \tcode{const int*}, \tcode{u} has type \tcode{const int} -static auto y = 0.0; // OK: \tcode{y} has type \tcode{double} -auto int r; // error: auto is not a \grammarterm{storage-class-specifier} -auto f() -> int; // OK: \tcode{f} returns \tcode{int} -auto g() { return 0.0; } // OK: \tcode{g} returns \tcode{double} -auto h(); // OK: \tcode{h}'s return type will be deduced when it is defined +auto x = 5; // OK: \tcode{x} has type \tcode{int} +const auto *v = &x, u = 6; // OK: \tcode{v} has type \tcode{const int*}, \tcode{u} has type \tcode{const int} +static auto y = 0.0; // OK: \tcode{y} has type \tcode{double} +auto int r; // error: \tcode{auto} is not a \grammarterm{storage-class-specifier} +auto f() -> int; // OK: \tcode{f} returns \tcode{int} +auto g() { return 0.0; } // OK: \tcode{g} returns \tcode{double} +auto h(); // OK: \tcode{h}'s return type will be deduced when it is defined \end{codeblock} \end{example} \pnum A placeholder type can also be used in declaring a variable in -the \nonterminal{condition} of a selection statement~(\ref{stmt.select}) or an iteration -statement~(\ref{stmt.iter}), in the \nonterminal{type-specifier-seq} in -the \nonterminal{new-type-id} or \nonterminal{type-id} of a -\nonterminal{new-expression}~(\ref{expr.new}), in a +the \grammarterm{condition} of a selection statement~(\ref{stmt.select}) or an iteration +statement~(\ref{stmt.iter}), in the \grammarterm{type-specifier-seq} in +the \grammarterm{new-type-id} or \grammarterm{type-id} of a +\grammarterm{new-expression}~(\ref{expr.new}), in a \grammarterm{for-range-declaration}, in declaring a static data member with a \grammarterm{brace-or-equal-initializer} that appears within the -\nonterminal{member-specification} of a class definition~(\ref{class.static.data}), +\grammarterm{member-specification} of a class definition~(\ref{class.static.data}), and as a \grammarterm{decl-specifier} of the \grammarterm{parameter-declaration}{'s} \grammarterm{decl-specifier-seq} @@ -1658,11 +1645,10 @@ \begin{example} \begin{codeblock} -auto x = 5, *y = &x; // OK: \tcode{auto} is \tcode{int} -auto a = 5, b = { 1, 2 }; // error: different types for \tcode{auto} +auto x = 5, *y = &x; // OK: \tcode{auto} is \tcode{int} +auto a = 5, b = { 1, 2 }; // error: different types for \tcode{auto} \end{codeblock} -\end{example}% -\indextext{specifier|)} +\end{example} \pnum If a function with a declared return type that contains a placeholder type has @@ -1677,8 +1663,8 @@ body. \begin{example} \begin{codeblock} -auto f() { } // OK, return type is \tcode{void} -auto* g() { } // error, cannot deduce \tcode{auto*} from \tcode{void()} +auto f() { } // OK, return type is \tcode{void} +auto* g() { } // error, cannot deduce \tcode{auto*} from \tcode{void()} \end{codeblock} \end{example} @@ -1690,14 +1676,14 @@ \tcode{return} statements. \begin{example} \begin{codeblock} -auto n = n; // error, \tcode{n}'s type is unknown +auto n = n; // error, \tcode{n}'s type is unknown auto f(); -void g() { &f; } // error, \tcode{f}'s return type is unknown +void g() { &f; } // error, \tcode{f}'s return type is unknown auto sum(int i) { if (i == 1) - return i; // \tcode{sum}'s return type is \tcode{int} + return i; // \tcode{sum}'s return type is \tcode{int} else - return sum(i-1)+i; // OK, \tcode{sum}'s return type has been deduced + return sum(i-1)+i; // OK, \tcode{sum}'s return type has been deduced } \end{codeblock} \end{example} @@ -1709,14 +1695,14 @@ \begin{note} Therefore, any use of a specialization of the function template will cause an implicit instantiation. Any errors that arise from this instantiation are not in the immediate context of the function type and can result in the -program being ill-formed. \end{note} +program being ill-formed~(\ref{temp.deduct}). \end{note} \begin{example} \begin{codeblock} -template auto f(T t) { return t; } // return type deduced at instantiation time -typedef decltype(f(1)) fint_t; // instantiates \tcode{f} to deduce return type +template auto f(T t) { return t; } // return type deduced at instantiation time +typedef decltype(f(1)) fint_t; // instantiates \tcode{f} to deduce return type template auto f(T* t) { return *t; } -void g() { int (*p)(int*) = &f; } // instantiates both \tcode{f}s to determine return types, - // chooses second +void g() { int (*p)(int*) = &f; } // instantiates both \tcode{f}s to determine return types, + // chooses second \end{codeblock} \end{example} @@ -1727,26 +1713,26 @@ \begin{example} \begin{codeblock} auto f(); -auto f() { return 42; } // return type is \tcode{int} -auto f(); // OK -int f(); // error, cannot be overloaded with \tcode{auto f()} -decltype(auto) f(); // error, \tcode{auto} and \tcode{decltype(auto)} don't match +auto f() { return 42; } // return type is \tcode{int} +auto f(); // OK +int f(); // error, cannot be overloaded with \tcode{auto f()} +decltype(auto) f(); // error, \tcode{auto} and \tcode{decltype(auto)} don't match template auto g(T t) { return t; } // \#1 template auto g(int); // OK, return type is \tcode{int} template char g(char); // error, no matching template template<> auto g(double); // OK, forward declaration with unknown return type -template T g(T t) { return t; } // OK, not functionally equivalent to \#1 -template char g(char); // OK, now there is a matching template -template auto g(float); // still matches \#1 +template T g(T t) { return t; } // OK, not functionally equivalent to \#1 +template char g(char); // OK, now there is a matching template +template auto g(float); // still matches \#1 -void h() { return g(42); } // error, ambiguous +void h() { return g(42); } // error, ambiguous template struct A { friend T frf(T); }; -auto frf(int i) { return i; } // not a friend of \tcode{A} +auto frf(int i) { return i; } // not a friend of \tcode{A} \end{codeblock} \end{example} @@ -1762,9 +1748,9 @@ \begin{example} \begin{codeblock} template auto f(T t) { return t; } -extern template auto f(int); // does not instantiate \tcode{f} -int (*p)(int) = f; // instantiates \tcode{f} to determine its return type, but an explicit - // instantiation definition is still required somewhere in the program +extern template auto f(int); // does not instantiate \tcode{f} +int (*p)(int) = f; // instantiates \tcode{f} to determine its return type, but an explicit + // instantiation definition is still required somewhere in the program \end{codeblock} \end{example} @@ -1811,7 +1797,7 @@ In the case of a \tcode{return} statement with no operand or with an operand of type \tcode{void}, \tcode{T} shall be either -\tcode{decltype(auto)} or \cv{} \tcode{auto}. +\tcode{decltype(auto)} or \cv{}~\tcode{auto}. \pnum If the deduction is for a \tcode{return} statement @@ -1837,11 +1823,11 @@ substituting the deduced \tcode{U} into \tcode{P}. \begin{example} \begin{codeblock} -auto x1 = { 1, 2 }; // \tcode{decltype(x1)} is \tcode{std::initializer_list} -auto x2 = { 1, 2.0 }; // error: cannot deduce element type -auto x3{ 1, 2 }; // error: not a single element -auto x4 = { 3 }; // \tcode{decltype(x4)} is \tcode{std::initializer_list} -auto x5{ 3 }; // \tcode{decltype(x5)} is \tcode{int} +auto x1 = { 1, 2 }; // \tcode{decltype(x1)} is \tcode{std::initializer_list} +auto x2 = { 1, 2.0 }; // error: cannot deduce element type +auto x3{ 1, 2 }; // error: not a single element +auto x4 = { 3 }; // \tcode{decltype(x4)} is \tcode{std::initializer_list} +auto x5{ 3 }; // \tcode{decltype(x5)} is \tcode{int} \end{codeblock} \end{example} @@ -1849,10 +1835,8 @@ \begin{codeblock} const auto &i = expr; \end{codeblock} - The type of \tcode{i} is the deduced type of the parameter \tcode{u} in the call \tcode{f(expr)} of the following invented function template: - \begin{codeblock} template void f(const U& u); \end{codeblock} @@ -1868,18 +1852,18 @@ \begin{codeblock} int i; int&& f(); -auto x2a(i); // \tcode{decltype(x2a)} is \tcode{int} -decltype(auto) x2d(i); // \tcode{decltype(x2d)} is \tcode{int} -auto x3a = i; // \tcode{decltype(x3a)} is \tcode{int} -decltype(auto) x3d = i; // \tcode{decltype(x3d)} is \tcode{int} -auto x4a = (i); // \tcode{decltype(x4a)} is \tcode{int} -decltype(auto) x4d = (i); // \tcode{decltype(x4d)} is \tcode{int\&} -auto x5a = f(); // \tcode{decltype(x5a)} is \tcode{int} -decltype(auto) x5d = f(); // \tcode{decltype(x5d)} is \tcode{int\&\&} -auto x6a = { 1, 2 }; // \tcode{decltype(x6a)} is \tcode{std::initializer_list} -decltype(auto) x6d = { 1, 2 }; // error, \tcode{\{ 1, 2 \}} is not an expression -auto *x7a = &i; // \tcode{decltype(x7a)} is \tcode{int*} -decltype(auto)*x7d = &i; // error, declared type is not plain \tcode{decltype(auto)} +auto x2a(i); // \tcode{decltype(x2a)} is \tcode{int} +decltype(auto) x2d(i); // \tcode{decltype(x2d)} is \tcode{int} +auto x3a = i; // \tcode{decltype(x3a)} is \tcode{int} +decltype(auto) x3d = i; // \tcode{decltype(x3d)} is \tcode{int} +auto x4a = (i); // \tcode{decltype(x4a)} is \tcode{int} +decltype(auto) x4d = (i); // \tcode{decltype(x4d)} is \tcode{int\&} +auto x5a = f(); // \tcode{decltype(x5a)} is \tcode{int} +decltype(auto) x5d = f(); // \tcode{decltype(x5d)} is \tcode{int\&\&} +auto x6a = { 1, 2 }; // \tcode{decltype(x6a)} is \tcode{std::initializer_list} +decltype(auto) x6d = { 1, 2 }; // error, \tcode{\{ 1, 2 \}} is not an expression +auto *x7a = &i; // \tcode{decltype(x7a)} is \tcode{int*} +decltype(auto)*x7d = &i; // error, declared type is not plain \tcode{decltype(auto)} \end{codeblock} \end{example} @@ -1913,18 +1897,19 @@ }; template container(Iter b, Iter e) -> container::value_type>; -std::vector v = { /* ... */}; +std::vector v = { @\commentellip@ }; container c(7); // OK, deduces \tcode{int} for \tcode{T} auto d = container(v.begin(), v.end()); // OK, deduces \tcode{double} for \tcode{T} container e{5, 6}; // error, \tcode{int} is not an iterator \end{codeblock} \end{example} +\indextext{specifier|)}% \rSec1[dcl.enum]{Enumeration declarations}% \indextext{enumeration}% \indextext{\idxcode{\{\}}!enum declaration@\tcode{enum} declaration}% -\indextext{\idxcode{enum}!type~of} +\indextext{\idxcode{enum}!type of} \pnum An enumeration is a distinct type~(\ref{basic.compound}) with named @@ -2000,7 +1985,7 @@ \begin{codeblock} struct S { enum E : int {}; - enum E : int {}; // error: redeclaration of enumeration + enum E : int {}; // error: redeclaration of enumeration }; \end{codeblock} @@ -2013,14 +1998,12 @@ \pnum \indextext{constant!enumeration}% \indextext{enumeration}% -\indextext{enumeration!unscoped}% -\indextext{enumeration!scoped}% The enumeration type declared with an \grammarterm{enum-key} -of only \tcode{enum} is an \term{}{unscoped enumeration}, +of only \tcode{enum} is an \defnx{unscoped enumeration}{enumeration!unscoped}, and its \grammarterm{enumerator}{s} are \term{unscoped enumerators}. The \grammarterm{enum-key}{s} \tcode{enum class} and \tcode{enum struct} are semantically equivalent; an enumeration -type declared with one of these is a \term{scoped enumeration}, +type declared with one of these is a \defnx{scoped enumeration}{enumeration!scoped}, and its \grammarterm{enumerator}{s} are \term{scoped enumerators}. The optional \grammarterm{identifier} shall not be omitted in the declaration of a scoped enumeration. The \grammarterm{type-specifier-seq} of an \grammarterm{enum-base} @@ -2029,7 +2012,7 @@ not omit the \grammarterm{enum-base}. The identifiers in an \grammarterm{enumerator-list} are declared as constants, and can appear wherever constants are required. -\indextext{enumerator!value~of}% +\indextext{enumerator!value of}% An \grammarterm{enumerator-definition} with \tcode{=} gives the associated \grammarterm{enumerator} the value indicated by the \grammarterm{constant-expression}. @@ -2074,8 +2057,8 @@ declaration. \pnum -\indextext{\idxcode{enum}!type~of}% -\indextext{\idxcode{enum}!underlying~type|see{type, underlying}}% +\indextext{\idxcode{enum}!type of}% +\indextext{\idxcode{enum}!underlying type|see{type, underlying}}% Each enumeration defines a type that is different from all other types. Each enumeration also has an \defnx{underlying type}{type!underlying!enumeration}. The underlying type can be explicitly specified using an \grammarterm{enum-base}. @@ -2142,16 +2125,16 @@ \indextext{signed integer representation!signed magnitude}% For an enumeration whose underlying type is fixed, the values of the enumeration are the values of the underlying type. Otherwise, -for an enumeration where $e_\mathit{min}$ is the smallest enumerator and -$e_\mathit{max}$ is the largest, the values of the enumeration are the -values in the range $b_{min}$ to $b_{max}$, defined as follows: Let $K$ +for an enumeration where $e_\text{min}$ is the smallest enumerator and +$e_\text{max}$ is the largest, the values of the enumeration are the +values in the range $b_\text{min}$ to $b_\text{max}$, defined as follows: Let $K$ be 1 for a two's complement representation and 0 for a ones' complement -or sign-magnitude representation. $b_{max}$ is the smallest value -greater than or equal to $max(|e_{min}| - K, |e_{max}|)$ and equal to -$2^M-1$, where $M$ is a non-negative integer. $b_{min}$ is zero if -$e_{min}$ is non-negative and $-(b_{max}+K)$ otherwise. The size of the +or sign-magnitude representation. $b_\text{max}$ is the smallest value +greater than or equal to $max(|e_\text{min}| - K, |e_\text{max}|)$ and equal to +$2^M-1$, where $M$ is a non-negative integer. $b_\text{min}$ is zero if +$e_\text{min}$ is non-negative and $-(b_\text{max}+K)$ otherwise. The size of the smallest bit-field large enough to hold all the values of the -enumeration type is $max(M,1)$ if $b_{min}$ is zero and $M+1$ otherwise. +enumeration type is $max(M,1)$ if $b_\text{min}$ is zero and $M+1$ otherwise. It is possible to define an enumeration that has values not defined by any of its enumerators. If the \grammarterm{enumerator-list} is empty, the values of the enumeration are as if the enumeration had a single enumerator with @@ -2168,7 +2151,6 @@ The value of an enumerator or an object of an unscoped enumeration type is converted to an integer by integral promotion~(\ref{conv.prom}). \begin{example} - \indextext{example!enumeration}% \begin{codeblock} enum color { red, yellow, green=20, blue }; @@ -2176,7 +2158,6 @@ color* cp = &col; if (*cp == blue) // ... \end{codeblock} - makes \tcode{color} a type describing various colors, and then declares \tcode{col} as an object of that type, and \tcode{cp} as a pointer to an object of that type. The possible values of an object of type @@ -2185,36 +2166,28 @@ \tcode{0}, \tcode{1}, \tcode{20}, and \tcode{21}. Since enumerations are distinct types, objects of type \tcode{color} can be assigned only values of type \tcode{color}. - \begin{codeblock} -color c = 1; // error: type mismatch, - // no conversion from \tcode{int} to \tcode{color} - -int i = yellow; // OK: \tcode{yellow} converted to integral value \tcode{1} - // integral promotion +color c = 1; // error: type mismatch, no conversion from \tcode{int} to \tcode{color} +int i = yellow; // OK: \tcode{yellow} converted to integral value \tcode{1}, integral promotion \end{codeblock} - Note that this implicit \tcode{enum} to \tcode{int} conversion is not provided for a scoped enumeration: - \begin{codeblock} enum class Col { red, yellow, green }; int x = Col::red; // error: no \tcode{Col} to \tcode{int} conversion Col y = Col::red; if (y) { } // error: no \tcode{Col} to \tcode{bool} conversion \end{codeblock} - \end{example} \pnum -\indextext{class!scope~of enumerator}% +\indextext{class!scope of enumerator}% Each \grammarterm{enum-name} and each unscoped \grammarterm{enumerator} is declared in the scope that immediately contains the \grammarterm{enum-specifier}. Each scoped \grammarterm{enumerator} is declared in the scope of the enumeration. These names obey the scope rules defined for all names -in~(\ref{basic.scope}) and~(\ref{basic.lookup}). \begin{example} - +in~\ref{basic.scope} and~\ref{basic.lookup}. \begin{example} \begin{codeblock} enum direction { left='l', right='r' }; @@ -2228,7 +2201,7 @@ void h() { altitude a; // OK - a = high; // error: high not in scope + a = high; // error: \tcode{high} not in scope a = altitude::low; // OK } \end{codeblock} @@ -2352,7 +2325,6 @@ \grammarterm{namespace-definition} is itself a \grammarterm{declaration}, it follows that \grammarterm{namespace-definitions} can be nested. \begin{example} - \begin{codeblock} namespace Outer { int i; @@ -2376,13 +2348,13 @@ \begin{codeblock} namespace Q { namespace V { - void f(); // enclosing namespaces are the global namespace, \tcode{Q}, and \tcode{Q::V} + void f(); // enclosing namespaces are the global namespace, \tcode{Q}, and \tcode{Q::V} class C { void m(); }; } - void V::f() { // enclosing namespaces are the global namespace, \tcode{Q}, and \tcode{Q::V} - extern void h(); // ... so this declares \tcode{Q::V::h} + void V::f() { // enclosing namespaces are the global namespace, \tcode{Q}, and \tcode{Q::V} + extern void h(); // ... so this declares \tcode{Q::V::h} } - void V::C::m() { // enclosing namespaces are the global namespace, \tcode{Q}, and \tcode{Q::V} + void V::C::m() { // enclosing namespaces are the global namespace, \tcode{Q}, and \tcode{Q::V} } } \end{codeblock} @@ -2462,39 +2434,38 @@ replaced by \begin{ncsimplebnf} -\terminal{inline}\opt{} \terminal{namespace} \uniquens{} \terminal{\{ /* empty body */ \}}\br -\terminal{using namespace} \uniquens{} \terminal{;}\br -\terminal{namespace} \uniquens{} \terminal{\{} namespace-body \terminal{\}} +\terminal{inline}\opt{} \terminal{namespace} \terminal{\uniquens} \terminal{\{ /* empty body */ \}}\br +\terminal{using namespace} \terminal{\uniquens} \terminal{;}\br +\terminal{namespace} \terminal{\uniquens} \terminal{\{} namespace-body \terminal{\}} \end{ncsimplebnf} where \tcode{inline} appears if and only if it appears in the \grammarterm{unnamed-namespace-definition} -and all occurrences of \uniquens{} in a translation unit are replaced by +and all occurrences of \tcode{\uniquens} in a translation unit are replaced by the same identifier, and this identifier differs from all other identifiers in the translation unit. The optional \grammarterm{attribute-specifier-seq} in the \grammarterm{unnamed-namespace-definition} -appertains to \uniquens{}. +appertains to \tcode{\uniquens}. \begin{example} - \begin{codeblock} -namespace { int i; } // \uniquens\tcode{::i} -void f() { i++; } // \uniquens\tcode{::i++} +namespace { int i; } // \tcode{\uniquens::i} +void f() { i++; } // \tcode{\uniquens::i++} namespace A { namespace { - int i; // \tcode{A::}\uniquens\tcode{::i} - int j; // \tcode{A::}\uniquens\tcode{::j} + int i; // \tcode{A::\uniquens::i} + int j; // \tcode{A::\uniquens::j} } - void g() { i++; } // \tcode{A::}\uniquens\tcode{::i++} + void g() { i++; } // \tcode{A::\uniquens::i++} } using namespace A; void h() { - i++; // error: \uniquens\tcode{::i} or \tcode{A::}\uniquens\tcode{::i} - A::i++; // \tcode{A::}\uniquens\tcode{::i} - j++; // \tcode{A::}\uniquens\tcode{::j} + i++; // error: \tcode{\uniquens::i} or \tcode{A::\uniquens::i} + A::i++; // \tcode{A::\uniquens::i} + j++; // \tcode{A::\uniquens::j} } \end{codeblock} \end{example} @@ -2512,22 +2483,23 @@ that is an \grammarterm{opaque-enum-declaration}, declares (or redeclares) its \grammarterm{unqualified-id} or \grammarterm{identifier} as a member of \tcode{N}. -\begin{note} An explicit instantiation~(\ref{temp.explicit}) or +\begin{note} +An explicit instantiation~(\ref{temp.explicit}) or explicit specialization~(\ref{temp.expl.spec}) of a template does not introduce a name and thus may be declared using an \grammarterm{unqualified-id} in a member of the enclosing namespace set, -if the primary template is declared in an inline namespace. \end{note} +if the primary template is declared in an inline namespace. +\end{note} \begin{example} - \begin{codeblock} namespace X { - void f() { /* ... */ } // OK: introduces \tcode{X::f()} + void f() { @\commentellip@ } // OK: introduces \tcode{X::f()} namespace M { - void g(); // OK: introduces \tcode{X::M::g()} + void g(); // OK: introduces \tcode{X::M::g()} } using M::g; - void g(); // error: conflicts with \tcode{X::M::g()} + void g(); // error: conflicts with \tcode{X::M::g()} } \end{codeblock} \end{example} @@ -2540,21 +2512,20 @@ the definition appears after the point of declaration in a namespace that encloses the declaration's namespace. \begin{example} - \begin{codeblock} namespace Q { namespace V { void f(); } - void V::f() { /* ... */ } // OK - void V::g() { /* ... */ } // error: \tcode{g()} is not yet a member of \tcode{V} + void V::f() { @\commentellip@ } // OK + void V::g() { @\commentellip@ } // error: \tcode{g()} is not yet a member of \tcode{V} namespace V { void g(); } } namespace R { - void Q::V::g() { /* ... */ } // error: \tcode{R} doesn't enclose \tcode{Q} + void Q::V::g() { @\commentellip@ } // error: \tcode{R} doesn't enclose \tcode{Q} } \end{codeblock} \end{example} @@ -2601,8 +2572,8 @@ // \tcode{A::f}, \tcode{A::g} and \tcode{A::h} are not visible here X x; void g() { f(x); } // definition of \tcode{A::g} - void f(X) @\tcode{\{ /* ... */\}}@ // definition of \tcode{A::f} - void h(int) @\tcode{\{ /* ... */ \}}@ // definition of \tcode{A::h} + void f(X) { @\commentellip@ } // definition of \tcode{A::f} + void h(int) { @\commentellip@ } // definition of \tcode{A::h} // \tcode{A::f}, \tcode{A::g} and \tcode{A::h} are visible here and known to be friends } @@ -2657,12 +2628,12 @@ declarative region to refer only to the namespace to which it already refers. \begin{example} -the following declarations are well-formed: +The following declarations are well-formed: \begin{codeblock} -namespace Company_with_very_long_name { /* ... */ } +namespace Company_with_very_long_name { @\commentellip@ } namespace CWVLN = Company_with_very_long_name; -namespace CWVLN = Company_with_very_long_name; // OK: duplicate +namespace CWVLN = Company_with_very_long_name; // OK: duplicate namespace CWVLN = CWVLN; \end{codeblock} \end{example} @@ -2707,7 +2678,7 @@ does not declare its enumerators in the \grammarterm{using-declaration}{'s} declarative region. \end{note} -\indextext{inheritance!\idxgram{using-declaration}~and}% +\indextext{inheritance!\idxgram{using-declaration} and}% If the \grammarterm{using-declarator} names a constructor, it declares that the class \term{inherits} the set of constructor declarations introduced by the \grammarterm{using-declarator} from the nominated base class. @@ -2748,11 +2719,10 @@ using bases::g...; }; -X x; // OK: \tcode{B::g} and \tcode{D::g} introduced +X x; // OK: \tcode{B::g} and \tcode{D::g} introduced \end{codeblock} \end{example} \begin{example} - \begin{codeblock} class C { int g(); @@ -2811,7 +2781,6 @@ A \grammarterm{using-declaration} that names a class member shall be a \grammarterm{member-declaration}. \begin{example} - \begin{codeblock} struct X { int i; @@ -2819,10 +2788,8 @@ }; void f() { - using X::i; // error: \tcode{X::i} is a class member - // and this is not a member declaration. - using X::s; // error: \tcode{X::s} is a class member - // and this is not a member declaration. + using X::i; // error: \tcode{X::i} is a class member and this is not a member declaration. + using X::s; // error: \tcode{X::s} is a class member and this is not a member declaration. } \end{codeblock} \end{example} @@ -2832,7 +2799,6 @@ explicit qualification just like other member names~(\ref{namespace.qual}). \begin{example} - \begin{codeblock} void f(); @@ -2841,14 +2807,14 @@ } namespace X { - using ::f; // global \tcode{f} - using A::g; // \tcode{A}'s \tcode{g} + using ::f; // global \tcode{f} + using A::g; // \tcode{A}'s \tcode{g} } void h() { - X::f(); // calls \tcode{::f} - X::g(); // calls \tcode{A::g} + X::f(); // calls \tcode{::f} + X::g(); // calls \tcode{A::g} } \end{codeblock} \end{example} @@ -2858,14 +2824,13 @@ therefore be used repeatedly where (and only where) multiple declarations are allowed. \begin{example} - \begin{codeblock} namespace A { int i; } namespace A1 { - using A::i, A::i; // OK: double declaration + using A::i, A::i; // OK: double declaration } struct B { @@ -2873,7 +2838,7 @@ }; struct X : B { - using B::i, B::i; // error: double member declaration + using B::i, B::i; // error: double member declaration }; \end{codeblock} \end{example} @@ -2896,19 +2861,17 @@ void f(int); } -using A::f; // \tcode{f} is a synonym for \tcode{A::f}; - // that is, for \tcode{A::f(int)}. +using A::f; // \tcode{f} is a synonym for \tcode{A::f}; that is, for \tcode{A::f(int)}. namespace A { void f(char); } void foo() { - f('a'); // calls \tcode{f(int)}, -} // even though \tcode{f(char)} exists. + f('a'); // calls \tcode{f(int)}, even though \tcode{f(char)} exists. +} void bar() { - using A::f; // \tcode{f} is a synonym for \tcode{A::f}; - // that is, for \tcode{A::f(int)} and \tcode{A::f(char)}. + using A::f; // \tcode{f} is a synonym for \tcode{A::f}; that is, for \tcode{A::f(int)} and \tcode{A::f(char)}. f('a'); // calls \tcode{f(char)} } \end{codeblock} @@ -3001,7 +2964,7 @@ \end{note} \pnum -\indextext{name~hiding!using-declaration and}% +\indextext{name hiding!using-declaration and}% When a \grammarterm{using-declarator} brings declarations from a base class into a derived class, member functions and member function templates in the derived class override and/or hide member functions and member @@ -3051,14 +3014,14 @@ using B1::B1; using B2::B2; }; -D1 d1(0); // ill-formed: ambiguous +D1 d1(0); // ill-formed: ambiguous struct D2 : B1, B2 { using B1::B1; using B2::B2; - D2(int); // OK: \tcode{D2::D2(int)} hides \tcode{B1::B1(int)} and \tcode{B2::B2(int)} + D2(int); // OK: \tcode{D2::D2(int)} hides \tcode{B1::B1(int)} and \tcode{B2::B2(int)} }; -D2 d2(0); // calls \tcode{D2::D2(int)} +D2 d2(0); // calls \tcode{D2::D2(int)} \end{codeblock} \end{example} @@ -3092,12 +3055,15 @@ member function, then all functions named shall be accessible. The base class members mentioned by a \grammarterm{using-declarator} shall be visible in the scope of at least one of the direct base classes of the -class where the \grammarterm{using-declarator} is specified. \begin{note} +class where the \grammarterm{using-declarator} is specified. + +\pnum +\begin{note} Because a \grammarterm{using-declarator} designates a base class member (and not a member subobject or a member function of a base class subobject), a \grammarterm{using-declarator} cannot be used to resolve -inherited member ambiguities. For example, - +inherited member ambiguities. +\begin{example} \begin{codeblock} struct A { int x(); }; struct B : A { }; @@ -3111,9 +3077,10 @@ int x(double); }; int f(D* d) { - return d->x(); // ambiguous: \tcode{B::x} or \tcode{C::x} + return d->x(); // error: overload resolution selects \tcode{A::x}, but \tcode{A} is an ambiguous base class } \end{codeblock} +\end{example} \end{note} \pnum @@ -3433,10 +3400,9 @@ \indextext{specification!linkage!implementation-defined}% Every implementation shall provide for linkage to functions written in the C programming language, -\indextext{C!linkage~to}% +\indextext{C!linkage to}% \tcode{"C"}, and linkage to \Cpp functions, \tcode{"C++"}. \begin{example} - \begin{codeblock} complex sqrt(complex); // \Cpp linkage by default extern "C" { @@ -3456,73 +3422,64 @@ external linkage, and variable names with external linkage declared within the \grammarterm{linkage-specification}. \begin{example} - \begin{codeblock} -extern "C" void f1(void(*pf)(int)); - // the name \tcode{f1} and its function type have C language - // linkage; \tcode{pf} is a pointer to a C function +extern "C" // the name \tcode{f1} and its function type have C language linkage; + void f1(void(*pf)(int)); // \tcode{pf} is a pointer to a C function + extern "C" typedef void FUNC(); FUNC f2; // the name \tcode{f2} has \Cpp language linkage and the // function's type has C language linkage -extern "C" FUNC f3; // the name of function \tcode{f3} and the function's type - // have C language linkage -void (*pf2)(FUNC*); // the name of the variable \tcode{pf2} has \Cpp linkage and - // the type of \tcode{pf2} is pointer to \Cpp function that - // takes one parameter of type pointer to C function + +extern "C" FUNC f3; // the name of function \tcode{f3} and the function's type have C language linkage + +void (*pf2)(FUNC*); // the name of the variable \tcode{pf2} has \Cpp linkage and the type + // of \tcode{pf2} is ``pointer to \Cpp function that takes one parameter of type + // pointer to C function'' extern "C" { - static void f4(); // the name of the function f4 has - // internal linkage (not C language - // linkage) and the function's type - // has C language linkage. + static void f4(); // the name of the function \tcode{f4} has internal linkage (not C language linkage) + // and the function's type has C language linkage. } extern "C" void f5() { - extern void f4(); // OK: Name linkage (internal) - // and function type linkage (C - // language linkage) obtained from - // previous declaration. + extern void f4(); // OK: Name linkage (internal) and function type linkage (C language linkage) + // obtained from previous declaration. } -extern void f4(); // OK: Name linkage (internal) - // and function type linkage (C - // language linkage) obtained from - // previous declaration. +extern void f4(); // OK: Name linkage (internal) and function type linkage (C language linkage) + // obtained from previous declaration. void f6() { - extern void f4(); // OK: Name linkage (internal) - // and function type linkage (C - // language linkage) obtained from - // previous declaration. + extern void f4(); // OK: Name linkage (internal) and function type linkage (C language linkage) + // obtained from previous declaration. } \end{codeblock} \end{example} -\indextext{class!linkage~specification}% +\indextext{class!linkage specification}% A C language linkage is ignored in determining the language linkage of the names of class members and the function type of class member functions. \begin{example} - \begin{codeblock} extern "C" typedef void FUNC_c(); + class C { - void mf1(FUNC_c*); // the name of the function \tcode{mf1} and the member - // function's type have \Cpp language linkage; the - // parameter has type pointer to C function - FUNC_c mf2; // the name of the function \tcode{mf2} and the member - // function's type have \Cpp language linkage - static FUNC_c* q; // the name of the data member \tcode{q} has \Cpp language - // linkage and the data member's type is pointer to - // C function + void mf1(FUNC_c*); // the name of the function \tcode{mf1} and the member function's type have + // \Cpp language linkage; the parameter has type ``pointer to C function'' + + FUNC_c mf2; // the name of the function \tcode{mf2} and the member function's type have + // \Cpp language linkage + + static FUNC_c* q; // the name of the data member \tcode{q} has \Cpp language linkage and + // the data member's type is ``pointer to C function'' }; extern "C" { class X { - void mf(); // the name of the function \tcode{mf} and the member - // function's type have \Cpp language linkage - void mf2(void(*)()); // the name of the function \tcode{mf2} has \Cpp language - // linkage; the parameter has type pointer to - // C function + void mf(); // the name of the function \tcode{mf} and the member function's type have + // \Cpp language linkage + void mf2(void(*)()); // the name of the function \tcode{mf2} has \Cpp language linkage; + // the parameter has type ``pointer to C function'' }; } \end{codeblock} @@ -3535,7 +3492,7 @@ namespace and the declarations give the names different language linkages, the program is ill-formed; no diagnostic is required if the declarations appear in different translation units. -\indextext{consistency!linkage~specification}% +\indextext{consistency!linkage specification}% Except for functions with \Cpp linkage, a function declaration without a linkage specification shall not precede the first linkage specification for that function. A function can be declared without a linkage @@ -3544,7 +3501,7 @@ by such a function declaration. \pnum -\indextext{function!linkage~specification overloaded}% +\indextext{function!linkage specification overloaded}% At most one function with a particular name can have C language linkage. Two declarations for a function with C language linkage with the same function name (ignoring the namespace names that qualify it) that appear @@ -3580,8 +3537,7 @@ namespace B { extern "C" int f(); // \tcode{A::f} and \tcode{B::f} refer to the same function - extern "C" int g() { return 1; } // ill-formed, the function \tcode{g} - // with C language linkage has two definitions + extern "C" int g() { return 1; } // ill-formed, the function \tcode{g} with C language linkage has two definitions } int A::f() { return 98; } // definition for the function \tcode{f} with C language linkage @@ -3619,10 +3575,10 @@ \end{note} \pnum -\indextext{object!linkage~specification}% +\indextext{object!linkage specification}% \indextext{linkage!implementation-defined object}% Linkage from \Cpp to objects defined in other languages and to objects -defined in \Cpp from other languages is implemen\-tation-defined and +defined in \Cpp from other languages is \impldef{linkage of objects between \Cpp and other languages} and language-dependent. Only where the object layout strategies of two language implementations are similar enough can such linkage be achieved.% @@ -3725,11 +3681,11 @@ \end{note} \begin{example} \begin{codeblock} -[[using CC: opt(1), debug]] // same as \tcode{[[CC::opt(1), CC::debug]]} +[[using CC: opt(1), debug]] // same as \tcode{[[CC::opt(1), CC::debug]]} void f() {} -[[using CC: opt(1)]] [[CC::debug]] // same as \tcode{[[CC::opt(1)]] [[CC::debug]]} +[[using CC: opt(1)]] [[CC::debug]] // same as \tcode{[[CC::opt(1)]] [[CC::debug]]} void g() {} -[[using CC: CC::opt(1)]] // error: cannot combine \tcode{using} and scoped attribute token +[[using CC: CC::opt(1)]] // error: cannot combine \tcode{using} and scoped attribute token void h() {} \end{codeblock} \end{example} @@ -3790,11 +3746,9 @@ int p[10]; void f() { int x = 42, y[5]; - int(p[[x] { return x; }()]); // error: invalid attribute on a nested - // \grammarterm{declarator-id} and not a function-style cast of - // an element of \tcode{p}. - y[[] { return 2; }()] = 2; // error even though attributes are not allowed - // in this context. + int(p[[x] { return x; }()]); // error: invalid attribute on a nested \grammarterm{declarator-id} and + // not a function-style cast of an element of \tcode{p}. + y[[] { return 2; }()] = 2; // error even though attributes are not allowed in this context. int i [[vendor::attr([[]])]]; // well-formed implementation-defined attribute. } \end{codeblock} @@ -3851,8 +3805,7 @@ struct alignas(8) S {}; struct alignas(1) U { S s; -}; // Error: \tcode{U} specifies an alignment that is less strict than - // if the \tcode{alignas(1)} were omitted. +}; // error: \tcode{U} specifies an alignment that is less strict than if the \tcode{alignas(1)} were omitted. \end{codeblock} \end{example} @@ -3868,15 +3821,14 @@ No diagnostic is required if declarations of an entity have different \grammarterm{alignment-specifier}{s} in different translation units. - \begin{example} \begin{codeblock} // Translation unit \#1: struct S { int x; } s, *p = &s; // Translation unit \#2: -struct alignas(16) S; // error: definition of \tcode{S} lacks alignment; no -extern S* p; // diagnostic required +struct alignas(16) S; // error: definition of \tcode{S} lacks alignment; no diagnostic required +extern S* p; \end{codeblock} \end{example} @@ -3884,7 +3836,6 @@ \begin{example} An aligned buffer with an alignment requirement of \tcode{A} and holding \tcode{N} elements of type \tcode{T} can be declared as: - \begin{codeblock} alignas(T) alignas(A) T buffer[N]; \end{codeblock} @@ -3896,11 +3847,11 @@ \pnum \begin{example} \begin{codeblock} -alignas(double) void f(); // error: alignment applied to function -alignas(double) unsigned char c[sizeof(double)]; // array of characters, suitably aligned for a \tcode{double} -extern unsigned char c[sizeof(double)]; // no \tcode{alignas} necessary +alignas(double) void f(); // error: alignment applied to function +alignas(double) unsigned char c[sizeof(double)]; // array of characters, suitably aligned for a \tcode{double} +extern unsigned char c[sizeof(double)]; // no \tcode{alignas} necessary alignas(float) - extern unsigned char c[sizeof(double)]; // error: different alignment in declaration + extern unsigned char c[sizeof(double)]; // error: different alignment in declaration \end{codeblock} \end{example} @@ -3969,14 +3920,12 @@ } \end{codeblock} -\pnum The \tcode{carries_dependency} attribute on function \tcode{f} means that the return value carries a dependency out of \tcode{f}, so that the implementation need not constrain ordering upon return from \tcode{f}. Implementations of \tcode{f} and its caller may choose to preserve dependencies instead of emitting hardware memory ordering instructions (a.k.a. fences). -\pnum Function \tcode{g}'s second parameter has a \tcode{carries_dependency} attribute, but its first parameter does not. Therefore, function \tcode{h}'s first call to \tcode{g} carries a dependency into \tcode{g}, but its second call does not. The @@ -3992,7 +3941,7 @@ \pnum The \grammarterm{attribute-token} \tcode{deprecated} can be used to mark names and entities -whose use is still allowed, but is discouraged for some reason. \begin{note} in particular, +whose use is still allowed, but is discouraged for some reason. \begin{note} In particular, \tcode{deprecated} is appropriate for names and entities that are deemed obsolescent or unsafe. \end{note} It shall appear at most once in each \grammarterm{attribute-list}. An \grammarterm{attribute-argument-clause} may be present and, if present, it shall have the form: @@ -4000,7 +3949,7 @@ \begin{codeblock} ( @\grammarterm{string-literal}@ ) \end{codeblock} -\begin{note} the \grammarterm{string-literal} in the \grammarterm{attribute-argument-clause} +\begin{note} The \grammarterm{string-literal} in the \grammarterm{attribute-argument-clause} could be used to explain the rationale for deprecation and/or to suggest a replacing entity. \end{note} @@ -4017,7 +3966,7 @@ a template specialization. \pnum -A name or entity declared without the \tcode{deprecated} attribute can later be re-declared +A name or entity declared without the \tcode{deprecated} attribute can later be redeclared with the attribute and vice-versa. \begin{note} Thus, an entity initially declared without the attribute can be marked as deprecated by a subsequent redeclaration. However, after an entity is marked as deprecated, later redeclarations do not un-deprecate the entity. \end{note} @@ -4070,11 +4019,11 @@ case 2: g(); [[fallthrough]]; - case 3: // warning on fallthrough discouraged + case 3: // warning on fallthrough discouraged h(); - case 4: // implementation may warn on fallthrough + case 4: // implementation may warn on fallthrough i(); - [[fallthrough]]; // ill-formed + [[fallthrough]]; // ill-formed } } \end{codeblock} @@ -4147,7 +4096,7 @@ \pnum \begin{example} \begin{codeblock} -struct [[nodiscard]] error_info { /*...*/ }; +struct [[nodiscard]] error_info { @\commentellip@ }; error_info enable_missile_safety_mode(); void launch_missiles(); void test_missiles() { @@ -4155,7 +4104,7 @@ launch_missiles(); } error_info &foo(); -void f() { foo(); } // reference type, warning not encouraged +void f() { foo(); } // reference type, warning not encouraged \end{codeblock} \end{example} @@ -4182,10 +4131,10 @@ \begin{example} \begin{codeblock} [[ noreturn ]] void f() { - throw "error"; // OK + throw "error"; // OK } -[[ noreturn ]] void q(int i) { // behavior is undefined if called with an argument \tcode{<= 0} +[[ noreturn ]] void q(int i) { // behavior is undefined if called with an argument \tcode{<= 0} if (i > 0) throw "positive"; } diff --git a/source/declarators.tex b/source/declarators.tex index 836294292c..0dff1ac97b 100644 --- a/source/declarators.tex +++ b/source/declarators.tex @@ -4,7 +4,7 @@ \gramSec[gram.decl]{Declarators} -\indextext{initialization!class~object|seealso{constructor}}% +\indextext{initialization!class object|seealso{constructor}}% \indextext{\idxcode{*}|see{declarator, pointer}} \indextext{\idxcode{\&}|see{declarator, reference}}% \indextext{\idxcode{::*}|see{declarator, pointer to member}}% @@ -75,23 +75,23 @@ they do not have the same meaning, as in \begin{codeblock} struct S { ... }; -S S, T; // declare two instances of \tcode{struct S} +S S, T; // declare two instances of \tcode{struct S} \end{codeblock} which is not equivalent to \begin{codeblock} struct S { ... }; S S; -S T; // error +S T; // error \end{codeblock} Another exception is when \tcode{T} is \tcode{auto}~(\ref{dcl.spec.auto}), for example: \begin{codeblock} -auto i = 1, j = 2.0; // error: deduced types for \tcode{i} and \tcode{j} do not match +auto i = 1, j = 2.0; // error: deduced types for \tcode{i} and \tcode{j} do not match \end{codeblock} as opposed to \begin{codeblock} -auto i = 1; // OK: \tcode{i} deduced to have type \tcode{int} -auto j = 2.0; // OK: \tcode{j} deduced to have type \tcode{double} +auto i = 1; // OK: \tcode{i} deduced to have type \tcode{int} +auto j = 2.0; // OK: \tcode{j} deduced to have type \tcode{double} \end{codeblock} \end{note} @@ -162,7 +162,7 @@ \rSec1[dcl.name]{Type names} \pnum -\indextext{type~name}% +\indextext{type name}% To specify type conversions explicitly, \indextext{operator!cast}% and as an argument of @@ -227,8 +227,7 @@ The named type is then the same as the type of the hypothetical identifier. \begin{example} - -\indextext{example!type~name}% +\indextext{example!type name}% \indextext{example!declarator}% \begin{codeblock} int // \tcode{int i} @@ -238,7 +237,6 @@ int *() // \tcode{int *f()} int (*)(double) // \tcode{int (*pf)(double)} \end{codeblock} - name respectively the types ``\tcode{int}'', ``pointer to @@ -261,8 +259,8 @@ (\ref{dcl.typedef}). \rSec1[dcl.ambig.res]{Ambiguity resolution}% -\indextext{ambiguity!declaration~versus cast}% -\indextext{declaration!parentheses~in} +\indextext{ambiguity!declaration versus cast}% +\indextext{declaration!parentheses in} \pnum The ambiguity arising from the similarity between a function-style cast and @@ -280,18 +278,17 @@ list-initialization syntax, or by use of a non-function-style cast. \end{note} \begin{example} - \begin{codeblock} struct S { S(int); }; void foo(double a) { - S w(int(a)); // function declaration - S x(int()); // function declaration - S y((int(a))); // object declaration - S y((int)a); // object declaration - S z = int(a); // object declaration + S w(int(a)); // function declaration + S x(int()); // function declaration + S y((int(a))); // object declaration + S y((int)a); // object declaration + S z = int(a); // object declaration } \end{codeblock} \end{example} @@ -353,7 +350,7 @@ \begin{codeblock} class C { }; void f(int(C)) { } // \tcode{void f(int(*fp)(C c)) \{ \}} - // not: \tcode{void f(int C)}; + // not: \tcode{void f(int C) \{ \}} int g(C); @@ -373,7 +370,7 @@ \end{example} \rSec1[dcl.meaning]{Meaning of declarators}% -\indextext{declarator!meaning~of|(} +\indextext{declarator!meaning of|(} \pnum \indextext{declaration!type}% @@ -468,7 +465,7 @@ determines the type \tcode{T}. \begin{example} -in the declaration +In the declaration \begin{codeblock} int unsigned i; @@ -501,7 +498,7 @@ has the form \begin{ncsimplebnf} -( D1 ) +\terminal{(} \terminal{D1} \terminal{)} \end{ncsimplebnf} the type of the contained @@ -509,12 +506,10 @@ is the same as that of the contained \grammarterm{declarator-id} in the declaration - \begin{codeblock} T D1 \end{codeblock} - -\indextext{declaration!parentheses~in}% +\indextext{declaration!parentheses in}% Parentheses do not alter the type of the embedded \grammarterm{declarator-id}, but they can alter the binding of complex declarators. @@ -537,14 +532,14 @@ and the type of the identifier in the declaration \tcode{T} \tcode{D1} -is ``\nonterminal{derived-declarator-type-list} +is ``\placeholder{derived-declarator-type-list} \tcode{T}'', then the type of the identifier of \tcode{D} -is ``\nonterminal{derived-declarator-type-list cv-qualifier-seq} pointer to +is ``\placeholder{derived-declarator-type-list} \grammarterm{cv-qualifier-seq} pointer to \tcode{T}''. \indextext{declaration!pointer}% -\indextext{declaration!constant~pointer}% +\indextext{declaration!constant pointer}% The \grammarterm{cv-qualifier}{s} apply to the pointer and not to the object pointed to. @@ -552,7 +547,7 @@ \pnum \begin{example} -the declarations +The declarations \indextext{example!\idxcode{const}}% \indextext{example!constant pointer}% \begin{codeblock} @@ -614,8 +609,7 @@ or allow it to be changed through a cv-unqualified pointer later, for example: \begin{codeblock} -*ppc = &ci; // OK, but would make \tcode{p} point to \tcode{ci} ... - // ... because of previous error +*ppc = &ci; // OK, but would make \tcode{p} point to \tcode{ci} because of previous error *p = 5; // clobber \tcode{ci} \end{codeblock} \end{example} @@ -652,11 +646,11 @@ and the type of the identifier in the declaration \tcode{T} \tcode{D1} -is ``\nonterminal{derived-declarator-type-list} +is ``\placeholder{derived-declarator-type-list} \tcode{T}'', then the type of the identifier of \tcode{D} -is ``\nonterminal{derived-declarator-type-list} reference to +is ``\placeholder{derived-declarator-type-list} reference to \tcode{T}''. The optional \grammarterm{attribute-specifier-seq} appertains to the reference type. Cv-qualified references are ill-formed except when the cv-qualifiers @@ -681,13 +675,13 @@ \end{note} \indextext{\idxcode{void\&}}% A declarator that specifies the type -``reference to \cv{} \tcode{void}'' +``reference to \cv{}~\tcode{void}'' is ill-formed. \pnum -\indextext{lvalue~reference}% -\indextext{rvalue~reference}% +\indextext{lvalue reference}% +\indextext{rvalue reference}% A reference type that is declared using \tcode{\&} is called an \term{lvalue reference}, and a reference type that is declared using \tcode{\&\&} is called an @@ -787,7 +781,7 @@ A reference shall be initialized to refer to a valid object or function. \begin{note} \indextext{reference!null}% -in particular, a null reference cannot exist in a well-defined program, +In particular, a null reference cannot exist in a well-defined program, because the only way to create such a reference would be to bind it to the ``object'' obtained by indirection through a null pointer, which causes undefined behavior. @@ -799,9 +793,9 @@ \indextext{reference collapsing}% If a \grammarterm{typedef-name}~(\ref{dcl.typedef}, \ref{temp.param}) or a \grammarterm{decltype-specifier}~(\ref{dcl.type.simple}) denotes a type \tcode{TR} that -is a reference to a type \tcode{T}, an attempt to create the type ``lvalue reference to \cv{} -\tcode{TR}'' creates the type ``lvalue reference to \tcode{T}'', while an attempt to create -the type ``rvalue reference to \cv{} \tcode{TR}'' creates the type \tcode{TR}. +is a reference to a type \tcode{T}, an attempt to create the type ``lvalue reference to \cv{}~\tcode{TR}'' +creates the type ``lvalue reference to \tcode{T}'', while an attempt to create +the type ``rvalue reference to \cv{}~\tcode{TR}'' creates the type \tcode{TR}. \begin{note} This rule is known as reference collapsing. \end{note} \begin{example} @@ -840,7 +834,7 @@ has the form \begin{ncsimplebnf} -nested-name-specifier \terminal{*} attribute-specifier-seq\opt cv-qualifier-seq\opt \tcode{D1} +nested-name-specifier \terminal{*} attribute-specifier-seq\opt cv-qualifier-seq\opt{} \terminal{D1} \end{ncsimplebnf} and the @@ -849,19 +843,19 @@ and the type of the identifier in the declaration \tcode{T} \tcode{D1} -is ``\nonterminal{derived-declarator-type-list} +is ``\placeholder{derived-declarator-type-list} \tcode{T}'', then the type of the identifier of \tcode{D} -is ``\nonterminal{derived-declarator-type-list cv-qualifier-seq} pointer to member of class -\nonterminal{nested-name-specifier} of type +is ``\placeholder{derived-declarator-type-list} \grammarterm{cv-qualifier-seq} pointer to member of class +\grammarterm{nested-name-specifier} of type \tcode{T}''. The optional \grammarterm{attribute-specifier-seq}~(\ref{dcl.attr.grammar}) appertains to the pointer-to-member. \pnum \begin{example}% -\indextext{example!pointer~to~member} +\indextext{example!pointer to member} \begin{codeblock} struct X { @@ -914,14 +908,11 @@ and \tcode{pmf} can be used like this: - \begin{codeblock} X obj; // ... -obj.*pmi = 7; // assign \tcode{7} to an integer - // member of \tcode{obj} -(obj.*pmf)(7); // call a function member of \tcode{obj} - // with the argument \tcode{7} +obj.*pmi = 7; // assign \tcode{7} to an integer member of \tcode{obj} +(obj.*pmf)(7); // call a function member of \tcode{obj} with the argument \tcode{7} \end{codeblock} \end{example} @@ -930,8 +921,7 @@ of a class (\ref{class.static}), a member with reference type, or -``\cv{} -\tcode{void}''. +``\cv{}~\tcode{void}''. \begin{note} See also~\ref{expr.unary} and~\ref{expr.mptr.oper}. @@ -960,18 +950,17 @@ \tcode{T} \tcode{D1} is -``\grammarterm{derived-declarator-type-list} +``\placeholder{derived-declarator-type-list} \tcode{T}'', then the type of the identifier of \tcode{D} is an array type; if the type of the identifier of \tcode{D} -contains the \tcode{auto} \nonterminal{type-specifier}, +contains the \tcode{auto} \grammarterm{type-specifier}, the program is ill-formed. \tcode{T} is called the array \term{element type}; -this type shall not be a reference type, the (possibly cv-qualified) type -\tcode{void}, +this type shall not be a reference type, \cv{}~\tcode{void}, a function type or an abstract class type. \indextext{declaration!array}% If the @@ -981,7 +970,7 @@ its value shall be greater than zero. The constant expression specifies the \indextext{array!bound}% -\indextext{bound,~of~array}% +\indextext{bound, of array}% \term{bound} of (number of elements in) the array. If the value of the constant expression is @@ -994,7 +983,7 @@ \tcode{N-1}, and the type of the identifier of \tcode{D} -is ``\nonterminal{derived-declarator-type-list} array of +is ``\placeholder{derived-declarator-type-list} array of \tcode{N} \tcode{T}''. An object of array type contains a contiguously allocated non-empty set of @@ -1004,24 +993,24 @@ Except as noted below, if the constant expression is omitted, the type of the identifier of \tcode{D} -is ``\nonterminal{derived-declarator-type-list} array of unknown bound of +is ``\placeholder{derived-declarator-type-list} array of unknown bound of \tcode{T}'', an incomplete object type. -The type ``\nonterminal{derived-declarator-type-list} array of +The type ``\placeholder{derived-declarator-type-list} array of \tcode{N} \tcode{T}'' is a different type from the type -``\nonterminal{derived-declarator-type-list} array of unknown bound of +``\placeholder{derived-declarator-type-list} array of unknown bound of \tcode{T}'', see~\ref{basic.types}. Any type of the form -``\nonterminal{cv-qualifier-seq} array of +``\grammarterm{cv-qualifier-seq} array of \tcode{N} \tcode{T}'' is adjusted to ``array of \tcode{N} -\nonterminal{cv-qualifier-seq} +\grammarterm{cv-qualifier-seq} \tcode{T}'', and similarly for ``array of unknown bound of @@ -1039,7 +1028,7 @@ An ``array of \tcode{N} -\nonterminal{cv-qualifier-seq} +\grammarterm{cv-qualifier-seq} \tcode{T}'' has cv-qualified type; see~\ref{basic.type.qualifier}. \end{note} @@ -1068,7 +1057,7 @@ when a declarator for a static data member is followed by a \grammarterm{brace-or-equal-initializer}~(\ref{class.mem}). In both cases the bound is calculated from the number -\indextext{array~size!default}% +\indextext{array size!default}% of initial elements (say, \tcode{N}) supplied @@ -1123,19 +1112,19 @@ static int y[10]; }; -int x[]; // OK: bound is 10 -int S::y[]; // OK: bound is 10 +int x[]; // OK: bound is 10 +int S::y[]; // OK: bound is 10 void f() { extern int x[]; - int i = sizeof(x); // error: incomplete object type + int i = sizeof(x); // error: incomplete object type } \end{codeblock} \end{example} \pnum \begin{note} -conversions affecting expressions of array type are described in~\ref{conv.array}. +Conversions affecting expressions of array type are described in~\ref{conv.array}. Objects of array types cannot be modified, see~\ref{basic.lval}. \end{note} @@ -1148,7 +1137,7 @@ in such a way that \tcode{E1[E2]} is identical to -\tcode{*((E1)+(E2))}. +\tcode{*((E1)+(E2))}~(\ref{expr.sub}). Because of the conversion rules that apply to \tcode{+}, @@ -1166,8 +1155,10 @@ Therefore, despite its asymmetric appearance, subscripting is a commutative operation. +\end{note} \pnum +\begin{note} A consistent rule is followed for \indextext{array!multidimensional}% multidimensional arrays. @@ -1177,7 +1168,7 @@ \textit{n}-dimensional array of rank -$i \times j \times \ldots \times k$, +$i \times j \times \dotsb \times k$, then \tcode{E} appearing in an expression @@ -1185,7 +1176,7 @@ is converted to a pointer to an $(n-1)$-dimensional array with rank -$j \times \ldots \times k$. +$j \times \dotsb \times k$. If the \tcode{*} operator, either explicitly @@ -1193,10 +1184,8 @@ is applied to this pointer, the result is the pointed-to $(n-1)$-dimensional array, which itself is immediately converted into a pointer. - -\pnum \begin{example} -consider +Consider \begin{codeblock} int x[3][5]; @@ -1236,7 +1225,7 @@ \begin{note} It follows from all this that arrays in \Cpp are stored row-wise (last subscript varies fastest) -\indextext{array!storage~of}% +\indextext{array!storage of}% and that the first subscript in the declaration helps determine the amount of storage consumed by an array but plays no other part in subscript calculations. @@ -1265,14 +1254,14 @@ \tcode{T} \tcode{D1} is -``\grammarterm{derived-declarator-type-list} +``\placeholder{derived-declarator-type-list} \tcode{T}'', the type of the \grammarterm{declarator-id} in \tcode{D} is -``\grammarterm{derived-declarator-type-list} +``\placeholder{derived-declarator-type-list} \tcode{noexcept}\opt function of (\grammarterm{parameter-declaration-clause} ) @@ -1303,14 +1292,14 @@ \tcode{T} \tcode{D1} is -``\grammarterm{derived-declarator-type-list} \tcode{T}'', +``\placeholder{derived-declarator-type-list} \tcode{T}'', \tcode{T} shall be the single \grammarterm{type-specifier} \tcode{auto}. The type of the \grammarterm{declarator-id} in \tcode{D} is -``\grammarterm{derived-declarator-type-list} +``\placeholder{derived-declarator-type-list} \tcode{noexcept}\opt function of (\grammarterm{parameter-declaration-clause}) @@ -1330,7 +1319,7 @@ \indextext{declaration!function}% \begin{bnf} \nontermdef{parameter-declaration-clause}\br -parameter-declaration-list\opt{} \terminal{...}\opt\br + parameter-declaration-list\opt{} \terminal{...}\opt\br parameter-declaration-list \terminal{, ...} \end{bnf} @@ -1358,12 +1347,12 @@ determines the arguments that can be specified, and their processing, when the function is called. \begin{note} \indextext{conversion!argument}% -the +The \grammarterm{parameter-declaration-clause} is used to convert the arguments specified on the function call; see~\ref{expr.call}. \end{note} -\indextext{argument~list!empty}% +\indextext{argument list!empty}% If the \grammarterm{parameter-declaration-clause} is empty, the function takes no arguments. @@ -1375,11 +1364,11 @@ \tcode{void}. If the \grammarterm{parameter-declaration-clause} -\indextext{argument~type!unknown}% +\indextext{argument type!unknown}% \indextext{\idxcode{...}|see{ellipsis}}% -\indextext{declaration!ellipsis~in function}% -\indextext{argument~list!variable}% -\indextext{parameter~list!variable}% +\indextext{declaration!ellipsis in function}% +\indextext{argument list!variable}% +\indextext{parameter list!variable}% terminates with an ellipsis or a function parameter pack~(\ref{temp.variadic}), the number of arguments shall be equal to or greater than the number of parameters that do not have a default @@ -1391,8 +1380,8 @@ ``\tcode{...}''. \begin{example} \indextext{example!ellipsis}% -\indextext{example!variable parameter~list}% -the declaration +\indextext{example!variable parameter list}% +The declaration \begin{codeblock} int printf(const char*, ...); @@ -1432,9 +1421,9 @@ and \grammarterm{declarator}. After determining the type of each parameter, any parameter -\indextext{array!parameter~of~type}% +\indextext{array!parameter of type}% of type ``array of \tcode{T}'' or -\indextext{function!parameter~of~type}% +\indextext{function!parameter of type}% of function type \tcode{T} is adjusted to be ``pointer to \tcode{T}''. After producing the list of parameter types, @@ -1487,7 +1476,7 @@ in a function declarator is not the same as adding cv-qualification on top of the function type. In the latter case, the cv-qualifiers are ignored. -\begin{note} a function type that has a \grammarterm{cv-qualifier-seq} is not a +\begin{note} A function type that has a \grammarterm{cv-qualifier-seq} is not a cv-qualified type; there are no cv-qualified function types. \end{note} \begin{example} @@ -1513,7 +1502,7 @@ \pnum \begin{example} \indextext{example!function declaration}% -the declaration +The declaration \begin{codeblock} int fseek(FILE*, long, int); @@ -1526,8 +1515,8 @@ \end{example} \pnum -\indextext{function~return~type|see{return~type}}% -\indextext{return~type}% +\indextext{function return type|see{return type}}% +\indextext{return type}% Functions shall not have a return type of type array or function, although they may have a return type of type pointer or reference to such things. There shall be no arrays of functions, although there can be arrays of pointers @@ -1570,7 +1559,7 @@ \pnum \begin{example} -the declaration +The declaration \indextext{example!declaration}% \begin{codeblock} @@ -1705,9 +1694,9 @@ Default arguments will be used in calls where trailing arguments are missing. \pnum -\indextext{argument!example~of default}% +\indextext{argument!example of default}% \begin{example} -the declaration +The declaration \begin{codeblock} void point(int = 3, int = 4); @@ -1780,16 +1769,14 @@ void f(int, int = 7); void h() { f(3); // OK, calls \tcode{f(3, 7)} - void f(int = 1, int); // error: does not use default - // from surrounding scope + void f(int = 1, int); // error: does not use default from surrounding scope } void m() { void f(int, int); // has no defaults f(4); // error: wrong number of arguments void f(int, int = 5); // OK f(4); // OK, calls \tcode{f(4, 5);} - void f(int, int = 5); // error: cannot redefine, even to - // same value + void f(int, int = 5); // error: cannot redefine, even to same value } void n() { f(6); // OK, calls \tcode{f(6, 7)} @@ -1805,9 +1792,9 @@ declaration of the function or function template in the translation unit. \pnum -\indextext{argument!type~checking~of default}% -\indextext{argument!binding~of default}% -\indextext{argument!evaluation~of default}% +\indextext{argument!type checking of default}% +\indextext{argument!binding of default}% +\indextext{argument!evaluation of default}% The default argument has the same semantic constraints as the initializer in a declaration of a variable of the parameter type, using the @@ -1819,8 +1806,8 @@ arguments in function templates and in member functions of class templates are performed as described in~\ref{temp.inst}. \begin{example} -in the following code, -\indextext{argument!example~of default}% +In the following code, +\indextext{argument!example of default}% \tcode{g} will be called with the value \tcode{f(2)}: @@ -1860,17 +1847,14 @@ shall be specified on the initial declaration of the member function within the class template. \begin{example} - \begin{codeblock} class C { void f(int i = 3); void g(int i, int j = 99); }; -void C::f(int i = 3) { // error: default argument already -} // specified in class scope -void C::g(int i = 88, int j) { // in this translation unit, -} // \tcode{C::g} can be called with no argument +void C::f(int i = 3) {} // error: default argument already specified in class scope +void C::g(int i = 88, int j) {} // in this translation unit, \tcode{C::g} can be called with no argument \end{codeblock} \end{example} @@ -1878,12 +1862,11 @@ A local variable shall not appear as a potentially-evaluated expression in a default argument. \begin{example} - \begin{codeblock} void f() { int i; - extern void g(int x = i); // error - extern void h(int x = sizeof(i)); // OK + extern void g(int x = i); // error + extern void h(int x = sizeof(i)); // OK // ... } \end{codeblock} @@ -1899,28 +1882,26 @@ \begin{codeblock} class A { - void f(A* p = this) { } // error + void f(A* p = this) { } // error }; \end{codeblock} \end{example} \end{note} \pnum -\indextext{argument!evaluation~of default}% +\indextext{argument!evaluation of default}% A default argument is evaluated each time the function is called with no argument for the corresponding parameter. -\indextext{argument!scope~of default}% +\indextext{argument!scope of default}% A parameter shall not appear as a potentially-evaluated expression in a default argument. -\indextext{argument~and~name~hiding!default}% +\indextext{argument and name hiding!default}% Parameters of a function declared before a default argument are in scope and can hide namespace and class member names. \begin{example} - \begin{codeblock} int a; -int f(int a, int b = a); // error: parameter \tcode{a} - // used as default argument +int f(int a, int b = a); // error: parameter \tcode{a} used as default argument typedef int I; int g(float I, int b = I(2)); // error: parameter \tcode{I} found int h(int a, int b = sizeof(a)); // OK, unevaluated operand @@ -1930,24 +1911,21 @@ the \grammarterm{id-expression} of a class member access expression (\ref{expr.ref}) or unless it is used to form a pointer to member (\ref{expr.unary.op}). \begin{example} -the declaration of +The declaration of \tcode{X::mem1()} in the following example is ill-formed because no object is supplied for the non-static member \tcode{X::a} used as an initializer. - \begin{codeblock} int b; class X { int a; - int mem1(int i = a); // error: non-static member \tcode{a} - // used as default argument - int mem2(int i = b); // OK; use \tcode{X::b} + int mem1(int i = a); // error: non-static member \tcode{a} used as default argument + int mem2(int i = b); // OK; use \tcode{X::b} static int b; }; \end{codeblock} - The declaration of \tcode{X::mem2()} is meaningful, however, since no object is needed to access the static member @@ -1957,17 +1935,16 @@ A default argument is not part of the type of a function. \begin{example} - \begin{codeblock} int f(int = 0); void h() { int j = f(1); - int k = f(); // OK, means \tcode{f(0)} + int k = f(); // OK, means \tcode{f(0)} } int (*p1)(int) = &f; -int (*p2)() = &f; // error: type mismatch +int (*p2)() = &f; // error: type mismatch \end{codeblock} \end{example} When a declaration of a function is introduced by way of a @@ -1982,7 +1959,7 @@ is in scope. \pnum -\indextext{argument~and~virtual~function!default}% +\indextext{argument and virtual function!default}% A virtual function call (\ref{class.virtual}) uses the default arguments in the declaration of the virtual function determined by the static type of the pointer or reference denoting the @@ -2007,7 +1984,7 @@ \end{codeblock} \end{example}% \indextext{declaration!default argument|)}% -\indextext{declarator!meaning~of|)} +\indextext{declarator!meaning of|)} \rSec1[dcl.fct.def]{Function definitions}% \indextext{definition!function|(} @@ -2050,7 +2027,7 @@ \pnum \begin{example} -a simple example of a complete function definition is +A simple example of a complete function definition is \indextext{example!function definition}% \begin{codeblock} @@ -2072,13 +2049,13 @@ \tcode{c)} is the \grammarterm{declarator}; -\tcode{\{ /* ... */ \}} +\tcode{\{ /* ...\ */ \}} is the \grammarterm{function-body}. \end{example} \pnum -\indextext{initializer!base~class}% +\indextext{initializer!base class}% \indextext{initializer!member}% \indextext{definition!constructor}% A @@ -2112,11 +2089,9 @@ \pnum The function-local predefined variable \tcode{__func__} is defined as if a definition of the form - \begin{codeblock} static const char __func__[] = "@\grammarterm{function-name}@"; \end{codeblock} - had been provided, where \grammarterm{function-name} is an \impldef{string resulting from \mname{func}} string. It is unspecified whether such a variable has an address @@ -2124,19 +2099,18 @@ permitted to provide additional predefined variables with names that are reserved to the implementation~(\ref{lex.name}). If a predefined variable is not odr-used~(\ref{basic.def.odr}), its string value need not be present in the program image.} - \begin{example} \begin{codeblock} struct S { 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: \tcode{__func__} is undeclared \end{codeblock} \end{example} \rSec2[dcl.fct.def.default]{Explicitly-defaulted functions}% -\indextext{definition!function!explicitly-defaulted} +\indextext{definition!function!explicitly-defaulted}% \pnum A function definition of the form: @@ -2183,15 +2157,15 @@ \begin{example} \begin{codeblock} struct S { - constexpr S() = default; // ill-formed: implicit \tcode{S()} is not \tcode{constexpr} - S(int a = 0) = default; // ill-formed: default argument - void operator=(const S&) = default; // ill-formed: non-matching return type - ~S() noexcept(false) = default; // deleted: exception specification does not match + constexpr S() = default; // ill-formed: implicit \tcode{S()} is not \tcode{constexpr} + S(int a = 0) = default; // ill-formed: default argument + void operator=(const S&) = default; // ill-formed: non-matching return type + ~S() noexcept(false) = default; // deleted: exception specification does not match private: int i; - S(S&); // OK: private copy constructor + S(S&); // OK: private copy constructor }; -S::S(S&) = default; // OK: defines copy constructor +S::S(S&) = default; // OK: defines copy constructor \end{codeblock} \end{example} @@ -2229,12 +2203,12 @@ struct nontrivial1 { nontrivial1(); }; -nontrivial1::nontrivial1() = default; // not first declaration +nontrivial1::nontrivial1() = default; // not first declaration \end{codeblock} \end{example} \rSec2[dcl.fct.def.delete]{Deleted definitions}% -\indextext{definition!function!deleted} +\indextext{definition!function!deleted}% \pnum A function definition of the form: @@ -2259,21 +2233,19 @@ \pnum \begin{example} One can enforce non-default-initialization and non-integral initialization with - \begin{codeblock} struct onlydouble { - onlydouble() = delete; // OK, but redundant + onlydouble() = delete; // OK, but redundant onlydouble(std::intmax_t) = delete; onlydouble(double); }; \end{codeblock} - \end{example} -\begin{example} One can prevent use of a +\begin{example} +One can prevent use of a class in certain \grammarterm{new-expression}{s} by using deleted definitions of a user-declared \tcode{operator new} for that class. - \begin{codeblock} struct sometype { void* operator new(std::size_t) = delete; @@ -2284,10 +2256,10 @@ \end{codeblock} \end{example} -\begin{example} One can make a class uncopyable, i.e. move-only, by using deleted +\begin{example} +One can make a class uncopyable, i.e. move-only, by using deleted definitions of the copy constructor and copy assignment operator, and then providing defaulted definitions of the move constructor and move assignment operator. - \begin{codeblock} struct moveonly { moveonly() = default; @@ -2298,7 +2270,7 @@ ~moveonly() = default; }; moveonly* p; -moveonly q(*p); // error, deleted copy constructor +moveonly q(*p); // error, deleted copy constructor \end{codeblock} \end{example} @@ -2315,7 +2287,7 @@ struct sometype { sometype(); }; -sometype::sometype() = delete; // ill-formed; not first declaration +sometype::sometype() = delete; // ill-formed; not first declaration \end{codeblock} \end{example}% \indextext{definition!function|)} @@ -2334,14 +2306,14 @@ variable with a unique name \tcode{e} is introduced. If the \grammarterm{assignment-expression} in the \grammarterm{initializer} has array type \tcode{A} and no \grammarterm{ref-qualifier} is present, \tcode{e} -has type \cv{} \tcode{A} and each element is copy-initialized or direct-initialized +has type \cv{}~\tcode{A} and each element is copy-initialized or direct-initialized from the corresponding element of the \grammarterm{assignment-expression} as specified by the form of the \grammarterm{initializer}. Otherwise, \tcode{e} is defined as-if by \begin{ncbnf} -attribute-specifier-seq\opt{} decl-specifier-seq ref-qualifier\opt{} \tcode{e} initializer \terminal{;} +attribute-specifier-seq\opt{} decl-specifier-seq ref-qualifier\opt{} \terminal{e} initializer \terminal{;} \end{ncbnf} where @@ -2365,8 +2337,8 @@ \begin{example} \begin{codeblock} auto f() -> int(&)[2]; - auto [ x, y ] = f(); // \tcode{x} and \tcode{y} refer to elements in a copy of the array return value - auto& [ xr, yr ] = f(); // \tcode{xr} and \tcode{yr} refer to elements in the array referred to by \tcode{f}'s return value + auto [ x, y ] = f(); // \tcode{x} and \tcode{y} refer to elements in a copy of the array return value + auto& [ xr, yr ] = f(); // \tcode{xr} and \tcode{yr} refer to elements in the array referred to by \tcode{f}'s return value \end{codeblock} \end{example} @@ -2389,11 +2361,11 @@ Ordinary unqualified lookup~(\ref{basic.lookup.unqual}) is not performed. \end{note} In either case, \tcode{e} is an lvalue if the type of the entity \tcode{e} -is an lvalue reference and an xvalue otherwise. Given the type \tcode{T}$_i$ +is an lvalue reference and an xvalue otherwise. Given the type $\tcode{T}_i$ designated by \tcode{std::tuple_element::type}, each \tcode{v}$_i$ -is a variable of type ``reference to \tcode{T}$_i$'' initialized with the +is a variable of type ``reference to $\tcode{T}_i$'' initialized with the initializer, where the reference is an lvalue reference if the initializer is -an lvalue and an rvalue reference otherwise; the referenced type is \tcode{T}$_i$. +an lvalue and an rvalue reference otherwise; the referenced type is $\tcode{T}_i$. \pnum Otherwise, all of \tcode{E}'s non-static data members shall be public direct @@ -2406,8 +2378,8 @@ (in declaration order), each \tcode{v}$_i$ is the name of an lvalue that refers to the member \tcode{m}$_i$ of \tcode{e} and -whose type is \cv{} \tcode{T}$_i$, where \tcode{T}$_i$ is the declared type of -that member; the referenced type is \cv{} \tcode{T}$_i$. The lvalue is a +whose type is \cv{}~$\tcode{T}_i$, where $\tcode{T}_i$ is the declared type of +that member; the referenced type is \cv{}~$\tcode{T}_i$. The lvalue is a bit-field if that member is a bit-field. \begin{example} \begin{codeblock} @@ -2491,8 +2463,10 @@ \pnum \begin{note} Default arguments are more restricted; see~\ref{dcl.fct.default}. +\end{note} \pnum +\begin{note} The order of initialization of variables with static storage duration is described in~\ref{basic.start} and~\ref{stmt.dcl}. \end{note} @@ -2598,7 +2572,7 @@ if \tcode{T} is a union with at least one non-static data member, exactly one variant member has a default member initializer, \item -if \tcode{T} is a not a union, +if \tcode{T} is not a union, for each anonymous union member with at least one non-static data member (if any), exactly one non-static data member has a default member initializer, and \item @@ -2686,7 +2660,7 @@ \pnum \indextext{value!indeterminate}% -\indextext{indeterminate~value}% +\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 @@ -2728,18 +2702,17 @@ \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} + 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}% +\indextext{initialization!class member}% An initializer for a static member is in the scope of the member's class. \begin{example} - \begin{codeblock} int a; @@ -2749,7 +2722,7 @@ }; int X::a = 1; -int X::b = a; // \tcode{X::b = X::a} +int X::b = a; // \tcode{X::b = X::a} \end{codeblock} \end{example} @@ -2774,12 +2747,10 @@ \pnum The initialization that occurs in the forms - \begin{codeblock} T x(a); T x{a}; \end{codeblock} - as well as in \tcode{new} expressions~(\ref{expr.new}), @@ -2801,7 +2772,6 @@ is the type of the initializer expression. If the initializer is not a single (possibly parenthesized) expression, the source type is not defined. - \begin{itemize} \item If the initializer is a (non-parenthesized) \grammarterm{braced-init-list} @@ -2887,13 +2857,13 @@ \indextext{initialization!\idxcode{const}}% \begin{note} An expression of type -``\nonterminal{cv1} \tcode{T}'' +``\cvqual{cv1} \tcode{T}'' can initialize an object of type -``\nonterminal{cv2} \tcode{T}'' +``\cvqual{cv2} \tcode{T}'' independently of the cv-qualifiers -\nonterminal{cv1} -and \nonterminal{cv2}. +\cvqual{cv1} +and \cvqual{cv2}. \begin{codeblock} int a; @@ -2926,10 +2896,10 @@ \rSec2[dcl.init.aggr]{Aggregates}% \indextext{aggregate}% \indextext{initialization!aggregate}% -\indextext{aggregate~initialization}% +\indextext{aggregate initialization}% \indextext{initialization!array}% -\indextext{initialization!class~object}% -\indextext{class~object~initialization|see{constructor}}% +\indextext{initialization!class object}% +\indextext{class object initialization|see{constructor}}% \indextext{\idxcode{\{\}}!initializer list} \pnum @@ -3022,7 +2992,7 @@ expression not enclosed in braces, as described in~\ref{dcl.init}. \pnum -An array of unknown size initialized with a +An array of unknown bound initialized with a brace-enclosed \grammarterm{initializer-list} containing @@ -3032,7 +3002,7 @@ \tcode{n} shall be greater than zero, is defined as having \tcode{n} -elements (\ref{dcl.array}). +elements~(\ref{dcl.array}). \begin{example} \begin{codeblock} @@ -3050,11 +3020,25 @@ for an array of unknown bound.\footnote{The syntax provides for empty \grammarterm{initializer-list}{s}, but nonetheless \Cpp does not have zero length arrays.} +\begin{note} +A default member initializer does not determine the bound for a member +array of unknown bound. Since the default member initializer is +ignored if a suitable \grammarterm{mem-initializer} is present +(\ref{class.base.init}), the default member initializer is not +considered to initialize the array of unknown bound. +\begin{example} +\begin{codeblock} +struct S { + int y[] = { 0 }; // error: non-static data member of incomplete type +}; +\end{codeblock} +\end{example} +\end{note} \pnum \begin{note} Static data members and unnamed bit-fields are not considered -elements of the aggregate for purposes of aggregate initialization. +elements of the aggregate. \begin{example} \begin{codeblock} @@ -3133,22 +3117,21 @@ struct A; extern A a; struct A { - const A& a1 { A{a,a} }; // OK - const A& a2 { A{} }; // error + const A& a1 { A{a,a} }; // OK + const A& a2 { A{} }; // error }; - A a{a,a}; // OK + A a{a,a}; // OK \end{codeblock} \end{example} \pnum If an aggregate class \tcode{C} contains a subaggregate element -\tcode{e} that has no elements for purposes of aggregate initialization, +\tcode{e} with no elements, the \grammarterm{initializer-clause} for \tcode{e} shall not be omitted from an \grammarterm{initializer-list} for an object of type \tcode{C} unless the \grammarterm{initializer-clause}{s} for all elements of \tcode{C} following \tcode{e} are also omitted. \begin{example} - \begin{codeblock} struct S { } s; struct A { @@ -3159,11 +3142,11 @@ S s3; int i3; } a = { - { }, // Required initialization + { }, // Required initialization 0, - s, // Required initialization + s, // Required initialization 0 -}; // Initialization not required for \tcode{A::s3} because \tcode{A::i3} is also not initialized +}; // Initialization not required for \tcode{A::s3} because \tcode{A::i3} is also not initialized \end{codeblock} \end{example} @@ -3302,7 +3285,7 @@ \grammarterm{assignment-expression} is considered for the initialization of the first element of the subaggregate. \begin{note} As specified above, brace elision cannot apply to -subaggregates with no elements for purposes of aggregate initialization; an +subaggregates with no elements; an \grammarterm{initializer-clause} for the entire subobject is required.\end{note} @@ -3337,7 +3320,7 @@ \end{example} \pnum -\indextext{initialization!array~of class~objects}% +\indextext{initialization!array of class objects}% \begin{note} An aggregate array or an aggregate class may contain elements of a class type with a user-provided constructor (\ref{class.ctor}). @@ -3391,7 +3374,7 @@ literal, or wide string literal, respectively, or by an appropriately-typed string literal enclosed in braces~(\ref{lex.string}). -\indextext{initialization!character~array}% +\indextext{initialization!character array}% Successive characters of the value of the string literal @@ -3464,9 +3447,9 @@ \begin{note} Assignment to a reference assigns to the object referred to by the reference (\ref{expr.ass}). \end{note} -\indextext{argument~passing!reference~and}% +\indextext{argument passing!reference and}% Argument passing (\ref{expr.call}) -\indextext{\idxcode{return}!reference~and}% +\indextext{\idxcode{return}!reference and}% and function value return (\ref{stmt.return}) are initializations. \pnum @@ -3485,15 +3468,13 @@ \end{example} \pnum -Given types ``\nonterminal{cv1} \tcode{T1}'' and ``\nonterminal{cv2} \tcode{T2}'', -``\nonterminal{cv1} \tcode{T1}'' is \nonterminal{reference-related} to -\indextext{reference-related}% -``\nonterminal{cv2} \tcode{T2}'' if +Given types ``\cvqual{cv1} \tcode{T1}'' and ``\cvqual{cv2} \tcode{T2}'', +``\cvqual{cv1} \tcode{T1}'' is \defn{reference-related} to +``\cvqual{cv2} \tcode{T2}'' if \tcode{T1} is the same type as \tcode{T2}, or \tcode{T1} is a base class of \tcode{T2}. -``\nonterminal{cv1} \tcode{T1}'' is \nonterminal{reference-compatible} -\indextext{reference-compatible}% -with ``\nonterminal{cv2} \tcode{T2}'' if +``\cvqual{cv1} \tcode{T1}'' is \defn{reference-compatible} +with ``\cvqual{cv2} \tcode{T2}'' if \begin{itemize} \item \tcode{T1} is reference-related to \tcode{T2}, or \item \tcode{T2} is ``\tcode{noexcept} function'' and \tcode{T1} is ``function'', @@ -3527,15 +3508,15 @@ \item is an lvalue (but is not a bit-field), and -``\nonterminal{cv1} \tcode{T1}'' is reference-compatible with -``\nonterminal{cv2} \tcode{T2}'', or +``\cvqual{cv1} \tcode{T1}'' is reference-compatible with +``\cvqual{cv2} \tcode{T2}'', or \item has a class type (i.e., \tcode{T2} is a class type), where \tcode{T1} is not reference-related to \tcode{T2}, and can be converted -to an lvalue of type ``\nonterminal{cv3} \tcode{T3}'', where -``\nonterminal{cv1} \tcode{T1}'' is reference-compatible with -``\nonterminal{cv3} \tcode{T3}''\footnote{This requires a conversion +to an lvalue of type ``\cvqual{cv3} \tcode{T3}'', where +``\cvqual{cv1} \tcode{T1}'' is reference-compatible with +``\cvqual{cv3} \tcode{T3}''\footnote{This requires a conversion function~(\ref{class.conv.fct}) returning a reference type.} (this conversion is selected by enumerating the applicable conversion functions (\ref{over.match.ref}) and choosing the best one through overload @@ -3635,7 +3616,7 @@ \tcode{T1} is not reference-related to \tcode{T2}, user-defined conversions are considered using the rules for copy-initialization of an object of type -``\nonterminal{cv1} \tcode{T1}'' by +``\cvqual{cv1} \tcode{T1}'' by user-defined conversion (\ref{dcl.init}, \ref{over.match.copy}, \ref{over.match.conv}); the program is ill-formed if the corresponding non-reference @@ -3646,7 +3627,7 @@ \item Otherwise, the initializer expression is implicitly converted to a prvalue -of type ``\nonterminal{cv1} \tcode{T1}''. +of type ``\cvqual{cv1} \tcode{T1}''. The temporary materialization conversion is applied and the reference is bound to the result. \end{itemize} @@ -3680,9 +3661,9 @@ const double& rcd2 = 2; // \tcode{rcd2} refers to temporary with value \tcode{2.0} double&& rrd = 2; // \tcode{rrd} refers to temporary with value \tcode{2.0} const volatile int cvi = 1; -const int& r2 = cvi; // error: type qualifiers dropped +const int& r2 = cvi; // error: cv-qualifier dropped struct A { operator volatile int&(); } a; -const int& r3 = a; // error: type qualifiers dropped +const int& r3 = a; // error: cv-qualifier dropped // from result of conversion function double d2 = 1.0; double&& rrd2 = d2; // error: initializer is lvalue of related type diff --git a/source/derived.tex b/source/derived.tex index 1b5d1ece10..ad0c0b2188 100644 --- a/source/derived.tex +++ b/source/derived.tex @@ -1,17 +1,17 @@ %!TEX root = std.tex \rSec0[class.derived]{Derived classes}% -\indextext{derived~class|(} +\indextext{derived class|(} \gramSec[gram.derived]{Derived classes} -\indextext{base~class~virtual|see{virtual~base~class}} -\indextext{function, virtual|see{virtual~function}} -\indextext{dynamic binding|see{virtual~function}} +\indextext{virtual base class|see{base class, virtual}} +\indextext{function, virtual|see{virtual function}} +\indextext{dynamic binding|see{virtual function}} \pnum -\indextext{base~class}% +\indextext{base class}% \indextext{inheritance}% -\indextext{multiple~inheritance}% +\indextext{multiple inheritance}% A list of base classes can be specified in a class definition using the notation: @@ -45,7 +45,7 @@ class-or-decltype \end{bnf} -\indextext{specifier~access|see{access~specifier}}% +\indextext{specifier access|see{access specifier}}% % \begin{bnf} \nontermdef{access-specifier}\br @@ -62,17 +62,17 @@ a class type that is not an incompletely defined class (Clause~\ref{class}); this class is called a -\indextext{base~class!direct}% +\indextext{base class!direct}% \term{direct base class} for the class being defined. -\indextext{base~class}% +\indextext{base class}% \indextext{derivation|see{inheritance}}% During the lookup for a base class name, non-type names are ignored~(\ref{basic.scope.hiding}). If the name found is not a \grammarterm{class-name}, the program is ill-formed. A class \tcode{B} is a base class of a class \tcode{D} if it is a direct base class of \tcode{D} or a direct base class of one of \tcode{D}'s base classes. -\indextext{base~class!indirect}% +\indextext{base class!indirect}% A class is an \term{indirect} base class of another if it is a base class but not a direct base class. A class is said to be (directly or indirectly) \term{derived} from its (direct or indirect) base @@ -81,7 +81,7 @@ See Clause~\ref{class.access} for the meaning of \grammarterm{access-specifier}. \end{note} -\indextext{access control!base~class member}% +\indextext{access control!base class member}% Unless redeclared in the derived class, members of a base class are also considered to be members of the derived class. Members of a base class other than constructors are said to be @@ -92,7 +92,7 @@ Inherited members can be referred to in expressions in the same manner as other members of the derived class, unless their names are hidden or ambiguous~(\ref{class.member.lookup}). -\indextext{operator!scope~resolution}% +\indextext{operator!scope resolution}% \begin{note} The scope resolution operator \tcode{::}~(\ref{expr.prim}) can be used to refer to a direct or indirect base member explicitly. This allows @@ -110,7 +110,7 @@ \term{base class subobjects} contained in an object of the derived class type. \begin{example} -\indextext{example!derived~class}% +\indextext{example!derived class}% \begin{codeblock} struct Base { int a, b, c; @@ -142,21 +142,18 @@ The order in which the base class subobjects are allocated in the most derived object~(\ref{intro.object}) is unspecified. \begin{note} -\indextext{directed~acyclic~graph|see{DAG}}% +\indextext{directed acyclic graph|see{DAG}}% \indextext{lattice|see{DAG, subobject}}% -a derived class and its base class subobjects can be represented by a +A derived class and its base class subobjects can be represented by a directed acyclic graph (DAG) where an arrow means ``directly derived -from.'' A DAG of subobjects is often referred to as a ``subobject -lattice.'' +from''. An arrow need not have a physical representation in memory. +A DAG of subobjects is often referred to as a ``subobject lattice''. \begin{importgraphic} {Directed acyclic graph} {fig:dag} {figdag.pdf} \end{importgraphic} - -\pnum -The arrows need not have a physical representation in memory. \end{note} \pnum @@ -178,8 +175,8 @@ \end{note} \rSec1[class.mi]{Multiple base classes} -\indextext{multiple~inheritance}% -\indextext{base~class}% +\indextext{multiple inheritance}% +\indextext{base class}% \pnum A class can be derived from any number of base classes. @@ -188,16 +185,16 @@ \end{note} \begin{example} \begin{codeblock} -class A { /* ... */ }; -class B { /* ... */ }; -class C { /* ... */ }; -class D : public A, public B, public C { /* ... */ }; +class A { @\commentellip@ }; +class B { @\commentellip@ }; +class C { @\commentellip@ }; +class D : public A, public B, public C { @\commentellip@ }; \end{codeblock} \end{example} \pnum -\indextext{layout!class~object}% -\indextext{initialization!order~of}% +\indextext{layout!class object}% +\indextext{initialization!order of}% \begin{note} The order of derivation is not significant except as specified by the semantics of initialization by constructor~(\ref{class.base.init}), @@ -218,21 +215,21 @@ \end{note} \begin{example} \begin{codeblock} -class X { /* ... */ }; -class Y : public X, public X { /* ... */ }; // ill-formed +class X { @\commentellip@ }; +class Y : public X, public X { @\commentellip@ }; // ill-formed \end{codeblock} \begin{codeblock} -class L { public: int next; /* ... */ }; -class A : public L { /* ... */ }; -class B : public L { /* ... */ }; -class C : public A, public B { void f(); /* ... */ }; // well-formed -class D : public A, public L { void f(); /* ... */ }; // well-formed +class L { public: int next; @\commentellip@ }; +class A : public L { @\commentellip@ }; +class B : public L { @\commentellip@ }; +class C : public A, public B { void f(); @\commentellip@ }; // well-formed +class D : public A, public L { void f(); @\commentellip@ }; // well-formed \end{codeblock} \end{example} \pnum -\indextext{virtual~base~class}% +\indextext{base class!virtual}% A base class specifier that does not contain the keyword \tcode{virtual}, specifies a \grammarterm{non-virtual} base class. A base class specifier that contains the keyword \tcode{virtual}, specifies a @@ -242,8 +239,10 @@ corresponding distinct base class subobject of that type. For each distinct base class that is specified virtual, the most derived object shall contain a single base class subobject of that type. -\begin{example} -for an object of class type \tcode{C}, each distinct occurrence of a + +\pnum +\begin{note} +For an object of class type \tcode{C}, each distinct occurrence of a (non-virtual) base class \tcode{L} in the class lattice of \tcode{C} corresponds one-to-one with a distinct \tcode{L} subobject within the object of type \tcode{C}. Given the class \tcode{C} defined above, an @@ -256,7 +255,6 @@ {fignonvirt.pdf} \end{importgraphic} -\pnum In such lattices, explicit qualification can be used to specify which subobject is meant. The body of function \tcode{C::f} could refer to the member \tcode{next} of each \tcode{L} subobject: @@ -266,39 +264,41 @@ Without the \tcode{A::} or \tcode{B::} qualifiers, the definition of \tcode{C::f} above would be ill-formed because of ambiguity~(\ref{class.member.lookup}). +\end{note} \pnum -For another example, +\begin{note} +In contrast, consider the case with a virtual base class: \begin{codeblock} -class V { /* ... */ }; -class A : virtual public V { /* ... */ }; -class B : virtual public V { /* ... */ }; -class C : public A, public B { /* ... */ }; +class V { @\commentellip@ }; +class A : virtual public V { @\commentellip@ }; +class B : virtual public V { @\commentellip@ }; +class C : public A, public B { @\commentellip@ }; \end{codeblock} -for an object \tcode{c} of class type \tcode{C}, a single subobject of -type \tcode{V} is shared by every base subobject of \tcode{c} that has a -\tcode{virtual} base class of type \tcode{V}. Given the class \tcode{C} -defined above, an object of class \tcode{C} will have one subobject of -class \tcode{V}, as shown in Figure~\ref{fig:virt}. - -\indextext{DAG!multiple~inheritance}% -\indextext{DAG!virtual~base~class}% \begin{importgraphic} {Virtual base} {fig:virt} {figvirt.pdf} \end{importgraphic} - +For an object \tcode{c} of class type \tcode{C}, a single subobject of +type \tcode{V} is shared by every base class subobject of \tcode{c} that has a +\tcode{virtual} base class of type \tcode{V}. Given the class \tcode{C} +defined above, an object of class \tcode{C} will have one subobject of +class \tcode{V}, as shown in Figure~\ref{fig:virt}. +\indextext{DAG!multiple inheritance}% +\indextext{DAG!virtual base class}% +\end{note} \pnum +\begin{note} A class can have both virtual and non-virtual base classes of a given type. \begin{codeblock} -class B { /* ... */ }; -class X : virtual public B { /* ... */ }; -class Y : virtual public B { /* ... */ }; -class Z : public B { /* ... */ }; -class AA : public X, public Y, public Z { /* ... */ }; +class B { @\commentellip@ }; +class X : virtual public B { @\commentellip@ }; +class Y : virtual public B { @\commentellip@ }; +class Z : public B { @\commentellip@ }; +class AA : public X, public Y, public Z { @\commentellip@ }; \end{codeblock} For an object of class \tcode{AA}, all \tcode{virtual} occurrences of base class \tcode{B} in the class lattice of \tcode{AA} correspond to a @@ -310,20 +310,19 @@ class \tcode{B}: \tcode{Z}'s \tcode{B} and the virtual \tcode{B} shared by \tcode{X} and \tcode{Y}, as shown in Figure~\ref{fig:virtnonvirt}. -\indextext{DAG!virtual~base~class}% -\indextext{DAG!non-virtual~base~class}% -\indextext{DAG!multiple~inheritance}% +\indextext{DAG!virtual base class}% +\indextext{DAG!non-virtual base class}% +\indextext{DAG!multiple inheritance}% \begin{importgraphic} {Virtual and non-virtual base} {fig:virtnonvirt} {figvirtnonvirt.pdf} \end{importgraphic} - -\end{example} +\end{note} \rSec1[class.member.lookup]{Member name lookup}% \indextext{lookup!member name}% -\indextext{ambiguity!base~class~member}% +\indextext{ambiguity!base class member}% \indextext{ambiguity!member access} \pnum @@ -419,17 +418,17 @@ \end{codeblock} $S(x,F)$ is unambiguous because the \tcode{A} and \tcode{B} base -subobjects of \tcode{D} are also base subobjects of \tcode{E}, so +class subobjects of \tcode{D} are also base class subobjects of \tcode{E}, so $S(x,D)$ is discarded in the first merge step. \end{example} \pnum -\indextext{access control!overload~resolution~and}% +\indextext{access control!overload resolution and}% If the name of an overloaded function is unambiguously found, overload resolution~(\ref{over.match}) also takes place before access control. -\indextext{example!scope~resolution operator}% -\indextext{example!explicit~qualification}% +\indextext{example!scope resolution operator}% +\indextext{example!explicit qualification}% \indextext{overloading!resolution!scoping ambiguity}% Ambiguities can often be resolved by qualifying a name with its class name. \begin{example} @@ -484,7 +483,7 @@ \pnum \begin{note} -\indextext{dominance!virtual~base~class}% +\indextext{dominance!virtual base class}% When virtual base classes are used, a hidden declaration can be reached along a path through the subobject lattice that does not pass through the hiding declaration. This is not an ambiguity. The identical use with @@ -510,12 +509,9 @@ {figname.pdf} \end{importgraphic} -\pnum -\begin{note} The names declared in \tcode{V} and the left-hand instance of \tcode{W} are hidden by those in \tcode{B}, but the names declared in the right-hand instance of \tcode{W} are not hidden at all. -\end{note} \begin{codeblock} void D::glorp() { x++; // OK: \tcode{B::x} hides \tcode{V::x} @@ -582,7 +578,7 @@ \end{codeblock}\end{example} \rSec1[class.virtual]{Virtual functions}% -\indextext{virtual~function|(}% +\indextext{virtual function|(}% \indextext{type!polymorphic}% \indextext{class!polymorphic} @@ -704,7 +700,7 @@ \pnum The return type of an overriding function shall be either identical to -the return type of the overridden function or \term{covariant} with +the return type of the overridden function or \defnx{covariant}{return type!covariant} with the classes of the functions. If a function \tcode{D::f} overrides a function \tcode{B::f}, the return types of the functions are covariant if they satisfy the following criteria: @@ -734,7 +730,7 @@ the type returned by the (statically chosen) overridden function~(\ref{expr.call}). \begin{example} -\indextext{example!virtual~function}% +\indextext{example!virtual function}% \begin{codeblock} class B { }; class D : private B { friend class Derived; }; @@ -756,8 +752,8 @@ void vf1(); // virtual and overrides \tcode{Base::vf1()} void vf2(int); // not virtual, hides \tcode{Base::vf2()} char vf3(); // error: invalid difference in return type only - D* vf4(); // OK: returns pointer to derived class - A* vf5(); // error: returns pointer to incomplete class + D* vf4(); // OK: returns pointer to derived class + A* vf5(); // error: returns pointer to incomplete class void f(); }; @@ -798,17 +794,17 @@ \end{note} \pnum -\indextext{definition!virtual~function}% +\indextext{definition!virtual function}% A virtual function declared in a class shall be defined, or declared -pure~(\ref{class.abstract}) in that class, or both; but no diagnostic is +pure~(\ref{class.abstract}) in that class, or both; no diagnostic is required~(\ref{basic.def.odr}). -\indextext{friend!\tcode{virtual}~and}% +\indextext{friend!\tcode{virtual} and}% \pnum -\indextext{multiple~inheritance!\tcode{virtual}~and}% +\indextext{multiple inheritance!\tcode{virtual} and}% \begin{example} -here are some uses of virtual functions with multiple base classes: -\indextext{example!virtual~function}% +Here are some uses of virtual functions with multiple base classes: +\indextext{example!virtual function}% \begin{codeblock} struct A { virtual void f(); @@ -839,8 +835,10 @@ and hence two occurrences of the virtual member function \tcode{A::f}. The final overrider of \tcode{B1::A::f} is \tcode{B1::f} and the final overrider of \tcode{B2::A::f} is \tcode{B2::f}. +\end{example} \pnum +\begin{example} The following example shows a function that does not have a unique final overrider: \begin{codeblock} @@ -867,8 +865,10 @@ is no overrider of both of them in class \tcode{Error}. This example is therefore ill-formed. Class \tcode{Okay} is well formed, however, because \tcode{Okay::f} is a final overrider. +\end{example} \pnum +\begin{example} The following example uses the well-formed classes from above. \begin{codeblock} struct VB1a : virtual A { // does not declare \tcode{f} @@ -885,8 +885,8 @@ \end{example} \pnum -\indextext{operator!scope~resolution}% -\indextext{virtual~function~call}% +\indextext{operator!scope resolution}% +\indextext{virtual function call}% Explicit qualification with the scope operator~(\ref{expr.prim}) suppresses the virtual call mechanism. \begin{example} @@ -894,7 +894,7 @@ class B { public: virtual void f(); }; class D : public B { public: void f(); }; -void D::f() { /* ... */ B::f(); } +void D::f() { @\commentellip@ B::f(); } \end{codeblock} Here, the function call in @@ -910,7 +910,7 @@ not override a function that does not have a deleted definition. Likewise, a function that does not have a deleted definition shall not override a function with a deleted definition.% -\indextext{virtual~function|)} +\indextext{virtual function|)} \rSec1[class.abstract]{Abstract classes}% \indextext{class!abstract} @@ -932,18 +932,18 @@ \begin{note} Such a function might be inherited: see below. \end{note} -\indextext{virtual~function!pure}% +\indextext{virtual function!pure}% A virtual function is specified \term{pure} by using a \grammarterm{pure-specifier}~(\ref{class.mem}) in the function declaration in the class definition. -\indextext{definition!pure virtual~function}% +\indextext{definition!pure virtual function}% A pure virtual function need be defined only if called with, or as if with~(\ref{class.dtor}), the \grammarterm{qualified-id} syntax~(\ref{expr.prim}). \begin{example} -\indextext{example!pure virtual~function}% +\indextext{example!pure virtual function}% \begin{codeblock} -class point { /* ... */ }; +class point { @\commentellip@ }; class shape { // abstract class point center; public: @@ -967,7 +967,7 @@ \end{example} \pnum -\indextext{class!pointer~to abstract}% +\indextext{class!pointer to abstract}% An abstract class shall not be used as a parameter type, as a function return type, or as the type of an explicit conversion. Pointers and references to an abstract class can be declared. @@ -982,7 +982,7 @@ \end{example} \pnum -\indextext{virtual~function!pure}% +\indextext{virtual function!pure}% A class is abstract if it contains or inherits at least one pure virtual function for which the final overrider is pure virtual. \begin{example} @@ -1018,11 +1018,11 @@ \end{note} \pnum -\indextext{class!constructor~and abstract}% +\indextext{class!constructor and abstract}% Member functions can be called from a constructor (or destructor) of an abstract class; -\indextext{virtual~function~call!undefined pure}% +\indextext{virtual function call!undefined pure}% the effect of making a virtual call~(\ref{class.virtual}) to a pure virtual function directly or indirectly for the object being created (or destroyed) from such a constructor (or destructor) is undefined.% -\indextext{derived~class|)} +\indextext{derived class|)} diff --git a/source/diagnostics.tex b/source/diagnostics.tex index 757c25c414..5b411857bf 100644 --- a/source/diagnostics.tex +++ b/source/diagnostics.tex @@ -49,6 +49,7 @@ These exceptions are related by inheritance. \rSec2[stdexcept.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{stdexcept}}% \indexlibrary{\idxhdr{stdexcept}}% \indexlibrary{\idxcode{logic_error}}% \indexlibrary{\idxcode{domain_error}}% @@ -545,6 +546,7 @@ \rSec2[cassert.syn]{Header \tcode{} synopsis} \indextext{\idxhdr{cassert}}% +\indexlibrary{\idxhdr{cassert}}% \indexlibrary{\idxcode{assert}}% \begin{codeblock} #define assert(E) @\seebelow@ @@ -552,6 +554,7 @@ \pnum \indextext{\idxhdr{assert.h}}% +\indexlibrary{\idxhdr{assert.h}}% \indextext{static_assert@\tcode{static_assert}!not macro}% The contents are the same as the C standard library header \tcode{}, @@ -578,6 +581,7 @@ \pnum \indextext{\idxhdr{errno.h}}% +\indexlibrary{\idxhdr{errno.h}}% The contents of the header \tcode{} are the same as the POSIX header \tcode{}, except that \tcode{errno} shall be defined as a macro. \begin{note} @@ -588,6 +592,7 @@ \rSec2[cerrno.syn]{Header \tcode{} synopsis} \indextext{\idxhdr{cerrno}}% +\indexlibrary{\idxhdr{cerrno}}% \indexlibrary{\idxcode{errno}}% \indexlibrary{\idxcode{E2BIG}}% \indexlibrary{\idxcode{EACCES}}% @@ -778,8 +783,6 @@ \indexlibrary{\idxcode{is_error_code_enum}}% \indexlibrary{\idxcode{is_error_condition_enum}}% \indexlibrary{\idxcode{errc}}% -\indexlibrary{\idxcode{make_error_code}}% -\indexlibrary{\idxcode{make_error_condition}}% \begin{codeblock} namespace std { @@ -890,7 +893,7 @@ // \ref{syserr.errcondition.nonmembers}, non-member functions error_condition make_error_condition(errc e) noexcept; - // \ref{syserr.compare}, comparison operators + // \ref{syserr.compare}, comparison functions bool operator<(const error_code& lhs, const error_code& rhs) noexcept; bool operator<(const error_condition& lhs, const error_condition& rhs) noexcept; bool operator==(const error_code& lhs, const error_code& rhs) noexcept; @@ -1349,7 +1352,7 @@ \rSec3[syserr.errcode.nonmembers]{Class \tcode{error_code} non-member functions} -\indexlibrary{\idxcode{make_error_code}}% +\indexlibrarymember{make_error_code}{errc}% \begin{itemdecl} error_code make_error_code(errc e) noexcept; \end{itemdecl} @@ -1359,7 +1362,7 @@ \returns \tcode{error_code(static_cast(e), generic_category())}. \end{itemdescr} -\indexlibrarymember{operator\shl}{error_code}% +\indexlibrarymember{operator<<}{error_code}% \begin{itemdecl} template basic_ostream& @@ -1495,6 +1498,7 @@ \end{itemdecl} \begin{itemdescr} +\pnum \postconditions \tcode{value() == 0} and \tcode{category() == generic_category()}. \end{itemdescr} @@ -1542,16 +1546,17 @@ \rSec3[syserr.errcondition.nonmembers]{Class \tcode{error_condition} non-member functions} -\indexlibrary{\idxcode{make_error_condition}}% +\indexlibrarymember{make_error_condition}{errc}% \begin{itemdecl} error_condition make_error_condition(errc e) noexcept; \end{itemdecl} \begin{itemdescr} +\pnum \returns \tcode{error_condition(static_cast(e), generic_category())}. \end{itemdescr} -\rSec2[syserr.compare]{Comparison operators} +\rSec2[syserr.compare]{Comparison functions} \indexlibrarymember{operator<}{error_code}% \begin{itemdecl} @@ -1791,6 +1796,6 @@ \pnum \returns An \ntbs incorporating the arguments supplied in the constructor. -\begin{note} The returned NTBS might be the contents of \tcode{what_arg + ": " + +\begin{note} The returned \ntbs might be the contents of \tcode{what_arg + ": " + code.message()}.\end{note} \end{itemdescr} diff --git a/source/exceptions.tex b/source/exceptions.tex index 759fc83a64..5778f10cb3 100644 --- a/source/exceptions.tex +++ b/source/exceptions.tex @@ -114,10 +114,10 @@ T1 t1; try { T2 t2; - if (@\textit{condition}@) + if (@\grammarterm{condition}@) goto lab; - } catch(...) { /* @\textit{handler 2}@ */ } - } catch(...) { /* @\textit{handler 1}@ */ } + } catch(...) { @\tcode{/* handler 2 */}@ } + } catch(...) { @\tcode{/* handler 1 */}@ } \end{codeblock} Here, executing @@ -132,11 +132,11 @@ Any exception thrown while destroying \tcode{t2} will result in executing -\textit{handler 2}; +\tcode{handler 2}; any exception thrown while destroying \tcode{t1} will result in executing -\textit{handler 1}. +\tcode{handler 1}. \end{example} \pnum @@ -208,7 +208,7 @@ throw "Help!"; \end{codeblock} can be caught by a -\term{handler} +\grammarterm{handler} of \tcode{const} \tcode{char*} @@ -260,14 +260,13 @@ Throwing an exception copy-initializes~(\ref{dcl.init}, \ref{class.copy}) a temporary object, called the -\indextext{exception handling!exception object}\term{exception object}. +\defnx{exception object}{exception handling!exception object}. An lvalue denoting the temporary is used to initialize the variable declared in the matching -\term{handler}~(\ref{except.handle}). +\grammarterm{handler}~(\ref{except.handle}). If the type of the exception object would be an incomplete type or a pointer to an incomplete -type other than (possibly cv-qualified) -\tcode{void} the program is ill-formed. +type other than \cv{}~\tcode{void} the program is ill-formed. \pnum \indextext{exception handling!memory}% @@ -303,7 +302,7 @@ The implementation may then deallocate the memory for the exception object; any such deallocation is done in an unspecified way. -\begin{note} a thrown exception does not +\begin{note} A thrown exception does not propagate to other threads unless caught, stored, and rethrown using appropriate library functions; see~\ref{propagation} and~\ref{futures}. \end{note} @@ -360,8 +359,8 @@ \rSec1[except.ctor]{Constructors and destructors}% \indextext{exception handling!constructors and destructors}% -\indextext{constructor!exception~handling|see{exception handling, constructors and destructors}}% -\indextext{destructor!exception~handling|see{exception handling, constructors and destructors}} +\indextext{constructor!exception handling|see{exception handling, constructors and destructors}}% +\indextext{destructor!exception handling|see{exception handling, constructors and destructors}} \pnum \indextext{unwinding!stack}% @@ -445,10 +444,10 @@ The \grammarterm{exception-declaration} in a -\term{handler} +\grammarterm{handler} describes the type(s) of exceptions that can cause that -\term{handler} +\grammarterm{handler} to be entered. \indextext{exception handling!handler!incomplete type in}% \indextext{exception handling!handler!rvalue reference in}% @@ -473,9 +472,9 @@ \pnum A handler of type -\indextext{array!handler~of~type}% +\indextext{array!handler of type}% ``array of \tcode{T}'' or -\indextext{function!handler~of~type}% +\indextext{function!handler of type}% function type \tcode{T} is adjusted to be of type ``pointer to \tcode{T}''. @@ -483,7 +482,7 @@ \pnum \indextext{exception handling!handler!match|(}% A -\term{handler} +\grammarterm{handler} is a match for an exception object of type @@ -491,16 +490,16 @@ if \begin{itemize} \item% -The \term{handler} is of type \cv{} \tcode{T} or -\cv{} \tcode{T\&} and +The \grammarterm{handler} is of type \cv{}~\tcode{T} or +\cv{}~\tcode{T\&} and \tcode{E} and \tcode{T} are the same type (ignoring the top-level \grammarterm{cv-qualifiers}), or \item% -the \term{handler} is of type \cv{} \tcode{T} or -\cv{} \tcode{T\&} and +the \grammarterm{handler} is of type \cv{}~\tcode{T} or +\cv{}~\tcode{T\&} and \tcode{T} is an unambiguous public base class of \tcode{E}, or \item% -the \term{handler} is of type \cv{} \tcode{T} or \tcode{const T\&} +the \grammarterm{handler} is of type \cv{}~\tcode{T} or \tcode{const T\&} where \tcode{T} is a pointer or pointer to member type and \tcode{E} is a pointer or pointer to member type that can be converted to \tcode{T} by one or more of @@ -517,7 +516,7 @@ \end{itemize} \item -the \term{handler} is of type \cv{} \tcode{T} or \tcode{const T\&} where \tcode{T} is a pointer or pointer to member type and \tcode{E} is \tcode{std::nullptr_t}. +the \grammarterm{handler} is of type \cv{}~\tcode{T} or \tcode{const T\&} where \tcode{T} is a pointer or pointer to member type and \tcode{E} is \tcode{std::nullptr_t}. \end{itemize} @@ -532,10 +531,10 @@ \begin{example} \begin{codeblock} -class Matherr { /* ... */ virtual void vf(); }; -class Overflow: public Matherr { /* ... */ }; -class Underflow: public Matherr { /* ... */ }; -class Zerodivide: public Matherr { /* ... */ }; +class Matherr { @\commentellip@ virtual void vf(); }; +class Overflow: public Matherr { @\commentellip@ }; +class Underflow: public Matherr { @\commentellip@ }; +class Zerodivide: public Matherr { @\commentellip@ }; void f() { try { @@ -602,9 +601,10 @@ catch clause exits. \pnum +\indextext{currently handled exception|see{exception handling, currently handled exception}}% The exception with the most recently activated handler that is still active is called the -\term{currently handled exception}. +\defnx{currently handled exception}{exception handling!currently handled exception}. \pnum If no matching handler is found, @@ -632,7 +632,8 @@ constructors of namespace-scope objects with static storage duration are not caught by a \grammarterm{function-try-block} on -\tcode{main()}. Exceptions thrown in destructors of objects with thread storage duration or in constructors of namespace-scope objects with thread storage duration are not caught by a +the \tcode{main} function~(\ref{basic.start.main}). +Exceptions thrown in destructors of objects with thread storage duration or in constructors of namespace-scope objects with thread storage duration are not caught by a \grammarterm{function-try-block} on the initial function of the thread. @@ -657,7 +658,7 @@ \pnum The variable declared by the \grammarterm{exception-declaration}, of type -\cv{} \tcode{T} or \cv{} \tcode{T\&}, is initialized from the exception object, +\cv{}~\tcode{T} or \cv{}~\tcode{T\&}, is initialized from the exception object, of type \tcode{E}, as follows: \begin{itemize} @@ -966,6 +967,8 @@ \grammarterm{noexcept-specifier} of a specialization of a function template or member function of a class template is instantiated only when needed. +% +\indextext{exception specification|)} \rSec1[except.special]{Special functions} diff --git a/source/expressions.tex b/source/expressions.tex index 1892267af0..65a8f5910c 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -80,12 +80,12 @@ \end{note} \pnum -If a prvalue initially has the type ``\cv{} \tcode{T}'', where +If a prvalue initially has the type ``\cv{}~\tcode{T}'', where \tcode{T} is a cv-unqualified non-class, non-array type, the type of the expression is adjusted to \tcode{T} prior to any further analysis. \pnum -\indextext{expression!rvalue~reference}% +\indextext{expression!rvalue reference}% \begin{note} An expression is an xvalue if it is: \begin{itemize} @@ -140,7 +140,7 @@ or function-to-pointer~(\ref{conv.func}) standard conversions are applied to convert the expression to a prvalue. \begin{note} -because cv-qualifiers are removed from the type of an expression of +Because cv-qualifiers are removed from the type of an expression of non-class type when the expression is converted to a prvalue, an lvalue expression of type \tcode{const int} can, for example, be used where a prvalue expression of type \tcode{int} is required. @@ -256,18 +256,20 @@ similar to \tcode{T1} whose cv-qualification signature~(\ref{conv.qual}) is: \begin{itemize} \item -for every $j > 0$, \cv$_{3,j}$ is the union of -\cv$_{1,j}$ and \cv$_{2,j}$; +for every $i > 0$, $cv^3_i$ is the union of +$cv^1_i$ and $cv^2_i$; \item -if the resulting \cv$_{3,j}$ is different from -\cv$_{1,j}$ or \cv$_{2,j}$, then -\tcode{const} is added to every \cv$_{3,k}$ for $0 < k < j$. +if the resulting $cv^3_i$ is different from +$cv^1_i$ or $cv^2_i$, then +\tcode{const} is added to every $cv^3_k$ for $0 < k < i$. \end{itemize} \begin{note} Given similar types \tcode{T1} and \tcode{T2}, this construction ensures that both can be converted to \tcode{T3}. \end{note} + +\pnum \indextext{pointer!composite pointer type}% The \defn{composite pointer type} of two operands \tcode{p1} and @@ -505,16 +507,16 @@ \rSec3[expr.prim.id.qual]{Qualified names} -\indextext{operator!scope~resolution}% -\indextext{\idxcode{::}|see{scope~resolution~operator}}% +\indextext{operator!scope resolution}% +\indextext{\idxcode{::}|see{scope resolution operator}}% % \begin{bnf} \nontermdef{qualified-id}\br nested-name-specifier \terminal{template}\opt unqualified-id \end{bnf} -\indextext{operator!scope~resolution}% -\indextext{name~hiding}% +\indextext{operator!scope resolution}% +\indextext{name hiding}% % \begin{bnf} \nontermdef{nested-name-specifier}\br @@ -553,7 +555,7 @@ The form \tcode{\tilde}~\grammarterm{decltype-specifier} also denotes the destructor, but it shall not be used as the \grammarterm{unqualified-id} in a \grammarterm{qualified-id}. \begin{note} -a \grammarterm{typedef-name} that names a class is a +A \grammarterm{typedef-name} that names a class is a \grammarterm{class-name}~(\ref{class.name}). \end{note} @@ -589,22 +591,6 @@ \rSec2[expr.prim.lambda]{Lambda expressions}% \indextext{expression!lambda|(} -\pnum -Lambda expressions provide a concise way to create simple function objects. -\begin{example} - -\begin{codeblock} -#include -#include -void abssort(float* x, unsigned N) { - std::sort(x, x + N, - [](float a, float b) { - return std::abs(a) < std::abs(b); - }); -} -\end{codeblock} -\end{example} - \begin{bnf} \nontermdef{lambda-expression}\br lambda-introducer lambda-declarator\opt compound-statement @@ -660,6 +646,18 @@ \hspace*{\bnfindentinc}noexcept-specifier\opt attribute-specifier-seq\opt trailing-return-type\opt \end{bnf} +\pnum +Lambda expressions provide a concise way to create simple function objects. +\begin{example} +\begin{codeblock} +#include +#include +void abssort(float* x, unsigned N) { + std::sort(x, x + N, [](float a, float b) { return std::abs(a) < std::abs(b); }); +} +\end{codeblock} +\end{example} + \pnum In the \grammarterm{decl-specifier-seq} of the \grammarterm{lambda-declarator}, each \grammarterm{decl-specifier} @@ -774,21 +772,22 @@ invented \grammarterm{template-parameter}. \begin{example} \begin{codeblock} - auto glambda = [](auto a, auto&& b) { return a < b; }; - bool b = glambda(3, 3.14); // OK - auto vglambda = [](auto printer) { - return [=](auto&& ... ts) { // OK: \tcode{ts} is a function parameter pack - printer(std::forward(ts)...); - - return [=]() { - printer(ts ...); - }; - }; +auto glambda = [](auto a, auto&& b) { return a < b; }; +bool b = glambda(3, 3.14); // OK + +auto vglambda = [](auto printer) { + return [=](auto&& ... ts) { // OK: \tcode{ts} is a function parameter pack + printer(std::forward(ts)...); + + return [=]() { + printer(ts ...); + }; }; - auto p = vglambda( [](auto v1, auto v2, auto v3) - { std::cout << v1 << v2 << v3; } ); - auto q = p(1, 'a', 3.14); // OK: outputs \tcode{1a3.14} - q(); // OK: outputs \tcode{1a3.14} +}; +auto p = vglambda( [](auto v1, auto v2, auto v3) + { std::cout << v1 << v2 << v3; } ); +auto q = p(1, 'a', 3.14); // OK: outputs \tcode{1a3.14} +q(); // OK: outputs \tcode{1a3.14} \end{codeblock} \end{example} This function call operator or operator template is declared @@ -1056,12 +1055,12 @@ void test() { const int x = 17; auto g = [](auto a) { - f(x); // OK: calls \#1, does not capture \tcode{x} + f(x); // OK: calls \#1, does not capture \tcode{x} }; auto g2 = [=](auto a) { int selector[sizeof(a) == 1 ? 1 : 2]{}; - f(x, selector); // OK: is a dependent expression, so captures \tcode{x} + f(x, selector); // OK: is a dependent expression, so captures \tcode{x} }; } \end{codeblock} @@ -1093,8 +1092,7 @@ int const M = 30; auto m2 = [i]{ int x[N][M]; // OK: \tcode{N} and \tcode{M} are not odr-used - x[0][0] = i; // OK: \tcode{i} is explicitly captured by \tcode{m2} - // and implicitly captured by \tcode{m1} + x[0][0] = i; // OK: \tcode{i} is explicitly captured by \tcode{m2} and implicitly captured by \tcode{m1} }; }; struct s1 { @@ -1104,13 +1102,10 @@ int j = 40; auto m3 = [this,m] { auto m4 = [&,j] { // error: \tcode{j} not captured by \tcode{m3} - int x = n; // error: \tcode{n} implicitly captured by \tcode{m4} - // but not captured by \tcode{m3} - x += m; // OK: \tcode{m} implicitly captured by \tcode{m4} - // and explicitly captured by \tcode{m3} + int x = n; // error: \tcode{n} implicitly captured by \tcode{m4} but not captured by \tcode{m3} + x += m; // OK: \tcode{m} implicitly captured by \tcode{m4} and explicitly captured by \tcode{m3} x += i; // error: \tcode{i} is outside of the reaching scope - x += f; // OK: \tcode{this} captured implicitly by \tcode{m4} - // and explicitly by \tcode{m3} + x += f; // OK: \tcode{this} captured implicitly by \tcode{m4} and explicitly by \tcode{m3} }; }; } @@ -1122,13 +1117,13 @@ auto f() { return [this] { return [*this] { - return ohseven; // OK + return ohseven; // OK } }(); } auto g() { return [] { - return [*this] { }; // error: \tcode{*this} not captured by outer \grammarterm{lambda-expression} + return [*this] { }; // error: \tcode{*this} not captured by outer \grammarterm{lambda-expression} }(); } }; @@ -1142,17 +1137,17 @@ \begin{codeblock} void f2() { int i = 1; - void g1(int = ([i]{ return i; })()); // ill-formed - void g2(int = ([i]{ return 0; })()); // ill-formed - void g3(int = ([=]{ return i; })()); // ill-formed - void g4(int = ([=]{ return 0; })()); // OK - void g5(int = ([]{ return sizeof i; })()); // OK + void g1(int = ([i]{ return i; })()); // ill-formed + void g2(int = ([i]{ return 0; })()); // ill-formed + void g3(int = ([=]{ return i; })()); // ill-formed + void g4(int = ([=]{ return 0; })()); // OK + void g5(int = ([]{ return sizeof i; })()); // OK } \end{codeblock} \end{example} \pnum -An entity is \defnx{captured by copy}{captured!by~copy} if +An entity is \defnx{captured by copy}{captured!by copy} if \begin{itemize} \item it is implicitly captured, @@ -1190,16 +1185,16 @@ void g() { const int N = 10; [=] { - int arr[N]; // OK: not an odr-use, refers to automatic variable - f(&N); // OK: causes \tcode{N} to be captured; \tcode{\&N} points to the - // corresponding member of the closure type + int arr[N]; // OK: not an odr-use, refers to automatic variable + f(&N); // OK: causes \tcode{N} to be captured; \tcode{\&N} points to + // the corresponding member of the closure type }; } \end{codeblock} \end{example} \pnum -An entity is \defnx{captured by reference}{captured!by~reference} if it is implicitly or explicitly +An entity is \defnx{captured by reference}{captured!by reference} if it is implicitly or explicitly captured but not captured by copy. It is unspecified whether additional unnamed non-static data members are declared in the closure type for entities captured by reference. @@ -1227,7 +1222,7 @@ \tcode{m2} captures the same entity captured by \tcode{m1}. \end{itemize} -\begin{example} the nested lambda expressions and invocations below will output +\begin{example} The nested lambda expressions and invocations below will output \tcode{123234}. \begin{codeblock} int a = 1, b = 1, c = 1; @@ -1257,8 +1252,7 @@ float x, &r = x; [=] { // \tcode{x} and \tcode{r} are not captured (appearance in a \tcode{decltype} operand is not an odr-use) decltype(x) y1; // \tcode{y1} has type \tcode{float} - decltype((x)) y2 = y1; // \tcode{y2} has type \tcode{float const\&} because this lambda - // is not \tcode{mutable} and \tcode{x} is an lvalue + decltype((x)) y2 = y1; // \tcode{y2} has type \tcode{float const\&} because this lambda is not \tcode{mutable} and \tcode{x} is an lvalue decltype(r) r1 = y1; // \tcode{r1} has type \tcode{float\&} (transformation not considered) decltype((r)) r2 = y2; // \tcode{r2} has type \tcode{float const\&} }; @@ -1313,8 +1307,7 @@ } \end{codeblock} \end{example}% -\indextext{expression!lambda|)}% -\indextext{expression!primary|)} +\indextext{expression!lambda|)} \rSec2[expr.prim.fold]{Fold expressions}% \indextext{expression!fold|(} @@ -1331,9 +1324,11 @@ \end{bnf} \begin{bnf} +%% Ed. note: character protrusion would misalign operators with leading `-`. +\microtypesetup{protrusion=false} \nontermdef{fold-operator} \textnormal{one of}\br - \terminal{+ }\quad\terminal{- }\quad\terminal{* }\quad\terminal{/ }\quad\terminal{\% }\quad\terminal{\caret }\quad\terminal{\& }\quad\terminal{| }\quad\terminal{\shl\ }\quad\terminal{\shr }\br - \terminal{+=}\quad\terminal{-=}\quad\terminal{*=}\quad\terminal{/=}\quad\terminal{\%=}\quad\terminal{\caret=}\quad\terminal{\&=}\quad\terminal{|=}\quad\terminal{\shl=}\quad\terminal{\shr=}\quad\terminal{=}\br + \terminal{+ }\quad\terminal{- }\quad\terminal{* }\quad\terminal{/ }\quad\terminal{\% }\quad\terminal{\caret{} }\quad\terminal{\& }\quad\terminal{| }\quad\terminal{<< }\quad\terminal{>> }\br + \terminal{+=}\quad\terminal{-=}\quad\terminal{*=}\quad\terminal{/=}\quad\terminal{\%=}\quad\terminal{\caret=}\quad\terminal{\&=}\quad\terminal{|=}\quad\terminal{<<=}\quad\terminal{>>=}\quad\terminal{=}\br \terminal{==}\quad\terminal{!=}\quad\terminal{< }\quad\terminal{> }\quad\terminal{<=}\quad\terminal{>=}\quad\terminal{\&\&}\quad\terminal{||}\quad\terminal{, }\quad\terminal{.* }\quad\terminal{->*} \end{bnf} @@ -1380,11 +1375,12 @@ template bool f(Args ...args) { - return (args + ... + args); // error: both operands contain unexpanded parameter packs + return (args + ... + args); // error: both operands contain unexpanded parameter packs } \end{codeblock} \end{example} -\indextext{expression!fold|)} +\indextext{expression!fold|)}% +\indextext{expression!primary|)} \rSec1[expr.post]{Postfix expressions}% \indextext{expression!postfix|(} @@ -1432,7 +1428,7 @@ \pnum \begin{note} The \tcode{>} token following the -\nonterminal{type-id} in a \tcode{dynamic_cast}, +\grammarterm{type-id} in a \tcode{dynamic_cast}, \tcode{static_cast}, \tcode{reinterpret_cast}, or \tcode{const_cast} may be the product of replacing a \tcode{>{>}} token by two consecutive \tcode{>} @@ -1467,9 +1463,9 @@ \rSec2[expr.call]{Function call} \pnum -\indextext{expression!function~call}% -\indextext{operator!function~call}% -\indextext{\idxcode{()}|see{operator, function~call}}% +\indextext{expression!function call}% +\indextext{operator!function call}% +\indextext{\idxcode{()}|see{operator, function call}}% A function call is a postfix expression followed by parentheses containing a possibly empty, comma-separated list of \grammarterm{initializer-clause}{s} which @@ -1503,7 +1499,7 @@ member access expression is a \grammarterm{qualified-id}, that function is called. Otherwise, its final overrider~(\ref{class.virtual}) in the dynamic type of the object expression is called; such a call is referred to as a -\defnx{virtual function call}{function!virtual function~call}. +\defnx{virtual function call}{function!virtual function call}. \begin{note} The dynamic type is the type of the object referred to by the current value of the object expression. \ref{class.cdtor}~describes the @@ -1527,12 +1523,11 @@ statically chosen function (i.e., ignoring the \tcode{virtual} keyword), even if the type of the function actually called is different. \indextext{type!incomplete}% -This return type shall be an object type, a reference type or \cv{} -\tcode{void}. +This return type shall be an object type, a reference type or \cv{}~\tcode{void}. \pnum -\indextext{function~argument|see{argument}}% -\indextext{function~parameter|see{parameter}}% +\indextext{function argument|see{argument}}% +\indextext{function parameter|see{parameter}}% \indextext{initialization!parameter}% When a function is called, each parameter~(\ref{dcl.fct}) shall be initialized~(\ref{dcl.init},~\ref{class.copy},~\ref{class.ctor}) with @@ -1562,7 +1557,7 @@ The initialization and destruction of each parameter occurs within the context of the calling function. \begin{example} -the access of the constructor, conversion functions or destructor is +The access of the constructor, conversion functions or destructor is checked at the point of call in the calling function. If a constructor or destructor for a function parameter throws an exception, the search for a handler starts in the scope of the calling function; in @@ -1572,9 +1567,9 @@ \end{example} \pnum -\indextext{evaluation!order~of argument}% -\indextext{evaluation!unspecified order~of function~call}% -\indextext{evaluation!unspecified order~of argument}% +\indextext{evaluation!order of argument}% +\indextext{evaluation!unspecified order of function call}% +\indextext{evaluation!unspecified order of argument}% The \grammarterm{postfix-expression} is sequenced before each \grammarterm{expression} in the \grammarterm{expression-list} and any default argument. @@ -1628,13 +1623,13 @@ \pnum \begin{note} -\indextext{type~checking!argument}% -\indextext{function~call}% -\indextext{argument~passing}% -\indextext{value!call~by}% -\indextext{reference!call~by}% +\indextext{type checking!argument}% +\indextext{function call}% +\indextext{argument passing}% +\indextext{value!call by}% +\indextext{reference!call by}% \indextext{argument!reference}% -a function can change the values of its non-const parameters, but these +A function can change the values of its non-const parameters, but these changes cannot affect the values of the arguments except where a parameter is of a reference type~(\ref{dcl.ref}); if the reference is to a const-qualified type, \tcode{const_cast} is required to be used to @@ -1647,19 +1642,19 @@ \end{note} \pnum -\indextext{declaration!ellipsis~in function}% -\indextext{parameter~list!variable}% +\indextext{declaration!ellipsis in function}% +\indextext{parameter list!variable}% A function can be declared to accept fewer arguments (by declaring default arguments~(\ref{dcl.fct.default})) or more arguments (by using the ellipsis, \tcode{...}, or a function parameter pack~(\ref{dcl.fct})) than the number of parameters in the function definition~(\ref{dcl.fct.def}). \begin{note} -this implies that, except where the ellipsis (\tcode{...}) or a function +This implies that, except where the ellipsis (\tcode{...}) or a function parameter pack is used, a parameter is available for each argument. \end{note} \pnum -\indextext{ellipsis!conversion~sequence}% +\indextext{ellipsis!conversion sequence}% When there is no parameter for a given argument, the argument is passed in such a way that the receiving function can obtain the value of the argument by invoking \tcode{va_arg}~(\ref{support.runtime}). @@ -1671,7 +1666,7 @@ lvalue-to-rvalue~(\ref{conv.lval}), array-to-pointer~(\ref{conv.array}), and function-to-pointer~(\ref{conv.func}) standard conversions are performed on the argument expression. -An argument that has (possibly cv-qualified) type \tcode{std::nullptr_t} is converted +An argument that has type \cv{}~\tcode{std::nullptr_t} is converted to type \tcode{void*}~(\ref{conv.ptr}). After these conversions, if the argument does not have arithmetic, enumeration, pointer, pointer to @@ -1682,13 +1677,13 @@ non-trivial destructor, with no corresponding parameter, is conditionally-supported with \impldef{passing argument of class type through ellipsis} semantics. If the argument has integral or enumeration type that is subject to the integral -promotions~(\ref{conv.prom}), or a floating-point type that is subject to the floating -point promotion~(\ref{conv.fpprom}), the value of the argument is converted to the +promotions~(\ref{conv.prom}), or a floating-point type that is subject to the +floating-point promotion~(\ref{conv.fpprom}), the value of the argument is converted to the promoted type before the call. These promotions are referred to as the \defnx{default argument promotions}{promotion!default argument promotion}. \pnum -\indextext{function~call!recursive}% +\indextext{function call!recursive}% Recursive calls are permitted, except to the \tcode{main} function~(\ref{basic.start.main}). @@ -1702,9 +1697,9 @@ \pnum \indextext{expression!cast}% -\indextext{explicit~type~conversion|see{casting}}% -\indextext{type~conversion,~explicit|see{casting}}% -\indextext{conversion~explicit~type|see{casting}}% +\indextext{explicit type conversion|see{casting}}% +\indextext{type conversion, explicit|see{casting}}% +\indextext{conversion explicit type|see{casting}}% \indextext{casting}% A \grammarterm{simple-type-specifier}~(\ref{dcl.type.simple}) or \grammarterm{typename-specifier}~(\ref{temp.res}) followed @@ -1727,7 +1722,7 @@ definedness, and if defined in meaning) to the corresponding cast expression~(\ref{expr.cast}). \indextext{type!incomplete}% -If the type is (possibly cv-qualified) \tcode{void} +If the type is \cv{}~\tcode{void} and the initializer is \tcode{()}, the expression is a prvalue of the specified type that performs no initialization. @@ -1741,8 +1736,8 @@ \rSec2[expr.pseudo]{Pseudo destructor call} \pnum -\indextext{expression!pseudo-destructor~call}% -\indextext{call!pseudo~destructor}% +\indextext{expression!pseudo-destructor call}% +\indextext{call!pseudo destructor}% \indextext{pseudo-destructor-name}% The use of a \grammarterm{pseudo-destructor-name} after a dot \tcode{.} or arrow \tcode{->} operator represents the destructor for the non-class @@ -1770,16 +1765,16 @@ \rSec2[expr.ref]{Class member access} \pnum -\indextext{expression!class~member~access}% +\indextext{expression!class member access}% \indextext{access control!class member}% -\indextext{syntax!class~member}% -\indextext{semantics!class~member}% -\indextext{operator!class~member~access}% -\indextext{\idxcode{.}|see{operator, class~member~access}}% -\indextext{dot~operator|see{operator, class~member~access}}% -\indextext{operator!class~member~access}% -\indextext{\idxcode{->}|see{operator, class~member~access}}% -\indextext{arrow~operator|see{operator, class~member~access}}% +\indextext{syntax!class member}% +\indextext{semantics!class member}% +\indextext{operator!class member access}% +\indextext{\idxcode{.}|see{operator, class member access}}% +\indextext{dot operator|see{operator, class member access}}% +\indextext{operator!class member access}% +\indextext{\idxcode{->}|see{operator, class member access}}% +\indextext{arrow operator|see{operator, class member access}}% A postfix expression followed by a dot \tcode{.} or an arrow \tcode{->}, optionally followed by the keyword \tcode{template}~(\ref{temp.names}), and then followed by an @@ -1902,14 +1897,14 @@ \indextext{expression!increment}% \indextext{operator!increment}% \indextext{\idxcode{++}|see{operator, increment}}% -\indextext{postfix~\tcode{++}}% +\indextext{postfix \tcode{++}}% The value of a postfix \tcode{++} expression is the value of its operand. \begin{note} -the value obtained is a copy of the original value +The value obtained is a copy of the original value \end{note} The operand shall be a modifiable lvalue. The type of the operand shall -be an arithmetic type other than \cv{} \tcode{bool}, +be an arithmetic type other than \cv{}~\tcode{bool}, or a pointer to a complete object type. The value of the operand object is modified by adding \tcode{1} to it. The @@ -1936,7 +1931,7 @@ \indextext{expression!decrement}% \indextext{operator!decrement}% \indextext{\idxcode{\dcr}|see{operator, decrement}}% -\indextext{postfix~\tcode{\dcr}}% +\indextext{postfix \tcode{\dcr}}% The operand of postfix \tcode{\dcr} is decremented analogously to the postfix \tcode{++} operator. \begin{note} @@ -1946,7 +1941,7 @@ \rSec2[expr.dynamic.cast]{Dynamic cast} \pnum -\indextext{expression!dynamic~cast}% +\indextext{expression!dynamic cast}% \indextext{cast!dynamic}% The result of the expression \tcode{dynamic_cast(v)} is the result of converting the expression \tcode{v} to type \tcode{T}. @@ -1982,8 +1977,8 @@ \tcode{T} is ``reference to \cvqual{cv1} \tcode{B}'' and \tcode{v} has type \cvqual{cv2} \tcode{D} such that \tcode{B} is a base class of \tcode{D}, the result is the unique \tcode{B} subobject of the \tcode{D} -object referred to by \tcode{v}. -\footnote{The most derived object~(\ref{intro.object}) pointed or referred to by +object referred to by \tcode{v}.\footnote{The most derived +object~(\ref{intro.object}) pointed or referred to by \tcode{v} can contain other \tcode{B} objects as base classes, but these are ignored.} In both the pointer and @@ -2062,8 +2057,7 @@ void h() { F f; A* ap = &f; // succeeds: finds unique \tcode{A} - D* dp = dynamic_cast(ap); // fails: yields \tcode{0} - // \tcode{f} has two \tcode{D} subobjects + D* dp = dynamic_cast(ap); // fails: yields null; \tcode{f} has two \tcode{D} subobjects E* ep = (E*)ap; // ill-formed: cast from virtual base E* ep1 = dynamic_cast(ap); // succeeds } @@ -2077,7 +2071,7 @@ \rSec2[expr.typeid]{Type identification} \pnum -\indextext{expression!type~identification}% +\indextext{expression!type identification}% \indextext{\idxcode{typeid}}% The result of a \tcode{typeid} expression is an lvalue of static type \indextext{\idxcode{type_info}}% @@ -2085,7 +2079,7 @@ \tcode{const} \tcode{std::type_info}~(\ref{type.info}) and dynamic type \tcode{const} \tcode{std::type_info} or \tcode{const} \term{name} where \term{name} is an \impldef{derived type for \tcode{typeid}} class publicly derived from -\tcode{std\,::\,type_info} which preserves the behavior described +\tcode{std::type_info} which preserves the behavior described in~\ref{type.info}.\footnote{The recommended name for such a class is \tcode{extended_type_info}.} The lifetime of the object referred to by the lvalue extends to the end @@ -2140,7 +2134,7 @@ \begin{example} \begin{codeblock} -class D @\tcode{\{ /* ... */ \}}@; +class D { @\commentellip@ }; D d1; const D d2; @@ -2164,7 +2158,7 @@ \rSec2[expr.static.cast]{Static cast} \pnum -\indextext{expression!static~cast}% +\indextext{expression!static cast}% \indextext{cast!static}% The result of the expression \tcode{static_cast(v)} is the result of converting the expression \tcode{v} to type \tcode{T}. @@ -2247,8 +2241,8 @@ \tcode{static_cast}. \pnum -Any expression can be explicitly converted to type \cv{} -\tcode{void}, in which case it becomes a discarded-value +Any expression can be explicitly converted to type \cv{}~\tcode{void}, +in which case it becomes a discarded-value expression (Clause~\ref{expr}). \begin{note} However, if the value is in a temporary @@ -2275,8 +2269,8 @@ struct B { }; struct D : private B { }; void f() { - static_cast((B*)0); // Error: B is a private base of D. - static_cast((int D::*)0); // Error: B is a private base of D. + static_cast((B*)0); // error: \tcode{B} is a private base of \tcode{D} + static_cast((int D::*)0); // error: \tcode{B} is a private base of \tcode{D} } \end{codeblock} \end{example} @@ -2292,7 +2286,7 @@ \pnum A value of a scoped enumeration type~(\ref{dcl.enum}) can be explicitly converted to an -integral type. When that type is \cv{} \tcode{bool}, the resulting value is +integral type. When that type is \cv{}~\tcode{bool}, the resulting value is \tcode{false} if the original value is zero and \tcode{true} for all other values. For the remaining integral types, the value is unchanged if the original value can be represented by the @@ -2302,8 +2296,8 @@ value to the floating-point type. \pnum -\indextext{enumeration~type!conversion~to}% -\indextext{enumeration~type!\idxcode{static_cast}!conversion~to}% +\indextext{enumeration type!conversion to}% +\indextext{enumeration type!\idxcode{static_cast}!conversion to}% A value of integral or enumeration type can be explicitly converted to a complete enumeration type. The value is unchanged if the original value is within the range of the enumeration values~(\ref{dcl.enum}). Otherwise, @@ -2314,8 +2308,8 @@ the enumeration type. \pnum -\indextext{cast!base~class}% -\indextext{cast!derived~class}% +\indextext{cast!base class}% +\indextext{cast!derived class}% A prvalue of type ``pointer to \cvqual{cv1} \tcode{B}'', where \tcode{B} is a class type, can be converted to a prvalue of type ``pointer to \cvqual{cv2} \tcode{D}'', where \tcode{D} is a class derived @@ -2353,7 +2347,7 @@ containing the original member, the resulting pointer to member points to the original member. Otherwise, the behavior is undefined. \begin{note} -although class \tcode{B} need not contain the original member, the +Although class \tcode{B} need not contain the original member, the dynamic type of the object with which indirection through the pointer to member is performed must contain the original member; see~\ref{expr.mptr.oper}. @@ -2385,7 +2379,7 @@ \rSec2[expr.reinterpret.cast]{Reinterpret cast} \pnum -\indextext{expression!reinterpret~cast}% +\indextext{expression!reinterpret cast}% \indextext{cast!reinterpret}% The result of the expression \tcode{reinterpret_cast(v)} is the result of converting the expression \tcode{v} to type \tcode{T}. @@ -2414,11 +2408,11 @@ \pnum \indextext{cast!reinterpret!pointer to integer}% -\indextext{cast!pointer~to integer}% +\indextext{cast!pointer to integer}% A pointer can be explicitly converted to any integral type large enough to hold it. -\indextext{conversion!implementation~defined pointer integer}% -The mapping function is implementa\-tion-defined. +\indextext{conversion!implementation-defined pointer integer}% +The mapping function is \impldef{mapping of pointer to integer}. \begin{note} It is intended to be unsurprising to those who know the addressing structure of the underlying machine. @@ -2429,13 +2423,13 @@ \tcode{std::nullptr_t}. \end{note} \pnum -\indextext{cast!reinterpret!integer~to pointer}% -\indextext{cast!integer~to pointer}% +\indextext{cast!reinterpret!integer to pointer}% +\indextext{cast!integer to pointer}% A value of integral type or enumeration type can be explicitly converted to a pointer. A pointer converted to an integer of sufficient size (if any such exists on the implementation) and back to the same pointer type will have its original value; -\indextext{conversion!implementation~defined pointer integer}% +\indextext{conversion!implementation-defined pointer integer}% mappings between pointers and integers are otherwise \impldef{conversions between pointers and integers}. \begin{note} Except as described in \ref{basic.stc.dynamic.safety}, the result of @@ -2447,7 +2441,7 @@ \indextext{cast!undefined pointer-to-function}% A function pointer can be explicitly converted to a function pointer of a different type. -\indextext{function~call!undefined}% +\indextext{function call!undefined}% \begin{note} The effect of calling a function through a pointer to a function type~(\ref{dcl.fct}) that is not the same as the type used in the @@ -2469,8 +2463,7 @@ the overall restriction that a \tcode{reinterpret_cast} cannot cast away constness.} When a prvalue \tcode{v} of object pointer type is converted to -the object pointer type ``pointer to \cv{} \tcode{T}'', the result is \tcode{static_cast<\cv{} T*>(static_cast<\cv{} -void*>(v))}. +the object pointer type ``pointer to \cv{}~\tcode{T}'', the result is \tcode{static_cast<\cv{} T*>(static_cast<\cv{}~void*>(v))}. \begin{note} Converting a prvalue of type ``pointer to \tcode{T1}'' to the type ``pointer to \tcode{T2}'' (where \tcode{T1} and \tcode{T2} are @@ -2539,12 +2532,12 @@ temporary is created, no copy is made, and constructors~(\ref{class.ctor}) or conversion functions~(\ref{class.conv}) are not called.\footnote{This -is sometimes referred to as a \defnx{type pun}{type~pun}.} +is sometimes referred to as a \defn{type pun}.} \rSec2[expr.const.cast]{Const cast} \pnum -\indextext{expression!const~cast}% +\indextext{expression!const cast}% \indextext{cast!const}% The result of the expression \tcode{const_cast(v)} is of type \tcode{T}. If \tcode{T} is an lvalue reference to object type, the result is an @@ -2574,8 +2567,8 @@ typedef const int *const CA[3]; // array of 3 const pointer to \tcode{const int} CA &&r = A{}; // OK, reference binds to temporary array object after qualification conversion to type \tcode{CA} -A &&r1 = const_cast(CA{}); // error: temporary array decayed to pointer -A &&r2 = const_cast(CA{}); // OK +A &&r1 = const_cast(CA{}); // error: temporary array decayed to pointer +A &&r2 = const_cast(CA{}); // OK \end{codeblock} \end{example} @@ -2685,14 +2678,14 @@ \indextext{\idxcode{*}|see{operator, indirection}}% \indextext{operator!address-of}% \indextext{\idxcode{\&}|see{operator, address-of}}% -\indextext{operator!unary~minus}% -\indextext{\idxcode{-}|see{operator, unary~minus}}% -\indextext{operator!unary~plus}% -\indextext{\idxcode{+}|see{operator, unary~plus}}% +\indextext{operator!unary minus}% +\indextext{\idxcode{-}|see{operator, unary minus}}% +\indextext{operator!unary plus}% +\indextext{\idxcode{+}|see{operator, unary plus}}% \indextext{operator!logical negation}% -\indextext{\idxcode{"!}|see{operator, logical~negation}}% -\indextext{operator!ones'~complement}% -\indextext{~@\tcode{\tilde}|see{operator, ones'~complement}}% +\indextext{\idxcode{"!}|see{operator, logical negation}}% +\indextext{operator!ones' complement}% +\indextext{~@\tcode{\tilde}|see{operator, ones' complement}}% \indextext{operator!increment}% \indextext{operator!decrement}% % @@ -2704,7 +2697,7 @@ \rSec2[expr.unary.op]{Unary operators} \pnum -\indextext{expression!unary~operator}% +\indextext{expression!unary operator}% \indextext{operator!unary}% The unary \tcode{*} operator performs \defn{indirection}: \indextext{dereferencing|seealso{indirection}}% @@ -2725,8 +2718,8 @@ The result of each of the following unary operators is a prvalue. \pnum -\indextext{name!address~of cv-qualified}% -\indextext{expression!pointer~to~member constant}% +\indextext{name!address of cv-qualified}% +\indextext{expression!pointer to member constant}% The result of the unary \tcode{\&} operator is a pointer to its operand. The operand shall be an lvalue or a \grammarterm{qualified-id}. If the operand is a \grammarterm{qualified-id} naming a non-static or variant member \tcode{m} @@ -2735,7 +2728,7 @@ Otherwise, if the type of the expression is \tcode{T}, the result has type ``pointer to \tcode{T}'' and is a prvalue that is the address of the designated object~(\ref{intro.memory}) or a pointer to the designated function. \begin{note} In particular, the address of an -object of type ``\cv{} \tcode{T}'' is ``pointer to \cv{} \tcode{T}'', with the same +object of type ``\cv{}~\tcode{T}'' is ``pointer to \cv{}~\tcode{T}'', with the same cv-qualification. \end{note} For purposes of pointer arithmetic~(\ref{expr.add}) and comparison~(\ref{expr.rel}, \ref{expr.eq}), @@ -2783,7 +2776,7 @@ called. The operand of \tcode{\&} shall not be a bit-field. \pnum -\indextext{overloaded~function!address~of}% +\indextext{overloaded function!address of}% The address of an overloaded function (Clause~\ref{over}) can be taken only in a context that uniquely determines which version of the overloaded function is referred to (see~\ref{over.over}). @@ -2795,14 +2788,14 @@ \end{note} \pnum -\indextext{operator!unary~plus}% +\indextext{operator!unary plus}% The operand of the unary \tcode{+} operator shall have arithmetic, unscoped enumeration, or pointer type and the result is the value of the argument. Integral promotion is performed on integral or enumeration operands. The type of the result is the type of the promoted operand. \pnum -\indextext{operator!unary~minus}% +\indextext{operator!unary minus}% The operand of the unary \tcode{-} operator shall have arithmetic or unscoped enumeration type and the result is the negation of its operand. Integral promotion is performed on integral or enumeration operands. The negative @@ -2820,7 +2813,7 @@ \pnum \indextext{signed integer representation!ones' complement}% -\indextext{operator!ones'~complement}% +\indextext{operator!ones' complement}% The operand of \tcode{\~{}} shall have integral or unscoped enumeration type; the result is the ones' complement of its operand. Integral promotions are performed. The type of the result is the type of the promoted operand. @@ -2845,11 +2838,11 @@ \indextext{expression!decrement}% The operand of prefix \tcode{++} \indextext{operator!increment}% -\indextext{prefix~\tcode{++}}% +\indextext{prefix \tcode{++}}% is modified by adding \tcode{1}. -\indextext{prefix~\tcode{\dcr}}% +\indextext{prefix \tcode{\dcr}}% The operand shall be a modifiable lvalue. The type of the operand shall -be an arithmetic type other than \cv{} \tcode{bool}, +be an arithmetic type other than \cv{}~\tcode{bool}, or a pointer to a completely-defined object type. The result is the updated operand; it is an lvalue, and it is a bit-field if the operand is a bit-field. @@ -2906,7 +2899,7 @@ \indextext{reference!\idxcode{sizeof}}% When applied to a reference or a reference type, the result is the size of the referenced type. -\indextext{class~object!\idxcode{sizeof}}% +\indextext{class object!\idxcode{sizeof}}% When applied to a class, the result is the number of bytes in an object of that class including any padding required for placing objects of that type in an array. The size of a most derived class shall be greater than @@ -2956,16 +2949,16 @@ \indexlibrary{\idxcode{size_t}}% \tcode{std::size_t} is defined in the standard header \indextext{\idxhdr{cstddef}}% -\tcode{}~(\ref{support.types}). +\tcode{}~(\ref{cstddef.syn}, \ref{support.types.layout}). \end{note} \rSec2[expr.new]{New} \pnum \indextext{expression!\idxcode{new}}% -\indextext{free~store|seealso{\tcode{new},~\tcode{delete}}}% -\indextext{memory~management|seealso{\tcode{new},~\tcode{delete}}}% -\indextext{storage~management|see{\tcode{new},~\tcode{delete}}}% +\indextext{free store|seealso{\tcode{new}, \tcode{delete}}}% +\indextext{memory management|seealso{\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 \grammarterm{type-id}~(\ref{dcl.name}) or \grammarterm{new-type-id} to which @@ -3019,11 +3012,11 @@ braced-init-list \end{bnf} -\indextext{storage~duration!dynamic}% +\indextext{storage duration!dynamic}% Entities created by a \grammarterm{new-expression} have dynamic storage duration~(\ref{basic.stc.dynamic}). \begin{note} -\indextext{\idxcode{new}!scoping~and}% +\indextext{\idxcode{new}!scoping and}% The lifetime of such an entity is not necessarily restricted to the scope in which it is created. \end{note} @@ -3034,19 +3027,19 @@ \pnum If a placeholder type~(\ref{dcl.spec.auto}) appears in the -\nonterminal{type-specifier-seq} of a \nonterminal{new-type-id} or -\nonterminal{type-id} of a \nonterminal{new-expression}, -the \nonterminal{new-expression} shall contain a -\nonterminal{new-initializer} of the form +\grammarterm{type-specifier-seq} of a \grammarterm{new-type-id} or +\grammarterm{type-id} of a \grammarterm{new-expression}, +the \grammarterm{new-expression} shall contain a +\grammarterm{new-initializer} of the form \begin{ncsimplebnf} \terminal{(} assignment-expression \terminal{)} \end{ncsimplebnf} -The allocated type is deduced from the \nonterminal{new-initializer} as -follows: Let \tcode{e} be the \grammarterm{assignment-expression} in the \nonterminal{new-initializer} and -\tcode{T} be the \nonterminal{new-type-id} or \nonterminal{type-id} of -the \nonterminal{new-expression}, then the allocated type is the type +The allocated type is deduced from the \grammarterm{new-initializer} as +follows: Let \tcode{e} be the \grammarterm{assignment-expression} in the \grammarterm{new-initializer} and +\tcode{T} be the \grammarterm{new-type-id} or \grammarterm{type-id} of +the \grammarterm{new-expression}, then the allocated type is the type deduced for the variable \tcode{x} in the invented declaration~(\ref{dcl.spec.auto}): @@ -3065,7 +3058,7 @@ The \grammarterm{new-type-id} in a \grammarterm{new-expression} is the longest possible sequence of \grammarterm{new-declarator}{s}. \begin{note} -this prevents ambiguities between the declarator operators \tcode{\&}, \tcode{\&\&}, +This prevents ambiguities between the declarator operators \tcode{\&}, \tcode{\&\&}, \tcode{*}, and \tcode{[]} and their expression counterparts. \end{note} \begin{example} @@ -3079,8 +3072,8 @@ \pnum \begin{note} -\indextext{ambiguity!parentheses~and}% -parentheses in a \grammarterm{new-type-id} of a \grammarterm{new-expression} +\indextext{ambiguity!parentheses and}% +Parentheses in a \grammarterm{new-type-id} of a \grammarterm{new-expression} can have surprising effects. \begin{example} @@ -3127,10 +3120,10 @@ expression~(\ref{expr.const}) of type \tcode{std\colcol{}size_t} and shall evaluate to a strictly positive value. \indextext{\idxcode{new}}% -The \grammarterm{expression} in a \grammarterm{noptr-new-declarator}is +The \grammarterm{expression} in a \grammarterm{noptr-new-declarator} is implicitly converted to \tcode{std\colcol{}size_t}. \begin{example} -given the definition \tcode{int n = 42}, +Given the definition \tcode{int n = 42}, \tcode{new float[n][5]} is well-formed (because \tcode{n} is the \grammarterm{expression} of a \grammarterm{noptr-new-declarator}), but \tcode{new float[5][n]} is ill-formed (because \tcode{n} is not a @@ -3218,7 +3211,7 @@ \end{note} \pnum -\indextext{operator!scope~resolution}% +\indextext{operator!scope resolution}% If the \grammarterm{new-expression} begins with a unary \tcode{::} operator, the allocation function's name is looked up in the global scope. Otherwise, if the allocated type is a class type \tcode{T} or @@ -3296,7 +3289,7 @@ alignment requirement~(\ref{basic.align}) of any object type whose size is no greater than the size of the array being created. \begin{note} -\indextext{allocation!alignment~storage}% +\indextext{allocation!alignment storage}% Because allocation functions are assumed to return pointers to storage that is appropriately aligned for objects of any type with fundamental alignment, this constraint @@ -3312,11 +3305,11 @@ padding necessary to align the allocated objects within the allocated memory. \pnum -\indextext{placement~syntax!\idxcode{new}}% +\indextext{placement syntax!\idxcode{new}}% \indextext{new-expression@\grammarterm{new-expression}!placement}% The \grammarterm{new-placement} syntax is used to supply additional arguments to an allocation function; such an expression is called -a \defnx{placement \grammarterm{new-expression}}{placement~new-expression@placement \grammarterm{new-expression}}{.} +a \defnx{placement \grammarterm{new-expression}}{placement new-expression@placement \grammarterm{new-expression}}{.} \pnum Overload resolution is @@ -3396,7 +3389,7 @@ \pnum \begin{note} -when the allocation function returns a value other than null, it must be +When the allocation function returns a value other than null, it must be a pointer to a block of storage in which space for the object has been reserved. The block of storage is assumed to be appropriately aligned and of the requested size. The address of the created object will not @@ -3404,13 +3397,13 @@ \end{note} \pnum -\indextext{\idxcode{new}!array~of class~objects~and}% -\indextext{\idxcode{new}!initialization~and}% -\indextext{\idxcode{new}!constructor~and}% -\indextext{\idxcode{new}!default~constructor~and}% -\indextext{default~constructor|see{constructor, default}}% -\indextext{trivial~type}% -\indextext{trivial~class~type}% +\indextext{\idxcode{new}!array of class objects and}% +\indextext{\idxcode{new}!initialization and}% +\indextext{\idxcode{new}!constructor and}% +\indextext{\idxcode{new}!default constructor and}% +\indextext{default constructor|see{constructor, default}}% +\indextext{trivial type}% +\indextext{trivial class type}% A \grammarterm{new-expression} that creates an object of type \tcode{T} initializes that object as follows: @@ -3424,8 +3417,8 @@ \end{itemize} \pnum -\indextext{\idxcode{new}!unspecified order~of evaluation}% -\indextext{\idxcode{new}!unspecified constructor~and}% +\indextext{\idxcode{new}!unspecified order of evaluation}% +\indextext{\idxcode{new}!unspecified constructor and}% The invocation of the allocation function is sequenced before the evaluations of expressions in the \grammarterm{new-initializer}. Initialization of the allocated object is sequenced before the @@ -3442,7 +3435,7 @@ invoked~(\ref{class.dtor}). \pnum -\indextext{\idxcode{new}!exception~and}% +\indextext{\idxcode{new}!exception and}% If any part of the object initialization described above\footnote{This may include evaluating a \grammarterm{new-initializer} and/or calling a constructor.} @@ -3574,7 +3567,7 @@ \grammarterm{new-expression}. \end{note} \begin{note} -a pointer to a \tcode{const} type can be the operand of a +A pointer to a \tcode{const} type can be the operand of a \grammarterm{delete-expression}; it is not necessary to cast away the constness~(\ref{expr.const.cast}) of the pointer expression before it is used as the operand of the \grammarterm{delete-expression}. @@ -3600,7 +3593,7 @@ deallocation function, the behavior is undefined. \pnum -\indextext{\idxcode{delete}!destructor~and}% +\indextext{\idxcode{delete}!destructor and}% If the value of the operand of the \grammarterm{delete-expression} is not a null pointer value, the \grammarterm{delete-expression} will invoke the destructor (if any) for the object or the elements of the array being @@ -3648,7 +3641,7 @@ An implementation provides default definitions of the global deallocation functions \tcode{operator delete()} for non-arrays~(\ref{new.delete.single}) and -\indextext{operator~|see{\tcode{delete}}}% +\indextext{operator |see{\tcode{delete}}}% \indextext{\idxcode{operator delete}}% \tcode{operator delete[]()} for arrays~(\ref{new.delete.array}). A \Cpp program can provide alternative definitions of these @@ -3750,7 +3743,7 @@ \pnum The result of the \tcode{noexcept} operator is \tcode{true} -unless the \tcode{expression} is potentially-throwing~(\ref{except.spec}). +unless the \grammarterm{expression} is potentially-throwing~(\ref{except.spec}). \indextext{expression!unary|)} \rSec1[expr.cast]{Explicit type conversion (cast notation)}% @@ -3832,13 +3825,13 @@ struct I2 : A { }; struct D : I1, I2 { }; A* foo( D* p ) { - return (A*)( p ); // ill-formed \tcode{static_cast} interpretation + return (A*)( p ); // ill-formed \tcode{static_cast} interpretation } \end{codeblock} \end{example} \pnum -\indextext{class!cast~to incomplete}% +\indextext{class!cast to incomplete}% The operand of a cast using the cast notation can be a prvalue of type ``pointer to incomplete class type''. The destination type of a cast using the cast notation can be ``pointer to incomplete class type''. If @@ -3858,11 +3851,11 @@ \pnum \indextext{expression!pointer-to-member}% -\indextext{pointer~to~member}% -\indextext{operator!pointer~to~member}% -\indextext{\idxcode{.*}|see{operator, pointer~to~member}}% -\indextext{operator!pointer~to~member}% -\indextext{\idxcode{->*}|see{operator, pointer~to~member}}% +\indextext{pointer to member}% +\indextext{operator!pointer to member}% +\indextext{\idxcode{.*}|see{operator, pointer to member}}% +\indextext{operator!pointer to member}% +\indextext{\idxcode{->*}|see{operator, pointer to member}}% The pointer-to-member operators \tcode{->*} and \tcode{.*} group left-to-right. @@ -3925,7 +3918,7 @@ \end{note} \pnum -\indextext{function!pointer~to~member}% +\indextext{function!pointer to member}% If the result of \tcode{.*} or \tcode{->*} is a function, then that result can be used only as the operand for the function call operator \tcode{()}. @@ -3952,7 +3945,7 @@ pointer to member value~(\ref{conv.mem}), the behavior is undefined. \rSec1[expr.mul]{Multiplicative operators}% -\indextext{expression!multiplicative~operators}% +\indextext{expression!multiplicative operators}% \indextext{operator!multiplicative} \pnum @@ -3965,7 +3958,7 @@ \indextext{\idxcode{/}|see{operator, division}}% \indextext{operator!remainder}% \indextext{\idxcode{\%}|see{operator, remainder}}% -\indextext{remainder~operator|see{operator, remainder}}% +\indextext{remainder operator|see{operator, remainder}}% % \begin{bnf} \nontermdef{multiplicative-expression}\br @@ -3988,7 +3981,7 @@ The binary \tcode{/} operator yields the quotient, and the binary \tcode{\%} operator yields the remainder from the division of the first expression by the second. -\indextext{zero!undefined division~by}% +\indextext{zero!undefined division by}% If the second operand of \tcode{/} or \tcode{\%} is zero the behavior is undefined. For integral operands the \tcode{/} operator yields the algebraic quotient with @@ -3998,7 +3991,7 @@ of both \tcode{a/b} and \tcode{a\%b} is undefined. \rSec1[expr.add]{Additive operators}% -\indextext{expression!additive~operators}% +\indextext{expression!additive operators}% \indextext{operator!additive} \pnum @@ -4007,10 +4000,10 @@ enumeration type. \indextext{operator!addition}% -\indextext{addition~operator|see{operator, addition}}% +\indextext{addition operator|see{operator, addition}}% \indextext{\idxcode{+}|see{operator, addition}}% \indextext{operator!subtraction}% -\indextext{subtraction~operator|see{operator, subtraction}}% +\indextext{subtraction operator|see{operator, subtraction}}% \indextext{\idxcode{-}|see{operator, subtraction}}% % \begin{bnf} @@ -4066,8 +4059,8 @@ otherwise, the behavior is undefined. \pnum -\indextext{\idxcode{ptrdiff_t}!implementation~defined type~of}% -\indextext{subtraction!implementation~defined pointer}% +\indextext{\idxcode{ptrdiff_t}!implementation-defined type of}% +\indextext{subtraction!implementation-defined pointer}% \indextext{\idxcode{ptrdiff_t}}% \indextext{\idxhdr{cstddef}}% \indextext{comparison!undefined pointer}% @@ -4094,7 +4087,7 @@ \pnum For addition or subtraction, if the expressions \tcode{P} or \tcode{Q} have -type ``pointer to \cv{} \tcode{T}'', where \tcode{T} and the array element type +type ``pointer to \cv{}~\tcode{T}'', where \tcode{T} and the array element type are not similar~(\ref{conv.qual}), the behavior is undefined. \begin{note} In particular, a pointer to a base class cannot be used for pointer arithmetic when the array contains objects of a derived class type. @@ -4112,32 +4105,32 @@ \pnum \indextext{expression!left-shift-operator}% \indextext{expression!right-shift-operator}% -\indextext{shift~operator|see{operator, left~shift; operator, right~shift}}% -\indextext{right~shift~operator|see{operator, right~shift}}% -\indextext{left~shift~operator|see{operator, left~shift}}% -The shift operators \tcode{\shl} and \tcode{\shr} group left-to-right. - -\indextext{operator!left~shift}% -\indextext{\idxcode{\shl}|see{operator, left~shift}}% -\indextext{operator!right~shift}% -\indextext{\idxcode{\shr}|see{operator, right~shift}}% +\indextext{shift operator|see{operator, left shift; operator, right shift}}% +\indextext{right shift operator|see{operator, right shift}}% +\indextext{left shift operator|see{operator, left shift}}% +The shift operators \tcode{<<} and \tcode{>>} group left-to-right. + +\indextext{operator!left shift}% +\indextext{\idxcode{<<}|see{operator, left shift}}% +\indextext{operator!right shift}% +\indextext{\idxcode{>>}|see{operator, right shift}}% % \begin{bnf} \nontermdef{shift-expression}\br additive-expression\br - shift-expression \terminal{\shl} additive-expression\br - shift-expression \terminal{\shr} additive-expression + shift-expression \terminal{<<} additive-expression\br + shift-expression \terminal{>>} additive-expression \end{bnf} The operands shall be of integral or unscoped enumeration type and integral promotions are performed. The type of the result is that of the promoted left operand. -\indextext{left~shift!undefined}% +\indextext{left shift!undefined}% The behavior is undefined if the right operand is negative, or greater than or equal to the length in bits of the promoted left operand. \pnum -The value of \tcode{E1 \shl\ E2} is \tcode{E1} left-shifted \tcode{E2} bit positions; vacated bits are +The value of \tcode{E1 << E2} is \tcode{E1} left-shifted \tcode{E2} bit positions; vacated bits are zero-filled. If \tcode{E1} has an unsigned type, the value of the result is $\mathrm{E1}\times2^\mathrm{E2}$, reduced modulo one more than the maximum value representable in the result type. Otherwise, if @@ -4147,11 +4140,11 @@ behavior is undefined. \pnum -The value of \tcode{E1 \shr\ E2} is \tcode{E1} right-shifted \tcode{E2} +The value of \tcode{E1 >> E2} is \tcode{E1} right-shifted \tcode{E2} bit positions. If \tcode{E1} has an unsigned type or if \tcode{E1} has a signed type and a non-negative value, the value of the result is the integral part of the quotient of $\mathrm{E1}/2^\mathrm{E2}$. If \tcode{E1} -\indextext{right~shift!implementation~defined}% +\indextext{right shift!implementation-defined}% has a signed type and a negative value, the resulting value is \impldef{result of right shift of negative value}. @@ -4169,14 +4162,14 @@ \tcode{(a}|see{operator, greater~than}}% -\indextext{operator!less~than~or~equal~to}% -\indextext{\idxcode{<=}|see{operator, less~than~or~equal~to}}% -\indextext{operator!greater~than~or~equal~to}% -\indextext{\idxcode{>=}|see{operator, greater~than~or~equal~to}}% +\indextext{operator!less than}% +\indextext{\idxcode{<}|see{operator, less than}}% +\indextext{operator!greater than}% +\indextext{\idxcode{>}|see{operator, greater than}}% +\indextext{operator!less than or equal to}% +\indextext{\idxcode{<=}|see{operator, less than or equal to}}% +\indextext{operator!greater than or equal to}% +\indextext{\idxcode{>=}|see{operator, greater than or equal to}}% % \begin{bnf} \nontermdef{relational-expression}\br @@ -4241,7 +4234,7 @@ and \tcode{false} if it is false. \rSec1[expr.eq]{Equality operators}% -\indextext{expression!equality~operators}% +\indextext{expression!equality operators}% \indextext{operator!equality}% \indextext{operator!inequality} @@ -4262,7 +4255,7 @@ \pnum \indextext{comparison!pointer}% -\indextext{comparison!pointer~to function}% +\indextext{comparison!pointer to function}% If at least one of the operands is a pointer, pointer conversions~(\ref{conv.ptr}), function pointer conversions~(\ref{conv.fctptr}), and @@ -4370,7 +4363,7 @@ false. \rSec1[expr.bit.and]{Bitwise AND operator}% -\indextext{expression!bitwise~AND}% +\indextext{expression!bitwise AND}% \indextext{operator!bitwise}% \indextext{operator!bitwise AND}% \indextext{\idxcode{\&}|see{operator, bitwise AND}}% @@ -4387,9 +4380,9 @@ applies only to integral or unscoped enumeration operands. \rSec1[expr.xor]{Bitwise exclusive OR operator}% -\indextext{expression!bitwise~exclusive~OR}% -\indextext{operator!bitwise~exclusive OR}% -\indextext{\idxcode{\caret}|see{operator, bitwise~exclusive~OR}} +\indextext{expression!bitwise exclusive OR}% +\indextext{operator!bitwise exclusive OR}% +\indextext{\idxcode{\caret}|see{operator, bitwise exclusive OR}} \begin{bnf} \nontermdef{exclusive-or-expression}\br @@ -4403,9 +4396,9 @@ operator applies only to integral or unscoped enumeration operands. \rSec1[expr.or]{Bitwise inclusive OR operator}% -\indextext{expression!bitwise~inclusive~OR}% -\indextext{operator!bitwise~inclusive OR}% -\indextext{\idxcode{"|}|see{operator, bitwise~inclusive~OR}} +\indextext{expression!bitwise inclusive OR}% +\indextext{operator!bitwise inclusive OR}% +\indextext{\idxcode{"|}|see{operator, bitwise inclusive OR}} \begin{bnf} \nontermdef{inclusive-or-expression}\br @@ -4419,9 +4412,9 @@ operator applies only to integral or unscoped enumeration operands. \rSec1[expr.log.and]{Logical AND operator}% -\indextext{expression!logical~AND}% +\indextext{expression!logical AND}% \indextext{operator!logical AND}% -\indextext{\idxcode{\&\&}|see{operator, logical~AND}}% +\indextext{\idxcode{\&\&}|see{operator, logical AND}}% \begin{bnf} \nontermdef{logical-and-expression}\br @@ -4440,7 +4433,7 @@ \pnum The result is a \tcode{bool}. -\indextext{operator!side~effects~and logical AND}% +\indextext{operator!side effects and logical AND}% If the second expression is evaluated, every \indextext{value computation}% value computation and @@ -4450,28 +4443,28 @@ value computation and side effect associated with the second expression. \rSec1[expr.log.or]{Logical OR operator}% -\indextext{expression!logical~OR}% +\indextext{expression!logical OR}% \indextext{operator!logical OR}% -\indextext{\idxcode{"|"|}|see{operator, logical~OR}}% +\indextext{\idxcode{"|"|}|see{operator, logical OR}}% \begin{bnf} \nontermdef{logical-or-expression}\br logical-and-expression\br - logical-or-expression \terminal{$||$} logical-and-expression + logical-or-expression \terminal{||} logical-and-expression \end{bnf} \pnum -The \tcode{$||$} operator groups left-to-right. The operands are both +The \tcode{||} operator groups left-to-right. The operands are both contextually converted to \tcode{bool} (Clause~\ref{conv}). It returns \tcode{true} if either of its operands is \tcode{true}, and -\tcode{false} otherwise. Unlike \tcode{$|$}, \tcode{$||$} guarantees +\tcode{false} otherwise. Unlike \tcode{|}, \tcode{||} guarantees left-to-right evaluation; moreover, the second operand is not evaluated if the first operand evaluates to \tcode{true}. \pnum The result is a \tcode{bool}. -\indextext{operator!side~effects~and logical OR}% +\indextext{operator!side effects and logical OR}% If the second expression is evaluated, every \indextext{value computation}% value computation and @@ -4481,9 +4474,9 @@ and side effect associated with the second expression. \rSec1[expr.cond]{Conditional operator}% -\indextext{expression!conditional~operator}% -\indextext{operator!conditional~expression}% -\indextext{\idxcode{?:}|see{operator, conditional~expression}}% +\indextext{expression!conditional operator}% +\indextext{operator!conditional expression}% +\indextext{\idxcode{?:}|see{operator, conditional expression}}% \begin{bnf} \nontermdef{conditional-expression}\br @@ -4509,7 +4502,7 @@ one of the following shall hold: \begin{itemize} -\indextext{conditional-expression!throw-expression~in}% +\indextext{conditional-expression!throw-expression in}% \item The second or the third operand (but not both) is a (possibly parenthesized) \grammarterm{throw-expression}~(\ref{expr.throw}); the result is of the type and value category of the other. @@ -4677,8 +4670,7 @@ // ... } catch (...) { // catch all exceptions // respond (partially) to exception - throw; // pass the exception to some - // other handler + throw; // pass the exception to some other handler } \end{codeblock} \end{example} @@ -4698,14 +4690,14 @@ \pnum \indextext{operator!assignment}% -\indextext{\idxcode{=}|see{assignment~operator}}% +\indextext{\idxcode{=}|see{assignment operator}}% \indextext{operator!\idxcode{+=}}% \indextext{operator!\idxcode{-=}}% \indextext{operator!\idxcode{*=}}% \indextext{operator!\idxcode{/=}}% \indextext{operator!\idxcode{\%=}}% -\indextext{operator!\idxcode{\shr=}}% -\indextext{operator!\idxcode{\shl=}}% +\indextext{operator!\idxcode{>>=}}% +\indextext{operator!\idxcode{<<=}}% \indextext{operator!\idxcode{\&=}}% \indextext{operator!\idxcode{\caret=}}% \indextext{operator!\idxcode{"|=}}% @@ -4740,7 +4732,7 @@ \begin{bnf} \nontermdef{assignment-operator} \textnormal{one of}\br - \terminal{= *= /= \%= += -= \shr= \shl= \&= \caret= |=} + \terminal{= *= /= \%= += -= >>= <<= \&= \caret= |=} \end{bnf} \pnum @@ -4748,13 +4740,13 @@ that of the object referred to by the left operand. \pnum -\indextext{assignment!conversion~by}% +\indextext{assignment!conversion by}% If the left operand is not of class type, the expression is implicitly converted (Clause~\ref{conv}) to the cv-unqualified type of the left operand. \pnum -\indextext{class~object!assignment~to}% +\indextext{class object!assignment to}% \indextext{type!incomplete}% If the left operand is of class type, the class shall be complete. Assignment to objects of a class is defined by the copy/move assignment @@ -4767,7 +4759,7 @@ \end{note} \pnum -\indextext{reference!assignment~to}% +\indextext{reference!assignment to}% When the left operand of an assignment operator is a bit-field that cannot represent the value of the expression, the resulting value of the bit-field is @@ -4792,18 +4784,16 @@ \pnum A \grammarterm{braced-init-list} may appear on the right-hand side of - \begin{itemize} \item an assignment to a scalar, in which case the initializer list shall have -at most a single element. The meaning of \tcode{x=\{v\}}, where \tcode{T} is the -scalar type of the expression \tcode{x}, is that of \tcode{x=T\{v\}}. The meaning of -\tcode{x=\{\}} is \tcode{x=T\{\}}. +at most a single element. The meaning of \tcode{x = \{v\}}, where \tcode{T} is the +scalar type of the expression \tcode{x}, is that of \tcode{x = T\{v\}}. The meaning of +\tcode{x = \{\}} is \tcode{x = T\{\}}. \item an assignment to an object of class type, in which case the initializer list is passed as the argument to the assignment operator function selected by overload resolution~(\ref{over.ass}, \ref{over.match}). \end{itemize} - \begin{example} \begin{codeblock} complex z; @@ -4818,9 +4808,9 @@ \rSec1[expr.comma]{Comma operator}% \indextext{expression!comma}% \indextext{operator!comma}% -\indextext{comma~operator|see{operator, comma}}% +\indextext{comma operator|see{operator, comma}}% \indextext{\idxcode{,}|see{operator, comma}}% -\indextext{sequencing~operator|see{operator, comma}}% +\indextext{sequencing operator|see{operator, comma}}% \pnum The comma operator groups left-to-right. @@ -4839,7 +4829,7 @@ value computation and side effect associated with the left expression is sequenced before every value computation and side effect associated with the right expression. -\indextext{operator!side~effects~and comma}% +\indextext{operator!side effects and comma}% The type and value of the result are the type and value of the right operand; the result is of the same value category as its right operand, and is a bit-field if its @@ -4873,7 +4863,7 @@ assuming that copy elision is performed, are called \indexdefn{expression!constant}% -\defn{constant expression}{s}. \begin{note} Constant expressions can be evaluated +\defnx{constant expressions}{constant expression}. \begin{note} Constant expressions can be evaluated during translation.\end{note} \begin{bnf} @@ -4883,33 +4873,33 @@ \pnum A \grammarterm{conditional-expression} \tcode{e} is a -\defnx{core constant expression}{expression!core~constant} +\defnx{core constant expression}{expression!core constant} unless the evaluation of \tcode{e}, following the rules of the abstract machine~(\ref{intro.execution}), would evaluate one of the following expressions: \begin{itemize} \item \tcode{this}~(\ref{expr.prim.this}), except in a \tcode{constexpr} -function or a \tcode{constexpr} constructor that is being evaluated as part +function or a constexpr constructor that is being evaluated as part of \tcode{e}; \item an invocation of a function other than -a \tcode{constexpr} constructor for a literal class, -a \tcode{constexpr} function, +a constexpr constructor for a literal class, +a constexpr function, or an implicit invocation of a trivial destructor~(\ref{class.dtor}) \begin{note} Overload resolution~(\ref{over.match}) is applied as usual \end{note}; \item -an invocation of an undefined \tcode{constexpr} function or an -undefined \tcode{constexpr} constructor; +an invocation of an undefined constexpr function or an +undefined constexpr constructor; \item -an invocation of an instantiated \tcode{constexpr} function or -\tcode{constexpr} constructor that fails to satisfy the requirements -for a \tcode{constexpr} function or -\tcode{constexpr} constructor~(\ref{dcl.constexpr}); +an invocation of an instantiated constexpr function or +constexpr constructor that fails to satisfy the requirements +for a constexpr function or +constexpr constructor~(\ref{dcl.constexpr}); \item an expression that would exceed the implementation-defined @@ -5009,7 +4999,7 @@ \end{note} \item -a conversion from type \cv{} \tcode{void *} to a pointer-to-object type; +a conversion from type \cv{}~\tcode{void*} to a pointer-to-object type; \item a dynamic cast~(\ref{expr.dynamic.cast}); @@ -5092,7 +5082,7 @@ \end{example} \pnum -An \defnx{integral constant expression}{expression!integral~constant} +An \defnx{integral constant expression}{expression!integral constant} is an expression of integral or unscoped enumeration type, implicitly converted to a prvalue, where the converted expression is a core constant expression. \begin{note} @@ -5103,7 +5093,7 @@ \end{note} \pnum -A \defnx{converted constant expression}{expression!converted~constant} +A \defnx{converted constant expression}{expression!converted constant} of type \tcode{T} is an expression, implicitly converted to type \tcode{T}, where the converted expression is a constant expression and the @@ -5164,7 +5154,7 @@ each subobject satisfies these constraints for the value. \end{itemize} An entity is a -\defnx{permitted result of a constant expression}{constant expression!permitted result~of} +\defnx{permitted result of a constant expression}{constant expression!permitted result of} if it is an object with static storage duration that is either not a temporary object or is a temporary object whose value satisfies the above constraints, or it is a diff --git a/source/future.tex b/source/future.tex index 2098ef5442..7119aef6dc 100644 --- a/source/future.tex +++ b/source/future.tex @@ -9,7 +9,7 @@ These are deprecated features, where \term{deprecated} is defined as: -Normative for the current edition of the Standard, +Normative for the current edition of this International Standard, but having been identified as a candidate for removal from future revisions. An implementation may declare library names and entities described in this section with the \tcode{deprecated} attribute~(\ref{dcl.attr.deprecated}). @@ -54,7 +54,7 @@ For compatibility with the \indextext{library!C standard}% C standard library, the \Cpp standard library provides -the 26 \textit{C headers}, as shown in Table~\ref{tab:future.c.headers}. +the \defnx{C headers}{headers!C library} shown in Table~\ref{tab:future.c.headers}. \begin{floattable}{C headers}{tab:future.c.headers} {lllll} @@ -125,7 +125,9 @@ \pnum \begin{example} The header +\indextext{\idxhdr{cstdlib}}% \indexlibrary{\idxhdr{cstdlib}}% +\indextext{\idxhdr{stdlib.h}}% \indexlibrary{\idxhdr{stdlib.h}}% \tcode{} assuredly provides its declarations and definitions within the namespace @@ -143,6 +145,7 @@ \pnum The header +\indextext{\idxhdr{strstream}}% \indexlibrary{\idxhdr{strstream}}% \tcode{} defines three types that associate stream buffers with @@ -363,12 +366,16 @@ is declared in \tcode{} \indexlibrary{\idxcode{strlen}}% +\indextext{\idxhdr{cstring}}% \indexlibrary{\idxhdr{cstring}}% (\ref{cstring.syn}). The macro \tcode{INT_MAX} is defined in -\tcode{}\indexlibrary{\idxhdr{climits}} (\ref{climits.syn}).} +\tcode{} +\indextext{\idxhdr{climits}}% +\indexlibrary{\idxhdr{climits}}% +(\ref{climits.syn}).} \end{itemize} \pnum @@ -414,9 +421,9 @@ Destroys an object of class \tcode{strstreambuf}. The function frees the dynamically allocated array object only if -\tcode{strmode \& allocated != 0} +\tcode{(strmode \& allocated) != 0} and -\tcode{strmode \& frozen == 0}.~(\ref{depr.strstreambuf.virtuals} describes how a dynamically allocated array object is freed.) +\tcode{(strmode \& frozen) == 0}.~(\ref{depr.strstreambuf.virtuals} describes how a dynamically allocated array object is freed.) \end{itemdescr} \rSec3[depr.strstreambuf.members]{Member functions} @@ -429,7 +436,7 @@ \begin{itemdescr} \pnum \effects -If \tcode{strmode} \& \tcode{dynamic} is nonzero, alters the +If \tcode{strmode \& dynamic} is nonzero, alters the freeze status of the dynamic array object as follows: \begin{itemize} \item @@ -546,9 +553,9 @@ \pnum If -\tcode{strmode \& dynamic == 0}, +\tcode{(strmode \& dynamic) == 0}, or if -\tcode{strmode \& frozen != 0}, +\tcode{(strmode \& frozen) != 0}, the function cannot extend the array (reallocate it with greater length) to make a write position available. \end{itemdescr} @@ -576,7 +583,7 @@ If \tcode{c != EOF}, if the input sequence has a putback position available, and if -\tcode{strmode} \& \tcode{constant} is zero, +\tcode{strmode \& constant} is zero, assigns \tcode{c} to \tcode{*\dcr{}gnext}. @@ -970,6 +977,7 @@ is declared in \tcode{} \indexlibrary{\idxcode{strlen}}% +\indextext{\idxhdr{cstring}}% \indexlibrary{\idxhdr{cstring}}% (\ref{cstring.syn}).} \end{itemize} @@ -1183,6 +1191,7 @@ \pnum The header +\indextext{\idxhdr{exception}}% \indexlibrary{\idxhdr{exception}}% \tcode{} has the following addition: @@ -1227,7 +1236,7 @@ \pnum To enable old function adaptors to manipulate function objects that take one or two arguments, -many of the function objects in this standard +many of the function objects in this International Standard correspondingly provide \grammarterm{typedef-name}{s} \tcode{argument_type} and \tcode{result_type} for function objects that take one argument and @@ -1464,7 +1473,7 @@ \begin{itemize} \item a function type or a pointer to function type taking one argument of type \tcode{T1} % FIXME: Should this be R T0::f() ? -\item a pointer to member function \tcode{R T0::f} \cv{} (where \cv{} represents the member function's cv-qualifiers); the type \tcode{T1} is \cv{} \tcode{T0*} +\item a pointer to member function \tcode{R T0::f} \cv{} (where \cv{} represents the member function's cv-qualifiers); the type \tcode{T1} is \cv{}~\tcode{T0*} \item a class type where the \grammarterm{qualified-id} \tcode{T::argument_type} is valid and denotes a type~(\ref{temp.deduct}); the type \tcode{T1} is \tcode{T::argument_type}. @@ -1480,7 +1489,7 @@ only if the type \tcode{T} is any of the following: \begin{itemize} \item a function type or a pointer to function type taking two arguments of types \tcode{T1} and \tcode{T2} -\item a pointer to member function \tcode{R T0::f(T2)} \cv{} (where \cv{} represents the member function's cv-qualifiers); the type \tcode{T1} is \cv{} \tcode{T0*} +\item a pointer to member function \tcode{R T0::f(T2)} \cv{} (where \cv{} represents the member function's cv-qualifiers); the type \tcode{T1} is \cv{}~\tcode{T0*} \item a class type where the \grammarterm{qualified-id}{s} \tcode{T::first_argument_type} and \tcode{T::second_argument_type} are both valid and both denote types~(\ref{temp.deduct}); @@ -1522,7 +1531,7 @@ returned from a call to \tcode{mem_fn(pm)} shall define two nested types named \tcode{argument_type} and \tcode{result_type} -as synonyms for \cv{} \tcode{T*} and \tcode{Ret}, respectively, +as synonyms for \cv{}~\tcode{T*} and \tcode{Ret}, respectively, when \tcode{pm} is a pointer to member function with cv-qualifier \cv{} and taking no arguments, @@ -1536,7 +1545,7 @@ returned from a call to \tcode{mem_fn(pm)} shall define three nested types named \tcode{first_argument_type}, \tcode{second_argument_type}, and \tcode{result_type} -as synonyms for \cv{} \tcode{T*}, \tcode{T1}, and \tcode{Ret}, respectively, +as synonyms for \cv{}~\tcode{T*}, \tcode{T1}, and \tcode{Ret}, respectively, when \tcode{pm} is a pointer to member function with cv-qualifier \cv{} and taking one argument of type \tcode{T1}, @@ -1575,6 +1584,7 @@ \pnum The header +\indextext{\idxhdr{functional}}% \indexlibrary{\idxhdr{functional}}% \tcode{} has the following additions: @@ -1788,6 +1798,7 @@ \pnum The header +\indextext{\idxhdr{memory}}% \indexlibrary{\idxhdr{memory}}% \tcode{} has the following addition: @@ -1922,6 +1933,7 @@ \pnum The header +\indextext{\idxhdr{memory}}% \indexlibrary{\idxhdr{memory}}% \tcode{} has the following additions: @@ -1989,10 +2001,11 @@ Nothing. \end{itemdescr} -\rSec1[depr.meta.types]{Deprecated Type Traits} +\rSec1[depr.meta.types]{Deprecated type traits} \pnum The header +\indextext{\idxhdr{type_traits}}% \indexlibrary{\idxhdr{type_traits}}% \tcode{} has the following addition: @@ -2007,8 +2020,7 @@ \pnum \requires -\tcode{remove_all_extents_t} shall be a complete type or (possibly -cv-qualified) \tcode{void}. +\tcode{remove_all_extents_t} shall be a complete type or \cv{}~\tcode{void}. \pnum \effects @@ -2016,12 +2028,13 @@ \tcode{T} is a literal type~(\ref{basic.types}), and a base-characteristic of \tcode{false_type} otherwise. -\rSec1[depr.iterator.primitives]{Deprecated Iterator primitives} +\rSec1[depr.iterator.primitives]{Deprecated iterator primitives} \rSec2[depr.iterator.basic]{Basic iterator} \pnum The header +\indextext{\idxhdr{iterator}}% \indexlibrary{\idxhdr{iterator}}% \tcode{} has the following addition: diff --git a/source/intro.tex b/source/intro.tex index 65260427d2..bf9e508cb8 100644 --- a/source/intro.tex +++ b/source/intro.tex @@ -2,22 +2,22 @@ \rSec0[intro]{General} \indextext{diagnostic message|see{message, diagnostic}}% -\indexdefn{conditionally-supported behavior|see{behavior, conditionally-supported}}% +\indexdefn{conditionally-supported behavior|see{behavior, con\-ditionally-supported}}% \indextext{dynamic type|see{type, dynamic}}% \indextext{static type|see{type, static}}% \indextext{ill-formed program|see{program, ill-formed}}% \indextext{well-formed program|see{program, well-formed}}% -\indextext{implementation-defined behavior|see{behavior, implemen\-tation-defined}}% +\indextext{implementation-defined behavior|see{behavior, im\-plementation-defined}}% \indextext{undefined behavior|see{behavior, undefined}}% \indextext{unspecified behavior|see{behavior, unspecified}}% \indextext{implementation limits|see{limits, implementation}}% -\indextext{locale-specific behavior|see{behavior, locale-specific}}% +\indextext{locale-specific behavior|see{behavior, locale-spe\-cific}}% \indextext{multibyte character|see{character, multibyte}}% \indextext{object|seealso{object model}}% \indextext{subobject|seealso{object model}}% \indextext{derived class!most|see{most derived class}}% \indextext{derived object!most|see{most derived object}}% -\indextext{program execution!as-if rule|see{as-if~rule}}% +\indextext{program execution!as-if rule|see{as-if rule}}% \indextext{observable behavior|see{behavior, observable}}% \indextext{precedence of operator|see{operator, precedence of}}% \indextext{order of evaluation in expression|see{expression, order of evaluation of}}% @@ -164,7 +164,7 @@ \defncontext{glvalue} type of the most derived object~(\ref{intro.object}) to which the glvalue refers\\ \begin{example} -if a pointer~(\ref{dcl.ptr}) \tcode{p} whose static type is ``pointer to +If a pointer~(\ref{dcl.ptr}) \tcode{p} whose static type is ``pointer to class \tcode{B}'' is pointing to an object of class \tcode{D}, derived from \tcode{B} (Clause~\ref{class.derived}), the dynamic type of the expression \tcode{*p} is ``\tcode{D}''. References~(\ref{dcl.ref}) are @@ -297,7 +297,7 @@ \indexdefn{program!well-formed}% \definition{well-formed program}{defns.well.formed} \Cpp program constructed according to the syntax rules, diagnosable -semantic rules, and the one-definition rule ~(\ref{basic.def.odr}).% +semantic rules, and the one-definition rule~(\ref{basic.def.odr}).% \indextext{definitions|)} \rSec1[intro.compliance]{Implementation compliance} @@ -310,7 +310,7 @@ consists of all syntactic and semantic rules in this International Standard except for those rules containing an explicit notation that ``no diagnostic is required'' or which are described as resulting in -``undefined behavior.'' +``undefined behavior''. \pnum \indextext{conformance requirements!method of description}% @@ -328,7 +328,7 @@ \item \indextext{message!diagnostic}% If a program contains a violation of any diagnosable rule or an occurrence -of a construct described in this Standard as ``conditionally-supported'' when +of a construct described in this International Standard as ``conditionally-supported'' when the implementation does not support that construct, a conforming implementation shall issue at least one diagnostic message. \item @@ -438,7 +438,7 @@ categories are indicated by \grammarterm{italic} type, and literal words and characters in \tcode{constant} \tcode{width} type. Alternatives are listed on separate lines except in a few cases where a long set of -alternatives is marked by the phrase ``one of.'' If the text of an alternative is too long to fit on a line, the text is continued on subsequent lines indented from the first one. +alternatives is marked by the phrase ``one of''. If the text of an alternative is too long to fit on a line, the text is continued on subsequent lines indented from the first one. An optional terminal or non-terminal symbol is indicated by the subscript ``\opt'', so @@ -554,8 +554,7 @@ name~(Clause~\ref{basic}). An object has a storage duration~(\ref{basic.stc}) which influences its lifetime~(\ref{basic.life}). An object has a -type~(\ref{basic.types}). The term \defn{object type} refers to -the type with which the object is created. +type~(\ref{basic.types}). Some objects are polymorphic~(\ref{class.virtual}); the implementation generates information associated with each such object that makes it @@ -735,7 +734,7 @@ Standard places no requirement on the structure of conforming implementations. In particular, they need not copy or emulate the structure of the abstract machine. -\indextext{as-if~rule}% +\indextext{as-if rule}% \indextext{behavior!observable}% Rather, conforming implementations are required to emulate (only) the observable behavior of the abstract machine as explained below.\footnote{This provision is @@ -842,7 +841,7 @@ For example, in the following fragment \begin{codeblock} int a, b; -/*...*/ +@\commentellip@ a = a + 32760 + b + 5; \end{codeblock} the expression statement behaves exactly the same as @@ -902,7 +901,7 @@ \end{example} \pnum -The \defn{immediate subexpression}{s} of an expression \tcode{e} are +The \defnx{immediate subexpressions}{immediate subexpression} of an expression \tcode{e} are \begin{itemize} \item the constituent expressions of \tcode{e}'s operands (Clause \ref{expr}), @@ -1002,7 +1001,7 @@ function, or calling a function that does any of those operations are all \defn{side effects}, which are changes in the state of the execution -environment. \defn{Evaluation} of an expression (or a +environment. \defnx{Evaluation}{evaluation} of an expression (or a subexpression) in general includes both value computations (including determining the identity of an object for glvalue evaluation and fetching a value previously assigned to an object for prvalue evaluation) and @@ -1013,7 +1012,7 @@ may not have completed yet. \pnum -\defn{Sequenced before} is an asymmetric, transitive, pair-wise relation between +\defnx{Sequenced before}{sequenced before} is an asymmetric, transitive, pair-wise relation between evaluations executed by a single thread~(\ref{intro.multithread}), which induces a partial order among those evaluations. Given any two evaluations \placeholder{A} and \placeholder{B}, if \placeholder{A} is sequenced before \placeholder{B} @@ -1049,7 +1048,7 @@ place, usually in reverse order of the construction of each temporary object.} \pnum -\indextext{evaluation!unspecified order~of}% +\indextext{evaluation!unspecified order of}% Except where noted, evaluations of operands of individual operators and of subexpressions of individual expressions are unsequenced. \begin{note} In an expression that is evaluated more than once during the execution @@ -1096,9 +1095,8 @@ every evaluation \placeholder{B} that does not occur within \placeholder{F} but is evaluated on the same thread and as part of the same signal handler (if any), either \placeholder{A} is sequenced before \placeholder{B} or -\placeholder{B} is sequenced before \placeholder{A}. -\footnote{In other words, function executions do not interleave with -each other.} +\placeholder{B} is sequenced before \placeholder{A}.\footnote{In other words, +function executions do not interleave with each other.} \begin{note} If \placeholder{A} and \placeholder{B} would not otherwise be sequenced then they are indeterminately sequenced. @@ -1135,7 +1133,7 @@ through a pointer or reference~(\ref{basic.compound}).} Under a hosted implementation, a \Cpp program can have more than one thread running concurrently. The execution of each thread proceeds as defined by the remainder -of this standard. The execution of the entire program consists of an execution +of this International Standard. The execution of the entire program consists of an execution of all of its threads. \begin{note} Usually the execution can be viewed as an interleaving of all its threads. However, some kinds of atomic operations, for example, allow executions inconsistent with a simple interleaving, as described @@ -1409,13 +1407,12 @@ as described above, satisfy the resulting constraints as imposed here. \end{note} \pnum -Two actions are \defnx{potentially concurrent}{potentially~concurrent} if +Two actions are \defn{potentially concurrent} if \begin{itemize} \item they are performed by different threads, or \item they are unsequenced, at least one is performed by a signal handler, and they are not both performed by the same signal handler invocation. \end{itemize} -\indextext{data~race}% The execution of a program contains a \defn{data race} if it contains two potentially concurrent conflicting actions, at least one of which is not atomic, and neither happens before the other, @@ -1452,7 +1449,7 @@ \pnum \begin{note} Compiler transformations that introduce assignments to a potentially shared memory location that would not be modified by the abstract machine are -generally precluded by this standard, since such an assignment might overwrite +generally precluded by this International Standard, since such an assignment might overwrite another assignment by a different thread in cases in which an abstract machine execution would not have encountered a data race. This includes implementations of data member assignment that overwrite adjacent members in separate memory @@ -1463,7 +1460,7 @@ \pnum \begin{note} Transformations that introduce a speculative read of a potentially shared memory location may not preserve the semantics of the \Cpp program as -defined in this standard, since they potentially introduce a data race. However, +defined in this International Standard, since they potentially introduce a data race. However, they are typically valid in the context of an optimizing compiler that targets a specific machine with well-defined semantics for data races. They would be invalid for a hypothetical machine that is not tolerant of races or provides diff --git a/source/iostreams.tex b/source/iostreams.tex index a62fa59e64..64f0d0ddef 100644 --- a/source/iostreams.tex +++ b/source/iostreams.tex @@ -115,7 +115,8 @@ \rSec1[iostream.forward]{Forward declarations} -\synopsis{Header \tcode{} synopsis} +\rSec2[iosfwd.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{iosfwd}}% \indexlibrary{\idxhdr{iosfwd}}% \indexlibrary{\idxcode{basic_ios}}% @@ -255,8 +256,9 @@ and other headers does not violate the rules about multiple occurrences of default arguments.} +\rSec2[iostream.forward.overview]{Overview} + \pnum -\begin{note} The class template specialization \tcode{basic_ios} @@ -338,6 +340,7 @@ respectively. \pnum +\begin{note} This synopsis suggests a circularity between \tcode{streampos} and @@ -359,16 +362,15 @@ \rSec1[iostream.objects]{Standard iostream objects} -\rSec2[iostream.objects.overview]{Overview} - -\synopsis{Header \tcode{} synopsis} +\rSec2[iostream.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{iostream}}% \indexlibrary{\idxhdr{iostream}}% \begin{codeblock} -#include -#include -#include -#include +#include // see \ref{ios.syn} +#include // see \ref{streambuf.syn} +#include // see \ref{istream.syn} +#include // see \ref{ostream.syn} namespace std { extern istream cin; @@ -383,12 +385,15 @@ } \end{codeblock} +\rSec2[iostream.objects.overview]{Overview} + \pnum In this Clause, the type name \tcode{FILE} refers to the type \tcode{FILE} declared in \tcode{} +\indextext{\idxhdr{cstdio}}% \indexlibrary{\idxhdr{cstdio}}% (\ref{cstdio.syn}). @@ -405,7 +410,7 @@ The objects are constructed and the associations are established at some time prior to or during the first time an object of class \tcode{ios_base::Init} is constructed, and in any case before the body -of \tcode{main} begins execution.\footnote{If it is possible for them to do so, implementations are encouraged to +of \tcode{main}~(\ref{basic.start.main}) begins execution.\footnote{If it is possible for them to do so, implementations are encouraged to initialize the objects earlier than required.} The objects are not destroyed during program execution.\footnote{Constructors and destructors for static objects can access these objects to read input from @@ -445,6 +450,7 @@ associated with the object \tcode{stdin}, declared in +\indextext{\idxhdr{cstdio}}% \indexlibrary{\idxhdr{cstdio}}% \tcode{}~(\ref{cstdio.syn}). @@ -472,6 +478,7 @@ associated with the object \tcode{stdout}, declared in +\indextext{\idxhdr{cstdio}}% \indexlibrary{\idxhdr{cstdio}}% \tcode{}~(\ref{cstdio.syn}). \end{itemdescr} @@ -489,6 +496,7 @@ associated with the object \tcode{stderr}, declared in +\indextext{\idxhdr{cstdio}}% \indexlibrary{\idxhdr{cstdio}}% \tcode{}~(\ref{cstdio.syn}). @@ -515,6 +523,7 @@ associated with the object \tcode{stderr}, declared in +\indextext{\idxhdr{cstdio}}% \indexlibrary{\idxhdr{cstdio}}% \tcode{}~(\ref{cstdio.syn}). \end{itemdescr} @@ -534,6 +543,7 @@ associated with the object \tcode{stdin}, declared in +\indextext{\idxhdr{cstdio}}% \indexlibrary{\idxhdr{cstdio}}% \tcode{}~(\ref{cstdio.syn}). @@ -561,6 +571,7 @@ associated with the object \tcode{stdout}, declared in +\indextext{\idxhdr{cstdio}}% \indexlibrary{\idxhdr{cstdio}}% \tcode{}~(\ref{cstdio.syn}). \end{itemdescr} @@ -578,6 +589,7 @@ associated with the object \tcode{stderr}, declared in +\indextext{\idxhdr{cstdio}}% \indexlibrary{\idxhdr{cstdio}}% \tcode{}~(\ref{cstdio.syn}). @@ -604,19 +616,20 @@ associated with the object \tcode{stderr}, declared in +\indextext{\idxhdr{cstdio}}% \indexlibrary{\idxhdr{cstdio}}% \tcode{}~(\ref{cstdio.syn}). \end{itemdescr} \rSec1[iostreams.base]{Iostreams base classes} -\rSec2[iostreams.base.overview]{Overview} - -\synopsis{Header \tcode{} synopsis} +\rSec2[ios.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{ios}}% \indexlibrary{\idxhdr{ios}}% +\indexlibrary{\idxcode{io_errc}}% \begin{codeblock} -#include +#include // see \ref{iosfwd.syn} namespace std { using streamoff = @\impdef@; @@ -1452,7 +1465,7 @@ If the function fails\footnote{for example, because it cannot allocate space.} and \tcode{*this} -is a base subobject of a +is a base class subobject of a \tcode{basic_ios<>} object or subobject, the effect is equivalent to calling \tcode{basic_ios<>::setstate(badbit)} @@ -1496,7 +1509,7 @@ If the function fails\footnote{for example, because it cannot allocate space.} and \tcode{*this} -is a base subobject of a +is a base class subobject of a \tcode{basic_ios<>} object or subobject, the effect is equivalent to calling \tcode{basic_ios<>::setstate(badbit)} @@ -1671,7 +1684,7 @@ \tcode{P p = i;} & & & - post: \tcode{p == P(i)}. \\ \rowsep + \postconditions \tcode{p == P(i)}. \\ \rowsep \tcode{P(o)} & \tcode{fpos} & converts from \tcode{offset} & \\ \rowsep @@ -1854,6 +1867,7 @@ \end{itemdecl} \begin{itemdescr} +\pnum \postconditions The postconditions of this function are indicated in Table~\ref{tab:iostreams.basicios.init.effects}. @@ -1873,7 +1887,7 @@ \tcode{precision()} & \tcode{6} \\ \tcode{fill()} & - \tcode{widen(' ');} \\ + \tcode{widen(' ')} \\ \tcode{getloc()} & a copy of the value returned by \tcode{locale()} \\ \tcode{\textit{iarray}} & @@ -2018,7 +2032,7 @@ \begin{itemdescr} \pnum \postconditions -\tcode{traits::eq(fillch, fill())} +\tcode{traits::eq(fillch, fill())}. \pnum \returns @@ -2070,9 +2084,11 @@ \end{enumerate} \pnum -\realnote The second pass through the callback pairs permits a copied \tcode{pword} +\begin{note} +The second pass through the callback pairs permits a copied \tcode{pword} value to be zeroed, or to have its referent deep copied or reference counted, or to have other special action taken. +\end{note} \pnum \postconditions @@ -2618,9 +2634,9 @@ \tcode{dec(ios_base\&)} can be called by the function signature -\tcode{basic_ostream\& stream::operator\shl(ios_base\& (*)(ios_base\&))} +\tcode{basic_ostream\& stream::operator<<(ios_base\& (*)(ios_base\&))} to permit expressions of the form -\tcode{cout \shl dec} +\tcode{cout << dec} to change the format flags stored in \tcode{cout}.}. \end{itemdescr} @@ -2726,7 +2742,7 @@ \rSec3[error.reporting]{Error reporting} -\indexlibrary{\idxcode{make_error_code}}% +\indexlibrarymember{make_error_code}{io_errc}% \begin{itemdecl} error_code make_error_code(io_errc e) noexcept; \end{itemdecl} @@ -2736,7 +2752,7 @@ \returns \tcode{error_code(static_cast(e), iostream_category())}. \end{itemdescr} -\indexlibrary{\idxcode{make_error_condition}}% +\indexlibrarymember{make_error_condition}{io_errc}% \begin{itemdecl} error_condition make_error_condition(io_errc e) noexcept; \end{itemdecl} @@ -2763,9 +2779,8 @@ \rSec1[stream.buffers]{Stream buffers} -\rSec2[stream.buffers.overview]{Overview} - -\synopsis{Header \tcode{} synopsis} +\rSec2[streambuf.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{streambuf}}% \indexlibrary{\idxhdr{streambuf}}% \indexlibrary{\idxcode{streambuf}}% @@ -3634,7 +3649,7 @@ might fail by throwing an exception prematurely. The intention is not only that the calls will not return \tcode{eof()} -but that they will return ``immediately.''} +but that they will return ``immediately''.} \pnum \default @@ -3714,9 +3729,8 @@ of characters is defined as the concatenation of \begin{itemize} \item the empty sequence if \tcode{gptr()} is null, otherwise the -\tcode{egptr() - gptr()} -characters starting at -\tcode{gptr()}, +characters in +\range{gptr()}{egptr()}, followed by \item some (possibly empty) sequence of characters read from the input sequence. @@ -3734,9 +3748,8 @@ The \term{backup sequence} is the empty sequence if \tcode{eback()} is null, otherwise the -\tcode{gptr() - eback()} -characters beginning at -\tcode{eback()}. +characters in +\range{eback()}{gptr()}. \pnum \effects @@ -3748,10 +3761,9 @@ if the pending sequence is non-empty, then \tcode{egptr()} is non-null and -\tcode{egptr() - gptr()} -characters starting at -\tcode{gptr()} -are the characters in the pending sequence, otherwise +the characters in \range{gptr()}{egptr()} are +the characters in the pending sequence, +otherwise either \tcode{gptr()} is null or \tcode{gptr() == egptr()}. @@ -3766,16 +3778,13 @@ \item the backup sequence contains at least \tcode{gptr() - eback()} -characters, in which case the -\tcode{gptr() - eback()} -characters starting at -\tcode{eback()} +characters, in which case the characters in +\range{eback()}{gptr()} agree with the last \tcode{gptr() - eback()} characters of the backup sequence, or \item -the \tcode{n} characters starting at -\tcode{gptr() - n} +the characters in \range{gptr() - n}{gptr()} agree with the backup sequence (where \tcode{n} is the length of the backup sequence). \end{itemize} @@ -4026,20 +4035,21 @@ \rSec1[iostream.format]{Formatting and manipulators} -\rSec2[iostream.format.overview]{Overview} - +\rSec2[istream.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{istream}}% \indexlibrary{\idxhdr{istream}}% -\synopsis{Header \tcode{} synopsis} \begin{codeblock} namespace std { template > class basic_istream; + using istream = basic_istream; using wistream = basic_istream; template > class basic_iostream; + using iostream = basic_iostream; using wiostream = basic_iostream; @@ -4047,8 +4057,7 @@ basic_istream& ws(basic_istream& is); template - basic_istream& - operator>>(basic_istream&& is, T&& x); + basic_istream& operator>>(basic_istream&& is, T&& x); } \end{codeblock} @@ -4057,13 +4066,15 @@ \indexlibrary{\idxcode{wistream}}% \indexlibrary{\idxcode{basic_istream}}% -\synopsis{Header \tcode{} synopsis} +\rSec2[ostream.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{ostream}}% \indexlibrary{\idxhdr{ostream}}% \begin{codeblock} namespace std { template > class basic_ostream; + using ostream = basic_ostream; using wostream = basic_ostream; @@ -4075,8 +4086,7 @@ basic_ostream& flush(basic_ostream& os); template - basic_ostream& - operator<<(basic_ostream&& os, const T& x); + basic_ostream& operator<<(basic_ostream&& os, const T& x); } \end{codeblock} @@ -4085,7 +4095,8 @@ \indexlibrary{\idxcode{wostream}}% \indexlibrary{\idxcode{basic_ostream}}% -\synopsis{Header \tcode{} synopsis} +\rSec2[iomanip.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{iomanip}}% \indexlibrary{\idxhdr{iomanip}}% \begin{codeblock} @@ -4129,8 +4140,7 @@ \begin{codeblock} namespace std { template > - class basic_istream - : virtual public basic_ios { + class basic_istream : virtual public basic_ios { public: // types (inherited from \tcode{basic_ios} (\ref{ios})): using char_type = charT; @@ -4147,12 +4157,12 @@ class sentry; // \ref{istream.formatted}, formatted input - basic_istream& operator>>( - basic_istream& (*pf)(basic_istream&)); - basic_istream& operator>>( - basic_ios& (*pf)(basic_ios&)); - basic_istream& operator>>( - ios_base& (*pf)(ios_base&)); + basic_istream& + operator>>(basic_istream& (*pf)(basic_istream&)); + basic_istream& + operator>>(basic_ios& (*pf)(basic_ios&)); + basic_istream& + operator>>(ios_base& (*pf)(ios_base&)); basic_istream& operator>>(bool& n); basic_istream& operator>>(short& n); @@ -4168,26 +4178,21 @@ basic_istream& operator>>(long double& f); basic_istream& operator>>(void*& p); - basic_istream& operator>>( - basic_streambuf* sb); + basic_istream& operator>>(basic_streambuf* sb); // \ref{istream.unformatted}, unformatted input streamsize gcount() const; int_type get(); basic_istream& get(char_type& c); basic_istream& get(char_type* s, streamsize n); - basic_istream& get(char_type* s, streamsize n, - char_type delim); + basic_istream& get(char_type* s, streamsize n, char_type delim); basic_istream& get(basic_streambuf& sb); - basic_istream& get(basic_streambuf& sb, - char_type delim); + basic_istream& get(basic_streambuf& sb, char_type delim); basic_istream& getline(char_type* s, streamsize n); - basic_istream& getline(char_type* s, streamsize n, - char_type delim); + basic_istream& getline(char_type* s, streamsize n, char_type delim); - basic_istream& ignore( - streamsize n = 1, int_type delim = traits::eof()); + basic_istream& ignore(streamsize n = 1, int_type delim = traits::eof()); int_type peek(); basic_istream& read (char_type* s, streamsize n); streamsize readsome(char_type* s, streamsize n); @@ -4213,24 +4218,18 @@ // \ref{istream.extractors}, character extraction templates template - basic_istream& operator>>(basic_istream&, - charT&); + basic_istream& operator>>(basic_istream&, charT&); template - basic_istream& operator>>(basic_istream&, - unsigned char&); + basic_istream& operator>>(basic_istream&, unsigned char&); template - basic_istream& operator>>(basic_istream&, - signed char&); + basic_istream& operator>>(basic_istream&, signed char&); template - basic_istream& operator>>(basic_istream&, - charT*); + basic_istream& operator>>(basic_istream&, charT*); template - basic_istream& operator>>(basic_istream&, - unsigned char*); + basic_istream& operator>>(basic_istream&, unsigned char*); template - basic_istream& operator>>(basic_istream&, - signed char*); + basic_istream& operator>>(basic_istream&, signed char*); } \end{codeblock} @@ -4298,13 +4297,12 @@ \pnum \effects Constructs an object of class -\tcode{basic_istream}, -assigning initial values to the base class by calling +\tcode{basic_istream}, initializing the base class subobject with \tcode{basic_ios::init(sb)}~(\ref{basic.ios.cons}). \pnum \postconditions -\tcode{gcount() == 0} +\tcode{gcount() == 0}. \end{itemdescr} @@ -4452,7 +4450,9 @@ \pnum \remarks The constructor -\tcode{explicit sentry(basic_istream\& is, bool noskipws = false)} +\begin{codeblock} +explicit sentry(basic_istream& is, bool noskipws = false) +\end{codeblock} uses the currently imbued locale in \tcode{is}, to determine whether the next input character is whitespace or not. @@ -4546,7 +4546,7 @@ \rSec4[istream.formatted.arithmetic]{Arithmetic extractors} -\indexlibrarymember{operator\shr}{basic_istream}% +\indexlibrarymember{operator>>}{basic_istream}% \begin{itemdecl} operator>>(unsigned short& val); operator>>(unsigned int& val); @@ -4569,14 +4569,12 @@ stream data. These extractors behave as formatted input functions (as described in~\ref{istream.formatted.reqmts}). After a sentry object is constructed, the conversion occurs as if performed by the following code fragment: - \begin{codeblock} -using numget = num_get< charT, istreambuf_iterator>; +using numget = num_get>; iostate err = iostate::goodbit; -use_facet(loc).get(*this, 0, *this, err, val); +use_facet(loc).get(*this, 0, *this, err, val); setstate(err); \end{codeblock} - In the above fragment, \tcode{loc} stands for the private member of the @@ -4597,7 +4595,7 @@ \tcode{istream}. \end{itemdescr} -\indexlibrarymember{operator\shr}{basic_istream}% +\indexlibrarymember{operator>>}{basic_istream}% \begin{itemdecl} operator>>(short& val); \end{itemdecl} @@ -4623,7 +4621,7 @@ \end{codeblock} \end{itemdescr} -\indexlibrarymember{operator\shr}{basic_istream}% +\indexlibrarymember{operator>>}{basic_istream}% \begin{itemdecl} operator>>(int& val); \end{itemdecl} @@ -4649,12 +4647,12 @@ \end{codeblock} \end{itemdescr} -\rSec4[istream.extractors]{\tcode{basic_istream::operator\shr}} +\rSec4[istream.extractors]{\tcode{basic_istream::operator>>}} -\indexlibrarymember{operator\shr}{basic_istream}% +\indexlibrarymember{operator>>}{basic_istream}% \begin{itemdecl} -basic_istream& operator>> - (basic_istream& (*pf)(basic_istream&)); +basic_istream& + operator>>(basic_istream& (*pf)(basic_istream&)); \end{itemdecl} \begin{itemdescr} @@ -4671,10 +4669,10 @@ \indexlibrary{\idxcode{ws}}}% \end{itemdescr} -\indexlibrarymember{operator\shr}{basic_istream}% +\indexlibrarymember{operator>>}{basic_istream}% \begin{itemdecl} -basic_istream& operator>> - (basic_ios& (*pf)(basic_ios&)); +basic_istream& + operator>>(basic_ios& (*pf)(basic_ios&)); \end{itemdecl} \begin{itemdescr} @@ -4690,10 +4688,9 @@ \tcode{*this}. \end{itemdescr} -\indexlibrarymember{operator\shr}{basic_istream}% +\indexlibrarymember{operator>>}{basic_istream}% \begin{itemdecl} -basic_istream& operator>> - (ios_base& (*pf)(ios_base&)); +basic_istream& operator>>(ios_base& (*pf)(ios_base&)); \end{itemdecl} \begin{itemdescr} @@ -4710,17 +4707,14 @@ \tcode{*this}. \end{itemdescr} -\indexlibrarymember{operator\shr}{basic_istream}% +\indexlibrarymember{operator>>}{basic_istream}% \begin{itemdecl} template - basic_istream& operator>>(basic_istream& in, - charT* s); + basic_istream& operator>>(basic_istream& in, charT* s); template - basic_istream& operator>>(basic_istream& in, - unsigned char* s); + basic_istream& operator>>(basic_istream& in, unsigned char* s); template - basic_istream& operator>>(basic_istream& in, - signed char* s); + basic_istream& operator>>(basic_istream& in, signed char* s); \end{itemdecl} \begin{itemdescr} @@ -4731,7 +4725,7 @@ After a \tcode{sentry} object is constructed, -\tcode{operator\shr} +\tcode{operator>>} extracts characters and stores them into successive locations of an array whose first element is designated by \tcode{s}. @@ -4749,27 +4743,19 @@ \pnum Characters are extracted and stored until any of the following occurs: \begin{itemize} -\item -\tcode{n-1} -characters are stored; -\item -end of file occurs on the input sequence; -\item -\tcode{ct.is(ct.space, c)} -is -\tcode{true} -for the next available input character \tcode{c}, -where \tcode{ct} is -\tcode{use_facet>(in.getloc())}. +\item \tcode{n-1} characters are stored; +\item end of file occurs on the input sequence; +\item letting \tcode{ct} be \tcode{use_facet>(in.getloc())}, +\tcode{ct.is(ct.space, c)} is \tcode{true}. \end{itemize} \pnum -\tcode{operator\shr} +\tcode{operator>>} then stores a null byte (\tcode{charT()}) in the next position, which may be the first position if no characters were extracted. -\tcode{operator\shr} +\tcode{operator>>} then calls \tcode{width(0)}. @@ -4784,17 +4770,14 @@ \tcode{in}. \end{itemdescr} -\indexlibrarymember{operator\shr}{basic_istream}% +\indexlibrarymember{operator>>}{basic_istream}% \begin{itemdecl} template - basic_istream& operator>>(basic_istream& in, - charT& c); + basic_istream& operator>>(basic_istream& in, charT& c); template - basic_istream& operator>>(basic_istream& in, - unsigned char& c); + basic_istream& operator>>(basic_istream& in, unsigned char& c); template - basic_istream& operator>>(basic_istream& in, - signed char& c); + basic_istream& operator>>(basic_istream& in, signed char& c); \end{itemdecl} \begin{itemdescr} @@ -4814,10 +4797,9 @@ \tcode{in}. \end{itemdescr} -\indexlibrarymember{operator\shr}{basic_istream}% +\indexlibrarymember{operator>>}{basic_istream}% \begin{itemdecl} -basic_istream& operator>> - (basic_streambuf* sb); +basic_istream& operator>>(basic_streambuf* sb); \end{itemdecl} \begin{itemdescr} @@ -4981,8 +4963,7 @@ \indexlibrarymember{get}{basic_istream}% \begin{itemdecl} -basic_istream& get(char_type* s, streamsize n, - char_type delim); +basic_istream& get(char_type* s, streamsize n, char_type delim); \end{itemdecl} \begin{itemdescr} @@ -5044,8 +5025,7 @@ \indexlibrarymember{get}{basic_istream}% \begin{itemdecl} -basic_istream& get(basic_streambuf& sb, - char_type delim); +basic_istream& get(basic_streambuf& sb, char_type delim); \end{itemdecl} \begin{itemdescr} @@ -5102,8 +5082,7 @@ \indexlibrarymember{getline}{basic_istream}% \begin{itemdecl} -basic_istream& getline(char_type* s, streamsize n, - char_type delim); +basic_istream& getline(char_type* s, streamsize n, char_type delim); \end{itemdecl} \begin{itemdescr} @@ -5129,7 +5108,7 @@ for the next available input character \tcode{c} (in which case the input character is extracted but not stored);\footnote{Since -the final input character is ``extracted,'' +the final input character is ``extracted'', it is counted in the \tcode{gcount()}, even though it is not stored.} @@ -5207,8 +5186,7 @@ \indexlibrarymember{ignore}{basic_istream}% \begin{itemdecl} -basic_istream& - ignore(streamsize n = 1, int_type delim = traits::eof()); +basic_istream& ignore(streamsize n = 1, int_type delim = traits::eof()); \end{itemdecl} \begin{itemdescr} @@ -5221,7 +5199,7 @@ Characters are extracted until any of the following occurs: \begin{itemize} \item -\tcode{n != numeric_limits::max()}~(\ref{limits}) +\tcode{n != numeric_limits::max()}~(\ref{numeric.limits}) and \tcode{n} characters have been extracted so far \item @@ -5570,11 +5548,10 @@ \rSec3[istream.rvalue]{Rvalue stream extraction} -\indexlibrarymember{operator\shr}{basic_istream}% +\indexlibrarymember{operator>>}{basic_istream}% \begin{itemdecl} template - basic_istream& - operator>>(basic_istream&& is, T&& x); + basic_istream& operator>>(basic_istream&& is, T&& x); \end{itemdecl} \begin{itemdescr} @@ -5641,9 +5618,8 @@ \begin{itemdescr} \pnum \effects -Constructs an object of class -\tcode{basic_iostream}, -assigning initial values to the base classes by calling +Constructs an object of class \tcode{basic_iostream}, +initializing the base class subobjects with \tcode{basic_istream(sb)}~(\ref{istream}) and \tcode{basic_ostream(sb)}~(\ref{ostream}). @@ -5724,8 +5700,7 @@ \begin{codeblock} namespace std { template > - class basic_ostream - : virtual public basic_ios { + class basic_ostream : virtual public basic_ios { public: // types (inherited from \tcode{basic_ios} (\ref{ios})): using char_type = charT; @@ -5742,12 +5717,12 @@ class sentry; // \ref{ostream.formatted}, formatted output - basic_ostream& operator<<( - basic_ostream& (*pf)(basic_ostream&)); - basic_ostream& operator<<( - basic_ios& (*pf)(basic_ios&)); - basic_ostream& operator<<( - ios_base& (*pf)(ios_base&)); + basic_ostream& + operator<<(basic_ostream& (*pf)(basic_ostream&)); + basic_ostream& + operator<<(basic_ios& (*pf)(basic_ios&)); + basic_ostream& + operator<<(ios_base& (*pf)(ios_base&)); basic_ostream& operator<<(bool n); basic_ostream& operator<<(short n); @@ -5764,8 +5739,7 @@ basic_ostream& operator<<(const void* p); basic_ostream& operator<<(nullptr_t); - basic_ostream& operator<<( - basic_streambuf* sb); + basic_ostream& operator<<(basic_streambuf* sb); // \ref{ostream.unformatted}, unformatted output basic_ostream& put(char_type c); @@ -5791,38 +5765,28 @@ // \ref{ostream.inserters.character}, character inserters template - basic_ostream& operator<<(basic_ostream&, - charT); + basic_ostream& operator<<(basic_ostream&, charT); template - basic_ostream& operator<<(basic_ostream&, - char); + basic_ostream& operator<<(basic_ostream&, char); template - basic_ostream& operator<<(basic_ostream&, - char); + basic_ostream& operator<<(basic_ostream&, char); template - basic_ostream& operator<<(basic_ostream&, - signed char); + basic_ostream& operator<<(basic_ostream&, signed char); template - basic_ostream& operator<<(basic_ostream&, - unsigned char); + basic_ostream& operator<<(basic_ostream&, unsigned char); template - basic_ostream& operator<<(basic_ostream&, - const charT*); + basic_ostream& operator<<(basic_ostream&, const charT*); template - basic_ostream& operator<<(basic_ostream&, - const char*); + basic_ostream& operator<<(basic_ostream&, const char*); template - basic_ostream& operator<<(basic_ostream&, - const char*); + basic_ostream& operator<<(basic_ostream&, const char*); template - basic_ostream& operator<<(basic_ostream&, - const signed char*); + basic_ostream& operator<<(basic_ostream&, const signed char*); template - basic_ostream& operator<<(basic_ostream&, - const unsigned char*); + basic_ostream& operator<<(basic_ostream&, const unsigned char*); } \end{codeblock} @@ -5882,8 +5846,7 @@ \pnum \effects Constructs an object of class -\tcode{basic_ostream}, -assigning initial values to the base class by calling +\tcode{basic_ostream}, initializing the base class subobject with \tcode{basic_ios::init(sb)}~(\ref{basic.ios.cons}). \pnum @@ -6159,7 +6122,7 @@ \rSec4[ostream.inserters.arithmetic]{Arithmetic inserters} -\indexlibrarymember{operator\shl}{basic_ostream}% +\indexlibrarymember{operator<<}{basic_ostream}% \begin{itemdecl} operator<<(bool val); operator<<(short val); @@ -6268,7 +6231,7 @@ interface to iostreams, since for flexibility it has been abstracted away from direct dependence on \tcode{ostream}. -The second parameter is a reference to the base subobject of type +The second parameter is a reference to the base class subobject of type \tcode{ios_base}. It provides formatting specifications such as field width, and a locale from which to obtain other facets. @@ -6285,12 +6248,12 @@ \tcode{*this}. \end{itemdescr} -\rSec4[ostream.inserters]{\tcode{basic_ostream::operator\shl}} +\rSec4[ostream.inserters]{\tcode{basic_ostream::operator<<}} -\indexlibrarymember{operator\shl}{basic_ostream}% +\indexlibrarymember{operator<<}{basic_ostream}% \begin{itemdecl} -basic_ostream& operator<< - (basic_ostream& (*pf)(basic_ostream&)); +basic_ostream& + operator<<(basic_ostream& (*pf)(basic_ostream&)); \end{itemdecl} \begin{itemdescr} @@ -6307,10 +6270,10 @@ \tcode{endl(basic_ostream\&)}~(\ref{ostream.manip}).} \end{itemdescr} -\indexlibrarymember{operator\shl}{basic_ostream}% +\indexlibrarymember{operator<<}{basic_ostream}% \begin{itemdecl} -basic_ostream& operator<< - (basic_ios& (*pf)(basic_ios&)); +basic_ostream& + operator<<(basic_ios& (*pf)(basic_ios&)); \end{itemdecl} \begin{itemdescr} @@ -6328,10 +6291,9 @@ \tcode{dec(ios_base\&)}~(\ref{basefield.manip}).} \end{itemdescr} -\indexlibrarymember{operator\shl}{basic_ostream}% +\indexlibrarymember{operator<<}{basic_ostream}% \begin{itemdecl} -basic_ostream& operator<< - (ios_base& (*pf)(ios_base&)); +basic_ostream& operator<<(ios_base& (*pf)(ios_base&)); \end{itemdecl} \begin{itemdescr} @@ -6347,10 +6309,9 @@ \tcode{*this}. \end{itemdescr} -\indexlibrarymember{operator\shl}{basic_ostream}% +\indexlibrarymember{operator<<}{basic_ostream}% \begin{itemdecl} -basic_ostream& operator<< - (basic_streambuf* sb); +basic_ostream& operator<<(basic_streambuf* sb); \end{itemdecl} \begin{itemdescr} @@ -6399,7 +6360,7 @@ \tcode{*this}. \end{itemdescr} -\indexlibrarymember{operator\shl}{basic_ostream}% +\indexlibrarymember{operator<<}{basic_ostream}% \begin{itemdecl} basic_ostream& operator<<(nullptr_t); \end{itemdecl} @@ -6412,39 +6373,33 @@ return *this << s; \end{codeblock} where \tcode{s} is an -\impldef{NTCTS in basic_ostream\& operator<<(nullptr_t)} +\impldef{NTCTS in \tcode{basic_ostream\& op\-er\-ator<<(nullptr_t)}} NTCTS~(\ref{defns.ntcts}). \end{itemdescr} \rSec4[ostream.inserters.character]{Character inserter function templates} -\indexlibrarymember{operator\shl}{basic_ostream}% +\indexlibrarymember{operator<<}{basic_ostream}% \begin{itemdecl} template - basic_ostream& operator<<(basic_ostream& out, - charT c); + basic_ostream& operator<<(basic_ostream& out, charT c); template - basic_ostream& operator<<(basic_ostream& out, - char c); - // specialization + basic_ostream& operator<<(basic_ostream& out, char c); +// specialization template - basic_ostream& operator<<(basic_ostream& out, - char c); - // signed and unsigned + basic_ostream& operator<<(basic_ostream& out, char c); +// signed and unsigned template - basic_ostream& operator<<(basic_ostream& out, - signed char c); + basic_ostream& operator<<(basic_ostream& out, signed char c); template - basic_ostream& operator<<(basic_ostream& out, - unsigned char c); + basic_ostream& operator<<(basic_ostream& out, unsigned char c); \end{itemdecl} \begin{itemdescr} \pnum \effects -Behaves as a formatted output function -(~\ref{ostream.formatted.reqmts}) of \tcode{out}. -Constructs a character sequence \tcode{seq}. +Behaves as a formatted output function~(\ref{ostream.formatted.reqmts}) +of \tcode{out}. Constructs a character sequence \tcode{seq}. If \tcode{c} has type \tcode{char} and the character type of the stream is not @@ -6461,20 +6416,16 @@ \tcode{out}. \end{itemdescr} -\indexlibrarymember{operator\shl}{basic_ostream}% +\indexlibrarymember{operator<<}{basic_ostream}% \begin{itemdecl} template - basic_ostream& operator<<(basic_ostream& out, - const charT* s); + basic_ostream& operator<<(basic_ostream& out, const charT* s); template - basic_ostream& operator<<(basic_ostream& out, - const char* s); + basic_ostream& operator<<(basic_ostream& out, const char* s); template - basic_ostream& operator<<(basic_ostream& out, - const char* s); + basic_ostream& operator<<(basic_ostream& out, const char* s); template - basic_ostream& operator<<(basic_ostream& out, - const signed char* s); + basic_ostream& operator<<(basic_ostream& out, const signed char* s); template basic_ostream& operator<<(basic_ostream& out, const unsigned char* s); @@ -6695,19 +6646,18 @@ \rSec3[ostream.rvalue]{Rvalue stream insertion} -\indexlibrarymember{operator\shl}{basic_ostream}% +\indexlibrarymember{operator<<}{basic_ostream}% \begin{itemdecl} template - basic_ostream& - operator<<(basic_ostream&& os, const T& x); + basic_ostream& operator<<(basic_ostream&& os, const T& x); \end{itemdecl} \begin{itemdescr} \pnum -\effects As if by: \tcode{os \shl{} x;} +\effects As if by: \tcode{os << x;} \pnum -\returns \tcode{os} +\returns \tcode{os}. \pnum \remarks This function shall not participate in overload resolution @@ -6730,19 +6680,19 @@ \pnum \returns An object of unspecified type such that if \tcode{out} is an object of type -\tcode{basic_ostream} then the expression \tcode{out \shl\ -resetiosflags(mask)} behaves as if it called \tcode{f(out, -mask)}, or if \tcode{in} is an object of type -\tcode{basic_istream} then the expression \tcode{in \shr\ -resetiosflags(\brk{}mask)} behaves as if it called \tcode{f(in, -mask)}, where the function \tcode{f} -is defined as:\footnote{ The expression \tcode{cin \shr resetiosflags(ios_base::skipws)} +\tcode{basic_ostream} then the expression +\tcode{out << resetiosflags(mask)} behaves as if it called +\tcode{f(out, mask)}, or if \tcode{in} is an object of type +\tcode{basic_istream} then the expression +\tcode{in >> resetiosflags(\brk{}mask)} behaves as if it called +\tcode{f(in, mask)}, where the function \tcode{f} +is defined as:\footnote{ The expression \tcode{cin >> resetiosflags(ios_base::skipws)} clears \tcode{ios_base::skipws} in the format flags stored in the \tcode{basic_istream} object \tcode{cin} (the same as -\tcode{cin \shr noskipws}), and the expression \tcode{cout \shl -resetiosflags(ios_base::showbase)} clears \tcode{ios_base::showbase} in the +\tcode{cin >> noskipws}), and the expression +\tcode{cout << resetiosflags(ios_base::showbase)} clears \tcode{ios_base::showbase} in the format flags stored in the \tcode{basic_ostream} object -\tcode{cout} (the same as \tcode{cout \shl noshowbase}). } +\tcode{cout} (the same as \tcode{cout << noshowbase}). } \begin{codeblock} void f(ios_base& str, ios_base::fmtflags mask) { @@ -6751,9 +6701,9 @@ } \end{codeblock} -The expression \tcode{out \shl\ resetiosflags(mask)} shall have +The expression \tcode{out << resetiosflags(mask)} shall have type \tcode{basic_ostream\&} and value \tcode{out}. The -expression \tcode{in \shr\ resetiosflags(mask)} shall have type +expression \tcode{in >> resetiosflags(mask)} shall have type \tcode{basic_istream\&} and value \tcode{in}. \end{itemdescr} \indexlibrary{\idxcode{setiosflags}}% @@ -6769,7 +6719,7 @@ is an object of type \tcode{basic_ostream} then the expression -\tcode{out \shl\ setiosflags(mask)} +\tcode{out << setiosflags(mask)} behaves as if it called \tcode{f(out, mask)}, or if @@ -6777,7 +6727,7 @@ is an object of type \tcode{basic_istream} then the expression -\tcode{in \shr\ setiosflags(mask)} +\tcode{in >> setiosflags(mask)} behaves as if it called \tcode{f(in, mask)}, where the function \tcode{f} is defined as: \indexlibrary{\idxcode{fmtflags}!\idxcode{ios_base}}% @@ -6790,13 +6740,13 @@ \end{codeblock} The expression -\tcode{out \shl\ setiosflags(mask)} +\tcode{out << setiosflags(mask)} shall have type \tcode{basic_ostream\&} and value \tcode{out}. The expression -\tcode{in \shr\ setiosflags(mask)} +\tcode{in >> setiosflags(mask)} shall have type \tcode{basic_istream\&} and value @@ -6816,7 +6766,7 @@ is an object of type \tcode{basic_ostream} then the expression -\tcode{out \shl\ setbase(base)} +\tcode{out << setbase(base)} behaves as if it called \tcode{f(out, base)}, or if @@ -6824,7 +6774,7 @@ is an object of type \tcode{basic_istream} then the expression -\tcode{in \shr\ setbase(base)} +\tcode{in >> setbase(base)} behaves as if it called \tcode{f(in, base)}, where the function \tcode{f} is defined as: @@ -6839,13 +6789,13 @@ \end{codeblock} The expression -\tcode{out \shl\ setbase(base)} +\tcode{out << setbase(base)} shall have type \tcode{basic_ostream\&} and value \tcode{out}. The expression -\tcode{in \shr\ setbase(base)} +\tcode{in >> setbase(base)} shall have type \tcode{basic_istream\&} and value @@ -6867,7 +6817,7 @@ and \tcode{c} has type \tcode{charT} then the expression -\tcode{out \shl\ setfill(c)} +\tcode{out << setfill(c)} behaves as if it called \tcode{f(out, c)}, where the function \tcode{f} is defined as: @@ -6880,7 +6830,7 @@ \end{codeblock} The expression -\tcode{out \shl\ setfill(c)} +\tcode{out << setfill(c)} shall have type \tcode{basic_ostream\&} and value @@ -6900,7 +6850,7 @@ is an object of type \tcode{basic_ostream} then the expression -\tcode{out \shl\ setprecision(n)} +\tcode{out << setprecision(n)} behaves as if it called \tcode{f(out, n)}, or if @@ -6908,7 +6858,7 @@ is an object of type \tcode{basic_istream} then the expression -\tcode{in \shr\ setprecision(n)} +\tcode{in >> setprecision(n)} behaves as if it called \tcode{f(in, n)}, where the function \tcode{f} is defined as: @@ -6920,13 +6870,13 @@ \end{codeblock} The expression -\tcode{out \shl\ setprecision(n)} +\tcode{out << setprecision(n)} shall have type \tcode{basic_ostream\&} and value \tcode{out}. The expression -\tcode{in \shr\ setprecision(n)} +\tcode{in >> setprecision(n)} shall have type \tcode{basic_istream\&} and value @@ -6946,7 +6896,7 @@ is an instance of \tcode{basic_ostream} then the expression -\tcode{out \shl\ setw(n)} +\tcode{out << setw(n)} behaves as if it called \tcode{f(out, n)}, or if @@ -6954,7 +6904,7 @@ is an object of type \tcode{basic_istream} then the expression -\tcode{in \shr\ setw(n)} +\tcode{in >> setw(n)} behaves as if it called \tcode{f(in, n)}, where the function \tcode{f} is defined as: @@ -6966,13 +6916,13 @@ \end{codeblock} The expression -\tcode{out \shl\ setw(n)} +\tcode{out << setw(n)} shall have type \tcode{basic_ostream\&} and value \tcode{out}. The expression -\tcode{in \shr\ setw(n)} +\tcode{in >> setw(n)} shall have type \tcode{basic_istream\&} and value @@ -6996,13 +6946,13 @@ specialization of the \tcode{basic_string} template (Clause~\ref{strings}). \pnum -\effects The expression \tcode{in \shr get_money(mon, intl)} described below +\effects The expression \tcode{in >> get_money(mon, intl)} described below behaves as a formatted input function~(\ref{istream.formatted.reqmts}). \pnum \returns An object of unspecified type such that if \tcode{in} is an object of type \tcode{basic_istream} -then the expression \tcode{in \shr\ get_money(mon, intl)} behaves as if it called +then the expression \tcode{in >> get_money(mon, intl)} behaves as if it called \tcode{f(in, mon, intl)}, where the function \tcode{f} is defined as: \begin{codeblock} @@ -7012,7 +6962,7 @@ using MoneyGet = money_get; ios_base::iostate err = ios_base::goodbit; - const MoneyGet &mg = use_facet(str.getloc()); + const MoneyGet& mg = use_facet(str.getloc()); mg.get(Iter(str.rdbuf()), Iter(), intl, str, err, mon); @@ -7021,7 +6971,7 @@ } \end{codeblock} -The expression \tcode{in \shr\ get_money(mon, intl)} shall have type +The expression \tcode{in >> get_money(mon, intl)} shall have type \tcode{basic_istream\&} and value \tcode{in}. \end{itemdescr} @@ -7038,7 +6988,8 @@ \pnum \returns An object of unspecified type such that if \tcode{out} is an object of type \tcode{basic_ostream} -then the expression \tcode{out \shl\ put_money(mon, intl)} behaves as a formatted output function~(\ref{ostream.formatted.reqmts}) that calls +then the expression \tcode{out << put_money(mon, intl)} behaves as a +formatted output function~(\ref{ostream.formatted.reqmts}) that calls \tcode{f(out, mon, intl)}, where the function \tcode{f} is defined as: \begin{codeblock} @@ -7055,7 +7006,7 @@ } \end{codeblock} -The expression \tcode{out \shl\ put_money(mon, intl)} shall have type +The expression \tcode{out << put_money(mon, intl)} shall have type \tcode{basic_ostream\&} and value \tcode{out}. \end{itemdescr} @@ -7071,7 +7022,7 @@ \pnum \returns An object of unspecified type such that if \tcode{in} is an object of type -\tcode{basic_istream} then the expression \tcode{in \shr\ get_time(tmb, +\tcode{basic_istream} then the expression \tcode{in >> get_time(tmb, fmt)} behaves as if it called \tcode{f(in, tmb, fmt)}, where the function \tcode{f} is defined as: @@ -7092,7 +7043,7 @@ } \end{codeblock} -The expression \tcode{in \shr\ get_time(tmb, fmt)} shall have type +The expression \tcode{in >> get_time(tmb, fmt)} shall have type \tcode{basic_istream\&} and value \tcode{in}. \end{itemdescr} @@ -7110,9 +7061,9 @@ \pnum \returns An object of unspecified type such that if \tcode{out} is an object of -type \tcode{basic_ostream} then the expression \tcode{out \shl\ -put_time(tmb, fmt)} behaves as if it called \tcode{f(out, tmb, fmt)}, where the -function \tcode{f} is defined as: +type \tcode{basic_ostream} then the expression +\tcode{out << put_time(tmb, fmt)} behaves as if it called \tcode{f(out, tmb, fmt)}, +where the function \tcode{f} is defined as: \begin{codeblock} template @@ -7129,7 +7080,7 @@ } \end{codeblock} -The expression \tcode{out \shl\ put_time(tmb, fmt)} shall have type +The expression \tcode{out << put_time(tmb, fmt)} shall have type \tcode{basic_ostream\&} and value \tcode{out}. \end{itemdescr} @@ -7153,7 +7104,7 @@ of \tcode{basic_ostream} with member type \tcode{char_type} the same as \tcode{charT} and with member type \tcode{traits_type}, which in the second form is the same as \tcode{traits}, then the expression -\tcode{out \shl\ quoted(s, delim, escape)} +\tcode{out << quoted(s, delim, escape)} behaves as a formatted output function~(\ref{ostream.formatted.reqmts}) of \tcode{out}. This forms a character sequence \tcode{seq}, initially consisting of the following elements: @@ -7169,7 +7120,7 @@ in~\ref{ostream.formatted.reqmts}, \tcode{seq} is inserted as if by calling \tcode{out.rdbuf()->sputn(seq, n)}, where \tcode{n} is the larger of \tcode{out.width()} and \tcode{x}, and \tcode{out.width(0)} is called. -The expression \tcode{out \shl\ quoted(s, delim, escape)} shall have type +The expression \tcode{out << quoted(s, delim, escape)} shall have type \tcode{basic_ostream\&} and value \tcode{out}. \end{itemdescr} @@ -7187,9 +7138,9 @@ \item If \tcode{in} is an instance of \tcode{basic_istream} with member types \tcode{char_type} and \tcode{traits_type} the same as \tcode{charT} and \tcode{traits}, respectively, then the expression -\tcode{in \shr\ quoted(s, delim, escape)} behaves as if it extracts the following +\tcode{in >> quoted(s, delim, escape)} behaves as if it extracts the following characters from \tcode{in} using -\tcode{operator\shr(basic_istream\&, charT\&)}~(\ref{istream.extractors}) +\tcode{operator>>(basic_istream\&, charT\&)}~(\ref{istream.extractors}) which may throw \tcode{ios_base::failure}~(\ref{ios::failure}): \begin{itemize} \item If the first character extracted is equal to \tcode{delim}, as @@ -7204,36 +7155,25 @@ \item Discard the final \tcode{delim} character. \item Restore the \tcode{skipws} flag to its original value. \end{itemize} -\item Otherwise, \tcode{in \shr\ s}. +\item Otherwise, \tcode{in >> s}. \end{itemize} \item If \tcode{out} is an instance of \tcode{basic_ostream} with member types \tcode{char_type} and \tcode{traits_type} the same as \tcode{charT} and \tcode{traits}, respectively, then the expression -\tcode{out \shl\ quoted(s, delim, escape)} behaves as specified for the +\tcode{out << quoted(s, delim, escape)} behaves as specified for the \tcode{const basic_string\&} overload of the \tcode{quoted} function. \end{itemize} -The expression \tcode{in \shr\ quoted(s, delim, escape)} shall have type +The expression \tcode{in >> quoted(s, delim, escape)} shall have type \tcode{basic_istream\&} and value \tcode{in}. The expression -\tcode{out \shl\ quoted(s, delim, escape)} shall have type +\tcode{out << quoted(s, delim, escape)} shall have type \tcode{basic_ostream\brk{}\&} and value \tcode{out}. \end{itemdescr} \rSec1[string.streams]{String-based streams} -\rSec2[string.streams.overview]{Overview} - -\pnum -The header -\tcode{} -defines four -class templates -and eight types that associate stream buffers with objects of class -\tcode{basic_string}, -\indexlibrary{\idxcode{basic_string}}% -as described in~\ref{string.classes}. - -\synopsis{Header \tcode{} synopsis} +\rSec2[sstream.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{sstream}}% \indexlibrary{\idxhdr{sstream}}% \indexlibrary{\idxcode{stringbuf}}% @@ -7282,14 +7222,23 @@ } \end{codeblock} +\pnum +The header +\tcode{} +defines four +class templates +and eight types that associate stream buffers with objects of class +\tcode{basic_string}, +\indexlibrary{\idxcode{basic_string}}% +as described in~\ref{string.classes}. + \rSec2[stringbuf]{Class template \tcode{basic_stringbuf}} \indexlibrary{\idxcode{basic_stringbuf}}% \begin{codeblock} namespace std { template , class Allocator = allocator> - class basic_stringbuf - : public basic_streambuf { + class basic_stringbuf : public basic_streambuf { public: using char_type = charT; using int_type = typename traits::int_type; @@ -7805,8 +7754,7 @@ namespace std { template , class Allocator = allocator> - class basic_istringstream - : public basic_istream { + class basic_istringstream : public basic_istream { public: using char_type = charT; using int_type = typename traits::int_type; @@ -7993,8 +7941,7 @@ namespace std { template , class Allocator = allocator> - class basic_ostringstream - : public basic_ostream { + class basic_ostringstream : public basic_ostream { public: using char_type = charT; using int_type = typename traits::int_type; @@ -8182,8 +8129,7 @@ namespace std { template , class Allocator = allocator> - class basic_stringstream - : public basic_iostream { + class basic_stringstream : public basic_iostream { public: using char_type = charT; using int_type = typename traits::int_type; @@ -8236,7 +8182,7 @@ \tcode{sb}, the \tcode{stringbuf} object. \end{itemize} -\rSec3[stringstream.cons]{basic_stringstream constructors} +\rSec3[stringstream.cons]{\tcode{basic_stringstream} constructors} \indexlibrary{\idxcode{basic_stringstream}!constructor}% \begin{itemdecl} @@ -8371,16 +8317,8 @@ \rSec1[file.streams]{File-based streams} -\rSec2[fstreams]{Overview} - -\pnum -The header -\tcode{} -defines four class templates and eight types -that associate stream buffers with files and assist -reading and writing files. - -\synopsis{Header \tcode{} synopsis} +\rSec2[fstream.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{fstream}}% \indexlibrary{\idxhdr{fstream}}% \indexlibrary{\idxcode{filebuf}}% \indexlibrary{\idxcode{basic_filebuf}}% @@ -8422,6 +8360,13 @@ } \end{codeblock} +\pnum +The header +\tcode{} +defines four class templates and eight types +that associate stream buffers with files and assist +reading and writing files. + \pnum \begin{note} The class template \tcode{basic_filebuf} treats a file as a source or sink of bytes. In an environment that uses a large character set, the file @@ -8435,8 +8380,7 @@ \begin{codeblock} namespace std { template > - class basic_filebuf - : public basic_streambuf { + class basic_filebuf : public basic_streambuf { public: using char_type = charT; using int_type = typename traits::int_type; @@ -8735,6 +8679,7 @@ \tcode{fseek(FILE*, long, int)} \indexlibrary{\idxcode{fseek}}% are declared, in +\indextext{\idxhdr{cstdio}}% \indexlibrary{\idxhdr{cstdio}}% \tcode{}~(\ref{cstdio.syn}).} @@ -8756,6 +8701,7 @@ \end{itemdecl} \begin{itemdescr} +\pnum \returns \tcode{open(s.c_str(), mode);} \end{itemdescr} @@ -8843,8 +8789,7 @@ \tcode{basic_streambuf::underflow()}, with the specialization that a sequence of characters is read from the input sequence as if by reading from the associated file -into an internal buffer ( -\tcode{extern_buf}) +into an internal buffer (\tcode{extern_buf}) and then as if by doing: \begin{codeblock} @@ -9200,8 +9145,7 @@ \begin{codeblock} namespace std { template > - class basic_ifstream - : public basic_istream { + class basic_ifstream : public basic_istream { public: using char_type = charT; using int_type = typename traits::int_type; @@ -9438,8 +9382,7 @@ \begin{codeblock} namespace std { template > - class basic_ofstream - : public basic_ostream { + class basic_ofstream : public basic_ostream { public: using char_type = charT; using int_type = typename traits::int_type; @@ -9673,8 +9616,7 @@ \begin{codeblock} namespace std { template > - class basic_fstream - : public basic_iostream { + class basic_fstream : public basic_iostream { public: using char_type = charT; using int_type = typename traits::int_type; @@ -10053,7 +9995,7 @@ \definitionx{native encoding}{fs.def.native.encode} For narrow character strings, the operating system dependent current encoding -for pathnames~(\ref{fs.def.pathname}). For wide character strings, the implementation defined execution +for pathnames~(\ref{fs.def.pathname}). For wide character strings, the implementation-defined execution wide-character set encoding~(\ref{lex.charset}). \definitionx{native pathname format}{fs.def.native} @@ -10160,6 +10102,7 @@ subclause are assumed to be qualified with \tcode{::std::filesystem::}. \rSec2[fs.filesystem.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{filesystem}}% \indexlibrary{\idxhdr{filesystem}}% \begin{codeblock} @@ -11824,7 +11767,7 @@ \item The \grammarterm{root-name} element, if present. \item The \grammarterm{root-directory} element, if present. \begin{note} -the generic format is required to ensure lexicographical +The generic format is required to ensure lexicographical comparison works correctly. \end{note} \item Each successive \grammarterm{filename} element, if present. \item \grammarterm{dot}, if one or more trailing non-root \grammarterm{slash} @@ -11930,16 +11873,16 @@ \indextext{path equality} \pnum \begin{note} Path equality and path equivalence have different semantics. - -\pnum -Equality is determined by the \tcode{path} non-member \tcode{operator==}, which considers the two path's lexical - representations only. Thus \tcode{path("foo") == "bar"} is never \tcode{true}. - -\pnum -Equivalence is determined by the \tcode{equivalent()} non-member function, which determines if two paths resolve~(\ref{fs.def.pathres}) to the same file system entity. - Thus \tcode{equivalent("foo", "bar")} will be \tcode{true} when both paths resolve to the same file. - -\pnum +\begin{itemize} +\item Equality is determined by the \tcode{path} non-member \tcode{operator==}, +which considers the two path's lexical representations only. +\begin{example} \tcode{path("foo") == "bar"} is never \tcode{true}. \end{example} +\item Equivalence is determined by the \tcode{equivalent()} non-member function, which +determines if two paths resolve~(\ref{fs.def.pathres}) to the same file system entity. +\begin{example} +\tcode{equivalent("foo", "bar")} will be \tcode{true} when both paths resolve to the same file. +\end{example} +\end{itemize} Programmers wishing to determine if two paths are ``the same'' must decide if ``the same'' means ``the same representation'' or ``resolve to the same actual file'', and choose the appropriate function accordingly. \end{note} @@ -11967,7 +11910,7 @@ \rSec4[path.io]{\tcode{path} inserter and extractor} -\indexlibrarymember{operator\shl}{path}% +\indexlibrarymember{operator<<}{path}% \begin{itemdecl} template basic_ostream& @@ -11983,7 +11926,7 @@ \returns \tcode{os}. \end{itemdescr} -\indexlibrarymember{operator\shr}{path}% +\indexlibrarymember{operator>>}{path}% \begin{itemdecl} template basic_istream& @@ -12054,17 +11997,14 @@ fs::create_directory(fs::u8path(utf8_string)); \end{codeblock} -\pnum For POSIX-based operating systems with the native narrow encoding set to UTF-8, no encoding or type conversion occurs. -\pnum For POSIX-based operating systems with the native narrow encoding not set to UTF-8, a conversion to UTF-32 occurs, followed by a conversion to the current native narrow encoding. Some Unicode characters may have no native character set representation. -\pnum For Windows-based operating systems a conversion from UTF-8 to UTF-16 occurs. \end{example} @@ -12762,8 +12702,10 @@ a symbolic link to a non-existent file. Programs recursively walking directory trees for purposes of removing and renaming entries may wish to avoid following symbolic links. +\end{note} \pnum +\begin{note} If a file is removed from or added to a directory after the construction of a \tcode{directory_iterator} for the directory, it is unspecified whether or not subsequently incrementing the iterator will ever @@ -13428,7 +13370,6 @@ file3 \end{codeblock} -\pnum Calling \tcode{copy("/dir1", "/dir3")} would result in: \begin{codeblock} /dir1 @@ -13441,7 +13382,6 @@ file2 \end{codeblock} -\pnum Alternatively, calling \tcode{copy("/dir1", "/dir3", copy_options::recursive)} would result in: \begin{codeblock} /dir1 @@ -13755,10 +13695,10 @@ \pnum \begin{note} The \tcode{current_path()} name was chosen to emphasize that the returned value is a - path, not just a single directory name. + path, not just a single directory name. \end{note} \pnum -The current path as returned by many operating systems is a dangerous +\begin{note} The current path as returned by many operating systems is a dangerous global variable. It may be changed unexpectedly by a third-party or system library functions, or by another thread. \end{note} \end{itemdescr} @@ -13816,7 +13756,7 @@ and equal \tcode{st_ino} values. \pnum -\throws As specified in~(\ref{fs.err.report}). +\throws As specified in~\ref{fs.err.report}. \end{itemdescr} @@ -14676,7 +14616,6 @@ \begin{example} For POSIX-based operating systems, \tcode{system_complete(p)} has the same semantics as \tcode{absolute(p, current_path())}. -\pnum For Windows-based operating systems, \tcode{system_complete(p)} has the same semantics as \tcode{absolute(p, current_path())} if \tcode{p.is_absolute() || !p.has_root_name()} or @@ -14714,13 +14653,12 @@ supplied by the first environment variable found in the list TMPDIR, TMP, TEMP, TEMPDIR, or if none of these are found, \tcode{"/tmp"}. -\pnum For Windows-based operating systems, an implementation might return the path reported by the Windows \tcode{GetTempPath} API function. \end{example} \end{itemdescr} -\rSec3[fs.op.weakly_canonical]{Weakly Canonical} +\rSec3[fs.op.weakly_canonical]{Weakly canonical} \indexlibrary{\idxcode{weakly_canonical}}% \begin{itemdecl} @@ -14764,7 +14702,7 @@ \rSec1[c.files]{C library files} \rSec2[cstdio.syn]{Header \tcode{} synopsis} - +\indextext{\idxhdr{cstdio}}% \indextext{\idxhdr{cstdio}}% \indexlibrary{\idxcode{size_t}}% \indexlibrary{\idxcode{FILE}}% @@ -14830,6 +14768,7 @@ \indexlibrary{\idxcode{feof}}% \indexlibrary{\idxcode{ferror}}% \indexlibrary{\idxcode{perror}}% + \begin{codeblock} namespace std { using size_t = @\textit{see \ref{support.types.layout}}@; @@ -14904,7 +14843,9 @@ \end{codeblock} \pnum +\indextext{\idxhdr{stdio.h}}% \indexlibrary{\idxhdr{stdio.h}}% +\indextext{\idxhdr{cstdio}}% \indexlibrary{\idxhdr{cstdio}}% The contents and meaning of the header \tcode{} are the same as the C standard library header \tcode{}. @@ -14919,6 +14860,7 @@ \rSec2[cinttypes.syn]{Header \tcode{} synopsis} \indextext{\idxhdr{cinttypes}}% +\indexlibrary{\idxhdr{cinttypes}}% \indexlibrary{\idxcode{imaxdiv_t}}% \indexlibrary{\idxcode{imaxabs}}% \indexlibrary{\idxcode{imaxdiv}}% @@ -14984,7 +14926,7 @@ \indexlibrary{\idxcode{SCNuPTR}}% \indexlibrary{\idxcode{SCNxPTR}}% \begin{codeblock} -#include +#include // see \ref{cstdint.syn} namespace std { using imaxdiv_t = @\seebelow@; @@ -15058,17 +15000,17 @@ \end{codeblock} \pnum +\indextext{\idxhdr{inttypes.h}}% \indexlibrary{\idxhdr{inttypes.h}}% +\indextext{\idxhdr{cinttypes}}% \indexlibrary{\idxhdr{cinttypes}}% -The contents and meaning of header \tcode{} +The contents and meaning of the header \tcode{} are the same as the C standard library header \tcode{}, with the following changes: - \begin{itemize} \item -the header \tcode{} includes the header \tcode{} instead +The header \tcode{} includes the header \tcode{} instead of \tcode{}, and - \item if and only if the type \tcode{intmax_t} designates an extended integer type~(\ref{basic.fundamental}), the following function signatures are added: diff --git a/source/iterators.tex b/source/iterators.tex index 90db8b5179..0f2a6fcb2c 100644 --- a/source/iterators.tex +++ b/source/iterators.tex @@ -102,11 +102,11 @@ \pnum Iterators that further satisfy the requirements of output iterators are -called \defn{mutable iterator}{s}. Nonmutable iterators are referred to -as \defn{constant iterator}{s}. +called \defnx{mutable iterators}{mutable iterator}. Nonmutable iterators are referred to +as \defnx{constant iterators}{constant iterator}. \pnum -In addition to the requirements in this sub-clause, +In addition to the requirements in this subclause, the nested \grammarterm{typedef-name}{s} specified in \ref{iterator.traits} shall be provided for the iterator type. \begin{note} Either the iterator type must provide the \grammarterm{typedef-name}{s} directly @@ -290,7 +290,7 @@ \tcode{*r} & unspecified & & - pre: \tcode{r} is dereferenceable. \\ \rowsep + \requires \tcode{r} is dereferenceable. \\ \rowsep \tcode{++r} & \tcode{X\&} & @@ -324,7 +324,7 @@ These requirements can be inferred from the uses that algorithm makes of \tcode{==} and \tcode{!=}. \begin{example} -the call \tcode{find(a,b,x)} +The call \tcode{find(a,b,x)} is defined only if the value of \tcode{a} has the property \textit{p} defined as follows: @@ -356,25 +356,25 @@ \tcode{a != b} & contextually convertible to \tcode{bool} & \tcode{!(a == b)} & - pre: \orange{a}{b} is in the domain of \tcode{==}. \\ \rowsep + \requires \orange{a}{b} is in the domain of \tcode{==}. \\ \rowsep \tcode{*a} & \tcode{reference}, convertible to \tcode{T} & & - pre: \tcode{a} is dereferenceable.\br + \requires \tcode{a} is dereferenceable.\br The expression\br \tcode{(void)*a, *a} is equivalent to \tcode{*a}.\br If \tcode{a == b} and \orange{a}{b} is in the domain of \tcode{==} then \tcode{*a} is equivalent to \tcode{*b}. \\ \rowsep \tcode{a->m} & & \tcode{(*a).m} & - pre: \tcode{a} is dereferenceable. \\ \rowsep + \requires \tcode{a} is dereferenceable. \\ \rowsep \tcode{++r} & \tcode{X\&} & & - pre: \tcode{r} is dereferenceable.\br - post: \tcode{r} is dereferenceable or \tcode{r} is past-the-end.\br - post: any copies of the previous value of \tcode{r} are no longer + \requires \tcode{r} is dereferenceable.\br + \postconditions \tcode{r} is dereferenceable or \tcode{r} is past-the-end;\br + any copies of the previous value of \tcode{r} are no longer required either to be dereferenceable or to be in the domain of \tcode{==}. \\ \rowsep \tcode{(void)r++} & @@ -432,14 +432,14 @@ result is not used & & \remarks\ After this operation \tcode{r} is not required to be dereferenceable.\br - post: \tcode{r} is incrementable. \\ \rowsep + \postconditions \tcode{r} is incrementable. \\ \rowsep \tcode{++r} & \tcode{X\&} & & \tcode{\&r == \&++r}.\br \remarks\ After this operation \tcode{r} is not required to be dereferenceable.\br - post: \tcode{r} is incrementable. \\ \rowsep + \postconditions \tcode{r} is incrementable. \\ \rowsep \tcode{r++} & convertible to \tcode{const X\&} & @@ -447,12 +447,12 @@ \tcode{ ++r;}\br \tcode{ return tmp; \}} & \remarks\ After this operation \tcode{r} is not required to be dereferenceable.\br - post: \tcode{r} is incrementable. \\ \rowsep + \postconditions \tcode{r} is incrementable. \\ \rowsep \tcode{*r++ = o} & result is not used && \remarks\ After this operation \tcode{r} is not required to be dereferenceable.\br - post: \tcode{r} is incrementable. \\ + \postconditions \tcode{r} is incrementable. \\ \end{libreqtab4b} \pnum @@ -580,8 +580,8 @@ \tcode{\dcr r} & \tcode{X\&} & & - pre: there exists \tcode{s} such that \tcode{r == ++s}.\br - post: \tcode{r} is dereferenceable.\br + \requires there exists \tcode{s} such that \tcode{r == ++s}.\br + \postconditions \tcode{r} is dereferenceable.\br \tcode{\dcr(++r) == r}.\br \tcode{\dcr r == \dcr s} implies \tcode{r == s}.\br \tcode{\&r == \&\dcr r}. \\ \hline @@ -643,7 +643,7 @@ \tcode{r -= n} & \tcode{X\&} & \tcode{return r += -n;} & - pre: the absolute value of \tcode{n} is in the range of + \requires the absolute value of \tcode{n} is in the range of representable values of \tcode{difference_type}. \\ \rowsep \tcode{a - n} & @@ -654,7 +654,7 @@ \tcode{b - a} & \tcode{difference_type} & \tcode{return n} & - pre: there exists a value \tcode{n} of type \tcode{difference_type} such that \tcode{a + n == b}.\br + \requires there exists a value \tcode{n} of type \tcode{difference_type} such that \tcode{a + n == b}.\br \tcode{b == a + (b - a)}. \\ \rowsep \tcode{a[n]} & @@ -686,6 +686,7 @@ \rSec1[iterator.synopsis]{Header \tcode{}\ synopsis} +\indextext{\idxhdr{iterator}}% \indexlibrary{\idxhdr{iterator}}% \begin{codeblock} namespace std { @@ -866,6 +867,7 @@ \rSec2[iterator.traits]{Iterator traits} \pnum +\indexlibrary{\idxcode{iterator_traits}}% To implement algorithms only in terms of iterators, it is often necessary to determine the value and difference types that correspond to a particular iterator type. @@ -1204,7 +1206,7 @@ constexpr reverse_iterator& operator+=(difference_type n); constexpr reverse_iterator operator- (difference_type n) const; constexpr reverse_iterator& operator-=(difference_type n); - constexpr @\unspec@ operator[](difference_type n) const; + constexpr @\unspecnc@ operator[](difference_type n) const; protected: Iterator current; }; @@ -1257,17 +1259,17 @@ \pnum Additionally, \tcode{Iterator} -shall meet the requirements of a Random Access Iterator~(\ref{random.access.iterators}) +shall meet the requirements of a random access iterator~(\ref{random.access.iterators}) if any of the members \tcode{operator+}~(\ref{reverse.iter.op+}), \tcode{operator-}~(\ref{reverse.iter.op-}), \tcode{operator+=}~(\ref{reverse.iter.op+=}), \tcode{operator-=}~(\ref{reverse.iter.op-=}), -\tcode{operator\,[]}~(\ref{reverse.iter.opindex}), +\tcode{operator[]}~(\ref{reverse.iter.opindex}), or the non-member operators \tcode{operator<}~(\ref{reverse.iter.op<}), \tcode{operator>}~(\ref{reverse.iter.op>}),\\ -\tcode{operator\,<=}~(\ref{reverse.iter.op<=}), +\tcode{operator<=}~(\ref{reverse.iter.op<=}), \tcode{operator>=}~(\ref{reverse.iter.op>=}), \tcode{operator-}~(\ref{reverse.iter.opdiff}) or @@ -1308,7 +1310,7 @@ \indexlibrary{\idxcode{reverse_iterator}!constructor}% \begin{itemdecl} -template constexpr reverse_iterator(const reverse_iterator &u); +template constexpr reverse_iterator(const reverse_iterator& u); \end{itemdecl} \begin{itemdescr} @@ -1651,7 +1653,7 @@ \rSec4[reverse.iter.make]{Non-member function \tcode{make_reverse_iterator()}} -\indexlibrary{\idxcode{reverse_iterator}!\idxcode{make_reverse_iterator}~non-member~function}% +\indexlibrary{\idxcode{reverse_iterator}!\idxcode{make_reverse_iterator} non-member function}% \indexlibrary{\idxcode{make_reverse_iterator}}% \begin{itemdecl} template @@ -2195,7 +2197,7 @@ \pnum The template parameter \tcode{Iterator} shall meet -the requirements for an Input Iterator~(\ref{input.iterators}). +the requirements of an input iterator~(\ref{input.iterators}). Additionally, if any of the bidirectional or random access traversal functions are instantiated, the template parameter shall meet the requirements for a Bidirectional Iterator~(\ref{bidirectional.iterators}) @@ -2562,7 +2564,7 @@ \tcode{istream_iterator} is an input iterator~(\ref{input.iterators}) that reads (using -\tcode{operator\shr}) +\tcode{operator>>}) successive elements from the input stream for which it was constructed. After it is constructed, and every time \tcode{++} @@ -2653,7 +2655,7 @@ \effects Constructs the end-of-stream iterator. If \tcode{is_trivially_default_constructible_v} is \tcode{true}, -then this constructor is a \tcode{constexpr} constructor. +then this constructor is a constexpr constructor. \pnum \postconditions \tcode{in_stream == 0}. @@ -2668,8 +2670,8 @@ \begin{itemdescr} \pnum \effects -Initializes \textit{in_stream} with \tcode{addressof(s)}. -\textit{value} may be initialized during +Initializes \tcode{in_stream} with \tcode{addressof(s)}. +\tcode{value} may be initialized during construction or the first time it is referenced. \pnum @@ -2716,7 +2718,7 @@ \begin{itemdescr} \pnum \returns -\textit{value}. +\tcode{value}. \end{itemdescr} \indexlibrarymember{operator->}{istream_iterator}% @@ -2741,7 +2743,7 @@ \pnum \effects -As if by: \tcode{*in_stream \shr value;} +As if by: \tcode{*in_stream >> value;} \pnum \returns @@ -2770,8 +2772,8 @@ \indexlibrarymember{operator==}{istream_iterator}% \begin{itemdecl} template - bool operator==(const istream_iterator &x, - const istream_iterator &y); + bool operator==(const istream_iterator& x, + const istream_iterator& y); \end{itemdecl} \begin{itemdescr} @@ -2783,8 +2785,8 @@ \indexlibrarymember{operator"!=}{istream_iterator}% \begin{itemdecl} template - bool operator!=(const istream_iterator &x, - const istream_iterator &y); + bool operator!=(const istream_iterator& x, + const istream_iterator& y); \end{itemdecl} \begin{itemdescr} @@ -2799,7 +2801,7 @@ \indexlibrary{\idxcode{ostream_iterator}}% \tcode{ostream_iterator} writes (using -\tcode{operator\shl}) +\tcode{operator<<}) successive elements onto the output stream from which it was constructed. If it was constructed with \tcode{charT*} @@ -2861,8 +2863,8 @@ \begin{itemdescr} \pnum \effects -Initializes \textit{out_stream} with \tcode{addressof(s)} and -\textit{delim} with null. +Initializes \tcode{out_stream} with \tcode{addressof(s)} and +\tcode{delim} with null. \end{itemdescr} @@ -2874,8 +2876,8 @@ \begin{itemdescr} \pnum \effects -Initializes \textit{out_stream} with \tcode{addressof(s)} and -\textit{delim} with \tcode{delimiter}. +Initializes \tcode{out_stream} with \tcode{addressof(s)} and +\tcode{delim} with \tcode{delimiter}. \end{itemdescr} @@ -2913,9 +2915,9 @@ \effects As if by: \begin{codeblock} -*@\textit{out_stream}@ << value; -if (@\textit{delim}@ != 0) - *@\textit{out_stream}@ << @\textit{delim}@; +*out_stream << value; +if (delim != 0) + *out_stream << delim; return *this; \end{codeblock} \end{itemdescr} diff --git a/source/lex.tex b/source/lex.tex index 601ef037e7..ae457307bd 100644 --- a/source/lex.tex +++ b/source/lex.tex @@ -135,7 +135,7 @@ \item White-space characters separating tokens are no longer significant. Each preprocessing token is converted into a -token.~(\ref{lex.token}). The resulting tokens are syntactically and +token~(\ref{lex.token}). The resulting tokens are syntactically and semantically analyzed and translated as a translation unit. \begin{note} The process of analyzing and translating the tokens may occasionally result in one token being replaced by a sequence of other @@ -401,7 +401,7 @@ There are five kinds of tokens: identifiers, keywords, literals,\footnote{Literals include strings and character and numeric literals. } operators, and other separators. -\indextext{white~space}% +\indextext{white space}% Blanks, horizontal and vertical tabs, newlines, formfeeds, and comments (collectively, ``white space''), as described below, are ignored except as they serve to separate tokens. \begin{note} Some white space is @@ -414,7 +414,7 @@ \pnum \indextext{comment|(}% -\indextext{comment!\tcode{/*}~\tcode{*/}}% +\indextext{comment!\tcode{/*} \tcode{*/}}% \indextext{comment!\tcode{//}}% The characters \tcode{/*} start a comment, which terminates with the characters \tcode{*/}. These comments do not nest. @@ -540,7 +540,7 @@ \end{bnf} \pnum -\indextext{name!length~of}% +\indextext{name!length of}% \indextext{name}% An identifier is an arbitrarily long sequence of letters and digits. Each \grammarterm{universal-character-name} in an identifier shall designate a @@ -638,11 +638,10 @@ \pnum \indextext{\idxcode{_}|see{character, underscore}}% \indextext{character!underscore!in identifier}% -\indextext{reserved~identifier}% +\indextext{reserved identifier}% In addition, some identifiers are reserved for use by \Cpp implementations and shall -not be used otherwise; no diagnostic is required.% -\indextext{identifier|)} +not be used otherwise; no diagnostic is required. \begin{itemize} \item Each identifier that contains a double underscore @@ -657,7 +656,8 @@ \indextext{character!underscore}% reserved to the implementation for use as a name in the global namespace.% \indextext{namespace!global} -\end{itemize} +\end{itemize}% +\indextext{identifier|)} \rSec1[lex.key]{Keywords} @@ -797,7 +797,7 @@ \>new \>delete \>? \>:: \>. \>.*\br \>+ \>- \>* \>/ \>\% \>\caret \>\& \>| \>\tilde\br \>! \>= \>< \>> \>+= \>-= \>*= \>/= \>\%=\br -\>\caret= \>\&= \>|= \>\shl \>\shr \>\shr= \>\shl= \>== \>!=\br +\>\caret= \>\&= \>|= \><< \>>> \>>>= \><<= \>== \>!=\br \><= \>>= \>\&\& \>|| \>++ \>-{-} \>, \>->* \>->\br \>and \>and_eq \>bitand \>bitor \>compl \>not \>not_eq\br \>or \>or_eq \>xor \>xor_eq @@ -926,7 +926,7 @@ \pnum \indextext{literal!\idxcode{unsigned}}% \indextext{literal!\idxcode{long}}% -\indextext{literal!base~of integer}% +\indextext{literal!base of integer}% An \defnx{integer literal}{literal!integer} is a sequence of digits that has no period or exponent part, with optional separating single quotes that are ignored when determining its value. An integer literal may have a prefix that specifies @@ -947,7 +947,7 @@ through \tcode{f} and \tcode{A} through \tcode{F} with decimal values ten through fifteen. \begin{example} The number twelve can be written \tcode{12}, \tcode{014}, -\tcode{0XC}, or \tcode{0b1100}. The literals \tcode{1048576}, +\tcode{0XC}, or \tcode{0b1100}. The integer literals \tcode{1048576}, \tcode{1'048'576}, \tcode{0X100000}, \tcode{0x10'0000}, and \tcode{0'004'000'000} all have the same value. \end{example} @@ -956,7 +956,7 @@ \indextext{literal!\idxcode{long}}% \indextext{literal!\idxcode{unsigned}}% \indextext{literal!integer}% -\indextext{literal!type~of integer}% +\indextext{literal!type of integer}% \indextext{suffix!\idxcode{L}}% \indextext{suffix!\idxcode{U}}% \indextext{suffix!\idxcode{l}}% @@ -1036,9 +1036,9 @@ \pnum If an integer literal cannot be represented by any type in its list and an extended integer type~(\ref{basic.fundamental}) can represent its value, it may have that -extended integer type. If all of the types in the list for the literal +extended integer type. If all of the types in the list for the integer literal are signed, the extended integer type shall be signed. If all of the -types in the list for the literal are unsigned, the extended integer +types in the list for the integer literal are unsigned, the extended integer type shall be unsigned. If the list contains both signed and unsigned types, the extended integer type may be signed or unsigned. A program is ill-formed if one of its translation units contains an integer literal @@ -1110,7 +1110,7 @@ respectively. \pnum -\indextext{literal!type~of character}% +\indextext{literal!type of character}% \indextext{literal!character!ordinary}% A character literal that does not begin with \tcode{u8}, \tcode{u}, \tcode{U}, or \tcode{L} @@ -1153,11 +1153,11 @@ begins with the letter \tcode{u}, such as \tcode{u'x'}, \indextext{prefix!\idxcode{u}}% is a character literal of type \tcode{char16_t}. The value -of a \tcode{char16_t} literal containing a single \grammarterm{c-char} is +of a \tcode{char16_t} character literal containing a single \grammarterm{c-char} is equal to its ISO 10646 code point value, provided that the code point is representable with a single 16-bit code unit. (That is, provided it is a basic multi-lingual plane code point.) If the value is not representable -within 16 bits, the program is ill-formed. A \tcode{char16_t} literal +within 16 bits, the program is ill-formed. A \tcode{char16_t} character literal containing multiple \grammarterm{c-char}{s} is ill-formed. \pnum @@ -1168,8 +1168,8 @@ begins with the letter \tcode{U}, such as \tcode{U'y'}, \indextext{prefix!\idxcode{U}}% is a character literal of type \tcode{char32_t}. The value of a -\tcode{char32_t} literal containing a single \grammarterm{c-char} is equal -to its ISO 10646 code point value. A \tcode{char32_t} literal containing +\tcode{char32_t} character literal containing a single \grammarterm{c-char} is equal +to its ISO 10646 code point value. A \tcode{char32_t} character literal containing multiple \grammarterm{c-char}{s} is ill-formed. \pnum @@ -1199,12 +1199,12 @@ the question mark \tcode{?},\footnote{Using an escape sequence for a question mark is supported for compatibility with ISO \CppXIV and ISO C.} and the backslash -\indextext{backslash~character}% +\indextext{backslash character}% \indextext{\idxcode{\textbackslash}|see{backslash}}% -\indextext{escape~character|see{backslash}}% +\indextext{escape character|see{backslash}}% \tcode{\textbackslash}, can be represented according to Table~\ref{tab:escape.sequences}. -\indextext{escape~sequence!undefined}% +\indextext{escape sequence!undefined}% The double quote \tcode{"} and the question mark \tcode{?}, can be represented as themselves or by the escape sequences \tcode{\textbackslash "} and \tcode{\textbackslash ?} respectively, but @@ -1248,11 +1248,11 @@ sequence. A sequence of octal or hexadecimal digits is terminated by the first character that is not an octal digit or a hexadecimal digit, respectively. -\indextext{literal!implementation-defined value~of \idxcode{char}}% +\indextext{literal!implementation-defined value of \idxcode{char}}% The value of a character literal is \impldef{value of character literal outside range of corresponding type} if it falls outside of the \impldef{range defined for character literals} -range defined for \tcode{char} (for literals with no prefix) or -\tcode{wchar_t} (for literals prefixed by \tcode{L}). +range defined for \tcode{char} (for character literals with no prefix) or +\tcode{wchar_t} (for character literals prefixed by \tcode{L}). \begin{note} If the value of a character literal prefixed by \tcode{u}, \tcode{u8}, or \tcode{U} @@ -1350,12 +1350,12 @@ The integer and fraction parts both consist of a sequence of decimal (base ten) digits if there is no prefix, or hexadecimal (base sixteen) digits if the prefix is \tcode{0x} or \tcode{0X}. -The literal is a \defnx{decimal floating literal}{literal!decimal floating} in the former case and +The floating literal is a \defnx{decimal floating literal}{literal!decimal floating} in the former case and a \defnx{hexadecimal floating literal}{literal!hexadecimal floating} in the latter case. Optional separating single quotes in a \grammarterm{digit-sequence} or \grammarterm{hexadecimal-digit-sequence} are ignored when determining its value. -\begin{example} The literals \tcode{1.602'176'565e-19} and \tcode{1.602176565e-19} +\begin{example} The floating literals \tcode{1.602'176'565e-19} and \tcode{1.602176565e-19} have the same value. \end{example} Either the integer part or the fraction part (not both) can be omitted. Either the radix point or the letter \tcode{e} or \tcode{E} and @@ -1369,7 +1369,7 @@ In a hexadecimal floating literal, the exponent indicates the power of 2 by which the significand is to be scaled. \begin{example} -The literals \tcode{49.625} and \tcode{0xC.68p+2} have the same value. +The floating literals \tcode{49.625} and \tcode{0xC.68p+2} have the same value. \end{example} If the scaled value is in the range of representable values for its type, the result is the scaled @@ -1378,7 +1378,7 @@ floating literal} manner. \indextext{literal!\idxcode{double}}% The type of a floating literal is \tcode{double} -\indextext{literal!type~of floating~point}% +\indextext{literal!type of floating-point}% unless explicitly specified by a suffix. \indextext{literal!\idxcode{float}}% \indextext{suffix!\idxcode{F}}% @@ -1428,7 +1428,7 @@ \begin{bnftab} \nontermdef{r-char}\br \>\textnormal{any member of the source character set, except}\br -\>\>\textnormal{a right parenthesis \terminal{)} followed by the initial \nonterminal{d-char-sequence}}\br +\>\>\textnormal{a right parenthesis \terminal{)} followed by the initial \grammarterm{d-char-sequence}}\br \>\>\textnormal{(which may be empty) followed by a double quote \terminal{"}.} \end{bnftab} @@ -1452,7 +1452,7 @@ \indextext{literal!string!wide}% \indextext{literal!string!\idxcode{char16_t}}% \indextext{literal!string!\idxcode{char32_t}}% -\indextext{character~string}% +\indextext{character string}% A \grammarterm{string-literal} is a sequence of characters (as defined in~\ref{lex.ccon}) surrounded by double quotes, optionally prefixed by \tcode{R}, @@ -1532,7 +1532,7 @@ is equivalent to \tcode{"\textbackslash n)\textbackslash?\textbackslash?=\textbackslash"\textbackslash n"}. \end{example} \pnum -\indextext{string!type~of}% +\indextext{string!type of}% \indextext{literal!string!narrow}% After translation phase 6, a \grammarterm{string-literal} that does not begin with an \grammarterm{encoding-prefix} is an \defn{ordinary string literal}, and is initialized with the given characters. @@ -1547,7 +1547,7 @@ Ordinary string literals and UTF-8 string literals are also referred to as narrow string literals. A narrow string literal has type -\indextext{literal!string!type~of}% +\indextext{literal!string!type of}% ``array of \placeholder{n} \tcode{const char}'', where \placeholder{n} is the size of the string as defined below, and has static storage duration~(\ref{basic.stc}). @@ -1605,7 +1605,7 @@ behavior. \begin{note} This concatenation is an interpretation, not a conversion. Because the interpretation happens in translation phase 6 (after each character from a -literal has been translated into a value from the appropriate character set), a +string literal has been translated into a value from the appropriate character set), a \grammarterm{string-literal}'s initial rawness has no effect on the interpretation or well-formedness of the concatenation. \end{note} @@ -1644,9 +1644,9 @@ \end{example} \pnum -\indextext{\idxcode{0}|seealso{zero,~null}}% +\indextext{\idxcode{0}|seealso{zero, null}}% \indextext{\idxcode{0}!string terminator}% -\indextext{\idxcode{0}!null~character|see {character, null}}% +\indextext{\idxcode{0}!null character|see {character, null}}% After any necessary concatenation, in translation phase 7~(\ref{lex.phases}), \tcode{'\textbackslash 0'} is appended to every string literal so that programs that scan a string can find its end. @@ -1672,7 +1672,7 @@ \tcode{u'\textbackslash 0'}. \begin{note} The size of a \tcode{char16_t} string literal is the number of code units, not the number of characters. \end{note} Within \tcode{char32_t} and \tcode{char16_t} -literals, any \grammarterm{universal-character-name}{s} shall be within the range +string literals, any \grammarterm{universal-character-name}{s} shall be within the range \tcode{0x0} to \tcode{0x10FFFF}. The size of a narrow string literal is the total number of escape sequences and other characters, plus at least one for the multibyte encoding of each \grammarterm{universal-character-name}, plus @@ -1688,7 +1688,7 @@ \grammarterm{string-literal} yield the same or a different object is unspecified. \begin{note} -\indextext{literal!string!undefined change~to}% +\indextext{literal!string!undefined change to}% The effect of attempting to modify a string literal is undefined. \end{note} \rSec2[lex.bool]{Boolean literals} @@ -1766,7 +1766,7 @@ \end{bnf} \pnum -If a token matches both \grammarterm{user-defined-literal} and another literal kind, it +If a token matches both \grammarterm{user-defined-literal} and another \grammarterm{literal} kind, it is treated as the latter. \begin{example} \tcode{123_km} is a \grammarterm{user-defined-literal}, but \tcode{12LL} is an \grammarterm{integer-literal}. \end{example} diff --git a/source/lib-intro.tex b/source/lib-intro.tex index 96f165f6dc..29c4ba456e 100644 --- a/source/lib-intro.tex +++ b/source/lib-intro.tex @@ -258,7 +258,7 @@ \definition{NTCTS}{defns.ntcts} \indexdefn{NTCTS}% -\indexdefn{string!null-terminated character~type}% +\indexdefn{string!null-terminated character type}% a sequence of values that have \term{character type} that precede the terminating null character type @@ -419,9 +419,9 @@ \pnum Interface convention requirements are stated as generally as possible. Instead -of stating ``class X has to define a member function \tcode{operator++()},'' the +of stating ``class X has to define a member function \tcode{operator++()}'', the interface requires ``for any object \tcode{x} of class \tcode{X}, \tcode{++x} is -defined.'' That is, whether the operator is a member is unspecified. +defined''. That is, whether the operator is a member is unspecified. \pnum Requirements are stated in terms of well-defined expressions that define valid terms of @@ -488,7 +488,6 @@ \item \complexity the time and/or space complexity of the function \item \remarks additional semantic constraints on the function \item \errors the error conditions for error codes reported by the function -\item \realnotes non-normative comments about the function \end{itemize} \pnum @@ -497,7 +496,7 @@ interpreted as follows. If \tcode{F}'s semantics specifies a \requires element, then that requirement is logically imposed prior to the \techterm{equivalent-to} semantics. Next, the semantics of the code sequence are determined by the \requires, \effects, -\sync, \postconditions, \returns, \throws, \complexity, \remarks, \errors, and \realnotes +\sync, \postconditions, \returns, \throws, \complexity, \remarks, and \errors specified for the function invocations contained in the code sequence. The value returned from \tcode{F} is specified by \tcode{F}'s \returns element, or if \tcode{F} has no \returns element, a non-\tcode{void} return from \tcode{F} is specified by the @@ -966,11 +965,9 @@ file names~(\ref{cpp.include}).} \pnum -The \Cpp standard library provides -61 -\term{\Cpp library headers}, -\indextext{header!C++ library}% -as shown in Table~\ref{tab:cpp.library.headers}. +The \Cpp standard library provides the +\defnx{\Cpp library headers}{header!C++ library}, +shown in Table~\ref{tab:cpp.library.headers}. \begin{floattable}{\Cpp library headers}{tab:cpp.library.headers} {llll} @@ -1058,9 +1055,9 @@ \pnum -The facilities of the C standard library are provided in 26 +The facilities of the C standard library are provided in the \indextext{library!C standard}% -additional headers, as shown in Table~\ref{tab:cpp.c.headers}.% +additional headers shown in Table~\ref{tab:cpp.c.headers}.% \footnote{It is intentional that there is no \Cpp header for any of these C headers: \indextext{\idxhdr{stdatomic.h}}% @@ -1681,18 +1678,18 @@ Expression & Return type & Operational semantics \\ \capsep \tcode{P u(np);}\br & & - post: \tcode{u == nullptr} \\ + \postconditions \tcode{u == nullptr} \\ \tcode{P u = np;} & & \\ \rowsep \tcode{P(np)} & & - post: \tcode{P(np) == nullptr} \\ \rowsep + \postconditions \tcode{P(np) == nullptr} \\ \rowsep \tcode{t = np} & \tcode{P\&} & - post: \tcode{t == nullptr} \\ \rowsep + \postconditions \tcode{t == nullptr} \\ \rowsep \tcode{a != b} & contextually convertible to \tcode{bool} & @@ -1878,11 +1875,11 @@ \tcode{p->m} & type of \tcode{T::m} & - \textit{pre:} \tcode{(*p).m} is well-defined. equivalent to \tcode{(*p).m} & \\ \rowsep + \requires \tcode{(*p).m} is well-defined. equivalent to \tcode{(*p).m} & \\ \rowsep \tcode{q->m} & type of \tcode{T::m} & - \textit{pre:} \tcode{(*q).m} is well-defined. equivalent to \tcode{(*q).m} & \\ \rowsep + \requires \tcode{(*q).m} is well-defined. equivalent to \tcode{(*q).m} & \\ \rowsep \tcode{static_-} \tcode{cast(w)} & \tcode{X::pointer} & @@ -1907,10 +1904,10 @@ \tcode{a.deallocate(p,n)} & (not used) & - \textit{pre:} \tcode{p} shall be a value returned by an earlier call + \requires \tcode{p} shall be a value returned by an earlier call to \tcode{allocate} that has not been invalidated by an intervening call to \tcode{deallocate}. \tcode{n} shall - match the value passed to \tcode{allocate} to obtain this memory. + match the value passed to \tcode{allocate} to obtain this memory.\br \throws Nothing. & \\ \rowsep \tcode{a.max_size()} & @@ -1940,33 +1937,33 @@ \tcode{X u = a;} & & Shall not exit via an exception.\br - post: \tcode{u == a} & \\ \rowsep + \postconditions \tcode{u == a} & \\ \rowsep \tcode{X u(b);} & & Shall not exit via an exception.\br - post: \tcode{Y(u) == b}, \tcode{u == X(b)} & \\ \rowsep + \postconditions \tcode{Y(u) == b}, \tcode{u == X(b)} & \\ \rowsep \tcode{X u(std::move(a));} \br \tcode{X u = std::move(a);} & & Shall not exit via an exception.\br - post: \tcode{u} is equal to the prior value of \tcode{a}. & \\ \rowsep + \postconditions \tcode{u} is equal to the prior value of \tcode{a}. & \\ \rowsep \tcode{X u(std::move(b));} & & Shall not exit via an exception.\br - post: \tcode{u} is equal to the prior value of \tcode{X(b)}. & \\ \rowsep + \postconditions \tcode{u} is equal to the prior value of \tcode{X(b)}. & \\ \rowsep \tcode{a.construct(c, args)}& (not used) & - Effect: Constructs an object of type \tcode{C} at + \effects Constructs an object of type \tcode{C} at \tcode{c} & \tcode{::new ((void*)c) C(forward<\brk{}Args>\brk(args)...)} \\ \rowsep \tcode{a.destroy(c)} & (not used) & - Effect: Destroys the object at \tcode{c} & + \effects Destroys the object at \tcode{c} & \tcode{c->\~{}C()} \\ \rowsep \tcode{a.select_on_container_copy_construction()} & @@ -2000,7 +1997,7 @@ \tcode{true_type} only if the expression \tcode{a1 == a2} is guaranteed to be \tcode{true} for any two (possibly \tcode{const}) values \tcode{a1}, \tcode{a2} of type \tcode{X}. & - \tcode{is_empty::type} \\ + \tcode{is_empty::\brk{}type} \\ \end{libreqtab4d} @@ -2029,7 +2026,7 @@ Note B: If \tcode{X::propagate_on_container_copy_assignment::value} is \tcode{true}, \tcode{X} shall satisfy the -\tcode{CopyAssignable} requirements (Table~\ref{tab:copyassignable}) +\tcode{CopyAssign\-able} requirements (Table~\ref{tab:copyassignable}) and the copy operation shall not throw exceptions. If \tcode{X::propagate_on_container_move_assignment::value} is \tcode{true}, \tcode{X} shall satisfy the @@ -2046,7 +2043,7 @@ \tcode{X::const_void_pointer} types shall satisfy the requirements of \tcode{NullablePointer}~(\ref{nullablepointer.requirements}). No constructor, -comparison operator, copy operation, move operation, or swap operation on +comparison function, copy operation, move operation, or swap operation on these pointer types shall exit via an exception. \tcode{X::pointer} and \tcode{X::const_pointer} shall also satisfy the requirements for a random access iterator~(\ref{iterator.requirements}). @@ -2092,7 +2089,7 @@ 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. -\begin{example} the following is an allocator class template supporting the minimal +\begin{example} The following is an allocator class template supporting the minimal interface that satisfies the requirements of Table~\ref{tab:utilities.allocator.requirements}: @@ -2167,7 +2164,7 @@ for the original template and is not explicitly prohibited.\footnote{Any library code that instantiates other library templates must be prepared to work adequately with any user-supplied specialization -that meets the minimum requirements of the Standard.} +that meets the minimum requirements of this International Standard.} \pnum The behavior of a \Cpp program is undefined if it declares @@ -2208,7 +2205,7 @@ The behavior of a \Cpp program is undefined if it adds declarations or definitions to such a namespace. \begin{example} The top level namespace \tcode{std2} is reserved -for use by future revisions of this standard. \end{example} +for use by future revisions of this International Standard. \end{example} \rSec3[reserved.names]{Reserved names}% \indextext{name!reserved} @@ -2301,12 +2298,12 @@ external linkage in a header is reserved to the implementation to designate that function signature with \indextext{linkage!external}% -external linkage. -\footnote{The list of such reserved function +external linkage.\footnote{The list of such reserved function signatures with external linkage includes \indexlibrary{\idxcode{setjmp}}% \tcode{setjmp(jmp_buf)}, declared or defined in +\indextext{\idxhdr{csetjmp}}% \indexlibrary{\idxhdr{csetjmp}}% \tcode{}, and @@ -2314,6 +2311,7 @@ \indexlibrary{\idxcode{va_list}}% \tcode{va_end(va_list)}, declared or defined in +\indextext{\idxhdr{cstdarg}}% \indexlibrary{\idxhdr{cstdarg}}% \tcode{}.} @@ -2338,16 +2336,14 @@ and \indextext{\idxcode{extern ""C++""}}% \tcode{extern "C++"} -linkage, -\footnote{ -The function -signatures declared in -\indextext{Amendment~1}% +linkage,\footnote{The function signatures declared in +\indextext{Amendment 1}% \indextext{\idxhdr{cuchar}}% \indexlibrary{\idxhdr{cuchar}}% \indextext{\idxhdr{cwchar}}% \indexlibrary{\idxhdr{cwchar}}% \indextext{\idxhdr{cwctype}}% +\indexlibrary{\idxhdr{cwctype}}% \tcode{}, \tcode{}, and @@ -2389,7 +2385,7 @@ \rSec4[usrlit.suffix]{User-defined literal suffixes} \pnum -Literal suffix identifiers ~(\ref{over.literal}) that do not start with an underscore are reserved for future standardization. +Literal suffix identifiers~(\ref{over.literal}) that do not start with an underscore are reserved for future standardization. \rSec3[alt.headers]{Headers} @@ -2529,7 +2525,7 @@ In certain cases (replacement functions, handler functions, operations on types used to instantiate standard library template components), the \Cpp standard library depends on components supplied by a \Cpp program. -If these components do not meet their requirements, the Standard places no requirements +If these components do not meet their requirements, this International Standard places no requirements on the implementation. \pnum @@ -2549,9 +2545,9 @@ \item for types used as template arguments when instantiating a template component, if the operations on the type do not implement the semantics of the applicable -\synopsis{Requirements} +\emph{Requirements} subclause~(\ref{allocator.requirements}, \ref{container.requirements}, \ref{iterator.requirements}, -\ref{numeric.requirements}). +\ref{algorithms.requirements}, \ref{numeric.requirements}). Operations on such types can report a failure by throwing an exception unless otherwise specified. \item @@ -2737,7 +2733,7 @@ For a non-virtual member function described in the \Cpp standard library, an implementation may declare a different set of member function signatures, provided that any call to the member function that would select -an overload from the set of declarations described in this standard +an overload from the set of declarations described in this International Standard behaves as if that overload were selected. \begin{note} For instance, an implementation may add parameters with default values, @@ -2746,10 +2742,10 @@ or add additional signatures for a member function name. \end{note} -\rSec3[constexpr.functions]{\tcode{constexpr} functions and constructors} +\rSec3[constexpr.functions]{Constexpr functions and constructors} \pnum -This standard explicitly requires that certain standard library functions are +This International Standard explicitly requires that certain standard library functions are \tcode{constexpr}~(\ref{dcl.constexpr}). An implementation shall not declare any standard library function signature as \tcode{constexpr} except for those where it is explicitly required. @@ -2780,7 +2776,7 @@ \rSec3[reentrancy]{Reentrancy} \pnum -Except where explicitly specified in this standard, it is \impldef{which functions in +Except where explicitly specified in this International Standard, it is \impldef{which functions in the \Cpp standard library may be recursively reentered} which functions in the \Cpp standard library may be recursively reentered. @@ -2927,7 +2923,7 @@ \Cpp standard library \indextext{specifications!C++}% that do not have a -\synopsis{Throws:} +\throws paragraph but do have a potentially-throwing exception specification diff --git a/source/limits.tex b/source/limits.tex index a34ddca1cc..1e12db5f85 100644 --- a/source/limits.tex +++ b/source/limits.tex @@ -117,7 +117,7 @@ \item% Nested external specifications [1\,024]. \item% -Recursive \tcode{constexpr} function invocations [512]. +Recursive constexpr function invocations [512]. \item% Full-expressions evaluated within a core constant expression [1\,048\,576]. \item% @@ -126,9 +126,7 @@ Recursively nested template instantiations, including substitution during template argument deduction~(\ref{temp.deduct}) [1\,024]. \item% -Handlers per -\tcode{try} -block [256]. +Handlers per try block [256]. \item% Number of placeholders~(\ref{func.bind.place}) [10]. diff --git a/source/locales.tex b/source/locales.tex index 7874ee8a8b..49b4e9b6ed 100644 --- a/source/locales.tex +++ b/source/locales.tex @@ -25,6 +25,7 @@ \rSec1[locale.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{locale}}% \indexlibrary{\idxhdr{locale}}% \begin{codeblock} namespace std { @@ -49,25 +50,31 @@ template charT toupper(charT c, const locale& loc); template charT tolower(charT c, const locale& loc); template , - class Byte_alloc = allocator> class wstring_convert; + class Wide_alloc = allocator, + class Byte_alloc = allocator> + class wstring_convert; template > + class wbuffer_convert; // \ref{category.ctype}, ctype class ctype_base; template class ctype; - template <> class ctype; // specialization + template <> class ctype; // specialization template class ctype_byname; class codecvt_base; template class codecvt; template class codecvt_byname; // \ref{category.numeric}, numeric - template > class num_get; - template > class num_put; - template class numpunct; - template class numpunct_byname; + template > + class num_get; + template > + class num_put; + template + class numpunct; + template + class numpunct_byname; // \ref{category.collate}, collation template class collate; @@ -86,10 +93,14 @@ // \ref{category.monetary}, money class money_base; - template > class money_get; - template > class money_put; - template class moneypunct; - template class moneypunct_byname; + template > + class money_get; + template > + class money_put; + template + class moneypunct; + template + class moneypunct_byname; // \ref{category.messages}, message retrieval class messages_base; @@ -105,13 +116,17 @@ the information peculiar to a locale.\footnote{In this subclause, the type name \tcode{struct tm} is an incomplete type that is defined in +\indextext{\idxhdr{ctime}}% \indexlibrary{\idxhdr{ctime}}% \tcode{}.} +\newpage + \rSec1[locales]{Locales} \rSec2[locale]{Class \tcode{locale}} +\indextext{\idxhdr{locale}}% \indexlibrary{\idxhdr{locale}}% \begin{codeblock} namespace std { @@ -148,8 +163,8 @@ bool operator!=(const locale& other) const; template - bool operator()(const basic_string& s1, - const basic_string& s2) const; + bool operator()(const basic_string& s1, + const basic_string& s2) const; // global locale objects: static locale global(const locale&); @@ -178,21 +193,21 @@ \pnum \begin{example} An iostream -\tcode{operator\shl} +\tcode{operator<<} might be implemented as:\footnote{Note that in the call to \tcode{put} the stream is implicitly converted to an -\tcode{ostreambuf_iterator}.} +\tcode{ostreambuf_iterator}.} \begin{codeblock} template -basic_ostream& -operator<< (basic_ostream& s, Date d) { - typename basic_ostream::sentry cerberos(s); +basic_ostream& +operator<< (basic_ostream& s, Date d) { + typename basic_ostream::sentry cerberos(s); if (cerberos) { ios_base::iostate err = ios_base::iostate::goodbit; tm tmbuf; d.extract(tmbuf); - use_facet> >( + use_facet> >( s.getloc()).put(s, s, s.fill(), err, &tmbuf, 'x'); s.setstate(err); // might throw } @@ -242,7 +257,7 @@ \tcode{isspace()}, so that given a locale object \tcode{loc} a \Cpp program can call -\tcode{isspace(c,loc)}. +\tcode{isspace(c, loc)}. (This eases upgrading existing extractors~(\ref{istream.formatted}).) \end{itemize} \end{note} @@ -346,12 +361,12 @@ \lhdr{Category} & \rhdr{Includes facets} \\ \capsep collate & \tcode{collate}, \tcode{collate} \\ \rowsep ctype & \tcode{ctype}, \tcode{ctype} \\ - & \tcode{codecvt} \\ - & \tcode{codecvt} \\ - & \tcode{codecvt} \\ - & \tcode{codecvt} \\ \rowsep + & \tcode{codecvt} \\ + & \tcode{codecvt} \\ + & \tcode{codecvt} \\ + & \tcode{codecvt} \\ \rowsep monetary & \tcode{moneypunct}, \tcode{moneypunct} \\ - & \tcode{moneypunct}, \tcode{moneypunct} \\ + & \tcode{moneypunct}, \tcode{moneypunct} \\ & \tcode{money_get}, \tcode{money_get} \\ & \tcode{money_put}, \tcode{money_put} \\ \rowsep numeric & \tcode{numpunct}, \tcode{numpunct} \\ @@ -387,24 +402,24 @@ \lhdr{Category} & \rhdr{Includes facets} \\ \capsep collate & \tcode{collate_byname}, \tcode{collate_byname} \\ \rowsep ctype & \tcode{ctype_byname}, \tcode{ctype_byname} \\ - & \tcode{codecvt_byname} \\ - & \tcode{codecvt_byname} \\ - & \tcode{codecvt_byname} \\ - & \tcode{codecvt_byname} \\ \rowsep -monetary & \tcode{moneypunct_byname} \\ - & \tcode{moneypunct_byname} \\ - & \tcode{money_get} \\ - & \tcode{money_put} \\ \rowsep + & \tcode{codecvt_byname} \\ + & \tcode{codecvt_byname} \\ + & \tcode{codecvt_byname} \\ + & \tcode{codecvt_byname} \\ \rowsep +monetary & \tcode{moneypunct_byname} \\ + & \tcode{moneypunct_byname} \\ + & \tcode{money_get} \\ + & \tcode{money_put} \\ \rowsep numeric & \tcode{numpunct_byname}, \tcode{numpunct_byname} \\ - & \tcode{num_get}, \tcode{num_put} \\ \rowsep -time & \tcode{time_get} \\ - & \tcode{time_get_byname} \\ - & \tcode{time_get} \\ - & \tcode{time_get_byname} \\ - & \tcode{time_put} \\ - & \tcode{time_put_byname} \\ - & \tcode{time_put} \\ - & \tcode{time_put_byname} \\ \rowsep + & \tcode{num_get}, \tcode{num_put} \\ \rowsep +time & \tcode{time_get} \\ + & \tcode{time_get_byname} \\ + & \tcode{time_get} \\ + & \tcode{time_get_byname} \\ + & \tcode{time_put} \\ + & \tcode{time_put_byname} \\ + & \tcode{time_put} \\ + & \tcode{time_put_byname} \\ \rowsep messages & \tcode{messages_byname}, \tcode{messages_byname} \\ \end{floattable} @@ -415,7 +430,7 @@ and \tcode{num_put} calls -\tcode{use_fac\-et\,\,(l)} +\tcode{use_fac\-et(l)} only for facet \tcode{F} of types @@ -468,7 +483,7 @@ \pnum Class \tcode{facet} is the base class for locale feature sets. -A class is a defn{facet} +A class is a \defn{facet} if it is publicly derived from another facet, or if it is a class derived from \tcode{locale::facet} and contains a publicly accessible declaration as follows:% @@ -818,8 +833,8 @@ \indexlibrarymember{locale}{operator()}% \begin{itemdecl} template - bool operator()(const basic_string& s1, - const basic_string& s2) const; + bool operator()(const basic_string& s1, + const basic_string& s2) const; \end{itemdecl} \begin{itemdescr} @@ -838,8 +853,10 @@ \pnum \returns -\tcode{use_facet>(*this).compare(s1.data(), s1.data() + s1.size(),\\ -s2.data(), s2.data() + s2.size()) < 0}. +\begin{codeblock} +use_facet>(*this).compare(s1.data(), s1.data() + s1.size(), + s2.data(), s2.data() + s2.size()) < 0 +\end{codeblock} \pnum \begin{example} @@ -1030,7 +1047,7 @@ \tcode{use_facet>(loc).tolower(c)}. \end{itemdescr} -\rSec4[conversions.string]{\tcode{string} conversions} +\rSec4[conversions.string]{Class template \tcode{wstring_convert}} \pnum Class template \tcode{wstring_convert} performs conversions between a wide @@ -1048,15 +1065,13 @@ \end{codeblock} \end{example} -\pnum -\synopsis{Class template \tcode{wstring_convert} synopsis} - \indexlibrary{\idxcode{wstring_convert}}% \begin{codeblock} namespace std { -template, - class Byte_alloc = allocator> class wstring_convert { + class Byte_alloc = allocator> + class wstring_convert { public: using byte_string = basic_string, Byte_alloc>; using wide_string = basic_string, Wide_alloc>; @@ -1084,6 +1099,7 @@ size_t converted() const noexcept; state_type state() const; + private: byte_string byte_err_string; // \expos wide_string wide_err_string; // \expos @@ -1183,6 +1199,7 @@ \end{itemdecl} \begin{itemdescr} +\pnum The type shall be a synonym for \tcode{wide_string::traits_type::int_type}. \end{itemdescr} @@ -1293,7 +1310,7 @@ \effects The destructor shall delete \tcode{cvtptr}. \end{itemdescr} -\rSec4[conversions.buffer]{Buffer conversions} +\rSec4[conversions.buffer]{Class template \tcode{wbuffer_convert}} \pnum Class template \tcode{wbuffer_convert} looks like a wide stream buffer, but @@ -1302,15 +1319,10 @@ lets you specify a code conversion facet to perform the conversions, without affecting any streams or locales. -\pnum -\synopsis{Class template \tcode{wbuffer_convert} synopsis} - \indexlibrary{\idxcode{wbuffer_convert}}% \begin{codeblock} namespace std { -template> +template > class wbuffer_convert : public basic_streambuf { public: @@ -1331,7 +1343,7 @@ state_type state() const; private: - streambuf* bufptr; // \expos + streambuf* bufptr; // \expos Codecvt* cvtptr; // \expos state_type cvtstate; // \expos }; @@ -1433,9 +1445,7 @@ Each of the standard categories includes a family of facets. Some of these implement formatting or parsing of a datum, for use by standard or users' iostream operators -\tcode{\shl} -and -\tcode{\shr}, +\tcode{<<} and \tcode{>>}, as members \tcode{put()} and @@ -1515,51 +1525,44 @@ \begin{codeblock} namespace std { template - class ctype : public locale::facet, public ctype_base { - public: - using char_type = charT; - - explicit ctype(size_t refs = 0); - - bool is(mask m, charT c) const; - const charT* is(const charT* low, const charT* high, mask* vec) const; - const charT* scan_is(mask m, - const charT* low, const charT* high) const; - const charT* scan_not(mask m, - const charT* low, const charT* high) const; - charT toupper(charT c) const; - const charT* toupper(charT* low, const charT* high) const; - charT tolower(charT c) const; - const charT* tolower(charT* low, const charT* high) const; - - charT widen(char c) const; - const char* widen(const char* low, const char* high, charT* to) const; - char narrow(charT c, char dfault) const; - const charT* narrow(const charT* low, const charT* high, char dfault, - char* to) const; - - static locale::id id; - - protected: - ~ctype(); - virtual bool do_is(mask m, charT c) const; - virtual const charT* do_is(const charT* low, const charT* high, - mask* vec) const; - virtual const charT* do_scan_is(mask m, - const charT* low, const charT* high) const; - virtual const charT* do_scan_not(mask m, - const charT* low, const charT* high) const; - virtual charT do_toupper(charT) const; - virtual const charT* do_toupper(charT* low, const charT* high) const; - virtual charT do_tolower(charT) const; - virtual const charT* do_tolower(charT* low, const charT* high) const; - virtual charT do_widen(char) const; - virtual const char* do_widen(const char* low, const char* high, - charT* dest) const; - virtual char do_narrow(charT, char dfault) const; - virtual const charT* do_narrow(const charT* low, const charT* high, - char dfault, char* dest) const; - }; + class ctype : public locale::facet, public ctype_base { + public: + using char_type = charT; + + explicit ctype(size_t refs = 0); + + bool is(mask m, charT c) const; + const charT* is(const charT* low, const charT* high, mask* vec) const; + const charT* scan_is(mask m, const charT* low, const charT* high) const; + const charT* scan_not(mask m, const charT* low, const charT* high) const; + charT toupper(charT c) const; + const charT* toupper(charT* low, const charT* high) const; + charT tolower(charT c) const; + const charT* tolower(charT* low, const charT* high) const; + + charT widen(char c) const; + const char* widen(const char* low, const char* high, charT* to) const; + char narrow(charT c, char dfault) const; + const charT* narrow(const charT* low, const charT* high, char dfault, char* to) const; + + static locale::id id; + + protected: + ~ctype(); + virtual bool do_is(mask m, charT c) const; + virtual const charT* do_is(const charT* low, const charT* high, mask* vec) const; + virtual const charT* do_scan_is(mask m, const charT* low, const charT* high) const; + virtual const charT* do_scan_not(mask m, const charT* low, const charT* high) const; + virtual charT do_toupper(charT) const; + virtual const charT* do_toupper(charT* low, const charT* high) const; + virtual charT do_tolower(charT) const; + virtual const charT* do_tolower(charT* low, const charT* high) const; + virtual charT do_widen(char) const; + virtual const char* do_widen(const char* low, const char* high, charT* dest) const; + virtual char do_narrow(charT, char dfault) const; + virtual const charT* do_narrow(const charT* low, const charT* high, + char dfault, char* dest) const; + }; } \end{codeblock} @@ -1702,9 +1705,9 @@ for each \tcode{*p} where -\tcode{(low<=p \&\& p} +\tcode{ctype } facet \tcode{ctc} and valid \tcode{ctype_base::mask} value \tcode{M}, @@ -1850,7 +1851,7 @@ in the range \range{low}{high}, placing the result in -\tcode{dest[p-low]}. +\tcode{dest[p - low]}. \pnum \returns @@ -1880,7 +1881,7 @@ the transformation is such that \begin{codeblock} -do_widen(do_narrow(c,0)) == c +do_widen(do_narrow(c, 0)) == c \end{codeblock} For any named @@ -1890,11 +1891,9 @@ facet \tcode{ctc} however, and \tcode{ctype_base::mask} value \tcode{M}, - \begin{codeblock} -(is(M,c) || !ctc.is(M, do_narrow(c,dfault)) ) +(is(M, c) || !ctc.is(M, do_narrow(c, dfault)) ) \end{codeblock} - is \tcode{true} (unless @@ -1911,7 +1910,7 @@ \range{low}{high}, placing the result (or \tcode{dfault} if no simple transformation is readily available) in -\tcode{dest[p-low]}. +\tcode{dest[p - low]}. \pnum \returns @@ -1926,14 +1925,14 @@ \begin{codeblock} namespace std { template - class ctype_byname : public ctype { - public: - using mask = typename ctype::mask; - explicit ctype_byname(const char*, size_t refs = 0); - explicit ctype_byname(const string&, size_t refs = 0); - protected: - ~ctype_byname(); - }; + class ctype_byname : public ctype { + public: + using mask = typename ctype::mask; + explicit ctype_byname(const char*, size_t refs = 0); + explicit ctype_byname(const string&, size_t refs = 0); + protected: + ~ctype_byname(); + }; } \end{codeblock} @@ -1942,54 +1941,54 @@ \indexlibrary{\idxcode{ctype}}% \begin{codeblock} namespace std { - template <> class ctype - : public locale::facet, public ctype_base { - public: - using char_type = char; - - explicit ctype(const mask* tab = 0, bool del = false, - size_t refs = 0); - - bool is(mask m, char c) const; - const char* is(const char* low, const char* high, mask* vec) const; - const char* scan_is (mask m, - const char* low, const char* high) const; - const char* scan_not(mask m, - const char* low, const char* high) const; - - char toupper(char c) const; - const char* toupper(char* low, const char* high) const; - char tolower(char c) const; - const char* tolower(char* low, const char* high) const; - - char widen(char c) const; - const char* widen(const char* low, const char* high, char* to) const; - char narrow(char c, char dfault) const; - const char* narrow(const char* low, const char* high, char dfault, - char* to) const; - - static locale::id id; - static const size_t table_size = @\impdef@; - - const mask* table() const noexcept; - static const mask* classic_table() noexcept; - - protected: - ~ctype(); - virtual char do_toupper(char c) const; - virtual const char* do_toupper(char* low, const char* high) const; - virtual char do_tolower(char c) const; - virtual const char* do_tolower(char* low, const char* high) const; - - virtual char do_widen(char c) const; - virtual const char* do_widen(const char* low, - const char* high, - char* to) const; - virtual char do_narrow(char c, char dfault) const; - virtual const char* do_narrow(const char* low, - const char* high, - char dfault, char* to) const; - }; + template <> + class ctype : public locale::facet, public ctype_base { + public: + using char_type = char; + + explicit ctype(const mask* tab = 0, bool del = false, + size_t refs = 0); + + bool is(mask m, char c) const; + const char* is(const char* low, const char* high, mask* vec) const; + const char* scan_is (mask m, + const char* low, const char* high) const; + const char* scan_not(mask m, + const char* low, const char* high) const; + + char toupper(char c) const; + const char* toupper(char* low, const char* high) const; + char tolower(char c) const; + const char* tolower(char* low, const char* high) const; + + char widen(char c) const; + const char* widen(const char* low, const char* high, char* to) const; + char narrow(char c, char dfault) const; + const char* narrow(const char* low, const char* high, char dfault, + char* to) const; + + static locale::id id; + static const size_t table_size = @\impdef@; + + const mask* table() const noexcept; + static const mask* classic_table() noexcept; + + protected: + ~ctype(); + virtual char do_toupper(char c) const; + virtual const char* do_toupper(char* low, const char* high) const; + virtual char do_tolower(char c) const; + virtual const char* do_tolower(char* low, const char* high) const; + + virtual char do_widen(char c) const; + virtual const char* do_widen(const char* low, + const char* high, + char* to) const; + virtual char do_narrow(char c, char dfault) const; + virtual const char* do_narrow(const char* low, + const char* high, + char dfault, char* to) const; + }; } \end{codeblock} @@ -2073,9 +2072,9 @@ \range{low}{high}, assigns into -\tcode{vec[p-low]} +\tcode{vec[p - low]} the value -\tcode{table()[\,(un\-signed char)*p]}. +\tcode{table()[(unsigned char)*p]}. \pnum \returns @@ -2256,52 +2255,60 @@ }; template - class codecvt : public locale::facet, public codecvt_base { - public: - using intern_type = internT; - using extern_type = externT; - using state_type = stateT; - - explicit codecvt(size_t refs = 0); - - result out(stateT& state, - const internT* from, const internT* from_end, const internT*& from_next, - externT* to, externT* to_end, externT*& to_next) const; - result unshift(stateT& state, - externT* to, externT* to_end, externT*& to_next) const; - result in(stateT& state, - const externT* from, const externT* from_end, const externT*& from_next, - internT* to, internT* to_end, internT*& to_next) const; - int encoding() const noexcept; - bool always_noconv() const noexcept; - int length(stateT&, const externT* from, const externT* end, - size_t max) const; - int max_length() const noexcept; - - static locale::id id; - - protected: - ~codecvt(); - virtual result do_out(stateT& state, - const internT* from, const internT* from_end, const internT*& from_next, - externT* to, externT* to_end, externT*& to_next) const; - virtual result do_in(stateT& state, - const externT* from, const externT* from_end, const externT*& from_next, - internT* to, internT* to_end, internT*& to_next) const; - virtual result do_unshift(stateT& state, - externT* to, externT* to_end, externT*& to_next) const; - virtual int do_encoding() const noexcept; - virtual bool do_always_noconv() const noexcept; - virtual int do_length(stateT&, const externT* from, - const externT* end, size_t max) const; - virtual int do_max_length() const noexcept; - }; + class codecvt : public locale::facet, public codecvt_base { + public: + using intern_type = internT; + using extern_type = externT; + using state_type = stateT; + + explicit codecvt(size_t refs = 0); + + result out( + stateT& state, + const internT* from, const internT* from_end, const internT*& from_next, + externT* to, externT* to_end, externT*& to_next) const; + + result unshift( + stateT& state, + externT* to, externT* to_end, externT*& to_next) const; + + result in( + stateT& state, + const externT* from, const externT* from_end, const externT*& from_next, + internT* to, internT* to_end, internT*& to_next) const; + + int encoding() const noexcept; + bool always_noconv() const noexcept; + int length(stateT&, const externT* from, const externT* end, size_t max) const; + int max_length() const noexcept; + + static locale::id id; + + protected: + ~codecvt(); + virtual result do_out( + stateT& state, + const internT* from, const internT* from_end, const internT*& from_next, + externT* to, externT* to_end, externT*& to_next) const; + virtual result do_in( + stateT& state, + const externT* from, const externT* from_end, const externT*& from_next, + internT* to, internT* to_end, internT*& to_next) const; + virtual result do_unshift( + stateT& state, + externT* to, externT* to_end, externT*& to_next) const; + + virtual int do_encoding() const noexcept; + virtual bool do_always_noconv() const noexcept; + virtual int do_length(stateT&, const externT* from, const externT* end, size_t max) const; + virtual int do_max_length() const noexcept; + }; } \end{codeblock} \pnum The class -\tcode{codecvt} +\tcode{codecvt} is for use when converting from one character encoding to another, such as from wide characters to multibyte characters or between wide character encodings such as @@ -2318,11 +2325,11 @@ \tcode{codecvt} implements a degenerate conversion; it does not convert at all. -The specialization \tcode{codecvt} +The specialization \tcode{codecvt} converts between the UTF-16 and UTF-8 encoding forms, and the specialization \tcode{codecvt} \tcode{} converts between the UTF-32 and UTF-8 encoding forms. -\tcode{codecvt} +\tcode{codecvt} converts between the native character sets for narrow and wide characters. Specializations on \tcode{mbstate_t} @@ -2343,9 +2350,10 @@ \indexlibrarymember{codecvt}{out}% \begin{itemdecl} -result out(stateT& state, - const internT* from, const internT* from_end, const internT*& from_next, - externT* to, externT* to_end, externT*& to_next) const; +result out( + stateT& state, + const internT* from, const internT* from_end, const internT*& from_next, + externT* to, externT* to_end, externT*& to_next) const; \end{itemdecl} \begin{itemdescr} @@ -2356,8 +2364,7 @@ \indexlibrarymember{codecvt}{unshift}% \begin{itemdecl} -result unshift(stateT& state, - externT* to, externT* to_end, externT*& to_next) const; +result unshift(stateT& state, externT* to, externT* to_end, externT*& to_next) const; \end{itemdecl} \begin{itemdescr} @@ -2368,9 +2375,10 @@ \indexlibrarymember{codecvt}{in}% \begin{itemdecl} -result in(stateT& state, - const externT* from, const externT* from_end, const externT*& from_next, - internT* to, internT* to_end, internT*& to_next) const; +result in( + stateT& state, + const externT* from, const externT* from_end, const externT*& from_next, + internT* to, internT* to_end, internT*& to_next) const; \end{itemdecl} \begin{itemdescr} @@ -2403,8 +2411,7 @@ \indexlibrarymember{codecvt}{length}% \begin{itemdecl} -int length(stateT& state, const externT* from, const externT* from_end, - size_t max) const; +int length(stateT& state, const externT* from, const externT* from_end, size_t max) const; \end{itemdecl} \begin{itemdescr} @@ -2429,19 +2436,21 @@ \indexlibrarymember{codecvt}{do_out}% \indexlibrarymember{codecvt}{do_in}% \begin{itemdecl} -result do_out(stateT& state, - const internT* from, const internT* from_end, const internT*& from_next, - externT* to, externT* to_end, externT*& to_next) const; +result do_out( + stateT& state, + const internT* from, const internT* from_end, const internT*& from_next, + externT* to, externT* to_end, externT*& to_next) const; -result do_in(stateT& state, - const externT* from, const externT* from_end, const externT*& from_next, - internT* to, internT* to_end, internT*& to_next) const; +result do_in( + stateT& state, + const externT* from, const externT* from_end, const externT*& from_next, + internT* to, internT* to_end, internT*& to_next) const; \end{itemdecl} \begin{itemdescr} \pnum \requires -\tcode{(from<=from_end \&\& to<=to_end)} +\tcode{(from <= from_end \&\& to <= to_end)} well-defined and \tcode{true}; \tcode{state} initialized, if at the beginning of a sequence, or else equal to @@ -2453,10 +2462,10 @@ \range{from}{from_end}, placing the results in sequential positions starting at destination \tcode{to}. Converts no more than -\tcode{(from_end-from)} +\tcode{(from_end - from)} source elements, and stores no more than -\tcode{(to_end-to)} +\tcode{(to_end - to)} destination elements. Stops if it encounters a character it cannot convert. @@ -2469,7 +2478,7 @@ \tcode{externT} are the same type and the converted sequence is identical to the input sequence -\range{from}{from_next}. +\range{from}{from\textunderscore\nobreak next}. \tcode{to_next} is set equal to \tcode{to}, the value of \tcode{state} is unchanged, and there are no changes to the values in \range{to}{to_end}. @@ -2546,7 +2555,7 @@ A return value of \tcode{partial}, if -\tcode{(from_next==from_end)}, +\tcode{(from_next == from_end)}, indicates that either the destination sequence has not absorbed all the available destination elements, or that additional source elements are needed before another destination element can be produced. @@ -2554,8 +2563,7 @@ \indexlibrarymember{codecvt}{do_unshift}% \begin{itemdecl} -result do_unshift(stateT& state, - externT* to, externT* to_end, externT*& to_next) const; +result do_unshift(stateT& state, externT* to, externT* to_end, externT*& to_next) const; \end{itemdecl} \begin{itemdescr} @@ -2574,7 +2582,7 @@ is given by \tcode{state}.\footnote{Typically these will be characters to return the state to \tcode{stateT()}.} Stores no more than -\tcode{(to_end-to)} +\tcode{(to_end - to)} destination elements, and leaves the \tcode{to_next} pointer pointing one beyond the last element successfully stored. @@ -2588,7 +2596,7 @@ \lhdr{Value} & \rhdr{Meaning} \\ \capsep \tcode{ok} & completed the sequence \\ \tcode{partial} & -space for more than \tcode{to_end-to} destination elements was needed +space for more than \tcode{to_end - to} destination elements was needed to terminate a sequence given the value of \tcode{state}\\ \tcode{error} & an unspecified error has occurred \\ \tcode{noconv} & no termination is needed for this \tcode{state_type} \\ @@ -2635,14 +2643,13 @@ \indexlibrarymember{codecvt}{do_length}% \begin{itemdecl} -int do_length(stateT& state, const externT* from, const externT* from_end, - size_t max) const; +int do_length(stateT& state, const externT* from, const externT* from_end, size_t max) const; \end{itemdecl} \begin{itemdescr} \pnum \requires -\tcode{(from<=from_end)} +\tcode{(from <= from_end)} well-defined and \tcode{true}; \tcode{state} initialized, if at the beginning of a sequence, or else equal to @@ -2702,13 +2709,13 @@ \begin{codeblock} namespace std { template - class codecvt_byname : public codecvt { - public: - explicit codecvt_byname(const char*, size_t refs = 0); - explicit codecvt_byname(const string&, size_t refs = 0); - protected: - ~codecvt_byname(); - }; + class codecvt_byname : public codecvt { + public: + explicit codecvt_byname(const char*, size_t refs = 0); + explicit codecvt_byname(const string&, size_t refs = 0); + protected: + ~codecvt_byname(); + }; } \end{codeblock} @@ -2743,7 +2750,7 @@ \tcode{num_put}, \tcode{num_put}, and -\tcode{num_put}. +\tcode{num_put}. These specializations refer to the \tcode{ios_base\&} argument for formatting specifications~(\ref{locale.categories}), @@ -2767,63 +2774,63 @@ \begin{codeblock} namespace std { template > - class num_get : public locale::facet { - public: - using char_type = charT; - using iter_type = InputIterator; - - explicit num_get(size_t refs = 0); - - iter_type get(iter_type in, iter_type end, ios_base&, - ios_base::iostate& err, bool& v) const; - iter_type get(iter_type in, iter_type end, ios_base&, - ios_base::iostate& err, long& v) const; - iter_type get(iter_type in, iter_type end, ios_base&, - ios_base::iostate& err, long long& v) const; - iter_type get(iter_type in, iter_type end, ios_base&, - ios_base::iostate& err, unsigned short& v) const; - iter_type get(iter_type in, iter_type end, ios_base&, - ios_base::iostate& err, unsigned int& v) const; - iter_type get(iter_type in, iter_type end, ios_base&, - ios_base::iostate& err, unsigned long& v) const; - iter_type get(iter_type in, iter_type end, ios_base&, - ios_base::iostate& err, unsigned long long& v) const; - iter_type get(iter_type in, iter_type end, ios_base&, - ios_base::iostate& err, float& v) const; - iter_type get(iter_type in, iter_type end, ios_base&, - ios_base::iostate& err, double& v) const; - iter_type get(iter_type in, iter_type end, ios_base&, - ios_base::iostate& err, long double& v) const; - iter_type get(iter_type in, iter_type end, ios_base&, - ios_base::iostate& err, void*& v) const; - - static locale::id id; - - protected: - ~num_get(); - virtual iter_type do_get(iter_type, iter_type, ios_base&, - ios_base::iostate& err, bool& v) const; - virtual iter_type do_get(iter_type, iter_type, ios_base&, - ios_base::iostate& err, long& v) const; - virtual iter_type do_get(iter_type, iter_type, ios_base&, - ios_base::iostate& err, long long& v) const; - virtual iter_type do_get(iter_type, iter_type, ios_base&, - ios_base::iostate& err, unsigned short& v) const; - virtual iter_type do_get(iter_type, iter_type, ios_base&, - ios_base::iostate& err, unsigned int& v) const; - virtual iter_type do_get(iter_type, iter_type, ios_base&, - ios_base::iostate& err, unsigned long& v) const; - virtual iter_type do_get(iter_type, iter_type, ios_base&, - ios_base::iostate& err, unsigned long long& v) const; - virtual iter_type do_get(iter_type, iter_type, ios_base&, - ios_base::iostate& err, float& v) const; - virtual iter_type do_get(iter_type, iter_type, ios_base&, - ios_base::iostate& err, double& v) const; - virtual iter_type do_get(iter_type, iter_type, ios_base&, - ios_base::iostate& err, long double& v) const; - virtual iter_type do_get(iter_type, iter_type, ios_base&, - ios_base::iostate& err, void*& v) const; - }; + class num_get : public locale::facet { + public: + using char_type = charT; + using iter_type = InputIterator; + + explicit num_get(size_t refs = 0); + + iter_type get(iter_type in, iter_type end, ios_base&, + ios_base::iostate& err, bool& v) const; + iter_type get(iter_type in, iter_type end, ios_base&, + ios_base::iostate& err, long& v) const; + iter_type get(iter_type in, iter_type end, ios_base&, + ios_base::iostate& err, long long& v) const; + iter_type get(iter_type in, iter_type end, ios_base&, + ios_base::iostate& err, unsigned short& v) const; + iter_type get(iter_type in, iter_type end, ios_base&, + ios_base::iostate& err, unsigned int& v) const; + iter_type get(iter_type in, iter_type end, ios_base&, + ios_base::iostate& err, unsigned long& v) const; + iter_type get(iter_type in, iter_type end, ios_base&, + ios_base::iostate& err, unsigned long long& v) const; + iter_type get(iter_type in, iter_type end, ios_base&, + ios_base::iostate& err, float& v) const; + iter_type get(iter_type in, iter_type end, ios_base&, + ios_base::iostate& err, double& v) const; + iter_type get(iter_type in, iter_type end, ios_base&, + ios_base::iostate& err, long double& v) const; + iter_type get(iter_type in, iter_type end, ios_base&, + ios_base::iostate& err, void*& v) const; + + static locale::id id; + + protected: + ~num_get(); + virtual iter_type do_get(iter_type, iter_type, ios_base&, + ios_base::iostate& err, bool& v) const; + virtual iter_type do_get(iter_type, iter_type, ios_base&, + ios_base::iostate& err, long& v) const; + virtual iter_type do_get(iter_type, iter_type, ios_base&, + ios_base::iostate& err, long long& v) const; + virtual iter_type do_get(iter_type, iter_type, ios_base&, + ios_base::iostate& err, unsigned short& v) const; + virtual iter_type do_get(iter_type, iter_type, ios_base&, + ios_base::iostate& err, unsigned int& v) const; + virtual iter_type do_get(iter_type, iter_type, ios_base&, + ios_base::iostate& err, unsigned long& v) const; + virtual iter_type do_get(iter_type, iter_type, ios_base&, + ios_base::iostate& err, unsigned long long& v) const; + virtual iter_type do_get(iter_type, iter_type, ios_base&, + ios_base::iostate& err, float& v) const; + virtual iter_type do_get(iter_type, iter_type, ios_base&, + ios_base::iostate& err, double& v) const; + virtual iter_type do_get(iter_type, iter_type, ios_base&, + ios_base::iostate& err, long double& v) const; + virtual iter_type do_get(iter_type, iter_type, ios_base&, + ios_base::iostate& err, void*& v) const; + }; } \end{codeblock} @@ -2981,7 +2988,7 @@ \stage{2} If -\tcode{in==end} +\tcode{in == end} then stage 2 terminates. Otherwise a \tcode{charT} @@ -3078,9 +3085,9 @@ \pnum In any case, if stage 2 processing was terminated by the test for -\tcode{in==end} +\tcode{in == end} then -\tcode{err |=ios_base::eofbit} +\tcode{err |= ios_base::eofbit} is performed. \end{itemdescr} @@ -3181,48 +3188,35 @@ \begin{codeblock} namespace std { template > - class num_put : public locale::facet { - public: - using char_type = charT; - using iter_type = OutputIterator; - - explicit num_put(size_t refs = 0); - - iter_type put(iter_type s, ios_base& f, char_type fill, bool v) const; - iter_type put(iter_type s, ios_base& f, char_type fill, long v) const; - iter_type put(iter_type s, ios_base& f, char_type fill, long long v) const; - iter_type put(iter_type s, ios_base& f, char_type fill, - unsigned long v) const; - iter_type put(iter_type s, ios_base& f, char_type fill, - unsigned long long v) const; - iter_type put(iter_type s, ios_base& f, char_type fill, - double v) const; - iter_type put(iter_type s, ios_base& f, char_type fill, - long double v) const; - iter_type put(iter_type s, ios_base& f, char_type fill, - const void* v) const; - - static locale::id id; - - protected: - ~num_put(); - virtual iter_type do_put(iter_type, ios_base&, char_type fill, - bool v) const; - virtual iter_type do_put(iter_type, ios_base&, char_type fill, - long v) const; - virtual iter_type do_put(iter_type, ios_base&, char_type fill, - long long v) const; - virtual iter_type do_put(iter_type, ios_base&, char_type fill, - unsigned long) const; - virtual iter_type do_put(iter_type, ios_base&, char_type fill, - unsigned long long) const; - virtual iter_type do_put(iter_type, ios_base&, char_type fill, - double v) const; - virtual iter_type do_put(iter_type, ios_base&, char_type fill, - long double v) const; - virtual iter_type do_put(iter_type, ios_base&, char_type fill, - const void* v) const; - }; + class num_put : public locale::facet { + public: + using char_type = charT; + using iter_type = OutputIterator; + + explicit num_put(size_t refs = 0); + + iter_type put(iter_type s, ios_base& f, char_type fill, bool v) const; + iter_type put(iter_type s, ios_base& f, char_type fill, long v) const; + iter_type put(iter_type s, ios_base& f, char_type fill, long long v) const; + iter_type put(iter_type s, ios_base& f, char_type fill, unsigned long v) const; + iter_type put(iter_type s, ios_base& f, char_type fill, unsigned long long v) const; + iter_type put(iter_type s, ios_base& f, char_type fill, double v) const; + iter_type put(iter_type s, ios_base& f, char_type fill, long double v) const; + iter_type put(iter_type s, ios_base& f, char_type fill, const void* v) const; + + static locale::id id; + + protected: + ~num_put(); + virtual iter_type do_put(iter_type, ios_base&, char_type fill, bool v) const; + virtual iter_type do_put(iter_type, ios_base&, char_type fill, long v) const; + virtual iter_type do_put(iter_type, ios_base&, char_type fill, long long v) const; + virtual iter_type do_put(iter_type, ios_base&, char_type fill, unsigned long) const; + virtual iter_type do_put(iter_type, ios_base&, char_type fill, unsigned long long) const; + virtual iter_type do_put(iter_type, ios_base&, char_type fill, double v) const; + virtual iter_type do_put(iter_type, ios_base&, char_type fill, long double v) const; + virtual iter_type do_put(iter_type, ios_base&, char_type fill, const void* v) const; + }; } \end{codeblock} @@ -3235,22 +3229,14 @@ \indexlibrarymember{num_put}{put}% \begin{itemdecl} -iter_type put(iter_type out, ios_base& str, char_type fill, - bool val) const; -iter_type put(iter_type out, ios_base& str, char_type fill, - long val) const; -iter_type put(iter_type out, ios_base& str, char_type fill, - long long val) const; -iter_type put(iter_type out, ios_base& str, char_type fill, - unsigned long val) const; -iter_type put(iter_type out, ios_base& str, char_type fill, - unsigned long long val) const; -iter_type put(iter_type out, ios_base& str, char_type fill, - double val) const; -iter_type put(iter_type out, ios_base& str, char_type fill, - long double val) const; -iter_type put(iter_type out, ios_base& str, char_type fill, - const void* val) const; +iter_type put(iter_type out, ios_base& str, char_type fill, bool val) const; +iter_type put(iter_type out, ios_base& str, char_type fill, long val) const; +iter_type put(iter_type out, ios_base& str, char_type fill, long long val) const; +iter_type put(iter_type out, ios_base& str, char_type fill, unsigned long val) const; +iter_type put(iter_type out, ios_base& str, char_type fill, unsigned long long val) const; +iter_type put(iter_type out, ios_base& str, char_type fill, double val) const; +iter_type put(iter_type out, ios_base& str, char_type fill, long double val) const; +iter_type put(iter_type out, ios_base& str, char_type fill, const void* val) const; \end{itemdecl} \begin{itemdescr} @@ -3263,20 +3249,13 @@ \indexlibrarymember{num_put}{do_put}% \begin{itemdecl} -iter_type do_put(iter_type out, ios_base& str, char_type fill, - long val) const; -iter_type do_put(iter_type out, ios_base& str, char_type fill, - long long val) const; -iter_type do_put(iter_type out, ios_base& str, char_type fill, - unsigned long val) const; -iter_type do_put(iter_type out, ios_base& str, char_type fill, - unsigned long long val) const; -iter_type do_put(iter_type out, ios_base& str, char_type fill, - double val) const; -iter_type do_put(iter_type out, ios_base& str, char_type fill, - long double val) const; -iter_type do_put(iter_type out, ios_base& str, char_type fill, - const void* val) const; +iter_type do_put(iter_type out, ios_base& str, char_type fill, long val) const; +iter_type do_put(iter_type out, ios_base& str, char_type fill, long long val) const; +iter_type do_put(iter_type out, ios_base& str, char_type fill, unsigned long val) const; +iter_type do_put(iter_type out, ios_base& str, char_type fill, unsigned long long val) const; +iter_type do_put(iter_type out, ios_base& str, char_type fill, double val) const; +iter_type do_put(iter_type out, ios_base& str, char_type fill, long double val) const; +iter_type do_put(iter_type out, ios_base& str, char_type fill, const void* val) const; \end{itemdecl} \begin{itemdescr} @@ -3503,8 +3482,7 @@ \indexlibrarymember{do_put}{num_put}% \begin{itemdecl} -iter_type do_put(iter_type out, ios_base& str, char_type fill, - bool val) const; +iter_type do_put(iter_type out, ios_base& str, char_type fill, bool val) const; \end{itemdecl} \begin{itemdescr} @@ -3520,7 +3498,7 @@ \begin{codeblock} string_type s = val ? use_facet>(loc).truename() - : use_facet>(loc).falsename(); + : use_facet>(loc).falsename(); \end{codeblock} and then inserts each character \tcode{c} @@ -3542,29 +3520,29 @@ \begin{codeblock} namespace std { template - class numpunct : public locale::facet { - public: - using char_type = charT; - using string_type = basic_string; - - explicit numpunct(size_t refs = 0); - - char_type decimal_point() const; - char_type thousands_sep() const; - string grouping() const; - string_type truename() const; - string_type falsename() const; - - static locale::id id; - - protected: - ~numpunct(); // virtual - virtual char_type do_decimal_point() const; - virtual char_type do_thousands_sep() const; - virtual string do_grouping() const; - virtual string_type do_truename() const; // for \tcode{bool} - virtual string_type do_falsename() const; // for \tcode{bool} - }; + class numpunct : public locale::facet { + public: + using char_type = charT; + using string_type = basic_string; + + explicit numpunct(size_t refs = 0); + + char_type decimal_point() const; + char_type thousands_sep() const; + string grouping() const; + string_type truename() const; + string_type falsename() const; + + static locale::id id; + + protected: + ~numpunct(); // virtual + virtual char_type do_decimal_point() const; + virtual char_type do_thousands_sep() const; + virtual string do_grouping() const; + virtual string_type do_truename() const; // for \tcode{bool} + virtual string_type do_falsename() const; // for \tcode{bool} + }; } \end{codeblock} @@ -3720,9 +3698,9 @@ If \tcode{vec.size() <= i}, the number is the same as group -\tcode{(i-1)}; +\tcode{(i - 1)}; if -\tcode{(i<0 || vec[i]<=0 || vec[i]==CHAR_MAX)}, +\tcode{(i < 0 || vec[i] <= 0 || vec[i] == CHAR_MAX)}, the size of the digit group is unlimited. \pnum @@ -3779,27 +3757,27 @@ \begin{codeblock} namespace std { template - class collate : public locale::facet { - public: - using char_type = charT; - using string_type = basic_string; - - explicit collate(size_t refs = 0); - - int compare(const charT* low1, const charT* high1, - const charT* low2, const charT* high2) const; - string_type transform(const charT* low, const charT* high) const; - long hash(const charT* low, const charT* high) const; - - static locale::id id; - - protected: - ~collate(); - virtual int do_compare(const charT* low1, const charT* high1, - const charT* low2, const charT* high2) const; - virtual string_type do_transform(const charT* low, const charT* high) const; - virtual long do_hash (const charT* low, const charT* high) const; - }; + class collate : public locale::facet { + public: + using char_type = charT; + using string_type = basic_string; + + explicit collate(size_t refs = 0); + + int compare(const charT* low1, const charT* high1, + const charT* low2, const charT* high2) const; + string_type transform(const charT* low, const charT* high) const; + long hash(const charT* low, const charT* high) const; + + static locale::id id; + + protected: + ~collate(); + virtual int do_compare(const charT* low1, const charT* high1, + const charT* low2, const charT* high2) const; + virtual string_type do_transform(const charT* low, const charT* high) const; + virtual long do_hash (const charT* low, const charT* high) const; + }; } \end{codeblock} @@ -3927,15 +3905,15 @@ \begin{codeblock} namespace std { template - class collate_byname : public collate { - public: - using string_type = basic_string; - - explicit collate_byname(const char*, size_t refs = 0); - explicit collate_byname(const string&, size_t refs = 0); - protected: - ~collate_byname(); - }; + class collate_byname : public collate { + public: + using string_type = basic_string; + + explicit collate_byname(const char*, size_t refs = 0); + explicit collate_byname(const string&, size_t refs = 0); + protected: + ~collate_byname(); + }; } \end{codeblock} @@ -3943,9 +3921,9 @@ \pnum Templates -\tcode{time_get} +\tcode{time_get} and -\tcode{time_put} +\tcode{time_put} provide date and time formatting and parsing. All specifications of member functions for \tcode{time_put} @@ -3959,7 +3937,7 @@ \tcode{ios_base::iostate\&}, and \tcode{fill} -arguments as described in~(\ref{locale.categories}), and the +arguments as described in~\ref{locale.categories}, and the \tcode{ctype<>} facet, to determine formatting details. @@ -3974,48 +3952,48 @@ }; template > - class time_get : public locale::facet, public time_base { - public: - using char_type = charT; - using iter_type = InputIterator; - - explicit time_get(size_t refs = 0); - - dateorder date_order() const { return do_date_order(); } - iter_type get_time(iter_type s, iter_type end, ios_base& f, - ios_base::iostate& err, tm* t) const; - iter_type get_date(iter_type s, iter_type end, ios_base& f, - ios_base::iostate& err, tm* t) const; - iter_type get_weekday(iter_type s, iter_type end, ios_base& f, - ios_base::iostate& err, tm* t) const; - iter_type get_monthname(iter_type s, iter_type end, ios_base& f, - ios_base::iostate& err, tm* t) const; - iter_type get_year(iter_type s, iter_type end, ios_base& f, - ios_base::iostate& err, tm* t) const; - iter_type get(iter_type s, iter_type end, ios_base& f, - ios_base::iostate& err, tm* t, char format, char modifier = 0) const; - iter_type get(iter_type s, iter_type end, ios_base& f, - ios_base::iostate& err, tm* t, const char_type* fmt, - const char_type* fmtend) const; - - static locale::id id; - - protected: - ~time_get(); - virtual dateorder do_date_order() const; - virtual iter_type do_get_time(iter_type s, iter_type end, ios_base&, - ios_base::iostate& err, tm* t) const; - virtual iter_type do_get_date(iter_type s, iter_type end, ios_base&, - ios_base::iostate& err, tm* t) const; - virtual iter_type do_get_weekday(iter_type s, iter_type end, ios_base&, - ios_base::iostate& err, tm* t) const; - virtual iter_type do_get_monthname(iter_type s, iter_type end, ios_base&, + class time_get : public locale::facet, public time_base { + public: + using char_type = charT; + using iter_type = InputIterator; + + explicit time_get(size_t refs = 0); + + dateorder date_order() const { return do_date_order(); } + iter_type get_time(iter_type s, iter_type end, ios_base& f, + ios_base::iostate& err, tm* t) const; + iter_type get_date(iter_type s, iter_type end, ios_base& f, + ios_base::iostate& err, tm* t) const; + iter_type get_weekday(iter_type s, iter_type end, ios_base& f, + ios_base::iostate& err, tm* t) const; + iter_type get_monthname(iter_type s, iter_type end, ios_base& f, + ios_base::iostate& err, tm* t) const; + iter_type get_year(iter_type s, iter_type end, ios_base& f, + ios_base::iostate& err, tm* t) const; + iter_type get(iter_type s, iter_type end, ios_base& f, + ios_base::iostate& err, tm* t, char format, char modifier = 0) const; + iter_type get(iter_type s, iter_type end, ios_base& f, + ios_base::iostate& err, tm* t, const char_type* fmt, + const char_type* fmtend) const; + + static locale::id id; + + protected: + ~time_get(); + virtual dateorder do_date_order() const; + virtual iter_type do_get_time(iter_type s, iter_type end, ios_base&, + ios_base::iostate& err, tm* t) const; + virtual iter_type do_get_date(iter_type s, iter_type end, ios_base&, + ios_base::iostate& err, tm* t) const; + virtual iter_type do_get_weekday(iter_type s, iter_type end, ios_base&, ios_base::iostate& err, tm* t) const; - virtual iter_type do_get_year(iter_type s, iter_type end, ios_base&, - ios_base::iostate& err, tm* t) const; - virtual iter_type do_get(iter_type s, iter_type end, ios_base& f, - ios_base::iostate& err, tm* t, char format, char modifier) const; - }; + virtual iter_type do_get_monthname(iter_type s, iter_type end, ios_base&, + ios_base::iostate& err, tm* t) const; + virtual iter_type do_get_year(iter_type s, iter_type end, ios_base&, + ios_base::iostate& err, tm* t) const; + virtual iter_type do_get(iter_type s, iter_type end, ios_base& f, + ios_base::iostate& err, tm* t, char format, char modifier) const; + }; } \end{codeblock} @@ -4025,7 +4003,7 @@ parse a character sequence, extracting components of a time or date into a \tcode{struct tm} -record. +object. Each \tcode{get} member parses a format as produced by a corresponding format specifier to @@ -4116,8 +4094,8 @@ \indexlibrarymember{get}{time_get}% \begin{itemdecl} -iter_type get(iter_type s, iter_type end, ios_base& f, - ios_base::iostate& err, tm* t, char format, char modifier = 0) const; +iter_type get(iter_type s, iter_type end, ios_base& f, ios_base::iostate& err, + tm* t, char format, char modifier = 0) const; \end{itemdecl} \begin{itemdescr} @@ -4127,8 +4105,8 @@ \indexlibrarymember{get}{time_get}% \begin{itemdecl} -iter_type get(iter_type s, iter_type end, ios_base& f, - ios_base::iostate& err, tm* t, const char_type* fmt, const char_type* fmtend) const; +iter_type get(iter_type s, iter_type end, ios_base& f, ios_base::iostate& err, + tm* t, const char_type* fmt, const char_type* fmtend) const; \end{itemdecl} \begin{itemdescr} @@ -4400,26 +4378,26 @@ \begin{codeblock} namespace std { template > - class time_put : public locale::facet { - public: - using char_type = charT; - using iter_type = OutputIterator; - - explicit time_put(size_t refs = 0); - - // the following is implemented in terms of other member functions. - iter_type put(iter_type s, ios_base& f, char_type fill, const tm* tmb, - const charT* pattern, const charT* pat_end) const; - iter_type put(iter_type s, ios_base& f, char_type fill, - const tm* tmb, char format, char modifier = 0) const; - - static locale::id id; - - protected: - ~time_put(); - virtual iter_type do_put(iter_type s, ios_base&, char_type, const tm* t, - char format, char modifier) const; - }; + class time_put : public locale::facet { + public: + using char_type = charT; + using iter_type = OutputIterator; + + explicit time_put(size_t refs = 0); + + // the following is implemented in terms of other member functions. + iter_type put(iter_type s, ios_base& f, char_type fill, const tm* tmb, + const charT* pattern, const charT* pat_end) const; + iter_type put(iter_type s, ios_base& f, char_type fill, + const tm* tmb, char format, char modifier = 0) const; + + static locale::id id; + + protected: + ~time_put(); + virtual iter_type do_put(iter_type s, ios_base&, char_type, const tm* t, + char format, char modifier) const; + }; } \end{codeblock} @@ -4453,7 +4431,7 @@ to a \tcode{char} value as if by -\tcode{ct.narrow(c,0)}, +\tcode{ct.narrow(c, 0)}, where \tcode{ct} is a reference to @@ -4564,10 +4542,10 @@ and~\ref{tab:localization.required.specializations}~(\ref{locale.category}). Their members use their \tcode{ios_base\&}, -\tcode{ios_base\,::\,io\-state\&}, +\tcode{ios_base::io\-state\&}, and \tcode{fill} -arguments as described in~(\ref{locale.categories}), and the +arguments as described in~\ref{locale.categories}, and the \tcode{moneypunct<>} and \tcode{ctype<>} @@ -4578,32 +4556,31 @@ \indexlibrary{\idxcode{money_get}}% \begin{codeblock} namespace std { - template > - class money_get : public locale::facet { - public: - using char_type = charT; - using iter_type = InputIterator; - using string_type = basic_string; - - explicit money_get(size_t refs = 0); - - iter_type get(iter_type s, iter_type end, bool intl, - ios_base& f, ios_base::iostate& err, - long double& units) const; - iter_type get(iter_type s, iter_type end, bool intl, - ios_base& f, ios_base::iostate& err, - string_type& digits) const; - - static locale::id id; - - protected: - ~money_get(); - virtual iter_type do_get(iter_type, iter_type, bool, ios_base&, - ios_base::iostate& err, long double& units) const; - virtual iter_type do_get(iter_type, iter_type, bool, ios_base&, - ios_base::iostate& err, string_type& digits) const; - }; + template > + class money_get : public locale::facet { + public: + using char_type = charT; + using iter_type = InputIterator; + using string_type = basic_string; + + explicit money_get(size_t refs = 0); + + iter_type get(iter_type s, iter_type end, bool intl, + ios_base& f, ios_base::iostate& err, + long double& units) const; + iter_type get(iter_type s, iter_type end, bool intl, + ios_base& f, ios_base::iostate& err, + string_type& digits) const; + + static locale::id id; + + protected: + ~money_get(); + virtual iter_type do_get(iter_type, iter_type, bool, ios_base&, + ios_base::iostate& err, long double& units) const; + virtual iter_type do_get(iter_type, iter_type, bool, ios_base&, + ios_base::iostate& err, string_type& digits) const; + }; } \end{codeblock} @@ -4643,7 +4620,7 @@ \tcode{s} to parse and construct a monetary value according to the format specified by a -\tcode{moneypunct} +\tcode{moneypunct} facet reference \tcode{mp} and the character mapping specified by a @@ -4724,7 +4701,7 @@ or the string \tcode{neg} returned by -\tcode{mp.neg\-a\-tive_sign()} +\tcode{mp.negative_sign()} is recognized in the position indicated by \tcode{sign} in the format pattern, it is consumed and any remaining characters @@ -4808,30 +4785,29 @@ \indexlibrary{\idxcode{money_put}}% \begin{codeblock} namespace std { - template > - class money_put : public locale::facet { - public: - using char_type = charT; - using iter_type = OutputIterator; - using string_type = basic_string; - - explicit money_put(size_t refs = 0); - - iter_type put(iter_type s, bool intl, ios_base& f, - char_type fill, long double units) const; - iter_type put(iter_type s, bool intl, ios_base& f, - char_type fill, const string_type& digits) const; - - static locale::id id; - - protected: - ~money_put(); - virtual iter_type do_put(iter_type, bool, ios_base&, char_type fill, - long double units) const; - virtual iter_type do_put(iter_type, bool, ios_base&, char_type fill, - const string_type& digits) const; - }; + template > + class money_put : public locale::facet { + public: + using char_type = charT; + using iter_type = OutputIterator; + using string_type = basic_string; + + explicit money_put(size_t refs = 0); + + iter_type put(iter_type s, bool intl, ios_base& f, + char_type fill, long double units) const; + iter_type put(iter_type s, bool intl, ios_base& f, + char_type fill, const string_type& digits) const; + + static locale::id id; + + protected: + ~money_put(); + virtual iter_type do_put(iter_type, bool, ios_base&, char_type fill, + long double units) const; + virtual iter_type do_put(iter_type, bool, ios_base&, char_type fill, + const string_type& digits) const; + }; } \end{codeblock} @@ -4867,7 +4843,7 @@ Writes characters to \tcode{s} according to the format specified by a -\tcode{moneypunct} +\tcode{moneypunct} facet reference \tcode{mp} and the character mapping specified by a @@ -4966,38 +4942,38 @@ }; template - class moneypunct : public locale::facet, public money_base { - public: - using char_type = charT; - using string_type = basic_string; - - explicit moneypunct(size_t refs = 0); - - charT decimal_point() const; - charT thousands_sep() const; - string grouping() const; - string_type curr_symbol() const; - string_type positive_sign() const; - string_type negative_sign() const; - int frac_digits() const; - pattern pos_format() const; - pattern neg_format() const; - - static locale::id id; - static const bool intl = International; - - protected: - ~moneypunct(); - virtual charT do_decimal_point() const; - virtual charT do_thousands_sep() const; - virtual string do_grouping() const; - virtual string_type do_curr_symbol() const; - virtual string_type do_positive_sign() const; - virtual string_type do_negative_sign() const; - virtual int do_frac_digits() const; - virtual pattern do_pos_format() const; - virtual pattern do_neg_format() const; - }; + class moneypunct : public locale::facet, public money_base { + public: + using char_type = charT; + using string_type = basic_string; + + explicit moneypunct(size_t refs = 0); + + charT decimal_point() const; + charT thousands_sep() const; + string grouping() const; + string_type curr_symbol() const; + string_type positive_sign() const; + string_type negative_sign() const; + int frac_digits() const; + pattern pos_format() const; + pattern neg_format() const; + + static locale::id id; + static const bool intl = International; + + protected: + ~moneypunct(); + virtual charT do_decimal_point() const; + virtual charT do_thousands_sep() const; + virtual string do_grouping() const; + virtual string_type do_curr_symbol() const; + virtual string_type do_positive_sign() const; + virtual string_type do_negative_sign() const; + virtual int do_frac_digits() const; + virtual pattern do_pos_format() const; + virtual pattern do_neg_format() const; + }; } \end{codeblock} @@ -5131,7 +5107,7 @@ White space characters are those characters \tcode{c} for which -\tcode{ci.is(space,c)} +\tcode{ci.is(space, c)} returns \tcode{true}. The number of digits required after the decimal point (if any) @@ -5275,9 +5251,9 @@ The specializations required in Table~\ref{tab:localization.required.specializations}~(\ref{locale.category}), namely \tcode{moneypunct}, \tcode{moneypunct<\brk{}wchar_t>}, -\tcode{moneypunct}, +\tcode{moneypunct}, and -\tcode{moneypunct}, +\tcode{moneypunct}, return an object of type \tcode{pattern} initialized to @@ -5325,27 +5301,27 @@ }; template - class messages : public locale::facet, public messages_base { - public: - using char_type = charT; - using string_type = basic_string; - - explicit messages(size_t refs = 0); - - catalog open(const basic_string& fn, const locale&) const; - string_type get(catalog c, int set, int msgid, - const string_type& dfault) const; - void close(catalog c) const; - - static locale::id id; - - protected: - ~messages(); - virtual catalog do_open(const basic_string&, const locale&) const; - virtual string_type do_get(catalog, int set, int msgid, - const string_type& dfault) const; - virtual void do_close(catalog) const; - }; + class messages : public locale::facet, public messages_base { + public: + using char_type = charT; + using string_type = basic_string; + + explicit messages(size_t refs = 0); + + catalog open(const basic_string& fn, const locale&) const; + string_type get(catalog c, int set, int msgid, + const string_type& dfault) const; + void close(catalog c) const; + + static locale::id id; + + protected: + ~messages(); + virtual catalog do_open(const basic_string&, const locale&) const; + virtual string_type do_get(catalog, int set, int msgid, + const string_type& dfault) const; + virtual void do_close(catalog) const; + }; } \end{codeblock} @@ -5374,8 +5350,7 @@ \indexlibrarymember{messages}{get}% \begin{itemdecl} -string_type get(catalog cat, int set, int msgid, - const string_type& dfault) const; +string_type get(catalog cat, int set, int msgid, const string_type& dfault) const; \end{itemdecl} \begin{itemdescr} @@ -5386,7 +5361,7 @@ \indexlibrarymember{messages}{close}% \begin{itemdecl} -void close(catalog cat) const; +void close(catalog cat) const; \end{itemdecl} \begin{itemdescr} @@ -5400,8 +5375,7 @@ \indexlibrarymember{messages}{do_open}% \begin{itemdecl} -catalog do_open(const basic_string& name, - const locale& loc) const; +catalog do_open(const basic_string& name, const locale& loc) const; \end{itemdecl} \begin{itemdescr} @@ -5427,8 +5401,7 @@ \indexlibrarymember{messages}{do_get}% \begin{itemdecl} -string_type do_get(catalog cat, int set, int msgid, - const string_type& dfault) const; +string_type do_get(catalog cat, int set, int msgid, const string_type& dfault) const; \end{itemdecl} \begin{itemdescr} @@ -5582,9 +5555,7 @@ \pnum The second is in the operators -\tcode{\shl} -and -\tcode{\shr}, +\tcode{<<} and \tcode{>>}, where a locale ``hitchhikes'' on another object, in this case a stream, to the point where it is needed. @@ -5703,11 +5674,7 @@ \rSec1[locale.stdcvt]{Standard code conversion facets} -\pnum -The header \tcode{} provides code conversion facets for various character encodings. - -\pnum -\synopsis{Header \tcode{} synopsis} +\rSec2[codecvt.syn]{Header \tcode{} synopsis} \indexlibrary{\idxcode{codecvt}}% \begin{codeblock} @@ -5718,80 +5685,106 @@ little_endian = 1 }; - template - class codecvt_utf8 - : public codecvt { - public: - explicit codecvt_utf8(size_t refs = 0); - ~codecvt_utf8(); - }; - - template - class codecvt_utf16 - : public codecvt { - public: - explicit codecvt_utf16(size_t refs = 0); - ~codecvt_utf16(); - }; - - template - class codecvt_utf8_utf16 - : public codecvt { - public: - explicit codecvt_utf8_utf16(size_t refs = 0); - ~codecvt_utf8_utf16(); - }; + template + class codecvt_utf8 : public codecvt { + public: + explicit codecvt_utf8(size_t refs = 0); + ~codecvt_utf8(); + }; + + template + class codecvt_utf16 : public codecvt { + public: + explicit codecvt_utf16(size_t refs = 0); + ~codecvt_utf16(); + }; + + template + class codecvt_utf8_utf16 : public codecvt { + public: + explicit codecvt_utf8_utf16(size_t refs = 0); + ~codecvt_utf8_utf16(); + }; } \end{codeblock} \pnum -For each of the three code conversion facets \tcode{codecvt_utf8}, \tcode{codecvt_utf16}, and \tcode{codecvt_utf8_utf16}: +The header \tcode{} provides code conversion facets for various character encodings. +\rSec2[locale.stdcvt.req]{Requirements} + +\pnum +For each of the three code conversion facets \tcode{codecvt_utf8}, +\tcode{codecvt_utf16}, and \tcode{codecvt_utf8_utf16}: \begin{itemize} -\item \tcode{Elem} is the wide-character type, such as \tcode{wchar_t}, \tcode{char16_t}, or \tcode{char32_t}. -\item \tcode{Maxcode} is the largest wide-character code that the facet will read or write without reporting a conversion error. -\item If \tcode{(Mode \& consume_header)}, the facet shall consume an initial header sequence, if present, when reading a multibyte sequence to determine the endianness of the subsequent multibyte sequence to be read. -\item If \tcode{(Mode \& generate_header)}, the facet shall generate an initial header sequence when writing a multibyte sequence to advertise the endianness of the subsequent multibyte sequence to be written. -\item If \tcode{(Mode \& little_endian)}, the facet shall generate a multibyte sequence in little-endian order, as opposed to the default big-endian order. +\item + \tcode{Elem} is the wide-character type, such as + \tcode{wchar_t}, \tcode{char16_t}, or \tcode{char32_t}. +\item + \tcode{Maxcode} is the largest wide-character code that the facet + will read or write without reporting a conversion error. +\item + If \tcode{(Mode \& consume_header)}, the facet shall consume an + initial header sequence, if present, when reading a multibyte sequence + to determine the endianness of the subsequent multibyte sequence to be read. +\item + If \tcode{(Mode \& generate_header)}, the facet shall generate an + initial header sequence when writing a multibyte sequence to advertise + the endianness of the subsequent multibyte sequence to be written. +\item + If \tcode{(Mode \& little_endian)}, the facet shall generate a + multibyte sequence in little-endian order, + as opposed to the default big-endian order. \end{itemize} \pnum For the facet \tcode{codecvt_utf8}: - \begin{itemize} -\item The facet shall convert between UTF-8 multibyte sequences and UCS2 or UCS4 (depending on the size of \tcode{Elem}) within the program. -\item Endianness shall not affect how multibyte sequences are read or written. -\item The multibyte sequences may be written as either a text or a binary file. +\item + The facet shall convert between UTF-8 multibyte sequences + and UCS2 or UCS4 (depending on the size of \tcode{Elem}) + within the program. +\item + Endianness shall not affect how multibyte sequences are read or written. +\item + The multibyte sequences may be written as either a text or a binary file. \end{itemize} \pnum For the facet \tcode{codecvt_utf16}: - \begin{itemize} -\item The facet shall convert between UTF-16 multibyte sequences and UCS2 or UCS4 (depending on the size of \tcode{Elem}) within the program. -\item Multibyte sequences shall be read or written according to the \tcode{Mode} flag, as set out above. -\item The multibyte sequences may be written only as a binary file. Attempting to write to a text file produces undefined behavior. +\item + The facet shall convert between UTF-16 multibyte sequences + and UCS2 or UCS4 (depending on the size of \tcode{Elem}) + within the program. +\item + Multibyte sequences shall be read or written + according to the \tcode{Mode} flag, as set out above. +\item + The multibyte sequences may be written only as a binary file. + Attempting to write to a text file produces undefined behavior. \end{itemize} \pnum For the facet \tcode{codecvt_utf8_utf16}: - \begin{itemize} -\item The facet shall convert between UTF-8 multibyte sequences and UTF-16 (one or two 16-bit codes) within the program. -\item Endianness shall not affect how multibyte sequences are read or written. -\item The multibyte sequences may be written as either a text or a binary file. +\item + The facet shall convert between UTF-8 multibyte sequences + and UTF-16 (one or two 16-bit codes) within the program. +\item + Endianness shall not affect how multibyte sequences are read or written. +\item + The multibyte sequences may be written as either a text or a binary file. \end{itemize} \xref ISO/IEC 10646-1:1993. \rSec1[c.locales]{C library locales} -\synopsis{Header \tcode{} synopsis} +\rSec2[clocale.syn]{Header \tcode{} synopsis} \indextext{\idxhdr{cassert}}% +\indexlibrary{\idxhdr{cassert}}% \indexlibrary{\idxcode{lconv}}% \indexlibrary{\idxcode{setlocale}}% \indexlibrary{\idxcode{localeconv}}% @@ -5820,6 +5813,7 @@ \end{codeblock} \pnum +\indextext{\idxhdr{locale.h}}% \indexlibrary{\idxhdr{locale.h}}% The contents and meaning of the header \tcode{} are the same as the C standard library header \tcode{}. diff --git a/source/macros.tex b/source/macros.tex index 8676edef18..959025812e 100644 --- a/source/macros.tex +++ b/source/macros.tex @@ -90,8 +90,6 @@ \addtocounter{scratch}{\value{SectionDepthBase}} \Sec{\arabic{scratch}}[#2]{#3}} -\newcommand{\synopsis}[1]{\textbf{#1}} - %%-------------------------------------------------- % Indexing @@ -179,8 +177,6 @@ \newcommand{\CppXI}{\Cpp 2011\xspace} \newcommand{\CppXIV}{\Cpp 2014\xspace} \newcommand{\opt}{{\ensuremath{_\mathit{opt}}}\xspace} -\newcommand{\shl}{<{<}} -\newcommand{\shr}{>{>}} \newcommand{\dcr}{-{-}} \newcommand{\bigoh}[1]{\ensuremath{\mathscr{O}(#1)}} @@ -219,8 +215,6 @@ \newcommand{\default}{\Fundesc{Default behavior}} \newcommand{\complexity}{\Fundesc{Complexity}} \newcommand{\remarks}{\Fundesc{Remarks}} -\newcommand{\realnote}{\Fundesc{Note}} -\newcommand{\realnotes}{\Fundesc{Notes}} \newcommand{\errors}{\Fundesc{Error conditions}} \newcommand{\sync}{\Fundesc{Synchronization}} \newcommand{\implimits}{\Fundesc{Implementation limits}} @@ -262,7 +256,7 @@ \newcommand{\unspecuniqtype}{\UNSP{unspecified unique type}} \newcommand{\unspecalloctype}{\UNSP{unspecified allocator type}} -\newcommand{\EXPLICIT}{\textit{\texttt{EXPLICIT}}} +\newcommand{\EXPLICIT}{\textit{\texttt{EXPLICIT}\nocorr}} %% Manual insertion of italic corrections, for aligning in the presence %% of the above annotations. @@ -281,8 +275,13 @@ \newcommand{\xname}[1]{\tcode{\unun\ungap#1}} \newcommand{\mname}[1]{\tcode{\unun\ungap#1\ungap\unun}} +%% An elided code fragment, /* ... */, that is formatted as code. +%% (By default, listings typeset comments as body text.) +%% Produces 9 output characters. +\newcommand{\commentellip}{\tcode{/* ...\ */}} + %% Ranges -\newcommand{\Range}[4]{\tcode{#1#3,~\brk{}#4#2}\xspace} +\newcommand{\Range}[4]{\tcode{#1#3,\penalty2000{} #4#2}\xspace} \newcommand{\crange}[2]{\Range{[}{]}{#1}{#2}} \newcommand{\brange}[2]{\Range{(}{]}{#1}{#2}} \newcommand{\orange}[2]{\Range{(}{)}{#1}{#2}} @@ -297,7 +296,7 @@ \newcommand{\howwide}{\diffdef{How widely used}} %% Miscellaneous -\newcommand{\uniquens}{\textrm{\textit{\textbf{unique}}}} +\newcommand{\uniquens}{\placeholdernc{unique}} \newcommand{\stage}[1]{\item{\textbf{Stage #1:}}\xspace} \newcommand{\doccite}[1]{\textit{#1}\xspace} \newcommand{\cvqual}[1]{\textit{#1}} @@ -321,7 +320,7 @@ xleftmargin=1em, showstringspaces=false, commentstyle=\itshape\rmfamily, - columns=flexible, + columns=fullflexible, keepspaces=true, texcl=true} @@ -352,8 +351,8 @@ %%-------------------------------------------------- %% Indented text -\newenvironment{indented} -{\begin{indenthelper}\item\relax} +\newenvironment{indented}[1][] +{\begin{indenthelper}[#1]\item\relax} {\end{indenthelper}} %%-------------------------------------------------- @@ -388,23 +387,21 @@ \setlength{\BnfRest}{2\BnfIndent} \newcommand{\BnfNontermshape}{\small\rmfamily\itshape} \newcommand{\BnfTermshape}{\small\ttfamily\upshape} -\newcommand{\nonterminal}[1]{{\BnfNontermshape #1}} \newenvironment{bnfbase} { - \newcommand{\nontermdef}[1]{\nonterminal{##1}\indexgrammar{\idxgram{##1}}:} + \newcommand{\nontermdef}[1]{{\BnfNontermshape##1\itcorr}\indexgrammar{\idxgram{##1}}\textnormal{:}} \newcommand{\terminal}[1]{{\BnfTermshape ##1}\xspace} - \newcommand{\descr}[1]{\normalfont{##1}} + \newcommand{\descr}[1]{\textnormal{##1}} \newcommand{\bnfindentfirst}{\BnfIndent} \newcommand{\bnfindentinc}{\BnfInc} \newcommand{\bnfindentrest}{\BnfRest} - \begin{minipage}{.9\hsize} - \newcommand{\br}{\hfill\\} + \newcommand{\br}{\hfill\\*} + \widowpenalties 1 10000 \frenchspacing } { \nonfrenchspacing - \end{minipage} } \newenvironment{BnfTabBase}[1] @@ -440,7 +437,7 @@ { \begin{bnfbase} \BnfNontermshape - \begin{indented} + \begin{indented}[before*=\setlength{\rightmargin}{-\leftmargin}] } { \end{indented} @@ -450,17 +447,12 @@ \newenvironment{bnf} { \begin{bnfbase} - \list{} - { - \setlength{\leftmargin}{\bnfindentrest} - \setlength{\listparindent}{-\bnfindentinc} - \setlength{\itemindent}{\listparindent} - } + \begin{bnflist} \BnfNontermshape \item\relax } { - \endlist + \end{bnflist} \end{bnfbase} } diff --git a/source/numerics.tex b/source/numerics.tex index 1d2d5b1d76..2bc129b2e0 100644 --- a/source/numerics.tex +++ b/source/numerics.tex @@ -152,6 +152,7 @@ \rSec1[cfenv]{The floating-point environment} \rSec2[cfenv.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{cfenv}}% \indexlibrary{\idxhdr{cfenv}}% \indexlibrary{\idxcode{fenv_t}}% @@ -249,6 +250,7 @@ \pnum The header +\indextext{\idxhdr{complex}}% \indexlibrary{\idxhdr{complex}}% \tcode{} defines a @@ -270,15 +272,15 @@ undefined. \pnum -If \tcode{z} is an lvalue expression of type \emph{cv} \tcode{complex} then: +If \tcode{z} is an lvalue expression of type \cv{} \tcode{complex} then: \begin{itemize} -\item the expression \tcode{reinterpret_cast(z)} shall be well-formed, -\item \tcode{reinterpret_cast(z)[0]} shall designate the real part of \tcode{z}, and -\item \tcode{reinterpret_cast(z)[1]} shall designate the imaginary part of \tcode{z}. +\item the expression \tcode{reinterpret_cast<\cv{} T(\&)[2]>(z)} shall be well-formed, +\item \tcode{reinterpret_cast<\cv{} T(\&)[2]>(z)[0]} shall designate the real part of \tcode{z}, and +\item \tcode{reinterpret_cast<\cv{} T(\&)[2]>(z)[1]} shall designate the imaginary part of \tcode{z}. \end{itemize} -Moreover, if \tcode{a} is an expression of type \cv{} \tcode{complex*} and the expression \tcode{a[i]} is well-defined for an integer expression \tcode{i}, then: +Moreover, if \tcode{a} is an expression of type \cv{}~\tcode{complex*} and the expression \tcode{a[i]} is well-defined for an integer expression \tcode{i}, then: \begin{itemize} \item \tcode{reinterpret_cast<\cv{} T*>(a)[2*i]} shall designate the real part of \tcode{a[i]}, and @@ -287,6 +289,7 @@ \rSec2[complex.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{complex}}% \indexlibrary{\idxhdr{complex}}% \begin{codeblock} namespace std { @@ -544,6 +547,7 @@ \end{itemdecl} \begin{itemdescr} +\pnum \returns The value of the real component. \end{itemdescr} @@ -553,6 +557,7 @@ \end{itemdecl} \begin{itemdescr} +\pnum \effects Assigns \tcode{val} to the real component. \end{itemdescr} @@ -562,6 +567,7 @@ \end{itemdecl} \begin{itemdescr} +\pnum \returns The value of the imaginary component. \end{itemdescr} @@ -571,6 +577,7 @@ \end{itemdecl} \begin{itemdescr} +\pnum \effects Assigns \tcode{val} to the imaginary component. \end{itemdescr} @@ -699,6 +706,7 @@ and stores the product in \tcode{*this}. +\pnum \returns \tcode{*this}. \end{itemdescr} @@ -838,7 +846,7 @@ \tcode{rhs.real() != lhs.real() || rhs.imag() != lhs.imag()}. \end{itemdescr} -\indexlibrarymember{operator\shr}{complex}% +\indexlibrarymember{operator>>}{complex}% \begin{itemdecl} template basic_istream& @@ -882,7 +890,7 @@ the same for each of the simpler extractions. \end{itemdescr} -\indexlibrarymember{operator\shl}{complex}% +\indexlibrarymember{operator<<}{complex}% \begin{itemdecl} template basic_ostream& @@ -892,29 +900,26 @@ \begin{itemdescr} \pnum \effects -inserts the complex number \tcode{x} +Inserts the complex number \tcode{x} onto the stream \tcode{o} as if it were implemented as follows: \begin{codeblock} -template -basic_ostream& -operator<<(basic_ostream& o, const complex& x) { - basic_ostringstream s; - s.flags(o.flags()); - s.imbue(o.getloc()); - s.precision(o.precision()); - s << '(' << x.real() << "," << x.imag() << ')'; - return o << s.str(); -} +basic_ostringstream s; +s.flags(o.flags()); +s.imbue(o.getloc()); +s.precision(o.precision()); +s << '(' << x.real() << "," << x.imag() << ')'; +return o << s.str(); \end{codeblock} \pnum -\realnote In a locale in which comma is used as a decimal point character, the +\begin{note} +In a locale in which comma is used as a decimal point character, the use of comma as a field separator can be ambiguous. Inserting \tcode{showpoint} into the output stream forces all outputs to show an explicit decimal point character; as a result, all inserted sequences of complex numbers can be extracted unambiguously. - +\end{note} \end{itemdescr} \rSec2[complex.value.ops]{\tcode{complex} value operations} @@ -1359,6 +1364,7 @@ \end{itemdescr} \rSec2[ccomplex.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{ccomplex}}% \indexlibrary{\idxhdr{ccomplex}}% \begin{codeblock} @@ -1556,7 +1562,7 @@ shall be interpreted as equivalent to the more formal requirement that ``\tcode{x} is a value of a type satisfying the requirements -of the specified iterator type.'' +of the specified iterator type''. \pnum Throughout this subclause \ref{rand}, @@ -1826,7 +1832,7 @@ a constructor, a \tcode{seed} function, assignment, - or a suitable \tcode{operator\shr{}}. + or a suitable \tcode{operator>>}. \pnum \tcode{E}'s specification shall define: @@ -1948,21 +1954,21 @@ \tcode{e.seed()}% \indextext{\idxcode{seed}!random number engine requirement} & \tcode{void} - & post: + & \postconditions \tcode{e == E()}. & same as \tcode{E()} \\ \rowsep \tcode{e.seed(s)}% \indextext{\idxcode{seed}!random number engine requirement} & \tcode{void} - & post: + & \postconditions \tcode{e == E(s)}. & same as \tcode{E(s)} \\ \rowsep \tcode{e.seed(q)}% \indextext{\idxcode{seed}!random number engine requirement} & \tcode{void} - & post: + & \postconditions \tcode{e == E(q)}. & same as \tcode{E(q)} \\ \rowsep @@ -2013,8 +2019,8 @@ & \tcode{!(x == y)}. & \bigoh{$\mbox{size of state}$} \\ \rowsep -\tcode{os \shl{} x}% -\indextext{\idxcode{operator\shl}!random number engine requirement} +\tcode{os << x}% +\indextext{\idxcode{operator<<}!random number engine requirement} & reference to the type of \tcode{os} & With \tcode{os.}\textit{fmtflags} set to \tcode{ios_base\colcol{}dec|ios_base\colcol{}left} @@ -2026,11 +2032,11 @@ adjacent numbers are separated by one or more space characters. - post: The \tcode{os.}\textit{fmtflags} and fill character are unchanged. + \postconditions The \tcode{os.}\textit{fmtflags} and fill character are unchanged. & \bigoh{$\mbox{size of state}$} \\ \rowsep -\tcode{is \shr{} v}% -\indextext{\idxcode{operator\shr}!random number engine requirement} +\tcode{is >> v}% +\indextext{\idxcode{operator>>}!random number engine requirement} & reference to the type of \tcode{is} & With \tcode{is.fmtflags} set to \tcode{ios_base::dec}, @@ -2041,13 +2047,13 @@ and calls \tcode{is.setstate(ios::failbit)} (which may throw \tcode{ios::failure}~[\ref{iostate.flags}]). - If a textual representation written via \tcode{os \shl{} x} - was subsequently read via \tcode{is \shr{} v}, + If a textual representation written via \tcode{os << x} + was subsequently read via \tcode{is >> v}, then \tcode{x == v} provided that there have been no intervening invocations of \tcode{x} or of \tcode{v}. - pre: + \requires \tcode{is} provides a textual representation that was previously written using an output stream @@ -2057,7 +2063,7 @@ \tcode{charT} and \tcode{traits} were respectively the same as those of \tcode{is}. - post: The \tcode{is.}\textit{fmtflags} are unchanged. + \postconditions The \tcode{is.}\textit{fmtflags} are unchanged. & \bigoh{$\mbox{size of state}$} \\ \end{libreqtab4d} @@ -2133,7 +2139,7 @@ \begin{itemdecl} -template void A::A(Sseq& q); +template A::A(Sseq& q); \end{itemdecl} \begin{itemdescr} @@ -2344,7 +2350,7 @@ \tcode{d.param(p)} \indextext{\idxcode{param}!random number distribution requirement} & \tcode{void} - & post: \tcode{d.param() == p}. + & \postconditions \tcode{d.param() == p}. & no worse than the complexity of \tcode{D(p)} \\ \rowsep \tcode{d(g)} @@ -2409,17 +2415,17 @@ & \tcode{!(x == y)}. & same as \tcode{x == y}. \\ \rowsep -\tcode{os \shl{} x} -\indextext{\idxcode{operator\shl}!random number distribution requirement} +\tcode{os << x} +\indextext{\idxcode{operator<<}!random number distribution requirement} & reference to the type of \tcode{os} & Writes to \tcode{os} a textual representation for the parameters and the additional internal data of \tcode{x}. - post: The \tcode{os.}\textit{fmtflags} and fill character are unchanged. + \postconditions The \tcode{os.}\textit{fmtflags} and fill character are unchanged. & \\ \rowsep -\tcode{is \shr{} d} -\indextext{\idxcode{operator\shr}!random number distribution requirement} +\tcode{is >> d} +\indextext{\idxcode{operator>>}!random number distribution requirement} & reference to the type of \tcode{is} & Restores from \tcode{is} the parameters and additional internal data of the lvalue \tcode{d}. @@ -2429,14 +2435,14 @@ calls \tcode{is.setstate(ios\colcol{}failbit)} (which may throw \tcode{ios\colcol{}failure}~[\ref{iostate.flags}]). - pre: \tcode{is} provides a textual representation + \requires \tcode{is} provides a textual representation that was previously written using an \tcode{os} whose imbued locale and whose type's template specialization arguments \tcode{charT} and \tcode{traits} were the same as those of \tcode{is}. - post: The \tcode{is.}\textit{fmtflags} are unchanged. + \postconditions The \tcode{is.}\textit{fmtflags} are unchanged. & \\ \end{libreqtab4d} @@ -2450,16 +2456,16 @@ The sequence of numbers produced by repeated invocations of \tcode{d(g)} shall be independent of any invocation of -\tcode{os \shl{} d} +\tcode{os << d} or of any \tcode{const} member function of \tcode{D} between any of the invocations \tcode{d(g)}. \pnum -If a textual representation is written using \tcode{os \shl{} x} +If a textual representation is written using \tcode{os << x} and that representation is restored into the same or a different object \tcode{y} -of the same type using \tcode{is \shr{} y}, +of the same type using \tcode{is >> y}, repeated invocations of \tcode{y(g)} shall produce the same sequence of numbers as would repeated invocations of \tcode{x(g)}. @@ -2513,6 +2519,7 @@ \rSec2[rand.synopsis]{Header \tcode{} synopsis}% +\indextext{\idxhdr{random}|(}% \indexlibrary{\idxhdr{random}|(}% \indextext{random number generation!synopsis|(} @@ -2520,137 +2527,138 @@ #include namespace std { - // \ref{rand.eng.lcong}, class template linear_congruential_engine - template - class linear_congruential_engine; - - // \ref{rand.eng.mers}, class template mersenne_twister_engine - template - class mersenne_twister_engine; - - // \ref{rand.eng.sub}, class template subtract_with_carry_engine - template - class subtract_with_carry_engine; - - // \ref{rand.adapt.disc}, class template discard_block_engine - template - class discard_block_engine; - - // \ref{rand.adapt.ibits}, class template independent_bits_engine - template - class independent_bits_engine; - - // \ref{rand.adapt.shuf}, class template shuffle_order_engine - template - class shuffle_order_engine; - - // \ref{rand.predef}, engines and engine adaptors with predefined parameters - using minstd_rand0 = @\seebelow@; - using minstd_rand = @\seebelow@; - using mt19937 = @\seebelow@; - using mt19937_64 = @\seebelow@; - using ranlux24_base = @\seebelow@; - using ranlux48_base = @\seebelow@; - using ranlux24 = @\seebelow@; - using ranlux48 = @\seebelow@; - using knuth_b = @\seebelow@; - - using default_random_engine = @\seebelow@; - - // \ref{rand.device}, class random_device - class random_device; - - // \ref{rand.util.seedseq}, class seed_seq - class seed_seq; - - // \ref{rand.util.canonical}, function template generate_canonical - template - RealType generate_canonical(URBG& g); - - // \ref{rand.dist.uni.int}, class template uniform_int_distribution - template - class uniform_int_distribution; - - // \ref{rand.dist.uni.real}, class template uniform_real_distribution - template - class uniform_real_distribution; - - // \ref{rand.dist.bern.bernoulli}, class bernoulli_distribution - class bernoulli_distribution; - - // \ref{rand.dist.bern.bin}, class template binomial_distribution - template - class binomial_distribution; - - // \ref{rand.dist.bern.geo}, class template geometric_distribution - template - class geometric_distribution; - - // \ref{rand.dist.bern.negbin}, class template negative_binomial_distribution - template - class negative_binomial_distribution; - - // \ref{rand.dist.pois.poisson}, class template poisson_distribution - template - class poisson_distribution; - - // \ref{rand.dist.pois.exp}, class template exponential_distribution - template - class exponential_distribution; - - // \ref{rand.dist.pois.gamma}, class template gamma_distribution - template - class gamma_distribution; - - // \ref{rand.dist.pois.weibull}, class template weibull_distribution - template - class weibull_distribution; - - // \ref{rand.dist.pois.extreme}, class template extreme_value_distribution - template - class extreme_value_distribution; - - // \ref{rand.dist.norm.normal}, class template normal_distribution - template - class normal_distribution; - - // \ref{rand.dist.norm.lognormal}, class template lognormal_distribution - template - class lognormal_distribution; - - // \ref{rand.dist.norm.chisq}, class template chi_squared_distribution - template - class chi_squared_distribution; - - // \ref{rand.dist.norm.cauchy}, class template cauchy_distribution - template - class cauchy_distribution; - - // \ref{rand.dist.norm.f}, class template fisher_f_distribution - template - class fisher_f_distribution; - - // \ref{rand.dist.norm.t}, class template student_t_distribution - template - class student_t_distribution; - - // \ref{rand.dist.samp.discrete}, class template discrete_distribution - template - class discrete_distribution; - - // \ref{rand.dist.samp.pconst}, class template piecewise_constant_distribution - template - class piecewise_constant_distribution; - - // \ref{rand.dist.samp.plinear}, class template piecewise_linear_distribution - template - class piecewise_linear_distribution; + // \ref{rand.eng.lcong}, class template linear_congruential_engine + template + class linear_congruential_engine; + + // \ref{rand.eng.mers}, class template mersenne_twister_engine + template + class mersenne_twister_engine; + + // \ref{rand.eng.sub}, class template subtract_with_carry_engine + template + class subtract_with_carry_engine; + + // \ref{rand.adapt.disc}, class template discard_block_engine + template + class discard_block_engine; + + // \ref{rand.adapt.ibits}, class template independent_bits_engine + template + class independent_bits_engine; + + // \ref{rand.adapt.shuf}, class template shuffle_order_engine + template + class shuffle_order_engine; + + // \ref{rand.predef}, engines and engine adaptors with predefined parameters + using minstd_rand0 = @\seebelow@; + using minstd_rand = @\seebelow@; + using mt19937 = @\seebelow@; + using mt19937_64 = @\seebelow@; + using ranlux24_base = @\seebelow@; + using ranlux48_base = @\seebelow@; + using ranlux24 = @\seebelow@; + using ranlux48 = @\seebelow@; + using knuth_b = @\seebelow@; + + using default_random_engine = @\seebelow@; + + // \ref{rand.device}, class random_device + class random_device; + + // \ref{rand.util.seedseq}, class seed_seq + class seed_seq; + + // \ref{rand.util.canonical}, function template generate_canonical + template + RealType generate_canonical(URBG& g); + + // \ref{rand.dist.uni.int}, class template uniform_int_distribution + template + class uniform_int_distribution; + + // \ref{rand.dist.uni.real}, class template uniform_real_distribution + template + class uniform_real_distribution; + + // \ref{rand.dist.bern.bernoulli}, class bernoulli_distribution + class bernoulli_distribution; + + // \ref{rand.dist.bern.bin}, class template binomial_distribution + template + class binomial_distribution; + + // \ref{rand.dist.bern.geo}, class template geometric_distribution + template + class geometric_distribution; + + // \ref{rand.dist.bern.negbin}, class template negative_binomial_distribution + template + class negative_binomial_distribution; + + // \ref{rand.dist.pois.poisson}, class template poisson_distribution + template + class poisson_distribution; + + // \ref{rand.dist.pois.exp}, class template exponential_distribution + template + class exponential_distribution; + + // \ref{rand.dist.pois.gamma}, class template gamma_distribution + template + class gamma_distribution; + + // \ref{rand.dist.pois.weibull}, class template weibull_distribution + template + class weibull_distribution; + + // \ref{rand.dist.pois.extreme}, class template extreme_value_distribution + template + class extreme_value_distribution; + + // \ref{rand.dist.norm.normal}, class template normal_distribution + template + class normal_distribution; + + // \ref{rand.dist.norm.lognormal}, class template lognormal_distribution + template + class lognormal_distribution; + + // \ref{rand.dist.norm.chisq}, class template chi_squared_distribution + template + class chi_squared_distribution; + + // \ref{rand.dist.norm.cauchy}, class template cauchy_distribution + template + class cauchy_distribution; + + // \ref{rand.dist.norm.f}, class template fisher_f_distribution + template + class fisher_f_distribution; + + // \ref{rand.dist.norm.t}, class template student_t_distribution + template + class student_t_distribution; + + // \ref{rand.dist.samp.discrete}, class template discrete_distribution + template + class discrete_distribution; + + // \ref{rand.dist.samp.pconst}, class template piecewise_constant_distribution + template + class piecewise_constant_distribution; + + // \ref{rand.dist.samp.plinear}, class template piecewise_linear_distribution + template + class piecewise_linear_distribution; } \end{codeblock}% \indextext{random number generation!synopsis|)}% +\indextext{\idxhdr{random}|)}% \indexlibrary{\idxhdr{random}|)} @@ -2693,7 +2701,7 @@ \pnum Descriptions are provided in this section~\ref{rand.eng} only for engine operations -that are not described in \mbox{\ref{rand.req.eng}} +that are not described in \ref{rand.req.eng} or for operations where there is additional semantic information. In particular, declarations for copy constructors, @@ -2712,7 +2720,7 @@ \pnum For every random number engine and for every random number engine adaptor \tcode{X} -defined in this subclause~(\ref{rand.eng}) and in sub-clause~\ref{rand.adapt}: +defined in this subclause~(\ref{rand.eng}) and in subclause~\ref{rand.adapt}: \begin{itemize} \item @@ -2766,30 +2774,29 @@ \indexlibrary{\idxcode{linear_congruential_engine}}% \begin{codeblock} template - class linear_congruential_engine -{ -public: - // types - using result_type = UIntType; - - // engine characteristics - static constexpr result_type multiplier = a; - static constexpr result_type increment = c; - static constexpr result_type modulus = m; - static constexpr result_type min() { return c == 0u ? 1u: 0u; } - static constexpr result_type max() { return m - 1u; } - static constexpr result_type default_seed = 1u; - - // constructors and seeding functions - explicit linear_congruential_engine(result_type s = default_seed); - template explicit linear_congruential_engine(Sseq& q); - void seed(result_type s = default_seed); - template void seed(Sseq& q); - - // generating functions - result_type operator()(); - void discard(unsigned long long z); -}; + class linear_congruential_engine { + public: + // types + using result_type = UIntType; + + // engine characteristics + static constexpr result_type multiplier = a; + static constexpr result_type increment = c; + static constexpr result_type modulus = m; + static constexpr result_type min() { return c == 0u ? 1u: 0u; } + static constexpr result_type max() { return m - 1u; } + static constexpr result_type default_seed = 1u; + + // constructors and seeding functions + explicit linear_congruential_engine(result_type s = default_seed); + template explicit linear_congruential_engine(Sseq& q); + void seed(result_type s = default_seed); + template void seed(Sseq& q); + + // generating functions + result_type operator()(); + void discard(unsigned long long z); + }; \end{codeblock} \pnum @@ -2929,43 +2936,42 @@ \indexlibrary{\idxcode{mersenne_twister_engine}}% \begin{codeblock} template - class mersenne_twister_engine -{ -public: - // types - using result_type = UIntType; - - // engine characteristics - static constexpr size_t word_size = w; - static constexpr size_t state_size = n; - static constexpr size_t shift_size = m; - static constexpr size_t mask_bits = r; - static constexpr UIntType xor_mask = a; - static constexpr size_t tempering_u = u; - static constexpr UIntType tempering_d = d; - static constexpr size_t tempering_s = s; - static constexpr UIntType tempering_b = b; - static constexpr size_t tempering_t = t; - static constexpr UIntType tempering_c = c; - static constexpr size_t tempering_l = l; - static constexpr UIntType initialization_multiplier = f; - static constexpr result_type min() { return 0; } - static constexpr result_type max() { return @$2^w - 1$@; } - static constexpr result_type default_seed = 5489u; - - // constructors and seeding functions - explicit mersenne_twister_engine(result_type value = default_seed); - template explicit mersenne_twister_engine(Sseq& q); - void seed(result_type value = default_seed); - template void seed(Sseq& q); - - // generating functions - result_type operator()(); - void discard(unsigned long long z); -}; + UIntType a, size_t u, UIntType d, size_t s, + UIntType b, size_t t, + UIntType c, size_t l, UIntType f> + class mersenne_twister_engine { + public: + // types + using result_type = UIntType; + + // engine characteristics + static constexpr size_t word_size = w; + static constexpr size_t state_size = n; + static constexpr size_t shift_size = m; + static constexpr size_t mask_bits = r; + static constexpr UIntType xor_mask = a; + static constexpr size_t tempering_u = u; + static constexpr UIntType tempering_d = d; + static constexpr size_t tempering_s = s; + static constexpr UIntType tempering_b = b; + static constexpr size_t tempering_t = t; + static constexpr UIntType tempering_c = c; + static constexpr size_t tempering_l = l; + static constexpr UIntType initialization_multiplier = f; + static constexpr result_type min() { return 0; } + static constexpr result_type max() { return @$2^w - 1$@; } + static constexpr result_type default_seed = 5489u; + + // constructors and seeding functions + explicit mersenne_twister_engine(result_type value = default_seed); + template explicit mersenne_twister_engine(Sseq& q); + void seed(result_type value = default_seed); + template void seed(Sseq& q); + + // generating functions + result_type operator()(); + void discard(unsigned long long z); + }; \end{codeblock} \pnum @@ -2979,12 +2985,12 @@ \tcode{t <= w}, \tcode{l <= w}, \tcode{w <= numeric_limits::digits}, - \tcode{a <= (1u\shl{}w) - 1u}, - \tcode{b <= (1u\shl{}w) - 1u}, - \tcode{c <= (1u\shl{}w) - 1u}, - \tcode{d <= (1u\shl{}w) - 1u}, + \tcode{a <= (1u< - class subtract_with_carry_engine -{ -public: - // types - using result_type = UIntType; - - // engine characteristics - static constexpr size_t word_size = w; - static constexpr size_t short_lag = s; - static constexpr size_t long_lag = r; - static constexpr result_type min() { return 0; } - static constexpr result_type max() { return @$m - 1$@; } - static constexpr result_type default_seed = 19780503u; - - // constructors and seeding functions - explicit subtract_with_carry_engine(result_type value = default_seed); - template explicit subtract_with_carry_engine(Sseq& q); - void seed(result_type value = default_seed); - template void seed(Sseq& q); - - // generating functions - result_type operator()(); - void discard(unsigned long long z); -}; + class subtract_with_carry_engine { + public: + // types + using result_type = UIntType; + + // engine characteristics + static constexpr size_t word_size = w; + static constexpr size_t short_lag = s; + static constexpr size_t long_lag = r; + static constexpr result_type min() { return 0; } + static constexpr result_type max() { return @$m - 1$@; } + static constexpr result_type default_seed = 19780503u; + + // constructors and seeding functions + explicit subtract_with_carry_engine(result_type value = default_seed); + template explicit subtract_with_carry_engine(Sseq& q); + void seed(result_type value = default_seed); + template void seed(Sseq& q); + + // generating functions + result_type operator()(); + void discard(unsigned long long z); + }; \end{codeblock} \pnum @@ -3309,39 +3314,38 @@ \indexlibrary{\idxcode{discard_block_engine}}% \begin{codeblock} template - class discard_block_engine -{ -public: - // types - using result_type = typename Engine::result_type; - - // engine characteristics - static constexpr size_t block_size = p; - static constexpr size_t used_block = r; - static constexpr result_type min() { return Engine::min(); } - static constexpr result_type max() { return Engine::max(); } - - // constructors and seeding functions - discard_block_engine(); - explicit discard_block_engine(const Engine& e); - explicit discard_block_engine(Engine&& e); - explicit discard_block_engine(result_type s); - template explicit discard_block_engine(Sseq& q); - void seed(); - void seed(result_type s); - template void seed(Sseq& q); - - // generating functions - result_type operator()(); - void discard(unsigned long long z); - - // property functions - const Engine& base() const noexcept { return e; }; - -private: - Engine e; // \expos - int n; // \expos -}; + class discard_block_engine { + public: + // types + using result_type = typename Engine::result_type; + + // engine characteristics + static constexpr size_t block_size = p; + static constexpr size_t used_block = r; + static constexpr result_type min() { return Engine::min(); } + static constexpr result_type max() { return Engine::max(); } + + // constructors and seeding functions + discard_block_engine(); + explicit discard_block_engine(const Engine& e); + explicit discard_block_engine(Engine&& e); + explicit discard_block_engine(result_type s); + template explicit discard_block_engine(Sseq& q); + void seed(); + void seed(result_type s); + template void seed(Sseq& q); + + // generating functions + result_type operator()(); + void discard(unsigned long long z); + + // property functions + const Engine& base() const noexcept { return e; }; + + private: + Engine e; // \expos + int n; // \expos + }; \end{codeblock} \pnum @@ -3435,7 +3439,7 @@ to obtain $ n_0 $ values less than -$ y_0 $ $ + \tcode{e.min()} $ +$ y_0 + \tcode{e.min()} $ and $ n - n_0 $ values less than $ y_1 + \tcode{e.min()} $% @@ -3464,36 +3468,35 @@ \indexlibrary{\idxcode{independent_bits_engine}}% \begin{codeblock} template -class independent_bits_engine -{ -public: - // types - using result_type = UIntType; - - // engine characteristics - static constexpr result_type min() { return 0; } - static constexpr result_type max() { return @$2^w - 1$@; } - - // constructors and seeding functions - independent_bits_engine(); - explicit independent_bits_engine(const Engine& e); - explicit independent_bits_engine(Engine&& e); - explicit independent_bits_engine(result_type s); - template explicit independent_bits_engine(Sseq& q); - void seed(); - void seed(result_type s); - template void seed(Sseq& q); - - // generating functions - result_type operator()(); - void discard(unsigned long long z); - - // property functions - const Engine& base() const noexcept { return e; }; - -private: - Engine e; // \expos -}; + class independent_bits_engine { + public: + // types + using result_type = UIntType; + + // engine characteristics + static constexpr result_type min() { return 0; } + static constexpr result_type max() { return @$2^w - 1$@; } + + // constructors and seeding functions + independent_bits_engine(); + explicit independent_bits_engine(const Engine& e); + explicit independent_bits_engine(Engine&& e); + explicit independent_bits_engine(result_type s); + template explicit independent_bits_engine(Sseq& q); + void seed(); + void seed(result_type s); + template void seed(Sseq& q); + + // generating functions + result_type operator()(); + void discard(unsigned long long z); + + // property functions + const Engine& base() const noexcept { return e; }; + + private: + Engine e; // \expos + }; \end{codeblock}% \pnum @@ -3564,39 +3567,38 @@ \indexlibrary{\idxcode{shuffle_order_engine}}% \begin{codeblock} template - class shuffle_order_engine -{ -public: - // types - using result_type = typename Engine::result_type; - - // engine characteristics - static constexpr size_t table_size = k; - static constexpr result_type min() { return Engine::min(); } - static constexpr result_type max() { return Engine::max(); } - - // constructors and seeding functions - shuffle_order_engine(); - explicit shuffle_order_engine(const Engine& e); - explicit shuffle_order_engine(Engine&& e); - explicit shuffle_order_engine(result_type s); - template explicit shuffle_order_engine(Sseq& q); - void seed(); - void seed(result_type s); - template void seed(Sseq& q); - - // generating functions - result_type operator()(); - void discard(unsigned long long z); - - // property functions - const Engine& base() const noexcept { return e; }; - -private: - Engine e; // \expos - result_type Y; // \expos - result_type V[k]; // \expos -}; + class shuffle_order_engine { + public: + // types + using result_type = typename Engine::result_type; + + // engine characteristics + static constexpr size_t table_size = k; + static constexpr result_type min() { return Engine::min(); } + static constexpr result_type max() { return Engine::max(); } + + // constructors and seeding functions + shuffle_order_engine(); + explicit shuffle_order_engine(const Engine& e); + explicit shuffle_order_engine(Engine&& e); + explicit shuffle_order_engine(result_type s); + template explicit shuffle_order_engine(Sseq& q); + void seed(); + void seed(result_type s); + template void seed(Sseq& q); + + // generating functions + result_type operator()(); + void discard(unsigned long long z); + + // property functions + const Engine& base() const noexcept { return e; }; + + private: + Engine e; // \expos + result_type V[k]; // \expos + result_type Y; // \expos + }; \end{codeblock} \pnum @@ -3717,7 +3719,7 @@ \pnum\required The $10000^{\,\mathrm{th}}$ consecutive invocation of a default-constructed object - of type \tcode{ranlux24_base} + of type \tcode{ran\-lux24_base} shall produce the value $ 7937952 $. \end{itemdescr} @@ -3733,7 +3735,7 @@ \pnum\required The $10000^{\,\mathrm{th}}$ consecutive invocation of a default-constructed object - of type \tcode{ranlux48_base} + of type \tcode{ran\-lux48_base} shall produce the value $ 61839128582725 $. \end{itemdescr} @@ -3838,28 +3840,27 @@ \indexlibrary{\idxcode{random_device}}% \begin{codeblock} -class random_device -{ +class random_device { public: - // types - using result_type = unsigned int; + // types + using result_type = unsigned int; - // generator characteristics - static constexpr result_type min() { return numeric_limits::min(); } - static constexpr result_type max() { return numeric_limits::max(); } + // generator characteristics + static constexpr result_type min() { return numeric_limits::min(); } + static constexpr result_type max() { return numeric_limits::max(); } - // constructors - explicit random_device(const string& token = @\textit{implementation-defined}@); + // constructors + explicit random_device(const string& token = @\textit{implementation-defined}@); - // generating functions - result_type operator()(); + // generating functions + result_type operator()(); - // property functions - double entropy() const noexcept; + // property functions + double entropy() const noexcept; - @\textit{// no copy functions}@ - random_device(const random_device& ) = delete; - void operator=(const random_device& ) = delete; + @\textit{// no copy functions}@ + random_device(const random_device& ) = delete; + void operator=(const random_device& ) = delete; }; \end{codeblock} @@ -3874,8 +3875,8 @@ nondeterministic uniform random bit generator object. The semantics and default value of the \tcode{token} parameter are - \impldef{semantics and default value of \tcode{token} parameter to \tcode{random_device} constructor}. - \footnote{The parameter is intended + \impldef{semantics and default value of \tcode{token} parameter to \tcode{random_device} constructor}.% +\footnote{The parameter is intended to allow an implementation to differentiate between different sources of randomness. } @@ -3945,34 +3946,33 @@ \indexlibrary{\idxcode{seed_seq}}% \begin{codeblock} -class seed_seq -{ +class seed_seq { public: - // types - using result_type = uint_least32_t; + // types + using result_type = uint_least32_t; - // constructors - seed_seq(); - template - seed_seq(initializer_list il); - template - seed_seq(InputIterator begin, InputIterator end); + // constructors + seed_seq(); + template + seed_seq(initializer_list il); + template + seed_seq(InputIterator begin, InputIterator end); - // generating functions - template - void generate(RandomAccessIterator begin, RandomAccessIterator end); + // generating functions + template + void generate(RandomAccessIterator begin, RandomAccessIterator end); - // property functions - size_t size() const noexcept; - template - void param(OutputIterator dest) const; + // property functions + size_t size() const noexcept; + template + void param(OutputIterator dest) const; - // no copy functions - seed_seq(const seed_seq& ) = delete; - void operator=(const seed_seq& ) = delete; + // no copy functions + seed_seq(const seed_seq& ) = delete; + void operator=(const seed_seq& ) = delete; private: - vector v; // \expos + vector v; // \expos }; \end{codeblock}% @@ -4035,8 +4035,7 @@ \begin{itemdescr} \pnum\requires \tcode{RandomAccessIterator} - shall meet the requirements of a mutable random access iterator - (Table~\ref{tab:iterator.random.access.requirements}) type. + shall meet the requirements of a mutable random access iterator~(\ref{random.access.iterators}). Moreover, \tcode{iterator_traits::value_type} shall denote an unsigned integer type @@ -4073,10 +4072,10 @@ calculate values \begin{eqnarray*} r_1 & = & - 1664525 \cdot \tcode{T}\left( \tcode{begin[}k\tcode{]} - \xor \tcode{begin[}k+p\tcode{]} - \xor \tcode{begin[}k-1 \tcode{]} - \right) + 1664525 \cdot T( \tcode{begin[}k\tcode{]} + \xor \tcode{begin[}k+p\tcode{]} + \xor \tcode{begin[}k-1 \tcode{]} + ) \\ r_2 & = & r_1 + \left\{ \begin{array}{cl} @@ -4100,10 +4099,10 @@ calculate values \begin{eqnarray*} r_3 & = & - 1566083941 \cdot \tcode{T}\left( \tcode{begin[}k \tcode{]} - + \tcode{begin[}k+p\tcode{]} - + \tcode{begin[}k-1\tcode{]} - \right) + 1566083941 \cdot T( \tcode{begin[}k \tcode{]} + + \tcode{begin[}k+p\tcode{]} + + \tcode{begin[}k-1\tcode{]} + ) \\ r_4 & = & r_3 - (k \bmod n) \end{eqnarray*} @@ -4142,7 +4141,7 @@ \begin{itemdescr} \pnum\requires \tcode{OutputIterator} shall satisfy the requirements - of an output iterator (Table~\ref{tab:iterator.output.requirements}) type. + of an output iterator~(\ref{output.iterators}). Moreover, the expression \tcode{*dest = rt} @@ -4308,32 +4307,31 @@ \indexlibrary{\idxcode{uniform_int_distribution}}% \begin{codeblock} template - class uniform_int_distribution -{ -public: - // types - using result_type = IntType; - using param_type = @\unspec@; - - // constructors and reset functions - explicit uniform_int_distribution(IntType a = 0, IntType b = numeric_limits::max()); - explicit uniform_int_distribution(const param_type& parm); - void reset(); - - // generating functions - template - result_type operator()(URBG& g); - template - result_type operator()(URBG& g, const param_type& parm); - - // property functions - result_type a() const; - result_type b() const; - param_type param() const; - void param(const param_type& parm); - result_type min() const; - result_type max() const; -}; + class uniform_int_distribution { + public: + // types + using result_type = IntType; + using param_type = @\unspec@; + + // constructors and reset functions + explicit uniform_int_distribution(IntType a = 0, IntType b = numeric_limits::max()); + explicit uniform_int_distribution(const param_type& parm); + void reset(); + + // generating functions + template + result_type operator()(URBG& g); + template + result_type operator()(URBG& g, const param_type& parm); + + // property functions + result_type a() const; + result_type b() const; + param_type param() const; + void param(const param_type& parm); + result_type min() const; + result_type max() const; + }; \end{codeblock} @@ -4397,32 +4395,31 @@ \indexlibrary{\idxcode{uniform_real_distribution}}% \begin{codeblock} template - class uniform_real_distribution -{ -public: - // types - using result_type = RealType; - using param_type = @\unspec@; - - // constructors and reset functions - explicit uniform_real_distribution(RealType a = 0.0, RealType b = 1.0); - explicit uniform_real_distribution(const param_type& parm); - void reset(); - - // generating functions - template - result_type operator()(URBG& g); - template - result_type operator()(URBG& g, const param_type& parm); - - // property functions - result_type a() const; - result_type b() const; - param_type param() const; - void param(const param_type& parm); - result_type min() const; - result_type max() const; -}; + class uniform_real_distribution { + public: + // types + using result_type = RealType; + using param_type = @\unspec@; + + // constructors and reset functions + explicit uniform_real_distribution(RealType a = 0.0, RealType b = 1.0); + explicit uniform_real_distribution(const param_type& parm); + void reset(); + + // generating functions + template + result_type operator()(URBG& g); + template + result_type operator()(URBG& g, const param_type& parm); + + // property functions + result_type a() const; + result_type b() const; + param_type param() const; + void param(const param_type& parm); + result_type min() const; + result_type max() const; + }; \end{codeblock} @@ -4500,30 +4497,29 @@ \indexlibrary{\idxcode{bernoulli_distribution}}% \begin{codeblock} -class bernoulli_distribution -{ +class bernoulli_distribution { public: - // types - using result_type = bool; - using param_type = @\unspec@; - - // constructors and reset functions - explicit bernoulli_distribution(double p = 0.5); - explicit bernoulli_distribution(const param_type& parm); - void reset(); - - // generating functions - template - result_type operator()(URBG& g); - template - result_type operator()(URBG& g, const param_type& parm); - - // property functions - double p() const; - param_type param() const; - void param(const param_type& parm); - result_type min() const; - result_type max() const; + // types + using result_type = bool; + using param_type = @\unspec@; + + // constructors and reset functions + explicit bernoulli_distribution(double p = 0.5); + explicit bernoulli_distribution(const param_type& parm); + void reset(); + + // generating functions + template + result_type operator()(URBG& g); + template + result_type operator()(URBG& g, const param_type& parm); + + // property functions + double p() const; + param_type param() const; + void param(const param_type& parm); + result_type min() const; + result_type max() const; }; \end{codeblock} @@ -4575,32 +4571,31 @@ \indexlibrary{\idxcode{binomial_distribution}}% \begin{codeblock} template - class binomial_distribution -{ -public: - // types - using result_type = IntType; - using param_type = @\unspec@; - - // constructors and reset functions - explicit binomial_distribution(IntType t = 1, double p = 0.5); - explicit binomial_distribution(const param_type& parm); - void reset(); - - // generating functions - template - result_type operator()(URBG& g); - template - result_type operator()(URBG& g, const param_type& parm); - - // property functions - IntType t() const; - double p() const; - param_type param() const; - void param(const param_type& parm); - result_type min() const; - result_type max() const; -}; + class binomial_distribution { + public: + // types + using result_type = IntType; + using param_type = @\unspec@; + + // constructors and reset functions + explicit binomial_distribution(IntType t = 1, double p = 0.5); + explicit binomial_distribution(const param_type& parm); + void reset(); + + // generating functions + template + result_type operator()(URBG& g); + template + result_type operator()(URBG& g, const param_type& parm); + + // property functions + IntType t() const; + double p() const; + param_type param() const; + void param(const param_type& parm); + result_type min() const; + result_type max() const; + }; \end{codeblock} @@ -4660,31 +4655,30 @@ \indexlibrary{\idxcode{geometric_distribution}}% \begin{codeblock} template - class geometric_distribution -{ -public: - // types - using result_type = IntType; - using param_type = @\unspec@; - - // constructors and reset functions - explicit geometric_distribution(double p = 0.5); - explicit geometric_distribution(const param_type& parm); - void reset(); - - // generating functions - template - result_type operator()(URBG& g); - template - result_type operator()(URBG& g, const param_type& parm); - - // property functions - double p() const; - param_type param() const; - void param(const param_type& parm); - result_type min() const; - result_type max() const; - }; + class geometric_distribution { + public: + // types + using result_type = IntType; + using param_type = @\unspec@; + + // constructors and reset functions + explicit geometric_distribution(double p = 0.5); + explicit geometric_distribution(const param_type& parm); + void reset(); + + // generating functions + template + result_type operator()(URBG& g); + template + result_type operator()(URBG& g, const param_type& parm); + + // property functions + double p() const; + param_type param() const; + void param(const param_type& parm); + result_type min() const; + result_type max() const; + }; \end{codeblock} @@ -4739,32 +4733,31 @@ \indexlibrary{\idxcode{negative_binomial_distribution}}% \begin{codeblock} template - class negative_binomial_distribution -{ -public: - // types - using result_type = IntType; - using param_type = @\unspec@; - - // constructor and reset functions - explicit negative_binomial_distribution(IntType k = 1, double p = 0.5); - explicit negative_binomial_distribution(const param_type& parm); - void reset(); - - // generating functions - template - result_type operator()(URBG& g); - template - result_type operator()(URBG& g, const param_type& parm); - - // property functions - IntType k() const; - double p() const; - param_type param() const; - void param(const param_type& parm); - result_type min() const; - result_type max() const; -}; + class negative_binomial_distribution { + public: + // types + using result_type = IntType; + using param_type = @\unspec@; + + // constructor and reset functions + explicit negative_binomial_distribution(IntType k = 1, double p = 0.5); + explicit negative_binomial_distribution(const param_type& parm); + void reset(); + + // generating functions + template + result_type operator()(URBG& g); + template + result_type operator()(URBG& g, const param_type& parm); + + // property functions + IntType k() const; + double p() const; + param_type param() const; + void param(const param_type& parm); + result_type min() const; + result_type max() const; + }; \end{codeblock} @@ -4845,31 +4838,31 @@ \indexlibrary{\idxcode{poisson_distribution}}% \begin{codeblock} template - class poisson_distribution -{ -public: - // types - using result_type = IntType; - using param_type = @\unspec@; - - // constructors and reset functions - explicit poisson_distribution(double mean = 1.0); - explicit poisson_distribution(const param_type& parm); - void reset(); - - // generating functions - template - result_type operator()(URBG& g); - template - result_type operator()(URBG& g, const param_type& parm); - - // property functions - double mean() const; - param_type param() const; - void param(const param_type& parm); - result_type min() const; - result_type max() const; -}; + class poisson_distribution + { + public: + // types + using result_type = IntType; + using param_type = @\unspec@; + + // constructors and reset functions + explicit poisson_distribution(double mean = 1.0); + explicit poisson_distribution(const param_type& parm); + void reset(); + + // generating functions + template + result_type operator()(URBG& g); + template + result_type operator()(URBG& g, const param_type& parm); + + // property functions + double mean() const; + param_type param() const; + void param(const param_type& parm); + result_type min() const; + result_type max() const; + }; \end{codeblock} \indexlibrary{\idxcode{poisson_distribution}!constructor}% @@ -4919,31 +4912,30 @@ \indexlibrary{\idxcode{exponential_distribution}}% \begin{codeblock} template - class exponential_distribution -{ -public: - // types - using result_type = RealType; - using param_type = @\unspec@; - - // constructors and reset functions - explicit exponential_distribution(RealType lambda = 1.0); - explicit exponential_distribution(const param_type& parm); - void reset(); - - // generating functions - template - result_type operator()(URBG& g); - template - result_type operator()(URBG& g, const param_type& parm); - - // property functions - RealType lambda() const; - param_type param() const; - void param(const param_type& parm); - result_type min() const; - result_type max() const; -}; + class exponential_distribution { + public: + // types + using result_type = RealType; + using param_type = @\unspec@; + + // constructors and reset functions + explicit exponential_distribution(RealType lambda = 1.0); + explicit exponential_distribution(const param_type& parm); + void reset(); + + // generating functions + template + result_type operator()(URBG& g); + template + result_type operator()(URBG& g, const param_type& parm); + + // property functions + RealType lambda() const; + param_type param() const; + void param(const param_type& parm); + result_type min() const; + result_type max() const; + }; \end{codeblock} @@ -4995,32 +4987,31 @@ \indexlibrary{\idxcode{gamma_distribution}}% \begin{codeblock} template - class gamma_distribution -{ -public: - // types - using result_type = RealType; - using param_type = @\unspec@; - - // constructors and reset functions - explicit gamma_distribution(RealType alpha = 1.0, RealType beta = 1.0); - explicit gamma_distribution(const param_type& parm); - void reset(); - - // generating functions - template - result_type operator()(URBG& g); - template - result_type operator()(URBG& g, const param_type& parm); - - // property functions - RealType alpha() const; - RealType beta() const; - param_type param() const; - void param(const param_type& parm); - result_type min() const; - result_type max() const; -}; + class gamma_distribution { + public: + // types + using result_type = RealType; + using param_type = @\unspec@; + + // constructors and reset functions + explicit gamma_distribution(RealType alpha = 1.0, RealType beta = 1.0); + explicit gamma_distribution(const param_type& parm); + void reset(); + + // generating functions + template + result_type operator()(URBG& g); + template + result_type operator()(URBG& g, const param_type& parm); + + // property functions + RealType alpha() const; + RealType beta() const; + param_type param() const; + void param(const param_type& parm); + result_type min() const; + result_type max() const; + }; \end{codeblock} @@ -5085,32 +5076,31 @@ \indexlibrary{\idxcode{weibull_distribution}}% \begin{codeblock} template - class weibull_distribution -{ -public: - // types - using result_type = RealType; - using param_type = @\unspec@; - - // constructor and reset functions - explicit weibull_distribution(RealType a = 1.0, RealType b = 1.0); - explicit weibull_distribution(const param_type& parm); - void reset(); - - // generating functions - template - result_type operator()(URBG& g); - template - result_type operator()(URBG& g, const param_type& parm); - - // property functions - RealType a() const; - RealType b() const; - param_type param() const; - void param(const param_type& parm); - result_type min() const; - result_type max() const; -}; + class weibull_distribution { + public: + // types + using result_type = RealType; + using param_type = @\unspec@; + + // constructor and reset functions + explicit weibull_distribution(RealType a = 1.0, RealType b = 1.0); + explicit weibull_distribution(const param_type& parm); + void reset(); + + // generating functions + template + result_type operator()(URBG& g); + template + result_type operator()(URBG& g, const param_type& parm); + + // property functions + RealType a() const; + RealType b() const; + param_type param() const; + void param(const param_type& parm); + result_type min() const; + result_type max() const; + }; \end{codeblock} \indexlibrary{\idxcode{weibull_distribution}!constructor}% @@ -5181,32 +5171,31 @@ \indexlibrary{\idxcode{extreme_value_distribution}}% \begin{codeblock} template - class extreme_value_distribution -{ -public: - // types - using result_type = RealType; - using param_type = @\unspec@; - - // constructor and reset functions - explicit extreme_value_distribution(RealType a = 0.0, RealType b = 1.0); - explicit extreme_value_distribution(const param_type& parm); - void reset(); - - // generating functions - template - result_type operator()(URBG& g); - template - result_type operator()(URBG& g, const param_type& parm); - - // property functions - RealType a() const; - RealType b() const; - param_type param() const; - void param(const param_type& parm); - result_type min() const; - result_type max() const; -}; + class extreme_value_distribution { + public: + // types + using result_type = RealType; + using param_type = @\unspec@; + + // constructor and reset functions + explicit extreme_value_distribution(RealType a = 0.0, RealType b = 1.0); + explicit extreme_value_distribution(const param_type& parm); + void reset(); + + // generating functions + template + result_type operator()(URBG& g); + template + result_type operator()(URBG& g, const param_type& parm); + + // property functions + RealType a() const; + RealType b() const; + param_type param() const; + void param(const param_type& parm); + result_type min() const; + result_type max() const; + }; \end{codeblock} @@ -5294,32 +5283,31 @@ \indexlibrary{\idxcode{normal_distribution}}% \begin{codeblock} template - class normal_distribution -{ -public: - // types - using result_type = RealType; - using param_type = @\unspec@; - - // constructors and reset functions - explicit normal_distribution(RealType mean = 0.0, RealType stddev = 1.0); - explicit normal_distribution(const param_type& parm); - void reset(); - - // generating functions - template - result_type operator()(URBG& g); - template - result_type operator()(URBG& g, const param_type& parm); - - // property functions - RealType mean() const; - RealType stddev() const; - param_type param() const; - void param(const param_type& parm); - result_type min() const; - result_type max() const; -}; + class normal_distribution { + public: + // types + using result_type = RealType; + using param_type = @\unspec@; + + // constructors and reset functions + explicit normal_distribution(RealType mean = 0.0, RealType stddev = 1.0); + explicit normal_distribution(const param_type& parm); + void reset(); + + // generating functions + template + result_type operator()(URBG& g); + template + result_type operator()(URBG& g, const param_type& parm); + + // property functions + RealType mean() const; + RealType stddev() const; + param_type param() const; + void param(const param_type& parm); + result_type min() const; + result_type max() const; + }; \end{codeblock} @@ -5387,32 +5375,31 @@ \indexlibrary{\idxcode{lognormal_distribution}}% \begin{codeblock} template - class lognormal_distribution -{ -public: - // types - using result_type = RealType; - using param_type = @\unspec@; - - // constructor and reset functions - explicit lognormal_distribution(RealType m = 0.0, RealType s = 1.0); - explicit lognormal_distribution(const param_type& parm); - void reset(); - - // generating functions - template - result_type operator()(URBG& g); - template - result_type operator()(URBG& g, const param_type& parm); - - // property functions - RealType m() const; - RealType s() const; - param_type param() const; - void param(const param_type& parm); - result_type min() const; - result_type max() const; -}; + class lognormal_distribution { + public: + // types + using result_type = RealType; + using param_type = @\unspec@; + + // constructor and reset functions + explicit lognormal_distribution(RealType m = 0.0, RealType s = 1.0); + explicit lognormal_distribution(const param_type& parm); + void reset(); + + // generating functions + template + result_type operator()(URBG& g); + template + result_type operator()(URBG& g, const param_type& parm); + + // property functions + RealType m() const; + RealType s() const; + param_type param() const; + void param(const param_type& parm); + result_type min() const; + result_type max() const; + }; \end{codeblock} @@ -5475,31 +5462,30 @@ \indexlibrary{\idxcode{chi_squared_distribution}}% \begin{codeblock} template - class chi_squared_distribution -{ -public: - // types - using result_type = RealType; - using param_type = @\unspec@; - - // constructor and reset functions - explicit chi_squared_distribution(RealType n = 1); - explicit chi_squared_distribution(const param_type& parm); - void reset(); - - // generating functions - template - result_type operator()(URBG& g); - template - result_type operator()(URBG& g, const param_type& parm); - - // property functions - RealType n() const; - param_type param() const; - void param(const param_type& parm); - result_type min() const; - result_type max() const; -}; + class chi_squared_distribution { + public: + // types + using result_type = RealType; + using param_type = @\unspec@; + + // constructor and reset functions + explicit chi_squared_distribution(RealType n = 1); + explicit chi_squared_distribution(const param_type& parm); + void reset(); + + // generating functions + template + result_type operator()(URBG& g); + template + result_type operator()(URBG& g, const param_type& parm); + + // property functions + RealType n() const; + param_type param() const; + void param(const param_type& parm); + result_type min() const; + result_type max() const; + }; \end{codeblock} @@ -5551,32 +5537,31 @@ \indexlibrary{\idxcode{cauchy_distribution}}% \begin{codeblock} template - class cauchy_distribution -{ -public: - // types - using result_type = RealType; - using param_type = @\unspec@; - - // constructor and reset functions - explicit cauchy_distribution(RealType a = 0.0, RealType b = 1.0); - explicit cauchy_distribution(const param_type& parm); - void reset(); - - // generating functions - template - result_type operator()(URBG& g); - template - result_type operator()(URBG& g, const param_type& parm); - - // property functions - RealType a() const; - RealType b() const; - param_type param() const; - void param(const param_type& parm); - result_type min() const; - result_type max() const; -}; + class cauchy_distribution { + public: + // types + using result_type = RealType; + using param_type = @\unspec@; + + // constructor and reset functions + explicit cauchy_distribution(RealType a = 0.0, RealType b = 1.0); + explicit cauchy_distribution(const param_type& parm); + void reset(); + + // generating functions + template + result_type operator()(URBG& g); + template + result_type operator()(URBG& g, const param_type& parm); + + // property functions + RealType a() const; + RealType b() const; + param_type param() const; + void param(const param_type& parm); + result_type min() const; + result_type max() const; + }; \end{codeblock} @@ -5645,32 +5630,31 @@ \indexlibrary{\idxcode{fisher_f_distribution}}% \begin{codeblock} template - class fisher_f_distribution -{ -public: - // types - using result_type = RealType; - using param_type = @\unspec@; - - // constructor and reset functions - explicit fisher_f_distribution(RealType m = 1, RealType n = 1); - explicit fisher_f_distribution(const param_type& parm); - void reset(); - - // generating functions - template - result_type operator()(URBG& g); - template - result_type operator()(URBG& g, const param_type& parm); - - // property functions - RealType m() const; - RealType n() const; - param_type param() const; - void param(const param_type& parm); - result_type min() const; - result_type max() const; -}; + class fisher_f_distribution { + public: + // types + using result_type = RealType; + using param_type = @\unspec@; + + // constructor and reset functions + explicit fisher_f_distribution(RealType m = 1, RealType n = 1); + explicit fisher_f_distribution(const param_type& parm); + void reset(); + + // generating functions + template + result_type operator()(URBG& g); + template + result_type operator()(URBG& g, const param_type& parm); + + // property functions + RealType m() const; + RealType n() const; + param_type param() const; + void param(const param_type& parm); + result_type min() const; + result_type max() const; + }; \end{codeblock} @@ -5736,31 +5720,30 @@ \indexlibrary{\idxcode{student_t_distribution}}% \begin{codeblock} template - class student_t_distribution -{ -public: - // types - using result_type = RealType; - using param_type = @\unspec@; - - // constructor and reset functions - explicit student_t_distribution(RealType n = 1); - explicit student_t_distribution(const param_type& parm); - void reset(); - - // generating functions - template - result_type operator()(URBG& g); - template - result_type operator()(URBG& g, const param_type& parm); - - // property functions - RealType n() const; - param_type param() const; - void param(const param_type& parm); - result_type min() const; - result_type max() const; -}; + class student_t_distribution { + public: + // types + using result_type = RealType; + using param_type = @\unspec@; + + // constructor and reset functions + explicit student_t_distribution(RealType n = 1); + explicit student_t_distribution(const param_type& parm); + void reset(); + + // generating functions + template + result_type operator()(URBG& g); + template + result_type operator()(URBG& g, const param_type& parm); + + // property functions + RealType n() const; + param_type param() const; + void param(const param_type& parm); + result_type min() const; + result_type max() const; + }; \end{codeblock} @@ -5838,36 +5821,35 @@ \indexlibrary{\idxcode{discrete_distribution}}% \begin{codeblock} template - class discrete_distribution -{ -public: - // types - using result_type = IntType; - using param_type = @\unspec@; - - // constructor and reset functions - discrete_distribution(); - template - discrete_distribution(InputIterator firstW, InputIterator lastW); - discrete_distribution(initializer_list wl); - template - discrete_distribution(size_t nw, double xmin, double xmax, UnaryOperation fw); - explicit discrete_distribution(const param_type& parm); - void reset(); - - // generating functions - template - result_type operator()(URBG& g); - template - result_type operator()(URBG& g, const param_type& parm); - - // property functions - vector probabilities() const; - param_type param() const; - void param(const param_type& parm); - result_type min() const; - result_type max() const; -}; + class discrete_distribution { + public: + // types + using result_type = IntType; + using param_type = @\unspec@; + + // constructor and reset functions + discrete_distribution(); + template + discrete_distribution(InputIterator firstW, InputIterator lastW); + discrete_distribution(initializer_list wl); + template + discrete_distribution(size_t nw, double xmin, double xmax, UnaryOperation fw); + explicit discrete_distribution(const param_type& parm); + void reset(); + + // generating functions + template + result_type operator()(URBG& g); + template + result_type operator()(URBG& g, const param_type& parm); + + // property functions + vector probabilities() const; + param_type param() const; + void param(const param_type& parm); + result_type min() const; + result_type max() const; + }; \end{codeblock} \indexlibrary{\idxcode{discrete_distribution}!constructor} @@ -5894,7 +5876,7 @@ \begin{itemdescr} \pnum\requires \tcode{InputIterator} shall satisfy the requirements - of an input iterator (Table~\ref{tab:iterator.input.requirements}) type. + of an input iterator~(\ref{input.iterators}). Moreover, \tcode{iterator_traits::value_type} shall denote a type that is convertible to \tcode{double}. @@ -6016,39 +5998,39 @@ \indexlibrary{\idxcode{piecewise_constant_distribution}}% \begin{codeblock} template - class piecewise_constant_distribution -{ -public: - // types - using result_type = RealType; - using param_type = @\unspec@; - - // constructor and reset functions - piecewise_constant_distribution(); - template - piecewise_constant_distribution(InputIteratorB firstB, InputIteratorB lastB, - InputIteratorW firstW); - template - piecewise_constant_distribution(initializer_list bl, UnaryOperation fw); - template - piecewise_constant_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw); - explicit piecewise_constant_distribution(const param_type& parm); - void reset(); - - // generating functions - template - result_type operator()(URBG& g); - template - result_type operator()(URBG& g, const param_type& parm); - - // property functions - vector intervals() const; - vector densities() const; - param_type param() const; - void param(const param_type& parm); - result_type min() const; - result_type max() const; -}; + class piecewise_constant_distribution { + public: + // types + using result_type = RealType; + using param_type = @\unspec@; + + // constructor and reset functions + piecewise_constant_distribution(); + template + piecewise_constant_distribution(InputIteratorB firstB, InputIteratorB lastB, + InputIteratorW firstW); + template + piecewise_constant_distribution(initializer_list bl, UnaryOperation fw); + template + piecewise_constant_distribution(size_t nw, RealType xmin, RealType xmax, + UnaryOperation fw); + explicit piecewise_constant_distribution(const param_type& parm); + void reset(); + + // generating functions + template + result_type operator()(URBG& g); + template + result_type operator()(URBG& g, const param_type& parm); + + // property functions + vector intervals() const; + vector densities() const; + param_type param() const; + void param(const param_type& parm); + result_type min() const; + result_type max() const; + }; \end{codeblock} @@ -6240,39 +6222,38 @@ \indexlibrary{\idxcode{piecewise_linear_distribution}}% \begin{codeblock} template - class piecewise_linear_distribution -{ -public: - // types - using result_type = RealType; - using param_type = @\unspec@; - - // constructor and reset functions - piecewise_linear_distribution(); - template - piecewise_linear_distribution(InputIteratorB firstB, InputIteratorB lastB, - InputIteratorW firstW); - template - piecewise_linear_distribution(initializer_list bl, UnaryOperation fw); - template - piecewise_linear_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw); - explicit piecewise_linear_distribution(const param_type& parm); - void reset(); - - // generating functions - template - result_type operator()(URBG& g); - template - result_type operator()(URBG& g, const param_type& parm); - - // property functions - vector intervals() const; - vector densities() const; - param_type param() const; - void param(const param_type& parm); - result_type min() const; - result_type max() const; -}; + class piecewise_linear_distribution { + public: + // types + using result_type = RealType; + using param_type = @\unspec@; + + // constructor and reset functions + piecewise_linear_distribution(); + template + piecewise_linear_distribution(InputIteratorB firstB, InputIteratorB lastB, + InputIteratorW firstW); + template + piecewise_linear_distribution(initializer_list bl, UnaryOperation fw); + template + piecewise_linear_distribution(size_t nw, RealType xmin, RealType xmax, UnaryOperation fw); + explicit piecewise_linear_distribution(const param_type& parm); + void reset(); + + // generating functions + template + result_type operator()(URBG& g); + template + result_type operator()(URBG& g, const param_type& parm); + + // property functions + vector intervals() const; + vector densities() const; + param_type param() const; + void param(const param_type& parm); + result_type min() const; + result_type max() const; + }; \end{codeblock} \indexlibrary{\idxcode{piecewise_linear_distribution}!constructor} @@ -6417,6 +6398,7 @@ \pnum \indextext{\idxhdr{cstdlib}}% +\indexlibrary{\idxhdr{cstdlib}}% \begin{note} The header \tcode{}~(\ref{cstdlib.syn}) declares the functions described in this subclause. @@ -6447,7 +6429,7 @@ \begin{note} \indexlibrary{\idxcode{rand}!discouraged}% The other random -number generation facilities in this standard~(\ref{rand}) are often preferable +number generation facilities in this International Standard~(\ref{rand}) are often preferable to \tcode{rand}, because \tcode{rand}'s underlying algorithm is unspecified. Use of \tcode{rand} therefore continues to be non-portable, with unpredictable and oft-questionable quality and performance. @@ -6463,6 +6445,7 @@ \rSec1[numarray]{Numeric arrays} \rSec2[valarray.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{valarray}}% \indexlibrary{\idxhdr{valarray}}% \begin{codeblock} #include @@ -6765,6 +6748,8 @@ one-dimensional smart array, with elements numbered sequentially from zero. It is a representation of the mathematical concept of an ordered set of values. +For convenience, an object of type \tcode{valarray} is referred +to as an ``array'' throughout the remainder of~\ref{numarray}. The illusion of higher dimensionality may be produced by the familiar idiom of computed indices, together with the powerful subsetting capabilities provided @@ -6794,11 +6779,8 @@ \begin{itemdescr} \pnum \effects -Constructs an object of class -\tcode{valarray}\footnote{For convenience, such objects are referred -to as ``arrays'' throughout the -remainder of~\ref{numarray}.} -which has zero length.\footnote{This default constructor is essential, +Constructs a \tcode{valarray} +that has zero length.\footnote{This default constructor is essential, since arrays of \tcode{valarray} may be useful. @@ -6809,37 +6791,41 @@ \indexlibrary{\idxcode{valarray}!constructor}% \begin{itemdecl} -explicit valarray(size_t); +explicit valarray(size_t n); \end{itemdecl} \begin{itemdescr} \pnum -The array created by this constructor has a length equal to the value of the argument. -The elements of the array are value-initialized~(\ref{dcl.init}). +\effects +Constructs a \tcode{valarray} that has length \tcode{n}. +Each element of the array is value-initialized~(\ref{dcl.init}). \end{itemdescr} \indexlibrary{\idxcode{valarray}!constructor}% \begin{itemdecl} -valarray(const T&, size_t); +valarray(const T& v, size_t n); \end{itemdecl} \begin{itemdescr} \pnum -The array created by this constructor has a length equal to the second -argument. -The elements of the array are initialized with the value of the first argument. +\effects +Constructs a \tcode{valarray} that has length \tcode{n}. +Each element of the array is initialized with \tcode{v}. \end{itemdescr} \indexlibrary{\idxcode{valarray}!constructor}% \begin{itemdecl} -valarray(const T*, size_t); +valarray(const T* p, size_t n); \end{itemdecl} \begin{itemdescr} \pnum -The array created by this constructor has a length equal to the second -argument -\tcode{n}. +\requires +\tcode{p} points to an array~(\ref{dcl.array}) of at least +\tcode{n} elements. + +\effects +Constructs a \tcode{valarray} that has length \tcode{n}. The values of the elements of the array are initialized with the first \tcode{n} @@ -6847,22 +6833,19 @@ preferred method for converting a C array to a \tcode{valarray} object.} -If the value of the second argument is greater than the number of values -pointed to by the first argument, the behavior is undefined.% -\indextext{undefined} \end{itemdescr} \indexlibrary{\idxcode{valarray}!constructor}% \begin{itemdecl} -valarray(const valarray&); +valarray(const valarray& v); \end{itemdecl} \begin{itemdescr} \pnum -The array created by this constructor has the same length as the argument -array. +\effects +Constructs a \tcode{valarray} that has the same length as \tcode{v}. The elements are initialized with the values of the corresponding -elements of the argument array.\footnote{This copy constructor creates +elements of \tcode{v}.\footnote{This copy constructor creates a distinct array rather than an alias. Implementations in which arrays share storage are permitted, but they shall implement a copy-on-reference mechanism to ensure that arrays are @@ -6876,10 +6859,10 @@ \begin{itemdescr} \pnum -The array created by this constructor has the same length as the argument -array. +\effects +Constructs a \tcode{valarray} that has the same length as \tcode{v}. The elements are initialized with the values of the corresponding -elements of the argument array. +elements of \tcode{v}. \pnum \complexity Constant. @@ -6892,7 +6875,7 @@ \begin{itemdescr} \pnum -\effects Same as \tcode{valarray(il.begin(), il.size())}. +\effects Equivalent to \tcode{valarray(il.begin(), il.size())}. \end{itemdescr} \indexlibrary{\idxcode{valarray}!constructor}% @@ -6917,6 +6900,7 @@ \begin{itemdescr} \pnum +\effects The destructor is applied to every element of \tcode{*this}; an implementation may return all allocated memory. @@ -6931,16 +6915,19 @@ \begin{itemdescr} \pnum +\effects Each element of the \tcode{*this} -array is assigned the value of the corresponding element of the argument -array. -If the length of \tcode{v} is not equal to the length of \tcode{*this} -, resizes \tcode{*this} to make the two arrays the same length, +array is assigned the value of the corresponding element of \tcode{v}. +If the length of \tcode{v} is not equal to the length of \tcode{*this}, +resizes \tcode{*this} to make the two arrays the same length, as if by calling \tcode{resize(v.size())}, before performing the assignment. \pnum \postconditions \tcode{size() == v.size()}. + +\pnum +\returns \tcode{*this}. \end{itemdescr} \indexlibrarymember{operator=}{valarray}% @@ -6953,6 +6940,9 @@ \effects \tcode{*this} obtains the value of \tcode{v}. The value of \tcode{v} after the assignment is not specified. +\pnum +\returns \tcode{*this}. + \pnum \complexity Linear. \end{itemdescr} @@ -6964,23 +6954,22 @@ \begin{itemdescr} \pnum -\effects As if by: \tcode{*this = valarray(il);} - -\pnum -\returns \tcode{*this}. +\effects Equivalent to: \tcode{return *this = valarray(il);} \end{itemdescr} \indexlibrarymember{operator=}{valarray}% \begin{itemdecl} -valarray& operator=(const T&); +valarray& operator=(const T& v); \end{itemdecl} \begin{itemdescr} \pnum -The scalar assignment operator causes each element of the -\tcode{*this} -array to be assigned the value of the argument. +\effects +Assigns \tcode{v} to each element of \tcode{*this}. + +\pnum +\returns \tcode{*this}. \end{itemdescr} \indexlibrarymember{operator=}{valarray}% @@ -6994,100 +6983,65 @@ \begin{itemdescr} \pnum \requires The length of the array to which the argument refers equals \tcode{size()}. +The value of an element in the left-hand side of a \tcode{valarray} assignment +operator does not depend on the value of another element in that left-hand side. \pnum These operators allow the results of a generalized subscripting operation to be assigned directly to a \tcode{valarray}. - -\pnum -If the value of an element in the left-hand side of a valarray assignment -operator depends on the value of another element in that left-hand side, -the behavior is undefined. \end{itemdescr} \rSec3[valarray.access]{\tcode{valarray} element access} \indexlibrarymember{operator[]}{valarray}% \begin{itemdecl} -const T& operator[](size_t) const; -T& operator[](size_t); +const T& operator[](size_t n) const; +T& operator[](size_t n); \end{itemdecl} \begin{itemdescr} \pnum -The subscript operator -returns a reference to the corresponding element of the array. - -\pnum -Thus, the expression -\tcode{(a[i] = q, a[i]) == q} -evaluates as \tcode{true} for any non-constant -\tcode{valarray a}, -any -\tcode{T q}, -and for any -\tcode{size_t i} -such that the value of -\tcode{i} -is less than the length of -\tcode{a}. +\requires +\tcode{n < size()}. \pnum -The expression -\tcode{\&a[i+j] == \&a[i] + j} -evaluates as \tcode{true} for all -\tcode{size_t i} -and -\tcode{size_t j} -such that -\tcode{i+j} -is less than the length of the array -\tcode{a}. +\returns +A reference to the corresponding element of the array. +\begin{note} +The expression \tcode{(a[i] = q, a[i]) == q} +evaluates to \tcode{true} for any non-constant \tcode{valarray a}, +any \tcode{T q}, and for any \tcode{size_t i} +such that the value of \tcode{i} is less than the length of \tcode{a}. +\end{note} \pnum -Likewise, the expression -\tcode{\&a[i] != \&b[j]} -evaluates as -\tcode{true} -for any two arrays -\tcode{a} -and -\tcode{b} -and for any -\tcode{size_t i} -and -\tcode{size_t j} -such that -\tcode{i} -is less than the length of -\tcode{a} -and -\tcode{j} -is less than the length of -\tcode{b}. -This property indicates an absence of aliasing and may be used to -advantage by optimizing compilers.\footnote{Compilers may take advantage +\remarks +The expression \tcode{\&a[i+j] == \&a[i] + j} +evaluates to \tcode{true} for all \tcode{size_t i} and \tcode{size_t j} +such that \tcode{i+j < a.size()}. + +\pnum +The expression \tcode{\&a[i] != \&b[j]} +evaluates to \tcode{true} for any two arrays +\tcode{a} and \tcode{b} and for any +\tcode{size_t i} and \tcode{size_t j} +such that \tcode{i < a.size()} +and \tcode{j < b.size()}. +\begin{note} This property indicates an absence of aliasing and may be used to +advantage by optimizing compilers. Compilers may take advantage of inlining, constant propagation, loop fusion, tracking of pointers obtained from \tcode{operator new}, -and other -techniques to generate efficient -\tcode{valarray}s.} +and other techniques to generate efficient +\tcode{valarray}s. +\end{note} \pnum The reference returned by the subscript operator for an array shall be valid until the member function \tcode{resize(size_t, T)}~(\ref{valarray.members}) is called for that array or until the lifetime of that array ends, whichever happens first. - -\pnum -If the subscript operator -is invoked with a -\tcode{size_t} -argument whose value is not -less than the length of the array, the behavior is undefined.% -\indextext{undefined} \end{itemdescr} \rSec3[valarray.sub]{\tcode{valarray} subset operations} @@ -7110,7 +7064,7 @@ \begin{itemdescr} \pnum -\returns An object of class \tcode{valarray} containing those +\returns A \tcode{valarray} containing those elements of the controlled sequence designated by \tcode{slicearr}. \begin{example} \begin{codeblock} @@ -7145,7 +7099,7 @@ \begin{itemdescr} \pnum -\returns An object of class \tcode{valarray} containing those +\returns A \tcode{valarray} containing those elements of the controlled sequence designated by \tcode{gslicearr}. \begin{example} \begin{codeblock} @@ -7187,7 +7141,7 @@ \begin{itemdescr} \pnum -\returns An object of class \tcode{valarray} containing those +\returns A \tcode{valarray} containing those elements of the controlled sequence designated by \tcode{boolarr}. \begin{example} \begin{codeblock} @@ -7225,7 +7179,7 @@ \begin{itemdescr} \pnum -\returns An object of class \tcode{valarray} containing those +\returns A \tcode{valarray} containing those elements of the controlled sequence designated by \tcode{indarr}. \begin{example} \begin{codeblock} @@ -7271,6 +7225,7 @@ \begin{itemdescr} \pnum +\requires Each of these operators may only be instantiated for a type \tcode{T} to which the indicated operator can be applied and for which the indicated operator returns a value which is of type \tcode{T} (\tcode{bool} for @@ -7278,8 +7233,7 @@ \tcode{T} (\tcode{bool} for \tcode{operator!}). \pnum -Each of these operators returns an array whose length is equal to the length -of the array. +\returns A \tcode{valarray} whose length is \tcode{size()}. Each element of the returned array is initialized with the result of applying the indicated operator to the corresponding element of the array. \end{itemdescr} @@ -7294,43 +7248,45 @@ \indexlibrarymember{operator\caret=}{valarray}% \indexlibrarymember{operator\&=}{valarray}% \indexlibrarymember{operator"|=}{valarray}% -\indexlibrarymember{operator\shl=}{valarray}% -\indexlibrarymember{operator\shr=}{valarray}% +\indexlibrarymember{operator<<=}{valarray}% +\indexlibrarymember{operator>>=}{valarray}% \begin{itemdecl} -valarray& operator*= (const valarray&); -valarray& operator/= (const valarray&); -valarray& operator%= (const valarray&); -valarray& operator+= (const valarray&); -valarray& operator-= (const valarray&); -valarray& operator^= (const valarray&); -valarray& operator&= (const valarray&); -valarray& operator|= (const valarray&); -valarray& operator<<=(const valarray&); -valarray& operator>>=(const valarray&); +valarray& operator*= (const valarray& v); +valarray& operator/= (const valarray& v); +valarray& operator%= (const valarray& v); +valarray& operator+= (const valarray& v); +valarray& operator-= (const valarray& v); +valarray& operator^= (const valarray& v); +valarray& operator&= (const valarray& v); +valarray& operator|= (const valarray& v); +valarray& operator<<=(const valarray& v); +valarray& operator>>=(const valarray& v); \end{itemdecl} \begin{itemdescr} \pnum +\requires +\tcode{size() == v.size()}. Each of these operators may only be instantiated for a type \tcode{T} -to which the indicated operator can be applied. -Each of these operators -performs the indicated operation on each of its elements and the -corresponding element of the argument array. +if the indicated operator can be applied to two operands of type \tcode{T}. +The value of an element in the left-hand side of a valarray compound +assignment operator does not depend on the value of another element in that left +hand side. \pnum -The array is then returned by reference. +\effects +Each of these operators +performs the indicated operation on each of the elements of \tcode{*this} and the +corresponding element of \tcode{v}. \pnum -If the array and the -argument array do not have the same length, the behavior is undefined.% -\indextext{undefined} -The appearance of an array on the left-hand side of a compound assignment -does \tcode{not} invalidate references or pointers. +\returns +\tcode{*this}. \pnum -If the value of an element in the left-hand side of a valarray compound -assignment operator depends on the value of another element in that left -hand side, the behavior is undefined. +\remarks +The appearance of an array on the left-hand side of a compound assignment +does not invalidate references or pointers. \end{itemdescr} \indexlibrarymember{operator*=}{valarray}% @@ -7341,37 +7297,40 @@ \indexlibrarymember{operator\caret=}{valarray}% \indexlibrarymember{operator\&=}{valarray}% \indexlibrarymember{operator"|=}{valarray}% -\indexlibrarymember{operator\shl=}{valarray}% -\indexlibrarymember{operator\shr=}{valarray}% +\indexlibrarymember{operator<<=}{valarray}% +\indexlibrarymember{operator>>=}{valarray}% \begin{itemdecl} -valarray& operator*= (const T&); -valarray& operator/= (const T&); -valarray& operator%= (const T&); -valarray& operator+= (const T&); -valarray& operator-= (const T&); -valarray& operator^= (const T&); -valarray& operator&= (const T&); -valarray& operator|= (const T&); -valarray& operator<<=(const T&); -valarray& operator>>=(const T&); +valarray& operator*= (const T& v); +valarray& operator/= (const T& v); +valarray& operator%= (const T& v); +valarray& operator+= (const T& v); +valarray& operator-= (const T& v); +valarray& operator^= (const T& v); +valarray& operator&= (const T& v); +valarray& operator|= (const T& v); +valarray& operator<<=(const T& v); +valarray& operator>>=(const T& v); \end{itemdecl} \begin{itemdescr} \pnum +\requires Each of these operators may only be instantiated for a type \tcode{T} -to which the indicated operator can be applied. +if the indicated operator can be applied to two operands of type \tcode{T}. \pnum +\effects Each of these operators applies the indicated operation to each element -of the array and the non-array argument. +of \tcode{*this} and \tcode{v}. \pnum -The array is then returned by reference. +\returns +\tcode{*this} \pnum +\remarks The appearance of an array on the left-hand side of a compound assignment -does -\textit{not} +does not invalidate references or pointers to the elements of the array. \end{itemdescr} @@ -7410,22 +7369,21 @@ \end{itemdecl} \begin{itemdescr} +\pnum +\requires +\tcode{size() > 0}. This function may only be instantiated for a type \tcode{T} to which \tcode{operator+=} can be applied. -This function returns the sum of all the elements of the array. \pnum -If the array has length 0, the behavior is undefined.% -\indextext{undefined} -If the array has length 1, -\tcode{sum()} -returns the value of element 0. +\returns +The sum of all the elements of the array. +If the array has length 1, returns the value of element 0. Otherwise, the returned value is calculated by applying \tcode{operator+=} to a copy of an element of the array and all other elements of the array in an unspecified order.% -\indextext{unspecified behavior} \end{itemdescr} \indexlibrarymember{min}{valarray}% @@ -7435,11 +7393,13 @@ \begin{itemdescr} \pnum -This function returns the minimum value contained in -\tcode{*this}. -The value returned for an array of length 0 is undefined. -For an array -of length 1, the value of element 0 is returned. +\requires +\tcode{size() > 0} + +\pnum +\returns +The minimum value contained in \tcode{*this}. +For an array of length 1, the value of element 0 is returned. For all other array lengths, the determination is made using \tcode{operator<}. @@ -7452,11 +7412,13 @@ \begin{itemdescr} \pnum -This function returns the maximum value contained in -\tcode{*this}. -The value returned for an array of length 0 is undefined. -For an array -of length 1, the value of element 0 is returned. +\requires +\tcode{size() > 0}. + +\pnum +\returns +The maximum value contained in \tcode{*this}. +For an array of length 1, the value of element 0 is returned. For all other array lengths, the determination is made using \tcode{operator<}. @@ -7469,23 +7431,18 @@ \begin{itemdescr} \pnum -This function returns an object of class -\tcode{valarray} -of length -\tcode{size()}, -each of whose elements -\textit{I} -is -\tcode{(*this)[I + n]} -if -\tcode{I + n} +\returns +A \tcode{valarray} of length \tcode{size()}, each of whose elements +\placeholder{I} is +\tcode{(*this)[\placeholder{I} + n]} +if \tcode{\placeholder{I} + n} is non-negative and less than -\tcode{size()}, -otherwise -\tcode{T()}. -Thus if element zero is taken as the leftmost element, +\tcode{size()}, otherwise \tcode{T()}. +\begin{note} +If element zero is taken as the leftmost element, a positive value of \tcode{n} shifts the elements left \tcode{n} places, with zero fill. +\end{note} \pnum \begin{example} @@ -7502,11 +7459,12 @@ \begin{itemdescr} \pnum -This function returns an object of class -\tcode{valarray} -of length -\tcode{size()} -that is a circular shift of \tcode{*this}. If element zero is taken as the leftmost element, a non-negative value of \emph{n} shifts the elements circularly left \emph{n} places and a negative value of \emph{n} shifts the elements circularly right \emph{-n} places. +\returns +A \tcode{valarray} of length \tcode{size()} +that is a circular shift of \tcode{*this}. If element zero is taken as +the leftmost element, a non-negative value of $n$ shifts +the elements circularly left $n$ places and a negative +value of $n$ shifts the elements circularly right $-n$ places. \end{itemdescr} \indexlibrarymember{apply}{valarray}% @@ -7517,10 +7475,11 @@ \begin{itemdescr} \pnum -These functions return an array whose length is equal to the array. +\returns +A \tcode{valarray} whose length is \tcode{size()}. Each element of the returned array is assigned the value returned by applying the argument function to the -corresponding element of the array. +corresponding element of \tcode{*this}. \end{itemdescr} \indexlibrarymember{resize}{valarray}% @@ -7530,10 +7489,8 @@ \begin{itemdescr} \pnum -This member function changes the length of the -\tcode{*this} -array to -\tcode{sz} +\effects +Changes the length of the \tcode{*this} array to \tcode{sz} and then assigns to each element the value of the second argument. Resizing invalidates all pointers and references to elements in the array. \end{itemdescr} @@ -7550,8 +7507,8 @@ \indexlibrarymember{operator\caret}{valarray}% \indexlibrarymember{operator\&}{valarray}% \indexlibrarymember{operator"|}{valarray}% -\indexlibrarymember{operator\shl}{valarray}% -\indexlibrarymember{operator\shr}{valarray}% +\indexlibrarymember{operator<<}{valarray}% +\indexlibrarymember{operator>>}{valarray}% \begin{itemdecl} template valarray operator* (const valarray&, const valarray&); @@ -7577,21 +7534,20 @@ \begin{itemdescr} \pnum +\requires Each of these operators may only be instantiated for a type \tcode{T} to which the indicated operator can be applied and for which the indicated operator returns a value which is of type \tcode{T} or which can be unambiguously implicitly converted to type \tcode{T}. +The argument arrays have the same length. \pnum -Each of these operators returns an array whose length is equal to the +\returns +A \tcode{valarray} whose length is equal to the lengths of the argument arrays. Each element of the returned array is initialized with the result of applying the indicated operator to the corresponding elements of the argument arrays. - -\pnum -If the argument arrays do not have the same length, the behavior is undefined.% -\indextext{undefined} \end{itemdescr} \indexlibrarymember{operator*}{valarray}% @@ -7602,8 +7558,8 @@ \indexlibrarymember{operator\caret}{valarray}% \indexlibrarymember{operator\&}{valarray}% \indexlibrarymember{operator"|}{valarray}% -\indexlibrarymember{operator\shl}{valarray}% -\indexlibrarymember{operator\shr}{valarray}% +\indexlibrarymember{operator<<}{valarray}% +\indexlibrarymember{operator>>}{valarray}% \begin{itemdecl} template valarray operator* (const valarray&, const T&); template valarray operator* (const T&, const valarray&); @@ -7629,13 +7585,15 @@ \begin{itemdescr} \pnum +\requires Each of these operators may only be instantiated for a type \tcode{T} to which the indicated operator can be applied and for which the indicated operator returns a value which is of type \tcode{T} or which can be unambiguously implicitly converted to type \tcode{T}. \pnum -Each of these operators returns an array whose length is equal to the +\returns +A \tcode{valarray} whose length is equal to the length of the array argument. Each element of the returned array is initialized with the result of applying the indicated operator to the @@ -7673,22 +7631,21 @@ \begin{itemdescr} \pnum +\requires Each of these operators may only be instantiated for a type \tcode{T} to which the indicated operator can be applied and for which the indicated operator returns a value which is of type \tcode{bool} or which can be unambiguously implicitly converted to type \tcode{bool}. +The two array arguments have the same length. +\indextext{undefined} \pnum -Each of these operators returns a \tcode{bool} array whose length +\returns +A \tcode{valarray} whose length is equal to the length of the array arguments. Each element of the returned array is initialized with the result of applying the indicated operator to the corresponding elements of the argument arrays. - -\pnum -If the two array arguments do not have the same length, -the behavior is undefined.% -\indextext{undefined} \end{itemdescr} \indexlibrarymember{operator==}{valarray}% @@ -7720,13 +7677,15 @@ \begin{itemdescr} \pnum +\requires Each of these operators may only be instantiated for a type \tcode{T} to which the indicated operator can be applied and for which the indicated operator returns a value which is of type \tcode{bool} or which can be unambiguously implicitly converted to type \tcode{bool}. \pnum -Each of these operators returns a \tcode{bool} array whose +\returns +A \tcode{valarray} whose length is equal to the length of the array argument. Each element of the returned array is initialized with the result of applying the @@ -7778,6 +7737,7 @@ \begin{itemdescr} \pnum +\requires Each of these functions may only be instantiated for a type \tcode{T} to which a unique function with the indicated name can be applied (unqualified). This function shall return a value which is of type \tcode{T} @@ -7793,7 +7753,7 @@ \begin{itemdescr} \pnum -\effects As if by \tcode{x.swap(y)}. +\effects Equivalent to \tcode{x.swap(y)}. \end{itemdescr} @@ -7817,8 +7777,7 @@ \end{codeblock} \pnum -The -\tcode{slice} +The \tcode{slice} class represents a BLAS-like slice from an array. Such a slice is specified by a starting index, a length, and a stride.\footnote{BLAS stands for @@ -7965,8 +7924,8 @@ \indexlibrarymember{operator\caret=}{slice_array}% \indexlibrarymember{operator\&=}{slice_array}% \indexlibrarymember{operator"|=}{slice_array}% -\indexlibrarymember{operator\shl=}{slice_array}% -\indexlibrarymember{operator\shr=}{slice_array}% +\indexlibrarymember{operator<<=}{slice_array}% +\indexlibrarymember{operator>>=}{slice_array}% \begin{itemdecl} void operator*= (const valarray&) const; void operator/= (const valarray&) const; @@ -8045,10 +8004,8 @@ the \tcode{valarray} template, which is one-dimensional. -The set of one-dimensional index values specified by a -\tcode{gslice} -are $$k = s + \sum_ji_jd_j$$ -% \$k = s + sum from j \{ i sub j d sub j \}\$ +The set of one-dimensional index values specified by a \tcode{gslice} are +\[ k = s + \sum_j i_j d_j \] where the multidimensional indices $i_j$ range in value from 0 to $l_{ij} - 1$. @@ -8063,9 +8020,7 @@ stride = {19, 4, 1} \end{codeblock} yields the sequence of one-dimensional indices - -$$k = 3 + (0,1) \times 19 + (0,1,2,3) \times 4 + (0,1,2) \times 1$$ - +\[ k = 3 + (0, 1) \times 19 + (0, 1, 2, 3) \times 4 + (0, 1, 2) \times 1 \] which are ordered as shown in the following table: \begin{tabbing} @@ -8251,8 +8206,8 @@ \indexlibrarymember{operator\caret=}{gslice_array}% \indexlibrarymember{operator\&=}{gslice_array}% \indexlibrarymember{operator"|=}{gslice_array}% -\indexlibrarymember{operator\shl=}{gslice_array}% -\indexlibrarymember{operator\shr=}{gslice_array}% +\indexlibrarymember{operator<<=}{gslice_array}% +\indexlibrarymember{operator>>=}{gslice_array}% \begin{itemdecl} void operator*= (const valarray&) const; void operator/= (const valarray&) const; @@ -8378,8 +8333,8 @@ \indexlibrarymember{operator\caret=}{mask_array}% \indexlibrarymember{operator\&=}{mask_array}% \indexlibrarymember{operator"|=}{mask_array}% -\indexlibrarymember{operator\shl=}{mask_array}% -\indexlibrarymember{operator\shr=}{mask_array}% +\indexlibrarymember{operator<<=}{mask_array}% +\indexlibrarymember{operator>>=}{mask_array}% \begin{itemdecl} void operator*= (const valarray&) const; void operator/= (const valarray&) const; @@ -8520,8 +8475,8 @@ \indexlibrarymember{operator\caret=}{indirect_array}% \indexlibrarymember{operator\&=}{indirect_array}% \indexlibrarymember{operator"|=}{indirect_array}% -\indexlibrarymember{operator\shl=}{indirect_array}% -\indexlibrarymember{operator\shr=}{indirect_array}% +\indexlibrarymember{operator<<=}{indirect_array}% +\indexlibrarymember{operator>>=}{indirect_array}% \begin{itemdecl} void operator*= (const valarray&) const; void operator/= (const valarray&) const; @@ -8571,7 +8526,7 @@ object refers. \end{itemdescr} -\rSec2[valarray.range]{valarray range access} +\rSec2[valarray.range]{\tcode{valarray} range access} \pnum In the \tcode{begin} and \tcode{end} function templates that follow, \unspec{1} @@ -8601,7 +8556,7 @@ \begin{itemdescr} \pnum -\returns An iterator referencing the first value in the numeric array. +\returns An iterator referencing the first value in the array. \end{itemdescr} \indexlibrary{\idxcode{end}!\idxcode{valarray}}% @@ -8612,7 +8567,7 @@ \begin{itemdescr} \pnum -\returns An iterator referencing one past the last value in the numeric array. +\returns An iterator referencing one past the last value in the array. \end{itemdescr} @@ -8620,6 +8575,7 @@ \rSec2[numeric.ops.overview]{Header \tcode{} synopsis} +\indextext{\idxhdr{numeric}}% \indexlibrary{\idxhdr{numeric}}% \begin{codeblock} namespace std { @@ -8955,11 +8911,12 @@ \bigoh{\tcode{last - first}} applications of \tcode{binary_op}. \pnum -\realnotes +\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. +\end{note} \end{itemdescr} \rSec2[transform.reduce]{Transform reduce} @@ -8992,8 +8949,9 @@ \tcode{binary_op}. \pnum -\realnotes +\begin{note} \tcode{transform_reduce} does not apply \tcode{unary_op} to \tcode{init}. +\end{note} \end{itemdescr} \rSec2[inner.product]{Inner product} @@ -9081,7 +9039,7 @@ In the ranges \crange{first}{last} and -\mbox{\crange{result}{result + (last - first)}} +\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. } @@ -9143,7 +9101,8 @@ \pnum \effects Equivalent to: \begin{codeblock} -return exclusive_scan(std::forward(exec), first, last, result, init, plus<>()); +return exclusive_scan(std::forward(exec), + first, last, result, init, plus<>()); \end{codeblock} \end{itemdescr} @@ -9154,7 +9113,8 @@ OutputIterator exclusive_scan(InputIterator first, InputIterator last, OutputIterator result, T init, BinaryOperation binary_op); -template +template OutputIterator exclusive_scan(ExecutionPolicy&& exec, InputIterator first, InputIterator last, OutputIterator result, @@ -9170,9 +9130,12 @@ \pnum \effects -Assigns through each iterator \tcode{i} in \range{result}{result + (last - first)} the value of -\tcode{\textit{GENERALIZED_NONCOMMUTATIVE_SUM}(binary_op, init, *j, ...)} -for every \tcode{j} in \range{first}{first + (i - result)}. +For each integer \tcode{K} in \range{0}{last - first} +assigns through \tcode{result + K} the value of: +\begin{codeblock} +@\placeholdernc{GENERALIZED_NONCOMMUTATIVE_SUM}@( + binary_op, init, *(first + 0), *(first + 1), ..., *(first + K - 1)) +\end{codeblock} \pnum \returns @@ -9187,11 +9150,12 @@ \tcode{result} may be equal to \tcode{first}. \pnum -\realnotes +\begin{note} The difference between \tcode{exclusive_scan} and \tcode{inclusive_scan} is that \tcode{exclusive_scan} excludes the \tcode{i}th input element from the \tcode{i}th sum. If \tcode{binary_op} is not mathematically associative, the behavior of \tcode{exclusive_scan} may be nondeterministic. +\end{note} \end{itemdescr} \rSec2[inclusive.scan]{Inclusive scan} @@ -9244,7 +9208,8 @@ OutputIterator inclusive_scan(InputIterator first, InputIterator last, OutputIterator result, BinaryOperation binary_op, T init); -template +template OutputIterator inclusive_scan(ExecutionPolicy&& exec, InputIterator first, InputIterator last, OutputIterator result, @@ -9260,15 +9225,15 @@ \pnum \effects -Assigns through each iterator \tcode{i} in \range{result}{result + (last - first)} the value of +For each integer \tcode{K} in \range{0}{last - first} +assigns through \tcode{result + K} the value of \begin{itemize} \item -\tcode{\textit{GENERALIZED_NONCOMMUTATIVE_SUM}(binary_op, init, *j, ...)} -for every \tcode{j} in \range{first}{first + (i - result + 1)} -if \tcode{init} is provided, or + \tcode{\placeholdernc{GENERALIZED_NONCOMMUTATIVE_SUM}(\\\phantom{\tcode{\ \ \ \ }}binary_op, + init, *(first + 0), *(first + 1), ..., *(first + K))}\\if \tcode{init} is provided, or \item -\tcode{\textit{GENERALIZED_NONCOMMUTATIVE_SUM}(binary_op, *j, ...)} -for every \tcode{j} in \range{first}{first + (i - result + 1)} otherwise. + \tcode{\placeholdernc{GENERALIZED_NONCOMMUTATIVE_SUM}(\\\phantom{\tcode{\ \ \ \ }}binary_op, + *(first + 0), *(first + 1), ..., *(first + K))}\\otherwise. \end{itemize} \pnum @@ -9284,11 +9249,12 @@ \tcode{result} may be equal to \tcode{first}. \pnum -\realnotes +\begin{note} The difference between \tcode{exclusive_scan} and \tcode{inclusive_scan} is that \tcode{inclusive_scan} includes the \tcode{i}th input element in the \tcode{i}th sum. If \tcode{binary_op} is not mathematically associative, the behavior of \tcode{inclusive_scan} may be nondeterministic. +\end{note} \end{itemdescr} \rSec2[transform.exclusive.scan]{Transform exclusive scan} @@ -9322,9 +9288,13 @@ \pnum \effects -Assigns through each iterator \tcode{i} in \range{result}{result + (last - first)} the value of -\tcode{\textit{GENERALIZED_NONCOMMUTATIVE_SUM}(binary_op, init, unary_op(*j), ...)} -for every \tcode{j} in \range{first}{first + (i - result)}. +For each integer \tcode{K} in \range{0}{last - first} +assigns through \tcode{result + K} the value of: +\begin{codeblock} +@\placeholdernc{GENERALIZED_NONCOMMUTATIVE_SUM}@( + binary_op, init, + unary_op(*(first + 0)), unary_op(*(first + 1)), ..., unary_op(*(first + K - 1))) +\end{codeblock} \pnum \returns @@ -9340,13 +9310,14 @@ \tcode{result} may be equal to \tcode{first}. \pnum -\realnotes +\begin{note} The difference between \tcode{transform_exclusive_scan} and \tcode{transform_inclusive_scan} is that \tcode{transform_exclusive_scan} -excludes the ith input element from the ith sum. If \tcode{binary_op} is not +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} \rSec2[transform.inclusive.scan]{Transform inclusive scan} @@ -9395,15 +9366,15 @@ \pnum \effects -Assigns through each iterator \tcode{i} in \range{result}{result + (last - first)} the value of +For each integer \tcode{K} in \range{0}{last - first} +assigns through \tcode{result + K} the value of \begin{itemize} \item -\tcode{\textit{GENERALIZED_NONCOMMUTATIVE_SUM}(binary_op, init, unary_op(*j), ...)} -for every \tcode{j} in \range{first}{first + (i - result + 1)} -if \tcode{init} is provided, or + \tcode{\placeholdernc{GENERALIZED_NONCOMMUTATIVE_SUM}(\\\phantom{\tcode{\ \ \ \ }}binary_op, init,\\\phantom{\tcode{\ \ \ \ }}unary_op(*(first + 0)), unary_op(*(first + 1)), ..., unary_op(*(first + K)))}\\ + if \tcode{init} is provided, or \item -\tcode{\textit{GENERALIZED_NONCOMMUTATIVE_SUM}(binary_op, unary_op(*j), ...)} -for every \tcode{j} in \range{first}{first + (i - result + 1)} otherwise. + \tcode{\placeholdernc{GENERALIZED_NONCOMMUTATIVE_SUM}(\\\phantom{\tcode{\ \ \ \ }}binary_op,\\\phantom{\tcode{\ \ \ \ }}unary_op(*(first + 0)), unary_op(*(first + 1)), ..., unary_op(*(first + K)))}\\ + otherwise. \end{itemize} \pnum @@ -9420,13 +9391,14 @@ \tcode{result} may be equal to \tcode{first}. \pnum -\realnotes +\begin{note} The difference between \tcode{transform_exclusive_scan} and \tcode{transform_inclusive_scan} is that \tcode{transform_inclusive_scan} -includes the ith input element in the ith sum. If \tcode{binary_op} is not +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} \rSec2[adjacent.difference]{Adjacent difference} @@ -9540,7 +9512,7 @@ \pnum \remarks If either \tcode{M} or \tcode{N} is not an integer type, or -if either is (possibly cv-qualified) \tcode{bool}, the program is ill-formed. +if either is \cv{}~\tcode{bool}, the program is ill-formed. \pnum \returns @@ -9571,7 +9543,7 @@ \pnum \remarks If either \tcode{M} or \tcode{N} is not an integer type, or -if either is (possibly cv-qualified) \tcode{bool} the program is ill-formed. +if either is \cv{}~\tcode{bool} the program is ill-formed. \pnum \returns @@ -9588,7 +9560,8 @@ \rSec2[cmath.syn]{Header \tcode{} synopsis} -\indexlibrary{\idxhdr{cstdlib}}% +\indextext{\idxhdr{cmath}}% +\indexlibrary{\idxhdr{cmath}}% \indexlibrary{\idxcode{FP_FAST_FMA}}% \indexlibrary{\idxcode{FP_FAST_FMAF}}% \indexlibrary{\idxcode{FP_FAST_FMAL}}% @@ -10239,17 +10212,17 @@ float betaf(float x, float y); long double betal(long double x, long double y); - // \ref{sf.cmath.comp_ellint_1}, (complete) elliptic integral of the first kind + // \ref{sf.cmath.comp_ellint_1}, complete elliptic integral of the first kind double comp_ellint_1(double k); float comp_ellint_1f(float k); long double comp_ellint_1l(long double k); - // \ref{sf.cmath.comp_ellint_2}, (complete) elliptic integral of the second kind + // \ref{sf.cmath.comp_ellint_2}, complete elliptic integral of the second kind double comp_ellint_2(double k); float comp_ellint_2f(float k); long double comp_ellint_2l(long double k); - // \ref{sf.cmath.comp_ellint_3}, (complete) elliptic integral of the third kind + // \ref{sf.cmath.comp_ellint_3}, complete elliptic integral of the third kind double comp_ellint_3(double k, double nu); float comp_ellint_3f(float k, float nu); long double comp_ellint_3l(long double k, long double nu); @@ -10259,7 +10232,7 @@ float cyl_bessel_if(float nu, float x); long double cyl_bessel_il(long double nu, long double x); - // \ref{sf.cmath.cyl_bessel_j}, cylindrical Bessel functions (of the first kind) + // \ref{sf.cmath.cyl_bessel_j}, cylindrical Bessel functions of the first kind double cyl_bessel_j(double nu, double x); float cyl_bessel_jf(float nu, float x); long double cyl_bessel_jl(long double nu, long double x); @@ -10270,22 +10243,22 @@ long double cyl_bessel_kl(long double nu, long double x); // \ref{sf.cmath.cyl_neumann}, cylindrical Neumann functions; - // cylindrical Bessel functions (of the second kind): + // cylindrical Bessel functions of the second kind double cyl_neumann(double nu, double x); float cyl_neumannf(float nu, float x); long double cyl_neumannl(long double nu, long double x); - // \ref{sf.cmath.ellint_1}, (incomplete) elliptic integral of the first kind + // \ref{sf.cmath.ellint_1}, incomplete elliptic integral of the first kind double ellint_1(double k, double phi); float ellint_1f(float k, float phi); long double ellint_1l(long double k, long double phi); - // \ref{sf.cmath.ellint_2}, (incomplete) elliptic integral of the second kind + // \ref{sf.cmath.ellint_2}, incomplete elliptic integral of the second kind double ellint_2(double k, double phi); float ellint_2f(float k, float phi); long double ellint_2l(long double k, long double phi); - // \ref{sf.cmath.ellint_3}, (incomplete) elliptic integral of the third kind + // \ref{sf.cmath.ellint_3}, incomplete elliptic integral of the third kind double ellint_3(double k, double nu, double phi); float ellint_3f(float k, float nu, float phi); long double ellint_3l(long double k, long double nu, long double phi); @@ -10315,7 +10288,7 @@ float riemann_zetaf(float x); long double riemann_zetal(long double x); - // \ref{sf.cmath.sph_bessel}, spherical Bessel functions (of the first kind) + // \ref{sf.cmath.sph_bessel}, spherical Bessel functions of the first kind double sph_bessel(unsigned n, double x); float sph_besself(unsigned n, float x); long double sph_bessell(unsigned n, long double x); @@ -10326,7 +10299,7 @@ long double sph_legendrel(unsigned l, unsigned m, long double theta); // \ref{sf.cmath.sph_neumann}, spherical Neumann functions; - // spherical Bessel functions (of the second kind): + // spherical Bessel functions of the second kind: double sph_neumann(unsigned n, double x); float sph_neumannf(unsigned n, float x); long double sph_neumannl(unsigned n, long double x); @@ -10377,7 +10350,9 @@ \pnum \indextext{\idxhdr{cstdlib}}% +\indexlibrary{\idxhdr{cstdlib}}% \indextext{\idxhdr{cmath}}% +\indexlibrary{\idxhdr{cmath}}% \begin{note} The headers \tcode{}~(\ref{cstdlib.syn}) and \tcode{}~(\ref{cmath.syn}) @@ -10426,7 +10401,7 @@ \begin{itemdescr} \pnum -\returns $\sqrt{x^2+y^2+z^2} \mbox{.}$ +\returns $\sqrt{x^2+y^2+z^2}$. \end{itemdescr} \rSec2[c.math.fpclass]{Classification / comparison functions} @@ -10598,7 +10573,7 @@ $y$ is \tcode{y}. \end{itemdescr} -\rSec3[sf.cmath.comp_ellint_1]{(Complete) elliptic integral of the first kind}% +\rSec3[sf.cmath.comp_ellint_1]{Complete elliptic integral of the first kind}% \indexlibrary{\idxcode{comp_ellint_1}}% \indexlibrary{\idxcode{comp_ellint_1f}}% \indexlibrary{\idxcode{comp_ellint_1l}}% @@ -10629,7 +10604,7 @@ \pnum See also \ref{sf.cmath.ellint_1}. \end{itemdescr} -\rSec3[sf.cmath.comp_ellint_2]{(Complete) elliptic integral of the second kind}% +\rSec3[sf.cmath.comp_ellint_2]{Complete elliptic integral of the second kind}% \indexlibrary{\idxcode{comp_ellint_2}}% \indexlibrary{\idxcode{comp_ellint_2f}}% \indexlibrary{\idxcode{comp_ellint_2l}}% @@ -10661,7 +10636,7 @@ \pnum See also \ref{sf.cmath.ellint_2}. \end{itemdescr} -\rSec3[sf.cmath.comp_ellint_3]{(Complete) elliptic integral of the third kind}% +\rSec3[sf.cmath.comp_ellint_3]{Complete elliptic integral of the third kind}% \indexlibrary{\idxcode{comp_ellint_3}}% \indexlibrary{\idxcode{comp_ellint_3f}}% \indexlibrary{\idxcode{comp_ellint_3l}}% @@ -10688,7 +10663,7 @@ \] where $k$ is \tcode{k} and -$nu$ is \tcode{nu}. +$\nu$ is \tcode{nu}. \pnum See also \ref{sf.cmath.ellint_3}. \end{itemdescr} @@ -10723,7 +10698,7 @@ \quad \mbox{for $x \ge 0$} \] where -$nu$ is \tcode{nu} and +$\nu$ is \tcode{nu} and $x$ is \tcode{x}. \pnum\remarks @@ -10734,7 +10709,7 @@ \pnum See also \ref{sf.cmath.cyl_bessel_j}. \end{itemdescr} -\rSec3[sf.cmath.cyl_bessel_j]{Cylindrical Bessel functions (of the first kind)}% +\rSec3[sf.cmath.cyl_bessel_j]{Cylindrical Bessel functions of the first kind}% \indexlibrary{\idxcode{cyl_bessel_j}}% \indexlibrary{\idxcode{cyl_bessel_jf}}% \indexlibrary{\idxcode{cyl_bessel_jl}}% @@ -10762,12 +10737,12 @@ \quad \mbox{for $x \ge 0$} \] where -$nu$ is \tcode{nu} and +$\nu$ is \tcode{nu} and $x$ is \tcode{x}. \pnum\remarks The effect of calling each of these functions -is \impldef{effect of calling cylindrical Bessel functions (of the first kind) with \tcode{nu >= 128}} +is \impldef{effect of calling cylindrical Bessel functions of the first kind with \tcode{nu >= 128}} if \tcode{nu >= 128}. \end{itemdescr} @@ -10816,7 +10791,7 @@ \right. \] where -$nu$ is \tcode{nu} and +$\nu$ is \tcode{nu} and $x$ is \tcode{x}. \pnum\remarks @@ -10867,7 +10842,7 @@ \right. \] where -$nu$ is \tcode{nu} and +$\nu$ is \tcode{nu} and $x$ is \tcode{x}. \pnum\remarks @@ -10878,7 +10853,7 @@ \pnum See also \ref{sf.cmath.cyl_bessel_j}. \end{itemdescr} -\rSec3[sf.cmath.ellint_1]{(Incomplete) elliptic integral of the first kind}% +\rSec3[sf.cmath.ellint_1]{Incomplete elliptic integral of the first kind}% \indexlibrary{\idxcode{ellint_1}}% \indexlibrary{\idxcode{ellint_1f}}% \indexlibrary{\idxcode{ellint_1l}}% @@ -10907,10 +10882,10 @@ \] where $k$ is \tcode{k} and -$phi$ is \tcode{phi}. +$\phi$ is \tcode{phi}. \end{itemdescr} -\rSec3[sf.cmath.ellint_2]{(Incomplete) elliptic integral of the second kind}% +\rSec3[sf.cmath.ellint_2]{Incomplete elliptic integral of the second kind}% \indexlibrary{\idxcode{ellint_2}}% \indexlibrary{\idxcode{ellint_2f}}% \indexlibrary{\idxcode{ellint_2l}}% @@ -10938,10 +10913,10 @@ \] where $k$ is \tcode{k} and -$phi$ is \tcode{phi}. +$\phi$ is \tcode{phi}. \end{itemdescr} -\rSec3[sf.cmath.ellint_3]{(Incomplete) elliptic integral of the third kind}% +\rSec3[sf.cmath.ellint_3]{Incomplete elliptic integral of the third kind}% \indexlibrary{\idxcode{ellint_3}}% \indexlibrary{\idxcode{ellint_3f}}% \indexlibrary{\idxcode{ellint_3l}}% @@ -10969,9 +10944,9 @@ \quad \mbox{for $|k| \le 1$} \] where -$nu$ is \tcode{nu}, +$\nu$ is \tcode{nu}, $k$ is \tcode{k}, and -$phi$ is \tcode{phi}. +$\phi$ is \tcode{phi}. \end{itemdescr} \rSec3[sf.cmath.expint]{Exponential integral}% @@ -11160,7 +11135,7 @@ $x$ is \tcode{x}. \end{itemdescr} -\rSec3[sf.cmath.sph_bessel]{Spherical Bessel functions (of the first kind)}% +\rSec3[sf.cmath.sph_bessel]{Spherical Bessel functions of the first kind}% \indexlibrary{\idxcode{sph_bessel}}% \indexlibrary{\idxcode{sph_besself}}% \indexlibrary{\idxcode{sph_bessell}}% @@ -11236,7 +11211,7 @@ and $l$ is \tcode{l}, $m$ is \tcode{m}, and -$theta$ is \tcode{theta}. +$\theta$ is \tcode{theta}. \pnum\remarks The effect of calling each of these functions @@ -11289,6 +11264,7 @@ \rSec2[ctgmath.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{ctgmath}}% \indexlibrary{\idxhdr{ctgmath}}% \begin{codeblock} #include diff --git a/source/overloading.tex b/source/overloading.tex index 8839668f74..3c2bdc82af 100644 --- a/source/overloading.tex +++ b/source/overloading.tex @@ -66,12 +66,12 @@ \begin{itemize} \item -\indextext{return~type!overloading~and}% +\indextext{return type!overloading and}% Function declarations that differ only in the return type, the exception specification~(\ref{except.spec}), or both cannot be overloaded. \item -\indextext{\idxcode{static}!overloading~and}% +\indextext{\idxcode{static}!overloading and}% Member function declarations with the same name and the same parameter-type-list~(\ref{dcl.fct}) cannot be overloaded if any of them is a \tcode{static} @@ -92,7 +92,7 @@ these member function declarations can be overloaded if they differ in the type of their implicit object parameter. \begin{example} -the following illustrates this distinction: +The following illustrates this distinction: \begin{codeblock} class X { @@ -128,8 +128,8 @@ \end{itemize} \pnum -\indextext{equivalent~parameter~declarations}% -\indextext{equivalent~parameter~declarations!overloading~and}% +\indextext{equivalent parameter declarations}% +\indextext{equivalent parameter declarations!overloading and}% \begin{note} As specified in~\ref{dcl.fct}, function declarations that have equivalent parameter declarations declare @@ -138,42 +138,39 @@ \begin{itemize} \item -\indextext{\idxcode{typedef}!overloading~and}% +\indextext{\idxcode{typedef}!overloading and}% Parameter declarations that differ only in the use of equivalent typedef ``types'' are equivalent. A \tcode{typedef} is not a separate type, but only a synonym for another type~(\ref{dcl.typedef}). \begin{example} - \begin{codeblock} typedef int Int; void f(int i); void f(Int i); // OK: redeclaration of \tcode{f(int)} -void f(int i) @\tcode{\{ /* ... */ \}}@ -void f(Int i) @\tcode{\{ /* ... */ \}}@ // error: redefinition of \tcode{f(int)} - +void f(int i) { @\commentellip@ } +void f(Int i) { @\commentellip@ } // error: redefinition of \tcode{f(int)} \end{codeblock} \end{example} -\indextext{\idxcode{enum}!overloading~and}% +\indextext{\idxcode{enum}!overloading and}% Enumerations, on the other hand, are distinct types and can be used to distinguish overloaded function declarations. \begin{example} - \begin{codeblock} enum E { a }; -void f(int i) @\tcode{\{ /* ... */ \}}@ -void f(E i) @\tcode{\{ /* ... */ \}}@ +void f(int i) { @\commentellip@ } +void f(E i) { @\commentellip@ } \end{codeblock} \end{example} \item -\indextext{overloading!array~versus~pointer}% -\indextext{array!overloading~and pointer~versus}% +\indextext{overloading!array versus pointer}% +\indextext{array!overloading and pointer versus}% Parameter declarations that differ only in a pointer \tcode{*} versus an array @@ -199,8 +196,8 @@ \end{example} \item -\indextext{overloading!function~versus~pointer}% -\indextext{function!overloading~and pointer~versus}% +\indextext{overloading!function versus pointer}% +\indextext{function!overloading and pointer versus}% Parameter declarations that differ only in that one is a function type and the other is a pointer to the same function type are equivalent. That is, the function type is adjusted to become a pointer to function type~(\ref{dcl.fct}). @@ -215,8 +212,8 @@ \end{example} \item -\indextext{\idxcode{const}!overloading~and}% -\indextext{\idxcode{volatile}!overloading~and}% +\indextext{\idxcode{const}!overloading and}% +\indextext{\idxcode{volatile}!overloading and}% Parameter declarations that differ only in the presence or absence of \tcode{const} and/or @@ -231,14 +228,13 @@ declared, defined, or called. \begin{example} - \begin{codeblock} typedef const int cInt; int f (int); int f (const int); // redeclaration of \tcode{f(int)} -int f (int) @\tcode{\{ /* ... */ \}}@ // definition of \tcode{f(int)} -int f (cInt) @\tcode{\{ /* ... */ \}}@ // error: redefinition of \tcode{f(int)} +int f (int) { @\commentellip@ } // definition of \tcode{f(int)} +int f (cInt) { @\commentellip@ } // error: redefinition of \tcode{f(int)} \end{codeblock} \end{example} @@ -282,11 +278,11 @@ \tcode{volatile} \tcode{T}''. \item -\indextext{default~initializers!overloading~and}% +\indextext{default initializers!overloading and}% Two parameter declarations that differ only in their default arguments are equivalent. \begin{example} -consider the following: +Consider the following: \begin{codeblock} void f (int i, int j); @@ -327,8 +323,8 @@ }; \end{codeblock} -\indextext{name~hiding!function}% -\indextext{name~hiding!overloading versus}% +\indextext{name hiding!function}% +\indextext{name hiding!overloading versus}% Here \tcode{D::f(const char*)} hides @@ -525,10 +521,10 @@ parameter is \begin{itemize} -\item ``lvalue reference to \cv{} \tcode{X}'' for functions declared +\item ``lvalue reference to \cv{}~\tcode{X}'' for functions declared without a \grammarterm{ref-qualifier} or with the \tcode{\&} \grammarterm{ref-qualifier} -\item ``rvalue reference to \cv{} \tcode{X}'' for functions declared with the +\item ``rvalue reference to \cv{}~\tcode{X}'' for functions declared with the \tcode{\&\&} \grammarterm{ref-qualifier} \end{itemize} @@ -539,7 +535,7 @@ is the cv-qualification on the member function declaration. \begin{example} -for a +For a \tcode{const} member function of class @@ -712,8 +708,7 @@ that is the left operand of the \tcode{.} operator -has type ``\cv{} -\tcode{T}'' +has type ``\cv{}~\tcode{T}'' where \tcode{T} denotes a class\footnote{Note that cv-qualifiers on the type of objects are @@ -801,8 +796,7 @@ \grammarterm{primary-expression} \tcode{E} in the function call syntax evaluates -to a class object of type ``\cv{} -\tcode{T}'', +to a class object of type ``\cv{}~\tcode{T}'', then the set of candidate functions includes at least the function call operators of \tcode{T}. @@ -830,17 +824,18 @@ and where \grammarterm{conversion-type-id} denotes the type ``pointer to function -of (\tcode{P1},...,\tcode{Pn)} returning \tcode{R}'', +of ($\tcode{P}_1, \dotsc, \tcode{P}_n$) returning \tcode{R}'', or the type ``reference to pointer to function -of (\tcode{P1},...,\tcode{Pn)} returning \tcode{R}'', +of ($\tcode{P}_1, \dotsc, \tcode{P}_n$) returning \tcode{R}'', or the type -``reference to function of (\tcode{P1},...,\tcode{Pn)} +``reference to function of ($\tcode{P}_1, \dotsc, \tcode{P}_n$) returning \tcode{R}'', a \term{surrogate call function} with the unique name \grammarterm{call-function} and having the form \begin{ncbnf} -\terminal{R} call-function \terminal{(} conversion-type-id \terminal{F, P1 a1, ... ,Pn an)} \terminal{\{ return F (a1,... ,an); \}} +\terminal{R} call-function \terminal{(} conversion-type-id \ % +\terminal{F, P$_1$ a$_1$, $\dotsc$, P$_n$ a$_n$)} \terminal{\{ return F (a$_1$, $\dotsc$, a$_n$); \}} \end{ncbnf} is also considered as a candidate function. @@ -901,8 +896,7 @@ operator fp1() { return f1; } operator fp2() { return f2; } } a; -int i = a(1); // calls \tcode{f1} via pointer returned from - // conversion function +int i = a(1); // calls \tcode{f1} via pointer returned from conversion function \end{codeblock} \end{example}% \indextext{overloading!resolution!function call syntax|)} @@ -939,11 +933,9 @@ String operator + (const String&, const String&); void f() { - const char* p= "one" + "two"; // ill-formed because neither - // operand has class or enumeration type - int I = 1 + 1; // Always evaluates to \tcode{2} even if - // class or enumeration types exist that - // would perform the operation. + const char* p= "one" + "two"; // ill-formed because neither operand has class or enumeration type + int I = 1 + 1; // always evaluates to \tcode{2} even if class or enumeration types exist + // that would perform the operation. } \end{codeblock} \end{example} @@ -1011,15 +1003,13 @@ However, if no operand has a class type, only those non-member functions in the lookup set that have a first parameter of type \tcode{T1} -or ``reference to (possibly cv-qualified) -\tcode{T1}'', +or ``reference to \cv{}~\tcode{T1}'', when \tcode{T1} is an enumeration type, or (if there is a right operand) a second parameter of type \tcode{T2} -or ``reference to (possibly cv-qualified) -\tcode{T2}'', +or ``reference to \cv{}~\tcode{T2}'', when \tcode{T2} is an enumeration type, @@ -1084,7 +1074,7 @@ A operator+(const A&, const A&); void m() { A a, b; - a + b; // \tcode{operator+(a,b)} chosen over \tcode{int(a) + int(b)} + a + b; // \tcode{operator+(a, b)} chosen over \tcode{int(a) + int(b)} } \end{codeblock} \end{example} @@ -1107,8 +1097,8 @@ operator int*(); }; -int *a = Y() + 100.0; // error: pointer arithmetic requires integral operand -int *b = Y() + X(); // error: pointer arithmetic requires integral operand +int *a = Y() + 100.0; // error: pointer arithmetic requires integral operand +int *b = Y() + X(); // error: pointer arithmetic requires integral operand \end{codeblock} \end{example} @@ -1217,7 +1207,7 @@ are candidate functions. \item When the type of the initializer expression is a class type -``\cv{} \tcode{S}'', +``\cv{}~\tcode{S}'', the non-explicit conversion functions of \tcode{S} and its base classes are considered. @@ -1267,7 +1257,7 @@ Overload resolution is used to select the conversion function to be invoked. Assuming that ``\cvqual{cv1} \tcode{T}'' is the -type of the object being initialized, and ``\cv{} \tcode{S}'' is the type +type of the object being initialized, and ``\cv{}~\tcode{S}'' is the type of the initializer expression, with \tcode{S} a class type, @@ -1325,7 +1315,7 @@ conversion function to be invoked. Assuming that ``reference to \cvqual{cv1} \tcode{T}'' is the type of the reference being initialized, and -``\cv{} \tcode{S}'' is the type +``\cv{}~\tcode{S}'' is the type of the initializer expression, with \tcode{S} a class type, @@ -1339,8 +1329,8 @@ \tcode{S} and yield type ``lvalue reference to \cvqual{cv2} \tcode{T2}'' (when initializing an lvalue reference or an rvalue reference to function) or -``\nonterminal{cv2} \tcode{T2}'' -or ``rvalue reference to \nonterminal{cv2} \tcode{T2}'' (when initializing an +``\cvqual{cv2} \tcode{T2}'' +or ``rvalue reference to \cvqual{cv2} \tcode{T2}'' (when initializing an rvalue reference or an lvalue reference to function), where ``\cvqual{cv1} \tcode{T}'' is reference-compatible~(\ref{dcl.init.ref}) with ``\cvqual{cv2} \tcode{T2}'', @@ -1381,9 +1371,7 @@ performed again, where the candidate functions are all the constructors of the class \tcode{T} and the argument list consists of the elements of the initializer list. -\end{itemize}% -\indextext{overloading!argument lists|)}% -\indextext{overloading!candidate functions|)} +\end{itemize} If the initializer list has no elements and \tcode{T} has a default constructor, the first phase is omitted. @@ -1462,29 +1450,31 @@ }; int i; -A a1 = { i, i }; // error: explicit constructor \#1 selected in copy-list-initialization during deduction, - // cannot deduce from non-forwarding rvalue reference in \#2 +A a1 = { i, i }; // error: explicit constructor \#1 selected in copy-list-initialization during deduction, + // cannot deduce from non-forwarding rvalue reference in \#2 -A a2{i, i}; // OK, \#1 deduces to \tcode{A} and also initializes -A a3{0, i}; // OK, \#2 deduces to \tcode{A} and also initializes -A a4 = {0, i}; // OK, \#2 deduces to \tcode{A} and also initializes +A a2{i, i}; // OK, \#1 deduces to \tcode{A} and also initializes +A a3{0, i}; // OK, \#2 deduces to \tcode{A} and also initializes +A a4 = {0, i}; // OK, \#2 deduces to \tcode{A} and also initializes template A(const T&, const T&) -> A; // \#3 template explicit A(T&&, T&&) -> A; // \#4 -A a5 = {0, 1}; // error: explicit deduction guide \#4 selected in copy-list-initialization during deduction -A a6{0,1}; // OK, \#4 deduces to \tcode{A} and \#2 initializes -A a7 = {0, i}; // error: \#3 deduces to \tcode{A}, \#1 and \#2 declare same constructor -A a8{0,i}; // error: \#3 deduces to \tcode{A}, \#1 and \#2 declare same constructor +A a5 = {0, 1}; // error: explicit deduction guide \#4 selected in copy-list-initialization during deduction +A a6{0,1}; // OK, \#4 deduces to \tcode{A} and \#2 initializes +A a7 = {0, i}; // error: \#3 deduces to \tcode{A}, \#1 and \#2 declare same constructor +A a8{0,i}; // error: \#3 deduces to \tcode{A}, \#1 and \#2 declare same constructor template struct B { template using TA = T; template B(U, TA); }; -B b{(int*)0, (char*)0}; // OK, deduces \tcode{B} +B b{(int*)0, (char*)0}; // OK, deduces \tcode{B} \end{codeblock} -\end{example} +\end{example}% +\indextext{overloading!argument lists|)}% +\indextext{overloading!candidate functions|)} \rSec2[over.match.viable]{Viable functions}% \indextext{overloading!resolution!viable functions|(} @@ -1499,8 +1489,8 @@ than the ranking of conversion sequences. \pnum -\indextext{ellipsis!overload resolution~and}% -\indextext{default~argument!overload resolution~and}% +\indextext{ellipsis!overload resolution and}% +\indextext{default argument!overload resolution and}% First, to be a viable function, a candidate function shall have enough parameters to agree in number with the arguments in the list. @@ -1558,22 +1548,21 @@ \indextext{overloading!resolution!best viable function|(} \pnum -\indextext{conversion!overload resolution~and}% +\indextext{conversion!overload resolution and}% Define ICS\textit{i}(\tcode{F}) as follows: - \begin{itemize} \item -if +If \tcode{F} is a static member function, ICS\textit{1}(\tcode{F}) is defined such that ICS\textit{1}(\tcode{F}) is neither better nor worse than ICS\textit{1}(\tcode{G}) for any function \tcode{G}, and, symmetrically, ICS\textit{1}(\tcode{G}) is neither better nor worse than -ICS\textit{1}(\tcode{F})\footnote{If a function is a static member function, this +ICS\textit{1}(\tcode{F});\footnote{If a function is a static member function, this definition means that the first argument, the implied object argument, has no effect in the determination of whether the function is better -or worse than any other function.}; +or worse than any other function.} otherwise, \item let ICS\textit{i}(\tcode{F}) denote the implicit conversion sequence that converts @@ -1601,7 +1590,6 @@ ICS\textit{i}(\tcode{F1}) is not a worse conversion sequence than ICS\textit{i}(\tcode{F2}), and then \begin{itemize} - \item for some argument \textit{j}, @@ -1618,20 +1606,18 @@ is a better conversion sequence than the standard conversion sequence from the return type of \tcode{F2} -to the destination type. +to the destination type \begin{example} - \begin{codeblock} struct A { A(); operator int(); operator double(); } a; -int i = a; // \tcode{a.operator int()} followed by no conversion - // is better than \tcode{a.operator double()} followed by - // a conversion to \tcode{int} -float x = a; // ambiguous: both possibilities require conversions, - // and neither is better than the other +int i = a; // \tcode{a.operator int()} followed by no conversion is better than + // \tcode{a.operator double()} followed by a conversion to \tcode{int} +float x = a; // ambiguous: both possibilities require conversions, + // and neither is better than the other \end{codeblock} \end{example} or, if not that, @@ -1641,18 +1627,16 @@ return type of \tcode{F1} is the same kind of reference (i.e. lvalue or rvalue) as the reference being initialized, and the return type of \tcode{F2} is not \begin{example} - \begin{codeblock} template struct A { - operator T&(); // \#1 - operator T&&(); // \#2 + operator T&(); // \#1 + operator T&&(); // \#2 }; typedef int Fn(); A a; -Fn& lf = a; // calls \#1 -Fn&& rf = a; // calls \#2 +Fn& lf = a; // calls \#1 +Fn&& rf = a; // calls \#2 \end{codeblock} - \end{example} or, if not that, @@ -1663,15 +1647,15 @@ \begin{example} \begin{codeblock} template struct A { - A(T, int*); // \#1 - A(A&, int*); // \#2 + A(T, int*); // \#1 + A(A&, int*); // \#2 enum { value }; }; template A(T&&, int*) -> A; // \#3 -A a{1, 0}; // uses \#1 to deduce \tcode{A} and initializes with \#1 -A b{a, 0}; // uses \#3 (not \#2) to deduce \tcode{A\&>} and initializes with \#1 +A a{1, 0}; // uses \#1 to deduce \tcode{A} and initializes with \#1 +A b{a, 0}; // uses \#3 (not \#2) to deduce \tcode{A\&>} and initializes with \#1 \end{codeblock} \end{example} or, if not that, @@ -1701,7 +1685,7 @@ \pnum If there is exactly one viable function that is a better function than all other viable functions, then it is the one selected by -overload resolution; otherwise the call is ill-formed\footnote{The algorithm +overload resolution; otherwise the call is ill-formed.\footnote{The algorithm for selecting the best viable function is linear in the number of viable functions. @@ -1735,10 +1719,8 @@ the viable functions to verify that \tcode{W} -is better than all other functions.}. - +is better than all other functions.} \begin{example} - \begin{codeblock} void Fcn(const int*, short); void Fcn(int*, int); @@ -1747,17 +1729,14 @@ short s = 0; void f() { - Fcn(&i, s); // is ambiguous because - // \tcode{\&i} $\to$ \tcode{int*} is better than \tcode{\&i} $\to$ \tcode{const int*} - // but \tcode{s} $\to$ \tcode{short} is also better than \tcode{s} $\to$ \tcode{int} + Fcn(&i, s); // is ambiguous because \tcode{\&i} $\to$ \tcode{int*} is better than \tcode{\&i} $\to$ \tcode{const int*} + // but \tcode{s} $\to$ \tcode{short} is also better than \tcode{s} $\to$ \tcode{int} - Fcn(&i, 1L); // calls \tcode{Fcn(int*, int)}, because - // \tcode{\&i} $\to$ \tcode{int*} is better than \tcode{\&i} $\to$ \tcode{const int*} - // and \tcode{1L} $\to$ \tcode{short} and \tcode{1L} $\to$ \tcode{int} are indistinguishable + Fcn(&i, 1L); // calls \tcode{Fcn(int*, int)}, because \tcode{\&i} $\to$ \tcode{int*} is better than \tcode{\&i} $\to$ \tcode{const int*} + // and \tcode{1L} $\to$ \tcode{short} and \tcode{1L} $\to$ \tcode{int} are indistinguishable - Fcn(&i,'c'); // calls \tcode{Fcn(int*, int)}, because - // \tcode{\&i} $\to$ \tcode{int*} is better than \tcode{\&i} $\to$ \tcode{const int*} - // and \tcode{c} $\to$ \tcode{int} is better than \tcode{c} $\to$ \tcode{short} + Fcn(&i, 'c'); // calls \tcode{Fcn(int*, int)}, because \tcode{\&i} $\to$ \tcode{int*} is better than \tcode{\&i} $\to$ \tcode{const int*} + // and \tcode{c} $\to$ \tcode{int} is better than \tcode{c} $\to$ \tcode{short} } \end{codeblock} \end{example} @@ -1771,7 +1750,6 @@ --- specify a default argument that made the function viable, the program is ill-formed. \begin{example} - \begin{codeblock} namespace A { extern "C" void f(int = 5); @@ -1784,8 +1762,8 @@ using B::f; void use() { - f(3); // OK, default argument was not used for viability - f(); // Error: found default argument twice + f(3); // OK, default argument was not used for viability + f(); // Error: found default argument twice } \end{codeblock} \end{example} @@ -1852,7 +1830,7 @@ when the initializer list has exactly one element that is itself an initializer list, and the target is the first parameter of a constructor of class \tcode{X}, and -the conversion is to \tcode{X} or reference to (possibly cv-qualified) \tcode{X}, +the conversion is to \tcode{X} or reference to \cv{}~\tcode{X}, \end{itemize} user-defined conversion sequences are not considered. \begin{note} @@ -1863,12 +1841,12 @@ \begin{codeblock} struct Y { Y(int); }; struct A { operator int(); }; - Y y1 = A(); // error: \tcode{A::operator int()} is not a candidate + Y y1 = A(); // error: \tcode{A::operator int()} is not a candidate struct X { }; struct B { operator X(); }; B b; - X x({b}); // error: \tcode{B::operator X()} is not a candidate + X x({b}); // error: \tcode{B::operator X()} is not a candidate \end{codeblock} \end{example} @@ -1890,7 +1868,7 @@ Any difference in top-level cv-qualification is subsumed by the initialization itself and does not constitute a conversion. \begin{example} -a parameter of type +A parameter of type \tcode{A} can be initialized from an argument of type \tcode{const A}. @@ -1937,56 +1915,26 @@ For the purpose of ranking implicit conversion sequences as described in~\ref{over.ics.rank}, the ambiguous conversion sequence is treated as a user-defined conversion sequence that is indistinguishable from any -other user-defined conversion sequence\footnote{The ambiguous conversion -sequence is ranked with user-defined -conversion sequences because multiple conversion sequences -for an argument can exist only if they involve different -user-defined conversions. The ambiguous conversion sequence -is indistinguishable from any other user-defined conversion -sequence because it represents at least two user-defined conversion -sequences, each with a different user-defined conversion, and -any other user-defined conversion sequence must be -indistinguishable from at least one of them. - +other user-defined conversion sequence. +\begin{note} This rule prevents a function from becoming non-viable because of an ambiguous conversion sequence for one of its parameters. -Consider this example, - -\begin{ttfamily} -\begin{tabbing} -\hspace{2in}\=\kill% -\indent class B;\\ -\indent class A \{ A (B\&);\};\\ -\indent class B \{ operator A (); \};\\ -\indent class C \{ C (B\&); \};\\ -\indent void f(A) \{ \}\\ -\indent void f(C) \{ \}\\ -\indent B b;\\ -\indent f(b);\>\textrm{// ambiguous because \tcode{b} $\to$ \tcode{C} via constructor and}\\ -\indent \>\textrm{// \tcode{b} $\to$ \tcode{A} via constructor or conversion function.} -\end{tabbing} -\end{ttfamily} - -If it were not for this rule, -\tcode{f(A)} -would be eliminated as a viable -function for the call -\tcode{f(b)} -causing overload resolution to select -\tcode{f(C)} -as the function to call even though it is not clearly the best -choice. -On the other hand, if an -\tcode{f(B)} -were to be declared then -\tcode{f(b)} -would resolve to that -\tcode{f(B)} -because the exact match -with -\tcode{f(B)} -is better than any of the sequences required to match -\tcode{f(A)}.}. +\begin{example} +\begin{codeblock} +class B; +class A { A (B&);}; +class B { operator A (); }; +class C { C (B&); }; +void f(A) { } +void f(C) { } +B b; +f(b); // ill-formed: ambiguous because there is a conversion \tcode{b} $\to$ \tcode{C} (via constructor) + // and an (ambiguous) conversion \tcode{b} $\to$ \tcode{A} (via constructor or conversion function) +void f(B) { } +f(b); // OK, unambiguous +\end{codeblock} +\end{example} +\end{note} If a function that uses the ambiguous conversion sequence is selected as the best viable function, the call will be ill-formed because the conversion of one of the arguments in the call is ambiguous. @@ -2104,7 +2052,7 @@ \rSec4[over.ics.ellipsis]{Ellipsis conversion sequences} \pnum -\indextext{ellipsis!conversion~sequence}% +\indextext{ellipsis!conversion sequence}% An ellipsis conversion sequence occurs when an argument in a function call is matched with the ellipsis parameter specification of the function called (see~\ref{expr.call}). @@ -2124,8 +2072,7 @@ struct B : public A {} b; int f(A&); int f(B&); -int i = f(b); // calls \tcode{f(B\&)}, an exact match, rather than - // \tcode{f(A\&)}, a conversion +int i = f(b); // calls \tcode{f(B\&)}, an exact match, rather than \tcode{f(A\&)}, a conversion \end{codeblock} \end{example} If the parameter binds directly to the result of @@ -2166,7 +2113,7 @@ do not affect the formation of a standard conversion sequence, however. \begin{example} -a function with an ``lvalue reference to \tcode{int}'' parameter can +A function with an ``lvalue reference to \tcode{int}'' parameter can be a viable candidate even if the corresponding argument is an \tcode{int} bit-field. @@ -2190,7 +2137,7 @@ \pnum If the parameter type is an aggregate class \tcode{X} and the initializer list has a -single element of type \cv{} \tcode{U}, where \tcode{U} is \tcode{X} +single element of type \cv{}~\tcode{U}, where \tcode{U} is \tcode{X} or a class derived from \tcode{X}, the implicit conversion sequence is the one required to convert the element to the parameter type. @@ -2212,24 +2159,24 @@ the context of a call to an initializer-list constructor. \begin{example} \begin{codeblock} void f(std::initializer_list); -f( {} ); // OK: \tcode{f(initializer_list)} identity conversion -f( {1,2,3} ); // OK: \tcode{f(initializer_list)} identity conversion -f( {'a','b'} ); // OK: \tcode{f(initializer_list)} integral promotion -f( {1.0} ); // error: narrowing +f( {} ); // OK: \tcode{f(initializer_list)} identity conversion +f( {1,2,3} ); // OK: \tcode{f(initializer_list)} identity conversion +f( {'a','b'} ); // OK: \tcode{f(initializer_list)} integral promotion +f( {1.0} ); // error: narrowing struct A { - A(std::initializer_list); // \#1 - A(std::initializer_list>); // \#2 - A(std::initializer_list); // \#3 + A(std::initializer_list); // \#1 + A(std::initializer_list>); // \#2 + A(std::initializer_list); // \#3 }; -A a{ 1.0,2.0 }; // OK, uses \#1 +A a{ 1.0,2.0 }; // OK, uses \#1 void g(A); -g({ "foo", "bar" }); // OK, uses \#3 +g({ "foo", "bar" }); // OK, uses \#3 typedef int IA[3]; void h(const IA&); -h({ 1, 2, 3 }); // OK: identity conversion +h({ 1, 2, 3 }); // OK: identity conversion \end{codeblock} \end{example} @@ -2248,7 +2195,7 @@ \begin{itemize} \item If \tcode{C} is not an initializer-list constructor -and the initializer list has a single element of type \cv{} \tcode{U}, +and the initializer list has a single element of type \cv{}~\tcode{U}, where \tcode{U} is \tcode{X} or a class derived from \tcode{X}, the implicit conversion sequence has Exact Match rank if \tcode{U} is \tcode{X}, or Conversion rank if \tcode{U} is derived from \tcode{X}. @@ -2261,35 +2208,36 @@ the others, the implicit conversion sequence is the ambiguous conversion sequence. User-defined conversions are allowed for conversion of the initializer list elements to the constructor parameter types except as noted -in~\ref{over.best.ics}. \begin{example} +in~\ref{over.best.ics}. +\begin{example} \begin{codeblock} struct A { A(std::initializer_list); }; void f(A); -f( {'a', 'b'} ); // OK: \tcode{f(A(std::initializer_list))} user-defined conversion +f( {'a', 'b'} ); // OK: \tcode{f(A(std::initializer_list))} user-defined conversion struct B { B(int, double); }; void g(B); -g( {'a', 'b'} ); // OK: \tcode{g(B(int,double))} user-defined conversion -g( {1.0, 1.0} ); // error: narrowing +g( {'a', 'b'} ); // OK: \tcode{g(B(int, double))} user-defined conversion +g( {1.0, 1.0} ); // error: narrowing void f(B); -f( {'a', 'b'} ); // error: ambiguous \tcode{f(A)} or \tcode{f(B)} +f( {'a', 'b'} ); // error: ambiguous \tcode{f(A)} or \tcode{f(B)} struct C { C(std::string); }; void h(C); -h({"foo"}); // OK: \tcode{h(C(std::string("foo")))} +h({"foo"}); // OK: \tcode{h(C(std::string("foo")))} struct D { D(A, C); }; void i(D); -i({ {1,2}, {"bar"} }); // OK: \tcode{i(D(A(std::initializer_list\{1,2\}),C(std::string("bar"))))} +i({ {1,2}, {"bar"} }); // OK: \tcode{i(D(A(std::initializer_list\{1,2\}), C(std::string("bar"))))} \end{codeblock} \end{example} @@ -2306,8 +2254,8 @@ }; void f(A); -f( {'a', 'b'} ); // OK: \tcode{f(A(int,double))} user-defined conversion -f( {1.0} ); // error: narrowing +f( {'a', 'b'} ); // OK: \tcode{f(A(int,double))} user-defined conversion +f( {1.0} ); // error: narrowing \end{codeblock} \end{example} @@ -2322,11 +2270,11 @@ }; void f(const A&); -f( {'a', 'b'} ); // OK: \tcode{f(A(int,double))} user-defined conversion -f( {1.0} ); // error: narrowing +f( {'a', 'b'} ); // OK: \tcode{f(A(int,double))} user-defined conversion +f( {1.0} ); // error: narrowing void g(const double &); -g({1}); // same conversion as \tcode{int} to \tcode{double} +g({1}); // same conversion as \tcode{int} to \tcode{double} \end{codeblock} \end{example} @@ -2339,8 +2287,8 @@ the parameter type; \begin{example} \begin{codeblock} void f(int); -f( {'a'} ); // OK: same conversion as \tcode{char} to \tcode{int} -f( {1.0} ); // error: narrowing +f( {'a'} ); // OK: same conversion as \tcode{char} to \tcode{int} +f( {1.0} ); // error: narrowing \end{codeblock} \end{example} @@ -2348,7 +2296,7 @@ is the identity conversion. \begin{example} \begin{codeblock} void f(int); -f( { } ); // OK: identity conversion +f( { } ); // OK: identity conversion \end{codeblock} \end{example} \end{itemize} @@ -2359,7 +2307,7 @@ \rSec3[over.ics.rank]{Ranking implicit conversion sequences} \pnum -\ref{over.ics.rank} defines a partial ordering of implicit conversion +This subclause defines a partial ordering of implicit conversion sequences based on the relationships \term{better conversion sequence} and @@ -2431,7 +2379,7 @@ \begin{itemize} \item -\indextext{subsequence~rule!overloading}% +\indextext{subsequence rule!overloading}% \tcode{S1} is a proper subsequence of \tcode{S2} @@ -2457,8 +2405,7 @@ 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 -rvalue and \tcode{S2} binds an lvalue reference. - +rvalue and \tcode{S2} binds an lvalue reference \begin{example} \begin{codeblock} int i; @@ -2476,11 +2423,11 @@ void p() &&; }; A& operator<<(A&&, char); -A() << 1; // calls \tcode{A::operator\shl(int)} -A() << 'c'; // calls \tcode{operator\shl(A\&\&, char)} +A() << 1; // calls \tcode{A::operator<<(int)} +A() << 'c'; // calls \tcode{operator<<(A\&\&, char)} A a; -a << 1; // calls \tcode{A::operator\shl(int)} -a << 'c'; // calls \tcode{A::operator\shl(int)} +a << 1; // calls \tcode{A::operator<<(int)} +a << 'c'; // calls \tcode{A::operator<<(int)} A().p(); // calls \tcode{A::p()\&\&} a.p(); // calls \tcode{A::p()\&} \end{codeblock} @@ -2490,7 +2437,8 @@ \item \tcode{S1} and \tcode{S2} are reference bindings~(\ref{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} +an rvalue reference to a function lvalue +\begin{example} \begin{codeblock} int f(void(&)()); // \#1 int f(void(&&)()); // \#2 @@ -2510,9 +2458,8 @@ \tcode{T2}~(\ref{conv.qual}), respectively, and the cv-qualification signature of type \tcode{T1} is a proper subset of the cv-qualification signature of type -\tcode{T2}. +\tcode{T2} \begin{example} - \begin{codeblock} int f(const volatile int *); int f(const int *); @@ -2534,7 +2481,6 @@ \tcode{S1} refers. \begin{example} - \begin{codeblock} int f(const int &); int f(int &); @@ -2742,7 +2688,7 @@ \rSec1[over.over]{Address of overloaded function}% \indextext{overloading!address of overloaded function}% -\indextext{overloaded~function!address~of} +\indextext{overloaded function!address of} \pnum A use of an overloaded function name without arguments is resolved @@ -2940,7 +2886,7 @@ \>new\>delete\>new[]\>delete[]\br \>+\>-\>*\>/\>\%\>\caret\>\&\>|\>\~\br \>!\>=\><\>>\>+=\>-=\>*=\>/=\>\%=\br -\>\caret=\>\&=\>|=\>\shl\>\shr\>\shr=\>\shl=\>={=}\>!=\br +\>\caret=\>\&=\>|=\><<\>>>\>>>=\><<=\>={=}\>!=\br \><=\>>=\>\&\&\>|{|}\>++\>-{-}\>,\>->*\>->\br \>(\,)\>[\,] \end{bnfkeywordtab} @@ -2957,7 +2903,7 @@ are formed from more than one token. \end{note} \indextext{operator!subscripting}% -\indextext{operator!function~call}% +\indextext{operator!function call}% \pnum Both the unary and binary forms of @@ -2969,7 +2915,7 @@ can be overloaded. \pnum -\indextext{restriction!operator~overloading}% +\indextext{restriction!operator overloading}% The following operators cannot be overloaded: \begin{codeblock} @@ -2983,7 +2929,7 @@ (Clause~\ref{cpp}). \pnum -\indextext{call!operator~function}% +\indextext{call!operator function}% Operator functions are usually not called directly; instead they are invoked to evaluate the operators they implement~(\ref{over.unary} -- \ref{over.inc}). They can be explicitly called, however, using the @@ -3030,7 +2976,7 @@ (comma), predefined for each type, can be changed for specific class and enumeration types by defining operator functions that implement these operators. -\indextext{overloaded~operator!inheritance~of}% +\indextext{overloaded operator!inheritance of}% Operator functions are inherited in the same manner as other base class functions. @@ -3047,7 +2993,7 @@ this is not required by operator functions. \pnum -\indextext{argument!overloaded~operator~and default}% +\indextext{argument!overloaded operator and default}% An operator function cannot have default arguments~(\ref{dcl.fct.default}), except where explicitly stated below. Operator @@ -3058,7 +3004,7 @@ \pnum Operators not mentioned explicitly in subclauses~\ref{over.ass} through~\ref{over.inc} act as ordinary unary and binary -operators obeying the rules of ~\ref{over.unary} or~\ref{over.binary}.% +operators obeying the rules of~\ref{over.unary} or~\ref{over.binary}.% \indextext{overloading!resolution!best viable function|)}% \indextext{overloading!resolution!viable functions|)} @@ -3070,7 +3016,7 @@ A prefix unary operator shall be implemented by a non-static member function~(\ref{class.mfct}) with no parameters or a non-member function with one parameter. -\indextext{unary~operator!interpretation~of}% +\indextext{unary operator!interpretation of}% Thus, for any prefix unary operator \tcode{@}, \tcode{@x} @@ -3102,7 +3048,7 @@ A binary operator shall be implemented either by a non-static member function~(\ref{class.mfct}) with one parameter or by a non-member function with two parameters. -\indextext{binary~operator!interpretation~of}% +\indextext{binary operator!interpretation of}% Thus, for any binary operator \tcode{@}, \tcode{x@y} @@ -3161,15 +3107,14 @@ *bptr = 99; // ditto bptr->operator=(dobj2); // calls \tcode{D::operator=(const B\&)} *bptr = dobj2; // ditto - dobj1 = dobj2; // calls implicitly-declared - // \tcode{D::operator=(const D\&)} + dobj1 = dobj2; // calls implicitly-declared \tcode{D::operator=(const D\&)} } \end{codeblock} \end{example} \end{note} \rSec2[over.call]{Function call}% -\indextext{function~call~operator!overloaded}% +\indextext{function call operator!overloaded}% \indextext{overloading!function call operator} \pnum @@ -3273,8 +3218,8 @@ \rSec2[over.inc]{Increment and decrement} \indextext{increment operator!overloaded|see{overloading, increment operator}}% \indextext{decrement operator!overloaded|see{overloading, decrement operator}}% -\indextext{prefix~++ and~-{-} overloading@prefix \tcode{++}~and~\tcode{\dcr}!overloading}% -\indextext{postfix~++~and~-{-} overloading@postfix \tcode{++}~and~\tcode{\dcr}!overloading}% +\indextext{prefix ++ and -{-} overloading@prefix \tcode{++} and \tcode{\dcr}!overloading}% +\indextext{postfix ++ and -{-} overloading@postfix \tcode{++} and \tcode{\dcr}!overloading}% \pnum The user-defined function called @@ -3466,17 +3411,19 @@ \end{note} \pnum +\indextext{type!integral!promoted}% +\indextext{type!arithmetic!promoted}% In this subclause, the term -\term{promoted integral type} +\defn{promoted integral type} is used to refer to those integral types which are preserved by -integral promotion (including e.g. +integral promotion~(\ref{conv.prom}) (including e.g. \tcode{int} and \tcode{long} but excluding e.g. \tcode{char}). Similarly, the term -\term{promoted arithmetic type} +\defn{promoted arithmetic type} refers to floating types plus promoted integral types. \begin{note} In all cases where a promoted integral type or promoted arithmetic type is @@ -3484,332 +3431,296 @@ integral promotions. \end{note} +\pnum +In the remainder of this section, \cvqual{vq} represents either +\tcode{volatile} or no cv-qualifier. + \pnum For every pair -(\textit{T}, -\textit{VQ}), +(\tcode{\placeholder{T}}, +\cvqual{vq}), where -\textit{T} -is an arithmetic type other than \tcode{bool}, and -\textit{VQ} -is either -\tcode{volatile} -or empty, +\tcode{\placeholder{T}} +is an arithmetic type other than \tcode{bool}, there exist candidate operator functions of the form \begin{codeblock} -@\textit{VQ T}@& operator++(@\textit{VQ T}@&); -@\textit{T}@ operator++(@\textit{VQ T}@&, int); +@\cvqual{vq} \placeholder{T}@& operator++(@\cvqual{vq} \placeholder{T}@&); +@\placeholder{T}@ operator++(@\cvqual{vq} \placeholder{T}@&, int); \end{codeblock} \pnum For every pair -(\textit{T}, -\textit{VQ}), +(\tcode{\placeholder{T}}, +\cvqual{vq}), where -\textit{T} +\tcode{\placeholder{T}} is an arithmetic type other than -\textit{bool}, -and -\textit{VQ} -is either -\tcode{volatile} -or empty, +\tcode{bool}, there exist candidate operator functions of the form \begin{codeblock} -@\textit{VQ T}@& operator--(@\textit{VQ T}@&); -@\textit{T}@ operator--(@\textit{VQ T}@&, int); +@\cvqual{vq} \placeholder{T}@& operator--(@\cvqual{vq} \placeholder{T}@&); +@\placeholder{T}@ operator--(@\cvqual{vq} \placeholder{T}@&, int); \end{codeblock} \pnum For every pair -(\textit{T}, -\textit{VQ}), +(\tcode{\placeholder{T}}, +\cvqual{vq}), where -\textit{T} -is a cv-qualified or cv-unqualified object type, and -\textit{VQ} -is either -\tcode{volatile} -or empty, +\tcode{\placeholder{T}} +is a cv-qualified or cv-unqualified object type, there exist candidate operator functions of the form \begin{codeblock} -@\textit{T}@*@\textit{VQ}@& operator++(@\textit{T}@*@\textit{VQ}@&); -@\textit{T}@*@\textit{VQ}@& operator--(@\textit{T}@*@\textit{VQ}@&); -@\textit{T}@* operator++(@\textit{T}@*@\textit{VQ}@&, int); -@\textit{T}@* operator--(@\textit{T}@*@\textit{VQ}@&, int); +@\placeholder{T}@*@\cvqual{vq}@& operator++(@\placeholder{T}@*@\cvqual{vq}@&); +@\placeholder{T}@*@\cvqual{vq}@& operator--(@\placeholder{T}@*@\cvqual{vq}@&); +@\placeholder{T}@* operator++(@\placeholder{T}@*@\cvqual{vq}@&, int); +@\placeholder{T}@* operator--(@\placeholder{T}@*@\cvqual{vq}@&, int); \end{codeblock} \pnum For every cv-qualified or cv-unqualified object type -\textit{T}, +\tcode{\placeholder{T}}, there exist candidate operator functions of the form \begin{codeblock} -@\textit{T}@& operator*(@\textit{T}@*); +@\placeholder{T}@& operator*(@\placeholder{T}@*); \end{codeblock} \pnum For every function type -\textit{T} that does not have cv-qualifiers or a \grammarterm{ref-qualifier}, +\tcode{\placeholder{T}} that does not have cv-qualifiers or a \grammarterm{ref-qualifier}, there exist candidate operator functions of the form \begin{codeblock} -@\textit{T}@& operator*(@\textit{T}@*); +@\placeholder{T}@& operator*(@\placeholder{T}@*); \end{codeblock} \pnum -For every type \textit{T} there exist candidate operator functions of the form +For every type \tcode{\placeholder{T}} there exist candidate operator functions of the form \begin{codeblock} -@\textit{T}@* operator+(@\textit{T}@*); +@\placeholder{T}@* operator+(@\placeholder{T}@*); \end{codeblock} \pnum For every promoted arithmetic type -\textit{T}, +\tcode{\placeholder{T}}, there exist candidate operator functions of the form \begin{codeblock} -@\textit{T}@ operator+(@\textit{T}@); -@\textit{T}@ operator-(@\textit{T}@); +@\placeholder{T}@ operator+(@\placeholder{T}@); +@\placeholder{T}@ operator-(@\placeholder{T}@); \end{codeblock} \pnum For every promoted integral type -\textit{T}, +\tcode{\placeholder{T}}, there exist candidate operator functions of the form \begin{codeblock} -@\textit{T}@ operator~(@\textit{T}@); +@\placeholder{T}@ operator~(@\placeholder{T}@); \end{codeblock} \pnum For every quintuple -(\textit{C1}, -\textit{C2}, -\textit{T}, -\textit{CV1}, -\textit{CV2}), +(\tcode{\placeholder{C1}}, +\tcode{\placeholder{C2}}, +\tcode{\placeholder{T}}, +\cvqual{cv1}, +\cvqual{cv2}), where -\textit{C2} +\tcode{\placeholder{C2}} is a class type, -\textit{C1} -is the same type as C2 or is a derived class of C2, -\textit{T} +\tcode{\placeholder{C1}} +is the same type as \tcode{\placeholder{C2}} or is a derived class of \tcode{\placeholder{C2}}, and +\tcode{\placeholder{T}} is an object type or a function type, -and -\textit{CV1} -and -\textit{CV2} -are -\grammarterm{cv-qualifier-seq}{s}, there exist candidate operator functions of the form \begin{codeblock} -@\textit{CV12 T}@& operator->*(@\textit{CV1 C1}@*, @\textit{CV2 T C2}@::*); +@\cvqual{cv12} \placeholder{T}@& operator->*(@\cvqual{cv1} \placeholder{C1}@*, @\cvqual{cv2} \placeholder{T C2}@::*); \end{codeblock} -where -\textit{CV12} -is the union of -\textit{CV1} -and -\textit{CV2}. +where \cvqual{cv12} is the union of \cvqual{cv1} and \cvqual{cv2}. The return type is shown for exposition only; see~\ref{expr.mptr.oper} for the determination of the operator's result type. \pnum For every pair of promoted arithmetic types -\textit{L} +\tcode{\placeholder{L}} and -\textit{R}, +\tcode{\placeholder{R}}, there exist candidate operator functions of the form \begin{codeblock} -@\textit{LR}@ operator*(@\textit{L}@, @\textit{R}@); -@\textit{LR}@ operator/(@\textit{L}@, @\textit{R}@); -@\textit{LR}@ operator+(@\textit{L}@, @\textit{R}@); -@\textit{LR}@ operator-(@\textit{L}@, @\textit{R}@); -bool operator<(@\textit{L}@, @\textit{R}@); -bool operator>(@\textit{L}@, @\textit{R}@); -bool operator<=(@\textit{L}@, @\textit{R}@); -bool operator>=(@\textit{L}@, @\textit{R}@); -bool operator==(@\textit{L}@, @\textit{R}@); -bool operator!=(@\textit{L}@, @\textit{R}@); +@\placeholder{LR}@ operator*(@\placeholder{L}@, @\placeholder{R}@); +@\placeholder{LR}@ operator/(@\placeholder{L}@, @\placeholder{R}@); +@\placeholder{LR}@ operator+(@\placeholder{L}@, @\placeholder{R}@); +@\placeholder{LR}@ operator-(@\placeholder{L}@, @\placeholder{R}@); +bool operator<(@\placeholder{L}@, @\placeholder{R}@); +bool operator>(@\placeholder{L}@, @\placeholder{R}@); +bool operator<=(@\placeholder{L}@, @\placeholder{R}@); +bool operator>=(@\placeholder{L}@, @\placeholder{R}@); +bool operator==(@\placeholder{L}@, @\placeholder{R}@); +bool operator!=(@\placeholder{L}@, @\placeholder{R}@); \end{codeblock} where -\textit{LR} +\tcode{\placeholder{LR}} is the result of the usual arithmetic conversions between types -\textit{L} +\tcode{\placeholder{L}} and -\textit{R}. +\tcode{\placeholder{R}}. \pnum For every cv-qualified or cv-unqualified object type -\textit{T} +\tcode{\placeholder{T}} there exist candidate operator functions of the form \begin{codeblock} -@\textit{T}@* operator+(@\textit{T}@*, std::ptrdiff_t); -@\textit{T}@& operator[](@\textit{T}@*, std::ptrdiff_t); -@\textit{T}@* operator-(@\textit{T}@*, std::ptrdiff_t); -@\textit{T}@* operator+(std::ptrdiff_t, @\textit{T}@*); -@\textit{T}@& operator[](std::ptrdiff_t, @\textit{T}@*); +@\placeholder{T}@* operator+(@\placeholder{T}@*, std::ptrdiff_t); +@\placeholder{T}@& operator[](@\placeholder{T}@*, std::ptrdiff_t); +@\placeholder{T}@* operator-(@\placeholder{T}@*, std::ptrdiff_t); +@\placeholder{T}@* operator+(std::ptrdiff_t, @\placeholder{T}@*); +@\placeholder{T}@& operator[](std::ptrdiff_t, @\placeholder{T}@*); \end{codeblock} \pnum For every -\textit{T}, +\tcode{\placeholder{T}}, where -\textit{T} +\tcode{\placeholder{T}} is a pointer to object type, there exist candidate operator functions of the form \begin{codeblock} -std::ptrdiff_t operator-(@\term{T}@, @\term{T}@); +std::ptrdiff_t operator-(@\placeholder{T}@, @\placeholder{T}@); \end{codeblock} \pnum -For every \term{T}, where \term{T} is an enumeration type or a pointer type, +For every \tcode{\placeholder{T}}, where \tcode{\placeholder{T}} is an enumeration type or a pointer type, there exist candidate operator functions of the form \begin{codeblock} -bool operator<(@\term{T}@, @\term{T}@); -bool operator>(@\term{T}@, @\term{T}@); -bool operator<=(@\term{T}@, @\term{T}@); -bool operator>=(@\term{T}@, @\term{T}@); -bool operator==(@\term{T}@, @\term{T}@); -bool operator!=(@\term{T}@, @\term{T}@); +bool operator<(@\placeholder{T}@, @\placeholder{T}@); +bool operator>(@\placeholder{T}@, @\placeholder{T}@); +bool operator<=(@\placeholder{T}@, @\placeholder{T}@); +bool operator>=(@\placeholder{T}@, @\placeholder{T}@); +bool operator==(@\placeholder{T}@, @\placeholder{T}@); +bool operator!=(@\placeholder{T}@, @\placeholder{T}@); \end{codeblock} \pnum -For every pointer to member type \term{T} or type \tcode{std::nullptr_t} there +For every pointer to member type \tcode{\placeholder{T}} or type \tcode{std::nullptr_t} there exist candidate operator functions of the form \begin{codeblock} -bool operator==(@\term{T}@, @\term{T}@); -bool operator!=(@\term{T}@, @\term{T}@); +bool operator==(@\placeholder{T}@, @\placeholder{T}@); +bool operator!=(@\placeholder{T}@, @\placeholder{T}@); \end{codeblock} \pnum For every pair of promoted integral types -\term{L} +\tcode{\placeholder{L}} and -\term{R}, +\tcode{\placeholder{R}}, there exist candidate operator functions of the form \begin{codeblock} -@\term{LR}@ operator%(@\term{L}@, @\term{R}@); -@\term{LR}@ operator&(@\term{L}@, @\term{R}@); -@\term{LR}@ operator^(@\term{L}@, @\term{R}@); -@\term{LR}@ operator|(@\term{L}@, @\term{R}@); -@\term{L}@ operator<<(@\term{L}@, @\term{R}@); -@\term{L}@ operator>>(@\term{L}@, @\term{R}@); +@\placeholder{LR}@ operator%(@\placeholder{L}@, @\placeholder{R}@); +@\placeholder{LR}@ operator&(@\placeholder{L}@, @\placeholder{R}@); +@\placeholder{LR}@ operator^(@\placeholder{L}@, @\placeholder{R}@); +@\placeholder{LR}@ operator|(@\placeholder{L}@, @\placeholder{R}@); +@\placeholder{L}@ operator<<(@\placeholder{L}@, @\placeholder{R}@); +@\placeholder{L}@ operator>>(@\placeholder{L}@, @\placeholder{R}@); \end{codeblock} where -\term{LR} +\tcode{\placeholder{LR}} is the result of the usual arithmetic conversions between types -\term{L} +\tcode{\placeholder{L}} and -\term{R}. +\tcode{\placeholder{R}}. \pnum For every triple -(\term{L}, -\term{VQ}, -\term{R}), +(\tcode{\placeholder{L}}, +\cvqual{vq}, +\tcode{\placeholder{R}}), where -\term{L} +\tcode{\placeholder{L}} is an arithmetic type, -\term{VQ} -is either -\tcode{volatile} -or empty, and -\term{R} +\tcode{\placeholder{R}} is a promoted arithmetic type, there exist candidate operator functions of the form \begin{codeblock} -@\term{VQ L}@& operator=(@\term{VQ L}@&, @\term{R}@); -@\term{VQ L}@& operator*=(@\term{VQ L}@&, @\term{R}@); -@\term{VQ L}@& operator/=(@\term{VQ L}@&, @\term{R}@); -@\term{VQ L}@& operator+=(@\term{VQ L}@&, @\term{R}@); -@\term{VQ L}@& operator-=(@\term{VQ L}@&, @\term{R}@); +@\cvqual{vq} \placeholder{L}@& operator=(@\cvqual{vq} \placeholder{L}@&, @\placeholder{R}@); +@\cvqual{vq} \placeholder{L}@& operator*=(@\cvqual{vq} \placeholder{L}@&, @\placeholder{R}@); +@\cvqual{vq} \placeholder{L}@& operator/=(@\cvqual{vq} \placeholder{L}@&, @\placeholder{R}@); +@\cvqual{vq} \placeholder{L}@& operator+=(@\cvqual{vq} \placeholder{L}@&, @\placeholder{R}@); +@\cvqual{vq} \placeholder{L}@& operator-=(@\cvqual{vq} \placeholder{L}@&, @\placeholder{R}@); \end{codeblock} \pnum -For every pair (\term{T}, \term{VQ}), where \term{T} is any type and \term{VQ} is either -\tcode{volatile} or empty, there exist candidate operator functions of the form +For every pair (\tcode{\placeholder{T}}, \cvqual{vq}), +where \tcode{\placeholder{T}} is any type, +there exist candidate operator functions of the form \begin{codeblock} -@\term{T}@*@\term{VQ}@& operator=(@\term{T}@*@\term{VQ}@&, @\term{T}@*); +@\placeholder{T}@*@\cvqual{vq}@& operator=(@\placeholder{T}@*@\cvqual{vq}@&, @\placeholder{T}@*); \end{codeblock} \pnum For every pair -(\term{T}, -\term{VQ}), +(\tcode{\placeholder{T}}, +\cvqual{vq}), where -\term{T} -is an enumeration or pointer to member type and -\term{VQ} -is either -\tcode{volatile} -or empty, +\tcode{\placeholder{T}} +is an enumeration or pointer to member type, there exist candidate operator functions of the form \begin{codeblock} -@\term{VQ} \term{T}@& operator=(@\term{VQ} \term{T}@&, @\term{T}@); +@\cvqual{vq} \placeholder{T}@& operator=(@\cvqual{vq} \placeholder{T}@&, @\placeholder{T}@); \end{codeblock} \pnum For every pair -(\term{T}, -\term{VQ}), +(\tcode{\placeholder{T}}, +\cvqual{vq}), where -\term{T} -is a cv-qualified or cv-unqualified object type and -\term{VQ} -is either -\tcode{volatile} -or empty, +\tcode{\placeholder{T}} +is a cv-qualified or cv-unqualified object type, there exist candidate operator functions of the form \begin{codeblock} -@\term{T}@*@\term{VQ}@& operator+=(@\term{T}@*@\term{VQ}@&, std::ptrdiff_t); -@\term{T}@*@\term{VQ}@& operator-=(@\term{T}@*@\term{VQ}@&, std::ptrdiff_t); +@\placeholder{T}@*@\cvqual{vq}@& operator+=(@\placeholder{T}@*@\cvqual{vq}@&, std::ptrdiff_t); +@\placeholder{T}@*@\cvqual{vq}@& operator-=(@\placeholder{T}@*@\cvqual{vq}@&, std::ptrdiff_t); \end{codeblock} \pnum For every triple -(\term{L}, -\term{VQ}, -\term{R}), +(\tcode{\placeholder{L}}, +\cvqual{vq}, +\tcode{\placeholder{R}}), where -\term{L} -is an integral type, -\term{VQ} -is either -\tcode{volatile} -or empty, -and -\term{R} +\tcode{\placeholder{L}} +is an integral type, and +\tcode{\placeholder{R}} is a promoted integral type, there exist candidate operator functions of the form \begin{codeblock} -@\term{VQ L}@& operator%=(@\term{VQ L}@&, @\term{R}@); -@\term{VQ L}@& operator<<=(@\term{VQ L}@&, @\term{R}@); -@\term{VQ L}@& operator>>=(@\term{VQ L}@&, @\term{R}@); -@\term{VQ L}@& operator&=(@\term{VQ L}@&, @\term{R}@); -@\term{VQ L}@& operator^=(@\term{VQ L}@&, @\term{R}@); -@\term{VQ L}@& operator|=(@\term{VQ L}@&, @\term{R}@); +@\cvqual{vq} \placeholder{L}@& operator%=(@\cvqual{vq} \placeholder{L}@&, @\placeholder{R}@); +@\cvqual{vq} \placeholder{L}@& operator<<=(@\cvqual{vq} \placeholder{L}@&, @\placeholder{R}@); +@\cvqual{vq} \placeholder{L}@& operator>>=(@\cvqual{vq} \placeholder{L}@&, @\placeholder{R}@); +@\cvqual{vq} \placeholder{L}@& operator&=(@\cvqual{vq} \placeholder{L}@&, @\placeholder{R}@); +@\cvqual{vq} \placeholder{L}@& operator^=(@\cvqual{vq} \placeholder{L}@&, @\placeholder{R}@); +@\cvqual{vq} \placeholder{L}@& operator|=(@\cvqual{vq} \placeholder{L}@&, @\placeholder{R}@); \end{codeblock} \pnum @@ -3823,21 +3734,21 @@ \pnum For every pair of promoted arithmetic types -\term{L} +\tcode{\placeholder{L}} and -\term{R}, +\tcode{\placeholder{R}}, there exist candidate operator functions of the form \begin{codeblock} -@\term{LR}@ operator?:(bool, @\term{L}@, @\term{R}@); +@\placeholder{LR}@ operator?:(bool, @\placeholder{L}@, @\placeholder{R}@); \end{codeblock} where -\term{LR} +\tcode{\placeholder{LR}} is the result of the usual arithmetic conversions between types -\term{L} +\tcode{\placeholder{L}} and -\term{R}. +\tcode{\placeholder{R}}. \begin{note} As with all these descriptions of candidate functions, this declaration serves only to describe the built-in operator for purposes of overload resolution. @@ -3848,13 +3759,13 @@ \pnum For every type -\term{T}, +\tcode{\placeholder{T}}, where -\term{T} +\tcode{\placeholder{T}} is a pointer, pointer-to-member, or scoped enumeration type, there exist candidate operator functions of the form \begin{codeblock} -@\term{T}@ operator?:(bool, @\term{T}@, @\term{T}@); +@\placeholder{T}@ operator?:(bool, @\placeholder{T}@, @\placeholder{T}@); \end{codeblock}% \indextext{overloading|)} diff --git a/source/preprocessor.tex b/source/preprocessor.tex index 547b758a69..703c5ceac9 100644 --- a/source/preprocessor.tex +++ b/source/preprocessor.tex @@ -19,7 +19,7 @@ or that follows white space containing at least one new-line character. The last token in the sequence is the first new-line character that follows the first token in the sequence.\footnote{Thus, -preprocessing directives are commonly called ``lines.'' +preprocessing directives are commonly called ``lines''. These ``lines'' have no other syntactic significance, as all white space is equivalent except in certain situations during preprocessing (see the @@ -41,12 +41,26 @@ \begin{bnf} \nontermdef{group-part}\br - if-section\br control-line\br + if-section\br text-line\br \terminal{\#} conditionally-supported-directive \end{bnf} +\begin{bnftab} +\nontermdef{control-line}\br +\>\terminal{\# include}\>\>pp-tokens new-line\br +\>\terminal{\# define}\>\>identifier replacement-list new-line\br +\>\terminal{\# define}\>\>identifier lparen identifier-list\opt{} \terminal{)} replacement-list new-line\br +\>\terminal{\# define}\>\>identifier lparen \terminal{... )} replacement-list new-line\br +\>\terminal{\# define}\>\>identifier lparen identifier-list, \terminal{... )} replacement-list new-line\br +\>\terminal{\# undef}\>\>identifier new-line\br +\>\terminal{\# line}\>\>pp-tokens new-line\br +\>\terminal{\# error}\>\>pp-tokens\opt new-line\br +\>\terminal{\# pragma}\>\>pp-tokens\opt new-line\br +\>\terminal{\# }new-line +\end{bnftab} + \begin{bnf} \nontermdef{if-section}\br if-group elif-groups\opt else-group\opt endif-line @@ -80,20 +94,6 @@ \>\terminal{\# endif}\>\>new-line \end{bnftab} -\begin{bnftab} -\nontermdef{control-line}\br -\>\terminal{\# include}\>\>pp-tokens new-line\br -\>\terminal{\# define}\>\>identifier replacement-list new-line\br -\>\terminal{\# define}\>\>identifier lparen identifier-list\opt{} \terminal{)} replacement-list new-line\br -\>\terminal{\# define}\>\>identifier lparen \terminal{... )} replacement-list new-line\br -\>\terminal{\# define}\>\>identifier lparen identifier-list, \terminal{... )} replacement-list new-line\br -\>\terminal{\# undef}\>\>identifier new-line\br -\>\terminal{\# line}\>\>pp-tokens new-line\br -\>\terminal{\# error}\>\>pp-tokens\opt new-line\br -\>\terminal{\# pragma}\>\>pp-tokens\opt new-line\br -\>\terminal{\# }new-line -\end{bnftab} - \begin{bnf} \nontermdef{text-line}\br pp-tokens\opt new-line @@ -196,7 +196,7 @@ \begin{ncbnf} \nontermdef{h-preprocessing-token}\br - \textnormal{any \nonterminal{preprocessing-token} other than \terminal{>}} + \textnormal{any \grammarterm{preprocessing-token} other than \terminal{>}} \end{ncbnf} \begin{ncbnf} @@ -442,7 +442,7 @@ \rSec1[cpp.include]{Source file inclusion} \indextext{preprocessing directives!header inclusion} \indextext{preprocessing directives!source-file inclusion} -\indextext{inclusion!source~file|see{preprocessing directives, source-file inclusion}}% +\indextext{inclusion!source file|see{preprocessing directives, source-file inclusion}}% \indextext{\idxcode{\#include}}% \pnum @@ -455,7 +455,7 @@ A preprocessing directive of the form \begin{ncsimplebnf} -\terminal{\# include <}h-char-sequence\terminal{>} new-line +\terminal{\# include <} h-char-sequence \terminal{>} new-line \end{ncsimplebnf} searches a sequence of @@ -475,11 +475,9 @@ \pnum A preprocessing directive of the form - \begin{ncsimplebnf} -\terminal{\# include "}q-char-sequence\terminal{"} new-line +\terminal{\# include "} q-char-sequence \terminal{"} new-line \end{ncsimplebnf} - causes the replacement of that directive by the entire contents of the source file identified by the specified sequence between the @@ -491,11 +489,9 @@ If this search is not supported, or if the search fails, the directive is reprocessed as if it read - \begin{ncsimplebnf} -\terminal{\# include <}h-char-sequence\terminal{>} new-line +\terminal{\# include <} h-char-sequence \terminal{>} new-line \end{ncsimplebnf} - with the identical contained sequence (including \tcode{>} characters, if any) from the original directive. @@ -655,7 +651,7 @@ \pnum If a -\indextext{\#\#0~operator@\tcode{\#}~operator} +\indextext{\#\#0 operator@\tcode{\#} operator} \tcode{\#} preprocessing token, followed by an identifier, @@ -689,13 +685,11 @@ \pnum A preprocessing directive of the form - \begin{ncsimplebnf} \terminal{\# define} identifier lparen identifier-list\opt{} \terminal{)} replacement-list new-line\br \terminal{\# define} identifier lparen \terminal{...} \terminal{)} replacement-list new-line\br -\terminal{\# define} identifier lparen identifier-list \terminal{, ...} \terminal{)} replacement-list new-line\br +\terminal{\# define} identifier lparen identifier-list \terminal{, ...} \terminal{)} replacement-list new-line \end{ncsimplebnf} - \indextext{macro!function-like}% defines a \defn{function-like macro} with parameters, whose use is @@ -747,7 +741,7 @@ \rSec2[cpp.subst]{Argument substitution}% \indextext{macro!argument substitution}% -\indextext{argument~substitution|see{macro, argument substitution}}% +\indextext{argument substitution|see{macro, argument substitution}}% \pnum After the arguments for the invocation of a function-like macro have @@ -773,7 +767,7 @@ the preprocessing tokens used to replace it. \rSec2[cpp.stringize]{The \tcode{\#} operator}% -\indextext{\#\#0~operator@\tcode{\#}~operator}% +\indextext{\#\#0 operator@\tcode{\#} operator}% \indextext{stringize|see{\tcode{\#}}} \pnum @@ -866,8 +860,7 @@ #define mkstr(a) # a #define in_between(a) mkstr(a) #define join(c, d) in_between(c hash_hash d) -char p[] = join(x, y); // equivalent to - // char p[] = "x \#\# y"; +char p[] = join(x, y); // equivalent to \tcode{char p[] = "x \#\# y";} \end{codeblock} The expansion produces, at various stages: @@ -942,7 +935,7 @@ \pnum \begin{example} -The simplest use of this facility is to define a ``manifest constant,'' +The simplest use of this facility is to define a ``manifest constant'', as in \begin{codeblock} #define TABSIZE 100 @@ -1248,9 +1241,8 @@ \indextext{__CPLUSPLUS@\xname{cplusplus}}% \item \xname{cplusplus}\\ -The integer literal \tcode{\cppver}. -\footnote{It is intended that future -versions of this standard will +The integer literal \tcode{\cppver}.\footnote{It is intended that future +versions of this International Standard will replace the value of this macro with a greater value. Non-conforming compilers should use a value with at most five decimal digits.} @@ -1284,13 +1276,11 @@ \footnote{The presumed line number can be changed by the \tcode{\#line} directive.} \indextext{__STDC_HOSTED__@\mname{STDC_HOSTED}}% -\indextext{__STDC_HOSTED__@\mname{STDC_HOSTED}!implementation-defined}% \item \mname{STDC_HOSTED}\\ The integer literal \tcode{1} if the implementation is a hosted implementation or the integer literal \tcode{0} if it is not. \indextext{__STDCPP_DEFAULT_NEW_ALIGNMENT__@\mname{STDCPP_DEFAULT_NEW_ALIGNMENT}}% -\indextext{__STDCPP_DEFAULT_NEW_ALIGNMENT__@\mname{STDCPP_DEFAULT_NEW_ALIGNMENT}!implementation-defined}% \item \mname{STDCPP_DEFAULT_NEW_ALIGNMENT}\\ An integer literal of type \tcode{std\colcol{}size_t} whose value is the alignment guaranteed @@ -1318,26 +1308,22 @@ \begin{description} \indextext{__STDC__@\mname{STDC}}% -\indextext{__STDC__@\mname{STDC}!implementation-defined}% \item \mname{STDC}\\ Whether \mname{STDC} is predefined and if so, what its value is, are \impldef{definition and meaning of \mname{STDC}}. \indextext{__STDC_MB_MIGHT_NEQ_WC__@\mname{STDC_MB_MIGHT_NEQ_WC}}% -\indextext{__STDC_MB_MIGHT_NEQ_WC__@\mname{STDC_MB_MIGHT_NEQ_WC}!implementation-defined}% \item \mname{STDC_MB_MIGHT_NEQ_WC}\\ The integer literal \tcode{1}, intended to indicate that, in the encoding for \tcode{wchar_t}, a member of the basic character set need not have a code value equal to its value when used as the lone character in an ordinary character literal. \indextext{__STDC_VERSION__@\mname{STDC_VERSION}}% -\indextext{__STDC_VERSION__@\mname{STDC_VERSION}!implementation-defined}% \item \mname{STDC_VERSION}\\ Whether \mname{STDC_VERSION} is predefined and if so, what its value is, are \impldef{definition and meaning of \mname{STDC_VERSION}}. \indextext{__STDC_ISO_10646__@\mname{STDC_ISO_10646}}% -\indextext{__STDC_ISO_10646__@\mname{STDC_ISO_10646}!implementation-defined}% \item \mname{STDC_ISO_10646}\\ An integer literal of the form \tcode{yyyymmL} (for example, \tcode{199712L}). @@ -1348,13 +1334,11 @@ all amendments and technical corrigenda as of the specified year and month. \indextext{__STDCPP_STRICT_POINTER_SAFETY__@\mname{STDCPP_STRICT_POINTER_SAFETY}}% -\indextext{__STDCPP_STRICT_POINTER_SAFETY__@\mname{STDCPP_STRICT_POINTER_SAFETY}!implementation-defined}% \item \mname{STDCPP_STRICT_POINTER_SAFETY}\\ Defined, and has the value integer literal 1, if and only if the implementation has strict pointer safety~(\ref{basic.stc.dynamic.safety}). \indextext{__STDCPP_THREADS__@\mname{STDCPP_THREADS}}% -\indextext{__STDCPP_THREADS__@\mname{STDCPP_THREADS}!implementation-defined}% \item \mname{STDCPP_THREADS}\\ Defined, and has the value integer literal 1, if and only if a program can have more than one thread of execution~(\ref{intro.multithread}). @@ -1387,6 +1371,7 @@ \indextext{macro!pragma operator}% \indextext{operator!pragma|see{macro, pragma operator}} +\pnum A unary operator expression of the form: \begin{ncbnf} @@ -1402,27 +1387,22 @@ \grammarterm{pp-tokens} in a pragma directive. The original four preprocessing tokens in the unary operator expression are removed. +\pnum \begin{example} - \begin{codeblock} #pragma listing on "..\listing.dir" \end{codeblock} - can also be expressed as: - \begin{codeblock} _Pragma ( "listing on \"..\\listing.dir\"" ) \end{codeblock} - The latter form is processed in the same way whether it appears literally as shown, or results from macro replacement, as in: - \begin{codeblock} #define LISTING(x) PRAGMA(listing on #x) #define PRAGMA(x) _Pragma(#x) LISTING( ..\listing.dir ) \end{codeblock} - \end{example}% \indextext{preprocessing directives|)} diff --git a/source/regex.tex b/source/regex.tex index 017af67b81..192822e342 100644 --- a/source/regex.tex +++ b/source/regex.tex @@ -210,7 +210,7 @@ corresponding character classes. If \tcode{b} is \tcode{true}, the returned bitmask is suitable for matching characters without regard to their case. - Returns 0 if the character + Returns \tcode{0} if the character sequence is not the name of a character class recognized by \tcode{X}. The value returned shall be independent of the case of the characters in the sequence. @@ -309,65 +309,53 @@ template bool operator==( - const basic_string< - typename iterator_traits::value_type, ST, SA>& lhs, + const basic_string::value_type, ST, SA>& lhs, const sub_match& rhs); template bool operator!=( - const basic_string< - typename iterator_traits::value_type, ST, SA>& lhs, + const basic_string::value_type, ST, SA>& lhs, const sub_match& rhs); template bool operator<( - const basic_string< - typename iterator_traits::value_type, ST, SA>& lhs, + const basic_string::value_type, ST, SA>& lhs, const sub_match& rhs); template bool operator>( - const basic_string< - typename iterator_traits::value_type, ST, SA>& lhs, + const basic_string::value_type, ST, SA>& lhs, const sub_match& rhs); template bool operator>=( - const basic_string< - typename iterator_traits::value_type, ST, SA>& lhs, + const basic_string::value_type, ST, SA>& lhs, const sub_match& rhs); template bool operator<=( - const basic_string< - typename iterator_traits::value_type, ST, SA>& lhs, + const basic_string::value_type, ST, SA>& lhs, const sub_match& rhs); template bool operator==( const sub_match& lhs, - const basic_string< - typename iterator_traits::value_type, ST, SA>& rhs); + const basic_string::value_type, ST, SA>& rhs); template bool operator!=( const sub_match& lhs, - const basic_string< - typename iterator_traits::value_type, ST, SA>& rhs); + const basic_string::value_type, ST, SA>& rhs); template bool operator<( const sub_match& lhs, - const basic_string< - typename iterator_traits::value_type, ST, SA>& rhs); + const basic_string::value_type, ST, SA>& rhs); template bool operator>( const sub_match& lhs, - const basic_string< - typename iterator_traits::value_type, ST, SA>& rhs); + const basic_string::value_type, ST, SA>& rhs); template bool operator>=( const sub_match& lhs, - const basic_string< - typename iterator_traits::value_type, ST, SA>& rhs); + const basic_string::value_type, ST, SA>& rhs); template bool operator<=( const sub_match& lhs, - const basic_string< - typename iterator_traits::value_type, ST, SA>& rhs); + const basic_string::value_type, ST, SA>& rhs); template bool operator==(const typename iterator_traits::value_type* lhs, @@ -447,7 +435,7 @@ template basic_ostream& - operator<<(basic_ostream& os, const sub_match& m); + operator<<(basic_ostream& os, const sub_match& m); // \ref{re.results}, class template match_results template & m2); // \ref{re.alg.match}, function template regex_match - template + template bool regex_match(BidirectionalIterator first, BidirectionalIterator last, match_results& m, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); template - bool regex_match(BidirectionalIterator first, BidirectionalIterator last, - const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + bool regex_match(BidirectionalIterator first, BidirectionalIterator last, + const basic_regex& e, + regex_constants::match_flag_type flags = regex_constants::match_default); template bool regex_match(const charT* str, match_results& m, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); template bool regex_match(const basic_string& s, - match_results< - typename basic_string::const_iterator, - Allocator>& m, + match_results::const_iterator, + Allocator>& m, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); template bool regex_match(const basic_string&&, - match_results< - typename basic_string::const_iterator, - Allocator>&, + match_results::const_iterator, + Allocator>&, const basic_regex&, - regex_constants::match_flag_type = - regex_constants::match_default) = delete; + regex_constants::match_flag_type = regex_constants::match_default) = delete; template bool regex_match(const charT* str, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); template bool regex_match(const basic_string& s, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); // \ref{re.alg.search}, function template regex_search - template + template bool regex_search(BidirectionalIterator first, BidirectionalIterator last, match_results& m, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); template bool regex_search(BidirectionalIterator first, BidirectionalIterator last, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); template bool regex_search(const charT* str, match_results& m, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); template bool regex_search(const charT* str, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); template bool regex_search(const basic_string& s, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); template bool regex_search(const basic_string& s, - match_results< - typename basic_string::const_iterator, - Allocator>& m, + match_results::const_iterator, + Allocator>& m, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); template bool regex_search(const basic_string&&, - match_results< - typename basic_string::const_iterator, - Allocator>&, + match_results::const_iterator, + Allocator>&, const basic_regex&, - regex_constants::match_flag_type = - regex_constants::match_default) = delete; + regex_constants::match_flag_type + = regex_constants::match_default) = delete; // \ref{re.alg.replace}, function template regex_replace template + class traits, class charT, class ST, class SA> OutputIterator - regex_replace(OutputIterator out, - BidirectionalIterator first, BidirectionalIterator last, - const basic_regex& e, - const basic_string& fmt, - regex_constants::match_flag_type flags = - regex_constants::match_default); - template + regex_replace(OutputIterator out, + BidirectionalIterator first, BidirectionalIterator last, + const basic_regex& e, + const basic_string& fmt, + regex_constants::match_flag_type flags = regex_constants::match_default); + template OutputIterator - regex_replace(OutputIterator out, - BidirectionalIterator first, BidirectionalIterator last, - const basic_regex& e, - const charT* fmt, - regex_constants::match_flag_type flags = - regex_constants::match_default); - template + regex_replace(OutputIterator out, + BidirectionalIterator first, BidirectionalIterator last, + const basic_regex& e, + const charT* fmt, + regex_constants::match_flag_type flags = regex_constants::match_default); + template basic_string - regex_replace(const basic_string& s, - const basic_regex& e, - const basic_string& fmt, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_replace(const basic_string& s, + const basic_regex& e, + const basic_string& fmt, + regex_constants::match_flag_type flags = regex_constants::match_default); template basic_string - regex_replace(const basic_string& s, - const basic_regex& e, - const charT* fmt, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_replace(const basic_string& s, + const basic_regex& e, + const charT* fmt, + regex_constants::match_flag_type flags = regex_constants::match_default); template basic_string - regex_replace(const charT* s, - const basic_regex& e, - const basic_string& fmt, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_replace(const charT* s, + const basic_regex& e, + const basic_string& fmt, + regex_constants::match_flag_type flags = regex_constants::match_default); template basic_string - regex_replace(const charT* s, - const basic_regex& e, - const charT* fmt, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_replace(const charT* s, + const basic_regex& e, + const charT* fmt, + regex_constants::match_flag_type flags = regex_constants::match_default); // \ref{re.regiter}, class template regex_iterator template ::value_type, + class charT = typename iterator_traits::value_type, class traits = regex_traits> class regex_iterator; @@ -626,8 +586,7 @@ // \ref{re.tokiter}, class template regex_token_iterator template ::value_type, + class charT = typename iterator_traits::value_type, class traits = regex_traits> class regex_token_iterator; @@ -1021,9 +980,9 @@ \indexlibrary{\idxcode{regex_error}}% \begin{codeblock} class regex_error : public runtime_error { - public: - explicit regex_error(regex_constants::error_type ecode); - regex_constants::error_type code() const; +public: + explicit regex_error(regex_constants::error_type ecode); + regex_constants::error_type code() const; }; \end{codeblock} @@ -1039,7 +998,7 @@ \begin{itemdescr} \pnum\effects Constructs an object of class \tcode{regex_error}. -\pnum\postconditions \tcode{ecode == code()} +\pnum\postconditions \tcode{ecode == code()}. \end{itemdescr} \indexlibrary{\idxcode{error_type}}% @@ -1057,33 +1016,32 @@ \begin{codeblock} namespace std { template - struct regex_traits { - public: - using char_type = charT; - using string_type = basic_string; - using locale_type = locale; - using char_class_type = @{\itshape bitmask_type}@; - - regex_traits(); - static size_t length(const char_type* p); - charT translate(charT c) const; - charT translate_nocase(charT c) const; - template - string_type transform(ForwardIterator first, ForwardIterator last) const; - template - string_type transform_primary( - ForwardIterator first, ForwardIterator last) const; - template - string_type lookup_collatename( - ForwardIterator first, ForwardIterator last) const; - template - char_class_type lookup_classname( - ForwardIterator first, ForwardIterator last, bool icase = false) const; - bool isctype(charT c, char_class_type f) const; - int value(charT ch, int radix) const; - locale_type imbue(locale_type l); - locale_type getloc() const; - }; + struct regex_traits { + using char_type = charT; + using string_type = basic_string; + using locale_type = locale; + using char_class_type = @{\itshape bitmask_type}@; + + regex_traits(); + static size_t length(const char_type* p); + charT translate(charT c) const; + charT translate_nocase(charT c) const; + template + string_type transform(ForwardIterator first, ForwardIterator last) const; + template + string_type transform_primary( + ForwardIterator first, ForwardIterator last) const; + template + string_type lookup_collatename( + ForwardIterator first, ForwardIterator last) const; + template + char_class_type lookup_classname( + ForwardIterator first, ForwardIterator last, bool icase = false) const; + bool isctype(charT c, char_class_type f) const; + int value(charT ch, int radix) const; + locale_type imbue(locale_type l); + locale_type getloc() const; + }; } \end{codeblock} @@ -1157,10 +1115,14 @@ \end{itemdecl} \begin{itemdescr} -\pnum\effects If \tcode{typeid(use_facet>) -== typeid(collate_byname)} +\pnum +\effects +If +\begin{codeblock} +typeid(use_facet>) == typeid(collate_byname) +\end{codeblock} and the form of the sort key returned -by \tcode{collate_byname \colcol transform(first, last)} is known and +by \tcode{collate_byname::transform(first, last)} is known and can be converted into a primary sort key then returns that key, otherwise returns an empty string. \end{itemdescr} @@ -1277,7 +1239,7 @@ \pnum \returns the value represented by the digit \tcode{ch} in base \tcode{radix} if the character \tcode{ch} is a valid digit in base -\tcode{radix}; otherwise returns -1. +\tcode{radix}; otherwise returns \tcode{-1}. \end{itemdescr} \indexlibrary{\idxcode{locale}}% @@ -1363,90 +1325,88 @@ \indexlibrary{\idxcode{basic_regex}}% \begin{codeblock} namespace std { - template > - class basic_regex { - public: - // types: - using value_type = charT; - using traits_type = traits; - using string_type = typename traits::string_type; - using flag_type = regex_constants::syntax_option_type; - using locale_type = typename traits::locale_type; - - // \ref{re.regex.const}, constants - static constexpr regex_constants::syntax_option_type - icase = regex_constants::icase; - static constexpr regex_constants::syntax_option_type - nosubs = regex_constants::nosubs; - static constexpr regex_constants::syntax_option_type - optimize = regex_constants::optimize; - static constexpr regex_constants::syntax_option_type - collate = regex_constants::collate; - static constexpr regex_constants::syntax_option_type - ECMAScript = regex_constants::ECMAScript; - static constexpr regex_constants::syntax_option_type - basic = regex_constants::basic; - static constexpr regex_constants::syntax_option_type - extended = regex_constants::extended; - static constexpr regex_constants::syntax_option_type - awk = regex_constants::awk; - static constexpr regex_constants::syntax_option_type - grep = regex_constants::grep; - static constexpr regex_constants::syntax_option_type - egrep = regex_constants::egrep; - - // \ref{re.regex.construct}, construct/copy/destroy - basic_regex(); - explicit basic_regex(const charT* p, - flag_type f = regex_constants::ECMAScript); - basic_regex(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript); - basic_regex(const basic_regex&); - basic_regex(basic_regex&&) noexcept; - template - explicit basic_regex(const basic_string& p, - flag_type f = regex_constants::ECMAScript); - template - basic_regex(ForwardIterator first, ForwardIterator last, - flag_type f = regex_constants::ECMAScript); - basic_regex(initializer_list, - flag_type = regex_constants::ECMAScript); - - ~basic_regex(); - - basic_regex& operator=(const basic_regex&); - basic_regex& operator=(basic_regex&&) noexcept; - basic_regex& operator=(const charT* ptr); - basic_regex& operator=(initializer_list il); - template - basic_regex& operator=(const basic_string& p); - - // \ref{re.regex.assign}, assign - basic_regex& assign(const basic_regex& that); - basic_regex& assign(basic_regex&& that) noexcept; - basic_regex& assign(const charT* ptr, - flag_type f = regex_constants::ECMAScript); - basic_regex& assign(const charT* p, size_t len, flag_type f); - template - basic_regex& assign(const basic_string& s, - flag_type f = regex_constants::ECMAScript); - template - basic_regex& assign(InputIterator first, InputIterator last, - flag_type f = regex_constants::ECMAScript); - basic_regex& assign(initializer_list, - flag_type = regex_constants::ECMAScript); - - // \ref{re.regex.operations}, const operations - unsigned mark_count() const; - flag_type flags() const; - - // \ref{re.regex.locale}, locale - locale_type imbue(locale_type loc); - locale_type getloc() const; - - // \ref{re.regex.swap}, swap - void swap(basic_regex&); - }; + template > + class basic_regex { + public: + // types: + using value_type = charT; + using traits_type = traits; + using string_type = typename traits::string_type; + using flag_type = regex_constants::syntax_option_type; + using locale_type = typename traits::locale_type; + + // \ref{re.regex.const}, constants + static constexpr regex_constants::syntax_option_type + icase = regex_constants::icase; + static constexpr regex_constants::syntax_option_type + nosubs = regex_constants::nosubs; + static constexpr regex_constants::syntax_option_type + optimize = regex_constants::optimize; + static constexpr regex_constants::syntax_option_type + collate = regex_constants::collate; + static constexpr regex_constants::syntax_option_type + ECMAScript = regex_constants::ECMAScript; + static constexpr regex_constants::syntax_option_type + basic = regex_constants::basic; + static constexpr regex_constants::syntax_option_type + extended = regex_constants::extended; + static constexpr regex_constants::syntax_option_type + awk = regex_constants::awk; + static constexpr regex_constants::syntax_option_type + grep = regex_constants::grep; + static constexpr regex_constants::syntax_option_type + egrep = regex_constants::egrep; + static constexpr regex_constants::syntax_option_type + multiline = regex_constants::multiline; + + // \ref{re.regex.construct}, construct/copy/destroy + basic_regex(); + explicit basic_regex(const charT* p, flag_type f = regex_constants::ECMAScript); + basic_regex(const charT* p, size_t len, flag_type f = regex_constants::ECMAScript); + basic_regex(const basic_regex&); + basic_regex(basic_regex&&) noexcept; + template + explicit basic_regex(const basic_string& p, + flag_type f = regex_constants::ECMAScript); + template + basic_regex(ForwardIterator first, ForwardIterator last, + flag_type f = regex_constants::ECMAScript); + basic_regex(initializer_list, flag_type = regex_constants::ECMAScript); + + ~basic_regex(); + + basic_regex& operator=(const basic_regex&); + basic_regex& operator=(basic_regex&&) noexcept; + basic_regex& operator=(const charT* ptr); + basic_regex& operator=(initializer_list il); + template + basic_regex& operator=(const basic_string& p); + + // \ref{re.regex.assign}, assign + basic_regex& assign(const basic_regex& that); + basic_regex& assign(basic_regex&& that) noexcept; + basic_regex& assign(const charT* ptr, flag_type f = regex_constants::ECMAScript); + basic_regex& assign(const charT* p, size_t len, flag_type f); + template + basic_regex& assign(const basic_string& s, + flag_type f = regex_constants::ECMAScript); + template + basic_regex& assign(InputIterator first, InputIterator last, + flag_type f = regex_constants::ECMAScript); + basic_regex& assign(initializer_list, + flag_type = regex_constants::ECMAScript); + + // \ref{re.regex.operations}, const operations + unsigned mark_count() const; + flag_type flags() const; + + // \ref{re.regex.locale}, locale + locale_type imbue(locale_type loc); + locale_type getloc() const; + + // \ref{re.regex.swap}, swap + void swap(basic_regex&); + }; } \end{codeblock} @@ -1454,26 +1414,17 @@ \indexlibrary{\idxcode{basic_regex}!constants}% \begin{codeblock} -static constexpr regex_constants::syntax_option_type - icase = regex_constants::icase; -static constexpr regex_constants::syntax_option_type - nosubs = regex_constants::nosubs; -static constexpr regex_constants::syntax_option_type - optimize = regex_constants::optimize; -static constexpr regex_constants::syntax_option_type - collate = regex_constants::collate; -static constexpr regex_constants::syntax_option_type - ECMAScript = regex_constants::ECMAScript; -static constexpr regex_constants::syntax_option_type - basic = regex_constants::basic; -static constexpr regex_constants::syntax_option_type - extended = regex_constants::extended; -static constexpr regex_constants::syntax_option_type - awk = regex_constants::awk; -static constexpr regex_constants::syntax_option_type - grep = regex_constants::grep; -static constexpr regex_constants::syntax_option_type - egrep = regex_constants::egrep; +static constexpr regex_constants::syntax_option_type icase = regex_constants::icase; +static constexpr regex_constants::syntax_option_type nosubs = regex_constants::nosubs; +static constexpr regex_constants::syntax_option_type optimize = regex_constants::optimize; +static constexpr regex_constants::syntax_option_type collate = regex_constants::collate; +static constexpr regex_constants::syntax_option_type ECMAScript = regex_constants::ECMAScript; +static constexpr regex_constants::syntax_option_type basic = regex_constants::basic; +static constexpr regex_constants::syntax_option_type extended = regex_constants::extended; +static constexpr regex_constants::syntax_option_type awk = regex_constants::awk; +static constexpr regex_constants::syntax_option_type grep = regex_constants::grep; +static constexpr regex_constants::syntax_option_type egrep = regex_constants::egrep; +static constexpr regex_constants::syntax_option_type multiline = regex_constants::multiline; \end{codeblock} \pnum @@ -1622,8 +1573,7 @@ \indexlibrary{\idxcode{basic_regex}!constructor}% \begin{itemdecl} -basic_regex(initializer_list il, - flag_type f = regex_constants::ECMAScript); +basic_regex(initializer_list il, flag_type f = regex_constants::ECMAScript); \end{itemdecl} \begin{itemdescr} @@ -1669,7 +1619,7 @@ \begin{itemdescr} \pnum -\requires \tcode{ptr} shall not be a null pointer. +\requires \tcode{ptr} shall not be a null pointer. \pnum \effects Returns \tcode{assign(ptr)}. @@ -1703,7 +1653,7 @@ \begin{itemdescr} \pnum -\effects Equivalent to \tcode{*this = that}. +\effects Equivalent to \tcode{*this = that}. \pnum \returns \tcode{*this}. @@ -1716,7 +1666,7 @@ \begin{itemdescr} \pnum -\effects Equivalent to \tcode{*this = std::move(that)}. +\effects Equivalent to \tcode{*this = std::move(that)}. \pnum \returns \tcode{*this}. @@ -1734,8 +1684,7 @@ \indexlibrarymember{basic_regex}{assign}% \begin{itemdecl} -basic_regex& assign(const charT* ptr, size_t len, - flag_type f = regex_constants::ECMAScript); +basic_regex& assign(const charT* ptr, size_t len, flag_type f = regex_constants::ECMAScript); \end{itemdecl} \begin{itemdescr} @@ -1892,27 +1841,27 @@ \begin{codeblock} namespace std { template - class sub_match : public pair { - public: - using value_type = - typename iterator_traits::value_type; - using difference_type = - typename iterator_traits::difference_type; - using iterator = BidirectionalIterator; - using string_type = basic_string; - - bool matched; - - constexpr sub_match(); - - difference_type length() const; - operator string_type() const; - string_type str() const; - - int compare(const sub_match& s) const; - int compare(const string_type& s) const; - int compare(const value_type* s) const; - }; + class sub_match : public pair { + public: + using value_type = + typename iterator_traits::value_type; + using difference_type = + typename iterator_traits::difference_type; + using iterator = BidirectionalIterator; + using string_type = basic_string; + + bool matched; + + constexpr sub_match(); + + difference_type length() const; + operator string_type() const; + string_type str() const; + + int compare(const sub_match& s) const; + int compare(const string_type& s) const; + int compare(const value_type* s) const; + }; } \end{codeblock} @@ -1936,7 +1885,7 @@ \end{itemdecl} \begin{itemdescr} -\pnum\returns \tcode{(matched ? distance(first, second) : 0)}. +\pnum\returns \tcode{matched ?\ distance(first, second) :\ 0}. \end{itemdescr} \indexlibrarymember{operator basic_string}{sub_match}% @@ -1945,7 +1894,7 @@ \end{itemdecl} \begin{itemdescr} -\pnum\returns \tcode{matched ? string_type(first, second) : string_type()}. +\pnum\returns \tcode{matched ?\ string_type(first, second) :\ string_type()}. \end{itemdescr} \indexlibrarymember{sub_match}{str}% @@ -1954,7 +1903,7 @@ \end{itemdecl} \begin{itemdescr} -\pnum\returns \tcode{matched ? string_type(first, second) : string_type()}. +\pnum\returns \tcode{matched ?\ string_type(first, second) :\ string_type()}. \end{itemdescr} \indexlibrarymember{sub_match}{compare}% @@ -2050,22 +1999,24 @@ \begin{itemdecl} template bool operator==( - const basic_string< - typename iterator_traits::value_type, ST, SA>& lhs, + const basic_string::value_type, ST, SA>& lhs, const sub_match& rhs); \end{itemdecl} \begin{itemdescr} -\pnum\returns \tcode{rhs.compare(typename sub_match::string_type(lhs.data(), lhs.size())) == 0}. +\pnum +\returns +\begin{codeblock} +rhs.compare(typename sub_match::string_type(lhs.data(), lhs.size())) == 0 +\end{codeblock} \end{itemdescr} \indexlibrarymember{sub_match}{operator"!=}% \begin{itemdecl} template bool operator!=( - const basic_string< - typename iterator_traits::value_type, ST, SA>& lhs, - const sub_match& rhs); + const basic_string::value_type, ST, SA>& lhs, + const sub_match& rhs); \end{itemdecl} \begin{itemdescr} @@ -2076,22 +2027,24 @@ \begin{itemdecl} template bool operator<( - const basic_string< - typename iterator_traits::value_type, ST, SA>& lhs, - const sub_match& rhs); + const basic_string::value_type, ST, SA>& lhs, + const sub_match& rhs); \end{itemdecl} \begin{itemdescr} -\pnum\returns \tcode{rhs.compare(typename sub_match::string_type(lhs.data(), lhs.size())) > 0}. +\pnum +\returns +\begin{codeblock} +rhs.compare(typename sub_match::string_type(lhs.data(), lhs.size())) > 0 +\end{codeblock} \end{itemdescr} \indexlibrarymember{sub_match}{operator>}% \begin{itemdecl} template bool operator>( - const basic_string< - typename iterator_traits::value_type, ST, SA>& lhs, - const sub_match& rhs); + const basic_string::value_type, ST, SA>& lhs, + const sub_match& rhs); \end{itemdecl} \begin{itemdescr} @@ -2102,9 +2055,8 @@ \begin{itemdecl} template bool operator>=( - const basic_string< - typename iterator_traits::value_type, ST, SA>& lhs, - const sub_match& rhs); + const basic_string::value_type, ST, SA>& lhs, + const sub_match& rhs); \end{itemdecl} \begin{itemdescr} @@ -2115,9 +2067,8 @@ \begin{itemdecl} template bool operator<=( - const basic_string< - typename iterator_traits::value_type, ST, SA>& lhs, - const sub_match& rhs); + const basic_string::value_type, ST, SA>& lhs, + const sub_match& rhs); \end{itemdecl} \begin{itemdescr} @@ -2127,22 +2078,26 @@ \indexlibrarymember{operator==}{sub_match}% \begin{itemdecl} template - bool operator==(const sub_match& lhs, - const basic_string< - typename iterator_traits::value_type, ST, SA>& rhs); + bool operator==( + const sub_match& lhs, + const basic_string::value_type, ST, SA>& rhs); \end{itemdecl} \begin{itemdescr} -\pnum\returns \tcode{lhs.compare(typename sub_match::string_type(rhs.data(), rhs.size())) == 0}. +\pnum +\returns +\begin{codeblock} +lhs.compare(typename sub_match::string_type(rhs.data(), rhs.size())) == 0 +\end{codeblock} \end{itemdescr} \indexlibrary{\idxcode{operator"!=}!\idxcode{sub_match}}% \indexlibrary{\idxcode{sub_match}!\idxcode{operator"!=}}% \begin{itemdecl} template - bool operator!=(const sub_match& lhs, - const basic_string< - typename iterator_traits::value_type, ST, SA>& rhs); + bool operator!=( + const sub_match& lhs, + const basic_string::value_type, ST, SA>& rhs); \end{itemdecl} \begin{itemdescr} @@ -2153,21 +2108,25 @@ \indexlibrary{\idxcode{sub_match}!\idxcode{operator<}}% \begin{itemdecl} template - bool operator<(const sub_match& lhs, - const basic_string< - typename iterator_traits::value_type, ST, SA>& rhs); + bool operator<( + const sub_match& lhs, + const basic_string::value_type, ST, SA>& rhs); \end{itemdecl} \begin{itemdescr} -\pnum\returns \tcode{lhs.compare(typename sub_match::string_type(rhs.data(), rhs.size())) < 0}. +\pnum +\returns +\begin{codeblock} +lhs.compare(typename sub_match::string_type(rhs.data(), rhs.size())) < 0 +\end{codeblock} \end{itemdescr} \indexlibrarymember{operator>}{sub_match}% \begin{itemdecl} template - bool operator>(const sub_match& lhs, - const basic_string< - typename iterator_traits::value_type, ST, SA>& rhs); + bool operator>( + const sub_match& lhs, + const basic_string::value_type, ST, SA>& rhs); \end{itemdecl} \begin{itemdescr} @@ -2177,9 +2136,9 @@ \indexlibrarymember{operator>=}{sub_match}% \begin{itemdecl} template - bool operator>=(const sub_match& lhs, - const basic_string< - typename iterator_traits::value_type, ST, SA>& rhs); + bool operator>=( + const sub_match& lhs, + const basic_string::value_type, ST, SA>& rhs); \end{itemdecl} \begin{itemdescr} @@ -2189,9 +2148,9 @@ \indexlibrarymember{operator<=}{sub_match}% \begin{itemdecl} template - bool operator<=(const sub_match& lhs, - const basic_string< - typename iterator_traits::value_type, ST, SA>& rhs); + bool operator<=( + const sub_match& lhs, + const basic_string::value_type, ST, SA>& rhs); \end{itemdecl} \begin{itemdescr} @@ -2476,15 +2435,15 @@ \end{itemdescr} \indexlibrary{\idxcode{basic_ostream}}% -\indexlibrarymember{sub_match}{operator\shl}% +\indexlibrarymember{sub_match}{operator<<}% \begin{itemdecl} template basic_ostream& - operator<<(basic_ostream& os, const sub_match& m); + operator<<(basic_ostream& os, const sub_match& m); \end{itemdecl} \begin{itemdescr} -\pnum\returns \tcode{(os <{}< m.str())}. +\pnum\returns \tcode{os << m.str()}. \end{itemdescr} \rSec1[re.results]{Class template \tcode{match_results}} @@ -2534,83 +2493,80 @@ namespace std { template >> - class match_results { - public: - using value_type = sub_match; - using const_reference = const value_type&; - using reference = value_type&; - using const_iterator = @{\impdef}@; - using iterator = const_iterator; - using difference_type = - typename iterator_traits::difference_type; - using size_type = typename allocator_traits::size_type; - using allocator_type = Allocator; - using char_type = - typename iterator_traits::value_type; - using string_type = basic_string; - - // \ref{re.results.const}, construct/copy/destroy - explicit match_results(const Allocator& a = Allocator()); - match_results(const match_results& m); - match_results(match_results&& m) noexcept; - match_results& operator=(const match_results& m); - match_results& operator=(match_results&& m); - ~match_results(); - - // \ref{re.results.state}, state - bool ready() const; - - // \ref{re.results.size}, size - size_type size() const; - size_type max_size() const; - bool empty() const; - - // \ref{re.results.acc}, element access - difference_type length(size_type sub = 0) const; - difference_type position(size_type sub = 0) const; - string_type str(size_type sub = 0) const; - const_reference operator[](size_type n) const; - - const_reference prefix() const; - const_reference suffix() const; - const_iterator begin() const; - const_iterator end() const; - const_iterator cbegin() const; - const_iterator cend() const; - - // \ref{re.results.form}, format - template - OutputIter - format(OutputIter out, - const char_type* fmt_first, const char_type* fmt_last, - regex_constants::match_flag_type flags = - regex_constants::format_default) const; - template - OutputIter - format(OutputIter out, - const basic_string& fmt, - regex_constants::match_flag_type flags = - regex_constants::format_default) const; - template - basic_string - format(const basic_string& fmt, - regex_constants::match_flag_type flags = - regex_constants::format_default) const; - string_type - format(const char_type* fmt, - regex_constants::match_flag_type flags = - regex_constants::format_default) const; - - // \ref{re.results.all}, allocator - allocator_type get_allocator() const; - - // \ref{re.results.swap}, swap - void swap(match_results& that); - }; + class match_results { + public: + using value_type = sub_match; + using const_reference = const value_type&; + using reference = value_type&; + using const_iterator = @{\impdef}@; + using iterator = const_iterator; + using difference_type = + typename iterator_traits::difference_type; + using size_type = typename allocator_traits::size_type; + using allocator_type = Allocator; + using char_type = + typename iterator_traits::value_type; + using string_type = basic_string; + + // \ref{re.results.const}, construct/copy/destroy + explicit match_results(const Allocator& a = Allocator()); + match_results(const match_results& m); + match_results(match_results&& m) noexcept; + match_results& operator=(const match_results& m); + match_results& operator=(match_results&& m); + ~match_results(); + + // \ref{re.results.state}, state + bool ready() const; + + // \ref{re.results.size}, size + size_type size() const; + size_type max_size() const; + bool empty() const; + + // \ref{re.results.acc}, element access + difference_type length(size_type sub = 0) const; + difference_type position(size_type sub = 0) const; + string_type str(size_type sub = 0) const; + const_reference operator[](size_type n) const; + + const_reference prefix() const; + const_reference suffix() const; + const_iterator begin() const; + const_iterator end() const; + const_iterator cbegin() const; + const_iterator cend() const; + + // \ref{re.results.form}, format + template + OutputIter + format(OutputIter out, + const char_type* fmt_first, const char_type* fmt_last, + regex_constants::match_flag_type flags = regex_constants::format_default) const; + template + OutputIter + format(OutputIter out, + const basic_string& fmt, + regex_constants::match_flag_type flags = regex_constants::format_default) const; + template + basic_string + format(const basic_string& fmt, + regex_constants::match_flag_type flags = regex_constants::format_default) const; + string_type + format(const char_type* fmt, + regex_constants::match_flag_type flags = regex_constants::format_default) const; + + // \ref{re.results.all}, allocator + allocator_type get_allocator() const; + + // \ref{re.results.swap}, swap + void swap(match_results& that); + }; } \end{codeblock} \rSec2[re.results.const]{\tcode{match_results} constructors} + \pnum In all \tcode{match_results} constructors, a copy of the \tcode{Allocator} argument shall be used for any memory allocation performed by the constructor @@ -2859,15 +2815,15 @@ \indexlibrarymember{match_results}{format}% \begin{itemdecl} template - OutputIter format(OutputIter out, - const char_type* fmt_first, const char_type* fmt_last, - regex_constants::match_flag_type flags = - regex_constants::format_default) const; + OutputIter format( + OutputIter out, + const char_type* fmt_first, const char_type* fmt_last, + regex_constants::match_flag_type flags = regex_constants::format_default) const; \end{itemdecl} \begin{itemdescr} \pnum -\requires\ \tcode{ready() == true} and \tcode{OutputIter} shall satisfy the requirements for an +\requires \tcode{ready() == true} and \tcode{OutputIter} shall satisfy the requirements for an Output Iterator~(\ref{output.iterators}). \pnum @@ -2879,16 +2835,16 @@ specifiers and escape sequences are recognized. \pnum -\returns\ \tcode{out}. +\returns \tcode{out}. \end{itemdescr} \indexlibrarymember{match_results}{format}% \begin{itemdecl} template - OutputIter format(OutputIter out, - const basic_string& fmt, - regex_constants::match_flag_type flags = - regex_constants::format_default) const; + OutputIter format( + OutputIter out, + const basic_string& fmt, + regex_constants::match_flag_type flags = regex_constants::format_default) const; \end{itemdecl} \begin{itemdescr} @@ -2902,10 +2858,9 @@ \indexlibrarymember{match_results}{format}% \begin{itemdecl} template - basic_string - format(const basic_string& fmt, - regex_constants::match_flag_type flags = - regex_constants::format_default) const; + basic_string format( + const basic_string& fmt, + regex_constants::match_flag_type flags = regex_constants::format_default) const; \end{itemdecl} \begin{itemdescr} @@ -2916,20 +2871,20 @@ \effects Constructs an empty string \tcode{result} of type \tcode{basic_string} and calls: + \begin{codeblock} format(back_inserter(result), fmt, flags); \end{codeblock} \pnum -\returns\ \tcode{result}. +\returns \tcode{result}. \end{itemdescr} \indexlibrarymember{match_results}{format}% \begin{itemdecl} -string_type - format(const char_type* fmt, - regex_constants::match_flag_type flags = - regex_constants::format_default) const; +string_type format( + const char_type* fmt, + regex_constants::match_flag_type flags = regex_constants::format_default) const; \end{itemdecl} \begin{itemdescr} @@ -2937,15 +2892,14 @@ \requires \tcode{ready() == true}. \pnum -\effects\ Constructs an empty string \tcode{result} of type \tcode{string_type} and +\effects Constructs an empty string \tcode{result} of type \tcode{string_type} and calls: \begin{codeblock} -format(back_inserter(result), - fmt, fmt + char_traits::length(fmt), flags); +format(back_inserter(result), fmt, fmt + char_traits::length(fmt), flags); \end{codeblock} \pnum -\returns\ \tcode{result}. +\returns \tcode{result}. \end{itemdescr} \rSec2[re.results.all]{\tcode{match_results} allocator}% @@ -3038,7 +2992,7 @@ \rSec1[re.alg]{Regular expression algorithms} -\rSec2[re.except]{exceptions} +\rSec2[re.except]{Exceptions} \pnum The algorithms described in this subclause may throw an exception of type \tcode{regex_error}. If such an exception \tcode{e} is thrown, @@ -3052,14 +3006,13 @@ bool regex_match(BidirectionalIterator first, BidirectionalIterator last, match_results& m, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); \end{itemdecl} \begin{itemdescr} \pnum -\requires The type \tcode{BidirectionalIterator} shall satisfy the requirements -of a Bidirectional Iterator ~(\ref{bidirectional.iterators}). +\requires The type \tcode{BidirectionalIterator} shall satisfy the requirements +of a Bidirectional Iterator~(\ref{bidirectional.iterators}). \pnum \effects Determines whether there is a match between the @@ -3162,13 +3115,12 @@ template bool regex_match(BidirectionalIterator first, BidirectionalIterator last, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); \end{itemdecl} \begin{itemdescr} \pnum -\effects Behaves ``as if'' by constructing an instance of +\effects Behaves ``as if'' by constructing an instance of \tcode{match_results what}, and then returning the result of \tcode{regex_match(first, last, what, e, flags)}. @@ -3180,8 +3132,7 @@ bool regex_match(const charT* str, match_results& m, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); \end{itemdecl} \begin{itemdescr} @@ -3193,12 +3144,10 @@ \begin{itemdecl} template bool regex_match(const basic_string& s, - match_results< - typename basic_string::const_iterator, - Allocator>& m, + match_results::const_iterator, + Allocator>& m, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); \end{itemdecl} \begin{itemdescr} @@ -3211,8 +3160,7 @@ template bool regex_match(const charT* str, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); \end{itemdecl} \begin{itemdescr} @@ -3225,8 +3173,7 @@ template bool regex_match(const basic_string& s, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); \end{itemdecl} \begin{itemdescr} @@ -3242,8 +3189,7 @@ bool regex_search(BidirectionalIterator first, BidirectionalIterator last, match_results& m, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); \end{itemdecl} \begin{itemdescr} @@ -3335,33 +3281,29 @@ \indexlibrary{\idxcode{regex_search}}% \begin{itemdecl} template -bool regex_search(const charT* str, match_results& m, - const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + bool regex_search(const charT* str, match_results& m, + const basic_regex& e, + regex_constants::match_flag_type flags = regex_constants::match_default); \end{itemdecl} \begin{itemdescr} \pnum -\returns The result of \tcode{regex_search(str, -str + char_traits::length(str), m, e, flags)}. +\returns \tcode{regex_search(str, str + char_traits::length(str), m, e, flags)}. \end{itemdescr} \indexlibrary{\idxcode{regex_search}}% \begin{itemdecl} template bool regex_search(const basic_string& s, - match_results< - typename basic_string::const_iterator, - Allocator>& m, + match_results::const_iterator, + Allocator>& m, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); \end{itemdecl} \begin{itemdescr} -\pnum\returns The result of \tcode{regex_search(s.begin(), s.end(), m, -e, flags)}. +\pnum +\returns \tcode{regex_search(s.begin(), s.end(), m, e, flags)}. \end{itemdescr} \indexlibrary{\idxcode{regex_search}}% @@ -3369,15 +3311,14 @@ template bool regex_search(BidirectionalIterator first, BidirectionalIterator last, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); \end{itemdecl} \begin{itemdescr} \pnum -\effects Behaves ``as if'' by constructing an object \tcode{what} -of type \tcode{match_results}, and then returning -the result of \tcode{regex_search(first, last, what, e, flags)}. +\effects Behaves ``as if'' by constructing an object \tcode{what} +of type \tcode{match_results} and returning +\tcode{regex_search(first, last, what, e, flags)}. \end{itemdescr} \indexlibrary{\idxcode{regex_search}}% @@ -3385,8 +3326,7 @@ template bool regex_search(const charT* str, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); \end{itemdecl} \begin{itemdescr} @@ -3399,8 +3339,7 @@ template bool regex_search(const basic_string& s, const basic_regex& e, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_constants::match_flag_type flags = regex_constants::match_default); \end{itemdecl} \begin{itemdescr} @@ -3412,23 +3351,20 @@ \indexlibrary{\idxcode{regex_replace}}% \begin{itemdecl} template + class traits, class charT, class ST, class SA> OutputIterator - regex_replace(OutputIterator out, - BidirectionalIterator first, BidirectionalIterator last, - const basic_regex& e, - const basic_string& fmt, - regex_constants::match_flag_type flags = - regex_constants::match_default); -template + regex_replace(OutputIterator out, + BidirectionalIterator first, BidirectionalIterator last, + const basic_regex& e, + const basic_string& fmt, + regex_constants::match_flag_type flags = regex_constants::match_default); +template OutputIterator - regex_replace(OutputIterator out, - BidirectionalIterator first, BidirectionalIterator last, - const basic_regex& e, - const charT* fmt, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_replace(OutputIterator out, + BidirectionalIterator first, BidirectionalIterator last, + const basic_regex& e, + const charT* fmt, + regex_constants::match_flag_type flags = regex_constants::match_default); \end{itemdecl} \begin{itemdescr} @@ -3485,18 +3421,16 @@ \begin{itemdecl} template basic_string - regex_replace(const basic_string& s, - const basic_regex& e, - const basic_string& fmt, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_replace(const basic_string& s, + const basic_regex& e, + const basic_string& fmt, + regex_constants::match_flag_type flags = regex_constants::match_default); template basic_string - regex_replace(const basic_string& s, - const basic_regex& e, - const charT* fmt, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_replace(const basic_string& s, + const basic_regex& e, + const charT* fmt, + regex_constants::match_flag_type flags = regex_constants::match_default); \end{itemdecl} \begin{itemdescr} @@ -3507,38 +3441,35 @@ \end{codeblock} \pnum -\returns\ \tcode{result}. +\returns \tcode{result}. \end{itemdescr} \indexlibrary{\idxcode{regex_replace}}% \begin{itemdecl} template basic_string - regex_replace(const charT* s, - const basic_regex& e, - const basic_string& fmt, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_replace(const charT* s, + const basic_regex& e, + const basic_string& fmt, + regex_constants::match_flag_type flags = regex_constants::match_default); template basic_string - regex_replace(const charT* s, - const basic_regex& e, - const charT* fmt, - regex_constants::match_flag_type flags = - regex_constants::match_default); + regex_replace(const charT* s, + const basic_regex& e, + const charT* fmt, + regex_constants::match_flag_type flags = regex_constants::match_default); \end{itemdecl} \begin{itemdescr} \pnum -\effects Constructs an empty string \tcode{result} of +\effects Constructs an empty string \tcode{result} of type \tcode{basic_string} and calls: \begin{codeblock} -regex_replace(back_inserter(result), - s, s + char_traits::length(s), e, fmt, flags); +regex_replace(back_inserter(result), s, s + char_traits::length(s), e, fmt, flags); \end{codeblock} \pnum -\returns\ \tcode{result}. +\returns \tcode{result}. \end{itemdescr} \rSec1[re.iter]{Regular expression iterators} @@ -3573,43 +3504,40 @@ \begin{codeblock} namespace std { template ::value_type, + class charT = typename iterator_traits::value_type, class traits = regex_traits> - class regex_iterator { - public: - using regex_type = basic_regex; - using iterator_category = forward_iterator_tag; - using value_type = match_results; - using difference_type = ptrdiff_t; - using pointer = const value_type*; - using reference = const value_type&; - - regex_iterator(); - regex_iterator(BidirectionalIterator a, BidirectionalIterator b, - const regex_type& re, - regex_constants::match_flag_type m = - regex_constants::match_default); - regex_iterator(BidirectionalIterator a, BidirectionalIterator b, - const regex_type&& re, - regex_constants::match_flag_type m = - regex_constants::match_default) = delete; - regex_iterator(const regex_iterator&); - regex_iterator& operator=(const regex_iterator&); - bool operator==(const regex_iterator&) const; - bool operator!=(const regex_iterator&) const; - const value_type& operator*() const; - const value_type* operator->() const; - regex_iterator& operator++(); - regex_iterator operator++(int); - - private: - BidirectionalIterator begin; // \expos - BidirectionalIterator end; // \expos - const regex_type* pregex; // \expos - regex_constants::match_flag_type flags; // \expos - match_results match; // \expos - }; + class regex_iterator { + public: + using regex_type = basic_regex; + using iterator_category = forward_iterator_tag; + using value_type = match_results; + using difference_type = ptrdiff_t; + using pointer = const value_type*; + using reference = const value_type&; + + regex_iterator(); + regex_iterator(BidirectionalIterator a, BidirectionalIterator b, + const regex_type& re, + regex_constants::match_flag_type m = regex_constants::match_default); + regex_iterator(BidirectionalIterator, BidirectionalIterator, + const regex_type&&, + regex_constants::match_flag_type = regex_constants::match_default) = delete; + regex_iterator(const regex_iterator&); + regex_iterator& operator=(const regex_iterator&); + bool operator==(const regex_iterator&) const; + bool operator!=(const regex_iterator&) const; + const value_type& operator*() const; + const value_type* operator->() const; + regex_iterator& operator++(); + regex_iterator operator++(int); + + private: + BidirectionalIterator begin; // \expos + BidirectionalIterator end; // \expos + const regex_type* pregex; // \expos + regex_constants::match_flag_type flags; // \expos + match_results match; // \expos + }; } \end{codeblock} @@ -3719,16 +3647,19 @@ \pnum \indexlibrary{\idxcode{match_not_null}}% \indexlibrary{\idxcode{match_continuous}}% -Otherwise, if the iterator holds a zero-length match the operator calls -\tcode{regex_search(start, end, match, *pregex, flags $|$ regex_constants::match_not_null -$|$ regex_constants::match_}\\\tcode{continuous)}. If the call returns \tcode{true} the operator +Otherwise, if the iterator holds a zero-length match, the operator calls: +\begin{codeblock} +regex_search(start, end, match, *pregex, + flags | regex_constants::match_not_null | regex_constants::match_continuous) +\end{codeblock} +If the call returns \tcode{true} the operator returns \tcode{*this}. Otherwise the operator increments \tcode{start} and continues as if the most recent match was not a zero-length match. \pnum \indexlibrary{\idxcode{match_prev_avail}}% If the most recent match was not a zero-length match, the operator sets -\tcode{flags} to \tcode{flags $|$ regex_constants \colcol match_prev_avail} and +\tcode{flags} to \tcode{flags | regex_constants::match_prev_avail} and calls \tcode{regex_search(start, end, match, *pregex, flags)}. If the call returns \tcode{false} the iterator sets \tcode{*this} to the end-of-sequence iterator. The iterator then returns \tcode{*this}. @@ -3834,79 +3765,78 @@ \begin{codeblock} namespace std { template ::value_type, + class charT = typename iterator_traits::value_type, class traits = regex_traits> - class regex_token_iterator { - public: - using regex_type = basic_regex; - using iterator_category = forward_iterator_tag; - using value_type = sub_match; - using difference_type = ptrdiff_t; - using pointer = const value_type*; - using reference = const value_type&; - - regex_token_iterator(); - regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, - const regex_type& re, - int submatch = 0, - regex_constants::match_flag_type m = - regex_constants::match_default); - regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, - const regex_type& re, - const vector& submatches, - regex_constants::match_flag_type m = - regex_constants::match_default); - regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, - const regex_type& re, - initializer_list submatches, - regex_constants::match_flag_type m = - regex_constants::match_default); - template + class regex_token_iterator { + public: + using regex_type = basic_regex; + using iterator_category = forward_iterator_tag; + using value_type = sub_match; + using difference_type = ptrdiff_t; + using pointer = const value_type*; + using reference = const value_type&; + + regex_token_iterator(); + regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, + const regex_type& re, + int submatch = 0, + regex_constants::match_flag_type m = + regex_constants::match_default); + regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, + const regex_type& re, + const vector& submatches, + regex_constants::match_flag_type m = + regex_constants::match_default); + regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, + const regex_type& re, + initializer_list submatches, + regex_constants::match_flag_type m = + regex_constants::match_default); + template + regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, + const regex_type& re, + const int (&submatches)[N], + regex_constants::match_flag_type m = + regex_constants::match_default); + regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, + const regex_type&& re, + int submatch = 0, + regex_constants::match_flag_type m = + regex_constants::match_default) = delete; + regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, + const regex_type&& re, + const vector& submatches, + regex_constants::match_flag_type m = + regex_constants::match_default) = delete; + regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, + const regex_type&& re, + initializer_list submatches, + regex_constants::match_flag_type m = + regex_constants::match_default) = delete; + template regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, - const regex_type& re, - const int (&submatches)[N], - regex_constants::match_flag_type m = - regex_constants::match_default); - regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, - const regex_type&& re, - int submatch = 0, - regex_constants::match_flag_type m = - regex_constants::match_default) = delete; - regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, - const regex_type&& re, - const vector& submatches, - regex_constants::match_flag_type m = - regex_constants::match_default) = delete; - regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, - const regex_type&& re, - initializer_list submatches, - regex_constants::match_flag_type m = - regex_constants::match_default) = delete; - template - regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, - const regex_type&& re, - const int (&submatches)[N], - regex_constants::match_flag_type m = - regex_constants::match_default) = delete; - regex_token_iterator(const regex_token_iterator&); - regex_token_iterator& operator=(const regex_token_iterator&); - bool operator==(const regex_token_iterator&) const; - bool operator!=(const regex_token_iterator&) const; - const value_type& operator*() const; - const value_type* operator->() const; - regex_token_iterator& operator++(); - regex_token_iterator operator++(int); - - private: - using position_iterator = - regex_iterator; // \expos - position_iterator position; // \expos - const value_type* result; // \expos - value_type suffix; // \expos - size_t N; // \expos - vector subs; // \expos - }; + const regex_type&& re, + const int (&submatches)[N], + regex_constants::match_flag_type m = + regex_constants::match_default) = delete; + regex_token_iterator(const regex_token_iterator&); + regex_token_iterator& operator=(const regex_token_iterator&); + bool operator==(const regex_token_iterator&) const; + bool operator!=(const regex_token_iterator&) const; + const value_type& operator*() const; + const value_type* operator->() const; + regex_token_iterator& operator++(); + regex_token_iterator operator++(int); + + private: + using position_iterator = + regex_iterator; // \expos + position_iterator position; // \expos + const value_type* result; // \expos + value_type suffix; // \expos + size_t N; // \expos + vector subs; // \expos + }; } \end{codeblock} @@ -3945,35 +3875,31 @@ \indexlibrary{\idxcode{regex_token_iterator}!constructor}% \begin{itemdecl} regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, - const regex_type& re, - int submatch = 0, - regex_constants::match_flag_type m = - regex_constants::match_default); + const regex_type& re, + int submatch = 0, + regex_constants::match_flag_type m = regex_constants::match_default); regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, - const regex_type& re, - const vector& submatches, - regex_constants::match_flag_type m = - regex_constants::match_default); + const regex_type& re, + const vector& submatches, + regex_constants::match_flag_type m = regex_constants::match_default); regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, - const regex_type& re, - initializer_list submatches, - regex_constants::match_flag_type m = - regex_constants::match_default); + const regex_type& re, + initializer_list submatches, + regex_constants::match_flag_type m = regex_constants::match_default); template regex_token_iterator(BidirectionalIterator a, BidirectionalIterator b, - const regex_type& re, - const int (&submatches)[N], - regex_constants::match_flag_type m = - regex_constants::match_default); + const regex_type& re, + const int (&submatches)[N], + regex_constants::match_flag_type m = regex_constants::match_default); \end{itemdecl} \begin{itemdescr} \pnum -\requires Each of the initialization values of \tcode{submatches} shall be \tcode{>= --1}. +\requires Each of the initialization values of \tcode{submatches} shall be +\tcode{>= -1}. \pnum \effects The first constructor initializes the member \tcode{subs} to hold the single @@ -4256,8 +4182,8 @@ \item During matching of a regular expression finite state machine against a sequence of characters, comparison of a collating element range \tcode{c1-c2} against a character \tcode{c} is -conducted as follows: if \tcode{flags() \& regex_constants \colcol -collate} is false then the character \tcode{c} is matched if \tcode{c1 +conducted as follows: if \tcode{flags() \& regex_constants::collate} +is false then the character \tcode{c} is matched if \tcode{c1 <= c \&\& c <= c2}, otherwise \tcode{c} is matched in accordance with the following algorithm: diff --git a/source/special.tex b/source/special.tex index d198ac6ec1..fde134161f 100644 --- a/source/special.tex +++ b/source/special.tex @@ -3,13 +3,13 @@ \gramSec[gram.special]{Special member functions} -\indextext{special~member~function|see{constructor, destructor, inline function, +\indextext{special member function|see{constructor, destructor, inline function, user-defined conversion, virtual function}}% \indextext{\idxcode{X(X\&)}|see{constructor, copy}}% \indextext{~@\tcode{\tilde}|see{destructor}}% \indextext{assignment!copy|see{assignment operator, copy}}% \indextext{assignment!move|see{assignment operator, move}}% -\indextext{implicitly-declared~default~constructor|see{constructor, default}} +\indextext{implicitly-declared default constructor|see{constructor, default}} \pnum \indextext{constructor!default}% @@ -33,7 +33,7 @@ \pnum Programs may explicitly refer to implicitly-declared special member functions. \begin{example} -a program may explicitly call, take the address of or form a pointer to member +A program may explicitly call, take the address of, or form a pointer to member to an implicitly-declared special member function. \begin{codeblock} @@ -56,10 +56,10 @@ \end{note} \pnum -\indextext{access control!member~function~and}% +\indextext{access control!member function and}% Special member functions obey the usual access rules (Clause~\ref{class.access}). \begin{example} -declaring a constructor +Declaring a constructor \tcode{protected} ensures that only derived classes and friends can create objects using it. \end{example} @@ -132,8 +132,8 @@ \end{note} \pnum -\indextext{\idxcode{const}!constructor~and}% -\indextext{\idxcode{volatile}!constructor~and}% +\indextext{\idxcode{const}!constructor and}% +\indextext{\idxcode{volatile}!constructor and}% A constructor can be invoked for a \tcode{const}, \tcode{volatile} @@ -150,7 +150,7 @@ most derived object~(\ref{intro.object}) ends. \pnum -\indextext{constructor!inheritance~of}% +\indextext{constructor!inheritance of}% \indextext{constructor!default}% \indextext{constructor!non-trivial}% A @@ -164,7 +164,7 @@ that is not a function parameter pack has a default argument (including the case of a constructor with no parameters). -\indextext{implicitly-declared~default~constructor}% +\indextext{implicitly-declared default constructor}% If there is no user-declared constructor for class \tcode{X}, a non-explicit constructor having no parameters is implicitly declared @@ -253,7 +253,7 @@ If that user-written default constructor would be ill-formed, the program is ill-formed. If that user-written default constructor would satisfy the requirements -of a \tcode{constexpr} constructor~(\ref{dcl.constexpr}), the implicitly-defined +of a constexpr constructor~(\ref{dcl.constexpr}), the implicitly-defined default constructor is \tcode{constexpr}. Before the defaulted default constructor for a class is implicitly defined, @@ -283,8 +283,8 @@ \pnum \begin{note} -\indextext{order~of~execution!base~class constructor}% -\indextext{order~of~execution!member constructor}% +\indextext{order of execution!base class constructor}% +\indextext{order of execution!member constructor}% \ref{class.base.init} describes the order in which constructors for base classes and non-static data members are called and describes how arguments can be specified for the calls to these constructors. @@ -295,7 +295,7 @@ A \tcode{return} statement in the body of a constructor shall not specify a return value. -\indextext{constructor!address~of}% +\indextext{constructor!address of}% The address of a constructor shall not be taken. \pnum @@ -326,8 +326,8 @@ \pnum \begin{note} -\indextext{member function!constructor~and}% -some language constructs have special semantics when used during construction; +\indextext{member function!constructor and}% +Some language constructs have special semantics when used during construction; see~\ref{class.base.init} and~\ref{class.cdtor}. \end{note} @@ -370,11 +370,11 @@ \rSec1[class.temporary]{Temporary objects} \pnum -\indextext{object~temporary|see{temporary}}% +\indextext{object temporary|see{temporary}}% \indextext{temporary}% -\indextext{optimization~of~temporary|see{temporary, elimination~of}}% -\indextext{temporary!elimination~of}% -\indextext{temporary!implementation-defined~generation~of}% +\indextext{optimization of temporary|see{temporary, elimination of}}% +\indextext{temporary!elimination of}% +\indextext{temporary!implementation-defined generation of}% Temporary objects are created \begin{itemize} \item @@ -393,7 +393,7 @@ all the semantic restrictions shall be respected as if the temporary object had been created and later destroyed. \begin{note} -This includes accessibility~(\ref{class.access}) and whether it is deleted, +This includes accessibility (Clause~\ref{class.access}) and whether it is deleted, for the constructor selected and for the destructor. However, in the special case of the operand of a \grammarterm{decltype-specifier}~(\ref{expr.call}), no temporary is introduced, @@ -450,7 +450,7 @@ } \end{codeblock} -\indextext{class~object~copy|see{constructor, copy}}% +\indextext{class object copy|see{constructor, copy}}% \indextext{constructor!copy}% \tcode{X(2)} is constructed in the space used to hold \tcode{f()}'s argument and \tcode{Y(3)} is constructed in the space used to hold \tcode{g()}'s argument. @@ -488,9 +488,9 @@ \end{note} \pnum -\indextext{temporary!constructor~for}% -\indextext{temporary!destructor~for}% -\indextext{temporary!destruction~of}% +\indextext{temporary!constructor for}% +\indextext{temporary!destructor for}% +\indextext{temporary!destruction of}% When an implementation introduces a temporary object of a class that has a non-trivial constructor~(\ref{class.ctor}, \ref{class.copy}), it shall ensure that a constructor is called for the temporary object. @@ -511,8 +511,8 @@ subexpression. \pnum -\indextext{initializer!temporary~and declarator}% -\indextext{temporary!order~of destruction~of}% +\indextext{initializer!temporary and declarator}% +\indextext{temporary!order of destruction of}% There are three contexts in which temporaries are destroyed at a different point than the end of the full-expression. The first context is when a default constructor is called to initialize @@ -547,6 +547,7 @@ \end{example} \begin{note} This may introduce a dangling reference, and implementations are encouraged to issue a warning in such a case. \end{note} \end{itemize} +\pnum The destruction of a temporary whose lifetime is not extended by being bound to a reference is sequenced before the destruction of every temporary which is constructed earlier in the same full-expression. @@ -571,8 +572,9 @@ the temporary shall be destroyed after \tcode{obj2} is destroyed. -\begin{example} +\pnum +\begin{example} \begin{codeblock} struct S { S(); @@ -658,7 +660,7 @@ \indextext{conversion!class}% \indextext{conversion!user-defined}% \indextext{constructor, conversion by|see{conversion, user-defined}}% -\indextext{conversion~function|see{conversion, user-defined}}% +\indextext{conversion function|see{conversion, user-defined}}% \indextext{conversion!implicit}% Type conversions of class objects can be specified by constructors and by conversion functions. @@ -683,9 +685,7 @@ \indextext{conversion!implicit user-defined}% At most one user-defined conversion (constructor or conversion function) is implicitly applied to a single value. - \begin{example} - \begin{codeblock} struct X { operator int(); @@ -696,21 +696,19 @@ }; Y a; -int b = a; // error - // \tcode{a.operator X().operator int()} not tried +int b = a; // error, \tcode{a.operator X().operator int()} not tried int c = X(a); // OK: \tcode{a.operator X().operator int()} \end{codeblock} \end{example} \pnum User-defined conversions are used implicitly only if they are unambiguous. -\indextext{name~hiding!user-defined conversion~and}% +\indextext{name hiding!user-defined conversion and}% A conversion function in a derived class does not hide a conversion function in a base class unless the two functions convert to the same type. Function overload resolution~(\ref{over.match.best}) selects the best conversion function to perform the conversion. \begin{example} - \begin{codeblock} struct X { operator int(); @@ -721,15 +719,14 @@ }; void f(Y& a) { - if (a) { // ill-formed: - // \tcode{X::operator int()} or \tcode{Y::operator char()} + if (a) { // ill-formed: \tcode{X::operator int()} or \tcode{Y::operator char()} } } \end{codeblock} \end{example} \rSec2[class.conv.ctor]{Conversion by constructor}% -\indextext{conversion!user-defined} +\indextext{conversion!user-defined}% \pnum A constructor declared without the @@ -764,13 +761,13 @@ \pnum \begin{note} An explicit constructor constructs objects just like non-explicit -constructors, but does so only where the direct-initialization syntax~(\ref{dcl.init}) or where casts~(\ref{expr.static.cast}, \ref{expr.cast}) are explicitly +constructors, but does so only where the direct-initialization syntax~(\ref{dcl.init}) +or where casts~(\ref{expr.static.cast}, \ref{expr.cast}) are explicitly used; see also~\ref{over.match.copy}. A default constructor may be an explicit constructor; such a constructor will be used to perform default-initialization or value-initialization~(\ref{dcl.init}). \begin{example} - \begin{codeblock} struct Z { explicit Z(); @@ -803,7 +800,7 @@ \rSec2[class.conv.fct]{Conversion functions}% \indextext{function!conversion}% -\indextext{fundamental~type~conversion|see{conversion, user-defined}}% +\indextext{fundamental type conversion|see{conversion, user-defined}}% \indextext{conversion!user-defined}% \pnum @@ -828,11 +825,11 @@ \tcode{X} to the type specified by the \grammarterm{conversion-type-id}. -Such functions are called \defn{conversion function}{s}. +Such functions are called \defnx{conversion functions}{conversion function}. A \grammarterm{decl-specifier} in the \grammarterm{decl-specifier-seq} of a conversion function (if any) shall be neither a \grammarterm{defining-type-specifier} nor \tcode{static}. -\indextext{conversion!type~of}% +\indextext{conversion!type of}% The type of the conversion function~(\ref{dcl.fct}) is ``function taking no parameter returning \grammarterm{conversion-type-id}''. @@ -844,13 +841,11 @@ Even though never directly called to perform a conversion, such conversion functions can be declared and can potentially be reached through a call to a virtual conversion function in a base class.} - \begin{example} - \begin{codeblock} struct X { operator int(); - operator auto() -> short; // error: trailing return type + operator auto() -> short; // error: trailing return type }; void f(X a) { @@ -859,7 +854,6 @@ i = a; } \end{codeblock} - In all three cases the value assigned will be converted by \tcode{X::operator int()}. \end{example} @@ -867,7 +861,6 @@ \pnum A conversion function may be explicit~(\ref{dcl.fct.spec}), in which case it is only considered as a user-defined conversion for direct-initialization~(\ref{dcl.init}). Otherwise, user-defined conversions are not restricted to use in assignments and initializations. \begin{example} - \begin{codeblock} class Y { }; struct Z { @@ -903,26 +896,23 @@ This prevents ambiguities between the declarator operator \tcode{*} and its expression counterparts. \begin{example} - \begin{codeblock} &ac.operator int*i; // syntax error: // parsed as: \tcode{\&(ac.operator int *)i} // not as: \tcode{\&(ac.operator int)*i} \end{codeblock} - The \tcode{*} is the pointer declarator and not the multiplication operator. \end{example} - This rule also prevents ambiguities for attributes. \begin{example} \begin{codeblock} -operator int [[noreturn]] (); // error: \tcode{noreturn} attribute applied to a type +operator int [[noreturn]] (); // error: \tcode{noreturn} attribute applied to a type \end{codeblock} \end{example} \end{note} \pnum -\indextext{conversion!inheritance~of user-defined}% +\indextext{conversion!inheritance of user-defined}% Conversion functions are inherited. \pnum @@ -930,15 +920,15 @@ Conversion functions can be virtual. \pnum -\indextext{conversion!deduced~return~type~of user-defined}% +\indextext{conversion!deduced return type of user-defined}% A conversion function template shall not have a deduced return type~(\ref{dcl.spec.auto}). \begin{example} \begin{codeblock} struct S { - operator auto() const { return 10; } // OK + operator auto() const { return 10; } // OK template - operator auto() const { return 1.2; } // error: conversion function template + operator auto() const { return 1.2; } // error: conversion function template }; \end{codeblock} \end{example} @@ -991,8 +981,8 @@ A destructor is used to destroy objects of its class type. \indextext{restriction!destructor}% The address of a destructor shall not be taken. -\indextext{\idxcode{const}!destructor~and}% -\indextext{\idxcode{volatile}!destructor~and}% +\indextext{\idxcode{const}!destructor and}% +\indextext{\idxcode{volatile}!destructor and}% A destructor can be invoked for a \tcode{const}, \tcode{volatile} @@ -1014,7 +1004,7 @@ \end{note} \pnum -\indextext{generated~destructor|see{destructor, default}}% +\indextext{generated destructor|see{destructor, default}}% \indextext{destructor!default}% \indextext{destructor!non-trivial}% If a class has no user-declared @@ -1073,9 +1063,9 @@ implicitly defined. \pnum -\indextext{order~of~execution!destructor}% -\indextext{order~of~execution!base~class destructor}% -\indextext{order~of~execution!member destructor}% +\indextext{order of execution!destructor}% +\indextext{order of execution!base class destructor}% +\indextext{order of execution!member destructor}% After executing the body of the destructor and destroying any automatic objects allocated within the body, a destructor for class @@ -1100,7 +1090,7 @@ statement~(\ref{stmt.return}) in a destructor might not directly return to the caller; before transferring control to the caller, the destructors for the members and bases are called. -\indextext{order~of~execution!destructor~and array}% +\indextext{order of execution!destructor and array}% Destructors for elements of an array are called in reverse order of their construction (see~\ref{class.init}). @@ -1118,14 +1108,14 @@ \pnum \begin{note} -\indextext{member function!destructor~and}% -some language constructs have special semantics when used during destruction; +\indextext{member function!destructor and}% +Some language constructs have special semantics when used during destruction; see~\ref{class.cdtor}. \end{note} \pnum \indextext{destructor!implicit call}% -\indextext{destructor!program termination~and}% +\indextext{destructor!program termination and}% A destructor is invoked implicitly \begin{itemize} @@ -1139,7 +1129,7 @@ \item for a constructed temporary object when its lifetime ends~(\ref{conv.rval}, \ref{class.temporary}). \end{itemize} -\indextext{\idxcode{delete}!destructor~and}% +\indextext{\idxcode{delete}!destructor and}% \indextext{destructor!explicit call}% In each case, the context of the invocation is the context of the construction of the object. A destructor is also invoked implicitly through use of a @@ -1180,7 +1170,7 @@ not of a class derived from the destructor's class type (including when the destructor is invoked via a null pointer value), the program has undefined behavior. -\begin{note} invoking \tcode{delete} on a null pointer does not call the +\begin{note} Invoking \tcode{delete} on a null pointer does not call the destructor; see \ref{expr.delete}. \end{note} \begin{example} @@ -1216,8 +1206,8 @@ \pnum \begin{note} -\indextext{object!destructor~and placement~of}% -explicit calls of destructors are rarely needed. +\indextext{object!destructor and placement of}% +Explicit calls of destructors are rarely needed. One use of such calls is for objects placed at specific addresses using a placement \grammarterm{new-expression}. @@ -1225,8 +1215,7 @@ to cope with dedicated hardware resources and for writing memory management facilities. For example, -\indextext{example!explicit destructor~call}% - +\indextext{example!explicit destructor call}% \begin{codeblock} void* operator new(std::size_t, void* p) { return p; } struct X { @@ -1249,20 +1238,19 @@ the behavior is undefined if the destructor is invoked for an object whose lifetime has ended~(\ref{basic.life}). \begin{example} -if the destructor for an automatic object is explicitly invoked, +If the destructor for an automatic object is explicitly invoked, and the block is subsequently left in a manner that would ordinarily invoke implicit destruction of the object, the behavior is undefined. \end{example} \pnum \begin{note} -\indextext{fundamental~type!destructor~and}% -the notation for explicit call of a destructor can be used for any scalar type +\indextext{fundamental type!destructor and}% +The notation for explicit call of a destructor can be used for any scalar type name~(\ref{expr.pseudo}). Allowing this makes it possible to write code without having to know if a destructor exists for a given type. -For example, - +For example: \begin{codeblock} typedef int I; I* p; @@ -1274,7 +1262,7 @@ \indextext{free store}% \pnum -\indextext{\idxcode{new}!type~of} +\indextext{\idxcode{new}!type of} Any allocation function for a class \tcode{T} is a static member (even if not explicitly declared @@ -1282,7 +1270,6 @@ \pnum \begin{example} - \begin{codeblock} class Arena; struct B { @@ -1339,7 +1326,7 @@ selects a placement deallocation function, the program is ill-formed. \pnum -\indextext{\idxcode{delete}!type~of}% +\indextext{\idxcode{delete}!type of}% Any deallocation function for a class \tcode{X} is a static member (even if not explicitly declared @@ -1365,9 +1352,9 @@ \tcode{static} they cannot be virtual. \begin{note} -\indextext{example!destructor~and \tcode{delete}}% -\indextext{example!scope~of \tcode{delete}}% -however, when the +\indextext{example!destructor and \tcode{delete}}% +\indextext{example!scope of \tcode{delete}}% +However, when the \grammarterm{cast-expression} of a \grammarterm{delete-expression} @@ -1376,7 +1363,6 @@ the class that is the dynamic type of the object, if the destructor is virtual, the effect is the same. For example, - \begin{codeblock} struct B { virtual ~B(); @@ -1392,7 +1378,6 @@ delete bp; // 1: uses \tcode{D::operator delete(void*)} } \end{codeblock} - Here, storage for the non-array object of class \tcode{D} is deallocated by @@ -1407,7 +1392,6 @@ \grammarterm{delete-expression} refers to an array of objects of class type. For example, - \begin{codeblock} struct B { virtual ~B(); @@ -1432,7 +1416,7 @@ Hence, even though a different one might actually be executed, the statically visible deallocation function is required to be accessible. \begin{example} -for the call on line //1 above, +For the call on line ``// 1'' above, if \tcode{B::operator delete()} had been @@ -1447,9 +1431,9 @@ \end{note} \rSec1[class.init]{Initialization}% -\indextext{initialization!class~object|(}% +\indextext{initialization!class object|(}% \indextext{initialization!default constructor and}% -\indextext{initialization!constructor~and} +\indextext{initialization!constructor and} \pnum When no initializer is specified for an object of (possibly @@ -1463,7 +1447,7 @@ see~\ref{class.expl.init} and~\ref{class.base.init}. \pnum -\indextext{order~of~execution!constructor~and array}% +\indextext{order of execution!constructor and array}% When an array of class objects is initialized (either explicitly or implicitly) and the elements are initialized by constructor, the constructor shall be called for each element of the array, @@ -1475,7 +1459,7 @@ \rSec2[class.expl.init]{Explicit initialization}% \indextext{initialization!explicit}% -\indextext{initialization!constructor~and}% +\indextext{initialization!constructor and}% \pnum An object of class type can be initialized with a parenthesized @@ -1493,9 +1477,8 @@ form of initialization. Either direct-initialization semantics or copy-initialization semantics apply; see~\ref{dcl.init}. -\indextext{example!constructor~and initialization}% +\indextext{example!constructor and initialization}% \begin{example} - \begin{codeblock} struct complex { complex(); @@ -1505,32 +1488,25 @@ complex sqrt(complex,complex); -complex a(1); // initialize by a call of - // \tcode{complex(double)} +complex a(1); // initialize by a call of \tcode{complex(double)} complex b = a; // initialize by a copy of \tcode{a} -complex c = complex(1,2); // construct \tcode{complex(1,2)} - // using \tcode{complex(double,double)} +complex c = complex(1,2); // construct \tcode{complex(1,2)} using \tcode{complex(double,double)}, // copy/move it into \tcode{c} -complex d = sqrt(b,c); // call \tcode{sqrt(complex,complex)} - // and copy/move the result into \tcode{d} -complex e; // initialize by a call of - // \tcode{complex()} -complex f = 3; // construct \tcode{complex(3)} using - // \tcode{complex(double)} - // copy/move it into \tcode{f} -complex g = { 1, 2 }; // initialize by a call of - // \tcode{complex(double, double)} +complex d = sqrt(b,c); // call \tcode{sqrt(complex,complex)} and copy/move the result into \tcode{d} +complex e; // initialize by a call of \tcode{complex()} +complex f = 3; // construct \tcode{complex(3)} using \tcode{complex(double)}, copy/move it into \tcode{f} +complex g = { 1, 2 }; // initialize by a call of \tcode{complex(double, double)} \end{codeblock} \end{example} \begin{note} -\indextext{initialization!overloaded assignment~and}% -overloading of the assignment operator~(\ref{over.ass}) +\indextext{initialization!overloaded assignment and}% +Overloading of the assignment operator~(\ref{over.ass}) has no effect on initialization. \end{note} \pnum -\indextext{initialization!array~of class~objects}% -\indextext{constructor!array~of class~objects~and}% +\indextext{initialization!array of class objects}% +\indextext{constructor!array of class objects and}% An object of class type can also be initialized by a \grammarterm{braced-init-list}. List-initialization semantics apply; see~\ref{dcl.init} and~\ref{dcl.init.list}. \begin{example} @@ -1594,18 +1570,18 @@ \pnum \begin{note} -\indextext{order~of~execution!constructor~and \tcode{static}~objects}% -the order in which objects with static or thread storage duration +\indextext{order of execution!constructor and \tcode{static} objects}% +The order in which objects with static or thread storage duration are initialized is described in~\ref{basic.start.dynamic} and~\ref{stmt.dcl}. \end{note} \rSec2[class.base.init]{Initializing bases and members}% -\indextext{initialization!base~class}% +\indextext{initialization!base class}% \indextext{initialization!member} \pnum In the definition of a constructor for a class, -initializers for direct and virtual base subobjects and +initializers for direct and virtual base class subobjects and non-static data members can be specified by a \grammarterm{ctor-initializer}, which has the form @@ -1668,7 +1644,7 @@ typedef A global_A; struct B { }; struct C: public A, public B { C(); }; -C::C(): global_A() { } // mem-initializer for base \tcode{A} +C::C(): global_A() { } // mem-initializer for base \tcode{A} \end{codeblock} \end{example} @@ -1707,10 +1683,10 @@ A \grammarterm{mem-initializer-list} can delegate to another constructor of the constructor's class using any \grammarterm{class-or-decltype} that denotes the constructor's class itself. If a -\nonterminal{mem-initializer-id} designates the constructor's class, -it shall be the only \nonterminal{mem-initializer}; the constructor +\grammarterm{mem-initializer-id} designates the constructor's class, +it shall be the only \grammarterm{mem-initializer}; the constructor is a \term{delegating constructor}, and the constructor selected by the -\nonterminal{mem-initializer} is the \term{target constructor}. +\grammarterm{mem-initializer} is the \term{target constructor}. The target constructor is selected by overload resolution. Once the target constructor returns, the body of the delegating constructor is executed. If a constructor delegates to itself directly or indirectly, @@ -1727,8 +1703,8 @@ \end{example} \pnum -\indextext{initialization!base~class}% -\indextext{initialization!member~object}% +\indextext{initialization!base class}% +\indextext{initialization!member object}% The \grammarterm{expression-list} or \grammarterm{braced-init-list} @@ -1737,20 +1713,17 @@ is used to initialize the designated subobject (or, in the case of a delegating constructor, the complete class object) according to the initialization rules of~\ref{dcl.init} for direct-initialization. - \begin{example} - \begin{codeblock} -struct B1 { B1(int); /* ... */ }; -struct B2 { B2(int); /* ... */ }; +struct B1 { B1(int); @\commentellip@ }; +struct B2 { B2(int); @\commentellip@ }; struct D : B1, B2 { D(int); B1 b; const int c; }; -D::D(int a) : B2(a+1), B1(a+2), c(a+3), b(a+4) - { /* ... */ } +D::D(int a) : B2(a+1), B1(a+2), c(a+3), b(a+4) { @\commentellip@ } D d(10); \end{codeblock} \end{example} @@ -1773,7 +1746,7 @@ \begin{example} \begin{codeblock} struct A { - A() : v(42) { } // error + A() : v(42) { } // error const int& v; }; \end{codeblock} @@ -1842,10 +1815,10 @@ struct C { C() { } // initializes members as follows: - A a; // OK: calls \tcode{A::A()} - const B b; // error: \tcode{B} has no default constructor - int i; // OK: \tcode{i} has indeterminate value - int j = 5; // OK: \tcode{j} has the value \tcode{5} + A a; // OK: calls \tcode{A::A()} + const B b; // error: \tcode{B} has no default constructor + int i; // OK: \tcode{i} has indeterminate value + int j = 5; // OK: \tcode{j} has the value \tcode{5} }; \end{codeblock} \end{example} @@ -1861,7 +1834,7 @@ % ligature), so we fix it up manually. \begin{codeblock} struct A { - int i = /* @\textrm{\textit{some integer expression with side effects}}@ */ ; + int i = /* some integer expression with side effects */ ; A(int arg) : i(arg) { } // ... }; @@ -1880,12 +1853,12 @@ \begin{example} \begin{codeblock} struct A { - A() = default; // OK - A(int v) : v(v) { } // OK - const int& v = 42; // OK + A() = default; // OK + A(int v) : v(v) { } // OK + const int& v = 42; // OK }; -A a1; // error: ill-formed binding of temporary to reference -A a2(1); // OK, unfortunately +A a1; // error: ill-formed binding of temporary to reference +A a2(1); // OK, unfortunately \end{codeblock} \end{example} @@ -1898,10 +1871,9 @@ \pnum In a non-delegating constructor, initialization proceeds in the following order: - \begin{itemize} \item -\indextext{initialization!order~of virtual~base~class}% +\indextext{initialization!order of virtual base class}% First, and only for the constructor of the most derived class~(\ref{intro.object}), virtual base classes are initialized in the order they appear on a depth-first left-to-right traversal of the directed acyclic graph of @@ -1910,14 +1882,14 @@ in the derived class \grammarterm{base-specifier-list}. \item -\indextext{initialization!order~of base~class}% +\indextext{initialization!order of base class}% Then, direct base classes are initialized in declaration order as they appear in the \grammarterm{base-specifier-list} (regardless of the order of the \grammarterm{mem-initializers}). \item -\indextext{initialization!order~of member}% +\indextext{initialization!order of member}% Then, non-static data members are initialized in the order they were declared in the class definition (again regardless of the order of the @@ -1955,9 +1927,9 @@ C(int); }; -A::A(int i) : V(i) { /* ... */ } -B::B(int i) { /* ... */ } -C::C(int i) { /* ... */ } +A::A(int i) : V(i) { @\commentellip@ } +B::B(int i) { @\commentellip@ } +C::C(int i) { @\commentellip@ } V v(1); // use \tcode{V(int)} A a(2); // use \tcode{V(int)} @@ -1967,7 +1939,7 @@ \end{example} \pnum -\indextext{initializer!scope~of member}% +\indextext{initializer!scope of member}% Names in the \grammarterm{expression-list} or \grammarterm{braced-init-list} @@ -2038,7 +2010,6 @@ \grammarterm{mem-initializer}{s} for base classes have completed, the program has undefined behavior. \begin{example} - \begin{codeblock} class A { public: @@ -2049,8 +2020,7 @@ int j; public: int f(); - B() : A(f()), // undefined: calls member function - // but base \tcode{A} not yet initialized + B() : A(f()), // undefined: calls member function but base \tcode{A} not yet initialized j(f()) { } // well-defined: bases are all initialized }; @@ -2062,8 +2032,7 @@ class D : public B, C { int i; public: - D() : C(f()), // undefined: calls member function - // but base \tcode{C} not yet initialized + D() : C(f()), // undefined: calls member function but base \tcode{C} not yet initialized i(f()) { } // well-defined: bases are all initialized }; \end{codeblock} @@ -2096,11 +2065,10 @@ }; \end{codeblock} -\end{example}% -\indextext{initialization!class~object|)} +\end{example} \rSec2[class.inhctor.init]{Initialization by inherited constructor}% -\indextext{initialization!by~inherited~constructor} +\indextext{initialization!by inherited constructor} \pnum When a constructor for type \tcode{B} is invoked @@ -2127,16 +2095,16 @@ int get(); struct D1 : B1 { - using B1::B1; // inherits \tcode{B1(int, ...)} + using B1::B1; // inherits \tcode{B1(int, ...)} int x; int y = get(); }; void test() { - D1 d(2, 3, 4); // OK: \tcode{B1} is initialized by calling \tcode{B1(2, 3, 4)}, - // then \tcode{d.x} is default-initialized (no initialization is performed), - // then \tcode{d.y} is initialized by calling \tcode{get()} - D1 e; // error: \tcode{D1} has a deleted default constructor + D1 d(2, 3, 4); // OK: \tcode{B1} is initialized by calling \tcode{B1(2, 3, 4)}, + // then \tcode{d.x} is default-initialized (no initialization is performed), + // then \tcode{d.y} is initialized by calling \tcode{get()} + D1 e; // error: \tcode{D1} has a deleted default constructor } struct D2 : B2 { @@ -2144,16 +2112,16 @@ B1 b; }; -D2 f(1.0); // error: \tcode{B1} has a deleted default constructor +D2 f(1.0); // error: \tcode{B1} has a deleted default constructor struct W { W(int); }; struct X : virtual W { using W::W; X() = delete; }; struct Y : X { using X::X; }; struct Z : Y, virtual W { using Y::Y; }; -Z z(0); // OK: initialization of \tcode{Y} does not invoke default constructor of \tcode{X} +Z z(0); // OK: initialization of \tcode{Y} does not invoke default constructor of \tcode{X} template struct Log : T { - using T::T; // inherits all constructors from class \tcode{T} + using T::T; // inherits all constructors from class \tcode{T} ~Log() { std::clog << "Destroying wrapper" << std::endl; } }; \end{codeblock} @@ -2186,27 +2154,28 @@ using V2::V2; }; -D1 d1(0); // ill-formed: ambiguous -D2 d2(0); // OK: initializes virtual \tcode{B} base class, which initializes the \tcode{A} base class - // then initializes the \tcode{V1} and \tcode{V2} base classes as if by a defaulted default constructor +D1 d1(0); // ill-formed: ambiguous +D2 d2(0); // OK: initializes virtual \tcode{B} base class, which initializes the \tcode{A} base class + // then initializes the \tcode{V1} and \tcode{V2} base classes as if by a defaulted default constructor struct M { M(); M(int); }; struct N : M { using M::M; }; struct O : M {}; struct P : N, O { using N::N; using O::O; }; -P p(0); // OK: use \tcode{M(0)} to initialize \tcode{N}{'s} base class, - // use \tcode{M()} to initialize \tcode{O}{'s} base class +P p(0); // OK: use \tcode{M(0)} to initialize \tcode{N}{'s} base class, + // use \tcode{M()} to initialize \tcode{O}{'s} base class \end{codeblock} \end{example} \pnum When an object is initialized by an inherited constructor, initialization of the object is complete -when the initialization of all subobjects is complete. +when the initialization of all subobjects is complete.% +\indextext{initialization!class object|)} \rSec1[class.cdtor]{Construction and destruction}% \indextext{construction|(}% -\indextext{destruction|(} +\indextext{destruction|(}% \pnum \indextext{construction!member access}% @@ -2217,7 +2186,6 @@ any non-static member or base class of the object after the destructor finishes execution results in undefined behavior. \begin{example} - \begin{codeblock} struct X { int i; }; struct Y : X { Y(); }; // non-trivial @@ -2236,10 +2204,7 @@ int* p3 = &xobj.i; // OK, \tcode{X} is a trivial class X xobj; \end{codeblock} - -\pnum For another example, - \begin{codeblock} struct W { int j; }; struct X : public virtual W { }; @@ -2278,7 +2243,6 @@ otherwise the computation of the pointer value (or accessing the member value) results in undefined behavior. \begin{example} - \begin{codeblock} struct A { }; struct B : virtual A { }; @@ -2287,23 +2251,20 @@ struct X { X(A*); }; struct E : C, D, X { - E() : D(this), // undefined: upcast from \tcode{E*} to \tcode{A*} - // might use path \tcode{E*} $\rightarrow$ \tcode{D*} $\rightarrow$ \tcode{A*} + E() : D(this), // undefined: upcast from \tcode{E*} to \tcode{A*} might use path \tcode{E*} $\rightarrow$ \tcode{D*} $\rightarrow$ \tcode{A*} // but \tcode{D} is not constructed - // \tcode{D((C*)this)}, // defined: - // \tcode{E*} $\rightarrow$ \tcode{C*} defined because \tcode{E()} has started - // and \tcode{C*} $\rightarrow$ \tcode{A*} defined because - // \tcode{C} fully constructed - X(this) { // defined: upon construction of \tcode{X}, - // \tcode{C/B/D/A} sublattice is fully constructed - } + + // ``\tcode{D((C*)this)}\!'' would be defined: \tcode{E*} $\rightarrow$ \tcode{C*} is defined because \tcode{E()} has started, + // and \tcode{C*} $\rightarrow$ \tcode{A*} is defined because \tcode{C} is fully constructed + + X(this) {} // defined: upon construction of \tcode{X}, \tcode{C/B/D/A} sublattice is fully constructed }; \end{codeblock} \end{example} \pnum -\indextext{virtual~function~call!constructor~and}% -\indextext{virtual~function~call!destructor~and}% +\indextext{virtual function call!constructor and}% +\indextext{virtual function call!destructor and}% \indextext{construction!virtual function call}% \indextext{destruction!virtual function call}% Member functions, including virtual functions~(\ref{class.virtual}), can be called @@ -2405,9 +2366,7 @@ own class or one of its bases, the \tcode{dynamic_cast} results in undefined behavior. - \begin{example} - \begin{codeblock} struct V { virtual void f(); @@ -2425,22 +2384,19 @@ B::B(V* v, A* a) { typeid(*this); // \tcode{type_info} for \tcode{B} - typeid(*v); // well-defined: \tcode{*v} has type \tcode{V}, a base of \tcode{B} - // yields \tcode{type_info} for \tcode{B} + typeid(*v); // well-defined: \tcode{*v} has type \tcode{V}, a base of \tcode{B} yields \tcode{type_info} for \tcode{B} typeid(*a); // undefined behavior: type \tcode{A} not a base of \tcode{B} - dynamic_cast(v); // well-defined: \tcode{v} of type \tcode{V*}, \tcode{V} base of \tcode{B} - // results in \tcode{B*} - dynamic_cast(a); // undefined behavior, - // \tcode{a} has type \tcode{A*}, \tcode{A} not a base of \tcode{B} + dynamic_cast(v); // well-defined: \tcode{v} of type \tcode{V*}, \tcode{V} base of \tcode{B} results in \tcode{B*} + dynamic_cast(a); // undefined behavior, \tcode{a} has type \tcode{A*}, \tcode{A} not a base of \tcode{B} } \end{codeblock} -\end{example}% +\end{example} \indextext{destruction|)}% -\indextext{construction|)} +\indextext{construction|)}% \rSec1[class.copy]{Copying and moving class objects}% -\indextext{copy!class~object|see{constructor, copy; assignment, copy}}% -\indextext{move!class~object|see{constructor, move; assignment, move}}% +\indextext{copy!class object|see{constructor, copy; assignment, copy}}% +\indextext{move!class object|see{constructor, move; assignment, move}}% \indextext{operator!copy assignment|see{assignment, copy}}% \indextext{operator!move assignment|see{assignment, move}} @@ -2735,7 +2691,7 @@ its odr-use (\ref{basic.def.odr}, \ref{class.temporary}). \end{note} If the implicitly-defined constructor would satisfy the requirements of a -\tcode{constexpr} constructor~(\ref{dcl.constexpr}), the implicitly-defined +constexpr constructor~(\ref{dcl.constexpr}), the implicitly-defined constructor is \tcode{constexpr}. \pnum @@ -2774,7 +2730,7 @@ otherwise, the base or member is direct-initialized with the corresponding base or member of \tcode{x}. \end{itemize} -\indextext{initialization!virtual~base~class}% +\indextext{initialization!virtual base class}% Virtual base class subobjects shall be initialized only once by the implicitly-defined copy/move constructor (see~\ref{class.base.init}). @@ -3051,12 +3007,12 @@ \item the assignment operator selected to copy/move each direct base class subobject -is a \tcode{constexpr} function, and +is a constexpr function, and \item for each non-static data member of \tcode{X} that is of class type (or array thereof), the assignment operator selected to copy/move that member is a -\tcode{constexpr} function. +constexpr function. \end{itemize} \pnum @@ -3124,7 +3080,7 @@ \rSec2[class.copy.elision]{Copy/move elision}% \pnum -\indextext{temporary!elimination~of}% +\indextext{temporary!elimination of}% \indextext{elision!copy constructor|see{constructor, copy, elision}}% \indextext{elision!move constructor|see{constructor, move, elision}}% \indextext{constructor!copy!elision}% @@ -3164,7 +3120,7 @@ omitted by constructing the automatic object directly into the function call's return object -\item in a \nonterminal{throw-expression}~(\ref{expr.throw}), when the operand +\item in a \grammarterm{throw-expression}~(\ref{expr.throw}), when the operand is the name of a non-volatile automatic object (other than a function or catch-clause parameter) whose scope does not extend beyond the end of the innermost enclosing @@ -3172,14 +3128,14 @@ operand to the exception object~(\ref{except.throw}) can be omitted by constructing the automatic object directly into the exception object -\item when the \nonterminal{exception-declaration} of an +\item when the \grammarterm{exception-declaration} of an exception handler (Clause~\ref{except}) declares an object of the same type (except for cv-qualification) as the exception object~(\ref{except.throw}), the copy operation can be omitted by treating -the \nonterminal{exception-declaration} as an alias for the exception +the \grammarterm{exception-declaration} as an alias for the exception object if the meaning of the program will be unchanged except for the execution of constructors and destructors for the object declared by the -\nonterminal{exception-declaration}. +\grammarterm{exception-declaration}. \begin{note} There cannot be a move from the exception object because it is always an lvalue. \end{note} \end{itemize} @@ -3195,7 +3151,6 @@ \pnum \begin{example} - \begin{codeblock} class Thing { public: @@ -3221,14 +3176,13 @@ return a; } -constexpr A a; // well-formed, \tcode{a.p} points to \tcode{a} -constexpr A b = g(); // well-formed, \tcode{b.p} points to \tcode{b} +constexpr A a; // well-formed, \tcode{a.p} points to \tcode{a} +constexpr A b = g(); // well-formed, \tcode{b.p} points to \tcode{b} void g() { - A c = g(); // well-formed, \tcode{c.p} may point to \tcode{c} or to an ephemeral temporary + A c = g(); // well-formed, \tcode{c.p} may point to \tcode{c} or to an ephemeral temporary } \end{codeblock} - Here the criteria for elision can eliminate the copying of the local automatic object @@ -3249,26 +3203,35 @@ \end{example} \pnum -When the criteria for elision of a copy/move operation are met, -but not for an \nonterminal{exception-declaration}, -and the object -to be copied is designated by an lvalue, -or when the \grammarterm{expression} in a \tcode{return} statement +In the following copy-initialization contexts, a move operation might be used instead of a copy operation: +\begin{itemize} +\item If the \grammarterm{expression} in a \tcode{return} statement~(\ref{stmt.return}) is a (possibly parenthesized) \grammarterm{id-expression} that names an object with automatic storage duration declared in the body or \grammarterm{parameter-declaration-clause} of the innermost enclosing -function or \grammarterm{lambda-expression}, +function or \grammarterm{lambda-expression}, or + +\item if the operand of a \grammarterm{throw-expression}~(\ref{expr.throw}) +is the name of a non-volatile automatic object +(other than a function or catch-clause parameter) +whose scope does not extend beyond the end of the innermost enclosing +\grammarterm{try-block} (if there is one), +\end{itemize} overload resolution to select the constructor -for the copy is first performed as if the object were designated by an rvalue. +for the copy is first performed as if the object were designated by an +rvalue. If the first overload resolution fails or was not performed, or if the type of the first parameter of the selected constructor is not an rvalue reference to the object's type (possibly cv-qualified), overload resolution is performed again, considering the object as an lvalue. -\begin{note} This two-stage overload resolution must be performed regardless +\begin{note} +This two-stage overload resolution must be performed regardless of whether copy elision will occur. It determines the constructor to be called if elision is not performed, and the selected constructor must be accessible even if -the call is elided. \end{note} +the call is elided. +\end{note} +\pnum \begin{example} \begin{codeblock} class Thing { @@ -3283,11 +3246,11 @@ Thing f(bool b) { Thing t; if (b) - throw t; // OK: \tcode{Thing(Thing\&\&)} used (or elided) to throw \tcode{t} - return t; // OK: \tcode{Thing(Thing\&\&)} used (or elided) to return \tcode{t} + throw t; // OK: \tcode{Thing(Thing\&\&)} used (or elided) to throw \tcode{t} + return t; // OK: \tcode{Thing(Thing\&\&)} used (or elided) to return \tcode{t} } -Thing t2 = f(false); // OK: no extra copy/move performed, \tcode{t2} constructed by call to \tcode{f} +Thing t2 = f(false); // OK: no extra copy/move performed, \tcode{t2} constructed by call to \tcode{f} struct Weird { Weird(); @@ -3296,8 +3259,7 @@ Weird g() { Weird w; - return w; // OK: first overload resolution fails, - // second overload resolution selects \tcode{Weird(Weird\&)} + return w; // OK: first overload resolution fails, second overload resolution selects \tcode{Weird(Weird\&)} } \end{codeblock} \end{example} diff --git a/source/statements.tex b/source/statements.tex index 6c8abf4f1c..6adfb50902 100644 --- a/source/statements.tex +++ b/source/statements.tex @@ -32,25 +32,25 @@ The optional \grammarterm{attribute-specifier-seq} appertains to the respective statement. \pnum -\indextext{\idxgram{condition}{s}!rules~for}% -The rules for \grammarterm{}{condition}{s} apply both to +\indextext{\idxgram{condition}{s}!rules for}% +The rules for \grammarterm{condition}{s} apply both to \grammarterm{selection-statement}{s} and to the \tcode{for} and \tcode{while} -statements~(\ref{stmt.iter}). The \grammarterm{}{declarator} shall not +statements~(\ref{stmt.iter}). The \grammarterm{declarator} shall not specify a function or an array. The \grammarterm{decl-specifier-seq} shall not -define a class or enumeration. If the \tcode{auto} \nonterminal{type-specifier} appears in -the \nonterminal{decl-specifier-seq}, +define a class or enumeration. If the \tcode{auto} \grammarterm{type-specifier} appears in +the \grammarterm{decl-specifier-seq}, the type of the identifier being declared is deduced from the initializer as described in~\ref{dcl.spec.auto}. \pnum \indextext{statement!declaration in \tcode{if}}% \indextext{statement!declaration in \tcode{switch}}% -A name introduced by a declaration in a \grammarterm{}{condition} (either +A name introduced by a declaration in a \grammarterm{condition} (either introduced by the \grammarterm{decl-specifier-seq} or the -\grammarterm{}{declarator} of the condition) is in scope from its point of +\grammarterm{declarator} of the condition) is in scope from its point of declaration until the end of the substatements controlled by the -condition. If the name is re-declared in the outermost block of a +condition. If the name is redeclared in the outermost block of a substatement controlled by the condition, the declaration that -re-declares the name is ill-formed. +redeclares the name is ill-formed. \begin{example} \begin{codeblock} @@ -64,17 +64,17 @@ \end{example} \pnum -The value of a \grammarterm{}{condition} that is an initialized declaration +The value of a \grammarterm{condition} that is an initialized declaration in a statement other than a \tcode{switch} statement is the value of the declared variable contextually converted to \tcode{bool} (Clause~\ref{conv}). If that conversion is ill-formed, the program is ill-formed. The value of a -\grammarterm{}{condition} that is an initialized declaration in a +\grammarterm{condition} that is an initialized declaration in a \tcode{switch} statement is the value of the declared variable if it has integral or enumeration type, or of that variable implicitly converted to integral or enumeration type otherwise. The value of a -\grammarterm{}{condition} that is an expression is the value of the +\grammarterm{condition} that is an expression is the value of the expression, contextually converted to \tcode{bool} for statements other than \tcode{switch}; @@ -83,7 +83,7 @@ ``the condition'' where the usage is unambiguous. \pnum -If a \grammarterm{}{condition} can be syntactically resolved as either an +If a \grammarterm{condition} can be syntactically resolved as either an expression or the declaration of a block-scope name, it is interpreted as a declaration. @@ -97,7 +97,7 @@ \pnum \indextext{statement!labeled}% -\indextext{\idxcode{:}!label~specifier}% +\indextext{\idxcode{:}!label specifier}% A statement can be labeled. \begin{bnf} @@ -112,11 +112,11 @@ identifier label is as the target of a \indextext{statement!\idxcode{goto}}% \tcode{goto}. -\indextext{label!scope~of}% +\indextext{label!scope of}% The scope of a label is the function in which it appears. Labels shall not be redeclared within a function. A label can be used in a \tcode{goto} statement before its declaration. -\indextext{name~space!label}% +\indextext{name space!label}% Labels have their own name space and do not interfere with other identifiers. \begin{note} @@ -182,7 +182,7 @@ A compound statement defines a block scope~(\ref{basic.scope}). \begin{note} -A declaration is a \grammarterm{}{statement}~(\ref{stmt.dcl}). +A declaration is a \grammarterm{statement}~(\ref{stmt.dcl}). \end{note} \rSec1[stmt.select]{Selection statements}% @@ -206,7 +206,7 @@ An \grammarterm{init-statement} ends with a semicolon. \end{note} In Clause~\ref{stmt.stmt}, the term \term{substatement} refers to -the contained \grammarterm{}{statement} or \grammarterm{}{statement}{s} that appear +the contained \grammarterm{statement} or \grammarterm{statement}{s} that appear in the syntax notation. \indextext{scope!\idxgram{selection-statement}}% The substatement in a \grammarterm{selection-statement} (each substatement, @@ -275,10 +275,10 @@ // ... handle \tcode{p} if constexpr (sizeof...(rs) > 0) - g(rs...); // never instantiated with an empty argument list. + g(rs...); // never instantiated with an empty argument list } -extern int x; // no definition of \tcode{x} required +extern int x; // no definition of \tcode{x} required int f() { if constexpr (true) @@ -390,11 +390,10 @@ and \tcode{case} and \tcode{default} labels appear on the top-level statements contained within the (compound) substatement, but this is not required. -\indextext{statement!declaration~in \tcode{switch}}% +\indextext{statement!declaration in \tcode{switch}}% Declarations can appear in the substatement of a \grammarterm{switch-statement}. -\end{note}% -\indextext{statement!selection|)} +\end{note} \pnum A \tcode{switch} statement of the form @@ -414,7 +413,8 @@ except that names declared in the \grammarterm{init-statement} are in the same declarative region as those declared in the -\grammarterm{condition}. +\grammarterm{condition}.% +\indextext{statement!selection|)} \rSec1[stmt.iter]{Iteration statements}% \indextext{statement!iteration|(} @@ -442,7 +442,7 @@ \begin{bnf} \nontermdef{for-range-initializer}\br - expr-or-braced-init-list\br + expr-or-braced-init-list \end{bnf} See~\ref{dcl.meaning} for the optional \grammarterm{attribute-specifier-seq} in a @@ -475,7 +475,6 @@ } \end{codeblock} -\pnum Thus after the \tcode{while} statement, \tcode{i} is no longer in scope. \end{example} @@ -489,11 +488,11 @@ substatement. \pnum -\indextext{statement!declaration~in \tcode{while}}% +\indextext{statement!declaration in \tcode{while}}% When the condition of a \tcode{while} statement is a declaration, the scope of the variable that is declared extends from its point of declaration~(\ref{basic.scope.pdecl}) to the end of the \tcode{while} -\grammarterm{}{statement}. A \tcode{while} statement of the form +\grammarterm{statement}. A \tcode{while} statement of the form \begin{codeblock} while (T t = x) @\grammarterm{statement}@ @@ -572,7 +571,7 @@ except that names declared in the \grammarterm{init-statement} are in the same declarative region as those declared in the \grammarterm{condition}, and except that a -\indextext{statement!\tcode{continue}~in \tcode{for}}% +\indextext{statement!\tcode{continue} in \tcode{for}}% \tcode{continue} in \grammarterm{statement} (not enclosed in another iteration statement) will execute \grammarterm{expression} before re-evaluating \grammarterm{condition}. @@ -592,8 +591,8 @@ equivalent to \tcode{while(true)}. \pnum -\indextext{statement!declaration~in \tcode{for}}% -\indextext{\idxcode{for}!scope~of declaration~in}% +\indextext{statement!declaration in \tcode{for}}% +\indextext{\idxcode{for}!scope of declaration in}% If the \grammarterm{init-statement} is a declaration, the scope of the name(s) declared extends to the end of the \tcode{for} statement. \begin{example} @@ -610,7 +609,7 @@ \end{example} \rSec2[stmt.ranged]{The range-based \tcode{for} statement}% -\indextext{statement!range~based \idxcode{for}} +\indextext{statement!range based \idxcode{for}} \pnum The range-based \tcode{for} statement @@ -676,14 +675,14 @@ for (int& x : array) x *= 2; \end{codeblock} -\end{example}% -\indextext{statement!iteration|)} +\end{example} \pnum In the \grammarterm{decl-specifier-seq} of a \grammarterm{for-range-declaration}, each \grammarterm{decl-specifier} shall be either a \grammarterm{type-specifier} or \tcode{constexpr}. The \grammarterm{decl-specifier-seq} shall not define a -class or enumeration. +class or enumeration.% +\indextext{statement!iteration|)} \rSec1[stmt.jump]{Jump statements}% \indextext{statement!jump} @@ -707,8 +706,8 @@ \end{bnf} \pnum -\indextext{local~variable!destruction~of}% -\indextext{scope!destructor~and exit~from}% +\indextext{local variable!destruction of}% +\indextext{scope!destructor and exit from}% On exit from a scope (however accomplished), objects with automatic storage duration~(\ref{basic.stc.auto}) that have been constructed in that scope are destroyed in the reverse order of their construction. \begin{note} For temporaries, @@ -790,7 +789,7 @@ \rSec2[stmt.return]{The \tcode{return} statement}% \indextext{\idxcode{return}}% -\indextext{function~return|see{\tcode{return}}}% +\indextext{function return|see{\tcode{return}}}% \pnum A function returns to its caller by the \tcode{return} statement. @@ -799,15 +798,15 @@ The \grammarterm{expr-or-braced-init-list} of a return statement is called its operand. A return statement with no operand shall be used only in a function whose return type is -\cv{} \tcode{void}, a constructor~(\ref{class.ctor}), or a +\cv{}~\tcode{void}, a constructor~(\ref{class.ctor}), or a destructor~(\ref{class.dtor}). -\indextext{\idxcode{return}!constructor~and}% -\indextext{\idxcode{return}!constructor~and}% +\indextext{\idxcode{return}!constructor and}% +\indextext{\idxcode{return}!constructor and}% A return statement with an operand of type \tcode{void} shall be used only -in a function whose return type is \cv{} \tcode{void}. +in a function whose return type is \cv{}~\tcode{void}. A return statement with any other operand shall be used only -in a function whose return type is not \cv{} \tcode{void}; -\indextext{conversion!return~type}% +in a function whose return type is not \cv{}~\tcode{void}; +\indextext{conversion!return type}% the return statement initializes the glvalue result or prvalue result object of the (explicit or implicit) function call by copy-initialization~(\ref{dcl.init}) from the operand. @@ -828,7 +827,7 @@ Flowing off the end of a constructor, a destructor, or -a function with a \cv{} \tcode{void} return type is +a function with a \cv{}~\tcode{void} return type is equivalent to a \tcode{return} with no operand. Otherwise, flowing off the end of a function other than \tcode{main}~(\ref{basic.start.main}) @@ -864,31 +863,31 @@ If an identifier introduced by a declaration was previously declared in an outer block, -\indextext{declaration~hiding|see{name~hiding}}% -\indextext{name~hiding}% -\indextext{block~structure}% +\indextext{declaration hiding|see{name hiding}}% +\indextext{name hiding}% +\indextext{block structure}% the outer declaration is hidden for the remainder of the block, after which it resumes its force. \pnum -\indextext{block!initialization~in}% +\indextext{block!initialization in}% \indextext{initialization!automatic}% Variables with automatic storage duration~(\ref{basic.stc.auto}) are initialized each time their \grammarterm{declaration-statement} is executed. -\indextext{local~variable!destruction~of}% +\indextext{local variable!destruction of}% Variables with automatic storage duration declared in the block are destroyed on exit from the block~(\ref{stmt.jump}). \pnum -\indextext{initialization!jump~past}% -\indextext{\idxcode{goto}!initialization~and}% +\indextext{initialization!jump past}% +\indextext{\idxcode{goto}!initialization and}% It is possible to transfer into a block, but not in a way that bypasses declarations with initialization. A program that jumps\footnote{The transfer from the condition of a \tcode{switch} statement to a \tcode{case} label is considered a jump in this respect.} from a point where a variable with automatic storage duration is not in scope to a point where it is in scope is ill-formed unless the variable has scalar type, class type with a trivial default constructor and a trivial destructor, a cv-qualified version of one of these types, or an array of one of the preceding types and is declared without an -\grammarterm{}{initializer}~(\ref{dcl.init}). +\grammarterm{initializer}~(\ref{dcl.init}). \begin{example} \begin{codeblock} @@ -900,16 +899,15 @@ X a = 1; // ... lx: - goto ly; // OK, jump implies destructor - // call for \tcode{a} followed by construction - // again immediately following label \tcode{ly} + goto ly; // OK, jump implies destructor call for \tcode{a} followed by + // construction again immediately following label \tcode{ly} } \end{codeblock} \end{example} \pnum \indextext{initialization!automatic}% -\indextext{initialization!dynamic~block-scope}% +\indextext{initialization!dynamic block-scope}% \indextext{initialization!local \tcode{static}}% \indextext{initialization!local \tcode{thread_local}}% Dynamic initialization of a block-scope variable with @@ -919,7 +917,14 @@ considered initialized upon the completion of its initialization. If the initialization exits by throwing an exception, the initialization is not complete, so it will be tried again the next time control enters the -declaration. If control enters the declaration concurrently while the variable is being initialized, the concurrent execution shall wait for completion of the initialization.\footnote{The implementation must not introduce any deadlock around execution of the initializer.} If control re-enters the declaration recursively while +declaration. +If control enters the declaration concurrently while the variable is +being initialized, the concurrent execution shall wait for completion +of the initialization.\footnote{The implementation must not introduce +any deadlock around execution of the initializer. Deadlocks might +still be caused by the program logic; the implementation need only +avoid deadlocks due to its own synchronization operations.} If control +re-enters the declaration recursively while the variable is being initialized, the behavior is undefined. \begin{example} @@ -932,7 +937,7 @@ \end{example} \pnum -\indextext{\idxcode{static}!destruction~of local}% +\indextext{\idxcode{static}!destruction of local}% The destructor for a block-scope object with static or thread storage duration will be executed if and only if it was constructed. \begin{note} @@ -941,7 +946,7 @@ \end{note} \rSec1[stmt.ambig]{Ambiguity resolution}% -\indextext{ambiguity!declaration~versus expression} +\indextext{ambiguity!declaration versus expression} \pnum There is an ambiguity in the grammar involving @@ -1029,13 +1034,9 @@ void f() { // disambiguation requires this to be parsed as a declaration: T1(a) = 3, - T2(4), // \tcode{T2} will be declared as - (*(*b)(T2(c)))(int(d)); // a variable of type \tcode{T1} - // but this will not allow - // the last part of the - // declaration to parse - // properly since it depends - // on \tcode{T2} being a type-name + T2(4), // \tcode{T2} will be declared as a variable of type \tcode{T1}, but this will not + (*(*b)(T2(c)))(int(d)); // allow the last part of the declaration to parse properly, + // since it depends on \tcode{T2} being a type-name } \end{codeblock} \end{example}% diff --git a/source/std.tex b/source/std.tex index f81ed7ebd2..c6583eda32 100644 --- a/source/std.tex +++ b/source/std.tex @@ -48,6 +48,10 @@ \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={bnftab,simplebnf,bnf,bnfkeywordtab}]{extract} % Grammar extraction +\pdfminorversion=5 +\pdfcompresslevel=9 +\pdfobjcompresslevel=2 + \renewcommand\RSsmallest{5.5pt} % smallest font size for relsize \input{layout} diff --git a/source/strings.tex b/source/strings.tex index 97115b9493..3eec571561 100644 --- a/source/strings.tex +++ b/source/strings.tex @@ -49,7 +49,7 @@ and~\ref{input.output} need a set of related types and functions to complete the definition of their semantics. These types and functions are provided as a set of member \grammarterm{typedef-name}{s} and functions in the template -parameter `traits' used by each such template. This subclause defines the +parameter \tcode{traits} used by each such template. This subclause defines the semantics of these members. \pnum @@ -147,48 +147,50 @@ \tcode{X::state_type} & & (described in~\ref{char.traits.typedefs}) & compile-time \\ \rowsep \tcode{X::eq(c,d)} & \tcode{bool} & -yields: whether \tcode{c} is to be treated as equal to \tcode{d}. & constant \\ \rowsep +\returns whether \tcode{c} is to be treated as equal to \tcode{d}. & constant \\ \rowsep \tcode{X::lt(c,d)} & \tcode{bool} & -yields: whether \tcode{c} is to be treated as less than \tcode{d}. & constant \\ \rowsep +\returns whether \tcode{c} is to be treated as less than \tcode{d}. & constant \\ \rowsep \tcode{X::compare(p,q,n)} & \tcode{int} & -yields: \tcode{0} if for each \tcode{i} in \tcode{[0,n)}, \tcode{X::eq(p[i],q[i])} +\returns \tcode{0} if for each \tcode{i} in \tcode{[0,n)}, \tcode{X::eq(p[i],q[i])} is \tcode{true}; else, a negative value if, for some \tcode{j} in \tcode{[0,n)}, \tcode{X::lt(p[j],q[j])} is \tcode{true} and for each \tcode{i} in \tcode{[0,j)} \tcode{X::eq(p[i],q[i])} is \tcode{true}; else a positive value. & linear \\ \rowsep \tcode{X::length(p)} & \tcode{size_t} & -yields: the smallest \tcode{i} such that \tcode{X::eq(p[i],charT())} is \tcode{true}. & linear \\ \rowsep +\returns the smallest \tcode{i} such that \tcode{X::eq(p[i],charT())} is \tcode{true}. & linear \\ \rowsep \tcode{X::find(p,n,c)} & \tcode{const X::char_type*} & -yields: the smallest \tcode{q} in \tcode{[p,p+n)} such that +\returns the smallest \tcode{q} in \tcode{[p,p+n)} such that \tcode{X::eq(*q,c)} is \tcode{true}, zero otherwise. & linear \\ \rowsep \tcode{X::move(s,p,n)} & \tcode{X::char_type*} & for each \tcode{i} in \tcode{[0,n)}, performs \tcode{X::assign(s[i],p[i])}. -Copies correctly even where the ranges \tcode{[p,p+n)} and \tcode{[s,s+n)} overlap. yields: \tcode{s}. & linear \\ \rowsep +Copies correctly even where the ranges \tcode{[p,p+n)} and \tcode{[s,s+n)} overlap.\br \returns \tcode{s}. & linear \\ \rowsep \tcode{X::copy(s,p,n)} & \tcode{X::char_type*} & -pre: \tcode{p} not in \tcode{[s,s+n)}. yields: \tcode{s}. for each \tcode{i} in +\requires \tcode{p} not in \tcode{[s,s+n)}. \returns \tcode{s}.\br +for each \tcode{i} in \tcode{[0,n)}, performs \tcode{X::assign(s[i],p[i])}. & linear \\ \rowsep \tcode{X::assign(r,d)} & (not used) & assigns \tcode{r=d}. & constant \\ \rowsep \tcode{X::assign\-(s,n,c)} & \tcode{X::char_type*} & for each \tcode{i} in \tcode{[0,n)}, performs -\tcode{X::assign(s[i],c)}. yields: \tcode{s}. & linear \\ \rowsep +\tcode{X::assign(s[i],c)}.\br +\returns \tcode{s}. & linear \\ \rowsep \tcode{X::not_eof(e)} & \tcode{int_type} & -yields: \tcode{e} if \tcode{X::eq_int_type(e,X::eof())} is \tcode{false}, +\returns \tcode{e} if \tcode{X::eq_int_type(e,X::eof())} is \tcode{false}, otherwise a value \tcode{f} such that \tcode{X::eq_int_type(f,X::eof())} is \tcode{false}. & constant \\ \rowsep \tcode{X::to_char_type\-(e)} & \tcode{X::char_type} & -yields: if for some \tcode{c}, \tcode{X::eq_int_type(e,X::to_int_type(c))} +\returns if for some \tcode{c}, \tcode{X::eq_int_type(e,X::to_int_type(c))} is \tcode{true}, \tcode{c}; else some unspecified value. & constant \\ \rowsep \tcode{X::to_int_type\-(c)} & \tcode{X::int_type} & -yields: some value \tcode{e}, constrained by the definitions of +\returns some value \tcode{e}, constrained by the definitions of \tcode{to_char_type} and \tcode{eq_int_type}. & constant \\ \rowsep \tcode{X::eq_int_type\-(e,f)} & \tcode{bool} & -yields: for all \tcode{c} and \tcode{d}, \tcode{X::eq(c,d)} is equal to +\returns for all \tcode{c} and \tcode{d}, \tcode{X::eq(c,d)} is equal to \tcode{X::eq_int_type(X::to_int_type(c), X::to_int_type(d))}; otherwise, yields \tcode{true} if \tcode{e} and \tcode{f} are both copies of \tcode{X::eof()}; otherwise, yields \tcode{false} if one of \tcode{e} and \tcode{f} is a copy of \tcode{X::eof()} and the other is not; otherwise the value is unspecified. & constant \\ \rowsep \tcode{X::eof()} & \tcode{X::int_type} & -yields: a value \tcode{e} such that \tcode{X::eq_int_type(e,X::to_int_type(c))} +\returns a value \tcode{e} such that \tcode{X::eq_int_type(e,X::to_int_type(c))} is \tcode{false} for all values \tcode{c}. & constant \\ \end{libreqtab4d} @@ -204,7 +206,7 @@ \tcode{} as a basis for explicit specializations. -\rSec2[char.traits.typedefs]{traits typedefs} +\rSec2[char.traits.typedefs]{Traits typedefs} \indexlibrarymember{char_type}{char_traits}% \begin{itemdecl} @@ -428,7 +430,7 @@ The type \tcode{u16streampos} shall be an \impldef{type of \tcode{u16streampos}} type that satisfies the requirements -for pos_type in~\ref{iostreams.limits.pos} and \ref{iostream.forward}. +for \tcode{pos_type} in~\ref{iostreams.limits.pos} and \ref{iostream.forward}. \pnum The two-argument members \tcode{assign}, @@ -478,7 +480,7 @@ The type \tcode{u32streampos} shall be an \impldef{type of \tcode{u32streampos}} type that satisfies the requirements -for pos_type in~\ref{iostreams.limits.pos} and \ref{iostream.forward}. +for \tcode{pos_type} in~\ref{iostreams.limits.pos} and \ref{iostream.forward}. \pnum The two-argument members \tcode{assign}, @@ -541,7 +543,7 @@ The type \tcode{wstreampos} shall be an \impldef{type of \tcode{wstreampos}} type that satisfies the requirements -for pos_type in~\ref{iostreams.limits.pos} and \ref{iostream.forward}. +for \tcode{pos_type} in~\ref{iostreams.limits.pos} and \ref{iostream.forward}. \pnum The type @@ -588,9 +590,10 @@ and \tcode{basic_string<\brk{}wchar_t>}, respectively. -\synopsis{Header \tcode{} synopsis} - +\rSec2[string.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{string}}% \indexlibrary{\idxhdr{string}}% + \begin{codeblock} #include @@ -1001,10 +1004,10 @@ basic_string& assign(InputIterator first, InputIterator last); basic_string& assign(initializer_list); - basic_string& insert(size_type pos1, const basic_string& str); + basic_string& insert(size_type pos, const basic_string& str); basic_string& insert(size_type pos1, const basic_string& str, size_type pos2, size_type n = npos); - basic_string& insert(size_type pos1, basic_string_view sv); + basic_string& insert(size_type pos, basic_string_view sv); template basic_string& insert(size_type pos1, const T& t, size_type pos2, size_type n = npos); @@ -1379,12 +1382,6 @@ \tcode{size()} & \tcode{traits::length(s)} \\ \tcode{capacity()} & a value at least as large as \tcode{size()} \\ \end{libefftabvalue} - -\pnum -\remarks -Uses -\tcode{traits::length()}. -\indexlibrary{\idxcode{length}!\idxcode{char_traits}}% \end{itemdescr} \indexlibrary{\idxcode{basic_string}!constructor}% @@ -2360,7 +2357,7 @@ \indexlibrarymember{insert}{basic_string}% \begin{itemdecl} basic_string& - insert(size_type pos1, + insert(size_type pos, const basic_string& str); \end{itemdecl} @@ -2399,13 +2396,13 @@ \indexlibrarymember{insert}{basic_string}% \begin{itemdecl} -basic_string& insert(size_type pos1, basic_string_view sv); +basic_string& insert(size_type pos, basic_string_view sv); \end{itemdecl} \begin{itemdescr} \pnum \effects -Equivalent to: \tcode{return insert(pos1, sv.data(), sv.size());} +Equivalent to: \tcode{return insert(pos, sv.data(), sv.size());} \end{itemdescr} \indexlibrarymember{insert}{basic_string}% @@ -3095,8 +3092,7 @@ \indexlibrarymember{find}{basic_string}% \begin{itemdecl} -size_type find(basic_string_view sv, - size_type pos = 0) const noexcept; +size_type find(basic_string_view sv, size_type pos = 0) const noexcept; \end{itemdecl} \begin{itemdescr} @@ -3104,7 +3100,6 @@ \effects Determines the lowest position \tcode{xpos}, if possible, such that both of the following conditions hold: - \begin{itemize} \item \tcode{pos <= xpos} and @@ -3120,17 +3115,11 @@ \tcode{xpos} if the function can determine such a value for \tcode{xpos}. Otherwise, returns \tcode{npos}. - -\pnum -\remarks -Uses -\tcode{traits::eq()}. \end{itemdescr} \indexlibrarymember{find}{basic_string}% \begin{itemdecl} -size_type find(const basic_string& str, - size_type pos = 0) const noexcept; +size_type find(const basic_string& str, size_type pos = 0) const noexcept; \end{itemdecl} \begin{itemdescr} @@ -3180,8 +3169,7 @@ \indexlibrarymember{rfind}{basic_string}% \begin{itemdecl} -size_type rfind(basic_string_view sv, - size_type pos = npos) const noexcept; +size_type rfind(basic_string_view sv, size_type pos = npos) const noexcept; \end{itemdecl} \begin{itemdescr} @@ -3189,7 +3177,6 @@ \effects Determines the highest position \tcode{xpos}, if possible, such that both of the following conditions hold: - \begin{itemize} \item \tcode{xpos <= pos} @@ -3206,17 +3193,11 @@ \tcode{xpos} if the function can determine such a value for \tcode{xpos}. Otherwise, returns \tcode{npos}. - -\pnum -\remarks -Uses -\tcode{traits::eq()}. \end{itemdescr} \indexlibrarymember{rfind}{basic_string}% \begin{itemdecl} -size_type rfind(const basic_string& str, - size_type pos = npos) const noexcept; +size_type rfind(const basic_string& str, size_type pos = npos) const noexcept; \end{itemdecl} \begin{itemdescr} @@ -3266,8 +3247,7 @@ \indexlibrarymember{find_first_of}{basic_string}% \begin{itemdecl} -size_type find_first_of(basic_string_view sv, - size_type pos = 0) const noexcept; +size_type find_first_of(basic_string_view sv, size_type pos = 0) const noexcept; \end{itemdecl} \begin{itemdescr} @@ -3292,17 +3272,11 @@ \tcode{xpos} if the function can determine such a value for \tcode{xpos}. Otherwise, returns \tcode{npos}. - -\pnum -\remarks -Uses -\tcode{traits::eq()}. \end{itemdescr} \indexlibrarymember{find_first_of}{basic_string}% \begin{itemdecl} -size_type find_first_of(const basic_string& str, - size_type pos = 0) const noexcept; +size_type find_first_of(const basic_string& str, size_type pos = 0) const noexcept; \end{itemdecl} \begin{itemdescr} @@ -3313,8 +3287,7 @@ \indexlibrarymember{find_first_of}{basic_string}% \begin{itemdecl} -size_type - find_first_of(const charT* s, size_type pos, size_type n) const; +size_type find_first_of(const charT* s, size_type pos, size_type n) const; \end{itemdecl} \begin{itemdescr} @@ -3353,8 +3326,7 @@ \indexlibrarymember{find_last_of}{basic_string}% \begin{itemdecl} -size_type find_last_of (basic_string_view sv, - size_type pos = npos) const noexcept; +size_type find_last_of(basic_string_view sv, size_type pos = npos) const noexcept; \end{itemdecl} \begin{itemdescr} @@ -3362,7 +3334,6 @@ \effects Determines the highest position \tcode{xpos}, if possible, such that both of the following conditions hold: - \begin{itemize} \item \tcode{xpos <= pos} @@ -3379,17 +3350,11 @@ \tcode{xpos} if the function can determine such a value for \tcode{xpos}. Otherwise, returns \tcode{npos}. - -\pnum -\remarks -Uses -\tcode{traits::eq()}. \end{itemdescr} \indexlibrarymember{find_last_of}{basic_string}% \begin{itemdecl} -size_type find_last_of(const basic_string& str, - size_type pos = npos) const noexcept; +size_type find_last_of(const basic_string& str, size_type pos = npos) const noexcept; \end{itemdecl} \begin{itemdescr} @@ -3448,7 +3413,6 @@ \effects Determines the lowest position \tcode{xpos}, if possible, such that both of the following conditions hold: - \begin{itemize} \item \tcode{pos <= xpos} @@ -3465,30 +3429,25 @@ \tcode{xpos} if the function can determine such a value for \tcode{xpos}. Otherwise, returns \tcode{npos}. - -\pnum -\remarks -Uses -\tcode{traits::eq()}. \end{itemdescr} \indexlibrarymember{find_first_not_of}{basic_string}% \begin{itemdecl} -size_type find_first_not_of(const basic_string& str, - size_type pos = 0) const noexcept; +size_type find_first_not_of(const basic_string& str, size_type pos = 0) const noexcept; \end{itemdecl} \begin{itemdescr} \pnum \effects Equivalent to: -\tcode{return find_first_not_of(basic_string_view(str), pos);} +\begin{codeblock} +return find_first_not_of(basic_string_view(str), pos); +\end{codeblock} \end{itemdescr} \indexlibrarymember{find_first_not_of}{basic_string}% \begin{itemdecl} -size_type - find_first_not_of(const charT* s, size_type pos, size_type n) const; +size_type find_first_not_of(const charT* s, size_type pos, size_type n) const; \end{itemdecl} \begin{itemdescr} @@ -3527,8 +3486,8 @@ \indexlibrarymember{find_last_not_of}{basic_string}% \begin{itemdecl} -size_type find_last_not_of (basic_string_view sv, - size_type pos = npos) const noexcept; +size_type find_last_not_of(basic_string_view sv, + size_type pos = npos) const noexcept; \end{itemdecl} \begin{itemdescr} @@ -3536,7 +3495,6 @@ \effects Determines the highest position \tcode{xpos}, if possible, such that both of the following conditions hold: - \begin{itemize} \item \tcode{xpos <= pos} @@ -3553,30 +3511,25 @@ \tcode{xpos} if the function can determine such a value for \tcode{xpos}. Otherwise, returns \tcode{npos}. - -\pnum -\remarks -Uses -\tcode{traits::eq()}. \end{itemdescr} \indexlibrarymember{find_last_not_of}{basic_string}% \begin{itemdecl} -size_type find_last_not_of(const basic_string& str, - size_type pos = npos) const noexcept; +size_type find_last_not_of(const basic_string& str, size_type pos = npos) const noexcept; \end{itemdecl} \begin{itemdescr} \pnum \effects Equivalent to: -\tcode{return find_last_not_of(basic_string_view(str), pos);} +\begin{codeblock} +return find_last_not_of(basic_string_view(str), pos); +\end{codeblock} \end{itemdescr} \indexlibrarymember{find_last_not_of}{basic_string}% \begin{itemdecl} -size_type find_last_not_of(const charT* s, size_type pos, - size_type n) const; +size_type find_last_not_of(const charT* s, size_type pos, size_type n) const; \end{itemdecl} \begin{itemdescr} @@ -3671,8 +3624,7 @@ \indexlibrarymember{compare}{basic_string}% \begin{itemdecl} -int compare(size_type pos1, size_type n1, - basic_string_view sv) const; +int compare(size_type pos1, size_type n1, basic_string_view sv) const; \end{itemdecl} \begin{itemdescr} @@ -3697,7 +3649,8 @@ Equivalent to: \begin{codeblock} basic_string_view sv = t; -return basic_string_view(data(), size()).substr(pos1, n1).compare(sv.substr(pos2, n2)); +return basic_string_view( + data(), size()).substr(pos1, n1).compare(sv.substr(pos2, n2)); \end{codeblock} \pnum @@ -3721,8 +3674,7 @@ \indexlibrarymember{compare}{basic_string}% \begin{itemdecl} -int compare(size_type pos1, size_type n1, - const basic_string& str) const; +int compare(size_type pos1, size_type n1, const basic_string& str) const; \end{itemdecl} \begin{itemdescr} @@ -3760,8 +3712,7 @@ \indexlibrarymember{compare}{basic_string}% \begin{itemdecl} -int compare(size_type pos, size_type n1, - const charT* s) const; +int compare(size_type pos, size_type n1, const charT* s) const; \end{itemdecl} \begin{itemdescr} @@ -3771,8 +3722,7 @@ \indexlibrarymember{compare}{basic_string}% \begin{itemdecl} -int compare(size_type pos, size_type n1, - const charT* s, size_type n2) const; +int compare(size_type pos, size_type n1, const charT* s, size_type n2) const; \end{itemdecl} \begin{itemdescr} @@ -4249,7 +4199,7 @@ \rSec3[string.io]{Inserters and extractors} -\indexlibrarymember{operator\shr}{basic_string}% +\indexlibrarymember{operator>>}{basic_string}% \begin{itemdecl} template basic_istream& @@ -4295,7 +4245,7 @@ \tcode{is.width(0)} is called and the \tcode{sentry} -object \tcode{k} is destroyed. +object is destroyed. \pnum If the function extracts no characters, it calls @@ -4308,7 +4258,7 @@ \tcode{is}. \end{itemdescr} -\indexlibrarymember{operator\shl}{basic_string}% +\indexlibrarymember{operator<<}{basic_string}% \begin{itemdecl} template basic_ostream& @@ -4378,8 +4328,7 @@ In any case, after the last character is extracted, the \tcode{sentry} -object \tcode{k} -is destroyed. +object is destroyed. \pnum If the function extracts no characters, it calls @@ -4686,6 +4635,7 @@ \rSec2[string.view.synop]{Header \tcode{} synopsis} +\indextext{\idxhdr{string_view}}% \indexlibrary{\idxhdr{string_view}}% \begin{codeblock} namespace std { @@ -4759,10 +4709,10 @@ // types using traits_type = traits; using value_type = charT; - using pointer = charT*; - using const_pointer = const charT*; - using reference = charT&; - using const_reference = const charT&; + using pointer = value_type*; + using const_pointer = const value_type*; + using reference = value_type&; + using const_reference = const value_type&; using const_iterator = @\impdefx{type of \tcode{basic_string_view::const_iterator}}@; // see \ref{string.view.iterators} using iterator = const_iterator;@\footnote{Because \tcode{basic_string_view} refers to a constant sequence, \tcode{iterator} and \tcode{const_iterator} are the same type.}@ using const_reverse_iterator = reverse_iterator; @@ -5133,7 +5083,7 @@ \begin{note} Unlike \tcode{basic_string::data()} and string literals, \tcode{data()} may return a pointer to a buffer that is not null-terminated. -Therefore it is typically a mistake to pass \tcode{data()} to a routine that takes just a \tcode{const charT*} and expects a null-terminated string. +Therefore it is typically a mistake to pass \tcode{data()} to a function that takes just a \tcode{const charT*} and expects a null-terminated string. \end{note} \end{itemdescr} @@ -5376,10 +5326,6 @@ \returns \tcode{xpos} if the function can determine such a value for \tcode{xpos}. Otherwise, returns \tcode{npos}. - -\pnum -\remarks -Uses \tcode{traits::eq()}. \end{itemdescr} \indexlibrarymember{rfind}{basic_string_view}% @@ -5407,10 +5353,6 @@ \returns \tcode{xpos} if the function can determine such a value for \tcode{xpos}. Otherwise, returns \tcode{npos}. - -\pnum -\remarks -Uses \tcode{traits::eq()}. \end{itemdescr} \indexlibrarymember{find_first_of}{basic_string_view}% @@ -5438,10 +5380,6 @@ \returns \tcode{xpos} if the function can determine such a value for \tcode{xpos}. Otherwise, returns \tcode{npos}. - -\pnum -\remarks -Uses \tcode{traits::eq()}. \end{itemdescr} \indexlibrarymember{find_last_of}{basic_string_view}% @@ -5469,10 +5407,6 @@ \returns \tcode{xpos} if the function can determine such a value for \tcode{xpos}. Otherwise, returns \tcode{npos}. - -\pnum -\remarks -Uses \tcode{traits::eq()}. \end{itemdescr} \indexlibrarymember{find_first_not_of}{basic_string_view}% @@ -5499,10 +5433,6 @@ \pnum \returns \tcode{xpos} if the function can determine such a value for \tcode{xpos}. Otherwise, returns \tcode{npos}. - -\pnum -\remarks -Uses \tcode{traits::eq()}. \end{itemdescr} \indexlibrarymember{find_last_not_of}{basic_string_view}% @@ -5512,7 +5442,7 @@ \begin{itemdescr} \pnum -Let \tcode{xpos} the highest position, if possible, such that the following conditions hold: +Let \tcode{xpos} be the highest position, if possible, such that the following conditions hold: \begin{itemize} \item \tcode{xpos <= pos} @@ -5530,10 +5460,6 @@ \returns \tcode{xpos} if the function can determine such a value for \tcode{xpos}. Otherwise, returns \tcode{npos}. - -\pnum -\remarks -Uses \tcode{traits::eq()}. \end{itemdescr} \rSec2[string.view.comparison]{Non-member comparison functions} @@ -5658,7 +5584,7 @@ \rSec2[string.view.io]{Inserters and extractors} -\indexlibrarymember{operator\shl}{basic_string_view}% +\indexlibrarymember{operator<<}{basic_string_view}% \begin{itemdecl} template basic_ostream& @@ -5700,6 +5626,10 @@ \begin{itemdescr} \pnum The specialization is enabled~(\ref{unord.hash}). +\begin{note} +The hash value of a string view object is equal to the hash value of +the corresponding string object (\ref{basic.string.hash}). +\end{note} \end{itemdescr} \rSec2[string.view.literals]{Suffix for \tcode{basic_string_view} literals} @@ -5750,6 +5680,7 @@ \rSec2[cctype.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{cctype}}% \indexlibrary{\idxhdr{cctype}}% \indexlibrary{\idxcode{isalnum}}% \indexlibrary{\idxcode{isalpha}}% @@ -5786,6 +5717,7 @@ \pnum \indextext{\idxhdr{ctype.h}}% +\indexlibrary{\idxhdr{ctype.h}}% The contents and meaning of the header \tcode{} are the same as the C standard library header \tcode{}. @@ -5793,6 +5725,7 @@ \rSec2[cwctype.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{cwctype}}% \indexlibrary{\idxhdr{cwctype}}% \indexlibrary{\idxcode{wint_t}}% \indexlibrary{\idxcode{wctrans_t}}% @@ -5847,6 +5780,7 @@ \pnum \indextext{\idxhdr{wctype.h}}% +\indexlibrary{\idxhdr{wctype.h}}% The contents and meaning of the header \tcode{} are the same as the C standard library header \tcode{}. @@ -5854,6 +5788,7 @@ \rSec2[cstring.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{cstring}}% \indexlibrary{\idxhdr{cstring}}% \indexlibrary{\idxcode{memchr}}% \indexlibrary{\idxcode{memcmp}}% @@ -5916,6 +5851,7 @@ \pnum \indextext{\idxhdr{string.h}}% +\indexlibrary{\idxhdr{string.h}}% The contents and meaning of the header \tcode{} are the same as the C standard library header \tcode{}. @@ -5935,6 +5871,7 @@ \rSec2[cwchar.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{cwchar}}% \indexlibrary{\idxhdr{cwchar}}% \indexlibrary{\idxcode{NULL}}% \indexlibrary{\idxcode{WCHAR_MAX}}% @@ -6087,6 +6024,7 @@ \pnum \indextext{\idxhdr{wchar.h}}% +\indexlibrary{\idxhdr{wchar.h}}% The contents and meaning of the header \tcode{} are the same as the C standard library header \tcode{}, except that it does not declare a type \tcode{wchar_t}. @@ -6103,6 +6041,7 @@ \rSec2[cuchar.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{cuchar}}% \indexlibrary{\idxhdr{cuchar}}% \indexlibrary{\idxcode{mbstate_t}}% \indexlibrary{\idxcode{size_t}}% @@ -6124,6 +6063,7 @@ \pnum \indextext{\idxhdr{uchar.h}}% +\indexlibrary{\idxhdr{uchar.h}}% The contents and meaning of the header \tcode{} are the same as the C standard library header \tcode{}, except that it does not declare types \tcode{char16_t} nor @@ -6135,7 +6075,9 @@ \pnum \indextext{\idxhdr{cstdlib}}% +\indexlibrary{\idxhdr{cstdlib}}% \indextext{\idxhdr{cwchar}}% +\indexlibrary{\idxhdr{cwchar}}% \begin{note} The headers \tcode{}~(\ref{cstdlib.syn}) and \tcode{}~(\ref{cwchar.syn}) diff --git a/source/styles.tex b/source/styles.tex index da875b1dea..b45fdf0fc2 100644 --- a/source/styles.tex +++ b/source/styles.tex @@ -102,9 +102,12 @@ % set style for lists (itemizations, enumerations) \setlength{\partopsep}{0pt} \newlist{indenthelper}{itemize}{1} +\newlist{bnflist}{itemize}{1} \setlist[itemize]{parsep=\parskip, partopsep=0pt, itemsep=0pt, topsep=0pt} \setlist[enumerate]{parsep=\parskip, partopsep=0pt, itemsep=0pt, topsep=0pt} \setlist[indenthelper]{parsep=\parskip, partopsep=0pt, itemsep=0pt, topsep=0pt, label={}} +\setlist[bnflist]{parsep=\parskip, partopsep=0pt, itemsep=0pt, topsep=0pt, label={}, + leftmargin=\bnfindentrest, listparindent=-\bnfindentinc, itemindent=\listparindent} %%-------------------------------------------------- %% set caption style and delimiter diff --git a/source/support.tex b/source/support.tex index f46acdc069..76d2a9df4e 100644 --- a/source/support.tex +++ b/source/support.tex @@ -63,6 +63,16 @@ #define offsetof(P, D) @\seebelow@ \end{codeblock} +\pnum +The contents and meaning of the header \tcode{} are the same as +the C standard library header \tcode{}, +except that it does not declare the type \tcode{wchar_t}, +and except as noted in +\ref{support.types.nullptr} and +\ref{support.types.layout}. + +\xref ISO C 7.19 + \rSec2[cstdlib.syn]{Header \tcode{} synopsis} \indextext{\idxhdr{cstdlib}}% @@ -306,54 +316,17 @@ \rSec1[support.limits]{Implementation properties} -\rSec2[support.limits.general]{In general} +\rSec2[support.limits.general]{General} \pnum The headers -\tcode{}~(\ref{limits}), +\tcode{}~(\ref{limits.syn}), \tcode{}~(\ref{climits.syn}), and \tcode{}~(\ref{cfloat.syn}) -supply characteristics of implementation-dependent +supply characteristics of imple\-mentation-dependent arithmetic types~(\ref{basic.fundamental}). -\rSec2[limits]{Numeric limits} - -\rSec3[limits.numeric]{Class template \tcode{numeric_limits}} - -\pnum -The -\indexlibrary{\idxcode{numeric_limits}}% -\tcode{numeric_limits} -class template provides a \Cpp program with information about various properties of -the implementation's representation of the -arithmetic types. - -\pnum -Specializations shall be provided for each -arithmetic type, -both floating-point and integer, including -\tcode{bool}. -The member -\tcode{is_specialized} -shall be -\tcode{true} -for all such specializations of -\tcode{numeric_limits}. - -\pnum -For all members declared -\tcode{static} \tcode{constexpr} -in the -\tcode{numeric_limits} -template, specializations shall define these values in such a way -that they are usable as -constant expressions. - -\pnum -Non-arithmetic standard types, such as -\tcode{complex}~(\ref{complex}), shall not have specializations. - -\rSec3[limits.syn]{Header \tcode{} synopsis} +\rSec2[limits.syn]{Header \tcode{} synopsis} \indextext{\idxhdr{limits}}% \indexlibrary{\idxhdr{limits}}% \indextext{\idxcode{numeric_limits}}% @@ -363,10 +336,13 @@ \begin{codeblock} namespace std { - template class numeric_limits; + // \ref{fp.style}, floating-point type properties enum float_round_style; enum float_denorm_style; + // \ref{numeric.limits}, class template numeric_limits + template class numeric_limits; + template<> class numeric_limits; template<> class numeric_limits; @@ -391,7 +367,95 @@ } \end{codeblock} -\rSec3[numeric.limits]{Class template \tcode{numeric_limits}} +\rSec2[fp.style]{Floating-point type properties} + +\rSec3[round.style]{Type \tcode{float_round_style}} + +\indexlibrary{\idxcode{float_round_style}}% +\begin{codeblock} +namespace std { + enum float_round_style { + round_indeterminate = -1, + round_toward_zero = 0, + round_to_nearest = 1, + round_toward_infinity = 2, + round_toward_neg_infinity = 3 + }; +} +\end{codeblock} + +\pnum +The rounding mode for floating-point arithmetic is characterized by the +values: + +\begin{itemize} +\item +\indexlibrary{\idxcode{round_indeterminate}}% +\tcode{round_indeterminate} +if the rounding style is indeterminable +\item +\indexlibrary{\idxcode{round_toward_zero}}% +\tcode{round_toward_zero} +if the rounding style is toward zero +\item +\indexlibrary{\idxcode{round_to_nearest}}% +\tcode{round_to_nearest} +if the rounding style is to the nearest representable value +\item +\indexlibrary{\idxcode{round_toward_infinity}}% +\tcode{round_toward_infinity} +if the rounding style is toward infinity +\item +\indexlibrary{\idxcode{round_toward_neg_infinity}}% +\tcode{round_toward_neg_infinity} +if the rounding style is toward negative infinity +\end{itemize} + +\rSec3[denorm.style]{Type \tcode{float_denorm_style}} + +\indexlibrary{\idxcode{float_denorm_style}}% +\begin{codeblock} +namespace std { + enum float_denorm_style { + denorm_indeterminate = -1, + denorm_absent = 0, + denorm_present = 1 + }; +} +\end{codeblock} + +\indextext{denormalized value|see{number, subnormal}}% +\indextext{value!denormalized|see{number, subnormal}}% +\indextext{subnormal number|see{number, subnormal}}% +\indextext{number!subnormal}% +\pnum +The presence or absence of subnormal numbers (variable number of exponent bits) +is characterized by the values: + +\begin{itemize} +\item +\indexlibrary{\idxcode{denorm_indeterminate}}% +\tcode{denorm_indeterminate} +if it cannot be determined whether or not the type allows subnormal values +\item +\indexlibrary{\idxcode{denorm_absent}}% +\tcode{denorm_absent} +if the type does not allow subnormal values +\item +\indexlibrary{\idxcode{denorm_present}}% +\tcode{denorm_present} +if the type does allow subnormal values +\end{itemize} + +\rSec2[numeric.limits]{Class template \tcode{numeric_limits}} + +\pnum +The +\indexlibrary{\idxcode{numeric_limits}}% +\tcode{numeric_limits} +class template provides a \Cpp program with information about various properties of +the implementation's representation of the +arithmetic types. \indexlibrary{\idxcode{numeric_limits}}% \begin{codeblock} @@ -443,6 +507,15 @@ } \end{codeblock} +\pnum +For all members declared +\tcode{static} \tcode{constexpr} +in the +\tcode{numeric_limits} +template, specializations shall define these values in such a way +that they are usable as +constant expressions. + \pnum The default \tcode{numeric_limits} @@ -450,12 +523,28 @@ \tcode{false} values. +\pnum +Specializations shall be provided for each +arithmetic type, +both floating-point and integer, including +\tcode{bool}. +The member +\tcode{is_specialized} +shall be +\tcode{true} +for all such specializations of +\tcode{numeric_limits}. + \pnum The value of each member of a specialization of \tcode{numeric_limits} on a cv-qualified type \tcode{cv T} shall be equal to the value of the corresponding member of the specialization on the unqualified type \tcode{T}. +\pnum +Non-arithmetic standard types, such as +\tcode{complex}~(\ref{complex}), shall not have specializations. + \rSec3[numeric.limits.members]{\tcode{numeric_limits} members} \indexlibrarymember{min}{numeric_limits}% @@ -468,8 +557,9 @@ Minimum finite value.\footnote{Equivalent to \tcode{CHAR_MIN}, \tcode{SHRT_MIN}, \tcode{FLT_MIN}, \tcode{DBL_MIN}, etc.} +\indextext{number!subnormal}% \pnum -For floating types with denormalization, returns the minimum positive +For floating types with subnormal numbers, returns the minimum positive normalized value. \pnum @@ -565,7 +655,7 @@ \begin{itemdescr} \pnum -True if the type is signed. +\tcode{true} if the type is signed. \pnum Meaningful for all specializations. @@ -578,7 +668,7 @@ \begin{itemdescr} \pnum -True if the type is integer. +\tcode{true} if the type is integer. \pnum Meaningful for all specializations. @@ -591,7 +681,7 @@ \begin{itemdescr} \pnum -True if the type uses an exact representation. +\tcode{true} if the type uses an exact representation. All integer types are exact, but not all exact types are integer. For example, rational and fixed-exponent representations are exact but not integer. @@ -654,8 +744,8 @@ \pnum Minimum negative integer such that \tcode{radix} -raised to the power of one less than that integer is a normalized floating -point number.\footnote{Equivalent to \tcode{FLT_MIN_EXP}, \tcode{DBL_MIN_EXP}, +raised to the power of one less than that integer is a normalized floating-point +number.\footnote{Equivalent to \tcode{FLT_MIN_EXP}, \tcode{DBL_MIN_EXP}, \tcode{LDBL_MIN_EXP}.} \pnum @@ -716,7 +806,7 @@ \begin{itemdescr} \pnum -True if the type has a representation for positive infinity. +\tcode{true} if the type has a representation for positive infinity. \pnum Meaningful for all floating-point types. @@ -735,8 +825,8 @@ \begin{itemdescr} \pnum -True if the type has a representation for a quiet (non-signaling) ``Not a -Number.''\footnote{Required by LIA-1.} +\tcode{true} if the type has a representation for a quiet (non-signaling) ``Not a +Number''.\footnote{Required by LIA-1.} \pnum Meaningful for all floating-point types. @@ -755,7 +845,7 @@ \begin{itemdescr} \pnum -True if the type has a representation for a signaling ``Not a Number.''\footnote{Required by LIA-1.} +\tcode{true} if the type has a representation for a signaling ``Not a Number''.\footnote{Required by LIA-1.} \pnum Meaningful for all floating-point types. @@ -772,17 +862,18 @@ static constexpr float_denorm_style has_denorm; \end{itemdecl} +\indextext{number!subnormal}% \begin{itemdescr} \pnum \tcode{denorm_present} -if the type allows denormalized values +if the type allows subnormal values (variable number of exponent bits)\footnote{Required by LIA-1.}, \tcode{denorm_absent} -if the type does not allow denormalized values, +if the type does not allow subnormal values, and \tcode{denorm_indeterminate} if it is indeterminate at compile time whether the type allows -denormalized values. +subnormal values. \pnum Meaningful for all floating-point types. @@ -795,7 +886,7 @@ \begin{itemdescr} \pnum -True if loss of accuracy is detected as a +\tcode{true} if loss of accuracy is detected as a denormalization loss, rather than as an inexact result.\footnote{See ISO/IEC/IEEE 60559.} \end{itemdescr} @@ -823,7 +914,7 @@ \begin{itemdescr} \pnum -Representation of a quiet ``Not a Number,'' if available.\footnote{Required by LIA-1.} +Representation of a quiet ``Not a Number'', if available.\footnote{Required by LIA-1.} \pnum Meaningful for all specializations for which @@ -839,7 +930,7 @@ \begin{itemdescr} \pnum -Representation of a signaling ``Not a Number,'' if available.\footnote{Required by LIA-1.} +Representation of a signaling ``Not a Number'', if available.\footnote{Required by LIA-1.} \pnum Meaningful for all specializations for which @@ -854,8 +945,9 @@ \end{itemdecl} \begin{itemdescr} +\indextext{number!subnormal}% \pnum -Minimum positive denormalized value.\footnote{Required by LIA-1.} +Minimum positive subnormal value.\footnote{Required by LIA-1.} \pnum Meaningful for all floating-point types. @@ -873,7 +965,7 @@ \begin{itemdescr} \pnum -True if and only if the type adheres to ISO/IEC/IEEE +\tcode{true} if and only if the type adheres to ISO/IEC/IEEE 60559.\footnote{ISO/IEC/IEEE 60559:2011 is the same as IEEE 754-2008.} \pnum @@ -887,7 +979,7 @@ \begin{itemdescr} \pnum -True if the set of values representable by the type is finite.\footnote{Required by LIA-1.} +\tcode{true} if the set of values representable by the type is finite.\footnote{Required by LIA-1.} \begin{note} All fundamental types~(\ref{basic.fundamental}) are bounded. This member would be \tcode{false} for arbitrary precision types.\end{note} @@ -902,7 +994,7 @@ \begin{itemdescr} \pnum -True if the type is modulo.\footnote{Required by LIA-1.} +\tcode{true} if the type is modulo.\footnote{Required by LIA-1.} A type is modulo if, for any operation involving \tcode{+}, \tcode{-}, or \tcode{*} on values of that type whose result would fall outside the range \crange{min()}{max()}, the value returned differs from the true value by an @@ -966,80 +1058,6 @@ \tcode{round_toward_zero}. \end{itemdescr} -\rSec3[round.style]{Type \tcode{float_round_style}} - -\indexlibrary{\idxcode{float_round_style}}% -\begin{codeblock} -namespace std { - enum float_round_style { - round_indeterminate = -1, - round_toward_zero = 0, - round_to_nearest = 1, - round_toward_infinity = 2, - round_toward_neg_infinity = 3 - }; -} -\end{codeblock} - -\pnum -The rounding mode for floating-point arithmetic is characterized by the -values: - -\begin{itemize} -\item -\indexlibrary{\idxcode{round_indeterminate}}% -\tcode{round_indeterminate} -if the rounding style is indeterminable -\item -\indexlibrary{\idxcode{round_toward_zero}}% -\tcode{round_toward_zero} -if the rounding style is toward zero -\item -\indexlibrary{\idxcode{round_to_nearest}}% -\tcode{round_to_nearest} -if the rounding style is to the nearest representable value -\item -\indexlibrary{\idxcode{round_toward_infinity}}% -\tcode{round_toward_infinity} -if the rounding style is toward infinity -\item -\indexlibrary{\idxcode{round_toward_neg_infinity}}% -\tcode{round_toward_neg_infinity} -if the rounding style is toward negative infinity -\end{itemize} - -\rSec3[denorm.style]{Type \tcode{float_denorm_style}} - -\indexlibrary{\idxcode{float_denorm_style}}% -\begin{codeblock} -namespace std { - enum float_denorm_style { - denorm_indeterminate = -1, - denorm_absent = 0, - denorm_present = 1 - }; -} -\end{codeblock} - -\pnum -The presence or absence of denormalization (variable number of exponent bits) -is characterized by the values: - -\begin{itemize} -\item -\indexlibrary{\idxcode{denorm_indeterminate}}% -\tcode{denorm_indeterminate} -if it cannot be determined whether or not the type allows denormalized values -\item -\indexlibrary{\idxcode{denorm_absent}}% -\tcode{denorm_absent} -if the type does not allow denormalized values -\item -\indexlibrary{\idxcode{denorm_present}}% -\tcode{denorm_present} -if the type does allow denormalized values -\end{itemize} - \rSec3[numeric.special]{\tcode{numeric_limits} specializations} \pnum @@ -1063,9 +1081,9 @@ public: static constexpr bool is_specialized = true; - inline static constexpr float min() noexcept { return 1.17549435E-38F; } - inline static constexpr float max() noexcept { return 3.40282347E+38F; } - inline static constexpr float lowest() noexcept { return -3.40282347E+38F; } + static constexpr float min() noexcept { return 1.17549435E-38F; } + static constexpr float max() noexcept { return 3.40282347E+38F; } + static constexpr float lowest() noexcept { return -3.40282347E+38F; } static constexpr int digits = 24; static constexpr int digits10 = 6; @@ -1076,8 +1094,8 @@ static constexpr bool is_exact = false; static constexpr int radix = 2; - inline static constexpr float epsilon() noexcept { return 1.19209290E-07F; } - inline static constexpr float round_error() noexcept { return 0.5F; } + static constexpr float epsilon() noexcept { return 1.19209290E-07F; } + static constexpr float round_error() noexcept { return 0.5F; } static constexpr int min_exponent = -125; static constexpr int min_exponent10 = - 37; @@ -1090,10 +1108,10 @@ static constexpr float_denorm_style has_denorm = denorm_absent; static constexpr bool has_denorm_loss = false; - inline static constexpr float infinity() noexcept { return @\textit{value}@; } - inline static constexpr float quiet_NaN() noexcept { return @\textit{value}@; } - inline static constexpr float signaling_NaN() noexcept { return @\textit{value}@; } - inline static constexpr float denorm_min() noexcept { return min(); } + static constexpr float infinity() noexcept { return @\textit{value}@; } + static constexpr float quiet_NaN() noexcept { return @\textit{value}@; } + static constexpr float signaling_NaN() noexcept { return @\textit{value}@; } + static constexpr float denorm_min() noexcept { return min(); } static constexpr bool is_iec559 = true; static constexpr bool is_bounded = true; @@ -1158,9 +1176,7 @@ } \end{codeblock} -\rSec2[c.limits]{C library} - -\rSec3[climits.syn]{Header \tcode{} synopsis} +\rSec2[climits.syn]{Header \tcode{} synopsis} \indexlibrary{\idxcode{CHAR_BIT}}% \indexlibrary{\idxcode{SCHAR_MIN}}% @@ -1213,7 +1229,7 @@ \xref ISO C 5.2.4.2.1 -\rSec3[cfloat.syn]{Header \tcode{} synopsis} +\rSec2[cfloat.syn]{Header \tcode{} synopsis} \indexlibrary{\idxcode{DBL_DECIMAL_DIG}}% \indexlibrary{\idxcode{DBL_DIG}}% @@ -1400,6 +1416,8 @@ The header defines all types and macros the same as the C standard library header \tcode{}. +\xref ISO C~7.20. + \rSec1[support.start.term]{Start and termination} \pnum @@ -1494,14 +1512,13 @@ See~\ref{basic.start.term} for the order of destructions and calls. (Automatic objects are not destroyed as a result of calling \tcode{exit()}.)\footnote{Objects with automatic storage duration are all destroyed in a program whose -function -\tcode{main()} +\tcode{main} function~(\ref{basic.start.main}) contains no automatic objects and executes the call to \tcode{exit()}. Control can be transferred directly to such a -\tcode{main()} +\tcode{main} function by throwing an exception that is caught in -\tcode{main()}.} +\tcode{main}.} If control leaves a registered function called by \tcode{exit} because the function does not provide a handler for a thrown exception, \tcode{std::terminate()} shall be called~(\ref{except.terminate}).% @@ -1670,7 +1687,7 @@ \rSec2[new.delete]{Storage allocation and deallocation} \pnum -Except where otherwise specified, the provisions of~(\ref{basic.stc.dynamic}) +Except where otherwise specified, the provisions of~\ref{basic.stc.dynamic} apply to the library versions of \tcode{operator new} and \tcode{op\-er\-a\-tor delete}. If the value of an alignment argument @@ -1877,7 +1894,7 @@ The functions that have a \tcode{size} parameter forward their other parameters to the corresponding function without a \tcode{size} parameter. -\begin{note} See the note in the above \textit{Replaceable} paragraph. \end{note} +\begin{note} See the note in the above \replaceable paragraph. \end{note} \pnum \default @@ -2192,9 +2209,9 @@ \rSec3[new.delete.placement]{Non-allocating forms} \pnum -These functions are reserved, a \Cpp program may not define functions that displace +These functions are reserved; a \Cpp program may not define functions that displace the versions in the \Cpp standard library~(\ref{constraints}). -The provisions of~(\ref{basic.stc.dynamic}) do not apply to these reserved +The provisions of~\ref{basic.stc.dynamic} do not apply to these reserved placement forms of \tcode{operator new} and \tcode{operator delete}. \indexlibrary{\idxcode{new}!\idxcode{operator}}% @@ -2442,7 +2459,7 @@ \indexlibrary{\idxcode{bad_alloc}}% \tcode{bad_alloc}; \item -terminate execution of the program without returning to the caller; +terminate execution of the program without returning to the caller. \indexlibrary{\idxcode{abort}}% \indexlibrary{\idxcode{exit}}% \end{itemize} @@ -2518,10 +2535,10 @@ an object that is pointer-interconvertible with \placeholder{Y}, or the immediately-enclosing array object if \placeholder{Y} is an array element. The program is ill-formed if \tcode{T} is a function type -or (possibly cv-qualified) \tcode{void}. +or \cv{}~\tcode{void}. \pnum -\realnotes +\begin{note} If a new object is created in storage occupied by an existing object of the same type, a pointer to the original object @@ -2530,6 +2547,7 @@ in the latter cases, this function can be used to obtain a usable pointer to the new object. See~\ref{basic.life}. +\end{note} \pnum \begin{example} @@ -2708,7 +2726,7 @@ objects which compare equal. \pnum -\remarks an implementation should return different values for two +\remarks An implementation should return different values for two \tcode{type_info} objects which do not compare equal. \end{itemdescr} @@ -3206,7 +3224,7 @@ \tcode{exception_ptr} objects shall access and modify only the \tcode{exception_ptr} objects themselves and not the exceptions they refer to. Use of \tcode{rethrow_exception} on \tcode{exception_ptr} objects that refer to -the same exception object shall not introduce a data race. \begin{note} if +the same exception object shall not introduce a data race. \begin{note} If \tcode{rethrow_exception} rethrows the same exception object (rather than a copy), concurrent access to that rethrown exception object may introduce a data race. Changes in the number of \tcode{exception_ptr} objects that refer to a @@ -3249,7 +3267,7 @@ \requires \tcode{p} shall not be a null pointer. \pnum -\throws the exception object to which \tcode{p} refers. +\throws The exception object to which \tcode{p} refers. \end{itemdescr} \indexlibrary{\idxcode{make_exception_ptr}}% @@ -3350,7 +3368,7 @@ \pnum \throws -if \tcode{is_class_v \&\& !is_final_v \&\& !is_base_of_v} +If \tcode{is_class_v \&\& !is_final_v \&\& !is_base_of_v} is \tcode{true}, an exception of unspecified type that is publicly derived from both \tcode{U} and \tcode{nested_exception} @@ -3434,10 +3452,10 @@ \begin{itemdescr} \pnum -\effects constructs an empty \tcode{initializer_list} object. +\effects Constructs an empty \tcode{initializer_list} object. \pnum -\postconditions \tcode{size() == 0} +\postconditions \tcode{size() == 0}. \end{itemdescr} \rSec2[support.initlist.access]{Initializer list access} @@ -3461,7 +3479,7 @@ \begin{itemdescr} \pnum -\returns \tcode{begin() + size()} +\returns \tcode{begin() + size()}. \end{itemdescr} \indexlibrarymember{size}{initializer_list}% @@ -3502,11 +3520,17 @@ \rSec1[support.runtime]{Other runtime support} \pnum +\indextext{\idxhdr{cstdarg}}% \indexlibrary{\idxhdr{cstdarg}}% +\indextext{\idxhdr{csetjmp}}% \indexlibrary{\idxhdr{csetjmp}}% +\indextext{\idxhdr{ctime}}% \indexlibrary{\idxhdr{ctime}}% +\indextext{\idxhdr{csignal}}% \indexlibrary{\idxhdr{csignal}}% +\indextext{\idxhdr{cstdlib}}% \indexlibrary{\idxhdr{cstdlib}}% +\indextext{\idxhdr{cstdbool}}% \indexlibrary{\idxhdr{cstdbool}}% \indexlibrary{\idxcode{getenv}}% \indexlibrary{\idxcode{system}}% @@ -3543,6 +3567,7 @@ \rSec2[cstdarg.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{cstdarg}}% \indexlibrary{\idxhdr{cstdarg}}% \indexlibrary{\idxcode{va_list}}% \indexlibrary{\idxcode{va_start}}% @@ -3561,6 +3586,7 @@ \end{codeblock} \pnum +\indextext{\idxhdr{stdarg.h}}% \indexlibrary{\idxhdr{stdarg.h}}% The contents of the header \tcode{} are the same as the C standard library header \tcode{}, with the following changes: @@ -3591,6 +3617,7 @@ \rSec2[csetjmp.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{csetjmp}}% \indexlibrary{\idxhdr{csetjmp}}% \indexlibrary{\idxcode{jmp_buf}}% \indexlibrary{\idxcode{longjmp}}% @@ -3605,6 +3632,7 @@ \end{codeblock} \pnum +\indextext{\idxhdr{setjmp.h}}% \indexlibrary{\idxhdr{setjmp.h}}% The contents of the header \tcode{} are the same as the C standard library header \tcode{}. @@ -3623,6 +3651,7 @@ \rSec2[cstdbool.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{cstdbool}}% \indexlibrary{\idxhdr{cstdbool}}% \indexlibrary{\idxcode{__bool_true_false_are_defined}}% \begin{codeblock} @@ -3630,6 +3659,7 @@ \end{codeblock} \pnum +\indextext{\idxhdr{stdbool.h}}% \indexlibrary{\idxhdr{stdbool.h}}% The contents of the header \tcode{} are the same as the C standard library header \tcode{}, with the following changes: @@ -3641,6 +3671,7 @@ \rSec2[cstdalign.syn]{Header \tcode{} synopsis} \indexlibrary{\idxcode{__alignas_is_defined}}% +\indextext{\idxhdr{cstdalign}}% \indexlibrary{\idxhdr{cstdalign}}% \begin{codeblock} #define @\xname{alignas_is_defined}@ 1 @@ -3648,6 +3679,7 @@ \pnum \indexlibrary{\idxhdr{cstdalign}}% +\indextext{\idxhdr{stdalign.h}}% \indexlibrary{\idxhdr{stdalign.h}}% The contents of the header \tcode{} are the same as the C standard library header \tcode{}, with the following changes: @@ -3658,6 +3690,7 @@ \rSec2[csignal.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{csignal}}% \indexlibrary{\idxhdr{csignal}}% \indexlibrary{\idxcode{sig_atomic_t}}% \indexlibrary{\idxcode{signal}}% @@ -3693,6 +3726,7 @@ \end{codeblock} \pnum +\indextext{\idxhdr{signal.h}}% \indexlibrary{\idxhdr{signal.h}}% The contents of the header \tcode{} are the same as the C standard library header \tcode{}. diff --git a/source/tables.tex b/source/tables.tex index b29ee1b439..0119f4fe4e 100644 --- a/source/tables.tex +++ b/source/tables.tex @@ -155,145 +155,6 @@ \end{floattable} } -% usage: \begin{LibSynTab}{TITLE}{XREF}{COUNT}{LAYOUT} -% produces table with COUNT columns. Used as base for description tables -% for C library -\newenvironment{LibSynTab}[4] -{ - \begin{LibSynTabBase}{Header}{#1}{#2}{#3}{#4} -} -{ - \end{LibSynTabBase} -} - -% usage: \begin{LibSynTabAdd}{TITLE}{XREF}{COUNT}{LAYOUT} -% produces table with COUNT columns. Used as base for description tables -% for additions to C library -\newenvironment{LibSynTabAdd}[4] -{ - \begin{LibSynTabBase}{Additions to header}{#1}{#2}{#3}{#4} -} -{ - \end{LibSynTabBase} -} - -% usage: \begin{libsyntabN}{TITLE}{XREF} -% \begin{libsyntabaddN}{TITLE}{XREF} -% produces a table with N columns for C library description tables -\newenvironment{libsyntab2}[2] -{ - \begin{LibSynTab}{#1}{#2}{2}{ll} -} -{ - \end{LibSynTab} -} - -\newenvironment{libsyntab3}[2] -{ - \begin{LibSynTab}{#1}{#2}{3}{lll} -} -{ - \end{LibSynTab} -} - -\newenvironment{libsyntab4}[2] -{ - \begin{LibSynTab}{#1}{#2}{4}{llll} -} -{ - \end{LibSynTab} -} - -\newenvironment{libsyntab5}[2] -{ - \begin{LibSynTab}{#1}{#2}{5}{lllll} -} -{ - \end{LibSynTab} -} - -\newenvironment{libsyntab6}[2] -{ - \begin{LibSynTab}{#1}{#2}{6}{llllll} -} -{ - \end{LibSynTab} -} - -\newenvironment{libsyntabadd2}[2] -{ - \begin{LibSynTabAdd}{#1}{#2}{2}{ll} -} -{ - \end{LibSynTabAdd} -} - -\newenvironment{libsyntabadd3}[2] -{ - \begin{LibSynTabAdd}{#1}{#2}{3}{lll} -} -{ - \end{LibSynTabAdd} -} - -\newenvironment{libsyntabadd4}[2] -{ - \begin{LibSynTabAdd}{#1}{#2}{4}{llll} -} -{ - \end{LibSynTabAdd} -} - -\newenvironment{libsyntabadd5}[2] -{ - \begin{LibSynTabAdd}{#1}{#2}{5}{lllll} -} -{ - \end{LibSynTabAdd} -} - -\newenvironment{libsyntabadd6}[2] -{ - \begin{LibSynTabAdd}{#1}{#2}{6}{llllll} -} -{ - \end{LibSynTabAdd} -} - -% usage: \begin{libsyntabfN}{TITLE}{XREF} -% produces a fixed width table with N columns for C library description tables -\newenvironment{libsyntabf2}[2] -{ - \begin{LibSynTab}{#1}{#2}{2}{p{1in}p{4in}} -} -{ - \end{LibSynTab} -} - -\newenvironment{libsyntabf3}[2] -{ - \begin{LibSynTab}{#1}{#2}{3}{p{1in}p{.9in}p{2.9in}} -} -{ - \end{LibSynTab} -} - -\newenvironment{libsyntabf5}[2] -{ - \begin{LibSynTab}{#1}{#2}{5}{p{.9in}p{.9in}p{.9in}p{.9in}p{.9in}} -} -{ - \end{LibSynTab} -} - -\newenvironment{libsyntabf4}[2] -{ - \begin{LibSynTab}{#1}{#2}{4}{p{1in}p{.9in}p{.9in}p{1.8in}} -} -{ - \end{LibSynTab} -} - % usage: \begin{concepttable}{TITLE}{TAG}{LAYOUT} % produces table at current location \newenvironment{concepttable}[3] @@ -463,15 +324,6 @@ \end{LongTable} } -\newenvironment{libreqtab4}[2] -{ - \begin{LongTable} - {#1}{#2} -} -{ - \end{LongTable} -} - \newenvironment{libreqtab4a}[2] { \begin{LongTable} @@ -634,7 +486,7 @@ % tables in standard. \newenvironment{libefftabvaluenarrow}[2] { - \begin{LibEffTab}{#1}{#2}{Value}{1.3in} + \begin{LibEffTab}{#1}{#2}{Value}{1.5in} } { \end{LibEffTab} diff --git a/source/templates.tex b/source/templates.tex index 72addbfe2f..b3834151ea 100644 --- a/source/templates.tex +++ b/source/templates.tex @@ -8,7 +8,7 @@ \indextext{type generator|see{template}} \pnum -A \term{template} defines a family of classes or functions or an alias for a +A \defn{template} defines a family of classes, functions, or variables, or an alias for a family of types. \indextext{\idxcode{template}}% @@ -25,8 +25,8 @@ \end{bnf} \begin{note} The \tcode{>} token following the -\nonterminal{template-parameter-list} of a -\nonterminal{template-declaration} +\grammarterm{template-parameter-list} of a +\grammarterm{template-declaration} may be the product of replacing a \tcode{>{>}} token by two consecutive \tcode{>} tokens~(\ref{temp.names}).\end{note} @@ -51,15 +51,13 @@ \end{itemize} A \grammarterm{template-declaration} is a \grammarterm{declaration}. -\indextext{template!definition~of}% +\indextext{template!definition of}% A \grammarterm{template-declaration} is also a definition if its \grammarterm{declaration} defines a function, a class, a variable, or a static data member. A declaration introduced by a template declaration of a -\indextext{variable template!definition~of}% -\indextext{template!variable}% -\indextext{template!static data member}% -variable is a \term{variable template}. A variable template at class scope is a -\term{static data member template}. +\indextext{variable template!definition of}% +variable is a \defnx{variable template}{template!variable}. A variable template at class scope is a +\defnx{static data member template}{template!static data member}. \begin{example} \begin{codeblock} @@ -110,7 +108,7 @@ no declarator is permitted. \pnum -\indextext{template~name!linkage~of}% +\indextext{template name!linkage of}% A template name has linkage~(\ref{basic.link}). Specializations (explicit or implicit) of a template that has internal linkage are @@ -131,7 +129,7 @@ \pnum A class template shall not have the same name as any other template, class, function, variable, enumeration, enumerator, namespace, or -type in the same scope~(\ref{basic.scope}), except as specified in~(\ref{temp.class.spec}). +type in the same scope~(\ref{basic.scope}), except as specified in~\ref{temp.class.spec}. Except that a function template can be overloaded either by non-template functions~(\ref{dcl.fct}) with the same name or by other function templates with the same name~(\ref{temp.over}), @@ -193,8 +191,8 @@ \end{bnf} \begin{note} The \tcode{>} token following the -\nonterminal{template-parameter-list} of a -\nonterminal{type-parameter} +\grammarterm{template-parameter-list} of a +\grammarterm{type-parameter} may be the product of replacing a \tcode{>{>}} token by two consecutive \tcode{>} tokens~(\ref{temp.names}).\end{note} @@ -228,7 +226,7 @@ \tcode{class} \grammarterm{identifier} is a \grammarterm{type-parameter}. \begin{example} \begin{codeblock} - class T { /* ... */ }; + class T { @\commentellip@ }; int i; template void f(T t) { @@ -267,7 +265,7 @@ For example, \begin{codeblock} -template class myarray { /* ... */ }; +template class myarray { @\commentellip@ }; template class C = myarray> class Map { @@ -352,16 +350,16 @@ \pnum A non-type \grammarterm{template-parameter} -\indextext{array!template parameter~of~type}% +\indextext{array!template parameter of type}% of type ``array of \tcode{T}'' or -\indextext{function!template parameter~of~type}% +\indextext{function!template parameter of type}% of function type \tcode{T} is adjusted to be of type ``pointer to \tcode{T}''. \begin{example} \begin{codeblock} -template struct R { /* ... */ }; -template struct S { /* ... */ }; +template struct R { @\commentellip@ }; +template struct S { @\commentellip@ }; int p; R<&p> w; // OK S<&p> x; // OK due to parameter adjustment @@ -373,7 +371,7 @@ \pnum A -\term{default template-argument} +\defnx{default template-argument}{\idxgram{template-argument}!default} is a \grammarterm{template-argument}~(\ref{temp.arg}) specified after \tcode{=} @@ -467,11 +465,11 @@ \begin{codeblock} template class X; -template class X { /*... */ }; // error +template class X { @\commentellip@ }; // error \end{codeblock} \end{example} -\indextext{\idxcode{<}!template~and}% +\indextext{\idxcode{<}!template and}% \pnum When parsing a default @@ -487,10 +485,10 @@ \begin{codeblock} template 4 > // syntax error -class X { /* ... */ }; +class X { @\commentellip@ }; template 4) > // OK -class Y { /* ... */ }; +class Y { @\commentellip@ }; \end{codeblock} \end{example} @@ -600,7 +598,7 @@ the name must be known to refer to a template. \pnum -\indextext{\idxcode{<}!template~and}% +\indextext{\idxcode{<}!template and}% After name lookup~(\ref{basic.lookup}) finds that a name is a \grammarterm{template-name} or that an \grammarterm{operator-function-id} or a \grammarterm{literal-operator-id} refers to a set of @@ -624,20 +622,20 @@ rather than a greater-than operator. Similarly, the first non-nested \tcode{>{>}} is treated as two consecutive but distinct \tcode{>} tokens, the first of which is taken -as the end of the \nonterminal{template-argument-list} and completes -the \nonterminal{template-id}. \begin{note} The second \tcode{>} +as the end of the \grammarterm{template-argument-list} and completes +the \grammarterm{template-id}. \begin{note} The second \tcode{>} token produced by this replacement rule may terminate an enclosing -\nonterminal{template-id} construct or it may be part of a different +\grammarterm{template-id} construct or it may be part of a different construct (e.g. a cast).\end{note} \begin{example} \begin{codeblock} -template class X @\tcode{\{ /* ... */ \};}@ +template class X { @\commentellip@ }; X< 1>2 > x1; // syntax error X<(1>2)> x2; // OK -template class Y @\tcode{\{ /* ... */ \};}@ +template class Y { @\commentellip@ }; Y> x3; // OK, same as \tcode{Y > x3;} Y>1>> x4; // syntax error Y>1)>> x5; // OK @@ -763,7 +761,6 @@ parameter pack~(\ref{temp.variadic}), it will correspond to zero or more \grammarterm{template-argument}{s}. \begin{example} - \begin{codeblock} template class Array { T* v; @@ -775,8 +772,7 @@ }; Array v1(20); -typedef std::complex dcomplex; // \tcode{std::complex} is a standard - // library template +typedef std::complex dcomplex; // \tcode{std::complex} is a standard library template Array v2(30); Array v3(40); @@ -802,7 +798,6 @@ determines the allowable forms of the \grammarterm{template-argument}.} \begin{example} - \begin{codeblock} template void f(); template void f(); @@ -837,7 +832,7 @@ class Y { private: - struct S { /* ... */ }; + struct S { @\commentellip@ }; X x; // OK: \tcode{S} is accessible // \tcode{X} has a static member of type \tcode{Y::S} // OK: even though \tcode{Y::S} is private @@ -859,7 +854,7 @@ template class B { private: - struct S { /* ... */ }; + struct S { @\commentellip@ }; }; A b; // ill-formed: \tcode{A} has no access to \tcode{B::S} @@ -933,7 +928,7 @@ \begin{example} \begin{codeblock} template struct S { }; -S* p; // the type of \tcode{p} is \tcode{S*} +S* p; // the type of \tcode{p} is \tcode{S*} \end{codeblock} The default argument for \tcode{U} is instantiated to form the type \tcode{S*}. \end{example} @@ -1021,30 +1016,30 @@ \pnum \begin{example} \begin{codeblock} -template struct X { /* ... */ }; +template struct X { @\commentellip@ }; int ai[10]; X xi; // array to pointer and qualification conversions -struct Y { /* ... */ }; -template struct Z { /* ... */ }; +struct Y { @\commentellip@ }; +template struct Z { @\commentellip@ }; Y y; Z z; // no conversion, but note extra cv-qualification -template struct W { /* ... */ }; +template struct W { @\commentellip@ }; int b[5]; W w; // no conversion void f(char); void f(int); -template struct A { /* ... */ }; +template struct A { @\commentellip@ }; A<&f> a; // selects \tcode{f(int)} -template struct B { /* ... */ }; -B<5> b1; // OK: template parameter type is \tcode{int} -B<'a'> b2; // OK: template parameter type is \tcode{char} -B<2.5> b3; // error: template parameter type cannot be \tcode{double} +template struct B { @\commentellip@ }; +B<5> b1; // OK: template parameter type is \tcode{int} +B<'a'> b2; // OK: template parameter type is \tcode{char} +B<2.5> b3; // error: template parameter type cannot be \tcode{double} \end{codeblock} \end{example} @@ -1057,7 +1052,7 @@ \begin{codeblock} template class X { - /* ... */ + @\commentellip@ }; X x1; // error: string literal as template-argument @@ -1099,7 +1094,7 @@ \begin{example} \begin{codeblock} -template struct B { /* ... */ }; +template struct B { @\commentellip@ }; B<1> b2; // error: temporary would be required for template argument @@ -1172,13 +1167,13 @@ \begin{example} \begin{codeblock} -template class A { /* ... */ }; -template class B { /* ... */ }; -template class C { /* ... */ }; -template class D { /* ... */ }; -template class P> class X { /* ... */ }; -template class Q> class Y { /* ... */ }; -template class R> class Z { /* ... */ }; +template class A { @\commentellip@ }; +template class B { @\commentellip@ }; +template class C { @\commentellip@ }; +template class D { @\commentellip@ }; +template class P> class X { @\commentellip@ }; +template class Q> class Y { @\commentellip@ }; +template class R> class Z { @\commentellip@ }; X xa; // OK X xb; // OK @@ -1271,7 +1266,7 @@ \begin{example} \begin{codeblock} -template class buffer { /* ... */ }; +template class buffer { @\commentellip@ }; buffer x; buffer y; \end{codeblock} @@ -1283,7 +1278,7 @@ to be of the same type, and \begin{codeblock} -template class list { /* ... */ }; +template class list { @\commentellip@ }; list x1; list x2; list x3; @@ -1361,25 +1356,20 @@ \rSec2[temp.class]{Class templates} \pnum -A class -\term{template} +A +\defnx{class template}{template!class} defines the layout and operations for an unbounded set of related types. -\begin{example} -a single class template -\tcode{List} -might provide a common definition for -list of -\tcode{int}, -list of -\tcode{float}, -and list of pointers to -\tcode{Shape}s. -\end{example} +\pnum \begin{example} -An array class template might be declared like this: - +A single class template +\tcode{List} +might provide an unbounded set of class definitions: +one class \tcode{List} for every type \tcode{T}, +each describing a linked list of elements of type \tcode{T}. +Similarly, a class template \tcode{Array} describing a contiguous, +dynamic array might be defined like this: \begin{codeblock} template class Array { T* v; @@ -1390,16 +1380,11 @@ T& elem(int i) { return v[i]; } }; \end{codeblock} - -\pnum -The prefix -\tcode{template} -\tcode{} +The prefix \tcode{template} specifies that a template is being declared and that a \grammarterm{type-name} \tcode{T} -will be used in the declaration. +may be used in the declaration. In other words, \tcode{Array} is a parameterized type with @@ -1457,7 +1442,7 @@ \rSec3[temp.mem.func]{Member functions of class templates} \pnum -\indextext{template!member~function}% +\indextext{template!member function}% A member function of a class template may be defined outside of the class @@ -1493,10 +1478,10 @@ \grammarterm{template-argument}{s} of the type of the object for which the member function is called. \begin{example} -the +The \grammarterm{template-argument} for -\tcode{Array\,::\,op\-er\-a\-tor\,[]\,()} +\tcode{Array::operator[]()} will be determined by the \tcode{Array} to which the subscripting operation is applied. @@ -1533,7 +1518,7 @@ \rSec3[temp.static]{Static data members of class templates} \pnum -\indextext{member!template~and \tcode{static}}% +\indextext{member!template and \tcode{static}}% A definition for a static data member or static data member template may be provided in a namespace scope enclosing the definition of the static member's class template. @@ -1547,11 +1532,11 @@ struct limits { template - static const T min; // declaration + static const T min; // declaration }; template - const T limits::min = { }; // definition + const T limits::min = { }; // definition \end{codeblock} \end{example} @@ -1563,8 +1548,8 @@ template struct A { static int i[]; }; -template int A::i[4]; // 4 elements -template <> int A::i[] = { 1 }; // OK: 1 element +template int A::i[4]; // 4 elements +template <> int A::i[] = { 1 }; // OK: 1 element \end{codeblock} \end{example} @@ -1572,8 +1557,8 @@ \pnum An enumeration member of a class template may be defined outside the class -template definition. \begin{example} - +template definition. +\begin{example} \begin{codeblock} template struct A { enum E : T; @@ -1598,11 +1583,10 @@ \grammarterm{template-parameter}{s} of the member template. \begin{example} - \begin{codeblock} template struct string { template int compare(const T2&); - template string(const string& s) { /* ... */ } + template string(const string& s) { @\commentellip@ } }; template template int string::compare(const T2& s) { @@ -1659,7 +1643,6 @@ a member function template does not override a virtual function from a base class. \begin{example} - \begin{codeblock} class B { virtual void f(int); @@ -1667,8 +1650,7 @@ class D : public B { template void f(T); // does not override \tcode{B::f(int)} - void f(int i) { f<>(i); } // overriding function that calls - // the template instantiation + void f(int i) { f<>(i); } // overriding function that calls the template instantiation }; \end{codeblock} \end{example} @@ -1692,8 +1674,7 @@ int main() { A a; int* ip; - ip = a.operator int*(); // explicit call to template operator - // \tcode{A::operator int*()} + ip = a.operator int*(); // explicit call to template operator \tcode{A::operator int*()} } \end{codeblock} \end{example} @@ -1735,7 +1716,7 @@ \rSec2[temp.variadic]{Variadic templates} \pnum -A \term{template parameter pack} is a template parameter +A \defn{template parameter pack} is a template parameter that accepts zero or more template arguments. \begin{example} \begin{codeblock} @@ -1750,26 +1731,27 @@ \end{example} \pnum -A \term{function parameter pack} is a function parameter +A \defn{function parameter pack} is a function parameter that accepts zero or more function arguments. \begin{example} \begin{codeblock} template void f(Types ... args); -f(); // OK: \tcode{args} contains no arguments -f(1); // OK: \tcode{args} contains one argument: \tcode{int} -f(2, 1.0); // OK: \tcode{args} contains two arguments: \tcode{int} and \tcode{double} +f(); // OK: \tcode{args} contains no arguments +f(1); // OK: \tcode{args} contains one argument: \tcode{int} +f(2, 1.0); // OK: \tcode{args} contains two arguments: \tcode{int} and \tcode{double} \end{codeblock} \end{example} \pnum -A \term{parameter pack} is either a template parameter +A \defn{parameter pack} is either a template parameter pack or a function parameter pack. \pnum -A \term{pack expansion} -consists of a \term{pattern} and an ellipsis, the instantiation of which +\indextext{pattern|see{pack expansion, pattern}}% +A \defn{pack expansion} +consists of a \defnx{pattern}{pack expansion!pattern} and an ellipsis, the instantiation of which produces zero or more instantiations of the pattern in a list (described below). The form of the pattern depends on the context in which the expansion occurs. Pack @@ -1824,14 +1806,12 @@ \end{itemize} \begin{example} - \begin{codeblock} template void f(Types ... rest); template void g(Types ... rest) { f(&rest ...); // ``\tcode{\&rest ...}'' is a pack expansion; ``\tcode{\&rest}'' is its pattern } \end{codeblock} - \end{example} \pnum @@ -1846,7 +1826,7 @@ a parameter pack is only expanded by the innermost enclosing pack expansion. The pattern of a pack expansion shall name one or more parameter packs that are not expanded by a nested pack expansion; such parameter packs are called -\term{unexpanded} parameter packs in the pattern. All of the parameter packs expanded +\defnx{unexpanded parameter packs}{parameter pack!unexpanded} in the pattern. All of the parameter packs expanded by a pack expansion shall have the same number of arguments specified. An appearance of a name of a parameter pack that is not expanded is ill-formed. \begin{example} @@ -1867,12 +1847,12 @@ // error: different number of arguments specified for \tcode{Args1} and \tcode{Args2} template - void g(Args ... args) { // OK: \tcode{Args} is expanded by the function parameter pack \tcode{args} - f(const_cast(&args)...); // OK: ``\tcode{Args}'' and ``\tcode{args}'' are expanded - f(5 ...); // error: pattern does not contain any parameter packs - f(args); // error: parameter pack ``\tcode{args}'' is not expanded - f(h(args ...) + args ...); // OK: first ``\tcode{args}'' expanded within \tcode{h}, second - // ``\tcode{args}'' expanded within \tcode{f} + void g(Args ... args) { // OK: \tcode{Args} is expanded by the function parameter pack \tcode{args} + f(const_cast(&args)...); // OK: ``\tcode{Args}'' and ``\tcode{args}'' are expanded + f(5 ...); // error: pattern does not contain any parameter packs + f(args); // error: parameter pack ``\tcode{args}'' is not expanded + f(h(args ...) + args ...); // OK: first ``\tcode{args}'' expanded within \tcode{h}, + // second ``\tcode{args}'' expanded within \tcode{f} } \end{codeblock} @@ -1884,7 +1864,7 @@ nor a \grammarterm{fold-expression} produces a list -$\mathtt{E}_1, \mathtt{E}_2, ..., \mathtt{E}_N$, +$\mathtt{E}_1, \mathtt{E}_2, \dotsc, \mathtt{E}_N$, where $N$ is the number of elements in the pack expansion parameters. Each $\mathtt{E}_i$ is generated by instantiating the pattern and @@ -2003,7 +1983,7 @@ \rSec2[temp.friend]{Friends} \pnum -\indextext{friend!template~and}% +\indextext{friend!template and}% A friend of a class or class template can be a function template or class template, a specialization of a function template or class template, or a non-template function or class. @@ -2094,11 +2074,10 @@ In these cases, all specializations of the friend class or friend function template are friends of the class or class template granting friendship. \begin{example} - \begin{codeblock} class A { template friend class B; // OK - template friend void f(T)@\tcode{\{ /* ... */ \}}@ // OK + template friend void f(T){ @\commentellip@ } // OK }; \end{codeblock} \end{example} @@ -2109,7 +2088,6 @@ specialized~(\ref{temp.class.spec}) or explicitly specialized~(\ref{temp.expl.spec}), are friends of the class containing the template friend declaration. \begin{example} - \begin{codeblock} class X { template friend struct A; @@ -2205,13 +2183,13 @@ \indextext{specialization!class template partial}% \indextext{template!primary}% A -\term{primary} -class template declaration is one in which the class template name is an +\defnx{primary class template}{see{template, primary}} +declaration is one in which the class template name is an identifier. A template declaration in which the class template name is a \grammarterm{simple-template-id} is a -\term{partial specialization} +\defnx{partial specialization}{specialization!class template partial} of the class template named in the \grammarterm{simple-template-id}. A partial specialization of a class template provides an alternative definition @@ -2256,7 +2234,7 @@ Specifically, the order of the template arguments is the sequence in which they appear in the template parameter list. \begin{example} -the template argument list for the primary template in the example +The template argument list for the primary template in the example above is \tcode{ a0; A a2; - a0.f(); // OK, uses definition of primary template's member - a2.g(); // OK, uses definition of - // partial specialization's member - a2.h(); // OK, uses definition of - // explicit specialization's member - a2.f(); // ill-formed, no definition of \tcode{f} for \tcode{A} - // the primary template is not used here + a0.f(); // OK, uses definition of primary template's member + a2.g(); // OK, uses definition of partial specialization's member + a2.h(); // OK, uses definition of explicit specialization's member + a2.f(); // ill-formed, no definition of \tcode{f} for \tcode{A}; the primary template is not used here } \end{codeblock} \end{example} @@ -2592,7 +2561,7 @@ \pnum A function template defines an unbounded set of related functions. \begin{example} -a family of sort functions might be declared like this: +A family of sort functions might be declared like this: \begin{codeblock} template class Array { }; @@ -2696,8 +2665,9 @@ \end{note} \pnum +\indextext{equivalent!expression|see{expression, equivalent}}% Two expressions involving template parameters are considered -\term{equivalent} +\defnx{equivalent}{expression!equivalent} if two function definitions containing the expressions would satisfy the one-definition rule~(\ref{basic.def.odr}), except that the tokens used to name the template parameters may differ as long as a token used to @@ -2722,21 +2692,26 @@ // was not in scope at the first declaration of \tcode{h()} \end{codeblock} \end{example} +\indextext{equivalent!functionally|see{expression, functionally equivalent}}% +\indextext{functionally equivalent!expression|see{expression, functionally equivalent}}% Two expressions involving template parameters that are not equivalent are -\term{functionally equivalent} +\defnx{functionally equivalent}{expression!functionally equivalent} if, for any given set of template arguments, the evaluation of the expression results in the same value. \pnum +\indextext{equivalent!function template|see{template, function, equivalent}}% Two function templates are -\term{equivalent} +\defnx{equivalent}{template!function!equivalent} if they are declared in the same scope, have the same name, have identical template parameter lists, and have return types and parameter lists that are equivalent using the rules described above to compare expressions involving template parameters. +\indextext{equivalent!functionally|see{template, function, functionally equivalent}}% +\indextext{functionally equivalent!function template|see{template, function, functionally equivalent}}% Two function templates are -\term{functionally equivalent} +\defnx{functionally equivalent}{template!function!functionally equivalent} if they are equivalent except that one or more expressions that involve template parameters in the return types and parameter @@ -2775,12 +2750,12 @@ \pnum \indextext{overloading!resolution!template}% -\indextext{ordering!function template partial}% +\indextext{ordering!function template partial|see{template, function, partial ordering}}% If a function template is overloaded, the use of a function template specialization might be ambiguous because template argument deduction~(\ref{temp.deduct}) may associate the function template specialization with more than one function template declaration. -\term{Partial ordering} +\defnx{Partial ordering}{template!function!partial ordering} of overloaded function template declarations is used in the following contexts to select the function template to which a function template specialization refers: @@ -2827,11 +2802,11 @@ a new first parameter inserted in its function parameter list. Given \cv{} as the cv-qualifiers of \placeholder{M} (if any), the new parameter is of type ``rvalue reference to -\cv{} \placeholder{A}'' if the optional \grammarterm{ref-qualifier} of +\cv{}~\placeholder{A}'' if the optional \grammarterm{ref-qualifier} of \placeholder{M} is \tcode{\&\&} or if \placeholder{M} has no \grammarterm{ref-qualifier} and the first parameter of the other template has rvalue reference type. Otherwise, the new parameter is -of type ``lvalue reference to \cv{} \placeholder{A}''. +of type ``lvalue reference to \cv{}~\placeholder{A}''. \begin{note} This allows a non-static member to be ordered with respect to a non-member function and for the results to be equivalent to the ordering of two equivalent non-members. \end{note} @@ -2878,7 +2853,7 @@ const int* p; f(p); // \tcode{f(const T*)} is more specialized than \tcode{f(T)} or \tcode{f(T*)} float x; - g(x); // Ambiguous: \tcode{g(T)} or \tcode{g(T\&)} + g(x); // ambiguous: \tcode{g(T)} or \tcode{g(T\&)} A z; h(z); // overload resolution selects \tcode{h(A\&)} const A z2; @@ -2895,44 +2870,44 @@ \begin{example} \begin{codeblock} -template void f(T); // \#1 -template void f(T*, int=1); // \#2 -template void g(T); // \#3 -template void g(T*, ...); // \#4 +template void f(T); // \#1 +template void f(T*, int=1); // \#2 +template void g(T); // \#3 +template void g(T*, ...); // \#4 \end{codeblock} \begin{codeblock} int main() { int* ip; - f(ip); // calls \#2 - g(ip); // calls \#4 + f(ip); // calls \#2 + g(ip); // calls \#4 } \end{codeblock} \end{example}\begin{example} \begin{codeblock} template struct A { }; -template void f(U, A* p = 0); // \#1 -template< class U> void f(U, A* p = 0); // \#2 -template void g(T, T = T()); // \#3 -template void g(T, U ...); // \#4 +template void f(U, A* p = 0); // \#1 +template< class U> void f(U, A* p = 0); // \#2 +template void g(T, T = T()); // \#3 +template void g(T, U ...); // \#4 void h() { - f(42, (A*)0); // calls \#2 - f(42); // error: ambiguous - g(42); // error: ambiguous + f(42, (A*)0); // calls \#2 + f(42); // error: ambiguous + g(42); // error: ambiguous } \end{codeblock} \end{example}\begin{example} \begin{codeblock} -template void f(T, U...); // \#1 -template void f(T); // \#2 -template void g(T*, U...); // \#3 -template void g(T); // \#4 +template void f(T, U...); // \#1 +template void f(T); // \#2 +template void g(T*, U...); // \#3 +template void g(T); // \#4 void h(int i) { - f(&i); // error: ambiguous - g(&i); // OK: calls \#3 + f(&i); // error: ambiguous + g(&i); // OK: calls \#3 } \end{codeblock} \end{example}\end{note} @@ -2956,17 +2931,17 @@ \begin{example} \begin{codeblock} -template struct Alloc { /* ... */ }; +template struct Alloc { @\commentellip@ }; template using Vec = vector>; Vec v; // same as \tcode{vector{>} v;} template void process(Vec& v) - { /* ... */ } + { @\commentellip@ } template void process(vector>& w) - { /* ... */ } // error: redefinition + { @\commentellip@ } // error: redefinition template class TT> void f(TT); @@ -2987,7 +2962,7 @@ \begin{codeblock} template using void_t = void; template void_t f(); -f(); // error, \tcode{int} does not have a nested type \tcode{foo} +f(); // error, \tcode{int} does not have a nested type \tcode{foo} \end{codeblock} \end{example} @@ -3052,24 +3027,22 @@ TA* a5; // declare pointer to \tcode{T}'s \tcode{A} typename T::A* a6; // declare pointer to \tcode{T}'s \tcode{A} T::A* a7; // \tcode{T::A} is not a type name: - // multiply \tcode{T::A} by \tcode{a7}; ill-formed, - // no visible declaration of \tcode{a7} + // multiplication of \tcode{T::A} by \tcode{a7}; ill-formed, no visible declaration of \tcode{a7} B* a8; // \tcode{B} is not a type name: - // multiply \tcode{B} by \tcode{a8}; ill-formed, - // no visible declarations of \tcode{B} and \tcode{a8} + // multiplication of \tcode{B} by \tcode{a8}; ill-formed, no visible declarations of \tcode{B} and \tcode{a8} } }; \end{codeblock} \end{example} \pnum -When a \nonterminal{qualified-id} is intended to refer to a type +When a \grammarterm{qualified-id} is intended to refer to a type that is not a member of the current instantiation~(\ref{temp.dep.type}) -and its \nonterminal{nested-name-specifier} +and its \grammarterm{nested-name-specifier} refers to a dependent type, it shall be prefixed by the keyword \tcode{typename}, forming a -\nonterminal{typename-specifier}. +\grammarterm{typename-specifier}. If the \grammarterm{qualified-id} in a \grammarterm{typename-specifier} does not denote a type or a class template, @@ -3175,7 +3148,7 @@ is not required when referring to the name of a previously declared member of the class template that declares a type or a class template. -\begin{note} such names can be found using unqualified name lookup~(\ref{basic.lookup.unqual}), +\begin{note} Such names can be found using unqualified name lookup~(\ref{basic.lookup.unqual}), class member lookup~(\ref{class.qual}) into the current instantiation~(\ref{temp.dep.type}), or class member access expression lookup~(\ref{basic.lookup.classref}) when the type of the object expression is the current instantiation~(\ref{temp.dep.expr}). @@ -3192,7 +3165,7 @@ \pnum \indextext{checking!syntax}% -\indextext{checking!point~of error}% +\indextext{checking!point of error}% Knowing which names are type names allows the syntax of every template to be checked. The program is ill-formed, no diagnostic required, if: @@ -3237,7 +3210,7 @@ \item the value of a \tcode{const} object of integral or unscoped enumeration type or \item the value of a \tcode{constexpr} object or \item the value of a reference or - \item the definition of a \tcode{constexpr} function, + \item the definition of a constexpr function, \end{itemize} and that entity was not defined when the template was defined, or @@ -3254,7 +3227,7 @@ for which a valid specialization can be generated. \begin{note} If a template is instantiated, errors will be diagnosed according -to the other rules in this Standard. +to the other rules in this International Standard. Exactly when these errors are diagnosed is a quality of implementation issue. \end{note} \begin{example} @@ -3263,24 +3236,20 @@ int j; template class X { void f(T t, int i, char* p) { - t = i; // diagnosed if \tcode{X::f} is instantiated - // and the assignment to \tcode{t} is an error - p = i; // may be diagnosed even if \tcode{X::f} is - // not instantiated - p = j; // may be diagnosed even if \tcode{X::f} is - // not instantiated + t = i; // diagnosed if \tcode{X::f} is instantiated, and the assignment to \tcode{t} is an error + p = i; // may be diagnosed even if \tcode{X::f} is not instantiated + p = j; // may be diagnosed even if \tcode{X::f} is not instantiated } void g(T t) { - +; // may be diagnosed even if \tcode{X::g} is - // not instantiated + +; // may be diagnosed even if \tcode{X::g} is not instantiated } }; template struct A { - void operator++(int, T... t); // error: too many parameters + void operator++(int, T... t); // error: too many parameters }; -template union X : T... { }; // error: union with base class -template struct A : T..., T... { };// error: duplicate base class +template union X : T... { }; // error: union with base class +template struct A : T..., T... { }; // error: duplicate base class \end{codeblock} \end{example} @@ -3330,13 +3299,13 @@ \grammarterm{template-argument}{s} are known. For example, even though the name -\tcode{operator\shl} +\tcode{operator<<} is known within the definition of \tcode{printall()} and a declaration of it can be found in \tcode{}, the actual declaration of -\tcode{operator\shl} +\tcode{operator<<} needed to print \tcode{p[i]} cannot be known until it is known what type @@ -3361,8 +3330,7 @@ f(1); // \tcode{f(char)} f(T(1)); // dependent f(t); // dependent - dd++; // not dependent - // error: declaration for dd not found + dd++; // not dependent; error: declaration for \tcode{dd} not found } enum E { e }; @@ -3370,8 +3338,7 @@ double dd; void h() { - g(e); // will cause one call of \tcode{f(char)} followed - // by two calls of \tcode{f(E)} + g(e); // will cause one call of \tcode{f(char)} followed by two calls of \tcode{f(E)} g('a'); // will cause three calls of \tcode{f(char)} } \end{codeblock} @@ -3520,7 +3487,7 @@ \begin{codeblock} template struct A { - struct B @\texttt{\{ /* ... */ \};}@ + struct B { @\commentellip@ }; typedef void C; void f(); template void g(U); @@ -3573,7 +3540,7 @@ \begin{codeblock} struct A { - struct B { /* ... */ }; + struct B { @\commentellip@ }; int a; int Y; }; @@ -3588,11 +3555,11 @@ \rSec2[temp.dep]{Dependent names} \pnum -\indextext{name!dependent}% +\indextext{dependent name|see{name, dependent}}% Inside a template, some constructs have semantics which may differ from one instantiation to another. Such a construct -\term{depends} +\defnx{depends}{name!dependent} on the template parameters. In particular, types and expressions may depend on the type and/or @@ -3619,8 +3586,7 @@ the \grammarterm{unqualified-id} denotes a -\indextext{name!dependent}% -\term{dependent name} +\defnx{dependent name}{name!dependent} if \begin{itemize} @@ -3704,7 +3670,7 @@ \begin{codeblock} struct A { - struct B { /* ... */ }; + struct B { @\commentellip@ }; int a; int Y; }; @@ -3712,7 +3678,7 @@ int a; template struct Y : T { - struct B { /* ... */ }; + struct B { @\commentellip@ }; B b; // The \tcode{B} defined in \tcode{Y} void f(int i) { a = i; } // \tcode{::a} Y* p; // \tcode{Y} @@ -3736,7 +3702,7 @@ \pnum A name refers to the -\term{current instantiation} +\defn{current instantiation} if it is \begin{itemize} @@ -3822,11 +3788,11 @@ \end{example} \pnum -\indextext{base class!dependent}% -A \term{dependent base class} is a base class that is a dependent type and is +\indextext{dependent base class|see{base class, dependent}}% +A \defnx{dependent base class}{base class!dependent} is a base class that is a dependent type and is not the current instantiation. \begin{note} -a base class can be the current instantiation in the case of a nested class +A base class can be the current instantiation in the case of a nested class naming an enclosing class as a base. \begin{example} \begin{codeblock} @@ -3839,16 +3805,16 @@ }; template struct A::B::C : A { - M m; // OK, \tcode{A::M} + M m; // OK, \tcode{A::M} }; \end{codeblock} \end{example} \end{note} \pnum -\indextext{instantiation!member of the current}% +\indextext{member of the current instantiation|see{current instantiation, member of the}}% A name is a -\term{member of the current instantiation} +\defnx{member of the current instantiation}{current instantiation!member of the} if it is \begin{itemize} @@ -3868,7 +3834,7 @@ refers to the current instantiation and that, when looked up, refers to at least one member of a class that is the current -instantiation or a non-dependent base class thereof. \begin{note} if no such +instantiation or a non-dependent base class thereof. \begin{note} If no such member is found, and the current instantiation has any dependent base classes, then the \grammarterm{qualified-id} is a member of an unknown specialization; see below. \end{note} @@ -3879,7 +3845,7 @@ current instantiation, and the \grammarterm{id-expression}, when looked up~(\ref{basic.lookup.classref}), refers to at least one member of a class that is the current -instantiation or a non-dependent base class thereof. \begin{note} if no such +instantiation or a non-dependent base class thereof. \begin{note} If no such member is found, and the current instantiation has any dependent base classes, then the \grammarterm{id-expression} is a member of an unknown specialization; see below. \end{note} @@ -3889,26 +3855,26 @@ \begin{codeblock} template class A { static const int i = 5; - int n1[i]; // \tcode{i} refers to a member of the current instantiation - int n2[A::i]; // \tcode{A::i} refers to a member of the current instantiation - int n3[A::i]; // \tcode{A::i} refers to a member of the current instantiation + int n1[i]; // \tcode{i} refers to a member of the current instantiation + int n2[A::i]; // \tcode{A::i} refers to a member of the current instantiation + int n3[A::i]; // \tcode{A::i} refers to a member of the current instantiation int f(); }; template int A::f() { - return i; // \tcode{i} refers to a member of the current instantiation + return i; // \tcode{i} refers to a member of the current instantiation } \end{codeblock} \end{example} -\indextext{instantiation!dependent member of the current}% -A name is a \term{dependent member of the current instantiation} if it is a +\indextext{dependent member of the current instantiation|see{current instantiation, dependent member of the}}% +A name is a \defnx{dependent member of the current instantiation}{current instantiation!dependent member of the} if it is a member of the current instantiation that, when looked up, refers to at least one member of a class that is the current instantiation. \pnum A name is a -\term{member of an unknown specialization} +\defn{member of an unknown specialization} if it is \begin{itemize} @@ -3953,9 +3919,9 @@ template class A { typedef int type; void f() { - A::type i; // OK: refers to a member of the current instantiation - typename A::other j; // error: neither a member of the current instantiation nor - // a member of an unknown specialization + A::type i; // OK: refers to a member of the current instantiation + typename A::other j; // error: neither a member of the current instantiation nor + // a member of an unknown specialization } }; \end{codeblock} @@ -3981,13 +3947,13 @@ template struct C : A, T { - int f() { return this->m; } // finds \tcode{A::m} in the template definition context - int g() { return m; } // finds \tcode{A::m} in the template definition context + int f() { return this->m; } // finds \tcode{A::m} in the template definition context + int g() { return m; } // finds \tcode{A::m} in the template definition context }; -template int C::f(); // error: finds both \tcode{A::m} and \tcode{B::m} -template int C::g(); // OK: transformation to class member access syntax - // does not occur in the template definition context; see~\ref{class.mfct.non-static} +template int C::f(); // error: finds both \tcode{A::m} and \tcode{B::m} +template int C::g(); // OK: transformation to class member access syntax + // does not occur in the template definition context; see~\ref{class.mfct.non-static} \end{codeblock} \end{example} @@ -4308,14 +4274,12 @@ public: void f() { g(1); // calls \tcode{g(double)} - h++; // ill-formed: cannot increment function; - // this could be diagnosed either here or - // at the point of instantiation + h++; // ill-formed: cannot increment function; this could be diagnosed + // either here or at the point of instantiation } }; -void g(int); // not in scope at the point of the template - // definition, not considered for the call \tcode{g(1)} +void g(int); // not in scope at the point of the template definition, not considered for the call \tcode{g(1)} \end{codeblock} \end{example} @@ -4338,7 +4302,7 @@ \rSec3[temp.point]{Point of instantiation} \pnum -\indextext{instantiation!point~of}% +\indextext{instantiation!point of}% For a function template specialization, a member function template specialization, or a specialization for a member function or static data member of a class template, @@ -4470,9 +4434,8 @@ void g() { number a(3), b(4); - a = gcd(a,b); // finds \tcode{gcd} because \tcode{number} is an - // associated class, making \tcode{gcd} visible - // in its namespace (global scope) + a = gcd(a,b); // finds \tcode{gcd} because \tcode{number} is an associated class, + // making \tcode{gcd} visible in its namespace (global scope) b = gcd(3,4); // ill-formed; \tcode{gcd} is not visible } \end{codeblock} @@ -4484,7 +4447,7 @@ \indextext{specialization!template}% The act of instantiating a function, a class, a member of a class template or a member template is referred to as -\term{template instantiation}. +\defn{template instantiation}. \pnum A function instantiated from a function template is called an instantiated @@ -4596,8 +4559,7 @@ static T t; }; typedef int function(); -A a; // ill-formed: would declare \tcode{A::t} - // as a static member function +A a; // ill-formed: would declare \tcode{A::t} as a static member function \end{codeblock} \end{example} @@ -4622,17 +4584,16 @@ \end{note} \begin{example} \begin{codeblock} -template class B { /* ... */ }; -template class D : public B { /* ... */ }; +template class B { @\commentellip@ }; +template class D : public B { @\commentellip@ }; void f(void*); void f(B*); void g(D* p, D* pp, D* ppp) { - f(p); // instantiation of \tcode{D} required: call \tcode{f(B*)} - B* q = pp; // instantiation of \tcode{D} required: - // convert \tcode{D*} to \tcode{B*} - delete ppp; // instantiation of \tcode{D} required + f(p); // instantiation of \tcode{D} required: call \tcode{f(B*)} + B* q = pp; // instantiation of \tcode{D} required: convert \tcode{D*} to \tcode{B*} + delete ppp; // instantiation of \tcode{D} required } \end{codeblock} \end{example} @@ -4642,8 +4603,7 @@ \begin{example} \begin{codeblock} template class X; - -X ch; // error: incomplete type \tcode{X} +X ch; // error: incomplete type \tcode{X} \end{codeblock} \end{example} \begin{note} @@ -4840,7 +4800,7 @@ remain as determined from the context of the definition for the default argument. This analysis is called -\term{default argument instantiation}. +\defn{default argument instantiation}. The instantiated default argument is then used as the argument of \tcode{f}. @@ -4890,7 +4850,7 @@ X* p; // OK X a; // implicit generation of \tcode{X} requires // the implicit instantiation of \tcode{X} which requires - // the implicit instantiation of \tcode{X} which ... + // the implicit instantiation of \tcode{X} which \ldots }; \end{codeblock} \end{example} @@ -4967,7 +4927,7 @@ template class Array; template void Array::mf(); -template void sort(Array& v) { /* ... */ } +template void sort(Array& v) { @\commentellip@ } template void sort(Array&); // argument is deduced here namespace N { @@ -5017,16 +4977,14 @@ template class Y { void mf() { } }; } -template class Y; // error: class template \tcode{Y} not visible - // in the global namespace +template class Y; // error: class template \tcode{Y} not visible in the global namespace using N::Y; template class Y; // error: explicit instantiation outside of the // namespace of the template template class N::Y; // OK: explicit instantiation in namespace \tcode{N} -template void N::Y::mf(); // OK: explicit instantiation - // in namespace \tcode{N} +template void N::Y::mf(); // OK: explicit instantiation in namespace \tcode{N} \end{codeblock} \end{example} @@ -5039,8 +4997,8 @@ \begin{example} \begin{codeblock} -template class Array { /* ... */ }; -template void sort(Array& v) { /* ... */ } +template class Array { @\commentellip@ }; +template void sort(Array& v) { @\commentellip@ } // instantiate \tcode{sort(Array\&)} - template-argument deduced template void sort<>(Array&); @@ -5160,10 +5118,10 @@ \begin{codeblock} template class stream; -template<> class stream { /* ... */ }; +template<> class stream { @\commentellip@ }; -template class Array { /* ... */ }; -template void sort(Array& v) { /* ... */ } +template class Array { @\commentellip@ }; +template void sort(Array& v) { @\commentellip@ } template<> void sort(Array&); \end{codeblock} @@ -5208,11 +5166,11 @@ \begin{example} \begin{codeblock} -template<> class X { /* ... */ }; // error: \tcode{X} not a template +template<> class X { @\commentellip@ }; // error: \tcode{X} not a template template class X; -template<> class X { /* ... */ }; // OK: \tcode{X} is a template +template<> class X { @\commentellip@ }; // OK: \tcode{X} is a template \end{codeblock} \end{example} @@ -5265,34 +5223,32 @@ a.f(16); // \tcode{A::f} must be defined somewhere } -// \tcode{template<>} not used for a member of an -// explicitly specialized class template -void A::f(int) { /* ... */ } +// \tcode{template<>} not used for a member of an explicitly specialized class template +void A::f(int) { @\commentellip@ } template<> struct A::B { void f(); }; -// \tcode{template<>} also not used when defining a member of -// an explicitly specialized member class -void A::B::f() { /* ... */ } +// \tcode{template<>} also not used when defining a member of an explicitly specialized member class +void A::B::f() { @\commentellip@ } template<> template struct A::C { void f(); }; -// \tcode{template<>} is used when defining a member of an explicitly -// specialized member class template specialized as a class template +// \tcode{template<>} is used when defining a member of an explicitly specialized member class template +// specialized as a class template template<> -template void A::C::f() { /* ... */ } +template void A::C::f() { @\commentellip@ } template<> struct A::B { void f(); }; -template<> void A::B::f() { /* ... */ } // error: \tcode{template<>} not permitted +template<> void A::B::f() { @\commentellip@ } // error: \tcode{template<>} not permitted template<> template struct A::C { void f(); }; -template void A::C::f() { /* ... */ } // error: \tcode{template<>} required +template void A::C::f() { @\commentellip@ } // error: \tcode{template<>} required \end{codeblock} \end{example} @@ -5312,28 +5268,26 @@ \begin{codeblock} class String { }; -template class Array { /* ... */ }; -template void sort(Array& v) { /* ... */ } +template class Array { @\commentellip@ }; +template void sort(Array& v) { @\commentellip@ } void f(Array& v) { - sort(v); // use primary template - // \tcode{sort(Array\&)}, \tcode{T} is \tcode{String} + sort(v); // use primary template \tcode{sort(Array\&)}, \tcode{T} is \tcode{String} } -template<> void sort(Array& v); // error: specialization - // after use of primary template -template<> void sort<>(Array& v); // OK: \tcode{sort} not yet used +template<> void sort(Array& v); // error: specialization after use of primary template +template<> void sort<>(Array& v); // OK: \tcode{sort} not yet used template struct A { enum E : T; enum class S : T; }; -template<> enum A::E : int { eint }; // OK -template<> enum class A::S : int { sint }; // OK +template<> enum A::E : int { eint }; // OK +template<> enum class A::S : int { sint }; // OK template enum A::E : T { eT }; template enum class A::S : T { sT }; -template<> enum A::E : char { echar }; // ill-formed, \tcode{A::E} was instantiated - // when \tcode{A} was instantiated -template<> enum class A::S : char { schar }; // OK +template<> enum A::E : char { echar }; // ill-formed, \tcode{A::E} was instantiated + // when \tcode{A} was instantiated +template<> enum class A::S : char { schar }; // OK \end{codeblock} \end{example} @@ -5358,7 +5312,6 @@ well-formed according to the relative positioning of the explicit specialization declarations and their points of instantiation in the translation unit as specified above and below. -\indextext{immolation!self}% When writing a specialization, be careful about its location; or to make it compile will be such a trial as to kindle its self-immolation. @@ -5369,19 +5322,15 @@ \begin{codeblock} namespace N { - template class X { /* ... */ }; - template class Y { /* ... */ }; + template class X { @\commentellip@ }; + template class Y { @\commentellip@ }; - template<> class X { /* ... */ }; // OK: specialization - // in same namespace - template<> class Y; // forward declare intent to - // specialize for \tcode{double} + template<> class X { @\commentellip@ }; // OK: specialization in same namespace + template<> class Y; // forward-declare intent to specialize for \tcode{double} } -template<> class N::Y { /* ... */ }; // OK: specialization - // in enclosing namespace -template<> class N::Y { /* ... */ }; // OK: specialization - // in enclosing namespace +template<> class N::Y { @\commentellip@ }; // OK: specialization in enclosing namespace +template<> class N::Y { @\commentellip@ }; // OK: specialization in enclosing namespace \end{codeblock} \end{example} @@ -5394,11 +5343,11 @@ \begin{example} \begin{codeblock} -template class X; // \tcode{X} is a class template +template class X; // \tcode{X} is a class template template<> class X; -X* p; // OK: pointer to declared class \tcode{X} -X x; // error: object of incomplete class \tcode{X} +X* p; // OK: pointer to declared class \tcode{X} +X x; // error: object of incomplete class \tcode{X} \end{codeblock} \end{example} @@ -5412,7 +5361,7 @@ \begin{example} \begin{codeblock} -template class Array { /* ... */ }; +template class Array { @\commentellip@ }; template void sort(Array& v); // explicit specialization for \tcode{sort(Array\&)} @@ -5433,11 +5382,11 @@ \begin{example} \begin{codeblock} -template void f(T) { /* ... */ } -template inline T g(T) { /* ... */ } +template void f(T) { @\commentellip@ } +template inline T g(T) { @\commentellip@ } -template<> inline void f<>(int) { /* ... */ } // OK: inline -template<> int g<>(int) { /* ... */ } // OK: not inline +template<> inline void f<>(int) { @\commentellip@ } // OK: inline +template<> int g<>(int) { @\commentellip@ } // OK: not inline \end{codeblock} \end{example} @@ -6012,10 +5961,10 @@ as part of the substitution process. \end{note} Only invalid types and expressions in the immediate context of the function type and its template parameter types can result in a deduction -failure. \begin{note} The evaluation of the substituted types and expressions can result -in side effects such as the instantiation of class template specializations and/or +failure. \begin{note} The substitution into types and expressions can result +in effects such as the instantiation of class template specializations and/or function template specializations, the generation of implicitly-defined functions, -etc. Such side effects are not in the ``immediate context'' and can result in the +etc. Such effects are not in the ``immediate context'' and can result in the program being ill-formed.\end{note} \begin{example} @@ -6779,17 +6728,16 @@ \end{itemize} \pnum -\indextext{more~specialized!function~template}% -\indextext{at~least~as specialized~as|see{more~specialized}}% +\indextext{at least as specialized as|see{more specialized}}% Function template \tcode{F} -is \term{at least as specialized as} +is \defnx{at least as specialized as}{more specialized} function template \tcode{G} if, for each pair of types used to determine the ordering, the type from \tcode{F} is at least as specialized as the type from \tcode{G}. \tcode{F} -is \term{more specialized than} +is \defnx{more specialized than}{more specialized!function template} \tcode{G} if \tcode{F} is at least as specialized as @@ -7018,9 +6966,9 @@ inconsistent template argument deductions: \begin{codeblock} -template void f(T x, T y) { /* ... */ } -struct A { /* ... */ }; -struct B : A { /* ... */ }; +template void f(T x, T y) { @\commentellip@ } +struct A { @\commentellip@ }; +struct B : A { @\commentellip@ }; void g(A a, B b) { f(a,b); // error: \tcode{T} could be \tcode{A} or \tcode{B} f(b,a); // error: \tcode{T} could be \tcode{A} or \tcode{B} @@ -7096,22 +7044,22 @@ T& T&& T[@\grammarterm{integer-constant}@] -@\grammarterm{template-name}@ (where @\grammarterm{template-name}@ refers to a class template) -@\term{type}@(T) +@\grammarterm{template-name}@ @\textrm{(where \tcode{\grammarterm{template-name}} refers to a class template)}@ +@\placeholder{type}@(T) T() T(T) -T @\term{type}@::* -@\term{type}@ T::* +T @\placeholder{type}@::* +@\placeholder{type}@ T::* T T::* -T (@\term{type}@::*)() -@\term{type}@ (T::*)() -@\term{type}@ (@\term{type}@::*)(T) -@\term{type}@ (T::*)(T) -T (@\term{type}@::*)(T) +T (@\placeholder{type}@::*)() +@\placeholder{type}@ (T::*)() +@\placeholder{type}@ (@\placeholder{type}@::*)(T) +@\placeholder{type}@ (T::*)(T) +T (@\placeholder{type}@::*)(T) T (T::*)() T (T::*)(T) -@\term{type}@[i] -@\grammarterm{template-name}@ (where @\grammarterm{template-name}@ refers to a class template) +@\placeholder{type}@[i] +@\grammarterm{template-name}@ @\textrm{(where \tcode{\grammarterm{template-name}} refers to a class template)}@ TT TT TT<> @@ -7248,13 +7196,13 @@ is of the form \begin{codeblock} -@\grammarterm{template-name}@ (*)(@\term{type}@[i]) +@\grammarterm{template-name}@ (*)(@\placeholder{type}@[i]) \end{codeblock} which is a variant of \begin{codeblock} -@\term{type}@ (*)(T) +@\placeholder{type}@ (*)(T) \end{codeblock} where type is @@ -7333,15 +7281,17 @@ f3(v); // OK: \tcode{i} deduced to be \tcode{10} } \end{codeblock} +\end{note} \pnum +\begin{note} If, in the declaration of a function template with a non-type template parameter, the non-type template parameter is used in a subexpression in the function parameter list, the expression is a non-deduced context as specified above. \begin{example} \begin{codeblock} -template class A { /* ... */ }; +template class A { @\commentellip@ }; template void g(A); template void f(A, A); void k() { @@ -7354,6 +7304,8 @@ \end{codeblock} \end{example} \end{note} + +\pnum \begin{note} Template parameters do not participate in template argument deduction if they are used only in non-deduced contexts. @@ -7394,7 +7346,7 @@ \begin{example} \begin{codeblock} -template class A { /* ... */ }; +template class A { @\commentellip@ }; template void f(A); void k1() { A<1> a; @@ -7558,6 +7510,7 @@ be given preference over a template specialization if the two functions are otherwise equally good candidates for an overload match.} +\pnum \begin{example} \begin{codeblock} template T max(T a, T b) { return a>b?a:b; } @@ -7569,7 +7522,6 @@ } \end{codeblock} -\pnum Adding the non-template function \begin{codeblock} @@ -7585,15 +7537,17 @@ \tcode{int} for \tcode{c}. +\end{example} \pnum +\begin{example} Here is an example involving conversions on a function argument involved in \grammarterm{template-argument} deduction: \begin{codeblock} -template struct B { /* ... */ }; -template struct D : public B { /* ... */ }; +template struct B { @\commentellip@ }; +template struct D : public B { @\commentellip@ }; template void f(B&); void g(B& bi, D& di) { @@ -7601,8 +7555,10 @@ f(di); // \tcode{f((B\&)di)} } \end{codeblock} +\end{example} \pnum +\begin{example} Here is an example involving conversions on a function argument not involved in \grammarterm{template-parameter} deduction: @@ -7636,7 +7592,6 @@ } \end{codeblock} -\pnum The call of \tcode{f} is well-formed even if the template diff --git a/source/threads.tex b/source/threads.tex index 62d8e09411..60bf10ee26 100644 --- a/source/threads.tex +++ b/source/threads.tex @@ -135,11 +135,11 @@ A function that takes an argument which specifies a timeout will throw if, during its execution, a clock, time point, or time duration throws an exception. Such exceptions are referred to as \term{timeout-related exceptions}. -\begin{note} instantiations of clock, time point and duration types supplied by +\begin{note} Instantiations of clock, time point and duration types supplied by the implementation as specified in~\ref{time.clock} do not throw exceptions. \end{note} -\rSec2[thread.req.lockable]{Requirements for Lockable types} +\rSec2[thread.req.lockable]{Requirements for \tcode{Lockable} types} \rSec3[thread.req.lockable.general]{In general} @@ -288,7 +288,8 @@ \begin{note} These threads are intended to map one-to-one with operating system threads. \end{note} -\synopsis{Header \tcode{} synopsis} +\rSec2[thread.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{thread}}% \indexlibrary{\idxhdr{thread}}% \begin{codeblock} @@ -448,7 +449,7 @@ \begin{itemdescr} \pnum -\returns \tcode{!(y < x)} +\returns \tcode{!(y < x)}. \end{itemdescr} \indexlibrarymember{operator>}{thread::id}% @@ -457,7 +458,7 @@ \end{itemdecl} \begin{itemdescr} -\pnum\returns \tcode{y < x} +\pnum\returns \tcode{y < x}. \end{itemdescr} \indexlibrarymember{operator>=}{thread::id}% @@ -466,10 +467,10 @@ \end{itemdecl} \begin{itemdescr} -\pnum\returns \tcode{!(x < y)} +\pnum\returns \tcode{!(x < y)}. \end{itemdescr} -\indexlibrarymember{operator\shl}{thread::id}% +\indexlibrarymember{operator<<}{thread::id}% \begin{itemdecl} template basic_ostream& @@ -483,7 +484,7 @@ representation and if \tcode{x != y} the \tcode{thread::id} objects shall have distinct text representations. -\pnum\returns \tcode{out} +\pnum\returns \tcode{out}. \end{itemdescr} \indexlibrary{\idxcode{hash}!\idxcode{thread::id}}% @@ -505,7 +506,7 @@ \begin{itemdescr} \pnum\effects Constructs a \tcode{thread} object that does not represent a thread of execution. -\pnum\postconditions \tcode{get_id() == id()} +\pnum\postconditions \tcode{get_id() == id()}. \end{itemdescr} \indexlibrary{\idxcode{thread}!constructor}% @@ -604,7 +605,7 @@ \tcode{x.get_id()} prior to the assignment. \pnum -\returns \tcode{*this} +\returns \tcode{*this}. \end{itemdescr} \rSec3[thread.thread.member]{\tcode{thread} members} @@ -626,7 +627,7 @@ \begin{itemdescr} \pnum -\returns \tcode{get_id() != id()} +\returns \tcode{get_id() != id()}. \end{itemdescr} \indexlibrarymember{join}{thread}% @@ -655,7 +656,7 @@ \errors \begin{itemize} \item \tcode{resource_deadlock_would_occur} --- if deadlock is detected or -\tcode{get_id() == this_thread::get_id()}. +\tcode{get_id() == this_thread::\brk{}get_id()}. \item \tcode{no_such_process} --- if the thread is not valid. @@ -807,7 +808,8 @@ once. These mechanisms ease the production of race-free programs~(\ref{intro.multithread}). -\synopsis{Header \tcode{} synopsis} +\rSec2[mutex.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{mutex}}% \indexlibrary{\idxhdr{mutex}}% \begin{codeblock} @@ -841,7 +843,8 @@ } \end{codeblock} -\synopsis{Header \tcode{} synopsis} +\rSec2[shared_mutex.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{shared_mutex}}% \indexlibrary{\idxhdr{shared_mutex}}% \begin{codeblock} @@ -898,7 +901,7 @@ The implementation shall provide lock and unlock operations, as described below. For purposes of determining the existence of a data race, these behave as atomic operations~(\ref{intro.multithread}). The lock and unlock operations on -a single mutex shall appear to occur in a single total order. \begin{note} this +a single mutex shall appear to occur in a single total order. \begin{note} This can be viewed as the modification order~(\ref{intro.multithread}) of the mutex. \end{note} \begin{note} Construction and @@ -922,7 +925,7 @@ \postconditions The calling thread owns the mutex. \pnum -\returntype \tcode{void} +\returntype \tcode{void}. \pnum \sync Prior \tcode{unlock()} operations on the same object shall @@ -963,7 +966,7 @@ in the absence of contending mutex acquisitions. \pnum -\returntype \tcode{bool} +\returntype \tcode{bool}. \pnum \returns \tcode{true} if ownership of the mutex was obtained for the calling @@ -991,7 +994,7 @@ \effects Releases the calling thread's ownership of the mutex. \pnum -\returntype \tcode{void} +\returntype \tcode{void}. \pnum \sync This operation synchronizes with~(\ref{intro.multithread}) subsequent @@ -1018,7 +1021,7 @@ bool try_lock(); void unlock(); - using native_handle_type = @\impdef@; // See~\ref{thread.req.native} + using native_handle_type = @\impdefnc@; // See~\ref{thread.req.native} native_handle_type native_handle(); // See~\ref{thread.req.native} }; } @@ -1073,7 +1076,7 @@ bool try_lock() noexcept; void unlock(); - using native_handle_type = @\impdef@; // See~\ref{thread.req.native} + using native_handle_type = @\impdefnc@; // See~\ref{thread.req.native} native_handle_type native_handle(); // See~\ref{thread.req.native} }; } @@ -1147,7 +1150,7 @@ \end{note} \pnum -\returntype \tcode{bool} +\returntype \tcode{bool}. \pnum \returns \tcode{true} if ownership was obtained, otherwise \tcode{false}. @@ -1179,7 +1182,7 @@ be obtained if the lock is available, but implementations are expected to make a strong effort to do so. \end{note} -\pnum\returntype \tcode{bool} +\pnum\returntype \tcode{bool}. \pnum \returns \tcode{true} if ownership was obtained, otherwise \tcode{false}. @@ -1213,7 +1216,7 @@ bool try_lock_until(const chrono::time_point& abs_time); void unlock(); - using native_handle_type = @\impdef@; // See~\ref{thread.req.native} + using native_handle_type = @\impdefnc@; // See~\ref{thread.req.native} native_handle_type native_handle(); // See~\ref{thread.req.native} }; } @@ -1264,7 +1267,7 @@ bool try_lock_until(const chrono::time_point& abs_time); void unlock(); - using native_handle_type = @\impdef@; // See~\ref{thread.req.native} + using native_handle_type = @\impdefnc@; // See~\ref{thread.req.native} native_handle_type native_handle(); // See~\ref{thread.req.native} }; } @@ -1349,10 +1352,10 @@ \returntype \tcode{void}. \pnum -\sync Prior \tcode{unlock()} operations on the same object shall synchronize with ~(\ref{intro.multithread}) this operation. +\sync Prior \tcode{unlock()} operations on the same object shall synchronize with~(\ref{intro.multithread}) this operation. \pnum -\throws \tcode{system_error} when an exception is required ~(\ref{thread.req.exception}). +\throws \tcode{system_error} when an exception is required~(\ref{thread.req.exception}). \pnum \errors @@ -1405,7 +1408,7 @@ \pnum \sync If \tcode{try_lock_shared()} returns \tcode{true}, prior \tcode{unlock()} -operations on the same object synchronize with ~(\ref{intro.multithread}) this +operations on the same object synchronize with~(\ref{intro.multithread}) this operation. \pnum @@ -1419,24 +1422,24 @@ namespace std { class shared_mutex { public: - shared_mutex(); - ~shared_mutex(); + shared_mutex(); + ~shared_mutex(); - shared_mutex(const shared_mutex&) = delete; - shared_mutex& operator=(const shared_mutex&) = delete; + shared_mutex(const shared_mutex&) = delete; + shared_mutex& operator=(const shared_mutex&) = delete; - // Exclusive ownership - void lock(); // blocking - bool try_lock(); - void unlock(); + // Exclusive ownership + void lock(); // blocking + bool try_lock(); + void unlock(); - // Shared ownership - void lock_shared(); // blocking - bool try_lock_shared(); - void unlock_shared(); + // Shared ownership + void lock_shared(); // blocking + bool try_lock_shared(); + void unlock_shared(); - using native_handle_type = @\impdef@; // See~\ref{thread.req.native} - native_handle_type native_handle(); // See~\ref{thread.req.native} + using native_handle_type = @\impdefnc@; // See~\ref{thread.req.native} + native_handle_type native_handle(); // See~\ref{thread.req.native} }; } \end{codeblock} @@ -1963,7 +1966,7 @@ \effects As if by \tcode{pm->lock()}. \pnum -\postconditions \tcode{owns == true} +\postconditions \tcode{owns == true}. \pnum \throws @@ -2001,7 +2004,7 @@ \pnum \throws Any exception thrown by \tcode{pm->try_lock()}. \tcode{system_error} when an exception -is required~(\ref{thread.req.exception}). +is required (\ref{thread.req.exception}). \pnum \errors @@ -2086,7 +2089,7 @@ \begin{itemdescr} \pnum\effects As if by \tcode{pm->unlock()}. -\pnum\postconditions \tcode{owns == false} +\pnum\postconditions \tcode{owns == false}. \pnum\throws \tcode{system_error} when an exception is required~(\ref{thread.req.exception}). @@ -2137,7 +2140,7 @@ \end{itemdecl} \begin{itemdescr} -\pnum\returns \tcode{owns} +\pnum\returns \tcode{owns}. \end{itemdescr} \indexlibrarymember{operator bool}{unique_lock}% @@ -2146,7 +2149,7 @@ \end{itemdecl} \begin{itemdescr} -\pnum\returns \tcode{owns} +\pnum\returns \tcode{owns}. \end{itemdescr} \indexlibrarymember{mutex}{unique_lock}% @@ -2155,7 +2158,7 @@ \end{itemdecl} \begin{itemdescr} -\pnum\returns \tcode{pm} +\pnum\returns \tcode{pm}. \end{itemdescr} \rSec3[thread.lock.shared]{Class template \tcode{shared_lock}} @@ -2518,7 +2521,7 @@ \postconditions \tcode{owns == false}. \pnum -\throws \tcode{system_error} when an exception is required ~(\ref{thread.req.exception}). +\throws \tcode{system_error} when an exception is required~(\ref{thread.req.exception}). \pnum \errors @@ -2618,7 +2621,7 @@ \pnum \returns \tcode{-1} if all calls to \tcode{try_lock()} returned \tcode{true}, -otherwise a 0-based index value that indicates the argument for which \tcode{try_lock()} +otherwise a zero-based index value that indicates the argument for which \tcode{try_lock()} returned \tcode{false}. \end{itemdescr} @@ -2708,7 +2711,7 @@ \tcode{call_once}. Among all executions of \tcode{call_once} for any given \tcode{once_flag}: at most one shall be a returning execution; if there is a returning execution, it shall be the last active execution; and there are -passive executions only if there is a returning execution. \begin{note} passive +passive executions only if there is a returning execution. \begin{note} Passive executions allow other threads to reliably observe the results produced by the earlier returning execution. \end{note} @@ -2787,7 +2790,8 @@ \pnum Condition variable construction and destruction need not be synchronized. -\synopsis{Header \tcode{} synopsis} +\rSec2[condition_variable.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{condition_variable}}% \indexlibrary{\idxhdr{condition_variable}}% \indexlibrary{\idxcode{cv_status}}% @@ -2802,6 +2806,7 @@ } \end{codeblock} +\rSec2[thread.condition.nonmember]{Non-member functions} \indexlibrary{\idxcode{notify_all_at_thread_exit}}% \begin{itemdecl} void notify_all_at_thread_exit(condition_variable& cond, unique_lock lk); @@ -2833,18 +2838,22 @@ all objects with thread storage duration associated with the current thread. \pnum -\realnote The supplied lock will be held until the thread exits, and care +\begin{note} +The supplied lock will be held until the thread exits, and care must be taken to ensure that this does not cause deadlock due to lock ordering issues. After calling \tcode{notify_all_at_thread_exit} it is recommended that the thread should be exited as soon as possible, and that no blocking or time-consuming tasks are run on that thread. +\end{note} \pnum -\realnote It is the user's responsibility to ensure that waiting threads +\begin{note} +It is the user's responsibility to ensure that waiting threads do not erroneously assume that the thread has finished if they experience spurious wakeups. This typically requires that the condition being waited for is satisfied while holding the lock on \tcode{lk}, and that this lock is not released and reacquired prior to calling \tcode{notify_all_at_thread_exit}. +\end{note} \end{itemdescr} \rSec2[thread.condition.condvar]{Class \tcode{condition_variable}} @@ -2882,7 +2891,7 @@ const chrono::duration& rel_time, Predicate pred); - using native_handle_type = @\impdef@; // See~\ref{thread.req.native} + using native_handle_type = @\impdefnc@; // See~\ref{thread.req.native} native_handle_type native_handle(); // See~\ref{thread.req.native} }; } @@ -3342,9 +3351,11 @@ \begin{itemdescr} \pnum -\realnote if any of the \tcode{wait} functions exits via an exception, it is +\begin{note} +If any of the \tcode{wait} functions exits via an exception, it is unspecified whether the \tcode{Lock} is held. One can use a \tcode{Lock} type that allows to query that, such as the \tcode{unique_lock} wrapper. +\end{note} \pnum \effects @@ -3509,9 +3520,11 @@ \begin{note} These components are not restricted to multi-threaded programs but can be useful in single-threaded programs as well. \end{note} -\synopsis{Header \tcode{} synopsis} +\rSec2[future.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{future}}% \indexlibrary{\idxhdr{future}}% +\indexlibrary{\idxcode{future_errc}}% \begin{codeblock} namespace std { enum class future_errc { @@ -3780,7 +3793,7 @@ \pnum Access to the result of the same shared state may conflict~(\ref{intro.multithread}). -\begin{note} this explicitly specifies that the result of the shared state is +\begin{note} This explicitly specifies that the result of the shared state is visible in the objects that reference this state in the sense of data race avoidance~(\ref{res.on.data.races}). For example, concurrent accesses through references returned by \tcode{shared_future::get()}~(\ref{futures.shared_future}) @@ -4114,7 +4127,7 @@ class future { public: future() noexcept; - future(future &&) noexcept; + future(future&&) noexcept; future(const future& rhs) = delete; ~future(); future& operator=(const future& rhs) = delete; @@ -4241,8 +4254,10 @@ \begin{itemdescr} \pnum -\realnote as described above, the template and its two required specializations differ only in +\begin{note} +As described above, the template and its two required specializations differ only in the return type and return value of the member function \tcode{get}. +\end{note} \pnum \effects @@ -4547,13 +4562,17 @@ \begin{itemdescr} \pnum -\realnote as described above, the template and its two required specializations differ only in +\begin{note} +As described above, the template and its two required specializations differ only in the return type and return value of the member function \tcode{get}. +\end{note} \pnum -\realnote access to a value object stored in the shared state is +\begin{note} +Access to a value object stored in the shared state is unsynchronized, so programmers should apply only those operations on \tcode{R} that do not introduce a data race~(\ref{intro.multithread}). +\end{note} \pnum \effects \tcode{wait()}{s} until the shared state is ready, then retrieves the @@ -4690,10 +4709,12 @@ \pnum \requires \tcode{F} and each \tcode{Ti} in \tcode{Args} shall satisfy the -\tcode{MoveConstructible} requirements. -\tcode{\textit{INVOKE}(\textit{DECAY_COPY}(std::forward(f)), -\textit{DECAY_COPY}(std::forward(args))...)} -(\ref{func.require}, \ref{thread.thread.constr}) shall be a valid expression. +\tcode{MoveConstructible} requirements, and +\begin{codeblock} +@\placeholder{INVOKE}@(@\placeholder{DECAY_COPY}@(std::forward(f)), + @\itcorr[1]\placeholder{DECAY_COPY}@(std::forward(args))...) // see \ref{func.require}, \ref{thread.thread.constr} +\end{codeblock} +shall be a valid expression. \pnum \effects diff --git a/source/utilities.tex b/source/utilities.tex index def31c029e..4df5dabba5 100644 --- a/source/utilities.tex +++ b/source/utilities.tex @@ -16,9 +16,9 @@ \ref{optional} & Optional objects & \tcode{} \\ \rowsep \ref{variant} & Variants & \tcode{} \\ \rowsep \ref{any} & Storage for any type & \tcode{} \\ \rowsep -\ref{template.bitset} & Fixed-size sequences of bits & \tcode{} \\ \rowsep +\ref{bitset} & Fixed-size sequences of bits & \tcode{} \\ \rowsep \ref{memory} & Memory & \tcode{} \\ - & & \tcode{} \\ + & & \tcode{} \\ \rowsep \ref{smartptr} & Smart pointers & \tcode{} \\ \rowsep \ref{mem.res} & Memory resources & \tcode{} \\ \rowsep \ref{allocator.adaptor} & Scoped allocators & \tcode{} \\ \rowsep @@ -37,17 +37,13 @@ This subclause contains some basic function and class templates that are used throughout the rest of the library. +\indextext{\idxhdr{utility}}% \indexlibrary{\idxhdr{utility}}% \indexlibrary{\idxcode{rel_ops}}% -\synopsis{Header \tcode{} synopsis} - -\pnum -The header \tcode{} defines several types and function templates -that are described in this Clause. It also defines the template \tcode{pair} -and various function templates that operate on \tcode{pair} objects. +\rSec2[utility.syn]{Header \tcode{} synopsis} \begin{codeblock} -#include +#include // see \ref{initializer_list.syn} namespace std { // \ref{operators}, operators @@ -59,14 +55,17 @@ } // \ref{utility.swap}, swap - template void swap(T& a, T& b) noexcept(@\seebelow@); - template void swap(T (&a)[N], T (&b)[N]) noexcept(is_nothrow_swappable_v); + template + void swap(T& a, T& b) noexcept(@\seebelow@); + template + void swap(T (&a)[N], T (&b)[N]) noexcept(is_nothrow_swappable_v); // \ref{utility.exchange}, exchange - template T exchange(T& obj, U&& new_val); + template + T exchange(T& obj, U&& new_val); // \ref{forward}, forward/move - template + template constexpr T&& forward(remove_reference_t& t) noexcept; template constexpr T&& forward(remove_reference_t&& t) noexcept; @@ -74,24 +73,26 @@ constexpr remove_reference_t&& move(T&&) noexcept; template constexpr conditional_t< - !is_nothrow_move_constructible_v && is_copy_constructible_v, - const T&, T&&> move_if_noexcept(T& x) noexcept; + !is_nothrow_move_constructible_v && is_copy_constructible_v, const T&, T&&> + move_if_noexcept(T& x) noexcept; // \ref{utility.as_const}, as_const - template constexpr add_const_t& as_const(T& t) noexcept; - template void as_const(const T&&) = delete; + template + constexpr add_const_t& as_const(T& t) noexcept; + template + void as_const(const T&&) = delete; // \ref{declval}, declval template add_rvalue_reference_t declval() noexcept; // as unevaluated operand - -@ +@% \indexlibrary{\idxcode{index_sequence}}% \indexlibrary{\idxcode{make_index_sequence}}% \indexlibrary{\idxcode{index_sequence_for}}% @ // \ref{intseq}, Compile-time integer sequences - template struct integer_sequence; + template + struct integer_sequence; template using index_sequence = integer_sequence; @@ -103,8 +104,9 @@ template using index_sequence_for = make_index_sequence; - // \ref{pairs}, pairs - template struct pair; + // \ref{pairs}, class template \tcode{pair} + template + struct pair; // \ref{pairs.spec}, pair specialized algorithms template @@ -119,8 +121,10 @@ constexpr bool operator>=(const pair&, const pair&); template constexpr bool operator<=(const pair&, const pair&); + template void swap(pair& x, pair& y) noexcept(noexcept(x.swap(y))); + template constexpr @\seebelow@ make_pair(T1&&, T2&&); @@ -133,38 +137,36 @@ template struct tuple_element<1, pair>; template - constexpr tuple_element_t>& - get(pair&) noexcept; + constexpr tuple_element_t>& get(pair&) noexcept; template - constexpr tuple_element_t>&& - get(pair&&) noexcept; + constexpr tuple_element_t>&& get(pair&&) noexcept; template - constexpr const tuple_element_t>& - get(const pair&) noexcept; + constexpr const tuple_element_t>& get(const pair&) noexcept; template - constexpr const tuple_element_t>&& - get(const pair&&) noexcept; - template - constexpr T& get(pair& p) noexcept; - template - constexpr const T& get(const pair& p) noexcept; - template - constexpr T&& get(pair&& p) noexcept; - template - constexpr const T&& get(const pair&& p) noexcept; - template - constexpr T& get(pair& p) noexcept; - template - constexpr const T& get(const pair& p) noexcept; - template - constexpr T&& get(pair&& p) noexcept; - template - constexpr const T&& get(const pair&& p) noexcept; + constexpr const tuple_element_t>&& get(const pair&&) noexcept; + template + constexpr T1& get(pair& p) noexcept; + template + constexpr const T1& get(const pair& p) noexcept; + template + constexpr T1&& get(pair&& p) noexcept; + template + constexpr const T1&& get(const pair&& p) noexcept; + template + constexpr T2& get(pair& p) noexcept; + template + constexpr const T2& get(const pair& p) noexcept; + template + constexpr T2&& get(pair&& p) noexcept; + template + constexpr const T2&& get(const pair&& p) noexcept; // \ref{pair.piecewise}, pair piecewise construction - struct piecewise_construct_t { explicit piecewise_construct_t() = default; }; + struct piecewise_construct_t { + explicit piecewise_construct_t() = default; + }; constexpr piecewise_construct_t piecewise_construct{}; - template class tuple; // defined in \tcode{} + template class tuple; // defined in \tcode{} (\ref{tuple.syn}) // in-place construction struct in_place_t { @@ -175,14 +177,12 @@ struct in_place_type_t { explicit in_place_type_t() = default; }; - template - inline constexpr in_place_type_t in_place_type{}; + template inline constexpr in_place_type_t in_place_type{}; template struct in_place_index_t { explicit in_place_index_t() = default; }; - template - inline constexpr in_place_index_t in_place_index{}; + template inline constexpr in_place_index_t in_place_index{}; @ \indexlibrary{\idxcode{chars_format}}% \indexlibrarymember{scientific}{chars_format}% @@ -214,9 +214,12 @@ to_chars_result to_chars(char* first, char* last, double value); to_chars_result to_chars(char* first, char* last, long double value); - to_chars_result to_chars(char* first, char* last, float value, chars_format fmt); - to_chars_result to_chars(char* first, char* last, double value, chars_format fmt); - to_chars_result to_chars(char* first, char* last, long double value, chars_format fmt); + to_chars_result to_chars(char* first, char* last, float value, + chars_format fmt); + to_chars_result to_chars(char* first, char* last, double value, + chars_format fmt); + to_chars_result to_chars(char* first, char* last, long double value, + chars_format fmt); to_chars_result to_chars(char* first, char* last, float value, chars_format fmt, int precision); @@ -247,6 +250,11 @@ } \end{codeblock} +\pnum +The header \tcode{} defines several types and function templates +that are described in this Clause. It also defines the template \tcode{pair} +and various function templates that operate on \tcode{pair} objects. + \pnum The type \tcode{chars_format} is a bitmask type~(\ref{bitmask.types}) @@ -328,11 +336,12 @@ and requirements and semantics are not explicitly provided, the requirements and semantics are as specified in this Clause. -\rSec2[utility.swap]{swap} +\rSec2[utility.swap]{\tcode{swap}} \indexlibrary{\idxcode{swap}}% \begin{itemdecl} -template void swap(T& a, T& b) noexcept(@\seebelow@); +template + void swap(T& a, T& b) noexcept(@\seebelow@); \end{itemdecl} \begin{itemdescr} @@ -381,11 +390,11 @@ \effects As if by \tcode{swap_ranges(a, a + N, b)}. \end{itemdescr} -\rSec2[utility.exchange]{exchange} +\rSec2[utility.exchange]{\tcode{exchange}} \indexlibrary{\idxcode{exchange}}% \begin{itemdecl} -template T exchange(T& obj, U&& new_val); +template T exchange(T& obj, U&& new_val); \end{itemdecl} \begin{itemdescr} @@ -400,7 +409,7 @@ \end{itemdescr} -\rSec2[forward]{forward/move helpers} +\rSec2[forward]{Forward/move helpers} \pnum The library provides templated helper functions to simplify @@ -438,8 +447,6 @@ shared_ptr sp2 = factory(i, 1.414); // OK } \end{codeblock} - -\pnum In the first call to \tcode{factory}, \tcode{A1} is deduced as \tcode{int}, so 2 is forwarded to \tcode{A}'s constructor as an rvalue. @@ -448,7 +455,6 @@ to \tcode{A}'s constructor as an lvalue. In both cases, \tcode{A2} is deduced as \tcode{double}, so 1.414 is forwarded to \tcode{A}'s constructor as an rvalue. - \end{example} \end{itemdescr} @@ -472,18 +478,16 @@ struct A { A(); - A(const A&); // copies from lvalues - A(A&&); // moves from rvalues + A(const A&); // copies from lvalues + A(A&&); // moves from rvalues }; void g() { A a; - shared_ptr sp1 = factory(a); // ``\tcode{a}'' binds to \tcode{A(const A\&)} - shared_ptr sp1 = factory(std::move(a)); // ``\tcode{a}'' binds to \tcode{A(A\&\&)} + shared_ptr sp1 = factory(a); // ``\tcode{a}\!'' binds to \tcode{A(const A\&)} + shared_ptr sp1 = factory(std::move(a)); // ``\tcode{a}\!'' binds to \tcode{A(A\&\&)} } \end{codeblock} - -\pnum In the first call to \tcode{factory}, \tcode{A1} is deduced as \tcode{A\&}, so \tcode{a} is forwarded as a non-const lvalue. This binds to the constructor \tcode{A(const A\&)}, @@ -493,15 +497,14 @@ \tcode{A1} is deduced as \tcode{A}, so \tcode{a} is forwarded as an rvalue. This binds to the constructor \tcode{A(A\&\&)}, which moves the value from \tcode{a}. - \end{example} \end{itemdescr} \indexlibrary{\idxcode{move_if_noexcept}}% \begin{itemdecl} template constexpr conditional_t< - !is_nothrow_move_constructible_v && is_copy_constructible_v, - const T&, T&&> move_if_noexcept(T& x) noexcept; + !is_nothrow_move_constructible_v && is_copy_constructible_v, const T&, T&&> + move_if_noexcept(T& x) noexcept; \end{itemdecl} \begin{itemdescr} @@ -529,8 +532,7 @@ \indexlibrary{\idxcode{declval}}% \begin{itemdecl} -template - add_rvalue_reference_t declval() noexcept; // as unevaluated operand +template add_rvalue_reference_t declval() noexcept; // as unevaluated operand \end{itemdecl} \begin{itemdescr} @@ -544,8 +546,7 @@ \pnum \begin{example} \begin{codeblock} -template - decltype(static_cast(declval())) convert(From&&); +template decltype(static_cast(declval())) convert(From&&); \end{codeblock} declares a function template \tcode{convert} which only participates in overloading if the type \tcode{From} can be explicitly converted to type \tcode{To}. For another example see class @@ -732,7 +733,7 @@ \indexlibrary{\idxcode{from_chars}}% \begin{itemdecl} from_chars_result from_chars(const char* first, const char* last, - @\seebelow@& value, int base = 10); + @\seebelow@&@\itcorr[-1]@ value, int base = 10); \end{itemdecl} \begin{itemdescr} @@ -820,27 +821,9 @@ The library provides a class template that can represent an integer sequence. When used as an argument to a function template the parameter pack defining the sequence can be deduced and used in a pack expansion. - -\pnum -\begin{example} - -\begin{codeblock} -template - decltype(auto) apply_impl(F&& f, Tuple&& t, index_sequence) { - return std::forward(f)(std::get(std::forward(t))...); - } - -template - decltype(auto) apply(F&& f, Tuple&& t) { - using Indices = make_index_sequence>>; - return apply_impl(std::forward(f), std::forward(t), Indices()); - } -\end{codeblock} - -\end{example} \begin{note} The \tcode{index_sequence} alias template is provided for the common case of -an integer sequence of type \tcode{size_t}. +an integer sequence of type \tcode{size_t}; see also \ref{tuple.apply}. \end{note} \rSec2[intseq.intseq]{Class template \tcode{integer_sequence}} @@ -849,10 +832,10 @@ \begin{codeblock} namespace std { template - struct integer_sequence { - using value_type = T; - static constexpr size_t size() noexcept { return sizeof...(I); } - }; + struct integer_sequence { + using value_type = T; + static constexpr size_t size() noexcept { return sizeof...(I); } + }; } \end{codeblock} @@ -896,34 +879,32 @@ \indexlibrary{\idxcode{pair}}% \begin{codeblock} -// defined in header \tcode{} - namespace std { template - struct pair { - using first_type = T1; - using second_type = T2; - - T1 first; - T2 second; - pair(const pair&) = default; - pair(pair&&) = default; - @\EXPLICIT@ constexpr pair(); - @\EXPLICIT@ constexpr pair(const T1& x, const T2& y); - template @\EXPLICIT@ constexpr pair(U&& x, V&& y); - template @\EXPLICIT@ constexpr pair(const pair& p); - template @\EXPLICIT@ constexpr pair(pair&& p); - template - pair(piecewise_construct_t, - tuple first_args, tuple second_args); - - pair& operator=(const pair& p); - template pair& operator=(const pair& p); - pair& operator=(pair&& p) noexcept(@\seebelow@); - template pair& operator=(pair&& p); - - void swap(pair& p) noexcept(@\seebelow@); - }; + struct pair { + using first_type = T1; + using second_type = T2; + + T1 first; + T2 second; + + pair(const pair&) = default; + pair(pair&&) = default; + @\EXPLICIT@ constexpr pair(); + @\EXPLICIT@ constexpr pair(const T1& x, const T2& y); + template @\EXPLICIT@ constexpr pair(U1&& x, U2&& y); + template @\EXPLICIT@ constexpr pair(const pair& p); + template @\EXPLICIT@ constexpr pair(pair&& p); + template + pair(piecewise_construct_t, tuple first_args, tuple second_args); + + pair& operator=(const pair& p); + template pair& operator=(const pair& p); + pair& operator=(pair&& p) noexcept(@\seebelow@); + template pair& operator=(pair&& p); + + void swap(pair& p) noexcept(@\seebelow@); + }; } \end{codeblock} @@ -934,9 +915,9 @@ \pnum The defaulted move and copy constructor, respectively, of pair shall -be a \tcode{constexpr} function if and only if all required element-wise +be a constexpr function if and only if all required element-wise initializations for copy and move, respectively, would satisfy the -requirements for a \tcode{constexpr} function. +requirements for a constexpr function. \indexlibrary{\idxcode{pair}!constructor}% \begin{itemdecl} @@ -970,8 +951,7 @@ \begin{itemdescr} \pnum \effects -The constructor initializes \tcode{first} with \tcode{x} and \tcode{second} -with \tcode{y}. +Initializes \tcode{first} with \tcode{x} and \tcode{second} with \tcode{y}. \pnum \remarks This constructor shall not participate in overload resolution @@ -984,72 +964,71 @@ \indexlibrary{\idxcode{pair}!constructor}% \begin{itemdecl} -template @\EXPLICIT@ constexpr pair(U&& x, V&& y); +template @\EXPLICIT@ constexpr pair(U1&& x, U2&& y); \end{itemdecl} \begin{itemdescr} \pnum \effects -The constructor initializes \tcode{first} with -\tcode{std::forward(x)} and \tcode{second} -with \tcode{std::forward<\brk{}V>(y)}. +Initializes \tcode{first} with +\tcode{std::forward(x)} and \tcode{second} +with \tcode{std::forward(y)}. \pnum \remarks This constructor shall not participate in overload resolution unless -\tcode{is_constructible_v} is \tcode{true} and -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_constructible_v} is \tcode{true} and +\tcode{is_constructible_v} is \tcode{true}. The constructor is explicit if and only if -\tcode{is_convertible_v} is \tcode{false} or -\tcode{is_convertible_v} is \tcode{false}. +\tcode{is_convertible_v} is \tcode{false} or +\tcode{is_convertible_v} is \tcode{false}. \end{itemdescr} \indexlibrary{\idxcode{pair}!constructor}% \begin{itemdecl} -template @\EXPLICIT@ constexpr pair(const pair& p); +template @\EXPLICIT@ constexpr pair(const pair& p); \end{itemdecl} \begin{itemdescr} \pnum \effects -The constructor initializes members from the corresponding members of the argument. +Initializes members from the corresponding members of the argument. \pnum \remarks This constructor shall not participate in overload resolution unless -\tcode{is_constructible_v} is \tcode{true} and -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_constructible_v} is \tcode{true} and +\tcode{is_constructible_v} is \tcode{true}. The constructor is explicit if and only if -\tcode{is_convertible_v} is \tcode{false} or -\tcode{is_convertible_v} is \tcode{false}. +\tcode{is_convertible_v} is \tcode{false} or +\tcode{is_convertible_v} is \tcode{false}. \end{itemdescr} \indexlibrary{\idxcode{pair}!constructor}% \begin{itemdecl} -template @\EXPLICIT@ constexpr pair(pair&& p); +template @\EXPLICIT@ constexpr pair(pair&& p); \end{itemdecl} \begin{itemdescr} \pnum \effects -The constructor initializes \tcode{first} with -\tcode{std::forward(p.first)} +Initializes \tcode{first} with +\tcode{std::forward(p.first)} and \tcode{second} with -\tcode{std::\brk{}forward(p.second)}. +\tcode{std::forward(\brk{}p.second)}. \pnum \remarks This constructor shall not participate in overload resolution unless -\tcode{is_constructible_v} is \tcode{true} and -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_constructible_v} is \tcode{true} and +\tcode{is_constructible_v} is \tcode{true}. The constructor is explicit if and only if -\tcode{is_convertible_v} is \tcode{false} or -\tcode{is_convertible_v} is \tcode{false}. +\tcode{is_convertible_v} is \tcode{false} or +\tcode{is_convertible_v} is \tcode{false}. \end{itemdescr} \indexlibrary{\idxcode{pair}!constructor}% \begin{itemdecl} template - pair(piecewise_construct_t, - tuple first_args, tuple second_args); + pair(piecewise_construct_t, tuple first_args, tuple second_args); \end{itemdecl} \begin{itemdescr} @@ -1058,7 +1037,7 @@ and \tcode{is_constructible_v} is \tcode{true}. \pnum -\effects The constructor initializes \tcode{first} with arguments of types +\effects Initializes \tcode{first} with arguments of types \tcode{Args1...} obtained by forwarding the elements of \tcode{first_args} and initializes \tcode{second} with arguments of types \tcode{Args2...} obtained by forwarding the elements of \tcode{second_args}. (Here, forwarding @@ -1074,31 +1053,31 @@ \end{itemdecl} \begin{itemdescr} +\pnum +\effects Assigns \tcode{p.first} to \tcode{first} and \tcode{p.second} to \tcode{second}. + \pnum \remarks This operator shall be defined as deleted unless \tcode{is_copy_assignable_v} is \tcode{true} and \tcode{is_copy_assignable_v} is \tcode{true}. -\pnum -\effects Assigns \tcode{p.first} to \tcode{first} and \tcode{p.second} to \tcode{second}. - \pnum \returns \tcode{*this}. \end{itemdescr} \indexlibrarymember{operator=}{pair}% \begin{itemdecl} -template pair& operator=(const pair& p); +template pair& operator=(const pair& p); \end{itemdecl} \begin{itemdescr} \pnum -\remarks This operator shall not participate in overload resolution unless -\tcode{is_assignable_v} is \tcode{true} -and \tcode{is_assignable_v} is \tcode{true}. +\effects Assigns \tcode{p.first} to \tcode{first} and \tcode{p.second} to \tcode{second}. \pnum -\effects Assigns \tcode{p.first} to \tcode{first} and \tcode{p.second} to \tcode{second}. +\remarks This operator shall not participate in overload resolution unless +\tcode{is_assignable_v} is \tcode{true} +and \tcode{is_assignable_v} is \tcode{true}. \pnum \returns \tcode{*this}. @@ -1111,11 +1090,9 @@ \begin{itemdescr} \pnum -\remarks The expression inside \tcode{noexcept} is equivalent to: - -\begin{codeblock} -is_nothrow_move_assignable_v && is_nothrow_move_assignable_v -\end{codeblock} +\effects +Assigns to \tcode{first} with \tcode{std::forward(p.first)} +and to \tcode{second} with\\ \tcode{std::forward(p.second)}. \pnum \remarks This operator shall be defined as deleted unless @@ -1123,9 +1100,10 @@ and \tcode{is_move_assignable_v} is \tcode{true}. \pnum -\effects -Assigns to \tcode{first} with \tcode{std::forward(p.first)} -and to \tcode{second} with\\ \tcode{std::forward(p.second)}. +\remarks The expression inside \tcode{noexcept} is equivalent to: +\begin{codeblock} +is_nothrow_move_assignable_v && is_nothrow_move_assignable_v +\end{codeblock} \pnum \returns \tcode{*this}. @@ -1133,20 +1111,20 @@ \indexlibrarymember{operator=}{pair}% \begin{itemdecl} -template pair& operator=(pair&& p); +template pair& operator=(pair&& p); \end{itemdecl} \begin{itemdescr} -\pnum -\remarks This operator shall not participate in overload resolution unless -\tcode{is_assignable_v} is \tcode{true} -and \tcode{is_assignable_v} is \tcode{true}. - \pnum \effects Assigns to \tcode{first} with \tcode{std::forward(p.first)} and to \tcode{second} with\\ \tcode{std::forward(p.second)}. +\pnum +\remarks This operator shall not participate in overload resolution unless +\tcode{is_assignable_v} is \tcode{true} +and \tcode{is_assignable_v} is \tcode{true}. + \pnum \returns \tcode{*this}. \end{itemdescr} @@ -1157,14 +1135,6 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\remarks The expression inside \tcode{noexcept} is equivalent to: - -\begin{codeblock} -is_nothrow_swappable_v && -is_nothrow_swappable_v -\end{codeblock} - \pnum \requires \tcode{first} shall be swappable with~(\ref{swappable.requirements}) @@ -1174,6 +1144,12 @@ \effects Swaps \tcode{first} with \tcode{p.first} and \tcode{second} with \tcode{p.second}. + +\pnum +\remarks The expression inside \tcode{noexcept} is equivalent to: +\begin{codeblock} +is_nothrow_swappable_v && is_nothrow_swappable_v +\end{codeblock} \end{itemdescr} \rSec2[pairs.spec]{Specialized algorithms} @@ -1274,21 +1250,18 @@ \pnum \returns \tcode{pair(std::forward(x), std::forward(y))}, where \tcode{V1} and \tcode{V2} are determined as follows: Let \tcode{Ui} be -\tcode{decay_t} for each \tcode{Ti}. Then each \tcode{Vi} is \tcode{X\&} -if \tcode{Ui} equals \tcode{reference_wrapper}, otherwise \tcode{Vi} is -\tcode{Ui}. +\tcode{decay_t} for each \tcode{Ti}. If \tcode{Ui} is a specialization +of \tcode{reference_wrapper}, then \tcode{Vi} is \tcode{Ui::type\&}, +otherwise \tcode{Vi} is \tcode{Ui}. \end{itemdescr} \pnum \begin{example} In place of: - \begin{codeblock} return pair(5, 3.1415926); // explicit types \end{codeblock} - a \Cpp program may contain: - \begin{codeblock} return make_pair(5, 3.1415926); // types are deduced \end{codeblock} @@ -1299,8 +1272,7 @@ \indexlibrary{\idxcode{tuple_size}}% \begin{itemdecl} template -struct tuple_size> - : integral_constant { }; + struct tuple_size> : integral_constant { }; \end{itemdecl} \indexlibrary{\idxcode{tuple_element}}% @@ -1308,7 +1280,7 @@ tuple_element<0, pair>::type \end{itemdecl} \begin{itemdescr} -\pnum\textit{Value:} the type \tcode{T1}. +\pnum\textit{Value:} The type \tcode{T1}. \end{itemdescr} \indexlibrary{\idxcode{tuple_element}}% @@ -1316,23 +1288,19 @@ tuple_element<1, pair>::type \end{itemdecl} \begin{itemdescr} -\pnum\textit{Value:} the type T2. +\pnum\textit{Value:} The type T2. \end{itemdescr} \indexlibrarymember{get}{pair}% \begin{itemdecl} template - constexpr tuple_element_t>& - get(pair& p) noexcept; + constexpr tuple_element_t>& get(pair& p) noexcept; template - constexpr const tuple_element_t>& - get(const pair& p) noexcept; + constexpr const tuple_element_t>& get(const pair& p) noexcept; template - constexpr tuple_element_t>&& - get(pair&& p) noexcept; + constexpr tuple_element_t>&& get(pair&& p) noexcept; template - constexpr const tuple_element_t>&& - get(const pair&& p) noexcept; + constexpr const tuple_element_t>&& get(const pair&& p) noexcept; \end{itemdecl} \begin{itemdescr} @@ -1344,18 +1312,18 @@ \indexlibrarymember{get}{pair}% \begin{itemdecl} -template - constexpr T& get(pair& p) noexcept; -template - constexpr const T& get(const pair& p) noexcept; -template - constexpr T&& get(pair&& p) noexcept; -template - constexpr const T&& get(const pair&& p) noexcept; +template + constexpr T1& get(pair& p) noexcept; +template + constexpr const T1& get(const pair& p) noexcept; +template + constexpr T1&& get(pair&& p) noexcept; +template + constexpr const T1&& get(const pair&& p) noexcept; \end{itemdecl} \begin{itemdescr} \pnum -\requires \tcode{T} and \tcode{U} are distinct types. Otherwise, the program is ill-formed. +\requires \tcode{T1} and \tcode{T2} are distinct types. Otherwise, the program is ill-formed. \pnum \returns A reference to \tcode{p.first}. @@ -1363,19 +1331,19 @@ \indexlibrarymember{get}{pair}% \begin{itemdecl} -template - constexpr T& get(pair& p) noexcept; -template - constexpr const T& get(const pair& p) noexcept; -template - constexpr T&& get(pair&& p) noexcept; -template - constexpr const T&& get(const pair&& p) noexcept; +template + constexpr T2& get(pair& p) noexcept; +template + constexpr const T2& get(const pair& p) noexcept; +template + constexpr T2&& get(pair&& p) noexcept; +template + constexpr const T2&& get(const pair&& p) noexcept; \end{itemdecl} \begin{itemdescr} \pnum -\requires \tcode{T} and \tcode{U} are distinct types. Otherwise, the program is ill-formed. +\requires \tcode{T1} and \tcode{T2} are distinct types. Otherwise, the program is ill-formed. \pnum \returns A reference to \tcode{p.second}. @@ -1386,7 +1354,9 @@ \indexlibrary{\idxcode{piecewise_construct_t}}% \indexlibrary{\idxcode{piecewise_construct}}% \begin{itemdecl} -struct piecewise_construct_t { explicit piecewise_construct_t() = default; }; +struct piecewise_construct_t { + explicit piecewise_construct_t() = default; +}; constexpr piecewise_construct_t piecewise_construct{}; \end{itemdecl} @@ -1411,28 +1381,30 @@ two arguments is similar to an instantiation of \tcode{pair} with the same two arguments. See~\ref{pairs}. -\pnum -\synopsis{Header \tcode{} synopsis} +\rSec2[tuple.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{tuple}}% \indexlibrary{\idxhdr{tuple}}% \begin{codeblock} namespace std { // \ref{tuple.tuple}, class template \tcode{tuple} - template class tuple; + template + class tuple; // \ref{tuple.creation}, tuple creation functions constexpr @\unspec@ ignore; - template - constexpr tuple<@\placeholder{VTypes}@...> make_tuple(Types&&...); - template - constexpr tuple forward_as_tuple(Types&&...) noexcept; + template + constexpr tuple make_tuple(TTypes&&...); + + template + constexpr tuple forward_as_tuple(TTypes&&...) noexcept; - template - constexpr tuple tie(Types&...) noexcept; + template + constexpr tuple tie(TTypes&...) noexcept; template - constexpr tuple<@\placeholder{Ctypes}@...> tuple_cat(Tuples&&...); + constexpr tuple tuple_cat(Tuples&&...); // \ref{tuple.apply}, calling a function with a tuple of arguments template @@ -1442,36 +1414,33 @@ constexpr T make_from_tuple(Tuple&& t); // \ref{tuple.helper}, tuple helper classes - template class tuple_size; // not defined + template class tuple_size; // not defined template class tuple_size; template class tuple_size; template class tuple_size; template class tuple_size>; - template class tuple_element; // not defined + template class tuple_element; // not defined template class tuple_element; template class tuple_element; template class tuple_element; - template class tuple_element>; + template + class tuple_element>; template using tuple_element_t = typename tuple_element::type; // \ref{tuple.elem}, element access template - constexpr tuple_element_t>& - get(tuple&) noexcept; + constexpr tuple_element_t>& get(tuple&) noexcept; template - constexpr tuple_element_t>&& - get(tuple&&) noexcept; + constexpr tuple_element_t>&& get(tuple&&) noexcept; template - constexpr const tuple_element_t>& - get(const tuple&) noexcept; + constexpr const tuple_element_t>& get(const tuple&) noexcept; template - constexpr const tuple_element_t>&& - get(const tuple&&) noexcept; + constexpr const tuple_element_t>&& get(const tuple&&) noexcept; template constexpr T& get(tuple& t) noexcept; template @@ -1504,76 +1473,75 @@ void swap(tuple& x, tuple& y) noexcept(@\seebelow@); // \ref{tuple.helper}, tuple helper classes - template constexpr size_t tuple_size_v - = tuple_size::value; + template + constexpr size_t tuple_size_v = tuple_size::value; } \end{codeblock} \rSec2[tuple.tuple]{Class template \tcode{tuple}} - \indexlibrary{\idxcode{tuple}}% + \begin{codeblock} namespace std { template - class tuple { - public: - - // \ref{tuple.cnstr}, \tcode{tuple} construction - @\EXPLICIT@ constexpr tuple(); - @\EXPLICIT@ constexpr tuple(const Types&...); // only if \tcode{sizeof...(Types) >= 1} - template - @\EXPLICIT@ constexpr tuple(UTypes&&...); // only if \tcode{sizeof...(Types) >= 1} - - tuple(const tuple&) = default; - tuple(tuple&&) = default; - - template - @\EXPLICIT@ constexpr tuple(const tuple&); - template - @\EXPLICIT@ constexpr tuple(tuple&&); - - template - @\EXPLICIT@ constexpr tuple(const pair&); // only if \tcode{sizeof...(Types) == 2} - template - @\EXPLICIT@ constexpr tuple(pair&&); // only if \tcode{sizeof...(Types) == 2} - - // allocator-extended constructors - template - tuple(allocator_arg_t, const Alloc& a); - template - @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, const Types&...); - template - @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, UTypes&&...); - template - tuple(allocator_arg_t, const Alloc& a, const tuple&); - template - tuple(allocator_arg_t, const Alloc& a, tuple&&); - template - @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, const tuple&); - template - @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, tuple&&); - template - @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, const pair&); - template - @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, pair&&); - - // \ref{tuple.assign}, \tcode{tuple} assignment - tuple& operator=(const tuple&); - tuple& operator=(tuple&&) noexcept(@\seebelow@); - - template - tuple& operator=(const tuple&); - template - tuple& operator=(tuple&&); - - template - tuple& operator=(const pair&); // only if \tcode{sizeof...(Types) == 2} - template - tuple& operator=(pair&&); // only if \tcode{sizeof...(Types) == 2} - - // \ref{tuple.swap}, \tcode{tuple} swap - void swap(tuple&) noexcept(@\seebelow@); - }; + class tuple { + public: + // \ref{tuple.cnstr}, \tcode{tuple} construction + @\EXPLICIT@ constexpr tuple(); + @\EXPLICIT@ constexpr tuple(const Types&...); // only if \tcode{sizeof...(Types) >= 1} + template + @\EXPLICIT@ constexpr tuple(UTypes&&...); // only if \tcode{sizeof...(Types) >= 1} + + tuple(const tuple&) = default; + tuple(tuple&&) = default; + + template + @\EXPLICIT@ constexpr tuple(const tuple&); + template + @\EXPLICIT@ constexpr tuple(tuple&&); + + template + @\EXPLICIT@ constexpr tuple(const pair&); // only if \tcode{sizeof...(Types) == 2} + template + @\EXPLICIT@ constexpr tuple(pair&&); // only if \tcode{sizeof...(Types) == 2} + + // allocator-extended constructors + template + tuple(allocator_arg_t, const Alloc& a); + template + @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, const Types&...); + template + @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, UTypes&&...); + template + tuple(allocator_arg_t, const Alloc& a, const tuple&); + template + tuple(allocator_arg_t, const Alloc& a, tuple&&); + template + @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, const tuple&); + template + @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, tuple&&); + template + @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, const pair&); + template + @\EXPLICIT@ tuple(allocator_arg_t, const Alloc& a, pair&&); + + // \ref{tuple.assign}, \tcode{tuple} assignment + tuple& operator=(const tuple&); + tuple& operator=(tuple&&) noexcept(@\seebelow@); + + template + tuple& operator=(const tuple&); + template + tuple& operator=(tuple&&); + + template + tuple& operator=(const pair&); // only if \tcode{sizeof...(Types) == 2} + template + tuple& operator=(pair&&); // only if \tcode{sizeof...(Types) == 2} + + // \ref{tuple.swap}, \tcode{tuple} swap + void swap(tuple&) noexcept(@\seebelow@); + }; } \end{codeblock} @@ -1585,16 +1553,17 @@ \pnum The defaulted move and copy constructor, respectively, of -\tcode{tuple} shall be a \tcode{constexpr} function if and only if all +\tcode{tuple} shall be a constexpr function if and only if all required element-wise initializations for copy and move, respectively, -would satisfy the requirements for a \tcode{constexpr} function. The +would satisfy the requirements for a constexpr function. The defaulted move and copy constructor of \tcode{tuple<>} shall be -\tcode{constexpr} functions. +constexpr functions. \pnum In the constructor descriptions that follow, let $i$ be in the range -\range{0}{sizeof...(Types)} in order, $T_i$ be the $i^{th}$ type in \tcode{Types}, and -$U_i$ be the $i^{th}$ type in a template parameter pack named \tcode{UTypes}, where indexing +\range{0}{sizeof...(Types)} in order, $\tcode{T}_i$ +be the $i^\text{th}$ type in \tcode{Types}, and +$\tcode{U}_i$ be the $i^\text{th}$ type in a template parameter pack named \tcode{UTypes}, where indexing is zero-based. \indexlibrary{\idxcode{tuple}!constructor}% @@ -1609,13 +1578,13 @@ \pnum \remarks This constructor shall not participate in overload resolution unless -\tcode{is_default_construct\-ible_v<$T_i$>} is \tcode{true} for all $i$. +\tcode{is_default_construct\-ible_v<$\tcode{T}_i$>} is \tcode{true} for all $i$. \begin{note} This behavior can be implemented by a constructor template with default template arguments. \end{note} -The constructor is explicit if and only if $T_i$ is not implicitly +The constructor is explicit if and only if $\tcode{T}_i$ is not implicitly default-constructible for at least one $i$. \begin{note} This behavior can be implemented with a trait that checks whether -a \tcode{const $T_i$\&} can be initialized with \tcode{\{\}}. \end{note} +a \tcode{const $\tcode{T}_i$\&} can be initialized with \tcode{\{\}}. \end{note} \end{itemdescr} \indexlibrary{\idxcode{tuple}!constructor}% @@ -1625,34 +1594,33 @@ \begin{itemdescr} \pnum -\effects The constructor initializes each element with the value of the +\effects Initializes each element with the value of the corresponding parameter. \pnum \remarks This constructor shall not participate in overload resolution unless -\tcode{sizeof...(Types) >= 1} and \tcode{is_copy_constructible_v<$T_i$>} +\tcode{sizeof...(Types) >= 1} and \tcode{is_copy_constructible_v<$\tcode{T}_i$>} is \tcode{true} for all $i$. The constructor is explicit if and only if -\tcode{is_convertible_v} is \tcode{false} +\tcode{is_convertible_v} is \tcode{false} for at least one $i$. \end{itemdescr} \indexlibrary{\idxcode{tuple}!constructor}% \begin{itemdecl} -template - @\EXPLICIT@ constexpr tuple(UTypes&&... u); +template @\EXPLICIT@ constexpr tuple(UTypes&&... u); \end{itemdecl} \begin{itemdescr} \pnum -\effects The constructor initializes the elements in the tuple with the -corresponding value in \tcode{std::for\-ward(u)}. +\effects Initializes the elements in the tuple with the +corresponding value in \tcode{std::forward(u)}. \pnum \remarks This constructor shall not participate in overload resolution unless \tcode{sizeof...(Types)} \tcode{==} \tcode{sizeof...(UTypes)} and -\tcode{sizeof...(Types) >= 1} and \tcode{is_constructible_v<$T_i$, $U_i$\&\&>} +\tcode{sizeof...(Types) >= 1} and \tcode{is_constructible_v<$\tcode{T}_i$, $\tcode{U}_i$\&\&>} is \tcode{true} for all $i$. The constructor is explicit if and only if -\tcode{is_convertible_v<$U_i$\&\&, $T_i$>} is \tcode{false} +\tcode{is_convertible_v<$\tcode{U}_i$\&\&, $\tcode{T}_i$>} is \tcode{false} for at least one $i$. \end{itemdescr} @@ -1663,7 +1631,7 @@ \begin{itemdescr} \pnum -\requires \tcode{is_copy_constructible_v<$T_i$>} is \tcode{true} for all $i$. +\requires \tcode{is_copy_constructible_v<$\tcode{T}_i$>} is \tcode{true} for all $i$. \pnum \effects Initializes each element of \tcode{*this} with the @@ -1677,11 +1645,11 @@ \begin{itemdescr} \pnum -\requires \tcode{is_move_constructible_v<$T_i$>} is \tcode{true} for all $i$. +\requires \tcode{is_move_constructible_v<$\tcode{T}_i$>} is \tcode{true} for all $i$. \pnum -\effects For all $i$, initializes the $i^{th}$ element of \tcode{*this} with -\tcode{std::forward<$T_i$>(get<$i$>(u))}. +\effects For all $i$, initializes the $i^\text{th}$ element of \tcode{*this} with +\tcode{std::forward<$\tcode{T}_i$>(get<$i$>(u))}. \end{itemdescr} \indexlibrary{\idxcode{tuple}!constructor}% @@ -1691,7 +1659,7 @@ \begin{itemdescr} \pnum -\effects The constructor initializes each element of \tcode{*this} +\effects Initializes each element of \tcode{*this} with the corresponding element of \tcode{u}. \pnum @@ -1700,7 +1668,7 @@ \item \tcode{sizeof...(Types)} \tcode{==} \tcode{sizeof...(UTypes)} and \item -\tcode{is_constructible_v<$T_i$, const $U_i$\&>} is \tcode{true} for all $i$, and +\tcode{is_constructible_v<$\tcode{T}_i$, const $\tcode{U}_i$\&>} is \tcode{true} for all $i$, and \item \tcode{sizeof...(Types) != 1}, or (when \tcode{Types...} expands to \tcode{T} and \tcode{UTypes...} expands to \tcode{U})\linebreak @@ -1708,7 +1676,7 @@ is \tcode{true}. \end{itemize} The constructor is explicit if and only if -\tcode{is_convertible_v} is \tcode{false} +\tcode{is_convertible_v} is \tcode{false} for at least one $i$. \end{itemdescr} @@ -1719,9 +1687,9 @@ \begin{itemdescr} \pnum -\effects For all $i$, the constructor -initializes the $i^{th}$ element of \tcode{*this} with -\tcode{std::forward<$U_i$>(get<$i$>(u))}. +\effects For all $i$, +initializes the $i^\text{th}$ element of \tcode{*this} with +\tcode{std::forward<$\tcode{U}_i$>(get<$i$>(u))}. \pnum \remarks This constructor shall not participate in overload resolution unless @@ -1730,7 +1698,7 @@ \item \tcode{sizeof...(Types)} \tcode{==} \tcode{sizeof...(UTypes)}, and \item -\tcode{is_constructible_v<$T_i$, $U_i$\&\&>} is \tcode{true} for all $i$, and +\tcode{is_constructible_v<$\tcode{T}_i$, $\tcode{U}_i$\&\&>} is \tcode{true} for all $i$, and \item \tcode{sizeof...(Types) != 1}, or (when \tcode{Types...} expands to \tcode{T} and \tcode{UTypes...} expands to \tcode{U})\linebreak @@ -1738,7 +1706,7 @@ is \tcode{true}. \end{itemize} The constructor is explicit if and only if -\tcode{is_convertible_v<$U_i$\&\&, $T_i$>} is \tcode{false} +\tcode{is_convertible_v<$\tcode{U}_i$\&\&, $\tcode{T}_i$>} is \tcode{false} for at least one $i$. \end{itemdescr} @@ -1750,19 +1718,19 @@ \begin{itemdescr} \pnum -\effects The constructor initializes the first element with \tcode{u.first} and the +\effects Initializes the first element with \tcode{u.first} and the second element with \tcode{u.second}. \pnum \remarks This constructor shall not participate in overload resolution unless \tcode{sizeof...(Types) == 2}, -\tcode{is_constructible_v<$T_0$, const U1\&>} is \tcode{true} and -\tcode{is_constructible_v<$T_1$, const U2\&>} is \tcode{true}. +\tcode{is_constructible_v<$\tcode{T}_0$, const U1\&>} is \tcode{true} and +\tcode{is_constructible_v<$\tcode{T}_1$, const U2\&>} is \tcode{true}. \pnum The constructor is explicit if and only if -\tcode{is_convertible_v} is \tcode{false} or -\tcode{is_convertible_v} is \tcode{false}. +\tcode{is_convertible_v} is \tcode{false} or +\tcode{is_convert\-ible_v} is \tcode{false}. \end{itemdescr} \indexlibrary{\idxcode{tuple}!constructor}% @@ -1773,20 +1741,20 @@ \begin{itemdescr} \pnum -\effects The constructor initializes the first element with +\effects Initializes the first element with \tcode{std::forward(u.first)} and the second element with \tcode{std::forward(u.second)}. \pnum \remarks This constructor shall not participate in overload resolution unless \tcode{sizeof...(Types) == 2}, -\tcode{is_constructible_v<$T_0$, U1\&\&>} is \tcode{true} and -\tcode{is_constructible_v<$T_1$, U2\&\&>} is \tcode{true}. +\tcode{is_constructible_v<$\tcode{T}_0$, U1\&\&>} is \tcode{true} and +\tcode{is_constructible_v<$\tcode{T}_1$, U2\&\&>} is \tcode{true}. \pnum The constructor is explicit if and only if -\tcode{is_convertible_v} is \tcode{false} or -\tcode{is_convertible_v} is \tcode{false}. +\tcode{is_convertible_v} is \tcode{false} or +\tcode{is_convertible_v} is \tcode{false}. \end{itemdescr} \indexlibrary{\idxcode{tuple}!constructor}% @@ -1827,7 +1795,8 @@ For each \tcode{tuple} assignment operator, an exception is thrown only if the assignment of one of the types in \tcode{Types} throws an exception. In the function descriptions that follow, let $i$ be in the range \range{0}{sizeof...\brk{}(Types)} -in order, $T_i$ be the $i^{th}$ type in \tcode{Types}, and $U_i$ be the $i^{th}$ type in a +in order, $\tcode{T}_i$ be the $i^\text{th}$ type in \tcode{Types}, +and $\tcode{U}_i$ be the $i^\text{th}$ type in a template parameter pack named \tcode{UTypes}, where indexing is zero-based. \indexlibrarymember{operator=}{tuple}% @@ -1836,14 +1805,14 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\remarks This operator shall be defined as deleted unless -\tcode{is_copy_assignable_v<$T_i$>} is \tcode{true} for all $i$. - \pnum \effects Assigns each element of \tcode{u} to the corresponding element of \tcode{*this}. +\pnum +\remarks This operator shall be defined as deleted unless +\tcode{is_copy_assignable_v<$\tcode{T}_i$>} is \tcode{true} for all $i$. + \pnum \returns \tcode{*this}. \end{itemdescr} @@ -1855,22 +1824,21 @@ \begin{itemdescr} \pnum -\remarks The expression inside \tcode{noexcept} is equivalent to the logical \textsc{and} of the -following expressions: - -\begin{codeblock} -is_nothrow_move_assignable_v<@$T_i$@> -\end{codeblock} - -where $T_i$ is the $i^{th}$ type in \tcode{Types}. +\effects For all $i$, assigns \tcode{std::forward<$\tcode{T}_i$>(get<$i$>(u))} to +\tcode{get<$i$>(*this)}. \pnum \remarks This operator shall be defined as deleted unless -\tcode{is_move_assignable_v<$T_i$>} is \tcode{true} for all $i$. +\tcode{is_move_assignable_v<$\tcode{T}_i$>} is \tcode{true} for all $i$. \pnum -\effects For all $i$, assigns \tcode{std::forward<$T_i$>(get<$i$>(u))} to -\tcode{get<$i$>(*this)}. +\remarks The expression inside \tcode{noexcept} is equivalent to the logical \textsc{and} of the +following expressions: + +\begin{codeblock} +is_nothrow_move_assignable_v<@$\mathtt{T}_i$@> +\end{codeblock} +where $\mathtt{T}_i$ is the $i^\text{th}$ type in \tcode{Types}. \pnum \returns \tcode{*this}. @@ -1878,19 +1846,18 @@ \indexlibrarymember{operator=}{tuple}% \begin{itemdecl} -template - tuple& operator=(const tuple& u); +template tuple& operator=(const tuple& u); \end{itemdecl} \begin{itemdescr} \pnum -\remarks This operator shall not participate in overload resolution unless -\tcode{sizeof...(Types) == sizeof...(UTypes)} and -\tcode{is_assignable_v<$T_i$\&, const $U_i$\&>} is \tcode{true} for all $i$. +\effects Assigns each element of \tcode{u} to the corresponding element +of \tcode{*this}. \pnum -\effects Assigns each element of \tcode{u} to the corresponding element -of \tcode{*this}. +\remarks This operator shall not participate in overload resolution unless +\tcode{sizeof...(Types) == sizeof...(UTypes)} and +\tcode{is_assignable_v<$\tcode{T}_i$\&, const $\tcode{U}_i$\&>} is \tcode{true} for all $i$. \pnum \returns \tcode{*this}. @@ -1898,19 +1865,18 @@ \indexlibrarymember{operator=}{tuple}% \begin{itemdecl} -template - tuple& operator=(tuple&& u); +template tuple& operator=(tuple&& u); \end{itemdecl} \begin{itemdescr} \pnum -\remarks This operator shall not participate in overload resolution unless -\tcode{is_assignable_v == true} for all \tcode{i} and -\tcode{sizeof...(Types)} \tcode{==}\\\tcode{sizeof...(UTypes)}. +\effects For all $i$, assigns \tcode{std::forward<$\tcode{U}_i$>(get<$i$>(u))} to +\tcode{get<$i$>(*this)}. \pnum -\effects For all $i$, assigns \tcode{std::forward<$U_i$>(get<$i$>(u))} to -\tcode{get<$i$>(*this)}. +\remarks This operator shall not participate in overload resolution unless +\tcode{is_assignable_v<$\tcode{T}_i$\&, $\tcode{U}_i$\&\&> == true} for all $i$ and +\tcode{sizeof...(Types) == sizeof...(UTypes)}. \pnum \returns \tcode{*this}. @@ -1923,17 +1889,17 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\remarks This operator shall not participate in overload resolution unless -\tcode{sizeof...(Types) == 2} and -\tcode{is_assignable_v<$T_0$\&, const U1\&>} is \tcode{true} for the first type $T_0$ in -\tcode{Types} and \tcode{is_assignable_v<$T_1$\&, const U2\&>} is \tcode{true} for the -second type $T_1$ in \tcode{Types}. - \pnum \effects Assigns \tcode{u.first} to the first element of \tcode{*this} and \tcode{u.second} to the second element of \tcode{*this}. +\pnum +\remarks This operator shall not participate in overload resolution unless +\tcode{sizeof...(Types) == 2} and +\tcode{is_assignable_v<$\tcode{T}_0$\&, const U1\&>} is \tcode{true} for the first type $\tcode{T}_0$ in +\tcode{Types} and \tcode{is_assignable_v<$\tcode{T}_1$\&, const U2\&>} is \tcode{true} for the +second type $\tcode{T}_1$ in \tcode{Types}. + \pnum \returns \tcode{*this}. \end{itemdescr} @@ -1945,19 +1911,19 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\remarks -This operator shall not participate in overload resolution unless -\tcode{sizeof...(Types) == 2} and -\tcode{is_assignable_v<$T_0$\&, U1\&\&>} is \tcode{true} for the first type $T_0$ in -\tcode{Types} and \tcode{is_assignable_v<$T_1$\&, U2\&\&>} is \tcode{true} for the second -type $T_1$ in \tcode{Types}. - \pnum \effects Assigns \tcode{std::forward(u.first)} to the first element of \tcode{*this} and\\ \tcode{std::forward(u.second)} to the second element of \tcode{*this}. +\pnum +\remarks +This operator shall not participate in overload resolution unless +\tcode{sizeof...(Types) == 2} and +\tcode{is_assignable_v<$\tcode{T}_0$\&, U1\&\&>} is \tcode{true} for the first type $\tcode{T}_0$ in +\tcode{Types} and \tcode{is_assignable_v<$\tcode{T}_1$\&, U2\&\&>} is \tcode{true} for the second +type $\tcode{T}_1$ in \tcode{Types}. + \pnum \returns \tcode{*this}. \end{itemdescr} @@ -1970,16 +1936,6 @@ \end{itemdecl} \begin{itemdescr} -\pnum -\remarks The expression inside \tcode{noexcept} is equivalent to the logical -\textsc{and} of the following expressions: - -\begin{codeblock} -is_nothrow_swappable_v<@$T_i$@> -\end{codeblock} - -where $T_i$ is the $i^{th}$ type in \tcode{Types}. - \pnum \requires Each element in \tcode{*this} shall be swappable with~(\ref{swappable.requirements}) @@ -1989,6 +1945,15 @@ \effects Calls \tcode{swap} for each element in \tcode{*this} and its corresponding element in \tcode{rhs}. +\pnum +\remarks The expression inside \tcode{noexcept} is equivalent to the logical +\textsc{and} of the following expressions: + +\begin{codeblock} +is_nothrow_swappable_v<@$\mathtt{T}_i$@> +\end{codeblock} +where $\mathtt{T}_i$ is the $i^\text{th}$ type in \tcode{Types}. + \pnum \throws Nothing unless one of the element-wise \tcode{swap} calls throws an exception. \end{itemdescr} @@ -1996,49 +1961,42 @@ \rSec3[tuple.creation]{Tuple creation functions} \pnum -In the function descriptions that follow, let $i$ be in the range \range{0}{sizeof...(TTypes)} -in order and let $T_i$ be the $i^{th}$ type in a template parameter pack named \tcode{TTypes}; -let $j$ be in the range \range{0}{sizeof...(UTypes)} in order and $U_j$ be the $j^{th}$ type -in a template parameter pack named \tcode{UTypes}, where indexing is zero-based. +In the function descriptions that follow, the members of a parameter pack \tcode{\placeholder{X}Types} +are denoted by \tcode{\placeholder{X}}$_i$ for $i$ in \range{0}{sizeof...(\placeholder{X}Types)} in +order, where indexing is zero-based. \indexlibrary{\idxcode{make_tuple}}% \indexlibrary{\idxcode{tuple}!\idxcode{make_tuple}}% \begin{itemdecl} -template - constexpr tuple<@\placeholder{VTypes}@...> make_tuple(Types&&... t); +template + constexpr tuple make_tuple(TTypes&&... t); \end{itemdecl} -\begin{itemdescr} \pnum Let \tcode{$U_i$} be \tcode{decay_t<$T_i$>} for each -$T_i$ in \tcode{Types}. Then each $V_i$ in \tcode{VTypes} is -\tcode{X\&} if $U_i$ equals \tcode{reference_wrapper}, otherwise -$V_i$ is $U_i$. +\begin{itemdescr} +\pnum +The pack \tcode{VTypes} is defined as follows. Let \tcode{U}$_i$ be \tcode{decay_t} for each +\tcode{T}$_i$ in \tcode{TTypes}. If \tcode{U}$_i$ is a specialization of +\tcode{reference_wrapper}, then \tcode{V}$_i$ in \tcode{VTypes} is \tcode{U$_i$::type\&}, +otherwise \tcode{V}$_i$ is \tcode{U}$_i$. \pnum -\returns \tcode{tuple(std::forward(t)...)}. +\returns \tcode{tuple(std::forward(t)...)}. \pnum \begin{example} - \begin{codeblock} int i; float j; make_tuple(1, ref(i), cref(j)) \end{codeblock} - -creates a tuple of type - -\begin{codeblock} -tuple -\end{codeblock} - +creates a tuple of type \tcode{tuple}. \end{example} - \end{itemdescr} \indexlibrary{\idxcode{forward_as_tuple}}% \indexlibrary{\idxcode{tuple}!\idxcode{forward_as_tuple}}% \begin{itemdecl} -template - constexpr tuple forward_as_tuple(Types&&... t) noexcept; +template + constexpr tuple forward_as_tuple(TTypes&&... t) noexcept; \end{itemdecl} \begin{itemdescr} @@ -2046,24 +2004,24 @@ \effects Constructs a tuple of references to the arguments in \tcode{t} suitable for forwarding as arguments to a function. Because the result may contain references to temporary variables, a program shall ensure that the return value of this -function does not outlive any of its arguments. (e.g., the program should typically +function does not outlive any of its arguments (e.g., the program should typically not store the result in a named variable). \pnum -\returns \tcode{tuple(std::forward(t)...)}. +\returns \tcode{tuple(std::forward(t)...)}. \end{itemdescr} \indexlibrary{\idxcode{tie}}% \indexlibrary{\idxcode{ignore}}% \indexlibrary{\idxcode{tuple}!\idxcode{tie}}% \begin{itemdecl} -template - constexpr tuple tie(Types&... t) noexcept; +template + constexpr tuple tie(TTypes&... t) noexcept; \end{itemdecl} \begin{itemdescr} \pnum -\returns \tcode{tuple(t...)}. When an +\returns \tcode{tuple(t...)}. When an argument in \tcode{t} is \tcode{ignore}, assigning any value to the corresponding tuple element has no effect. @@ -2083,44 +2041,51 @@ \indexlibrary{\idxcode{tuple_cat}} \begin{itemdecl} template - constexpr tuple<@\placeholder{CTypes}@...> tuple_cat(Tuples&&... tpls); + constexpr tuple tuple_cat(Tuples&&... tpls); \end{itemdecl} \begin{itemdescr} \pnum -In the following paragraphs, let $T_i$ be the $i^{th}$ type in \tcode{Tuples}, -$U_i$ be \tcode{remove_reference_t}, and $tp_i$ be the $i^{th}$ +In the following paragraphs, let $\tcode{T}_i$ be the $i^\text{th}$ type in \tcode{Tuples}, +$\tcode{U}_i$ be \tcode{remove_reference_t}, and $\tcode{tp}_i$ be the $i^\text{th}$ parameter in the function parameter pack \tcode{tpls}, where all indexing is zero-based. \pnum -\requires For all $i$, $U_i$ shall be the type -$\cv_i$ \tcode{tuple<$Args_i...$>}, where $\cv_i$ is the (possibly empty) $i^{th}$ -cv-qualifier-seq and $Args_i$ is the parameter pack representing the element -types in $U_i$. Let ${A_{ik}}$ be the ${k_i}^{th}$ type in $Args_i$. For all -$A_{ik}$ the following requirements shall be satisfied: If $T_i$ is -deduced as an lvalue reference type, then -\tcode{is_constructible_v<$A_{ik}$, $cv_i$ $A_{ik}$\&> == true}, otherwise -\tcode{is_constructible_v<$A_{ik}$, $cv_i A_{ik}$\&\&> == true}. +\requires For all $i$, $\tcode{U}_i$ shall be the type +$\cv_i$ \tcode{tuple<$\tcode{Args}_i$...>}, where $\cv_i$ is the (possibly empty) $i^\text{th}$ +\grammarterm{cv-qualifier-seq} and $\tcode{Args}_i$ is the parameter pack representing the element +types in $\tcode{U}_i$. Let $\tcode{A}_{ik}$ be the ${k}^\text{th}$ type in $\tcode{Args}_i$. For all +$\tcode{A}_{ik}$ the following requirements shall be satisfied: +\begin{itemize} +\item If $\tcode{T}_i$ is deduced as an lvalue reference type, then + \tcode{is_constructible_v<$\tcode{A}_{ik}$, $cv_i\;\tcode{A}_{ik}$\&> == true}, otherwise +\item \tcode{is_constructible_v<$\tcode{A}_{ik}$, $cv_i\;\tcode{A}_{ik}$\&\&> == true}. +\end{itemize} \pnum -\remarks The types in \tcode{\placeholder{Ctypes}} shall be equal to the ordered +\remarks The types in \tcode{CTypes} shall be equal to the ordered sequence of the extended types -\tcode{$Args_0$..., $Args_1$...,} ... \tcode{$Args_{n-1}$...}, where $n$ is -equal to \tcode{sizeof...(Tuples)}. Let \tcode{$e_i$...} be the $i^{th}$ +\tcode{$\tcode{Args}_0$..., $\tcode{Args}_1$..., $\dotsc$, $\tcode{Args}_{n-1}$...}, +where $n$ is +equal to \tcode{sizeof...(Tuples)}. Let \tcode{$\tcode{e}_i$...} be the $i^\text{th}$ ordered sequence of tuple elements of the resulting \tcode{tuple} object -corresponding to the type sequence $Args_i$. +corresponding to the type sequence $\tcode{Args}_i$. \pnum -\returns A \tcode{tuple} object constructed by initializing the ${k_i}^{th}$ -type element $e_{ik}$ in \tcode{$e_i$...} with\\ -\tcode{get<$k_i$>(std::forward<$T_i$>($tp_i$))} for each valid $k_i$ and -each group $e_i$ in order. +\returns A \tcode{tuple} object constructed by initializing the ${k_i}^\text{th}$ +type element $\tcode{e}_{ik}$ in \tcode{$\tcode{e}_i$...} with +\begin{codeblock} +get<@$k_i$@>(std::forward<@$\tcode{T}_i$@>(@$\tcode{tp}_i$@)) +\end{codeblock} +for each valid $k_i$ and each group $\tcode{e}_i$ in order. \pnum -\realnote An implementation may support additional types in the parameter +\begin{note} +An implementation may support additional types in the parameter pack \tcode{Tuples} that support the \tcode{tuple}-like protocol, such as \tcode{pair} and \tcode{array}. +\end{note} \end{itemdescr} \rSec3[tuple.apply]{Calling a function with a \tcode{tuple} of arguments} @@ -2138,7 +2103,7 @@ \begin{codeblock} template constexpr decltype(auto) - apply_impl(F&& f, Tuple&& t, index_sequence) { // exposition only + apply_impl(F&& f, Tuple&& t, index_sequence) { // exposition only return @\textit{INVOKE}@(std::forward(f), std::get(std::forward(t))...); } \end{codeblock} @@ -2161,7 +2126,7 @@ Given the exposition-only function: \begin{codeblock} template -constexpr T make_from_tuple_impl(Tuple&& t, index_sequence) { // exposition only +constexpr T make_from_tuple_impl(Tuple&& t, index_sequence) { // exposition only return T(get(std::forward(t))...); } \end{codeblock} @@ -2177,33 +2142,32 @@ \rSec3[tuple.helper]{Tuple helper classes} -\indexlibrary{\idxcode{tuple_size}!in~general}% +\indexlibrary{\idxcode{tuple_size}!in general}% \begin{itemdecl} template struct tuple_size; \end{itemdecl} \begin{itemdescr} \pnum -\remarks All specializations of \tcode{tuple_size} shall meet the +\remarks All specializations of \tcode{tuple_size} shall meet the \tcode{UnaryTypeTrait} requirements~(\ref{meta.rqmts}) with a -\tcode{BaseCharacteristic} of \tcode{integral_constant} +base characteristic of \tcode{integral_constant} for some \tcode{N}. \end{itemdescr} \indexlibrary{\idxcode{tuple_size}}% \begin{itemdecl} template -class tuple_size> - : public integral_constant { }; + class tuple_size> : public integral_constant { }; \end{itemdecl} \indexlibrary{\idxcode{tuple_element}}% \begin{itemdecl} template -class tuple_element> { -public: - using type = TI; -}; + class tuple_element> { + public: + using type = TI; + }; \end{itemdecl} \begin{itemdescr} @@ -2230,7 +2194,7 @@ If the expression \tcode{\placeholder{TS}::value} is well-formed when treated as an unevaluated operand, then each of the three templates shall meet the \tcode{UnaryTypeTrait} requirements~(\ref{meta.rqmts}) -with a \tcode{BaseCharacteristic} of +with a base characteristic of \begin{codeblock} integral_constant \end{codeblock} @@ -2297,7 +2261,7 @@ constexpr const tuple_element_t>& get(const tuple& t) noexcept; // Note B template - constexpr const tuple_element_t>&& get(const tuple&& t) noexcept; + constexpr const tuple_element_t>&& get(const tuple&& t) noexcept; \end{itemdecl} \begin{itemdescr} @@ -2461,11 +2425,11 @@ \pnum\returns \tcode{!(t < u)}. \end{itemdescr} -\pnum \begin{note} The above definitions for comparison operators +\pnum \begin{note} The above definitions for comparison functions do not require \tcode{t$_{\mathrm{tail}}$} (or \tcode{u$_{\mathrm{tail}}$}) to be constructed. It may not even be possible, as \tcode{t} and \tcode{u} are not required to be copy -constructible. Also, all comparison operators are short circuited; +constructible. Also, all comparison functions are short circuited; they do not perform element accesses beyond what is required to determine the result of the comparison. \end{note} @@ -2498,8 +2462,8 @@ \begin{itemdescr} \pnum \remarks This function shall not participate in overload resolution -unless \tcode{is_swappable_v} is \tcode{true} -for all $i$, where $0 \leq i < \text{\tcode{sizeof...(Types)}}$. +unless \tcode{is_swappable_v<$\tcode{T}_i$>} is \tcode{true} +for all $i$, where $0 \leq i < \tcode{sizeof...(Types)}$. The expression inside \tcode{noexcept} is equivalent to: \begin{codeblock} @@ -2526,11 +2490,13 @@ \rSec2[optional.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{optional}}% \indexlibrary{\idxhdr{optional}}% \begin{codeblock} namespace std { - // \ref{optional.optional}, optional - template class optional; + // \ref{optional.optional}, class template \tcode{optional} + template + class optional; // \ref{optional.nullopt}, no-value state indicator struct nullopt_t{@\seebelow@}; @@ -2582,8 +2548,11 @@ template constexpr bool operator>=(const T&, const optional&); // \ref{optional.specalg}, specialized algorithms - template void swap(optional&, optional&) noexcept(@\seebelow@); - template constexpr optional<@\seebelow@> make_optional(T&&); + template + void swap(optional&, optional&) noexcept(@\seebelow@); + + template + constexpr optional<@\seebelow@> make_optional(T&&); template constexpr optional make_optional(Args&&... args); template @@ -2604,61 +2573,65 @@ \indexlibrary{\idxcode{optional}}% \begin{codeblock} -template class optional { -public: - using value_type = T; - - // \ref{optional.ctor}, constructors - constexpr optional() noexcept; - constexpr optional(nullopt_t) noexcept; - optional(const optional&); - optional(optional&&) noexcept(@\seebelow@); - template constexpr explicit optional(in_place_t, Args &&...); - template - constexpr explicit optional(in_place_t, initializer_list, Args &&...); - template @\EXPLICIT@ constexpr optional(U&&); - template @\EXPLICIT@ optional(const optional&); - template @\EXPLICIT@ optional(optional &&); - - // \ref{optional.dtor}, destructor - ~optional(); - - // \ref{optional.assign}, assignment - optional& operator=(nullopt_t) noexcept; - optional& operator=(const optional&); - optional& operator=(optional&&) noexcept(@\seebelow@); - template optional& operator=(U&&); - template optional& operator=(const optional&); - template optional& operator=(optional&&); - template void emplace(Args&&...); - template - void emplace(initializer_list, Args&&...); +template + class optional { + public: + using value_type = T; - // \ref{optional.swap}, swap - void swap(optional&) noexcept(@\seebelow@); - - // \ref{optional.observe}, observers - constexpr const T* operator->() const; - constexpr T* operator->(); - constexpr const T& operator*() const&; - constexpr T& operator*() &; - constexpr T&& operator*() &&; - constexpr const T&& operator*() const&&; - constexpr explicit operator bool() const noexcept; - constexpr bool has_value() const noexcept; - constexpr const T& value() const&; - constexpr T& value() &; - constexpr T&& value() &&; - constexpr const T&& value() const&&; - template constexpr T value_or(U&&) const&; - template constexpr T value_or(U&&) &&; - - // \ref{optional.mod}, modifiers - void reset() noexcept; + // \ref{optional.ctor}, constructors + constexpr optional() noexcept; + constexpr optional(nullopt_t) noexcept; + optional(const optional&); + optional(optional&&) noexcept(@\seebelow@); + template + constexpr explicit optional(in_place_t, Args&&...); + template + constexpr explicit optional(in_place_t, initializer_list, Args&&...); + template + @\EXPLICIT@ constexpr optional(U&&); + template + @\EXPLICIT@ optional(const optional&); + template + @\EXPLICIT@ optional(optional&&); + + // \ref{optional.dtor}, destructor + ~optional(); + + // \ref{optional.assign}, assignment + optional& operator=(nullopt_t) noexcept; + optional& operator=(const optional&); + optional& operator=(optional&&) noexcept(@\seebelow@); + template optional& operator=(U&&); + template optional& operator=(const optional&); + template optional& operator=(optional&&); + template void emplace(Args&&...); + template void emplace(initializer_list, Args&&...); + + // \ref{optional.swap}, swap + void swap(optional&) noexcept(@\seebelow@); + + // \ref{optional.observe}, observers + constexpr const T* operator->() const; + constexpr T* operator->(); + constexpr const T& operator*() const&; + constexpr T& operator*() &; + constexpr T&& operator*() &&; + constexpr const T&& operator*() const&&; + constexpr explicit operator bool() const noexcept; + constexpr bool has_value() const noexcept; + constexpr const T& value() const&; + constexpr T& value() &; + constexpr T&& value() &&; + constexpr const T&& value() const&&; + template constexpr T value_or(U&&) const&; + template constexpr T value_or(U&&) &&; + + // \ref{optional.mod}, modifiers + void reset() noexcept; -private: - T *val; // \expos -}; + private: + T *val; // \expos + }; \end{codeblock} \pnum @@ -2694,7 +2667,7 @@ \pnum \remarks No contained value is initialized. -For every object type \tcode{T} these constructors shall be \tcode{constexpr} constructors (\ref{dcl.constexpr}). +For every object type \tcode{T} these constructors shall be constexpr constructors (\ref{dcl.constexpr}). \end{itemdescr} \indexlibrary{\idxcode{optional}!constructor}% @@ -2716,6 +2689,7 @@ \throws Any exception thrown by the selected constructor of \tcode{T}. +\pnum \remarks This constructor shall be defined as deleted unless \tcode{is_copy_constructible_v} is \tcode{true}. @@ -2769,7 +2743,7 @@ \pnum \remarks -If \tcode{T}'s constructor selected for the initialization is a \tcode{constexpr} constructor, this constructor shall be a \tcode{constexpr} constructor. +If \tcode{T}'s constructor selected for the initialization is a constexpr constructor, this constructor shall be a \tcode{constexpr} constructor. This constructor shall not participate in overload resolution unless \tcode{is_constructible_v} is \tcode{true}. \end{itemdescr} @@ -2796,7 +2770,7 @@ \pnum \remarks This constructor shall not participate in overload resolution unless \tcode{is_constructible_v\&, Args\&\&...>} is \tcode{true}. -If \tcode{T}'s constructor selected for the initialization is a \tcode{constexpr} constructor, this constructor shall be a \tcode{constexpr} constructor. +If \tcode{T}'s constructor selected for the initialization is a constexpr constructor, this constructor shall be a \tcode{constexpr} constructor. \end{itemdescr} \pnum @@ -2808,8 +2782,7 @@ \indexlibrary{\idxcode{optional}!constructor}% \begin{itemdecl} -template - @\EXPLICIT@ constexpr optional(U&& v); +template @\EXPLICIT@ constexpr optional(U&& v); \end{itemdecl} \begin{itemdescr} @@ -2828,8 +2801,8 @@ \pnum \remarks -If \tcode{T}'s selected constructor is a \tcode{constexpr} constructor, -this constructor shall be a \tcode{constexpr} constructor. +If \tcode{T}'s selected constructor is a constexpr constructor, +this constructor shall be a constexpr constructor. This constructor shall not participate in overload resolution unless \tcode{is_constructible_v} is \tcode{true}, \tcode{is_same_v} is \tcode{false}, and @@ -2840,8 +2813,7 @@ \indexlibrary{\idxcode{optional}!constructor}% \begin{itemdecl} -template - @\EXPLICIT@ optional(const optional& rhs); +template @\EXPLICIT@ optional(const optional& rhs); \end{itemdecl} \begin{itemdescr} @@ -2879,8 +2851,7 @@ \indexlibrary{\idxcode{optional}!constructor}% \begin{itemdecl} -template - @\EXPLICIT@ optional(optional&& rhs); +template @\EXPLICIT@ optional(optional&& rhs); \end{itemdecl} \begin{itemdescr} @@ -3324,7 +3295,7 @@ \pnum \remarks -These functions shall be \tcode{constexpr} functions. +These functions shall be constexpr functions. \end{itemdescr} \indexlibrarymember{operator*}{optional}% @@ -3348,7 +3319,7 @@ \pnum \remarks -These functions shall be \tcode{constexpr} functions. +These functions shall be constexpr functions. \end{itemdescr} \indexlibrarymember{operator*}{optional}% @@ -3379,7 +3350,7 @@ \pnum \remarks -This function shall be a \tcode{constexpr} function. +This function shall be a constexpr function. \end{itemdescr} \indexlibrarymember{has_value}{optional}% @@ -3392,7 +3363,7 @@ \returns \tcode{true} if and only if \tcode{*this} contains a value. \pnum -\remarks This function shall be a \tcode{constexpr} function. +\remarks This function shall be a constexpr function. \end{itemdescr} \indexlibrarymember{value}{optional}% @@ -3551,7 +3522,7 @@ \remarks Specializations of this function template for which \tcode{*x == *y} is a core constant expression -shall be \tcode{constexpr} functions. +shall be constexpr functions. \end{itemdescr} \indexlibrarymember{operator"!=}{optional}% @@ -3599,7 +3570,7 @@ \remarks Specializations of this function template for which \tcode{*x < *y} is a core constant expression -shall be \tcode{constexpr} functions. +shall be constexpr functions. \end{itemdescr} \indexlibrarymember{operator>}{optional}% @@ -3798,7 +3769,7 @@ \begin{itemdescr} \pnum \effects -Equivalent to: \tcode{return bool(x) ? *x == v : false;} +Equivalent to: \tcode{return bool(x) ?\ *x == v :\ false;} \end{itemdescr} \indexlibrarymember{operator==}{optional}% @@ -3809,7 +3780,7 @@ \begin{itemdescr} \pnum \effects -Equivalent to: \tcode{return bool(x) ? v == *x : false;} +Equivalent to: \tcode{return bool(x) ?\ v == *x :\ false;} \end{itemdescr} \indexlibrarymember{operator"!=}{optional}% @@ -3820,7 +3791,7 @@ \begin{itemdescr} \pnum \effects -Equivalent to: \tcode{return bool(x) ? *x != v : true;} +Equivalent to: \tcode{return bool(x) ?\ *x != v :\ true;} \end{itemdescr} \indexlibrarymember{operator"!=}{optional}% @@ -3831,7 +3802,7 @@ \begin{itemdescr} \pnum \effects -Equivalent to: \tcode{return bool(x) ? v != *x : true;} +Equivalent to: \tcode{return bool(x) ?\ v != *x :\ true;} \end{itemdescr} \indexlibrarymember{operator<}{optional}% @@ -3842,7 +3813,7 @@ \begin{itemdescr} \pnum \effects -Equivalent to: \tcode{return bool(x) ? *x < v : true;} +Equivalent to: \tcode{return bool(x) ?\ *x < v :\ true;} \end{itemdescr} \indexlibrarymember{operator<}{optional}% @@ -3853,7 +3824,7 @@ \begin{itemdescr} \pnum \effects -Equivalent to: \tcode{return bool(x) ? v < *x : false;} +Equivalent to: \tcode{return bool(x) ?\ v < *x :\ false;} \end{itemdescr} \indexlibrarymember{operator<=}{optional}% @@ -3864,7 +3835,7 @@ \begin{itemdescr} \pnum \effects -Equivalent to: \tcode{return bool(x) ? *x <= v : true;} +Equivalent to: \tcode{return bool(x) ?\ *x <= v :\ true;} \end{itemdescr} \indexlibrarymember{operator<=}{optional}% @@ -3875,7 +3846,7 @@ \begin{itemdescr} \pnum \effects -Equivalent to: \tcode{return bool(x) ? v <= *x : false;} +Equivalent to: \tcode{return bool(x) ?\ v <= *x :\ false;} \end{itemdescr} \indexlibrarymember{operator>}{optional}% @@ -3886,7 +3857,7 @@ \begin{itemdescr} \pnum \effects -Equivalent to: \tcode{return bool(x) ? *x > v : false;} +Equivalent to: \tcode{return bool(x) ?\ *x > v :\ false;} \end{itemdescr} \indexlibrarymember{operator>}{optional}% @@ -3897,7 +3868,7 @@ \begin{itemdescr} \pnum \effects -Equivalent to: \tcode{return bool(x) ? v > *x : true;} +Equivalent to: \tcode{return bool(x) ?\ v > *x :\ true;} \end{itemdescr} \indexlibrarymember{operator>=}{optional}% @@ -3908,7 +3879,7 @@ \begin{itemdescr} \pnum \effects -Equivalent to: \tcode{return bool(x) ? *x >= v : false;} +Equivalent to: \tcode{return bool(x) ?\ *x >= v :\ false;} \end{itemdescr} \indexlibrarymember{operator>=}{optional}% @@ -3919,7 +3890,7 @@ \begin{itemdescr} \pnum \effects -Equivalent to: \tcode{return bool(x) ? v >= *x : true;} +Equivalent to: \tcode{return bool(x) ?\ v >= *x :\ true;} \end{itemdescr} @@ -4002,26 +3973,28 @@ of the template argument types given to variant. These template arguments are called alternatives. +\rSec2[variant.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{variant}}% \indexlibrary{\idxhdr{variant}}% -\synopsis{Header \tcode{} synopsis} \begin{codeblock} namespace std { - // \ref{variant.variant}, variant - template class variant; + // \ref{variant.variant}, class template \tcode{variant} + template + class variant; // \ref{variant.helper}, variant helper classes - template struct variant_size; // not defined + template struct variant_size; // not defined template struct variant_size; template struct variant_size; template struct variant_size; - template constexpr size_t variant_size_v - = variant_size::value; + template + constexpr size_t variant_size_v = variant_size::value; template struct variant_size>; - template struct variant_alternative; // not defined + template struct variant_alternative; // not defined template struct variant_alternative; template struct variant_alternative; template struct variant_alternative; @@ -4038,17 +4011,13 @@ constexpr bool holds_alternative(const variant&) noexcept; template - constexpr variant_alternative_t>& - get(variant&); + constexpr variant_alternative_t>& get(variant&); template - constexpr variant_alternative_t>&& - get(variant&&); + constexpr variant_alternative_t>&& get(variant&&); template - constexpr const variant_alternative_t>& - get(const variant&); + constexpr const variant_alternative_t>& get(const variant&); template - constexpr const variant_alternative_t>&& - get(const variant&&); + constexpr const variant_alternative_t>&& get(const variant&&); template constexpr T& get(variant&); @@ -4061,39 +4030,35 @@ template constexpr add_pointer_t>> - get_if(variant*) noexcept; + get_if(variant*) noexcept; template constexpr add_pointer_t>> - get_if(const variant*) noexcept; + get_if(const variant*) noexcept; template - constexpr add_pointer_t get_if(variant*) noexcept; + constexpr add_pointer_t + get_if(variant*) noexcept; template - constexpr add_pointer_t get_if(const variant*) noexcept; + constexpr add_pointer_t + get_if(const variant*) noexcept; // \ref{variant.relops}, relational operators template - constexpr bool operator==(const variant&, - const variant&); + constexpr bool operator==(const variant&, const variant&); template - constexpr bool operator!=(const variant&, - const variant&); + constexpr bool operator!=(const variant&, const variant&); template - constexpr bool operator<(const variant&, - const variant&); + constexpr bool operator<(const variant&, const variant&); template - constexpr bool operator>(const variant&, - const variant&); + constexpr bool operator>(const variant&, const variant&); template - constexpr bool operator<=(const variant&, - const variant&); + constexpr bool operator<=(const variant&, const variant&); template - constexpr bool operator>=(const variant&, - const variant&); + constexpr bool operator>=(const variant&, const variant&); // \ref{variant.visit}, visitation template - constexpr @\seebelow@ visit(Visitor&&, Variants&&...); + constexpr @\seebelow@ visit(Visitor&&, Variants&&...); // \ref{variant.monostate}, class \tcode{monostate} struct monostate; @@ -4108,7 +4073,7 @@ // \ref{variant.specalg}, specialized algorithms template - void swap(variant&, variant&) noexcept(@\seebelow@); + void swap(variant&, variant&) noexcept(@\seebelow@); // \ref{variant.bad.access}, class \tcode{bad_variant_access} class bad_variant_access; @@ -4120,8 +4085,7 @@ // \ref{variant.traits}, allocator-related traits template struct uses_allocator; - template - struct uses_allocator, Alloc>; + template struct uses_allocator, Alloc>; } \end{codeblock} @@ -4131,67 +4095,72 @@ \begin{codeblock} namespace std { template - class variant { - public: - // \ref{variant.ctor}, constructors - constexpr variant() noexcept(@\seebelow@); - variant(const variant&); - variant(variant&&) noexcept(@\seebelow@); - - template constexpr variant(T&&) noexcept(@\seebelow@); - - template - constexpr explicit variant(in_place_type_t, Args&&...); - template - constexpr explicit variant(in_place_type_t, initializer_list, Args&&...); - - template - constexpr explicit variant(in_place_index_t, Args&&...); - template - constexpr explicit variant(in_place_index_t, initializer_list, Args&&...); - - // allocator-extended constructors - template - variant(allocator_arg_t, const Alloc&); - template - variant(allocator_arg_t, const Alloc&, const variant&); - template - variant(allocator_arg_t, const Alloc&, variant&&); - template - variant(allocator_arg_t, const Alloc&, T&&); - template - variant(allocator_arg_t, const Alloc&, in_place_type_t, Args&&...); - template - variant(allocator_arg_t, const Alloc&, in_place_type_t, initializer_list, Args&&...); - template - variant(allocator_arg_t, const Alloc&, in_place_index_t, Args&&...); - template - variant(allocator_arg_t, const Alloc&, in_place_index_t, initializer_list, Args&&...); - - // \ref{variant.dtor}, destructor - ~variant(); - - // \ref{variant.assign}, assignment - variant& operator=(const variant&); - variant& operator=(variant&&) noexcept(@\seebelow@); - - template variant& operator=(T&&) noexcept(@\seebelow@); - - // \ref{variant.mod}, modifiers - template void emplace(Args&&...); - template - void emplace(initializer_list, Args&&...); - template void emplace(Args&&...); - template - void emplace(initializer_list, Args&&...); - - // \ref{variant.status}, value status - constexpr bool valueless_by_exception() const noexcept; - constexpr size_t index() const noexcept; - - // \ref{variant.swap}, swap - void swap(variant&) noexcept(@\seebelow@); - }; + class variant { + public: + // \ref{variant.ctor}, constructors + constexpr variant() noexcept(@\seebelow@); + variant(const variant&); + variant(variant&&) noexcept(@\seebelow@); + + template + constexpr variant(T&&) noexcept(@\seebelow@); + + template + constexpr explicit variant(in_place_type_t, Args&&...); + template + constexpr explicit variant(in_place_type_t, initializer_list, Args&&...); + + template + constexpr explicit variant(in_place_index_t, Args&&...); + template + constexpr explicit variant(in_place_index_t, initializer_list, Args&&...); + + // allocator-extended constructors + template + variant(allocator_arg_t, const Alloc&); + template + variant(allocator_arg_t, const Alloc&, const variant&); + template + variant(allocator_arg_t, const Alloc&, variant&&); + template + variant(allocator_arg_t, const Alloc&, T&&); + template + variant(allocator_arg_t, const Alloc&, in_place_type_t, Args&&...); + template + variant(allocator_arg_t, const Alloc&, in_place_type_t, + initializer_list, Args&&...); + template + variant(allocator_arg_t, const Alloc&, in_place_index_t, Args&&...); + template + variant(allocator_arg_t, const Alloc&, in_place_index_t, + initializer_list, Args&&...); + + // \ref{variant.dtor}, destructor + ~variant(); + + // \ref{variant.assign}, assignment + variant& operator=(const variant&); + variant& operator=(variant&&) noexcept(@\seebelow@); + + template variant& operator=(T&&) noexcept(@\seebelow@); + + // \ref{variant.mod}, modifiers + template + void emplace(Args&&...); + template + void emplace(initializer_list, Args&&...); + template + void emplace(Args&&...); + template + void emplace(initializer_list, Args&&...); + + // \ref{variant.status}, value status + constexpr bool valueless_by_exception() const noexcept; + constexpr size_t index() const noexcept; + + // \ref{variant.swap}, swap + void swap(variant&) noexcept(@\seebelow@); + }; } \end{codeblock} @@ -4221,7 +4190,7 @@ \pnum In the descriptions that follow, let $i$ be in the range \range{0}{sizeof...(Types)}, -and \tcode{T}$_i$ be the $i^{th}$ type in \tcode{Types...}. +and $\tcode{T}_i$ be the $i^\text{th}$ type in \tcode{Types...}. \indexlibrary{\idxcode{variant}!constructor}% \begin{itemdecl} @@ -4231,7 +4200,7 @@ \begin{itemdescr} \pnum \effects -Constructs a \tcode{variant} holding a value-initialized value of type \tcode{T}$_0$. +Constructs a \tcode{variant} holding a value-initialized value of type $\tcode{T}_0$. \pnum \postconditions @@ -4239,17 +4208,17 @@ \pnum \throws -Any exception thrown by the value-initialization of \tcode{T}$_0$. +Any exception thrown by the value-initialization of $\tcode{T}_0$. \pnum \remarks This function shall be \tcode{constexpr} if and only if the -value-initialization of the alternative type \tcode{T}$_0$ would satisfy the -requirements for a \tcode{constexpr} function. +value-initialization of the alternative type $\tcode{T}_0$ would satisfy the +requirements for a constexpr function. The expression inside \tcode{noexcept} is equivalent to -\tcode{is_nothrow_default_constructible_v<\tcode{T}$_0$>}. +\tcode{is_nothrow_default_constructible_v<$\tcode{T}_0$>}. This function shall not participate in overload resolution unless -\tcode{is_default_constructible_v<\tcode{T}$_0$>} is \tcode{true}. +\tcode{is_default_constructible_v<$\tcode{T}_0$>} is \tcode{true}. \begin{note} See also class \tcode{monostate}. \end{note} \end{itemdescr} @@ -4268,12 +4237,12 @@ \pnum \throws -Any exception thrown by direct-initializing any \tcode{T}$_i$ for all $i$. +Any exception thrown by direct-initializing any $\tcode{T}_i$ for all $i$. \pnum \remarks This function shall not participate in overload resolution unless -\tcode{is_copy_constructible_v<\tcode{T}$_i$>} is \tcode{true} for all $i$. +\tcode{is_copy_constructible_v<$\tcode{T}_i$>} is \tcode{true} for all $i$. \end{itemdescr} \indexlibrary{\idxcode{variant}!constructor}% @@ -4291,14 +4260,14 @@ \pnum \throws -Any exception thrown by move-constructing any \tcode{T}$_i$ for all $i$. +Any exception thrown by move-constructing any $\tcode{T}_i$ for all $i$. \pnum \remarks The expression inside \tcode{noexcept} is equivalent to the logical AND of -\tcode{is_nothrow_move_constructible_v<\tcode{T}$_i$>} for all $i$. +\tcode{is_nothrow_move_constructible_v<$\tcode{T}_i$>} for all $i$. This function shall not participate in overload resolution unless -\tcode{is_move_constructible_v<\tcode{T}$_i$>} is \tcode{true} for all $i$. +\tcode{is_move_constructible_v<$\tcode{T}_i$>} is \tcode{true} for all $i$. \end{itemdescr} \indexlibrary{\idxcode{variant}!constructor}% @@ -4308,25 +4277,25 @@ \begin{itemdescr} \pnum -Let \tcode{T}$_j$ be a type that is determined as follows: -build an imaginary function \tcode{\textit{FUN}(\tcode{T}$_i$)} for each alternative type \tcode{T}$_i$. The overload \tcode{\textit{FUN}(\tcode{T}$_j$)} selected by overload -resolution for the expression \tcode{\textit{FUN}(std::forward(\brk{}t))} defines -the alternative \tcode{T}$_j$ which is the type of the contained value after +Let $\tcode{T}_j$ be a type that is determined as follows: +build an imaginary function \tcode{\placeholdernc{FUN}($\tcode{T}_i$)} for each alternative type $\tcode{T}_i$. The overload \tcode{\placeholdernc{FUN}($\tcode{T}_j$)} selected by overload +resolution for the expression \tcode{\placeholdernc{FUN}(std::forward(\brk{}t))} defines +the alternative $\tcode{T}_j$ which is the type of the contained value after construction. \pnum \effects -Initializes \tcode{*this} to hold the alternative type \tcode{T}$_j$ and +Initializes \tcode{*this} to hold the alternative type $\tcode{T}_j$ and direct-initializes the contained value as if direct-non-list-initializing it with \tcode{std::forward(t)}. \pnum \postconditions -\tcode{holds_alternative(*this)} is \tcode{true}. +\tcode{holds_alternative<$\tcode{T}_j$>(*this)} is \tcode{true}. \pnum \throws -Any exception thrown by the initialization of the selected alternative \tcode{T}$_j$. +Any exception thrown by the initialization of the selected alternative $\tcode{T}_j$. \pnum \remarks @@ -4335,9 +4304,9 @@ unless \tcode{decay_t} is neither a specialization of \tcode{in_place_type_t} nor a specialization of \tcode{in_place_index_t}, -unless \tcode{is_constructible_v} is \tcode{true}, +unless \tcode{is_constructible_v<$\tcode{T}_j$, T>} is \tcode{true}, and unless the expression -\tcode{\textit{FUN}(}\brk\tcode{std::forward(t))} (with \tcode{\textit{FUN}} +\tcode{\placeholdernc{FUN}(}\brk\tcode{std::forward(t))} (with \tcode{\placeholdernc{FUN}} being the above-mentioned set of imaginary functions) is well formed. \pnum @@ -4350,8 +4319,8 @@ \pnum The expression inside \tcode{noexcept} is equivalent to -\tcode{is_nothrow_constructible_v}. -If \tcode{T}$_j$'s selected constructor is a constexpr constructor, +\tcode{is_nothrow_constructible_v<$\tcode{T}_j$, T>}. +If $\tcode{T}_j$'s selected constructor is a constexpr constructor, this constructor shall be a constexpr constructor. \end{itemdescr} @@ -4419,7 +4388,7 @@ \begin{itemdescr} \pnum \effects -Initializes the contained value as if constructing an object of type \tcode{T}$_I$ +Initializes the contained value as if constructing an object of type $\tcode{T}_I$ with the arguments \tcode{std::forward(args)...}. \pnum @@ -4428,13 +4397,13 @@ \pnum \throws -Any exception thrown by calling the selected constructor of \tcode{T}$_I$. +Any exception thrown by calling the selected constructor of $\tcode{T}_I$. \pnum \remarks This function shall not participate in overload resolution unless \tcode{I} is -less than \tcode{sizeof...(Types)} and \tcode{is_constructible_v} is \tcode{true}. -If \tcode{T}$_I$'s selected constructor is a \tcode{constexpr} constructor, this +less than \tcode{sizeof...(Types)} and \tcode{is_constructible_v<$\tcode{T}_I$, Args...>} is \tcode{true}. +If $\tcode{T}_I$'s selected constructor is a constexpr constructor, this constructor shall be a constexpr constructor. \end{itemdescr} @@ -4448,7 +4417,7 @@ \pnum \effects Initializes the contained value as if constructing an object of type -\tcode{T}$_I$ with the arguments \tcode{il, std::forward(args)...}. +$\tcode{T}_I$ with the arguments \tcode{il, std::forward(args)...}. \pnum \postconditions @@ -4458,8 +4427,8 @@ \remarks This function shall not participate in overload resolution unless \tcode{I} is less than \tcode{sizeof...(Types)} and -\tcode{is_constructible_v\&, Args...>} is \tcode{true}. -If \tcode{T}$_I$'s selected constructor is a \tcode{constexpr} constructor, this +\tcode{is_constructible_v<$\tcode{T}_I$, initializer_list\&, Args...>} is \tcode{true}. +If $\tcode{T}_I$'s selected constructor is a constexpr constructor, this constructor shall be a constexpr constructor. \end{itemdescr} @@ -4512,7 +4481,7 @@ \pnum \remarks -If \tcode{is_trivially_destructible_v == true} for all \tcode{T}$_i$ +If \tcode{is_trivially_destructible_v<$\tcode{T}_i$> == true} for all $\tcode{T}_i$ then this destructor shall be a trivial destructor. \end{itemdescr} @@ -4539,8 +4508,8 @@ copies the value contained in \tcode{rhs} to a temporary, then destroys any value contained in \tcode{*this}. Sets \tcode{*this} to hold the same alternative index as \tcode{rhs} and initializes the value contained in -\tcode{*this} as if direct-non-list-initializing an object of type \tcode{T}$_j$ -with \tcode{std::forward(TMP),} with \tcode{TMP} being the temporary and +\tcode{*this} as if direct-non-list-initializing an object of type $\tcode{T}_j$ +with \tcode{std::forward<$\tcode{T}_j$>(TMP)}, with \tcode{TMP} being the temporary and $j$ being \tcode{rhs.index()}. \end{itemize} @@ -4553,15 +4522,15 @@ \pnum \remarks This function shall not participate in overload resolution unless -\tcode{is_copy_constructible_v \&\& is_move_constructible_v \&\& is_copy_assignable_v} +\tcode{is_copy_constructible_v<$\tcode{T}_i$> \&\& is_move_constructible_v<$\tcode{T}_i$> \&\& is_copy_assignable_v<$\tcode{T}_i$>} is \tcode{true} for all $i$. \begin{itemize} -\item If an exception is thrown during the call to \tcode{T}$_j$'s copy assignment, +\item If an exception is thrown during the call to $\tcode{T}_j$'s copy assignment, the state of the contained value is as defined by the exception safety -guarantee of \tcode{T}$_j$'s copy assignment; \tcode{index()} will be $j$. -\item If an exception is thrown during the call to \tcode{T}$_j$'s copy construction +guarantee of $\tcode{T}_j$'s copy assignment; \tcode{index()} will be $j$. +\item If an exception is thrown during the call to $\tcode{T}_j$'s copy construction (with $j$ being \tcode{rhs.index()}), \tcode{*this} will remain unchanged. -\item If an exception is thrown during the call to \tcode{T}$_j$'s move construction, +\item If an exception is thrown during the call to $\tcode{T}_j$'s move construction, the \tcode{variant} will hold no value. \end{itemize} \end{itemdescr} @@ -4586,7 +4555,7 @@ \item destroys any value contained in \tcode{*this}. Sets \tcode{*this} to hold the same alternative index as \tcode{rhs} and initializes the value contained in -\tcode{*this} as if direct-non-list-initializing an object of type \tcode{T}$_j$ +\tcode{*this} as if direct-non-list-initializing an object of type $\tcode{T}_j$ with \tcode{get<$j$>(std::move(rhs))} with $j$ being \tcode{rhs.index()}. \end{itemize} @@ -4596,16 +4565,16 @@ \pnum \remarks This function shall not participate in overload resolution unless -\tcode{is_move_constructible_v \&\& is_move_assignable_v} is +\tcode{is_move_constructible_v<$\tcode{T}_i$> \&\& is_move_assignable_v<$\tcode{T}_i$>} is \tcode{true} for all $i$. The expression inside \tcode{noexcept} is equivalent to: -\tcode{is_nothrow_move_constructible_v \&\& is_nothrow_move_assignable_v} for all $i$. +\tcode{is_nothrow_move_constructible_v<$\tcode{T}_i$> \&\& is_nothrow_move_assignable_v<$\tcode{T}_i$>} for all $i$. \begin{itemize} -\item If an exception is thrown during the call to \tcode{T}$_j$'s move construction +\item If an exception is thrown during the call to $\tcode{T}_j$'s move construction (with $j$ being \tcode{rhs.index())}, the \tcode{variant} will hold no value. -\item If an exception is thrown during the call to \tcode{T}$_j$'s move assignment, +\item If an exception is thrown during the call to $\tcode{T}_j$'s move assignment, the state of the contained value is as defined by the exception safety -guarantee of \tcode{T}$_j$'s move assignment; \tcode{index()} will be $j$. +guarantee of $\tcode{T}_j$'s move assignment; \tcode{index()} will be $j$. \end{itemize} \end{itemdescr} @@ -4616,25 +4585,25 @@ \begin{itemdescr} \pnum -Let \tcode{T}$_j$ be a type that is determined as follows: -build an imaginary function \tcode{\textit{FUN}(T$_i$)} for each alternative type -\tcode{T}$_i$. The overload \tcode{\textit{FUN}(T$_j$)} selected by overload -resolution for the expression \tcode{\textit{FUN}(std::forward(\brk{}t))} defines -the alternative \tcode{T}$_j$ which is the type of the contained value after +Let $\tcode{T}_j$ be a type that is determined as follows: +build an imaginary function \tcode{\placeholdernc{FUN}($\tcode{T}_i$)} for each alternative type +$\tcode{T}_i$. The overload \tcode{\placeholdernc{FUN}($\tcode{T}_j$)} selected by overload +resolution for the expression \tcode{\placeholdernc{FUN}(std::forward(\brk{}t))} defines +the alternative $\tcode{T}_j$ which is the type of the contained value after assignment. \pnum \effects -If \tcode{*this} holds a \tcode{T}$_j$, assigns \tcode{std::forward(t)} to +If \tcode{*this} holds a $\tcode{T}_j$, assigns \tcode{std::forward(t)} to the value contained in \tcode{*this}. Otherwise, destroys any value contained -in \tcode{*this}, sets \tcode{*this} to hold the alternative type \tcode{T}$_j$ +in \tcode{*this}, sets \tcode{*this} to hold the alternative type $\tcode{T}_j$ as selected by the imaginary function overload resolution described above, and direct-initializes the contained value as if direct-non-list-initializing it with \tcode{std::forward(t)}. \pnum \postconditions -\tcode{holds_alternative(*this)} is \tcode{true}, with \tcode{T}$_j$ +\tcode{holds_alternative<$\tcode{T}_j$>(*this)} is \tcode{true}, with $\tcode{T}_j$ selected by the imaginary function overload resolution described above. \pnum @@ -4644,9 +4613,9 @@ \remarks This function shall not participate in overload resolution unless \tcode{is_same_v, variant>} is \tcode{false}, unless -\tcode{is_assignable_v \&\& is_constructible_v} is \tcode{true}, -and unless the expression \tcode{\textit{FUN}(std::forward(t))} (with -\tcode{\textit{FUN}} being the above-mentioned set of imaginary functions) +\tcode{is_assignable_v<$\tcode{T}_j$\&, T> \&\& is_constructible_v<$\tcode{T}_j$, T>} is \tcode{true}, +and unless the expression \tcode{\placeholdernc{FUN}(std::forward(t))} (with +\tcode{\placeholdernc{FUN}} being the above-mentioned set of imaginary functions) is well formed. \pnum @@ -4660,7 +4629,9 @@ \pnum The expression inside \tcode{noexcept} is equivalent to: -\tcode{is_nothrow_assignable_v \&\& is_nothrow_constructible_v}. +\begin{codeblock} +is_nothrow_assignable_v && is_nothrow_constructible_v +\end{codeblock} \begin{itemize} \item If an exception is thrown during the assignment of \tcode{std::forward(t)} to the value contained in \tcode{*this}, the state of the contained value and @@ -4723,7 +4694,7 @@ \effects Destroys the currently contained value if \tcode{valueless_by_exception()} is \tcode{false}. Then direct-initializes the contained value as if -constructing a value of type \tcode{T}$_I$ with the arguments +constructing a value of type $\tcode{T}_I$ with the arguments \tcode{std::forward(args)...}. \pnum @@ -4737,7 +4708,7 @@ \pnum \remarks This function shall not participate in overload resolution unless -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_constructible_v<$\tcode{T}_I$, Args...>} is \tcode{true}. If an exception is thrown during the initialization of the contained value, the \tcode{variant} might not hold a value. \end{itemdescr} @@ -4756,7 +4727,7 @@ \effects Destroys the currently contained value if \tcode{valueless_by_exception()} is \tcode{false}. Then direct-initializes the contained value as if -constructing a value of type \tcode{T}$_I$ with the arguments +constructing a value of type $\tcode{T}_I$ with the arguments \tcode{il, std::forward(args)...}. \pnum @@ -4770,7 +4741,7 @@ \pnum \remarks This function shall not participate in overload resolution unless -\tcode{is_constructible_v\&, Args...>} is \tcode{true}. +\tcode{is_constructible_v<$\tcode{T}_I$, initializer_list\&, Args...>} is \tcode{true}. If an exception is thrown during the initialization of the contained value, the \tcode{variant} might not hold a value. \end{itemdescr} @@ -4822,8 +4793,8 @@ \begin{itemdescr} \pnum -\requires Lvalues of type \tcode{T}$_i$ shall be swappable~(\ref{swappable.requirements}) and -\tcode{is_move_constructible_v} shall be \tcode{true} for all $i$. +\requires Lvalues of type $\tcode{T}_i$ shall be swappable~(\ref{swappable.requirements}) and +\tcode{is_move_constructible_v<$\tcode{T}_i$>} shall be \tcode{true} for all $i$. \pnum \effects @@ -4842,7 +4813,7 @@ any exception thrown by \tcode{swap(get<$i$>(*this), get<$i$>(rhs))} with $i$ being \tcode{index()}. Otherwise, any exception thrown by the move constructor -of \tcode{T}$_i$ or \tcode{T}$_j$ +of $\tcode{T}_i$ or $\tcode{T}_j$ with $i$ being \tcode{index()} and $j$ being \tcode{rhs.index()}. \pnum @@ -4850,12 +4821,12 @@ If an exception is thrown during the call to function \tcode{swap(get<$i$>(*this), get<$i$>(rhs))}, the states of the contained values of \tcode{*this} and of \tcode{rhs} are determined by the exception safety guarantee of \tcode{swap} for lvalues of -\tcode{T}$_i$ with $i$ being \tcode{index()}. +$\tcode{T}_i$ with $i$ being \tcode{index()}. If an exception is thrown during the exchange of the values of \tcode{*this} and \tcode{rhs}, the states of the values of \tcode{*this} and of \tcode{rhs} are determined by the exception safety guarantee of \tcode{variant}'s move constructor. The expression inside \tcode{noexcept} is equivalent to the logical AND of -\tcode{is_nothrow_move_constructible_v \&\& is_nothrow_swappable_v} for all $i$. +\tcode{is_nothrow_move_constructible_v<$\tcode{T}_i$> \&\& is_nothrow_swappable_v<$\tcode{T}_i$>} for all $i$. \end{itemdescr} \rSec2[variant.helper]{\tcode{variant} helper classes} @@ -4868,8 +4839,9 @@ \begin{itemdescr} \pnum \remarks -All specializations of \tcode{variant_size} shall meet the -\tcode{UnaryTypeTrait} requirements~(\ref{meta.rqmts}) with a \tcode{BaseCharacteristic} of \tcode{integral_constant} for some \tcode{N}. +All specializations of \tcode{variant_size} shall meet the +\tcode{UnaryTypeTrait} requirements~(\ref{meta.rqmts}) +with a base characteristic of \tcode{integral_constant} for some \tcode{N}. \end{itemdescr} \indexlibrary{\idxcode{variant_size}}% @@ -4884,14 +4856,13 @@ Let \tcode{VS} denote \tcode{variant_size} of the cv-unqualified type \tcode{T}. Then each of the three templates shall meet the \tcode{UnaryTypeTrait} requirements~(\ref{meta.rqmts}) with a -\tcode{BaseCharacteristic} of \tcode{integral_constant}. +base characteristic of \tcode{integral_constant}. \end{itemdescr} \indexlibrary{\idxcode{variant_size}}% \begin{itemdecl} template -struct variant_size> - : integral_constant { }; + struct variant_size> : integral_constant { }; \end{itemdecl} % No itemdescr needed for variant_size> @@ -4925,7 +4896,7 @@ \requires \tcode{I < sizeof...(Types)}. \pnum -\textit{Value:} The type \tcode{T}$_I$. +\textit{Value:} The type $\tcode{T}_I$. \end{itemdescr} \rSec2[variant.get]{Value access} @@ -4997,10 +4968,10 @@ \begin{itemdecl} template constexpr add_pointer_t>> - get_if(variant* v) noexcept; + get_if(variant* v) noexcept; template constexpr add_pointer_t>> - get_if(const variant* v) noexcept; + get_if(const variant* v) noexcept; \end{itemdecl} \begin{itemdescr} @@ -5019,9 +4990,11 @@ \indexlibrary{\idxcode{variant}!\idxcode{get_if}}% \begin{itemdecl} template - constexpr add_pointer_t get_if(variant* v) noexcept; + constexpr add_pointer_t + get_if(variant* v) noexcept; template - constexpr add_pointer_t get_if(const variant* v) noexcept; + constexpr add_pointer_t + get_if(const variant* v) noexcept; \end{itemdecl} \begin{itemdescr} @@ -5176,6 +5149,7 @@ type and value category, for all combinations of alternative types of all variants. Otherwise, the program is ill-formed. +\pnum \effects Let \tcode{is...} be \tcode{vars.index()...}. Returns \tcode{\textit{INVOKE}(forward(vis), get(}\brk{} \tcode{forward(vars))...);}. @@ -5189,6 +5163,7 @@ \throws \tcode{bad_variant_access} if any \tcode{variant} in \tcode{vars} is \tcode{valueless_by_exception()}. +\pnum \complexity For \tcode{sizeof...(Variants) <= 1}, the invocation of the callable object is implemented in constant time, i.e. it does not depend on \tcode{sizeof...(Types).} @@ -5204,6 +5179,7 @@ \end{itemdecl} \begin{itemdescr} +\pnum The class \tcode{monostate} can serve as a first alternative type for a \tcode{variant} to make the \tcode{variant} type default constructible. \end{itemdescr} @@ -5236,7 +5212,8 @@ \indexlibrary{\idxcode{swap}!\idxcode{variant}}% \begin{itemdecl} -template void swap(variant& v, variant& w) noexcept(@\seebelow@); +template + void swap(variant& v, variant& w) noexcept(@\seebelow@); \end{itemdecl} \begin{itemdescr} @@ -5245,7 +5222,7 @@ \pnum \remarks This function shall not participate in overload resolution -unless \tcode{is_move_constructible_v \&\& is_swappable_v} +unless \tcode{is_move_constructible_v<$\tcode{T}_i$> \&\& is_swappable_v<$\tcode{T}_i$>} is \tcode{true} for all $i$. The expression inside \tcode{noexcept} is equivalent to \tcode{noexcept(v.swap(w))}. \end{itemdescr} @@ -5257,7 +5234,7 @@ class bad_variant_access : public exception { public: bad_variant_access() noexcept; - virtual const char* what() const noexcept; + const char* what() const noexcept override; }; \end{codeblock} @@ -5333,7 +5310,7 @@ \rSec1[any]{Storage for any type} \pnum -This section describes components that C++ programs may use to perform operations on objects of a discriminated type. +This section describes components that \Cpp programs may use to perform operations on objects of a discriminated type. \pnum \begin{note} @@ -5342,9 +5319,11 @@ This indifference to interpretation but awareness of type effectively allows safe, generic containers of single values, with no scope for surprises from ambiguous conversions. \end{note} -\indexlibrary{\idxhdr{any}}% \rSec2[any.synop]{Header \tcode{} synopsis} +\indextext{\idxhdr{any}}% +\indexlibrary{\idxhdr{any}}% + \begin{codeblock} namespace std { // \ref{any.bad_any_cast}, class \tcode{bad_any_cast} @@ -5361,17 +5340,17 @@ template any make_any(initializer_list il, Args&& ...args); - template - ValueType any_cast(const any& operand); - template - ValueType any_cast(any& operand); - template - ValueType any_cast(any&& operand); - - template - const ValueType* any_cast(const any* operand) noexcept; - template - ValueType* any_cast(any* operand) noexcept; + template + T any_cast(const any& operand); + template + T any_cast(any& operand); + template + T any_cast(any&& operand); + + template + const T* any_cast(const any* operand) noexcept; + template + T* any_cast(any* operand) noexcept; } \end{codeblock} @@ -5399,12 +5378,12 @@ any(const any& other); any(any&& other) noexcept; - template any(ValueType&& value); + template any(T&& value); - template - explicit any(in_place_type_t, Args&&...); - template - explicit any(in_place_type_t, initializer_list, Args&&...); + template + explicit any(in_place_type_t, Args&&...); + template + explicit any(in_place_type_t, initializer_list, Args&&...); ~any(); @@ -5412,12 +5391,12 @@ any& operator=(const any& rhs); any& operator=(any&& rhs) noexcept; - template any& operator=(ValueType&& rhs); + template any& operator=(T&& rhs); // \ref{any.modifiers}, modifiers - template + template void emplace(Args&& ...); - template + template void emplace(initializer_list, Args&&...); void reset() noexcept; void swap(any& rhs) noexcept; @@ -5490,92 +5469,92 @@ \indexlibrary{\idxcode{any}!constructor}% \begin{itemdecl} -template -any(ValueType&& value); +template + any(T&& value); \end{itemdecl} \begin{itemdescr} \pnum -Let \tcode{T} be \tcode{decay_t}. +Let \tcode{VT} be \tcode{decay_t}. \pnum \requires -\tcode{T} shall satisfy the \tcode{CopyConstructible} requirements. +\tcode{VT} shall satisfy the \tcode{CopyConstructible} requirements. \pnum \effects -Constructs an object of type \tcode{any} that contains an object of type \tcode{T} direct-initialized with \tcode{std::forward(value)}. +Constructs an object of type \tcode{any} that contains an object of type \tcode{VT} direct-initialized with \tcode{std::forward(value)}. \pnum \remarks This constructor shall not participate in overload resolution unless -\tcode{T} is not the same type as \tcode{any}, -\tcode{T} is not a specialization of \tcode{in_place_type_t}, -and \tcode{is_copy_constructible_v} is \tcode{true}. +\tcode{VT} is not the same type as \tcode{any}, +\tcode{VT} is not a specialization of \tcode{in_place_type_t}, +and \tcode{is_copy_constructible_v} is \tcode{true}. \pnum \throws -Any exception thrown by the selected constructor of \tcode{T}. +Any exception thrown by the selected constructor of \tcode{VT}. \end{itemdescr} \indexlibrary{\idxcode{any}!constructor}% \begin{itemdecl} -template - explicit any(in_place_type_t, Args&&... args); +template + explicit any(in_place_type_t, Args&&... args); \end{itemdecl} \begin{itemdescr} \pnum -Let \tcode{T} be \tcode{decay_t}. +Let \tcode{VT} be \tcode{decay_t}. \pnum -\requires \tcode{T} shall satisfy the \tcode{CopyConstructible} requirements. +\requires \tcode{VT} shall satisfy the \tcode{CopyConstructible} requirements. \pnum \effects Initializes the contained value as if direct-non-list-initializing an object of -type \tcode{T} with the arguments \tcode{std::forward(args)...}. +type \tcode{VT} with the arguments \tcode{std::forward(args)...}. \pnum -\postconditions \tcode{*this} contains a value of type \tcode{T}. +\postconditions \tcode{*this} contains a value of type \tcode{VT}. \pnum -\throws Any exception thrown by the selected constructor of \tcode{T}. +\throws Any exception thrown by the selected constructor of \tcode{VT}. \pnum \remarks This constructor shall not participate in overload resolution unless -\tcode{is_copy_constructible_v} is \tcode{true} and -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_copy_constructible_v} is \tcode{true} and +\tcode{is_constructible_v} is \tcode{true}. \end{itemdescr} \indexlibrary{\idxcode{any}!constructor}% \begin{itemdecl} -template - explicit any(in_place_type_t, initializer_list il, Args&&... args); +template + explicit any(in_place_type_t, initializer_list il, Args&&... args); \end{itemdecl} \begin{itemdescr} \pnum -Let \tcode{T} be \tcode{decay_t}. +Let \tcode{VT} be \tcode{decay_t}. \pnum -\requires \tcode{T} shall satisfy the \tcode{CopyConstructible} requirements. +\requires \tcode{VT} shall satisfy the \tcode{CopyConstructible} requirements. \pnum \effects Initializes the contained value as if direct-non-list-initializing an object of -type \tcode{T} with the arguments \tcode{il, std::forward(args)...}. +type \tcode{VT} with the arguments \tcode{il, std::forward(args)...}. \pnum \postconditions \tcode{*this} contains a value. \pnum -\throws Any exception thrown by the selected constructor of \tcode{T}. +\throws Any exception thrown by the selected constructor of \tcode{VT}. \pnum \remarks This constructor shall not participate in overload resolution unless -\tcode{is_copy_constructible_v} is \tcode{true} and -\tcode{is_constructible_v\&, Args...>} is \tcode{true}. +\tcode{is_copy_constructible_v} is \tcode{true} and +\tcode{is_constructible_v\&, Args...>} is \tcode{true}. \end{itemdescr} \indexlibrary{\idxcode{any}!destructor} @@ -5633,21 +5612,21 @@ \indexlibrarymember{operator=}{any}% \begin{itemdecl} -template -any& operator=(ValueType&& rhs); +template + any& operator=(T&& rhs); \end{itemdecl} \begin{itemdescr} \pnum -Let \tcode{T} be \tcode{decay_t}. +Let \tcode{VT} be \tcode{decay_t}. \pnum \requires -\tcode{T} shall satisfy the \tcode{CopyConstructible} requirements. +\tcode{VT} shall satisfy the \tcode{CopyConstructible} requirements. \pnum \effects -Constructs an object \tcode{tmp} of type \tcode{any} that contains an object of type \tcode{T} direct-initialized with \tcode{std::forward(rhs)}, and \tcode{tmp.swap(*this)}. +Constructs an object \tcode{tmp} of type \tcode{any} that contains an object of type \tcode{VT} direct-initialized with \tcode{std::forward(rhs)}, and \tcode{tmp.swap(*this)}. No effects if an exception is thrown. \pnum @@ -5669,70 +5648,70 @@ \indexlibrarymember{emplace}{any}% \begin{itemdecl} -template +template void emplace(Args&&... args); \end{itemdecl} \begin{itemdescr} \pnum -Let \tcode{T} be \tcode{decay_t}. +Let \tcode{VT} be \tcode{decay_t}. \pnum \requires -\tcode{T} shall satisfy the \tcode{CopyConstructible} requirements. +\tcode{VT} shall satisfy the \tcode{CopyConstructible} requirements. \pnum \effects Calls \tcode{reset()}. Then initializes the contained value as if direct-non-list-initializing -an object of type \tcode{T} with the arguments \tcode{std::forward(args)...}. +an object of type \tcode{VT} with the arguments \tcode{std::forward(args)...}. \pnum \postconditions \tcode{*this} contains a value. \pnum -\throws Any exception thrown by the selected constructor of \tcode{T}. +\throws Any exception thrown by the selected constructor of \tcode{VT}. \pnum -\remarks If an exception is thrown during the call to \tcode{T}'s constructor, +\remarks If an exception is thrown during the call to \tcode{VT}'s constructor, \tcode{*this} does not contain a value, and any previously contained object has been destroyed. This function shall not participate in overload resolution unless -\tcode{is_copy_constructible_v} is \tcode{true} and -\tcode{is_constructible_v} is \tcode{true}. +\tcode{is_copy_constructible_v} is \tcode{true} and +\tcode{is_constructible_v} is \tcode{true}. \end{itemdescr} \indexlibrarymember{emplace}{any}% \begin{itemdecl} -template +template void emplace(initializer_list il, Args&&... args); \end{itemdecl} \begin{itemdescr} \pnum -Let \tcode{T} be \tcode{decay_t}. +Let \tcode{VT} be \tcode{decay_t}. \pnum \requires -\tcode{T} shall satisfy the \tcode{CopyConstructible} requirements. +\tcode{VT} shall satisfy the \tcode{CopyConstructible} requirements. \pnum \effects Calls \tcode{reset()}. Then initializes the contained value -as if direct-non-list-initializing an object of type \tcode{T} with the arguments -\tcode{il, std::forward (args)...}. +as if direct-non-list-initializing an object of type \tcode{VT} with the arguments +\tcode{il, std::forward(args)...}. \pnum \postconditions \tcode{*this} contains a value. \pnum -\throws Any exception thrown by the selected constructor of \tcode{T}. +\throws Any exception thrown by the selected constructor of \tcode{VT}. \pnum -\remarks If an exception is thrown during the call to \tcode{T}'s constructor, +\remarks If an exception is thrown during the call to \tcode{VT}'s constructor, \tcode{*this} does not contain a value, and any previously contained object has been destroyed. The function shall not participate in overload resolution unless -\tcode{is_copy_constructible_v} is \tcode{true} and -\tcode{is_constructible_v\&, Args...>} is \tcode{true}. +\tcode{is_copy_constructible_v} is \tcode{true} and +\tcode{is_constructible_v\&, Args...>} is \tcode{true}. \end{itemdescr} \indexlibrarymember{reset}{any}% @@ -5831,28 +5810,28 @@ \indexlibrary{\idxcode{any_cast}}% \begin{itemdecl} -template - ValueType any_cast(const any& operand); -template - ValueType any_cast(any& operand); -template - ValueType any_cast(any&& operand); +template + T any_cast(const any& operand); +template + T any_cast(any& operand); +template + T any_cast(any&& operand); \end{itemdecl} \begin{itemdescr} \pnum \requires -\tcode{is_reference_v} is \tcode{true} or \tcode{is_copy_constructible_v} is \tcode{true}. +\tcode{is_reference_v} is \tcode{true} or \tcode{is_copy_constructible_v} is \tcode{true}. Otherwise the program is ill-formed. \pnum \returns -For the first form, \tcode{*any_cast>>(\&operand)}. -For the second and third forms, \tcode{*any_cast>(\&operand)}. +For the first form, \tcode{*any_cast>>(\&operand)}. +For the second and third forms, \tcode{*any_cast>(\&operand)}. \pnum \throws -\tcode{bad_any_cast} if \tcode{operand.type() != typeid(remove_reference_t)}. +\tcode{bad_any_cast} if \tcode{operand.type() != typeid(remove_reference_t)}. \pnum \begin{example} @@ -5886,16 +5865,16 @@ \indexlibrary{\idxcode{any_cast}}% \begin{itemdecl} -template - const ValueType* any_cast(const any* operand) noexcept; -template - ValueType* any_cast(any* operand) noexcept; +template + const T* any_cast(const any* operand) noexcept; +template + T* any_cast(any* operand) noexcept; \end{itemdecl} \begin{itemdescr} \pnum \returns -If \tcode{operand != nullptr \&\& operand->type() == typeid(ValueType)}, +If \tcode{operand != nullptr \&\& operand->type() == typeid(T)}, a pointer to the object contained by \tcode{operand}; otherwise, \tcode{nullptr}. @@ -5909,15 +5888,18 @@ \end{example} \end{itemdescr} -\rSec1[template.bitset]{Class template \tcode{bitset}}% +\rSec1[bitset]{Bitsets} \indexlibrary{\idxcode{bitset}}% -\synopsis{Header \tcode{} synopsis}% +\rSec2[bitset.syn]{Header \tcode{} synopsis}% + +\indextext{\idxhdr{bitset}}% \indexlibrary{\idxhdr{bitset}}% \begin{codeblock} #include -#include // for \tcode{istream}, \tcode{ostream} +#include // for \tcode{istream} (\ref{istream.syn}), \tcode{ostream} (\ref{ostream.syn}), see \ref{iosfwd.syn} + namespace std { template class bitset; @@ -5930,10 +5912,10 @@ bitset operator^(const bitset&, const bitset&) noexcept; template basic_istream& - operator>>(basic_istream& is, bitset& x); + operator>>(basic_istream& is, bitset& x); template basic_ostream& - operator<<(basic_ostream& os, const bitset& x); + operator<<(basic_ostream& os, const bitset& x); } \end{codeblock} @@ -5945,6 +5927,7 @@ and several related functions for representing and manipulating fixed-size sequences of bits. +\rSec2[template.bitset]{Class template \tcode{bitset}}% \indexlibrary{\idxcode{bitset}}% \begin{codeblock} namespace std { @@ -5972,12 +5955,14 @@ typename basic_string::size_type pos = 0, typename basic_string::size_type n = basic_string::npos, - charT zero = charT('0'), charT one = charT('1')); + charT zero = charT('0'), + charT one = charT('1')); template explicit bitset( const charT* str, typename basic_string::size_type n = basic_string::npos, - charT zero = charT('0'), charT one = charT('1')); + charT zero = charT('0'), + charT one = charT('1')); // \ref{bitset.members}, bitset operations bitset& operator&=(const bitset& rhs) noexcept; @@ -6000,10 +5985,11 @@ unsigned long to_ulong() const; unsigned long long to_ullong() const; template , - class Allocator = allocator> + class traits = char_traits, + class Allocator = allocator> basic_string - to_string(charT zero = charT('0'), charT one = charT('1')) const; + to_string(charT zero = charT('0'), charT one = charT('1')) const; + size_t count() const noexcept; constexpr size_t size() const noexcept; bool operator==(const bitset& rhs) const noexcept; @@ -6041,7 +6027,7 @@ and a value of some integral type, bit position \tcode{pos} corresponds to the \term{bit value} -\tcode{1 \shl pos}. +\tcode{1 << pos}. The integral value corresponding to two or more bits is the sum of their bit values. @@ -6070,7 +6056,7 @@ \indexlibrary{\idxcode{overflow_error}}% \end{itemize} -\rSec2[bitset.cons]{\tcode{bitset} constructors} +\rSec3[bitset.cons]{\tcode{bitset} constructors} \indexlibrary{\idxcode{bitset}!constructor}% \begin{itemdecl} @@ -6180,7 +6166,7 @@ \end{itemdescr} -\rSec2[bitset.members]{\tcode{bitset} members} +\rSec3[bitset.members]{\tcode{bitset} members} \indexlibrarymember{operator\&=}{bitset}% \begin{itemdecl} @@ -6233,7 +6219,7 @@ \tcode{*this}. \end{itemdescr} -\indexlibrarymember{operator\shl=}{bitset}% +\indexlibrarymember{operator<<=}{bitset}% \begin{itemdecl} bitset& operator<<=(size_t pos) noexcept; \end{itemdecl} @@ -6258,7 +6244,7 @@ \tcode{*this}. \end{itemdescr} -\indexlibrarymember{operator\shr=}{bitset}% +\indexlibrarymember{operator>>=}{bitset}% \begin{itemdecl} bitset& operator>>=(size_t pos) noexcept; \end{itemdecl} @@ -6282,7 +6268,9 @@ \tcode{*this}. \end{itemdescr} -\indexlibrarymember{set}{bitset}% +% Do not use \indexlibrarymember. +\indexlibrary{\idxcode{set} (member)!\idxcode{bitset}}% +\indexlibrary{\idxcode{bitset}!\idxcode{set}}% \begin{itemdecl} bitset& set() noexcept; \end{itemdecl} @@ -6298,7 +6286,8 @@ \tcode{*this}. \end{itemdescr} -\indexlibrarymember{set}{bitset}% +\indexlibrary{\idxcode{set} (member)!\idxcode{bitset}}% +\indexlibrary{\idxcode{bitset}!\idxcode{set}}% \begin{itemdecl} bitset& set(size_t pos, bool val = true); \end{itemdecl} @@ -6562,7 +6551,8 @@ \returns \tcode{count() == size()}. \end{itemdescr} -\indexlibrarymember{any}{bitset}% +\indexlibrary{\idxcode{any} (member)!\idxcode{bitset}}% +\indexlibrary{\idxcode{bitset}!\idxcode{any}}% \begin{itemdecl} bool any() const noexcept; \end{itemdecl} @@ -6582,7 +6572,7 @@ \returns \tcode{count() == 0}. \end{itemdescr} -\indexlibrarymember{operator\shl}{bitset}% +\indexlibrarymember{operator<<}{bitset}% \begin{itemdecl} bitset operator<<(size_t pos) const noexcept; \end{itemdecl} @@ -6590,10 +6580,10 @@ \begin{itemdescr} \pnum \returns -\tcode{bitset(*this) \shl= pos}. +\tcode{bitset(*this) <<= pos}. \end{itemdescr} -\indexlibrarymember{operator\shr}{bitset}% +\indexlibrarymember{operator>>}{bitset}% \begin{itemdecl} bitset operator>>(size_t pos) const noexcept; \end{itemdecl} @@ -6601,7 +6591,7 @@ \begin{itemdescr} \pnum \returns -\tcode{bitset(*this) \shr= pos}. +\tcode{bitset(*this) >>= pos}. \end{itemdescr} \indexlibrarymember{operator[]}{bitset}% @@ -6701,7 +6691,7 @@ \tcode{bitset(lhs) \caret= rhs}. \end{itemdescr} -\indexlibrarymember{operator\shr}{bitset}% +\indexlibrarymember{operator>>}{bitset}% \begin{itemdecl} template basic_istream& @@ -6746,7 +6736,7 @@ \tcode{is}. \end{itemdescr} -\indexlibrarymember{operator\shl}{bitset}% +\indexlibrarymember{operator<<}{bitset}% \begin{itemdecl} template basic_ostream& @@ -6757,7 +6747,7 @@ \pnum \returns \begin{codeblock} -os @\shl@ x.template to_string>( +os << x.template to_string>( use_facet>(os.getloc()).widen('0'), use_facet>(os.getloc()).widen('1')) \end{codeblock} @@ -6786,6 +6776,7 @@ \tcode{unique_ptr}, \tcode{shared_ptr}, \tcode{weak_ptr}, and various function templates that operate on objects of these types~(\ref{smartptr}). +\indextext{\idxhdr{memory}}% \indexlibrary{\idxhdr{memory}}% \begin{codeblock} namespace std { @@ -6954,7 +6945,8 @@ template class shared_ptr; // \ref{util.smartptr.shared.create}, shared_ptr creation - template shared_ptr make_shared(Args&&... args); + template + shared_ptr make_shared(Args&&... args); template shared_ptr allocate_shared(const A& a, Args&&... args); @@ -6998,7 +6990,8 @@ bool operator>=(nullptr_t, const shared_ptr& y) noexcept; // \ref{util.smartptr.shared.spec}, shared_ptr specialized algorithms - template void swap(shared_ptr& a, shared_ptr& b) noexcept; + template + void swap(shared_ptr& a, shared_ptr& b) noexcept; // \ref{util.smartptr.shared.cast}, shared_ptr casts template @@ -7009,7 +7002,8 @@ shared_ptr const_pointer_cast(const shared_ptr& r) noexcept; // \ref{util.smartptr.getdeleter}, shared_ptr get_deleter - template D* get_deleter(const shared_ptr& p) noexcept; + template + D* get_deleter(const shared_ptr& p) noexcept; // \ref{util.smartptr.shared.io}, shared_ptr I/O template @@ -7044,8 +7038,7 @@ template shared_ptr atomic_exchange(shared_ptr* p, shared_ptr r); template - shared_ptr atomic_exchange_explicit(shared_ptr* p, shared_ptr r, - memory_order mo); + shared_ptr atomic_exchange_explicit(shared_ptr* p, shared_ptr r, memory_order mo); template bool atomic_compare_exchange_weak( @@ -7068,8 +7061,8 @@ template struct hash>; // \ref{allocator.uses.trait}, uses_allocator - template constexpr bool uses_allocator_v - = uses_allocator::value; + template + constexpr bool uses_allocator_v = uses_allocator::value; } \end{codeblock} @@ -7160,7 +7153,7 @@ \begin{itemdescr} \pnum -\remarks If \tcode{element_type} is (possibly cv-qualified) \tcode{void}, the type of +\remarks If \tcode{element_type} is \cv{}~\tcode{void}, the type of \tcode{r} is unspecified; otherwise, it is \tcode{element_type\&}. \pnum @@ -7286,7 +7279,7 @@ \tcode{pointer_safety::\brk{}preferred} if the implementation has relaxed pointer safety} whether \tcode{get_pointer_safety} returns \tcode{pointer_safety::relaxed} or -\tcode{pointer_safety::preferred} if the implementation has relaxed pointer +\tcode{point\-er_safety::preferred} if the implementation has relaxed pointer safety.\footnote{\tcode{pointer_safety::preferred} might be returned to indicate that a leak detector is running so that the program can avoid spurious leak reports.} @@ -7360,8 +7353,8 @@ \begin{itemdescr} \pnum -\remarks automatically detects whether \tcode{T} has a nested \tcode{allocator_type} that -is convertible from \tcode{Alloc}. Meets the BinaryTypeTrait +\remarks Automatically detects whether \tcode{T} has a nested \tcode{allocator_type} that +is convertible from \tcode{Alloc}. Meets the \tcode{BinaryTypeTrait} requirements~(\ref{meta.rqmts}). The implementation shall provide a definition that is derived from \tcode{true_type} if the \grammarterm{qualified-id} \tcode{T::allocator_type} is valid and denotes a type~(\ref{temp.deduct}) and @@ -7379,7 +7372,7 @@ \end{itemize} \end{itemdescr} -\rSec3[allocator.uses.construction]{uses-allocator construction} +\rSec3[allocator.uses.construction]{Uses-allocator construction} \pnum \defn{Uses-allocator construction} with allocator \tcode{Alloc} refers to the @@ -7494,7 +7487,7 @@ \pnum \ctype \tcode{Alloc::void_pointer} if the \grammarterm{qualified-id} \tcode{Alloc::void_pointer} is valid and denotes a -type~(\ref{temp.deduct}); otherwise, +type (\ref{temp.deduct}); otherwise, \tcode{pointer_traits::rebind<\brk{}void>}. \end{itemdescr} @@ -8781,7 +8774,9 @@ \returns \tcode{get()}. \pnum -\realnote use typically requires that \tcode{T} be a complete type. +\begin{note} +The use of this function typically requires that \tcode{T} be a complete type. +\end{note} \end{itemdescr} \indexlibrarymember{get}{unique_ptr}% @@ -8842,7 +8837,7 @@ well-defined behavior, and shall not throw exceptions. \pnum -\effects Assigns \tcode{p} to the stored pointer, and then if the old value of the +\effects Assigns \tcode{p} to the stored pointer, and then if and only if the old value of the stored pointer, \tcode{old_p}, was not equal to \tcode{nullptr}, calls \tcode{get_deleter()(old_p)}. \begin{note} The order of these operations is significant because the call to \tcode{get_deleter()} may destroy \tcode{*this}. \end{note} @@ -9349,7 +9344,7 @@ via \tcode{new}. \tcode{shared_ptr} implements semantics of shared ownership; the last remaining owner of the pointer is responsible for destroying the object, or otherwise releasing the resources associated with the stored pointer. A -\tcode{shared_ptr} object is \term{empty} if it does not own a pointer. +\tcode{shared_ptr} is said to be empty if it does not own a pointer. \begin{codeblock} namespace std { @@ -9403,7 +9398,8 @@ }; // \ref{util.smartptr.shared.create}, shared_ptr creation - template shared_ptr make_shared(Args&&... args); + template + shared_ptr make_shared(Args&&... args); template shared_ptr allocate_shared(const A& a, Args&&... args); @@ -9447,7 +9443,8 @@ bool operator>=(nullptr_t, const shared_ptr& b) noexcept; // \ref{util.smartptr.shared.spec}, shared_ptr specialized algorithms - template void swap(shared_ptr& a, shared_ptr& b) noexcept; + template + void swap(shared_ptr& a, shared_ptr& b) noexcept; // \ref{util.smartptr.shared.cast}, shared_ptr casts template @@ -9460,7 +9457,8 @@ shared_ptr reinterpret_pointer_cast(const shared_ptr& r) noexcept; // \ref{util.smartptr.getdeleter}, shared_ptr get_deleter - template D* get_deleter(const shared_ptr& p) noexcept; + template + D* get_deleter(const shared_ptr& p) noexcept; // \ref{util.smartptr.shared.io}, shared_ptr I/O template @@ -9497,13 +9495,13 @@ \defnx{compatible with}{compatible with!\idxcode{shared_ptr}} a pointer type \tcode{T*} when either \tcode{Y*} is convertible to \tcode{T*} or -\tcode{Y} is \tcode{U[N]} and \tcode{T} is \cv{} \tcode{U[]}. +\tcode{Y} is \tcode{U[N]} and \tcode{T} is \cv{}~\tcode{U[]}. \rSec4[util.smartptr.shared.const]{\tcode{shared_ptr} constructors} \pnum In the constructor definitions below, -\term{enables \tcode{shared_from_this} with \tcode{p}}, +enables \tcode{shared_from_this} with \tcode{p}, for a pointer \tcode{p} of type \tcode{Y*}, means that if \tcode{Y} has an unambiguous and accessible base class that is a specialization of \tcode{enable_shared_from_this}~(\ref{util.smartptr.enab}), @@ -9522,7 +9520,7 @@ \end{itemdecl} \begin{itemdescr} -\pnum\effects Constructs an \textit{empty} \tcode{shared_ptr} object. +\pnum\effects Constructs an empty \tcode{shared_ptr} object. \pnum\postconditions \tcode{use_count() == 0 \&\& get() == nullptr}. \end{itemdescr} @@ -9544,7 +9542,7 @@ \pnum\effects When \tcode{T} is not an array type, constructs a \tcode{shared_ptr} object -that \textit{owns} the pointer \tcode{p}. +that owns the pointer \tcode{p}. Otherwise, constructs a \tcode{shared_ptr} that owns \tcode{p} and a deleter of an unspecified type that calls \tcode{delete[] p}. @@ -9579,7 +9577,7 @@ when \tcode{T} is \tcode{U[]}, \tcode{Y(*)[]} shall be convertible to \tcode{T*}; otherwise, \tcode{Y*} shall be convertible to \tcode{T*}. -\pnum\effects Constructs a \tcode{shared_ptr} object that \textit{owns} the +\pnum\effects Constructs a \tcode{shared_ptr} object that owns the object \tcode{p} and the deleter \tcode{d}. When \tcode{T} is not an array type, the first and second constructors enable \tcode{shared_from_this} with \tcode{p}. @@ -9602,7 +9600,7 @@ \begin{itemdescr} \pnum \effects Constructs a \tcode{shared_ptr} instance that -stores \tcode{p} and \textit{shares ownership} with \tcode{r}. +stores \tcode{p} and shares ownership with \tcode{r}. \pnum \postconditions \tcode{get() == p \&\& use_count() == r.use_count()}. @@ -9613,7 +9611,7 @@ least until the ownership group of \tcode{r} is destroyed. \end{note} \pnum -\begin{note} This constructor allows creation of an \textit{empty} +\begin{note} This constructor allows creation of an empty \tcode{shared_ptr} instance with a non-null stored pointer. \end{note} \end{itemdescr} @@ -9628,9 +9626,9 @@ The second constructor shall not participate in overload resolution unless \tcode{Y*} is compatible with \tcode{T*}. -\pnum\effects If \tcode{r} is \textit{empty}, constructs -an \textit{empty} \tcode{shared_ptr} object; otherwise, constructs -a \tcode{shared_ptr} object that \textit{shares ownership} with \tcode{r}. +\pnum\effects If \tcode{r} is empty, constructs +an empty \tcode{shared_ptr} object; otherwise, constructs +a \tcode{shared_ptr} object that shares ownership with \tcode{r}. \pnum\postconditions \tcode{get() == r.get() \&\& use_count() == r.use_count()}. \end{itemdescr} @@ -9651,7 +9649,7 @@ \pnum \postconditions \tcode{*this} shall contain the old value of -\tcode{r}. \tcode{r} shall be \textit{empty}. \tcode{r.get() == nullptr.} +\tcode{r}. \tcode{r} shall be empty. \tcode{r.get() == nullptr}. \end{itemdescr} \indexlibrary{\idxcode{shared_ptr}!constructor}% @@ -9663,7 +9661,7 @@ \begin{itemdescr} \pnum\requires \tcode{Y*} shall be compatible with \tcode{T*}. -\pnum\effects Constructs a \tcode{shared_ptr} object that \textit{shares ownership} with +\pnum\effects Constructs a \tcode{shared_ptr} object that shares ownership with \tcode{r} and stores a copy of the pointer stored in \tcode{r}. If an exception is thrown, the constructor has no effect. @@ -9701,14 +9699,14 @@ \begin{itemdescr} \pnum\effects \begin{itemize} -\item If \tcode{*this} is \textit{empty} or shares ownership with another +\item If \tcode{*this} is empty or shares ownership with another \tcode{shared_ptr} instance (\tcode{use_count() > 1}), there are no side effects. \item -Otherwise, if \tcode{*this} \textit{owns} an object +Otherwise, if \tcode{*this} owns an object \tcode{p} and a deleter \tcode{d}, \tcode{d(p)} is called. -\item Otherwise, \tcode{*this} \textit{owns} a pointer \tcode{p}, +\item Otherwise, \tcode{*this} owns a pointer \tcode{p}, and \tcode{delete p} is called. \end{itemize} \end{itemdescr} @@ -9848,7 +9846,7 @@ \pnum\returns \tcode{*get()}. -\pnum\remarks When \tcode{T} is an array type or (possibly cv-qualified) \tcode{void}, +\pnum\remarks When \tcode{T} is an array type or \cv{}~\tcode{void}, it is unspecified whether this member function is declared. If it is declared, it is unspecified what its return type is, except that the declaration (although not necessarily the @@ -9899,8 +9897,8 @@ \begin{itemdescr} \pnum\returns The number of \tcode{shared_ptr} objects, \tcode{*this} included, -that \textit{share ownership} with \tcode{*this}, or \tcode{0} when \tcode{*this} is -\textit{empty}. +that share ownership with \tcode{*this}, or \tcode{0} when \tcode{*this} is +empty. \pnum\sync None. @@ -9953,7 +9951,8 @@ \indexlibrary{\idxcode{make_shared}}% \indexlibrary{\idxcode{allocate_shared}}% \begin{itemdecl} -template shared_ptr make_shared(Args&&... args); +template + shared_ptr make_shared(Args&&... args); template shared_ptr allocate_shared(const A& a, Args&&... args); \end{itemdecl} @@ -9963,7 +9962,7 @@ \requires The expression \tcode{::new (pv) T(std::forward(args)...)}, where \tcode{pv} has type \tcode{void*} and points to storage suitable to hold an object of type \tcode{T}, shall be well formed. \tcode{A} shall -be an \textit{allocator}~(\ref{allocator.requirements}). The copy constructor +be an allocator~(\ref{allocator.requirements}). The copy constructor and destructor of \tcode{A} shall not throw exceptions. \pnum @@ -10003,28 +10002,32 @@ \indexlibrarymember{operator==}{shared_ptr}% \begin{itemdecl} -template bool operator==(const shared_ptr& a, const shared_ptr& b) noexcept; +template + bool operator==(const shared_ptr& a, const shared_ptr& b) noexcept; \end{itemdecl} \begin{itemdescr} -\pnum\returns \tcode{a.get() == b.get()}. +\pnum +\returns \tcode{a.get() == b.get()}. \end{itemdescr} \indexlibrarymember{operator<}{shared_ptr}% \begin{itemdecl} -template bool operator<(const shared_ptr& a, const shared_ptr& b) noexcept; +template + bool operator<(const shared_ptr& a, const shared_ptr& b) noexcept; \end{itemdecl} \begin{itemdescr} -\pnum\returns \tcode{less()(a.get(), b.get())}, +\pnum +\returns \tcode{less()(a.get(), b.get())}, where \tcode{V} is the composite pointer type (Clause~\ref{expr}) of \tcode{shared_ptr::element_type*} and \tcode{shared_ptr::element_type*}. -\pnum \begin{note} -Defining a comparison operator allows \tcode{shared_ptr} objects to be +\pnum +\begin{note} +Defining a comparison function allows \tcode{shared_ptr} objects to be used as keys in associative containers. \end{note} - \end{itemdescr} \indexlibrarymember{operator==}{shared_ptr}% @@ -10119,7 +10122,8 @@ \indexlibrarymember{swap}{shared_ptr}% \begin{itemdecl} -template void swap(shared_ptr& a, shared_ptr& b) noexcept; +template + void swap(shared_ptr& a, shared_ptr& b) noexcept; \end{itemdecl} \begin{itemdescr} @@ -10130,58 +10134,80 @@ \indexlibrarymember{static_pointer_cast}{shared_ptr}% \begin{itemdecl} -template shared_ptr static_pointer_cast(const shared_ptr& r) noexcept; +template + shared_ptr static_pointer_cast(const shared_ptr& r) noexcept; \end{itemdecl} \begin{itemdescr} -\pnum\requires The expression \tcode{static_cast((U*)0)} shall +\pnum +\requires The expression \tcode{static_cast((U*)0)} shall be well formed. -\pnum\returns \tcode{shared_ptr(r, static_cast::element_type*>(r.get()))}. +\pnum +\returns +\begin{codeblock} +shared_ptr(r, static_cast::element_type*>(r.get())) +\end{codeblock} \pnum -\begin{note} The seemingly equivalent expression +\begin{note} +The seemingly equivalent expression \tcode{shared_ptr(static_cast(r.get()))} will eventually result in undefined behavior, attempting to delete the -same object twice. \end{note} +same object twice. +\end{note} \end{itemdescr} \indexlibrarymember{dynamic_pointer_cast}{shared_ptr}% \begin{itemdecl} -template shared_ptr dynamic_pointer_cast(const shared_ptr& r) noexcept; +template + shared_ptr dynamic_pointer_cast(const shared_ptr& r) noexcept; \end{itemdecl} \begin{itemdescr} -\pnum\requires The expression \tcode{dynamic_cast((U*)0)} +\pnum +\requires The expression \tcode{dynamic_cast((U*)0)} shall be well formed and shall have well defined behavior. -\pnum\returns +\pnum +\returns \begin{itemize} \item When \tcode{dynamic_cast::element_type*>(r.get())} returns a nonzero value \tcode{p}, \tcode{shared_ptr(r, p)}. - \item Otherwise, \tcode{shared_ptr()}. \end{itemize} -\pnum \begin{note} The seemingly equivalent expression +\pnum +\begin{note} +The seemingly equivalent expression \tcode{shared_ptr(dynamic_cast(r.get()))} will eventually result in -undefined behavior, attempting to delete the same object twice. \end{note} +undefined behavior, attempting to delete the same object twice. +\end{note} \end{itemdescr} \indexlibrarymember{const_pointer_cast}{shared_ptr}% \begin{itemdecl} -template shared_ptr const_pointer_cast(const shared_ptr& r) noexcept; +template + shared_ptr const_pointer_cast(const shared_ptr& r) noexcept; \end{itemdecl} \begin{itemdescr} -\pnum\requires The expression \tcode{const_cast((U*)0)} shall +\pnum +\requires The expression \tcode{const_cast((U*)0)} shall be well formed. -\pnum\returns \tcode{shared_ptr(r, const_cast::element_type*>(r.get()))}. +\pnum +\returns +\begin{codeblock} +shared_ptr(r, const_cast::element_type*>(r.get())) +\end{codeblock} -\pnum \begin{note} The seemingly equivalent expression +\pnum +\begin{note} +The seemingly equivalent expression \tcode{shared_ptr(const_cast(r.get()))} will eventually result in -undefined behavior, attempting to delete the same object twice. \end{note} +undefined behavior, attempting to delete the same object twice. +\end{note} \end{itemdescr} \indexlibrarymember{reinterpret_pointer_cast}{shared_ptr}% @@ -10191,7 +10217,8 @@ \end{itemdecl} \begin{itemdescr} -\pnum\requires The expression \tcode{reinterpret_cast((U*)0)} +\pnum +\requires The expression \tcode{reinterpret_cast((U*)0)} shall be well formed. \pnum\returns @@ -10199,20 +10226,24 @@ shared_ptr(r, reinterpret_cast::element_type*>(r.get())) \end{codeblock} -\pnum \begin{note} The seemingly equivalent expression +\pnum +\begin{note} +The seemingly equivalent expression \tcode{shared_ptr(reinterpret_cast(r.get()))} will eventually result in -undefined behavior, attempting to delete the same object twice. \end{note} +undefined behavior, attempting to delete the same object twice. +\end{note} \end{itemdescr} \rSec4[util.smartptr.getdeleter]{\tcode{get_deleter}} \indexlibrarymember{get_deleter}{shared_ptr}% \begin{itemdecl} -template D* get_deleter(const shared_ptr& p) noexcept; +template + D* get_deleter(const shared_ptr& p) noexcept; \end{itemdecl} \begin{itemdescr} -\pnum\returns If \tcode{p} \textit{owns} a deleter \tcode{d} of type cv-unqualified +\pnum\returns If \tcode{p} owns a deleter \tcode{d} of type cv-unqualified \tcode{D}, returns \tcode{addressof(d)}; otherwise returns \tcode{nullptr}. The returned pointer remains valid as long as there exists a \tcode{shared_ptr} instance @@ -10224,7 +10255,7 @@ \rSec4[util.smartptr.shared.io]{\tcode{shared_ptr} I/O} -\indexlibrarymember{operator\shl}{shared_ptr}% +\indexlibrarymember{operator<<}{shared_ptr}% \begin{itemdecl} template basic_ostream& operator<< (basic_ostream& os, const shared_ptr& p); @@ -10267,7 +10298,7 @@ template weak_ptr& operator=(const weak_ptr& r) noexcept; template weak_ptr& operator=(const shared_ptr& r) noexcept; weak_ptr& operator=(weak_ptr&& r) noexcept; - template weak_ptr& operator=(weak_ptr&& r) noexcept; + template weak_ptr& operator=(weak_ptr&& r) noexcept; // \ref{util.smartptr.weak.mod}, modifiers void swap(weak_ptr& r) noexcept; @@ -10300,7 +10331,7 @@ \end{itemdecl} \begin{itemdescr} -\pnum\effects Constructs an \textit{empty} \tcode{weak_ptr} object. +\pnum\effects Constructs an empty \tcode{weak_ptr} object. \pnum\postconditions \tcode{use_count() == 0}. \end{itemdescr} @@ -10316,9 +10347,9 @@ \pnum\remarks The second and third constructors shall not participate in overload resolution unless \tcode{Y*} is compatible with \tcode{T*}. -\pnum\effects If \tcode{r} is \textit{empty}, constructs -an \textit{empty} \tcode{weak_ptr} object; otherwise, constructs -a \tcode{weak_ptr} object that \textit{shares ownership} +\pnum\effects If \tcode{r} is empty, constructs +an empty \tcode{weak_ptr} object; otherwise, constructs +a \tcode{weak_ptr} object that shares ownership with \tcode{r} and stores a copy of the pointer stored in \tcode{r}. \pnum\postconditions \tcode{use_count() == r.use_count()}. @@ -10337,7 +10368,7 @@ \pnum\effects Move constructs a \tcode{weak_ptr} instance from \tcode{r}. \pnum\postconditions \tcode{*this} shall contain the old value of \tcode{r}. -\tcode{r} shall be \textit{empty}. \tcode{r.use_count() == 0}. +\tcode{r} shall be empty. \tcode{r.use_count() == 0}. \end{itemdescr} \rSec4[util.smartptr.weak.dest]{\tcode{weak_ptr} destructor} @@ -10408,9 +10439,9 @@ \end{itemdecl} \begin{itemdescr} -\pnum\returns \tcode{0} if \tcode{*this} is \textit{empty}; +\pnum\returns \tcode{0} if \tcode{*this} is empty; otherwise, the number of \tcode{shared_ptr} instances -that \textit{share ownership} with \tcode{*this}. +that share ownership with \tcode{*this}. \end{itemdescr} \indexlibrarymember{expired}{weak_ptr}% @@ -10428,7 +10459,8 @@ \end{itemdecl} \begin{itemdescr} -\pnum\returns \tcode{expired() ? shared_ptr() : shared_ptr(*this)}, executed atomically. +\pnum +\returns \tcode{expired() ?\ shared_ptr() :\ shared_ptr(*this)}, executed atomically. \end{itemdescr} \indexlibrarymember{owner_before}{weak_ptr}% @@ -10456,7 +10488,8 @@ \indexlibrarymember{swap}{weak_ptr}% \begin{itemdecl} -template void swap(weak_ptr& a, weak_ptr& b) noexcept; +template + void swap(weak_ptr& a, weak_ptr& b) noexcept; \end{itemdecl} \begin{itemdescr} @@ -10520,14 +10553,12 @@ \indexlibrary{\idxcode{enable_shared_from_this}}% A class \tcode{T} can inherit from \tcode{enable_shared_from_this} to inherit the \tcode{shared_from_this} member functions that obtain -a \textit{shared_ptr} instance pointing to \tcode{*this}. +a \tcode{shared_ptr} instance pointing to \tcode{*this}. \pnum \begin{example} - \begin{codeblock} -struct X: public enable_shared_from_this { -}; +struct X: public enable_shared_from_this { }; int main() { shared_ptr p(new X); @@ -10591,8 +10622,6 @@ \begin{itemdescr} \pnum\returns \tcode{shared_ptr(weak_this)}. - -\pnum\postconditions \tcode{r.get() == this}. \end{itemdescr} \indexlibrary{\idxcode{weak_ptr}}% @@ -10727,8 +10756,7 @@ \indexlibrarymember{atomic_exchange_explicit}{shared_ptr}% \begin{itemdecl} template - shared_ptr atomic_exchange_explicit(shared_ptr* p, shared_ptr r, - memory_order mo); + shared_ptr atomic_exchange_explicit(shared_ptr* p, shared_ptr r, memory_order mo); \end{itemdecl} \begin{itemdescr} @@ -10748,8 +10776,7 @@ \indexlibrarymember{atomic_compare_exchange_weak}{shared_ptr}% \begin{itemdecl} template - bool atomic_compare_exchange_weak( - shared_ptr* p, shared_ptr* v, shared_ptr w); + bool atomic_compare_exchange_weak(shared_ptr* p, shared_ptr* v, shared_ptr w); \end{itemdecl} \begin{itemdescr} @@ -10757,8 +10784,10 @@ \requires \tcode{p} shall not be null and \tcode{v} shall not be null. \pnum -\returns \tcode{atomic_compare_exchange_weak_explicit(p, v, w, -memory_order_seq_cst, memory_order_seq_cst)}. +\returns +\begin{codeblock} +atomic_compare_exchange_weak_explicit(p, v, w, memory_order_seq_cst, memory_order_seq_cst) +\end{codeblock} \pnum \throws Nothing. @@ -10767,14 +10796,15 @@ \indexlibrarymember{atomic_compare_exchange_strong}{shared_ptr}% \begin{itemdecl} template - bool atomic_compare_exchange_strong( - shared_ptr* p, shared_ptr* v, shared_ptr w); + bool atomic_compare_exchange_strong(shared_ptr* p, shared_ptr* v, shared_ptr w); \end{itemdecl} \begin{itemdescr} \pnum -\returns \tcode{atomic_compare_exchange_strong_explicit(p, v, w,} -\tcode{memory_order_seq_cst, memory_order_seq_cst)}. +\returns +\begin{codeblock} +atomic_compare_exchange_strong_explicit(p, v, w, memory_order_seq_cst, memory_order_seq_cst) +\end{codeblock} \end{itemdescr} \indexlibrarymember{atomic_compare_exchange_weak_explicit}{shared_ptr}% @@ -10793,9 +10823,7 @@ \begin{itemdescr} \pnum \requires \tcode{p} shall not be null and \tcode{v} shall not be null. - -\pnum -\requires The \tcode{failure} argument shall not be \tcode{memory_order_release} nor +The \tcode{failure} argument shall not be \tcode{memory_order_release} nor \tcode{memory_order_acq_rel}. \pnum @@ -10811,11 +10839,9 @@ \throws Nothing. \pnum -\remarks two \tcode{shared_ptr} objects are equivalent if they store the same +\remarks Two \tcode{shared_ptr} objects are equivalent if they store the same pointer value and share ownership. - -\pnum -\remarks the weak forms may fail spuriously. See~\ref{atomics.types.operations}. +The weak form may fail spuriously. See~\ref{atomics.types.operations}. \end{itemdescr} \rSec3[util.smartptr.hash]{Smart pointer hash support} @@ -10852,6 +10878,7 @@ \rSec2[mem.res.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{memory_resource}}% \indexlibrary{\idxhdr{memory_resource}}% \begin{codeblock} namespace std::pmr { @@ -10861,7 +10888,7 @@ bool operator==(const memory_resource& a, const memory_resource& b) noexcept; bool operator!=(const memory_resource& a, const memory_resource& b) noexcept; - // \ref{mem.poly.allocator.class}, class \tcode{polymorphic_allocator} + // \ref{mem.poly.allocator.class}, class template \tcode{polymorphic_allocator} template class polymorphic_allocator; template @@ -11137,8 +11164,9 @@ Nothing. \pnum -\realnotes +\begin{note} This constructor provides an implicit conversion from \tcode{memory_resource*}. +\end{note} \end{itemdescr} \indexlibrary{\idxcode{polymorphic_allocator}!constructor}% @@ -11251,7 +11279,7 @@ If \tcode{uses_allocator_v} is \tcode{false} \\ and -\tcode{is_constructible_v} is \tcode{true}, +\tcode{is_constructible_v} is \tcode{true}, \\ then \tcode{xprime} is \tcode{x}. \item @@ -11278,7 +11306,7 @@ If \tcode{uses_allocator_v} is \tcode{false} \\ and -\tcode{is_constructible_v} is \tcode{true}, +\tcode{is_constructible_v} is \tcode{true}, \\ then \tcode{yprime} is \tcode{y}. \item @@ -11531,7 +11559,7 @@ are general-purpose memory resources having the following qualities: \begin{itemize} \item -Each resource \term{owns} the allocated memory, and frees it on destruction -- +Each resource frees its allocated memory on destruction, even if \tcode{deallocate} has not been called for some of the allocated blocks. \item A pool resource consists of a collection of \defn{pools}, @@ -11821,26 +11849,28 @@ Nothing. \end{itemdescr} -\indexlibrarymember{do_is_equal}{unsynchronized_pool_resource}% +\indexlibrarymember{do_is_equal}{synchronized_pool_resource}% \begin{itemdecl} -bool unsynchronized_pool_resource::do_is_equal(const memory_resource& other) const noexcept override; +bool synchronized_pool_resource::do_is_equal( + const memory_resource& other) const noexcept override; \end{itemdecl} \begin{itemdescr} \pnum \returns -\tcode{this == dynamic_cast(\&other)}. +\tcode{this == dynamic_cast(\&other)}. \end{itemdescr} -\indexlibrarymember{do_is_equal}{synchronized_pool_resource}% +\indexlibrarymember{do_is_equal}{unsynchronized_pool_resource}% \begin{itemdecl} -bool synchronized_pool_resource::do_is_equal(const memory_resource& other) const noexcept override; +bool unsynchronized_pool_resource::do_is_equal( + const memory_resource& other) const noexcept override; \end{itemdecl} \begin{itemdescr} \pnum \returns -\tcode{this == dynamic_cast(\&other)}. +\tcode{this == dynamic_cast(\&other)}. \end{itemdescr} \rSec2[mem.res.monotonic.buffer]{Class \tcode{monotonic_buffer_resource}} @@ -11870,7 +11900,7 @@ Specifically, calls to \tcode{allocate} and \tcode{deallocate} do not synchronize with one another. \item -It \term{owns} the allocated memory and frees it on destruction, +It frees the allocated memory on destruction, even if \tcode{deallocate} has not been called for some of the allocated blocks. \end{itemize} @@ -11951,7 +11981,7 @@ \effects Sets \tcode{upstream_rsrc} to \tcode{upstream}, \tcode{current_buffer} to \tcode{buffer}, and -\tcode{next_buffer_size} to \tcode{initial_size} (but not less than 1), +\tcode{next_buffer_size} to \tcode{buffer_size} (but not less than 1), then increases \tcode{next_buffer_size} by an \impldef{growth factor for \tcode{monotonic_buffer_resource}} growth factor (which need not be integral). \end{itemdescr} @@ -12064,6 +12094,7 @@ \rSec2[allocator.adaptor.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{scoped_allocator}}% \indexlibrary{\idxhdr{scoped_allocator}}% \begin{codeblock} // scoped allocator adaptor @@ -12340,16 +12371,16 @@ \pnum In the \tcode{construct} member functions, -\textit{OUTERMOST(x)} is \tcode{x} if \tcode{x} does not have an -\tcode{outer_allocator()} member function and \\ -\textit{OUTERMOST(x.outer_allocator())} +\tcode{\placeholdernc{OUTERMOST}(x)} is \tcode{x} if \tcode{x} does not have an +\tcode{outer_allocator()} member function and +\tcode{\placeholdernc{OUTERMOST}(x.outer_allocator())} otherwise; -\textit{OUTERMOST_ALLOC_TRAITS(x)} is \\ -\tcode{allocator_traits}. -\begin{note} \textit{OUTERMOST}(x) and \\ -\textit{OUTERMOST_ALLOC_TRAITS}(x) are recursive operations. It +\tcode{\placeholdernc{OUTERMOST_ALLOC_TRAITS}(x)} is +\tcode{allocator_traits}. +\begin{note} \tcode{\placeholdernc{OUTERMOST}(x)} and +\tcode{\placeholdernc{OUTERMOST_ALLOC_TRAITS}(x)} are recursive operations. It is incumbent upon the definition of \tcode{outer_allocator()} to ensure that the -recursion terminates. It will terminate for all instantiations of \\ +recursion terminates. It will terminate for all instantiations of \tcode{scoped_allocator_adaptor}. \end{note} \indexlibrarymember{inner_allocator}{scoped_allocator_adaptor}% @@ -12434,27 +12465,35 @@ \begin{itemdescr} \pnum \effects - \begin{itemize} -\item If \tcode{uses_allocator_v} is \tcode{false} and\\ -\tcode{is_constructible_v} is \tcode{true}, calls\\ -\textit{OUTERMOST_ALLOC_TRAITS}(\tcode{*this})\tcode{::construct(\\ -\textit{OUTERMOST}(*this), p, std::forward(args)...)}. +\item If \tcode{uses_allocator_v} is \tcode{false} and +\tcode{is_constructible_v} is \tcode{true}, calls: +\begin{codeblock} +@\placeholdernc{OUTERMOST_ALLOC_TRAITS}@(*this)::construct( + @\placeholdernc{OUTERMOST}@(*this), p, std::forward(args)...) +\end{codeblock} \item Otherwise, if \tcode{uses_allocator_v} is \tcode{true} and -\tcode{is_construc\-tible_v} is \tcode{true}, calls -\textit{OUTERMOST_ALLOC_TRAITS}(\tcode{*this})\tcode{::construct(\textit{OUTERMOST}(*this), -p, allocator_arg,\\inner_allocator(), std::forward(args)...)}. +\tcode{is_constructible_v} is \tcode{true}, calls: +\begin{codeblock} +@\placeholdernc{OUTERMOST_ALLOC_TRAITS}@(*this)::construct( + @\placeholdernc{OUTERMOST}@(*this), p, allocator_arg, inner_allocator(), std::forward(args)...) +\end{codeblock} \item Otherwise, if \tcode{uses_allocator_v} is \tcode{true} and -\tcode{is_construct\-ible_v} is \tcode{true}, calls -\textit{OUTERMOST_ALLOC_TRAITS}(*this):: -\tcode{construct(\textit{OUTERMOST}(*this), p, std::forward(args)...,\\inner_allocator())}. +\tcode{is_constructible_v} is \tcode{true}, calls: +\begin{codeblock} +@\placeholdernc{OUTERMOST_ALLOC_TRAITS}@(*this)::construct( + @\placeholdernc{OUTERMOST}@(*this), p, std::forward(args)..., inner_allocator()) +\end{codeblock} -\item Otherwise, the program is ill-formed. \begin{note} An error will result if +\item Otherwise, the program is ill-formed. +\begin{note} +An error will result if \tcode{uses_allocator} evaluates to \tcode{true} but the specific constructor does not take an allocator. This definition prevents a silent failure to pass an inner allocator to a -contained element. \end{note} +contained element. +\end{note} \end{itemize} \end{itemdescr} @@ -12473,55 +12512,63 @@ \pnum \effects Constructs a \tcode{tuple} object \tcode{xprime} from \tcode{x} by the following rules: - \begin{itemize} -\item If \tcode{uses_allocator_v} is \tcode{false} and\\ -\tcode{is_constructible_v} is \tcode{true}, +\item If \tcode{uses_allocator_v} is \tcode{false} and +\tcode{is_constructible_v} is \tcode{true}, then \tcode{xprime} is \tcode{x}. \item Otherwise, if \tcode{uses_allocator_v} is \tcode{true} and \tcode{is_construct\-ible_v} is -\tcode{true}, then \tcode{xprime} is -\tcode{tuple_cat(tuple( -allocator_arg, inner_allocator()), std::move(x))}. +\tcode{true}, then \tcode{xprime} is: +\begin{codeblock} +tuple_cat( + tuple(allocator_arg, inner_allocator()), + std::move(x)) +\end{codeblock} \item Otherwise, if \tcode{uses_allocator_v} is \tcode{true} and \tcode{is_construct\-ible_v} is \tcode{true}, -then \tcode{xprime} is -\tcode{tuple_cat(std::move(x), tuple(inner_allocator()))}. +then \tcode{xprime} is: +\begin{codeblock} +tuple_cat(std::move(x), tuple(inner_allocator())) +\end{codeblock} \item Otherwise, the program is ill-formed. \end{itemize} - and constructs a \tcode{tuple} object \tcode{yprime} from \tcode{y} by the following rules: - \begin{itemize} -\item If \tcode{uses_allocator_v} is \tcode{false} and\\ -\tcode{is_constructible_v} is \tcode{true}, then \tcode{yprime} is \tcode{y}. +\item If \tcode{uses_allocator_v} is \tcode{false} and +\tcode{is_constructible_v} is \tcode{true}, then \tcode{yprime} is \tcode{y}. \item Otherwise, if \tcode{uses_allocator_v} is \tcode{true} and -\tcode{is_construct\-ible_v} +\tcode{is_constructible_v} is -\tcode{true}, then \tcode{yprime} is -\tcode{tuple_cat(tuple( -allocator_arg, inner_allocator()), std::move(y))}. +\tcode{true}, then \tcode{yprime} is: +\begin{codeblock} +tuple_cat( + tuple(allocator_arg, inner_allocator()), + std::move(y)) +\end{codeblock} \item Otherwise, if \tcode{uses_allocator_v} is \tcode{true} and -\tcode{is_construct\-ible_v} is \tcode{true}, -then \tcode{yprime} is -\tcode{tuple_cat(std::move(y), tuple(inner_allocator()))}. +\tcode{is_constructible_v} is \tcode{true}, +then \tcode{yprime} is: +\begin{codeblock} +tuple_cat(std::move(y), tuple(inner_allocator())) +\end{codeblock} \item Otherwise, the program is ill-formed. \end{itemize} - -then calls \tcode{\textit{OUTERMOST_ALLOC_TRAITS}(*this)::construct(\textit{OUTERMOST}(*this), p,\\ -piecewise_construct, std::move(xprime), std::move(yprime))}. +then calls: +\begin{codeblock} +@\placeholdernc{OUTERMOST_ALLOC_TRAITS}@(*this)::construct( + @\placeholdernc{OUTERMOST}@(*this), p, piecewise_construct, std::move(xprime), std::move(yprime)) +\end{codeblock} \end{itemdescr} \indexlibrarymember{construct}{scoped_allocator_adaptor}% @@ -12594,7 +12641,7 @@ \begin{itemdescr} \pnum -\effects Calls \tcode{\textit{OUTERMOST_ALLOC_TRAITS}(*this)::destroy(\textit{OUTERMOST}(*this), p)}. +\effects Calls \tcode{\placeholdernc{OUTERMOST_ALLOC_TRAITS}(*this)::destroy(\placeholdernc{OUTERMOST}(*this), p)}. \end{itemdescr} \indexlibrarymember{select_on_container_copy_construction}{scoped_allocator_adaptor}% @@ -12658,14 +12705,15 @@ algorithmic templates work with pointers to functions, but also enables them to work with arbitrary function objects. -\pnum -\synopsis{Header \tcode{} synopsis} +\rSec2[functional.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{functional}}% \indexlibrary{\idxhdr{functional}}% \begin{codeblock} namespace std { // \ref{func.invoke}, invoke - template result_of_t invoke(F&& f, Args&&... args); + template + result_of_t invoke(F&& f, Args&&... args); // \ref{refwrap}, reference_wrapper template class reference_wrapper; @@ -12725,7 +12773,8 @@ template <> struct bit_not; // \ref{func.not_fn}, function template \tcode{not_fn} - template @\unspec@ not_fn(F&& f); + template + @\unspec@ not_fn(F&& f); // \ref{func.bind}, bind template struct is_bind_expression; @@ -12737,17 +12786,18 @@ @\unspec@ bind(F&&, BoundArgs&&...); namespace placeholders { - // M is the \impldef{number of placeholders for bind expressions} number of placeholders - @\seebelow@ _1; - @\seebelow@ _2; - . - . - . - @\seebelow@ _M; + // \tcode{\placeholder{M}} is the \impldef{number of placeholders for bind expressions} number of placeholders + @\seebelownc@ _1; + @\seebelownc@ _2; + . + . + . + @\seebelownc@ _@\placeholdernc{M}@; } // \ref{func.memfn}, member function adaptors - template @\unspec@ mem_fn(R T::*) noexcept; + template + @\unspec@ mem_fn(R T::*) noexcept; // \ref{func.wrap}, polymorphic function wrappers class bad_function_call; @@ -12770,49 +12820,60 @@ // \ref{func.search}, searchers template> class default_searcher; + template::value_type>, class BinaryPredicate = equal_to<>> class boyer_moore_searcher; + template::value_type>, class BinaryPredicate = equal_to<>> class boyer_moore_horspool_searcher; template> - default_searcher - make_default_searcher(ForwardIterator pat_first, ForwardIterator pat_last, - BinaryPredicate pred = BinaryPredicate()); + default_searcher + make_default_searcher( + ForwardIterator pat_first, + ForwardIterator pat_last, + BinaryPredicate pred = BinaryPredicate()); + template::value_type>, class BinaryPredicate = equal_to<>> - boyer_moore_searcher - make_boyer_moore_searcher( - RandomAccessIterator pat_first, RandomAccessIterator pat_last, - Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate()); + boyer_moore_searcher + make_boyer_moore_searcher( + RandomAccessIterator pat_first, + RandomAccessIterator pat_last, + Hash hf = Hash(), + BinaryPredicate pred = BinaryPredicate()); + template::value_type>, class BinaryPredicate = equal_to<>> - boyer_moore_horspool_searcher - make_boyer_moore_horspool_searcher( - RandomAccessIterator pat_first, RandomAccessIterator pat_last, - Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate()); + boyer_moore_horspool_searcher + make_boyer_moore_horspool_searcher( + RandomAccessIterator pat_first, + RandomAccessIterator pat_last, + Hash hf = Hash(), + BinaryPredicate pred = BinaryPredicate()); // \ref{unord.hash}, hash function primary template - template struct hash; + template + struct hash; // \ref{func.default.traits}, default functor traits template - struct default_order; + struct default_order; template - using default_order_t = typename default_order::type; + using default_order_t = typename default_order::type; // \ref{func.bind}, function object binders - template constexpr bool is_bind_expression_v - = is_bind_expression::value; - template constexpr int is_placeholder_v - = is_placeholder::value; + template + constexpr bool is_bind_expression_v = is_bind_expression::value; + template + constexpr int is_placeholder_v = is_placeholder::value; } \end{codeblock} @@ -12890,7 +12951,7 @@ \item \tcode{t1.*f} when \tcode{N == 1} and \tcode{f} is a pointer to data member of a class \tcode{T} and \tcode{is_base_of_v>} is \tcode{true}; - + \item \tcode{t1.get().*f} when \tcode{N == 1} and \tcode{f} is a pointer to data member of a class \tcode{T} and \tcode{decay_t} is a specialization of \tcode{reference_wrapper}; @@ -12906,7 +12967,7 @@ \indexlibrary{invoke@\tcode{\textit{INVOKE}}}% Define \tcode{\textit{INVOKE}(f, t1, t2, ..., tN, R)} as \tcode{static_cast(\textit{INVOKE}(f, t1, t2, ..., tN))} -if \tcode{R} is \cv{} \tcode{void}, otherwise +if \tcode{R} is \cv{}~\tcode{void}, otherwise \tcode{\textit{INVOKE}(f, t1, t2, ..., tN)} implicitly converted to \tcode{R}. @@ -13045,7 +13106,7 @@ \end{itemdescr} -\rSec3[refwrap.invoke]{reference_wrapper invocation} +\rSec3[refwrap.invoke]{\tcode{reference_wrapper} invocation} \indexlibrarymember{operator()}{reference_wrapper}% \begin{itemdecl} @@ -13059,7 +13120,7 @@ \end{itemdescr} -\rSec3[refwrap.helpers]{reference_wrapper helper functions} +\rSec3[refwrap.helpers]{\tcode{reference_wrapper} helper functions} \indexlibrarymember{ref}{reference_wrapper}% \begin{itemdecl} @@ -13103,7 +13164,7 @@ The library provides basic function object classes for all of the arithmetic operators in the language~(\ref{expr.mul}, \ref{expr.add}). -\rSec3[arithmetic.operations.plus]{class template \tcode{plus}} +\rSec3[arithmetic.operations.plus]{Class template \tcode{plus}} \indexlibrary{\idxcode{plus}}% \begin{itemdecl} @@ -13141,7 +13202,7 @@ \pnum\returns \tcode{std::forward(t) + std::forward(u)}. \end{itemdescr} -\rSec3[arithmetic.operations.minus]{class template \tcode{minus}} +\rSec3[arithmetic.operations.minus]{Class template \tcode{minus}} \indexlibrary{\idxcode{minus}}% \begin{itemdecl} @@ -13179,7 +13240,7 @@ \pnum\returns \tcode{std::forward(t) - std::forward(u)}. \end{itemdescr} -\rSec3[arithmetic.operations.multiplies]{class template \tcode{multiplies}} +\rSec3[arithmetic.operations.multiplies]{Class template \tcode{multiplies}} \indexlibrary{\idxcode{multiplies}}% \begin{itemdecl} @@ -13217,7 +13278,7 @@ \pnum\returns \tcode{std::forward(t) * std::forward(u)}. \end{itemdescr} -\rSec3[arithmetic.operations.divides]{class template \tcode{divides}} +\rSec3[arithmetic.operations.divides]{Class template \tcode{divides}} \indexlibrary{\idxcode{divides}}% \begin{itemdecl} @@ -13255,7 +13316,7 @@ \pnum\returns \tcode{std::forward(t) / std::forward(u)}. \end{itemdescr} -\rSec3[arithmetic.operations.modulus]{class template \tcode{modulus}} +\rSec3[arithmetic.operations.modulus]{Class template \tcode{modulus}} \indexlibrary{\idxcode{modulus}}% \begin{itemdecl} @@ -13293,7 +13354,7 @@ \pnum\returns \tcode{std::forward(t) \% std::forward(u)}. \end{itemdescr} -\rSec3[arithmetic.operations.negate]{class template \tcode{negate}} +\rSec3[arithmetic.operations.negate]{Class template \tcode{negate}} \indexlibrary{\idxcode{negate}}% \begin{itemdecl} @@ -13355,7 +13416,7 @@ that is consistent among those specializations and is also consistent with the partial order imposed by those built-in operators. -\rSec3[comparisons.equal_to]{class template \tcode{equal_to}} +\rSec3[comparisons.equal_to]{Class template \tcode{equal_to}} \indexlibrary{\idxcode{equal_to}}% \begin{itemdecl} @@ -13393,7 +13454,7 @@ \pnum\returns \tcode{std::forward(t) == std::forward(u)}. \end{itemdescr} -\rSec3[comparisons.not_equal_to]{class template \tcode{not_equal_to}} +\rSec3[comparisons.not_equal_to]{Class template \tcode{not_equal_to}} \indexlibrary{\idxcode{not_equal_to}}% \begin{itemdecl} @@ -13431,7 +13492,7 @@ \pnum\returns \tcode{std::forward(t) != std::forward(u)}. \end{itemdescr} -\rSec3[comparisons.greater]{class template \tcode{greater}} +\rSec3[comparisons.greater]{Class template \tcode{greater}} \indexlibrary{\idxcode{greater}}% \begin{itemdecl} @@ -13469,7 +13530,7 @@ \pnum\returns \tcode{std::forward(t) > std::forward(u)}. \end{itemdescr} -\rSec3[comparisons.less]{class template \tcode{less}} +\rSec3[comparisons.less]{Class template \tcode{less}} \indexlibrary{\idxcode{less}}% \begin{itemdecl} @@ -13507,7 +13568,7 @@ \pnum\returns \tcode{std::forward(t) < std::forward(u)}. \end{itemdescr} -\rSec3[comparisons.greater_equal]{class template \tcode{greater_equal}} +\rSec3[comparisons.greater_equal]{Class template \tcode{greater_equal}} \indexlibrary{\idxcode{greater_equal}}% \begin{itemdecl} @@ -13545,7 +13606,7 @@ \pnum\returns \tcode{std::forward(t) >= std::forward(u)}. \end{itemdescr} -\rSec3[comparisons.less_equal]{class template \tcode{less_equal}} +\rSec3[comparisons.less_equal]{Class template \tcode{less_equal}} \indexlibrary{\idxcode{less_equal}}% \begin{itemdecl} @@ -13590,7 +13651,7 @@ The library provides basic function object classes for all of the logical operators in the language~(\ref{expr.log.and}, \ref{expr.log.or}, \ref{expr.unary.op}). -\rSec3[logical.operations.and]{class template \tcode{logical_and}} +\rSec3[logical.operations.and]{Class template \tcode{logical_and}} \indexlibrary{\idxcode{logical_and}}% \begin{itemdecl} @@ -13628,7 +13689,7 @@ \pnum\returns \tcode{std::forward(t) \&\& std::forward(u)}. \end{itemdescr} -\rSec3[logical.operations.or]{class template \tcode{logical_or}} +\rSec3[logical.operations.or]{Class template \tcode{logical_or}} \indexlibrary{\idxcode{logical_or}}% \begin{itemdecl} @@ -13666,7 +13727,7 @@ \pnum\returns \tcode{std::forward(t) || std::forward(u)}. \end{itemdescr} -\rSec3[logical.operations.not]{class template \tcode{logical_not}} +\rSec3[logical.operations.not]{Class template \tcode{logical_not}} \indexlibrary{\idxcode{logical_not}}% \begin{itemdecl} @@ -13712,7 +13773,7 @@ operators in the language~(\ref{expr.bit.and}, \ref{expr.or}, \ref{expr.xor}, \ref{expr.unary.op}). -\rSec3[bitwise.operations.and]{class template \tcode{bit_and}} +\rSec3[bitwise.operations.and]{Class template \tcode{bit_and}} \indexlibrary{\idxcode{bit_and}}% \begin{itemdecl} @@ -13750,7 +13811,7 @@ \pnum\returns \tcode{std::forward(t) \& std::forward(u)}. \end{itemdescr} -\rSec3[bitwise.operations.or]{class template \tcode{bit_or}} +\rSec3[bitwise.operations.or]{Class template \tcode{bit_or}} \indexlibrary{\idxcode{bit_or}}% \begin{itemdecl} @@ -13788,7 +13849,7 @@ \pnum\returns \tcode{std::forward(t) | std::forward(u)}. \end{itemdescr} -\rSec3[bitwise.operations.xor]{class template \tcode{bit_xor}} +\rSec3[bitwise.operations.xor]{Class template \tcode{bit_xor}} \indexlibrary{\idxcode{bit_xor}}% \begin{itemdecl} @@ -13826,7 +13887,7 @@ \pnum\returns \tcode{std::forward(t) \caret{} std::forward(u)}. \end{itemdescr} -\rSec3[bitwise.operations.not]{class template \tcode{bit_not}} +\rSec3[bitwise.operations.not]{Class template \tcode{bit_not}} \begin{itemdecl} template struct bit_not { @@ -13874,42 +13935,40 @@ \begin{itemdescr} \pnum \effects -Equivalent to \tcode{return \textit{call_wrapper}(std::forward(f));} -where \textit{call_wrapper} is an exposition only class defined as follows: +Equivalent to \tcode{return \placeholder{call_wrapper}(std::forward(f));} +where \tcode{\placeholder{call_wrapper}} is an exposition only class defined as follows: \begin{codeblock} -class @\textit{call_wrapper}@ -{ - using FD = decay_t; - explicit @\textit{call_wrapper}@(F&& f); +class @\placeholder{call_wrapper}@ { + using FD = decay_t; + FD fd; -public: - @\textit{call_wrapper}@(@\textit{call_wrapper}@&&) = default; - @\textit{call_wrapper}@(const @\textit{call_wrapper}@&) = default; + explicit @\placeholder{call_wrapper}@(F&& f); - template - auto operator()(Args&&...) & - -> decltype(!declval>()); +public: + @\placeholder{call_wrapper}@(@\placeholder{call_wrapper}@&&) = default; + @\placeholder{call_wrapper}@(const @\placeholder{call_wrapper}@&) = default; - template - auto operator()(Args&&...) const& - -> decltype(!declval>()); + template + auto operator()(Args&&...) & + -> decltype(!declval>()); - template - auto operator()(Args&&...) && - -> decltype(!declval>()); + template + auto operator()(Args&&...) const& + -> decltype(!declval>()); - template - auto operator()(Args&&...) const&& - -> decltype(!declval>()); + template + auto operator()(Args&&...) && + -> decltype(!declval>()); -private: - FD fd; + template + auto operator()(Args&&...) const&& + -> decltype(!declval>()); }; \end{codeblock} \end{itemdescr} \begin{itemdecl} -explicit @\textit{call_wrapper}@(F&& f); +explicit @\placeholdernc{call_wrapper}@(F&& f); \end{itemdecl} \begin{itemdescr} @@ -13941,7 +14000,9 @@ \pnum \effects Equivalent to: -\tcode{return !\textit{INVOKE}(fd, std::forward(args)...);}~(\ref{func.require}). +\begin{codeblock} +return !@\placeholdernc{INVOKE}@(fd, std::forward(args)...); // see \ref{func.require} +\end{codeblock} \end{itemdescr} \begin{itemdecl} @@ -13957,7 +14018,9 @@ \pnum \effects Equivalent to: -\tcode{return !\textit{INVOKE}(std::move(fd), std::forward(args)...);}~(\ref{func.require}). +\begin{codeblock} +return !@\placeholdernc{INVOKE}@(std::move(fd), std::forward(args)...); // see \ref{func.require} +\end{codeblock} \end{itemdescr} \rSec2[func.bind]{Function object binders}% @@ -13972,23 +14035,23 @@ \indexlibrary{\idxcode{is_bind_expression}}% \begin{codeblock} namespace std { - template struct is_bind_expression; // see below + template struct is_bind_expression; // see below } \end{codeblock} \pnum -\tcode{is_bind_expression} can be used to detect function objects -generated by \tcode{bind}. \tcode{bind} +The class template \tcode{is_bind_expression} can be used to detect function objects +generated by \tcode{bind}. The function template \tcode{bind} uses \tcode{is_bind_expression} to detect subexpressions. \pnum Instantiations of the \tcode{is_bind_expression} template shall meet -the UnaryTypeTrait requirements~(\ref{meta.rqmts}). The implementation -shall provide a definition that has a BaseCharacteristic of +the \tcode{UnaryTypeTrait} requirements~(\ref{meta.rqmts}). The implementation +shall provide a definition that has a base characteristic of \tcode{true_type} if \tcode{T} is a type returned from \tcode{bind}, -otherwise it shall have a BaseCharacteristic of \tcode{false_type}. +otherwise it shall have a base characteristic of \tcode{false_type}. A program may specialize this template for a user-defined type \tcode{T} -to have a BaseCharacteristic of \tcode{true_type} to indicate that +to have a base characteristic of \tcode{true_type} to indicate that \tcode{T} should be treated as a subexpression in a \tcode{bind} call. \rSec3[func.bind.isplace]{Class template \tcode{is_placeholder}} @@ -13996,25 +14059,25 @@ \indexlibrary{\idxcode{is_placeholder}}% \begin{codeblock} namespace std { - template struct is_placeholder; // see below + template struct is_placeholder; // see below } \end{codeblock} \pnum -\tcode{is_placeholder} can be used to detect the standard placeholders -\tcode{_1}, \tcode{_2}, and so on. \tcode{bind} uses +The class template \tcode{is_placeholder} can be used to detect the standard placeholders +\tcode{_1}, \tcode{_2}, and so on. The function template \tcode{bind} uses \tcode{is_placeholder} to detect placeholders. \pnum Instantiations of the \tcode{is_placeholder} template shall meet -the UnaryTypeTrait requirements~(\ref{meta.rqmts}). The implementation -shall provide a definition that has the BaseCharacteristic of -\tcode{integral_constant} if \tcode{T} is the type of -\tcode{std::placeholders::_J}, otherwise it shall have a -BaseCharacteristic of \tcode{integral_constant}. A program +the \tcode{UnaryTypeTrait} requirements~(\ref{meta.rqmts}). The implementation +shall provide a definition that has the base characteristic of +\tcode{integral_constant} if \tcode{T} is the type of +\tcode{std::placeholders::_\placeholder{J}}, otherwise it shall have a +base characteristic of \tcode{integral_constant}. A program may specialize this template for a user-defined type \tcode{T} to -have a BaseCharacteristic of \tcode{integral_constant} -with \tcode{\textit{N} > 0} to indicate that \tcode{T} should be +have a base characteristic of \tcode{integral_constant} +with \tcode{N > 0} to indicate that \tcode{T} should be treated as a placeholder type. \rSec3[func.bind.bind]{Function template \tcode{bind}} @@ -14026,13 +14089,13 @@ \begin{itemize} \item \tcode{FD} is the type \tcode{decay_t}, \item \tcode{fd} is an lvalue of type \tcode{FD} constructed from \tcode{std::forward(f)}, -\item \tcode{Ti} is the $i^{th}$ type in the template parameter pack \tcode{BoundArgs}, -\item \tcode{TiD} is the type \tcode{decay_t}, -\item \tcode{ti} is the $i^{th}$ argument in the function parameter pack \tcode{bound_args}, -\item \tcode{tid} is an lvalue of type \tcode{TiD} constructed from \tcode{std::forward(ti)}, -\item \tcode{Uj} is the $j^{th}$ deduced type of the \tcode{UnBoundArgs\&\&...} parameter +\item $\tcode{T}_i$ is the $i^\text{th}$ type in the template parameter pack \tcode{BoundArgs}, +\item $\tcode{TD}_i$ is the type \tcode{decay_t<$\tcode{T}_i$>}, +\item $\tcode{t}_i$ is the $i^\text{th}$ argument in the function parameter pack \tcode{bound_args}, +\item $\tcode{td}_i$ is an lvalue of type $\tcode{TD}_i$ constructed from \tcode{std::forward<$\tcode{T}_i$>($\tcode{t}_i$)}, +\item $\tcode{U}_j$ is the $j^\text{th}$ deduced type of the \tcode{UnBoundArgs\&\&...} parameter of the forwarding call wrapper, and -\item \tcode{uj} is the $j^{th}$ argument associated with \tcode{Uj}. +\item $\tcode{u}_j$ is the $j^\text{th}$ argument associated with $\tcode{U}_j$. \end{itemize} \indexlibrary{\idxcode{bind}}% @@ -14044,34 +14107,37 @@ \begin{itemdescr} \pnum \requires -\tcode{is_constructible_v} shall be \tcode{true}. For each \tcode{Ti} -in \tcode{BoundArgs}, \tcode{is_cons\-tructible_v} shall be \tcode{true}. -\tcode{\textit{INVOKE} (fd, w1, w2, ..., -wN)}~(\ref{func.require}) shall be a valid expression for some -values \textit{w1, w2, ..., wN}, where -\tcode{N == sizeof...(bound_args)}. +\tcode{is_constructible_v} shall be \tcode{true}. For each $\tcode{T}_i$ +in \tcode{BoundArgs}, \tcode{is_cons\-tructible_v<$\tcode{TD}_i$, $\tcode{T}_i$>} shall be \tcode{true}. +\tcode{\placeholdernc{INVOKE}(fd, $\tcode{w}_1$, $\tcode{w}_2$, \ldots, +$\tcode{w}_N$)}~(\ref{func.require}) shall be a valid expression for some +values $\tcode{w}_1$, $\tcode{w}_2$, \ldots, $\tcode{w}_N$, where +$N$ has the value \tcode{sizeof...(bound_args)}. The cv-qualifiers \cv{} of the call wrapper \tcode{g}, as specified below, shall be neither \tcode{volatile} nor \tcode{const volatile}. \pnum\returns A forwarding call wrapper \tcode{g}~(\ref{func.require}). -The effect of \tcode{g(u1, u2, ..., uM)} shall -be \tcode{\textit{INVOKE}(fd, std::forward(v1), std::forward(v2), ..., std::forward(vN))}, +The effect of \tcode{g($\tcode{u}_1$, $\tcode{u}_2$, \ldots, $\tcode{u}_M$)} shall +be +\begin{codeblock} +@\placeholdernc{INVOKE}@(fd, std::forward<@$\tcode{V}_1$@>(@$\tcode{v}_1$@), std::forward<@$\tcode{V}_2$@>(@$\tcode{v}_2$@), @\ldots @, std::forward<@$\tcode{V}_N$@>(@$\tcode{v}_N$@)) +\end{codeblock} where the values and types of the bound -arguments \tcode{v1, v2, ..., vN} are determined as specified below. +arguments $\tcode{v}_1$, $\tcode{v}_2$, \ldots, $\tcode{v}_N$ are determined as specified below. The copy constructor and move constructor of the forwarding call wrapper shall throw an exception if and only if the corresponding constructor of \tcode{FD} or of any of the types -\tcode{TiD} throws an exception. +$\tcode{TD}_i$ throws an exception. \pnum \throws Nothing unless the construction of -\tcode{fd} or of one of the values \tcode{tid} throws an exception. +\tcode{fd} or of one of the values $\tcode{td}_i$ throws an exception. \pnum \remarks The return type shall satisfy the requirements of \tcode{MoveConstructible}. If all -of \tcode{FD} and \tcode{TiD} satisfy the requirements of \tcode{CopyConstructible}, then the +of \tcode{FD} and $\tcode{TD}_i$ satisfy the requirements of \tcode{CopyConstructible}, then the return type shall satisfy the requirements of \tcode{CopyConstructible}. \begin{note} This implies -that all of \tcode{FD} and \tcode{TiD} are \tcode{MoveConstructible}. \end{note} +that all of \tcode{FD} and $\tcode{TD}_i$ are \tcode{MoveConstructible}. \end{note} \end{itemdescr} \indexlibrary{\idxcode{bind}}% @@ -14083,12 +14149,12 @@ \begin{itemdescr} \pnum \requires -\tcode{is_constructible_v} shall be \tcode{true}. For each \tcode{Ti} -in \tcode{BoundArgs}, \tcode{is_con\-structible_v} shall be \tcode{true}. -\tcode{\textit{INVOKE}(fd, w1, w2, ..., wN)} shall be a valid +\tcode{is_constructible_v} shall be \tcode{true}. For each $\tcode{T}_i$ +in \tcode{BoundArgs}, \tcode{is_con\-structible_v<$\tcode{TD}_i$, $\tcode{T}_i$>} shall be \tcode{true}. +\tcode{\placeholdernc{INVOKE}(fd, $\tcode{w}_1$, $\tcode{w}_2$, \ldots, $\tcode{w}_N$)} shall be a valid expression for some -values \textit{w1, w2, ..., wN}, where -\tcode{N == sizeof...(bound_args)}. +values $\tcode{w}_1$, $\tcode{w}_2$, \ldots, $\tcode{w}_N$, where +$N$ has the value \tcode{sizeof...(bound_args)}. The cv-qualifiers \cv{} of the call wrapper \tcode{g}, as specified below, shall be neither \tcode{volatile} nor \tcode{const volatile}. @@ -14096,50 +14162,53 @@ \returns A forwarding call wrapper \tcode{g}~(\ref{func.require}). The effect of -\tcode{g(u1, u2, ..., uM)} shall be \tcode{\textit{INVOKE}(fd, -std::forward(v1), std::forward(v2), ..., -std::forward(vN), R)}, where the values and types of the bound -arguments \tcode{v1, v2, ..., vN} are determined as specified below. +\tcode{g($\tcode{u}_1$, $\tcode{u}_2$, \ldots, $\tcode{u}_M$)} shall be +\begin{codeblock} +@\placeholdernc{INVOKE}@(fd, std::forward<@$\tcode{V}_1$@>(@$\tcode{v}_1$@), std::forward<@$\tcode{V}_2$@>(@$\tcode{v}_2$@), @\ldots @, std::forward<@$\tcode{V}_N$@>(@$\tcode{v}_N$@), R) +\end{codeblock} +where the values and types of the bound +arguments $\tcode{v}_1$, $\tcode{v}_2$, \ldots, $\tcode{v}_N$ are determined as specified below. The copy constructor and move constructor of the forwarding call wrapper shall throw an exception if and only if the corresponding constructor of \tcode{FD} or of any of the types -\tcode{TiD} throws an exception. +$\tcode{TD}_i$ throws an exception. \pnum \throws Nothing unless the construction of -\tcode{fd} or of one of the values \tcode{tid} throws an exception. +\tcode{fd} or of one of the values $\tcode{td}_i$ throws an exception. \pnum \remarks The return type shall satisfy the requirements of \tcode{MoveConstructible}. If all -of \tcode{FD} and \tcode{TiD} satisfy the requirements of \tcode{CopyConstructible}, then the +of \tcode{FD} and $\tcode{TD}_i$ satisfy the requirements of \tcode{CopyConstructible}, then the return type shall satisfy the requirements of \tcode{CopyConstructible}. \begin{note} This implies -that all of \tcode{FD} and \tcode{TiD} are \tcode{MoveConstructible}. \end{note} +that all of \tcode{FD} and $\tcode{TD}_i$ are \tcode{MoveConstructible}. \end{note} \end{itemdescr} \pnum \indextext{bound arguments}% -The values of the \techterm{bound arguments} \tcode{v1, v2, ..., vN} and their -corresponding types \tcode{V1, V2, ..., VN} depend on the -types \tcode{TiD} derived from +The values of the \techterm{bound arguments} $\tcode{v}_1$, $\tcode{v}_2$, \ldots, $\tcode{v}_N$ and their +corresponding types $\tcode{V}_1$, $\tcode{V}_2$, \ldots, $\tcode{V}_N$ depend on the +types $\tcode{TD}_i$ derived from the call to \tcode{bind} and the cv-qualifiers \cv{} of the call wrapper \tcode{g} as follows: \begin{itemize} -\item if \tcode{TiD} is \tcode{reference_wrapper}, the -argument is \tcode{tid.get()} and its type \tcode{Vi} is \tcode{T\&}; +\item if $\tcode{TD}_i$ is \tcode{reference_wrapper}, the +argument is \tcode{$\tcode{td}_i$.get()} and its type $\tcode{V}_i$ is \tcode{T\&}; -\item if the value of \tcode{is_bind_expression_v} -is \tcode{true}, the argument is \tcode{tid(std::forward(\brk{}uj)...)} and its -type \tcode{Vi} is -\tcode{result_of_t\&\&}; +\item if the value of \tcode{is_bind_expression_v<$\tcode{TD}_i$>} +is \tcode{true}, the argument is \tcode{$\tcode{td}_i$(std::forward<$\tcode{U}_j$>($\tcode{u}_j$)...)} and its +type $\tcode{V}_i$ is +\tcode{result_of_t<$\tcode{TD}_i$ \cv{} \& ($\tcode{U}_j$\&\&...)>\&\&}; -\item if the value \tcode{j} of \tcode{is_placeholder_v} -is not zero, the argument is \tcode{std::forward(uj)} -and its type \tcode{Vi} -is \tcode{Uj\&\&}; +\item if the value \tcode{j} of \tcode{is_placeholder_v<$\tcode{TD}_i$>} +is not zero, the argument is \tcode{std::forward<$\tcode{U}_j$>($\tcode{u}_j$)} +and its type $\tcode{V}_i$ +is \tcode{$\tcode{U}_j$\&\&}; -\item otherwise, the value is \tcode{tid} and its type \tcode{Vi} -is \tcode{TiD \cv{} \&}. +\item otherwise, the value is $\tcode{td}_i$ and its type $\tcode{V}_i$ +is \tcode{$\tcode{TD}_i$ \cv{} \&}. \end{itemize} +\indexlibrary{\idxcode{bind}|)}% \rSec3[func.bind.place]{Placeholders} @@ -14163,9 +14232,7 @@ constructors shall not throw exceptions. It is \impldef{assignability of placeholder objects} whether placeholder types are \tcode{CopyAssignable}. \tcode{CopyAssignable} placeholders' copy -assignment operators shall not throw exceptions.% -\indexlibrary{\idxcode{bind}|)}% -\indextext{function object!binders|)} +assignment operators shall not throw exceptions. \pnum Placeholders should be defined as: @@ -14175,7 +14242,8 @@ If they are not, they shall be declared as: \begin{codeblock} extern @\unspec@ _1; -\end{codeblock} +\end{codeblock}% +\indextext{function object!binders|)} \rSec2[func.memfn]{Function template \tcode{mem_fn}}% \indextext{function object!\idxcode{mem_fn}|(} @@ -14541,7 +14609,7 @@ exception thrown by the wrapped callable object. \end{itemdescr} -\rSec4[func.wrap.func.targ]{function target access} +\rSec4[func.wrap.func.targ]{\tcode{function} target access} \indexlibrarymember{target_type}{function}% \begin{itemdecl} @@ -14564,7 +14632,7 @@ a pointer to the stored function target; otherwise a null pointer. \end{itemdescr} -\rSec4[func.wrap.func.nullptr]{null pointer comparison operators} +\rSec4[func.wrap.func.nullptr]{null pointer comparison functions} \indexlibrarymember{operator==}{function}% \begin{itemdecl} @@ -14607,7 +14675,7 @@ \pnum This subclause provides function object types (\ref{function.objects}) for -operations that search for a sequence \range{pat_first}{pat_last} in another +operations that search for a sequence \range{pat\textunderscore\nobreak first}{pat_last} in another sequence \range{first}{last} that is provided to the object's function call operator. The first sequence (the pattern to be searched for) is provided to the object's constructor, and the second (the sequence to be searched) is @@ -14640,20 +14708,20 @@ \indexlibrary{\idxcode{default_searcher}}% \begin{codeblock} template > -class default_searcher { -public: - default_searcher(ForwardIterator1 pat_first, ForwardIterator1 pat_last, - BinaryPredicate pred = BinaryPredicate()); + class default_searcher { + public: + default_searcher(ForwardIterator1 pat_first, ForwardIterator1 pat_last, + BinaryPredicate pred = BinaryPredicate()); - template - pair - operator()(ForwardIterator2 first, ForwardIterator2 last) const; + template + pair + operator()(ForwardIterator2 first, ForwardIterator2 last) const; -private: - ForwardIterator1 pat_first_; // \expos - ForwardIterator1 pat_last_; // \expos - BinaryPredicate pred_; // \expos -}; + private: + ForwardIterator1 pat_first_; // \expos + ForwardIterator1 pat_last_; // \expos + BinaryPredicate pred_; // \expos + }; \end{codeblock} \indexlibrary{\idxcode{default_searcher}!constructor}% @@ -14720,44 +14788,48 @@ template ::value_type>, class BinaryPredicate = equal_to<>> -class boyer_moore_searcher { -public: - boyer_moore_searcher(RandomAccessIterator1 pat_first, - RandomAccessIterator1 pat_last, Hash hf = Hash(), - BinaryPredicate pred = BinaryPredicate()); + class boyer_moore_searcher { + public: + boyer_moore_searcher(RandomAccessIterator1 pat_first, + RandomAccessIterator1 pat_last, + Hash hf = Hash(), + BinaryPredicate pred = BinaryPredicate()); - template - pair - operator()(RandomAccessIterator2 first, - RandomAccessIterator2 last) const; + template + pair + operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const; -private: - RandomAccessIterator1 pat_first_; // \expos - RandomAccessIterator1 pat_last_; // \expos - Hash hash_; // \expos - BinaryPredicate pred_; // \expos -}; + private: + RandomAccessIterator1 pat_first_; // \expos + RandomAccessIterator1 pat_last_; // \expos + Hash hash_; // \expos + BinaryPredicate pred_; // \expos + }; \end{codeblock} \indexlibrary{\idxcode{boyer_moore_searcher}!constructor}% \begin{itemdecl} boyer_moore_searcher(RandomAccessIterator1 pat_first, - RandomAccessIterator1 pat_last, Hash hf = Hash(), + RandomAccessIterator1 pat_last, + Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate()); \end{itemdecl} \begin{itemdescr} \pnum \requires -The value type of \tcode{RandomAccessIterator1} shall meet the \tcode{DefaultConstructible} requirements, the \tcode{CopyConstructible} requirements, and the \tcode{CopyAssignable} requirements. +The value type of \tcode{RandomAccessIterator1} shall meet the \tcode{DefaultConstructible} requirements, +the \tcode{CopyConstructible} requirements, and the \tcode{CopyAssignable} requirements. \pnum \requires -For any two values \tcode{A} and \tcode{B} of the type \tcode{iterator_traits::value_type}, if \tcode{pred(A,B)==true}, then \tcode{hf(A)==hf(B)} shall be \tcode{true}. +For any two values \tcode{A} and \tcode{B} of the type \tcode{iterator_traits::val\-ue_type}, +if \tcode{pred(A, B) == true}, then \tcode{hf(A) == hf(B)} shall be \tcode{true}. \pnum \effects -Constructs a \tcode{boyer_moore_searcher} object, initializing \tcode{pat_first_} with \tcode{pat_first}, \tcode{pat_last_} with \tcode{pat_last}, \tcode{hash_} with \tcode{hf}, and \tcode{pred_} with \tcode{pred}. +Constructs a \tcode{boyer_moore_searcher} object, initializing \tcode{pat_first_} with \tcode{pat_first}, +\tcode{pat_last_} with \tcode{pat_last}, \tcode{hash_} with \tcode{hf}, and \tcode{pred_} with \tcode{pred}. \pnum \throws @@ -14811,7 +14883,8 @@ class BinaryPredicate = equal_to<>> boyer_moore_searcher make_boyer_moore_searcher(RandomAccessIterator pat_first, - RandomAccessIterator pat_last, Hash hf = Hash(), + RandomAccessIterator pat_last, + Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate()); \end{itemdecl} @@ -14821,7 +14894,7 @@ Equivalent to: \begin{codeblock} return boyer_moore_searcher( - pat_first, pat_last, hf, pred); + pat_first, pat_last, hf, pred); \end{codeblock} \end{itemdescr} @@ -14832,42 +14905,43 @@ template ::value_type>, class BinaryPredicate = equal_to<>> -class boyer_moore_horspool_searcher { -public: - boyer_moore_horspool_searcher(RandomAccessIterator1 pat_first, - RandomAccessIterator1 pat_last, - Hash hf = Hash(), - BinaryPredicate pred = BinaryPredicate()); + class boyer_moore_horspool_searcher { + public: + boyer_moore_horspool_searcher(RandomAccessIterator1 pat_first, + RandomAccessIterator1 pat_last, + Hash hf = Hash(), + BinaryPredicate pred = BinaryPredicate()); - template - pair - operator()(RandomAccessIterator2 first, - RandomAccessIterator2 last) const; + template + pair + operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const; -private: - RandomAccessIterator1 pat_first_; // \expos - RandomAccessIterator1 pat_last_; // \expos - Hash hash_; // \expos - BinaryPredicate pred_; // \expos -}; + private: + RandomAccessIterator1 pat_first_; // \expos + RandomAccessIterator1 pat_last_; // \expos + Hash hash_; // \expos + BinaryPredicate pred_; // \expos + }; \end{codeblock} \indexlibrary{\idxcode{boyer_moore_horspool_searcher}!constructor}% \begin{itemdecl} boyer_moore_horspool_searcher(RandomAccessIterator1 pat_first, - RandomAccessIterator1 pat_last, Hash hf = Hash(), + RandomAccessIterator1 pat_last, + Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate()); \end{itemdecl} \begin{itemdescr} \pnum \requires -The value type of \tcode{RandomAccessIterator1} shall meet the \tcode{DefaultConstructible}, \tcode{Copy\-Constructible}, and \tcode{CopyAssignable} requirements. +The value type of \tcode{RandomAccessIterator1} shall meet the \tcode{DefaultConstructible}, +\tcode{Copy\-Constructible}, and \tcode{CopyAssignable} requirements. \pnum \requires -For any two values \tcode{A} and \tcode{B} of the type \tcode{iterator_traits::value_type}, -if \tcode{pred(A,B)==true}, then \tcode{hf(A)==hf(B)} shall be \tcode{true}. +For any two values \tcode{A} and \tcode{B} of the type \tcode{iterator_traits::val\-ue_type}, +if \tcode{pred(A, B) == true}, then \tcode{hf(A) == hf(B)} shall be \tcode{true}. \pnum \effects @@ -14925,19 +14999,19 @@ class Hash = hash::value_type>, class BinaryPredicate = equal_to<>> boyer_moore_horspool_searcher - make_boyer_moore_horspool_searcher( - RandomAccessIterator pat_first, RandomAccessIterator pat_last, - Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate()); + make_boyer_moore_horspool_searcher(RandomAccessIterator pat_first, + RandomAccessIterator pat_last, + Hash hf = Hash(), + BinaryPredicate pred = BinaryPredicate()); \end{itemdecl} \begin{itemdescr} - \pnum \effects Equivalent to: \begin{codeblock} return boyer_moore_horspool_searcher( - pat_first, pat_last, hf, pred); + pat_first, pat_last, hf, pred); \end{codeblock} \end{itemdescr} @@ -14947,7 +15021,8 @@ \indexlibrary{\idxcode{hash}}% \indextext{\idxcode{hash}!instantiation restrictions}% The unordered associative containers defined in \ref{unord} use -specializations of the class template \tcode{hash} as the default hash function. +specializations of the class template \tcode{hash} (\ref{functional.syn}) +as the default hash function. \pnum Each specialization of \tcode{hash} is either enabled or disabled, @@ -15064,13 +15139,13 @@ property being described. It shall be \tcode{DefaultConstructible}, \tcode{CopyConstructible}, and publicly and unambiguously derived, directly or indirectly, from -its \defn{BaseCharacteristic}, which is +its \defn{base characteristic}, which is a specialization of the template \tcode{integral_constant}~(\ref{meta.help}), with the arguments to the template \tcode{integral_constant} determined by the requirements for the particular property being described. -The member names of the BaseCharacteristic shall not be hidden and shall be -unambiguously available in the UnaryTypeTrait. +The member names of the base characteristic shall not be hidden and shall be +unambiguously available in the \tcode{UnaryTypeTrait}. \pnum A \defn{BinaryTypeTrait} describes a @@ -15080,13 +15155,13 @@ be \tcode{DefaultConstructible}, \tcode{CopyConstructible}, and publicly and unambiguously derived, directly or indirectly, from -its \term{BaseCharacteristic}, which is a specialization +its \term{base characteristic}, which is a specialization of the template \tcode{integral_constant}~(\ref{meta.help}), with the arguments to the template \tcode{integral_constant} determined by the requirements for the particular relationship being described. -The member names of the BaseCharacteristic shall not be hidden and shall be -unambiguously available in the BinaryTypeTrait. +The member names of the base characteristic shall not be hidden and shall be +unambiguously available in the \tcode{BinaryTypeTrait}. \pnum A \defn{TransformationTrait} @@ -15096,8 +15171,10 @@ define the modification. It shall define a publicly accessible nested type named \tcode{type}, which shall be a synonym for the modified type. -\indexlibrary{\idxhdr{type_traits}}% \rSec2[meta.type.synop]{Header \tcode{} synopsis} + +\indextext{\idxhdr{type_traits}}% +\indexlibrary{\idxhdr{type_traits}}% \begin{codeblock} namespace std { // \ref{meta.help}, helper class @@ -15203,7 +15280,7 @@ template struct is_callable; // not defined template struct is_callable; - + template struct is_nothrow_callable; // not defined template struct is_nothrow_callable; @@ -15271,7 +15348,7 @@ // \ref{meta.trans.other}, other transformations template // see \ref{meta.trans.other} - struct aligned_storage; + struct aligned_storage; template struct aligned_union; template struct decay; template struct enable_if; @@ -15297,7 +15374,7 @@ template using underlying_type_t = typename underlying_type::type; template - using result_of_t = typename result_of::type; + using result_of_t = typename result_of::type; template using void_t = void; @@ -15508,8 +15585,8 @@ \pnum Each of these templates shall be a -UnaryTypeTrait~(\ref{meta.rqmts}) -with a BaseCharacteristic of +\tcode{UnaryTypeTrait}~(\ref{meta.rqmts}) +with a base characteristic of \tcode{true_type} if the corresponding condition is \tcode{true}, otherwise \tcode{false_type}. @@ -15521,7 +15598,7 @@ \pnum For any given type \tcode{T}, the result of applying one of these templates to -\tcode{T} and to \cv{} \tcode{T} shall yield the same result. +\tcode{T} and to \cv{}~\tcode{T} shall yield the same result. \pnum \begin{note} @@ -15607,7 +15684,7 @@ \pnum For any given type \tcode{T}, the result of applying one of these templates to -\tcode{T} and to \cv{} \tcode{T} shall yield the same result. +\tcode{T} and to \cv{}~\tcode{T} shall yield the same result. \begin{libreqtab3b}{Composite type category predicates}{tab:type-traits.composite} \\ \topline @@ -15698,28 +15775,28 @@ \tcode{struct is_trivial;} & \tcode{T} is a trivial type~(\ref{basic.types}) & \tcode{remove_all_extents_t} shall be a complete - type or (possibly cv-qualified) \tcode{void}. \\ \rowsep + type or \cv{}~\tcode{void}. \\ \rowsep \indexlibrary{\idxcode{is_trivially_copyable}}% \tcode{template }\br \tcode{struct is_trivially_copyable;} & \tcode{T} is a trivially copyable type~(\ref{basic.types}) & \tcode{remove_all_extents_t} shall be a complete type or - (possibly cv-qualified) \tcode{void}. \\ \rowsep + \cv{}~\tcode{void}. \\ \rowsep \indexlibrary{\idxcode{is_standard_layout}}% \tcode{template }\br \tcode{struct is_standard_layout;} & \tcode{T} is a standard-layout type~(\ref{basic.types}) & \tcode{remove_all_extents_t} shall be a complete - type or (possibly cv-qualified) \tcode{void}. \\ \rowsep + type or \cv{}~\tcode{void}. \\ \rowsep \indexlibrary{\idxcode{is_pod}}% \tcode{template }\br \tcode{struct is_pod;} & \tcode{T} is a POD type~(\ref{basic.types}) & \tcode{remove_all_extents_t} shall be a complete - type or (possibly cv-qualified) \tcode{void}. \\ \rowsep + type or \cv{}~\tcode{void}. \\ \rowsep \indexlibrary{\idxcode{is_empty}!class}% \tcode{template }\br @@ -15768,18 +15845,18 @@ \tcode{template }\br \tcode{struct is_constructible;} & For a function type \tcode{T} or - for a (possibly cv-qualified) \tcode{void} type \tcode{T}, + for a \cv{}~\tcode{void} type \tcode{T}, \tcode{is_constructible_v} is \tcode{false}, otherwise \seebelow & \tcode{T} and all types in the parameter pack \tcode{Args} - shall be complete types, (possibly cv-qualified) \tcode{void}, + shall be complete types, \cv{}~\tcode{void}, or arrays of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_default_constructible}}% \tcode{template }\br \tcode{struct is_default_constructible;} & \tcode{is_constructible_v} is \tcode{true}. & - \tcode{T} shall be a complete type, (possibly cv-qualified) \tcode{void}, + \tcode{T} shall be a complete type, \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_copy_constructible}}% @@ -15787,7 +15864,7 @@ \tcode{struct is_copy_constructible;} & For a referenceable type \tcode{T} (\ref{defns.referenceable}), the same result as \tcode{is_constructible_v}, otherwise \tcode{false}. & - \tcode{T} shall be a complete type, (possibly cv-qualified) \tcode{void}, + \tcode{T} shall be a complete type, \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_move_constructible}}% @@ -15795,7 +15872,7 @@ \tcode{struct is_move_constructible;} & For a referenceable type \tcode{T}, the same result as \tcode{is_constructible_v}, otherwise \tcode{false}. & - \tcode{T} shall be a complete type, (possibly cv-qualified) \tcode{void}, + \tcode{T} shall be a complete type, \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_assignable}}% @@ -15810,7 +15887,7 @@ specializations and function template specializations, the generation of implicitly-defined functions, and so on. Such side effects are not in the ``immediate context'' and can result in the program being ill-formed. \end{note} & - \tcode{T} and \tcode{U} shall be complete types, (possibly cv-qualified) \tcode{void}, + \tcode{T} and \tcode{U} shall be complete types, \cv{}~\tcode{void}, or arrays of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_copy_assignable}}% @@ -15818,7 +15895,7 @@ \tcode{struct is_copy_assignable;} & For a referenceable type \tcode{T}, the same result as \tcode{is_assignable_v}, otherwise \tcode{false}. & - \tcode{T} shall be a complete type, (possibly cv-qualified) \tcode{void}, + \tcode{T} shall be a complete type, \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_move_assignable}}% @@ -15826,7 +15903,7 @@ \tcode{struct is_move_assignable;} & For a referenceable type \tcode{T}, the same result as \tcode{is_assignable_v}, otherwise \tcode{false}. & - \tcode{T} shall be a complete type, (possibly cv-qualified) \tcode{void}, + \tcode{T} shall be a complete type, \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_swappable_with}}% @@ -15850,7 +15927,7 @@ can result in the program being ill-formed. \end{note} & \tcode{T} and \tcode{U} shall be complete types, - (possibly cv-qualified) \tcode{void}, or + \cv{}~\tcode{void}, or arrays of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_swappable}}% @@ -15860,7 +15937,7 @@ the same result as \tcode{is_swappable_with_v}, otherwise \tcode{false}. & \tcode{T} shall be a complete type, - (possibly cv-qualified) \tcode{void}, or + \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_destructible}}% @@ -15874,7 +15951,7 @@ when treated as an unevaluated operand (Clause \ref{expr}), where \tcode{U} is \tcode{remove_all_extents}. & - \tcode{T} shall be a complete type, (possibly cv-qualified) \tcode{void}, + \tcode{T} shall be a complete type, \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_trivially_constructible}}% @@ -15884,16 +15961,16 @@ \tcode{is_constructible_v} is \tcode{true} and the variable definition for \tcode{is_constructible}, as defined below, is known to call - no operation that is not trivial (~\ref{basic.types},~\ref{special}). & + no operation that is not trivial~(\ref{basic.types},~\ref{special}). & \tcode{T} and all types in the parameter pack \tcode{Args} shall be complete types, - (possibly cv-qualified) \tcode{void}, or arrays of unknown bound. \\ \rowsep + \cv{}~\tcode{void}, or arrays of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_trivially_default_constructible}}% \tcode{template }\br \tcode{struct is_trivially_default_constructible;} & \tcode{is_trivially_constructible_v} is \tcode{true}. & \tcode{T} shall be a complete type, - (possibly cv-qualified) \tcode{void}, or an array of unknown + \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_trivially_copy_constructible}}% @@ -15902,7 +15979,7 @@ For a referenceable type \tcode{T}, the same result as \tcode{is_trivially_constructible_v}, otherwise \tcode{false}. & \tcode{T} shall be a complete type, - (possibly cv-qualified) \tcode{void}, or an array of unknown + \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_trivially_move_constructible}}% @@ -15911,7 +15988,7 @@ For a referenceable type \tcode{T}, the same result as \tcode{is_trivially_constructible_v}, otherwise \tcode{false}. & \tcode{T} shall be a complete type, - (possibly cv-qualified) \tcode{void}, or an array of unknown + \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_trivially_assignable}}% @@ -15920,7 +15997,7 @@ \tcode{is_assignable_v} is \tcode{true} and the assignment, as defined by \tcode{is_assignable}, is known to call no operation that is not trivial (\ref{basic.types},~\ref{special}). & - \tcode{T} and \tcode{U} shall be complete types, (possibly cv-qualified) \tcode{void}, + \tcode{T} and \tcode{U} shall be complete types, \cv{}~\tcode{void}, or arrays of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_trivially_copy_assignable}}% @@ -15929,7 +16006,7 @@ For a referenceable type \tcode{T}, the same result as \tcode{is_trivially_assignable_v}, otherwise \tcode{false}. & \tcode{T} shall be a complete type, - (possibly cv-qualified) \tcode{void}, or an array of unknown + \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_trivially_move_assignable}}% @@ -15938,7 +16015,7 @@ For a referenceable type \tcode{T}, the same result as \tcode{is_trivially_assignable_v}, otherwise \tcode{false}. & \tcode{T} shall be a complete type, - (possibly cv-qualified) \tcode{void}, or an array of unknown bound. \\ \rowsep + \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_trivially_destructible}}% \tcode{template }\br @@ -15946,7 +16023,7 @@ \tcode{is_destructible_v} is \tcode{true} and the indicated destructor is known to be trivial. & \tcode{T} shall be a complete type, - (possibly cv-qualified) \tcode{void}, or an array of unknown + \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_nothrow_constructible}}% @@ -15958,7 +16035,7 @@ throw any exceptions~(\ref{expr.unary.noexcept}). & \tcode{T} and all types in the parameter pack \tcode{Args} - shall be complete types, (possibly cv-qualified) \tcode{void}, + shall be complete types, \cv{}~\tcode{void}, or arrays of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_nothrow_default_constructible}}% @@ -15966,7 +16043,7 @@ \tcode{struct is_nothrow_default_constructible;} & \tcode{is_nothrow_constructible_v} is \tcode{true}. & \tcode{T} shall be a complete type, - (possibly cv-qualified) \tcode{void}, or an array of unknown + \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_nothrow_copy_constructible}}% @@ -15975,7 +16052,7 @@ For a referenceable type \tcode{T}, the same result as \tcode{is_nothrow_constructible_v}, otherwise \tcode{false}. & \tcode{T} shall be a complete type, - (possibly cv-qualified) \tcode{void}, or an array of unknown + \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_nothrow_move_constructible}}% @@ -15984,14 +16061,14 @@ For a referenceable type \tcode{T}, the same result as \tcode{is_nothrow_constructible_v}, otherwise \tcode{false}. & \tcode{T} shall be a complete type, - (possibly cv-qualified) \tcode{void}, or an array of unknown bound. \\ \rowsep + \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_nothrow_assignable}}% \tcode{template }\br \tcode{struct is_nothrow_assignable;} & \tcode{is_assignable_v} is \tcode{true} and the assignment is known not to throw any exceptions~(\ref{expr.unary.noexcept}). & - \tcode{T} and \tcode{U} shall be complete types, (possibly cv-qualified) \tcode{void}, + \tcode{T} and \tcode{U} shall be complete types, \cv{}~\tcode{void}, or arrays of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_nothrow_copy_assignable}}% @@ -16000,7 +16077,7 @@ For a referenceable type \tcode{T}, the same result as \tcode{is_nothrow_assignable_v}, otherwise \tcode{false}. & \tcode{T} shall be a complete type, - (possibly cv-qualified) \tcode{void}, or an array of unknown + \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_nothrow_move_assignable}}% @@ -16009,7 +16086,7 @@ For a referenceable type \tcode{T}, the same result as \tcode{is_nothrow_assignable_v}, otherwise \tcode{false}. & \tcode{T} shall be a complete type, - (possibly cv-qualified) \tcode{void}, or an array of unknown + \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_nothrow_swappable_with}}% @@ -16020,7 +16097,7 @@ \tcode{is_swappable_with} is known not to throw any exceptions~(\ref{expr.unary.noexcept}). & \tcode{T} and \tcode{U} shall be complete types, - (possibly cv-qualified) \tcode{void}, or + \cv{}~\tcode{void}, or arrays of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_nothrow_swappable}}% @@ -16030,7 +16107,7 @@ the same result as \tcode{is_nothrow_swappable_with_v}, otherwise \tcode{false}. & \tcode{T} shall be a complete type, - (possibly cv-qualified) \tcode{void}, or + \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_nothrow_destructible}}% @@ -16039,7 +16116,7 @@ \tcode{is_destructible_v} is \tcode{true} and the indicated destructor is known not to throw any exceptions~(\ref{expr.unary.noexcept}). & \tcode{T} shall be a complete type, - (possibly cv-qualified) \tcode{void}, or an array of unknown + \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \indexlibrary{\idxcode{has_virtual_destructor}}% @@ -16054,7 +16131,7 @@ For an array type \tcode{T}, the same result as \tcode{has_unique_object_representations_v>}, otherwise \seebelow. & - \tcode{T} shall be a complete type, (possibly cv-qualified) \tcode{void}, or + \tcode{T} shall be a complete type, \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \end{libreqtab3b} @@ -16175,7 +16252,7 @@ \pnum Each of these templates shall be a \tcode{UnaryTypeTrait}~(\ref{meta.rqmts}) with a -\tcode{BaseCharacteristic} of \tcode{integral_constant}. +base characteristic of \tcode{integral_constant}. \pnum \begin{example} @@ -16190,7 +16267,7 @@ \pnum \begin{example} \begin{codeblock} - // the following assertions hold: +// the following assertions hold: assert(extent_v == 0); assert(extent_v == 2); assert(extent_v == 2); @@ -16210,8 +16287,8 @@ \pnum Each of these templates shall be a -BinaryTypeTrait~(\ref{meta.rqmts}) -with a BaseCharacteristic of +\tcode{BinaryTypeTrait}~(\ref{meta.rqmts}) +with a base characteristic of \tcode{true_type} if the corresponding condition is true, otherwise \tcode{false_type}. @@ -16249,7 +16326,7 @@ \seebelow & \tcode{From} and \tcode{To} shall be complete types, arrays of unknown - bound, or (possibly cv-qualified) \tcode{void} types. \\ \rowsep + bound, or \cv{}~\tcode{void} types. \\ \rowsep \indexlibrary{\idxcode{is_callable}}% \tcode{template }\br @@ -16258,7 +16335,7 @@ The expression \tcode{\textit{INVOKE}(declval(), declval()..., R)} is well formed when treated as an unevaluated operand & \tcode{Fn}, \tcode{R}, and all types in the parameter pack \tcode{ArgTypes} - shall be complete types, (possibly cv-qualified) \tcode{void}, or + shall be complete types, \cv{}~\tcode{void}, or arrays of unknown bound. \\ \rowsep \indexlibrary{\idxcode{is_nothrow_callable}}% @@ -16269,7 +16346,7 @@ the expression \tcode{\textit{INVOKE}(declval(), declval()..., R)} is known not to throw any exceptions & \tcode{Fn}, \tcode{R}, and all types in the parameter pack \tcode{ArgTypes} - shall be complete types, (possibly cv-qualified) \tcode{void}, or + shall be complete types, \cv{}~\tcode{void}, or arrays of unknown bound. \\ \end{libreqtab3f} @@ -16313,11 +16390,11 @@ \end{codeblock} \begin{note} This requirement gives well defined results for reference types, void -types, array types, and function types.\end{note} Access checking is performed as -if in a context unrelated to \tcode{To} and \tcode{From}. Only the validity of -the immediate context of the expression of the \grammarterm{return-statement} -(including conversions to the return type) is considered. \begin{note} The -evaluation of the conversion can result in side effects such as the +types, array types, and function types.\end{note} Access checking is performed +in a context unrelated to \tcode{To} and \tcode{From}. Only the validity of +the immediate context of the \grammarterm{expression} of the \tcode{return} statement +(including initialization of the returned object or reference) is considered. \begin{note} The +initialization can result in side effects such as the instantiation of class template specializations and function template specializations, the generation of implicitly-defined functions, and so on. Such side effects are not in the ``immediate context'' and can result in the program @@ -16330,7 +16407,7 @@ \pnum Each of the templates in this subclause shall be a -\term{TransformationTrait}~(\ref{meta.rqmts}). +\tcode{TransformationTrait}~(\ref{meta.rqmts}). \rSec3[meta.trans.cv]{Const-volatile modifications} @@ -16553,7 +16630,7 @@ \tcode{template \br struct add_pointer;} & If \tcode{T} names a referenceable type (\ref{defns.referenceable}) or a - (possibly cv-qualified) \tcode{void} type then + \cv{}~\tcode{void} type then the member typedef \tcode{type} shall name the same type as \tcode{remove_reference_t*}; otherwise, \tcode{type} shall name \tcode{T}. \\ @@ -16634,7 +16711,7 @@ the member \tcode{type} shall be defined or omitted as specified in Note A, below. If it is omitted, there shall be no member \tcode{type}. Each type in the parameter pack \tcode{T} shall be - complete, \tcode{void}, or an array of unknown bound. \\ \rowsep + complete, \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep \indexlibrary{\idxcode{underlying_type}}% \tcode{template }\br @@ -16665,7 +16742,7 @@ context'' and can result in the program being ill-formed. \end{note} \br \requires{} \tcode{Fn} and all types in the parameter pack \tcode{ArgTypes} shall - be complete types, (possibly cv-qualified) \tcode{void}, or arrays of + be complete types, \cv{}~\tcode{void}, or arrays of unknown bound.\\ \end{libreqtab2a} @@ -16822,10 +16899,10 @@ The specialization \tcode{conjunction} has a public and unambiguous base that is either \begin{itemize} -\item +\item the first type \tcode{Bi} in the list \tcode{true_type, B1, ..., BN} for which \tcode{bool(Bi::value)} is \tcode{false}, or -\item +\item if there is no such \tcode{Bi}, the last type in the list. \end{itemize} \begin{note} This means a specialization of \tcode{conjunction} @@ -16896,7 +16973,7 @@ The class template \tcode{negation} forms the logical negation of its template type argument. The type \tcode{negation} -is a UnaryTypeTrait with a BaseCharacteristic of \tcode{bool_constant}. +is a \tcode{UnaryTypeTrait} with a base characteristic of \tcode{bool_constant}. \end{itemdescr} \rSec1[ratio]{Compile-time rational arithmetic} @@ -16916,9 +16993,10 @@ and the template argument is not a specialization of the \tcode{ratio} template, the program is ill-formed. -\indexlibrary{\idxhdr{ratio}}% \rSec2[ratio.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{ratio}}% +\indexlibrary{\idxhdr{ratio}}% \begin{codeblockdigitsep} namespace std { // \ref{ratio.ratio}, class template \tcode{ratio} @@ -16938,6 +17016,19 @@ template struct ratio_greater; template struct ratio_greater_equal; + template + constexpr bool ratio_equal_v = ratio_equal::value; + template + constexpr bool ratio_not_equal_v = ratio_not_equal::value; + template + constexpr bool ratio_less_v = ratio_less::value; + template + constexpr bool ratio_less_equal_v = ratio_less_equal::value; + template + constexpr bool ratio_greater_v = ratio_greater::value; + template + constexpr bool ratio_greater_equal_v = ratio_greater_equal::value; + // \ref{ratio.si}, convenience SI typedefs using yocto = ratio<1, 1'000'000'000'000'000'000'000'000>; // see below using zepto = ratio<1, 1'000'000'000'000'000'000'000>; // see below @@ -16959,20 +17050,6 @@ using exa = ratio< 1'000'000'000'000'000'000, 1>; using zetta = ratio< 1'000'000'000'000'000'000'000, 1>; // see below using yotta = ratio<1'000'000'000'000'000'000'000'000, 1>; // see below - - // \ref{ratio.arithmetic}, ratio comparison - template constexpr bool ratio_equal_v - = ratio_equal::value; - template constexpr bool ratio_not_equal_v - = ratio_not_equal::value; - template constexpr bool ratio_less_v - = ratio_less::value; - template constexpr bool ratio_less_equal_v - = ratio_less_equal::value; - template constexpr bool ratio_greater_v - = ratio_greater::value; - template constexpr bool ratio_greater_equal_v - = ratio_greater_equal::value; } \end{codeblockdigitsep} @@ -17083,20 +17160,20 @@ \indexlibrary{\idxcode{ratio_equal}}% \begin{itemdecl} -template struct ratio_equal - : bool_constant { }; +template + struct ratio_equal : bool_constant { }; \end{itemdecl} \indexlibrary{\idxcode{ratio_not_equal}}% \begin{itemdecl} -template struct ratio_not_equal - : bool_constant> { }; +template + struct ratio_not_equal : bool_constant> { }; \end{itemdecl} \indexlibrary{\idxcode{ratio_less}}% \begin{itemdecl} -template struct ratio_less - : bool_constant<@\seebelow@> { }; +template + struct ratio_less : bool_constant<@\seebelow@> { }; \end{itemdecl} \begin{itemdescr} @@ -17110,20 +17187,20 @@ \indexlibrary{\idxcode{ratio_less_equal}}% \begin{itemdecl} -template struct ratio_less_equal - : bool_constant> { }; +template + struct ratio_less_equal : bool_constant> { }; \end{itemdecl} \indexlibrary{\idxcode{ratio_greater}}% \begin{itemdecl} -template struct ratio_greater - : bool_constant> { }; +template + struct ratio_greater : bool_constant> { }; \end{itemdecl} \indexlibrary{\idxcode{ratio_greater_equal}}% \begin{itemdecl} -template struct ratio_greater_equal - : bool_constant> { }; +template + struct ratio_greater_equal : bool_constant> { }; \end{itemdecl} \rSec2[ratio.si]{SI types for \tcode{ratio}} @@ -17145,9 +17222,10 @@ functions~(\ref{ctime.syn}) that provide generally useful time utilities. -\indexlibrary{\idxhdr{chrono}}% \rSec2[time.syn]{Header \tcode{} synopsis} +\indextext{\idxhdr{chrono}}% +\indexlibrary{\idxhdr{chrono}}% \begin{codeblock} namespace std { namespace chrono { @@ -17306,7 +17384,7 @@ inline namespace literals { inline namespace chrono_literals { - // ~\ref{time.duration.literals}, suffixes for duration literals + // \ref{time.duration.literals}, suffixes for duration literals constexpr chrono::hours operator "" h(unsigned long long); constexpr chrono::duration<@\unspec,@ ratio<3600,1>> operator "" h(long double); constexpr chrono::minutes operator "" min(unsigned long long); @@ -17342,7 +17420,7 @@ before~(\ref{intro.multithread}) the call returning \tcode{t2} and both of these calls occur before \tcode{C1::time_point::max()}. -\begin{note} this means \tcode{C1} did not wrap around between \tcode{t1} and +\begin{note} This means \tcode{C1} did not wrap around between \tcode{t1} and \tcode{t2}. \end{note} \begin{libreqtab3a} @@ -17401,7 +17479,7 @@ \tcode{CopyCon\-structible} (Table~\ref{tab:copyconstructible}), \tcode{CopyAssignable} (Table~\ref{tab:copyassignable}), \tcode{Destructible} (Table~\ref{tab:destructible}), and the requirements of -numeric types~(\ref{numeric.requirements}). \begin{note} this means, in particular, +numeric types~(\ref{numeric.requirements}). \begin{note} This means, in particular, that operations on these types will not throw exceptions. \end{note} \item lvalues of the types \tcode{TC::rep}, \tcode{TC::duration}, and @@ -17591,31 +17669,26 @@ }; \end{codeblock} -\begin{itemdescr} -\pnum -\requires \tcode{Rep} shall be an arithmetic type or a class emulating an arithmetic type. - \pnum -\remarks If \tcode{duration} is instantiated with a \tcode{duration} type for the template -argument \tcode{Rep}, the program is ill-formed. +\tcode{Rep} shall be an arithmetic type or a class emulating an arithmetic type. +If \tcode{duration} is instantiated with a \tcode{duration} type as the argument for the template +parameter \tcode{Rep}, the program is ill-formed. \pnum -\remarks If \tcode{Period} is not a specialization of \tcode{ratio}, the program is ill-formed. +If \tcode{Period} is not a specialization of \tcode{ratio}, the program is ill-formed. +If \tcode{Period::num} is not positive, the program is ill-formed. \pnum -\remarks If \tcode{Period::num} is not positive, the program is ill-formed. - -\pnum -\requires Members of \tcode{duration} shall not throw exceptions other than +Members of \tcode{duration} shall not throw exceptions other than those thrown by the indicated operations on their representations. \pnum -\remarks The defaulted copy constructor of duration shall be a -\tcode{constexpr} function if and only if the required initialization +The defaulted copy constructor of duration shall be a +constexpr function if and only if the required initialization of the member \tcode{rep_} for copy and move, respectively, would -satisfy the requirements for a \tcode{constexpr} function. -\end{itemdescr} +satisfy the requirements for a constexpr function. +\pnum \begin{example} \begin{codeblock} duration> d0; // holds a count of minutes using a \tcode{long} @@ -18119,11 +18192,14 @@ \end{codeblock} \end{itemize} -\realnotes This function does not use any implicit conversions; all conversions +\pnum +\begin{note} +This function does not use any implicit conversions; all conversions are done with \tcode{static_cast}. It avoids multiplications and divisions when it is known at compile time that one or more arguments is 1. Intermediate computations are carried out in the widest representation and only converted to the destination representation at the final step. +\end{note} \end{itemdescr} \indexlibrarymember{floor}{duration}% @@ -18338,7 +18414,7 @@ \end{codeblock} \pnum -\tcode{Clock} shall meet the Clock requirements~(\ref{time.clock}). +\tcode{Clock} shall meet the Clock requirements~(\ref{time.clock.req}). \pnum If \tcode{Duration} is not an instance of \tcode{duration}, @@ -18765,6 +18841,7 @@ \rSec2[ctime.syn]{Header \tcode{} synopsis} \indextext{\idxhdr{ctime}}% +\indexlibrary{\idxhdr{ctime}}% \indexlibrary{\idxcode{CLOCKS_PER_SEC}}% \indexlibrary{\idxcode{NULL}}% \indexlibrary{\idxcode{TIME_UTC}}% @@ -18810,7 +18887,9 @@ \end{codeblock} \pnum +\indextext{\idxhdr{time.h}}% \indexlibrary{\idxhdr{time.h}}% +\indextext{\idxhdr{ctime}}% \indexlibrary{\idxhdr{ctime}}% The contents of the header \tcode{} are the same as the C standard library header \tcode{}.% \footnote{\tcode{strftime} supports the C conversion specifiers @@ -18827,9 +18906,10 @@ \rSec1[type.index]{Class \tcode{type_index}} -\indexlibrary{\idxhdr{typeindex}}% \rSec2[type.index.synopsis]{Header \tcode{} synopsis} +\indextext{\idxhdr{typeindex}}% +\indexlibrary{\idxhdr{typeindex}}% \begin{codeblock} namespace std { class type_index; @@ -18985,7 +19065,7 @@ \begin{example} \begin{codeblock} using namespace std; -vector v = ... +vector v = @\commentellip@; // standard sequential sort sort(v.begin(), v.end()); @@ -19007,8 +19087,10 @@ standard as extensions. \end{note} -\indexlibrary{\idxhdr{execution}}% \rSec2[execution.syn]{Header \tcode{} synopsis} + +\indextext{\idxhdr{execution}}% +\indexlibrary{\idxhdr{execution}}% \begin{codeblock} namespace std { // \ref{execpol.type}, execution policy type trait @@ -19047,8 +19129,8 @@ resolution participation. \pnum -\tcode{is_execution_policy} shall be a UnaryTypeTrait with a -BaseCharacteristic of \tcode{true_type} if \tcode{T} is the type of a standard +\tcode{is_execution_policy} shall be a \tcode{UnaryTypeTrait} with a +base characteristic of \tcode{true_type} if \tcode{T} is the type of a standard or \impldef{additional execution policies supported by parallel algorithms} execution policy, otherwise \tcode{false_type}.