diff --git a/papers/d4661.md b/papers/d4661.md deleted file mode 100644 index 3a5a75ad59..0000000000 --- a/papers/d4661.md +++ /dev/null @@ -1,331 +0,0 @@ -# N4639 Editors' Report -- Programming Languages -- C++ - -2017-03-17 -Richard Smith (editor) (Google Inc) -Dawn Perchik (co-editor) (Embarcadero Technologies Inc) -Thomas Köppe (co-editor) (Google DeepMind) -`` - -## Acknowledgements - -Special thanks to -the members of the editing committee for the C++17 DIS, namely -Marshall Clow, -Mike Miller, -Ville Voutilainen, -and -Jeffrey Yasskin -for their review of the correctness of the working paper -as modified by the motions from the Kona 2017 meeting. - -Special thanks also to -Jonathan Wakely -and -Alisdair Meredith -for performing edits and editorial review for several of the motions applied since N4640, -and to -Jens Maurer -for performing many of the editorial fixes since N4640. - -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 - - * [N4659](http://wg21.link/n4659) is the current working draft. It replaces [N4640](http://wg21.link/n4640). - * [N4660](http://wg21.link/n4660) is the C++17 DIS. - * N4661 is this Editors' Report. - -The contents of N4659 and N4660 are identical except for the cover sheet and -page headings. - -## Motions incorporated into working draft and C++17 DIS - -### Core working group motions - -CWG motion 1: [Core issue resolutions](http://wg21.link/p0575r1) for 5 issues in "ready" status applied: - - * [1677](http://wg21.link/cwg1677) Constant initialization via aggregate initialization - * [1860](http://wg21.link/cwg1860) What is a "direct member?" - * [2174](http://wg21.link/cwg2174) Unclear rules for friend definitions in templates - * [2205](http://wg21.link/cwg2205) Restrictions on use of alignas - * [2218](http://wg21.link/cwg2218) Ambiguity and namespace aliases - -**The other 7 issues in "ready" status from P0575R1 were applied by CWG Motion 3** - -CWG motion 2: [Core issue resolutions](http://wg21.link/p0576r1) for 5 issues in "tentatively ready" status applied: - - * [2201](http://wg21.link/cwg2201) Cv-qualification of array types - * [2206](http://wg21.link/cwg2206) Composite type of object and function pointers - * [2214](http://wg21.link/cwg2214) Missing requirement on representation of integer values - * [2220](http://wg21.link/cwg2220) Hiding index variable in range-based `for` - * [2224](http://wg21.link/cwg2224) Member subobjects and base-class casts - * [2259](http://wg21.link/cwg2259) Unclear context describing ambiguity - * [2262](http://wg21.link/cwg2262) Attributes for *asm-definition* - -CWG motion 3: [Core issue resolutions](http://wg21.link/p0622r0) for 12 issues in "ready" and "tentatively ready" status applied, resolving 13 issues: - - * [426](http://wg21.link/cwg426) Identically-named variables, one internally and one externally linked, allowed? - * [727](http://wg21.link/cwg727) In-class explicit specializations - * [1622](http://wg21.link/cwg1622) Empty aggregate initializer for union (no changes, resolved by 2272) - * [1710](http://wg21.link/cwg1710) Missing `template` keyword in *class-or-decltype* - * [2196](http://wg21.link/cwg2196) Zero-initialization with virtual base classes - * [2198](http://wg21.link/cwg2198) Linkage of enumerators - * [2211](http://wg21.link/cwg2211) Hiding by lambda captures and parameters - * [2247](http://wg21.link/cwg2247) Lambda capture and variable argument list - * [2248](http://wg21.link/cwg2248) Problems with sized delete - * [2251](http://wg21.link/cwg2251) Unreachable enumeration list-initialization - * [2268](http://wg21.link/cwg2268) Unions with mutable members in constant expressions revisited - * [2272](http://wg21.link/cwg2272) Implicit initialization of aggregate members of reference type - * [2276](http://wg21.link/cwg2276) Dependent `noexcept` and function type-dependence - -CWG motion 4: [P0612R0 "NB comment CH 2: volatile"](http://wg21.link/p0612r0), resolving 1 NB comment: - - * CH 2: Clarify whether volatile semantics require volatile objects or merely volatile-qualified glvalues - -CWG motion 5: [P0613R0 "NB comment GB15: Resolution of Core Issue 2011"](http://wg21.link/p0613r0), resolving 1 NB comment and 1 issue: - - * GB 15, [2011](http://wg21.link/cwg2011) Unclear effect of reference capture of reference - -CWG motion 6: [P0298R3 "A `byte` type definition"](http://wg21.link/p0298r3), resolving 3 NB comments: - - * CA 11, US 72: Adopt [P0257R1 "A `byte` type for increased type safety"](http://wg21.link/p0257r1) with modifications - * US 22: Adopt [P0298R1 "A `byte` type definition"](http://wg21.link/p0298r1) - -CWG motion 7: [P0615R0 "Renaming for structured bindings"](http://wg21.link/p0615r0) - -CWG motion 8: [P0620R0 "Drafting for class template argument deduction issues"](http://wg21.link/p0620r0), resolving 3 NB comments: - - * US 94, GB 13, FI 21: Support class template argument deduction in `T{x1, x2, ...}` syntax - -CWG motion 9: [P0270R3 "Removing C dependencies from signal handler wording"](http://wg21.link/p0270r3) **with changes, see below**, resolving 1 NB comment: - - * CA 1: Adopt [P0270R1 "Removing C dependencies from signal handler wording"](http://wg21.link/p0270r1) - -CWG motion 10: [P0250R3 "Wording improvements for initialization and thread ids"](http://wg21.link/p0250r3), resolving 2 issues in "concurrency" status: - - * [1784](http://wg21.link/cwg1784) Concurrent execution during static local initialization - * [2046](http://wg21.link/cwg2046) Incomplete thread specifications - -CWG motion 11a applies to the Modules TS. - -CWG motion 11b was not approved. - -### Library working group motions - -#### Issue resolutions - -LWG motion 1 applies to the Coroutines TS. - -LWG motion 2: [Library issue resolutions](http://wg21.link/p0165r4) for 22 issues in "Ready" and "Tentatively Ready" status applied, resolving 23 issues: - - * [2260](http://wg21.link/lwg2260) Missing requirement for `Allocator::pointer` - * [2768](http://wg21.link/lwg2768) `any_cast` and move semantics (no changes, resolved by 2769) - * [2769](http://wg21.link/lwg2769) Redundant `const` in the return type of `any_cast(const any&)` - * [2781](http://wg21.link/lwg2781) Contradictory requirements for `std::function` and `std::reference_wrapper` - * [2782](http://wg21.link/lwg2782) `scoped_allocator_adaptor` constructors must be constrained - * [2784](http://wg21.link/lwg2784) Resolution to [LWG 2484](http://wg21.link/lwg2484) is missing "otherwise, no effects" and is hard to parse - * [2785](http://wg21.link/lwg2785) `quoted` should work with `basic_string_view` - * [2786](http://wg21.link/lwg2786) Annex C should mention `shared_ptr` changes for array support - * [2787](http://wg21.link/lwg2787) [file_status.cons] doesn't match class definition - * [2789](http://wg21.link/lwg2789) Equivalence of contained objects - * [2794](http://wg21.link/lwg2794) Missing requirements for allocator pointers - * [2795](http://wg21.link/lwg2795) [global.functions] provides incorrect example of ADL use - * [2804](http://wg21.link/lwg2804) Unconditional `constexpr` default constructor for `istream_iterator` - * [2824](http://wg21.link/lwg2824) `list::sort` should say that the order of elements is unspecified if an exception is thrown - * [2826](http://wg21.link/lwg2826) `string_view` iterators use old wording - * [2834](http://wg21.link/lwg2834) Resolution to [LWG 2223](http://wg21.link/lwg2223) is missing wording about end iterators - * [2835](http://wg21.link/lwg2835) Resolution to [LWG 2536](http://wg21.link/lwg2536) seems to misspecify `` - * [2837](http://wg21.link/lwg2837) `gcd` and `lcm` should support a wider range of input values - * [2838](http://wg21.link/lwg2838) `is_literal_type` specification needs a little cleanup - * [2842](http://wg21.link/lwg2842) `in_place_t` check for `optional::optional(U&&)` should decay `U` - * [2850](http://wg21.link/lwg2850) `std::function` move constructor does unnecessary work - * [2853](http://wg21.link/lwg2853) Possible inconsistency in specification of `erase` in [vector.modifiers] - * [2855](http://wg21.link/lwg2855) `std::throw_with_nested("string_literal")` - -**Resolution of [2812](http://wg21.link/lwg2812) "Range access is available with ``" not applied, as this issue had already been resolved editorially** - -LWG motion 3: [Library issue resolutions](http://wg21.link/p0610r0) for 3 issues in "Review" status applied: - - * [2676](http://wg21.link/lwg2676) Provide `filesystem::path` overloads for "File-based streams" - * [2790](http://wg21.link/lwg2790) Missing specification of `istreambuf_iterator::operator->` - * [2796](http://wg21.link/lwg2796) `tuple` should be a literal type - -#### Filesystem - -LWG motion 4: [P0317R1 "Directory entry caching for filesystem"](http://wg21.link/p0317r1) **with changes, see below** - -LWG motion 5: [P0492R2 "Proposed resolution of C++17 National Body comments for filesystems"](http://wg21.link/p0492r2), resolving 31 NB comments and 2 issues: - - * US 32: Meaning of [fs.conform.9945] unclear - * US 33: Definition of "canonical path" problematic - * US 34: Are there attributes of a file that are not an aspect of the file system? - * US 36: Symbolic links themselves are attached to a directory via (hard) links - * US 37: The term "redundant current directory (*dot*) elements" is not defined - * US 43: Concerns about encoded character types - * US 44, [2798](http://wg21.link/lwg2798): Definition of `path` in terms of a string requires leaky abstraction - * US 45: Generic format portability compromised by unspecified *root-name* (no changes, resolved by US 73, CA 2) - * US 46: *filename* can be empty so productions for *relative-path* are redundant - * US 47: `.` and `..` already match the *name* production - * US 48: Multiple separators are often meaningful in a *root-name* - * US 51: Failing to add `/` when appending empty string prevents useful applications (no changes, resolved by US 74, CA 3) - * US 52, [2665](http://wg21.link/lwg2665): `remove_filename` postcondition is not by itself a definition - * US 53: `remove_filename`'s name does not correspond to its behavior (no changes, resolved by US 52, US 60) - * US 54: `remove_filename` is broken - * US 55: `replace_extension`'s use of `path` as parameter is inappropriate - * US 58: `parent_path` behavior for root paths is useless (no changes, resolved by US 77, CA 6) - * US 60: `path("/foo/").filename() == path(".")` is surprising - * US 61: Leading dots in `filename` should not begin an extension (no changes, resolved by US 74, CA 3) - * US 62: It is important that `stem() + extension() == filename()` (no changes, resolved by US 74, CA 3) - * US 63: `lexically_normal` inconsistently treats trailing `/` but not `/..` as directory (no changes, resolved by US 37, US 74, CA 3) - * US 73, CA 2: *root-name* is effectively implementation defined - * US 74, CA 3: The term "pathname" is ambiguous in some contexts - * US 77, CA 6: `operator/` and other `append`s not useful if arg has *root-name* - * US 78, CA 7: Member `absolute` in [fs.op.absolute] is overspecified for non-POSIX-like O/S - * Late 36: `permissions` `error_code` overload should be `noexcept` (no changes, resolved by Late 37) - * Late 37: `permissions` actions should be separate parameter - -LWG motion 6: [P0430R2 "File system library on non-POSIX-like operating systems"](http://wg21.link/p0430r2), resolving 6 NB comments: - - * US 75, CA 4: Extra flag in `path` constructors is needed - * US 76, CA 5: *root-name* definition is over-specified. - * US 79, CA 8: Some operation functions are overspecified for implementation-defined file types - -#### Parallel algorithms - -LWG motion 7: [P0452R1 "Unifying `` parallel algorithms"](http://wg21.link/p0452r1), partially resolving 2 NB comments: - - * US 161: `inner_product` should use `*GENERALIZED_SUM*` - * US 184: `inner_product` should not have `ExecutionPolicy` overload - -LWG motion 8: [P0518R1 "Allowing copies as arguments to function objects given to parallel algorithms"](http://wg21.link/p0518r1), resolving 1 NB comment: - - * CH 11: Allow parallel algorithms to make copies of their arguments - -LWG motion 9: [P0523R1 "Complexity of parallel algorithms"](http://wg21.link/p0523r1), partially resolving 1 NB comment: - - * CH 10: Relax complexity specifications for parallel algorithms - -LWG motion 10: [P0574R1 "Algorithm complexity constraints and parallel overloads"](http://wg21.link/p0574r1), partially resolving 1 NB comment: - - * CH 10: Relax complexity specifications for parallel algorithms - -LWG motion 11: [P0467R2 "Iterator concerns for parallel algorithms"](http://wg21.link/p0467r2), partially resolving 2 NB comments: - - * US 156: Relax iterator requirements for parallel algorithms - * US 162: Relax parallel `adjacent_difference` specification to permit parallelization - -LWG motion 12: [P0623R0 "Final C++17 parallel algorithms fixes"](http://wg21.link/p0623r0), partially resolving 3 NB comments: - - * US 161: `inner_product` should use `*GENERALIZED_SUM*` - * US 162: Relax parallel `adjacent_difference` specification to permit parallelization - * US 184: `inner_product` should not have `ExecutionPolicy` overload - -#### NB response papers - -LWG motion 13: [P0604R0 "Resolving GB 55, US 84, US 85, US 86"](http://wg21.link/p0604r0), resolving 4 NB comments: - - * GB 55, US 85: Fix `is_callable` and `result_of` to not use a function type as their interface - * US 84: More clearly distinguish `*INVOKE(f, t1, t2, ..., tN)*` and `*INVOKE(f, t1, t2, ..., tN, R)*` - * US 86: Rename `is_callable` to `is_invocable` - -LWG motion 14: [P0607R0 "`inline` variables for the standard library"](http://wg21.link/p0607r0), resolving 2 NB comments: - - * FI 9, GB28: Use `inline` variables for library tag types - -LWG motion 15: [P0618R0 "Deprecating ``"](http://wg21.link/p0618r0), resolving 3 NB comments: - - * GB 57: Deprecate `` - * US 64, CA 9: Preserve references to UCS2 - -LWG motion 16: **Revert [P0181R1 "Ordered By Default"](http://wg21.link/p0181r1)**, applied by 2016-06 LWG Motion 21, resolving 1 NB comment: - - * FI 18: Revert addition of `default_order` - -LWG motion 17: [P0156R2 "Variadic lock guard"](http://wg21.link/p0156r2), resolving 2 NB comments: - - * FI 8, GB 61: Revert making `lock_guard` variadic - -LWG motion 18: [P0599R1 "`noexcept` for `hash` functions"](http://wg21.link/p0599r1), resolving 1 NB comment: - - * US 140: Some or all `hash` specializations should be `noexcept` - -LWG motion 19: [P0433R2 "Integrating template deduction for class templates into the standard library"](http://wg21.link/p0433r2), resolving 2 NB comments and 3 issues: - - * US 7, US 19 (remaining parts after P0512R0), US 147, US 148, US 150: Provide suitable deduction guides for the standard library - -**Despite the claims of this paper and the wording of Motion 19, -this paper is unrelated to US 14** - -#### NB issue resolutions - -LWG motion 20: [Library issue resolutions](http://wg21.link/p0625r0) for 23 issues in "Immediate" status applied, resolving 20 NB comments: - - * CH 7, [2904](http://wg21.link/lwg2904): Make `variant` move-assignment more exception safe - * GB 36, [2866](http://wg21.link/lwg2866): Incorrect derived classes constraints - * GB 49, [2806](http://wg21.link/lwg2806): Base class of `bad_optional_access` - * GB 53, [2807](http://wg21.link/lwg2807): `std::invoke` should use `std::is_nothrow_callable` - * GB 54, [2868](http://wg21.link/lwg2868): Missing specification of `bad_any_cast::what()` - * US 107, [2872](http://wg21.link/lwg2872): Add definition for "direct-non-list-initialization" - * US 111, [2890](http://wg21.link/lwg2890): The definition of "object state" applies only to class types - * US 111, [2900](http://wg21.link/lwg2900): The copy and move constructors of `optional` are not `constexpr` - * US 118, [2903](http://wg21.link/lwg2903): The form of initialization for the emplace-constructors is not specified - * US 122, [2801](http://wg21.link/lwg2801): Default-constructibility of `unique_ptr` - * US 123, [2905](http://wg21.link/lwg2905): `is_constructible_v | P | D const &>` should be `false` when `D` is not copy constructible - * US 124, [2873](http://wg21.link/lwg2873): Add `noexcept` to several `shared_ptr` related functions - * US 125, [2874](http://wg21.link/lwg2874): Constructor `shared_ptr::shared_ptr(Y*)` should be constrained - * US 126, [2875](http://wg21.link/lwg2875): `shared_ptr::shared_ptr(Y* | D | […])` constructors should be constrained - * US 127, [2802](http://wg21.link/lwg2802): `shared_ptr` constructor requirements for a deleter - * US 129, [2876](http://wg21.link/lwg2876): `shared_ptr::shared_ptr(const weak_ptr&)` constructor should be constrained - * US 135, [2908](http://wg21.link/lwg2908): The less-than operator for shared pointers could do more - * US 145, [2861](http://wg21.link/lwg2861): `basic_string` should require that `charT` match `traits::char_type` - * US 153, [2878](http://wg21.link/lwg2878): Missing DefaultConstructible requirement for `istream_iterator` default constructor - * US 165, [2921](http://wg21.link/lwg2921): `packaged_task` and type-erased allocators - * [2788](http://wg21.link/lwg2788): `basic_string` range mutators unintentionally require a default constructible allocator - * [2857](http://wg21.link/lwg2857): `{variant,optional,any}::emplace` should return the constructed value - * [2934](http://wg21.link/lwg2934): `optional` doesn't compare with `T` - -**Note: the resolutions of issues 2894 and 2911 in P0625R0 are not included in this motion** - -LWG motion 20a was not approved. - -LWG motion 20b: [Library issue resolution](http://wg21.link/p0625r0) for 1 issue in "Immediate" status applied, resolving 1 NB comment: - - * US 143, [2911](http://wg21.link/lwg2911): An `is_aggregate_type` trait is needed - -#### Non-NB-comment papers - -LWG motion 21: [P0558R1 "Resolving `atomic` named base class inconsistencies"](http://wg21.link/p0558r1) - -LWG motion 22: [P0548R1 "`common_type` and `duration`"](http://wg21.link/p0548r1) - -LWG motion 23 applies to the Ranges TS. - -## Notable editorial changes - - * CWG 6: In application of P0298R3, updated introductory sentence of [cstddef.syn] - to avoid claiming that `std::byte` is part of ISO C's `` header. - - * CWG 9: Change to [csignal.syn] was not applied, because the desired normative - effect had already been accomplished by [P0175R1](http://wg21.link/p0175r1), - which was applied at the previous meeting and removed the baseline text for - this change. The effect of the merge is that `std::signal` is *not* required - to itself have C language linkage (but its parameter and returned function - pointer types are). Also added subclause to house description of signal - handlers, rather than including it in the `` header synopsis. - - * LWG 4: The normative description of `directory_entry::is_directory` is - specified in terms of a non-existent `file_status` member, and either the - `status` or `symlink_status` members could have been intended. After - [consulting with LWG](http://lists.isocpp.org/lib/2017/03/2262.php), - this usage of `file_status` has been replaced by `status`. - -## Minor editorial fixes - -A log of editorial fixes made since N4640 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/n4640...n4659). - - commit xxxxx diff --git a/papers/n4659.pdf b/papers/n4659.pdf new file mode 100644 index 0000000000..fedd1b8e50 Binary files /dev/null and b/papers/n4659.pdf differ diff --git a/papers/n4661.html b/papers/n4661.html new file mode 100644 index 0000000000..a29605270a --- /dev/null +++ b/papers/n4661.html @@ -0,0 +1,1005 @@ +N4661 +

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

+ +

2017-03-20
+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 +the members of the editing committee for the C++17 DIS, namely +Marshall Clow, +Mike Miller, +Ville Voutilainen, +and +Jeffrey Yasskin +for their review of the correctness of the working paper +as modified by the motions from the Kona 2017 meeting.

+ +

Special thanks also to +Jonathan Wakely +and +Alisdair Meredith +for performing edits and editorial review for several of the motions applied since N4640, +and to +Jens Maurer +for performing many of the editorial fixes since N4640.

+ +

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

+ +

New papers

+ +
    +
  • N4659 is the current working draft. It replaces N4640.
  • +
  • N4660 is the C++17 DIS.
  • +
  • N4661 is this Editors' Report.
  • +
+ +

The contents of N4659 and N4660 are identical except for the cover sheet and +page headings.

+ +

Motions incorporated into working draft and C++17 DIS

+ +

Core working group motions

+ +

CWG motion 1: Core issue resolutions for 5 issues in "ready" status applied:

+ +
    +
  • 1677 Constant initialization via aggregate initialization
  • +
  • 1860 What is a "direct member?"
  • +
  • 2174 Unclear rules for friend definitions in templates
  • +
  • 2205 Restrictions on use of alignas
  • +
  • 2218 Ambiguity and namespace aliases
  • +
+ +

The other 7 issues in "ready" status from P0575R1 were applied by CWG Motion 3

+ +

CWG motion 2: Core issue resolutions for 5 issues in "tentatively ready" status applied:

+ +
    +
  • 2201 Cv-qualification of array types
  • +
  • 2206 Composite type of object and function pointers
  • +
  • 2214 Missing requirement on representation of integer values
  • +
  • 2220 Hiding index variable in range-based for
  • +
  • 2224 Member subobjects and base-class casts
  • +
  • 2259 Unclear context describing ambiguity
  • +
  • 2262 Attributes for asm-definition
  • +
+ +

CWG motion 3: Core issue resolutions for 12 issues in "ready" and "tentatively ready" status applied, resolving 13 issues:

+ +
    +
  • 426 Identically-named variables, one internally and one externally linked, allowed?
  • +
  • 727 In-class explicit specializations
  • +
  • 1622 Empty aggregate initializer for union (no changes, resolved by 2272)
  • +
  • 1710 Missing template keyword in class-or-decltype
  • +
  • 2196 Zero-initialization with virtual base classes
  • +
  • 2198 Linkage of enumerators
  • +
  • 2211 Hiding by lambda captures and parameters
  • +
  • 2247 Lambda capture and variable argument list
  • +
  • 2248 Problems with sized delete
  • +
  • 2251 Unreachable enumeration list-initialization
  • +
  • 2268 Unions with mutable members in constant expressions revisited
  • +
  • 2272 Implicit initialization of aggregate members of reference type
  • +
  • 2276 Dependent noexcept and function type-dependence
  • +
+ +

CWG motion 4: P0612R0 "NB comment CH 2: volatile", resolving 1 NB comment:

+ +
    +
  • CH 2: Clarify whether volatile semantics require volatile objects or merely volatile-qualified glvalues
  • +
+ +

CWG motion 5: P0613R0 "NB comment GB15: Resolution of Core Issue 2011", resolving 1 NB comment and 1 issue:

+ +
    +
  • GB 15, 2011 Unclear effect of reference capture of reference
  • +
+ +

CWG motion 6: P0298R3 "A byte type definition", resolving 3 NB comments:

+ + + +

CWG motion 7: P0615R0 "Renaming for structured bindings"

+ +

CWG motion 8: P0620R0 "Drafting for class template argument deduction issues", resolving 3 NB comments:

+ +
    +
  • US 94, GB 13, FI 21: Support class template argument deduction in T{x1, x2, ...} syntax
  • +
+ +

CWG motion 9: P0270R3 "Removing C dependencies from signal handler wording" with changes, see below, resolving 1 NB comment:

+ + + +

CWG motion 10: P0250R3 "Wording improvements for initialization and thread ids", resolving 2 issues in "concurrency" status:

+ +
    +
  • 1784 Concurrent execution during static local initialization
  • +
  • 2046 Incomplete thread specifications
  • +
+ +

CWG motion 11a applies to the Modules TS.

+ +

CWG motion 11b was not approved.

+ +

Library working group motions

+ +

Issue resolutions

+ +

LWG motion 1 applies to the Coroutines TS.

+ +

LWG motion 2: Library issue resolutions for 22 issues in "Ready" and "Tentatively Ready" status applied, resolving 23 issues:

+ +
    +
  • 2260 Missing requirement for Allocator::pointer
  • +
  • 2768 any_cast and move semantics (no changes, resolved by 2769)
  • +
  • 2769 Redundant const in the return type of any_cast(const any&)
  • +
  • 2781 Contradictory requirements for std::function and std::reference_wrapper
  • +
  • 2782 scoped_allocator_adaptor constructors must be constrained
  • +
  • 2784 Resolution to LWG 2484 is missing "otherwise, no effects" and is hard to parse
  • +
  • 2785 quoted should work with basic_string_view
  • +
  • 2786 Annex C should mention shared_ptr changes for array support
  • +
  • 2787 [file_status.cons] doesn't match class definition
  • +
  • 2789 Equivalence of contained objects
  • +
  • 2794 Missing requirements for allocator pointers
  • +
  • 2795 [global.functions] provides incorrect example of ADL use
  • +
  • 2804 Unconditional constexpr default constructor for istream_iterator
  • +
  • 2824 list::sort should say that the order of elements is unspecified if an exception is thrown
  • +
  • 2826 string_view iterators use old wording
  • +
  • 2834 Resolution to LWG 2223 is missing wording about end iterators
  • +
  • 2835 Resolution to LWG 2536 seems to misspecify <tgmath.h>
  • +
  • 2837 gcd and lcm should support a wider range of input values
  • +
  • 2838 is_literal_type specification needs a little cleanup
  • +
  • 2842 in_place_t check for optional::optional(U&&) should decay U
  • +
  • 2850 std::function move constructor does unnecessary work
  • +
  • 2853 Possible inconsistency in specification of erase in [vector.modifiers]
  • +
  • 2855 std::throw_with_nested("string_literal")
  • +
+ +

Resolution of 2812 "Range access is available with <string_view>" not applied, as this issue had already been resolved editorially

+ +

LWG motion 3: Library issue resolutions for 3 issues in "Review" status applied:

+ +
    +
  • 2676 Provide filesystem::path overloads for "File-based streams"
  • +
  • 2790 Missing specification of istreambuf_iterator::operator->
  • +
  • 2796 tuple should be a literal type
  • +
+ +

Filesystem

+ +

LWG motion 4: P0317R1 "Directory entry caching for filesystem" with changes, see below

+ +

LWG motion 5: P0492R2 "Proposed resolution of C++17 National Body comments for filesystems", resolving 31 NB comments and 2 issues:

+ +
    +
  • US 32: Meaning of [fs.conform.9945] unclear
  • +
  • US 33: Definition of "canonical path" problematic
  • +
  • US 34: Are there attributes of a file that are not an aspect of the file system?
  • +
  • US 36: Symbolic links themselves are attached to a directory via (hard) links
  • +
  • US 37: The term "redundant current directory (dot) elements" is not defined
  • +
  • US 43: Concerns about encoded character types
  • +
  • US 44, 2798: Definition of path in terms of a string requires leaky abstraction
  • +
  • US 45: Generic format portability compromised by unspecified root-name (no changes, resolved by US 73, CA 2)
  • +
  • US 46: filename can be empty so productions for relative-path are redundant
  • +
  • US 47: . and .. already match the name production
  • +
  • US 48: Multiple separators are often meaningful in a root-name
  • +
  • US 51: Failing to add / when appending empty string prevents useful applications (no changes, resolved by US 74, CA 3)
  • +
  • US 52, 2665: remove_filename postcondition is not by itself a definition
  • +
  • US 53: remove_filename's name does not correspond to its behavior (no changes, resolved by US 52, US 60)
  • +
  • US 54: remove_filename is broken
  • +
  • US 55: replace_extension's use of path as parameter is inappropriate
  • +
  • US 58: parent_path behavior for root paths is useless (no changes, resolved by US 77, CA 6)
  • +
  • US 60: path("/foo/").filename() == path(".") is surprising
  • +
  • US 61: Leading dots in filename should not begin an extension (no changes, resolved by US 74, CA 3)
  • +
  • US 62: It is important that stem() + extension() == filename() (no changes, resolved by US 74, CA 3)
  • +
  • US 63: lexically_normal inconsistently treats trailing / but not /.. as directory (no changes, resolved by US 37, US 74, CA 3)
  • +
  • US 73, CA 2: root-name is effectively implementation defined
  • +
  • US 74, CA 3: The term "pathname" is ambiguous in some contexts
  • +
  • US 77, CA 6: operator/ and other appends not useful if arg has root-name
  • +
  • US 78, CA 7: Member absolute in [fs.op.absolute] is overspecified for non-POSIX-like O/S
  • +
  • Late 36: permissions error_code overload should be noexcept (no changes, resolved by Late 37)
  • +
  • Late 37: permissions actions should be separate parameter
  • +
+ +

LWG motion 6: P0430R2 "File system library on non-POSIX-like operating systems", resolving 6 NB comments:

+ +
    +
  • US 75, CA 4: Extra flag in path constructors is needed
  • +
  • US 76, CA 5: root-name definition is over-specified.
  • +
  • US 79, CA 8: Some operation functions are overspecified for implementation-defined file types
  • +
+ +

Parallel algorithms

+ +

LWG motion 7: P0452R1 "Unifying <numeric> parallel algorithms", partially resolving 2 NB comments:

+ +
    +
  • US 161: inner_product should use GENERALIZED_SUM
  • +
  • US 184: inner_product should not have ExecutionPolicy overload
  • +
+ +

LWG motion 8: P0518R1 "Allowing copies as arguments to function objects given to parallel algorithms", resolving 1 NB comment:

+ +
    +
  • CH 11: Allow parallel algorithms to make copies of their arguments
  • +
+ +

LWG motion 9: P0523R1 "Complexity of parallel algorithms", partially resolving 1 NB comment:

+ +
    +
  • CH 10: Relax complexity specifications for parallel algorithms
  • +
+ +

LWG motion 10: P0574R1 "Algorithm complexity constraints and parallel overloads", partially resolving 1 NB comment:

+ +
    +
  • CH 10: Relax complexity specifications for parallel algorithms
  • +
+ +

LWG motion 11: P0467R2 "Iterator concerns for parallel algorithms", partially resolving 2 NB comments:

+ +
    +
  • US 156: Relax iterator requirements for parallel algorithms
  • +
  • US 162: Relax parallel adjacent_difference specification to permit parallelization
  • +
+ +

LWG motion 12: P0623R0 "Final C++17 parallel algorithms fixes", partially resolving 3 NB comments:

+ +
    +
  • US 161: inner_product should use GENERALIZED_SUM
  • +
  • US 162: Relax parallel adjacent_difference specification to permit parallelization
  • +
  • US 184: inner_product should not have ExecutionPolicy overload
  • +
+ +

NB response papers

+ +

LWG motion 13: P0604R0 "Resolving GB 55, US 84, US 85, US 86", resolving 4 NB comments:

+ +
    +
  • GB 55, US 85: Fix is_callable and result_of to not use a function type as their interface
  • +
  • US 84: More clearly distinguish *INVOKE(f, t1, t2, ..., tN)* and *INVOKE(f, t1, t2, ..., tN, R)*
  • +
  • US 86: Rename is_callable to is_invocable
  • +
+ +

LWG motion 14: P0607R0 "inline variables for the standard library", resolving 2 NB comments:

+ +
    +
  • FI 9, GB28: Use inline variables for library tag types
  • +
+ +

LWG motion 15: P0618R0 "Deprecating <codecvt>", resolving 3 NB comments:

+ +
    +
  • GB 57: Deprecate <codecvt>
  • +
  • US 64, CA 9: Preserve references to UCS2
  • +
+ +

LWG motion 16: Revert P0181R1 "Ordered By Default", applied by 2016-06 LWG Motion 21, resolving 1 NB comment:

+ +
    +
  • FI 18: Revert addition of default_order
  • +
+ +

LWG motion 17: P0156R2 "Variadic lock guard", resolving 2 NB comments:

+ +
    +
  • FI 8, GB 61: Revert making lock_guard variadic
  • +
+ +

LWG motion 18: P0599R1 "noexcept for hash functions", resolving 1 NB comment:

+ +
    +
  • US 140: Some or all hash<T> specializations should be noexcept
  • +
+ +

LWG motion 19: P0433R2 "Integrating template deduction for class templates into the standard library", resolving 2 NB comments and 3 issues:

+ +
    +
  • US 7, US 19 (remaining parts after P0512R0), US 147, US 148, US 150: Provide suitable deduction guides for the standard library
  • +
+ +

Despite the claims of this paper and the wording of Motion 19, +this paper is unrelated to US 14

+ +

NB issue resolutions

+ +

LWG motion 20: Library issue resolutions for 23 issues in "Immediate" status applied, resolving 20 NB comments:

+ +
    +
  • CH 7, 2904: Make variant move-assignment more exception safe
  • +
  • GB 36, 2866: Incorrect derived classes constraints
  • +
  • GB 49, 2806: Base class of bad_optional_access
  • +
  • GB 53, 2807: std::invoke should use std::is_nothrow_callable
  • +
  • GB 54, 2868: Missing specification of bad_any_cast::what()
  • +
  • US 107, 2872: Add definition for "direct-non-list-initialization"
  • +
  • US 111, 2890: The definition of "object state" applies only to class types
  • +
  • US 111, 2900: The copy and move constructors of optional are not constexpr
  • +
  • US 118, 2903: The form of initialization for the emplace-constructors is not specified
  • +
  • US 122, 2801: Default-constructibility of unique_ptr
  • +
  • US 123, 2905: is_constructible_v<unique_ptr<P | D> | P | D const &> should be false when D is not copy constructible
  • +
  • US 124, 2873: Add noexcept to several shared_ptr related functions
  • +
  • US 125, 2874: Constructor shared_ptr::shared_ptr(Y*) should be constrained
  • +
  • US 126, 2875: shared_ptr::shared_ptr(Y* | D | […]) constructors should be constrained
  • +
  • US 127, 2802: shared_ptr constructor requirements for a deleter
  • +
  • US 129, 2876: shared_ptr::shared_ptr(const weak_ptr<Y>&) constructor should be constrained
  • +
  • US 135, 2908: The less-than operator for shared pointers could do more
  • +
  • US 145, 2861: basic_string should require that charT match traits::char_type
  • +
  • US 153, 2878: Missing DefaultConstructible requirement for istream_iterator default constructor
  • +
  • US 165, 2921: packaged_task and type-erased allocators
  • +
  • 2788: basic_string range mutators unintentionally require a default constructible allocator
  • +
  • 2857: {variant,optional,any}::emplace should return the constructed value
  • +
  • 2934: optional<const T> doesn't compare with T
  • +
+ +

Note: the resolutions of issues 2894 and 2911 in P0625R0 are not included in this motion

+ +

LWG motion 20a was not approved.

+ +

LWG motion 20b: Library issue resolution for 1 issue in "Immediate" status applied, resolving 1 NB comment:

+ +
    +
  • US 143, 2911: An is_aggregate_type trait is needed
  • +
+ +

Non-NB-comment papers

+ +

LWG motion 21: P0558R1 "Resolving atomic<T> named base class inconsistencies"

+ +

LWG motion 22: P0548R1 "common_type and duration"

+ +

LWG motion 23 applies to the Ranges TS.

+ +

Notable editorial changes

+ +

Motions

+ +
    +
  • CWG 6: In application of P0298R3, updated introductory sentence of [cstddef.syn] +to avoid claiming that std::byte is part of ISO C's <stddef.h> header.

  • +
  • CWG 9: Change to [csignal.syn] was not applied, because the desired normative +effect had already been accomplished by P0175R1, +which was applied at the previous meeting and removed the baseline text for +this change. The effect of the merge is that std::signal is not required +to itself have C language linkage (but its parameter and returned function +pointer types are). Also added subclause to house description of signal +handlers, rather than including it in the <csignal> header synopsis.

  • +
  • LWG 4: The normative description of directory_entry::is_directory is +specified in terms of a non-existent file_status member, and either the +status or symlink_status members could have been intended. After +consulting with LWG, +this usage of file_status has been replaced by status.

  • +
+ +

NB comments

+ +
    +
  • __cplusplus macro value updated from 201402L to 201703L, resolving +NB comments CA 15 and US 83.

  • +
  • Added acknowledgement of ECMAScript trademark, resolving NB comment GB 10.

  • +
  • Added normative references to LIA-1 and IEEE 754.

  • +
  • Added note to definition of literal type, resolving NB comment GB 68.

  • +
  • Made introductory sentence of [basic.stc] consistent with later normative +wording, resolving NB comment JP 3, as directed by CWG.

  • +
+ +

ISO Directives

+ +
    +
  • Promoted "Scope", "Normative references", and "Terms and definitions" to +top-level Clauses as required by ISO Directives.

  • +
  • Updated introductory text of "Normative references" and "Terms and definitions" +to match those specified by ISO Directives.

  • +
+ +

Content rearrangement

+ +
    +
  • [fs.path.generic]: rearranged pathname grammar to avoid long paragraphs of +text in descriptive elements and refactored to fix ambiguities in the +grammar, after consultation with LWG.

  • +
  • [expr.prim.lambda]: split out subclauses for the closure type and captures; +reviewed by CWG at Kona 2017.

  • +
  • Move specification of deprecated standard library headers into Annex D, +after consultation with LWG.

  • +
+ +

Stable name changes

+ +
    +
  • A "Cross references from ISO C++ 2014" section has been added, listing all +stable names from C++ 2014 that do not appear within the C++ 2017 standard, +and where the corresponding text can be found (if it still exists).

  • +
  • Systematic review and cleanup of filesystem stable names:
    + [class.path] -> [fs.class.path]
    + [path.generic] -> [fs.path.generic]
    + [path.cvt] -> [fs.path.cvt]
    + [path.fmt.cvt] -> [fs.path.fmt.cvt]
    + [path.type.cvt] -> [fs.path.type.cvt]
    + [path.req] -> [fs.path.req]
    + [path.member] -> [fs.path.member]
    + [path.construct] -> [fs.path.construct]
    + [path.assign] -> [fs.path.assign]
    + [path.append] -> [fs.path.append]
    + [path.concat] -> [fs.path.concat]
    + [path.modifiers] -> [fs.path.modifiers]
    + [path.native.obs] -> [fs.path.native.obs]
    + [path.generic.obs] -> [fs.path.generic.obs]
    + [path.compare] -> [fs.path.compare]
    + [path.decompose] -> [fs.path.decompose]
    + [path.query] -> [fs.path.query]
    + [path.gen] -> [fs.path.gen]
    + [path.itr] -> [fs.path.itr]
    + [path.non-member] -> [fs.path.nonmember]
    + [path.io] -> [fs.path.io]
    + [path.factory] -> [fs.path.factory]
    + [class.filesystem_error] -> [fs.class.filesystem_error]
    + [enum.path.format] -> [fs.enum.path.format]
    + [enum.file_type] -> [fs.enum.file_type]
    + [enum.copy_options] -> [fs.enum.copy.opts]
    + [enum.perms] -> [fs.enum.perms]
    + [enum.perm_options] -> [fs.enum.perm.opts]
    + [enum.directory_options] -> [fs.enum.dir.opts]
    + [class.file_status] -> [fs.class.file_status]
    + [file_status.cons] -> [fs.file_status.cons]
    + [file_status.obs] -> [fs.file_status.obs]
    + [file_status.mods] -> [fs.file_status.mods]
    + [class.directory_entry] -> [fs.class.directory_entry]
    + [directory_entry.cons] -> [fs.dir.entry.cons]
    + [directory_entry.mods] -> [fs.dir.entry.mods]
    + [directory_entry.obs] -> [fs.dir.entry.obs]
    + [class.directory_iterator] -> [fs.class.directory_iterator]
    + [directory_iterator.members] -> [fs.dir.itr.members]
    + [directory_iterator.nonmembers] -> [fs.dir.itr.nonmembers]
    + [class.rec.dir.itr] -> [fs.class.rec.dir.itr]
    + [rec.dir.itr.members] -> [fs.rec.dir.itr.members]
    + [rec.dir.itr.nonmembers] -> [fs.rec.dir.itr.nonmembers]

  • +
  • [istreambuf.iterator] 5 subclauses +[istreambuf.iterator::equal], +[istreambuf.iterator::op!=], +[istreambuf.iterator::op*], +[istreambuf.iterator::op++], +[istreambuf.iterator::op==] +merged into a single [istreambuf.iterator.ops] comprising half a page of text;

  • +
  • Several subclauses with stable names containing :: have been renamed to +instead use . as the component separator.

  • +
+ +

Minor editorial fixes

+ +

A log of editorial fixes made since N4640 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 dbf3efe18813054c95abae388c53bf30e96e7e83
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Mon Mar 20 15:19:47 2017 -0700
+
+    [intro.refs], [intro.defs] Update introductory text to match latest ISO
+    Directives.
+
+commit 32825151765e214d79103a137aa29a9a4357687f
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Mon Mar 20 15:00:51 2017 -0700
+
+    Replace "this International Standard" with "this document" in some
+    places where it is a clear improvement.
+
+    The 7th Edition of the ISO Directives no longer require us to use
+    "this International Standard" when the document refers to itself. We
+    retain that phrasing when the reference is to the abstract notion of
+    the specification as opposed to the text embodying it.
+
+    This is a step towards addressing #1389.
+
+commit 1798a9b6795d6ee92bf093e2a6256c34212552b1
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Mon Mar 20 14:14:22 2017 -0700
+
+    [fs.path.generic] Refactor generic pathname grammar to remove redundancy and ambiguity.
+
+commit 660d97e40353337b0b6b533903ab16e330855a77
+Author: Eelis van der Weegen <eelis@eelis.net>
+Date:   Sat Aug 6 18:02:50 2016 +0200
+
+    [depr.func.adaptor.typedefs] Clarify that reference_wrapper does not define argument_type for non-nullary member function pointer types.
+
+commit 95cbc03c20f20d98a53a3e696df6003ec27abc42
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Feb 8 16:35:25 2017 +0100
+
+    [istreambuf.iterator] Join subsections for operations descriptions.
+
+    There was one subsection for every operator, yet everything
+    fits on half a page.
+
+    Fixes #1429, #1449.
+
+commit d2b6fb6eefc3c28eb448352cd6d8b0d08e860a66
+Author: Jonathan Wakely <cxx@kayari.org>
+Date:   Thu Mar 16 21:27:11 2017 +0000
+
+    [containers] Rephrase deduction guide constraints
+
+    Replace "is called with" wording that doesn't apply to deduction guides.
+
+    Move rules about qualifying as input iterators or allocators to
+    [container.requirements.general].
+
+commit a7f52d1904e5a6d2d407eb4145ba54552d0b3e69
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Mon Mar 20 00:07:04 2017 -0700
+
+    [fs.path.generic] Move descriptions of grammar elements out of the
+    grammar and into separate paragraphs, and format path grammar as we
+    format the language grammar.
+
+    Also rephrase description of root-name to use the defined term
+    "implementation-defined" directly rather than separating it into
+    "implementations [...] define".
+
+commit 04a9e5d759b4fea810ed029dd6b6a0d5ebfd224a
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Feb 10 22:46:20 2017 +0100
+
+    [fs.op.copy], [fs.op.copy_file] Rephrase requirements on copy_options.
+
+    Use bitmask 'element' phrasing for restrictions on copy_options.
+
+    Fixes #1445.
+
+commit df9a809a36c34acc0870c5d7869e7549574e1437
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Mar 18 23:08:32 2017 +0100
+
+    [partial.sort] Remove 'It takes' from complexity specification.
+
+    Partially addresses #1088.
+
+commit 5cf60394dbe171ec16bfbba1459772e40b9cf6e1
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sat Mar 18 21:21:14 2017 +0000
+
+    [temp.class.spec.mfunc] Add missing comment to example
+
+commit cdd6dda21e3273ea63b733c3cfb3b630bb1847eb
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Thu Mar 16 15:37:17 2017 -0700
+
+    [xref] Add glossary of cross-references between C++14 section labels and
+    C++17 section labels.
+
+    Fixes #1547.
+
+commit 88c20950fac6915844143bb73129e2eb1b41d17d
+Author: Jonathan Wakely <cxx@kayari.org>
+Date:   Thu Mar 16 02:51:38 2017 +0000
+
+    [filesystem] Shorten stable names and add "fs." prefixes
+
+    [class.path] -> [fs.class.path]
+    [path.generic] -> [fs.path.generic]
+    [path.cvt] -> [fs.path.cvt]
+    [path.fmt.cvt] -> [fs.path.fmt.cvt]
+    [path.type.cvt] -> [fs.path.type.cvt]
+    [path.req] -> [fs.path.req]
+    [path.member] -> [fs.path.member]
+    [path.construct] -> [fs.path.construct]
+    [path.assign] -> [fs.path.assign]
+    [path.append] -> [fs.path.append]
+    [path.concat] -> [fs.path.concat]
+    [path.modifiers] -> [fs.path.modifiers]
+    [path.native.obs] -> [fs.path.native.obs]
+    [path.generic.obs] -> [fs.path.generic.obs]
+    [path.compare] -> [fs.path.compare]
+    [path.decompose] -> [fs.path.decompose]
+    [path.query] -> [fs.path.query]
+    [path.gen] -> [fs.path.gen]
+    [path.itr] -> [fs.path.itr]
+    [path.non-member] -> [fs.path.nonmember]
+    [path.io] -> [fs.path.io]
+    [path.factory] -> [fs.path.factory]
+    [class.filesystem_error] -> [fs.class.filesystem_error]
+    [enum.path.format] -> [fs.enum.path.format]
+    [enum.file_type] -> [fs.enum.file_type]
+    [enum.copy_options] -> [fs.enum.copy.opts]
+    [enum.perms] -> [fs.enum.perms]
+    [enum.perm_options] -> [fs.enum.perm.opts]
+    [enum.directory_options] -> [fs.enum.dir.opts]
+    [class.file_status] -> [fs.class.file_status]
+    [file_status.cons] -> [fs.file_status.cons]
+    [file_status.obs] -> [fs.file_status.obs]
+    [file_status.mods] -> [fs.file_status.mods]
+    [class.directory_entry] -> [fs.class.directory_entry]
+    [directory_entry.cons] -> [fs.dir.entry.cons]
+    [directory_entry.mods] -> [fs.dir.entry.mods]
+    [directory_entry.obs] -> [fs.dir.entry.obs]
+    [class.directory_iterator] -> [fs.class.directory_iterator]
+    [directory_iterator.members] -> [fs.dir.itr.members]
+    [directory_iterator.nonmembers] -> [fs.dir.itr.nonmembers]
+    [class.rec.dir.itr] -> [fs.class.rec.dir.itr]
+    [rec.dir.itr.members] -> [fs.rec.dir.itr.members]
+    [rec.dir.itr.nonmembers] -> [fs.rec.dir.itr.nonmembers]
+
+commit ad33212fded427f1e0b4e57c53c9e9215318b223
+Author: Alisdair Meredith <public@alisdairm.net>
+Date:   Thu Mar 16 11:21:05 2017 -0400
+
+    [any.modifiers] fix emplace return type for 'any' (#1545)
+
+    LWG issue 2857 was applied verbatim, without noticing
+    that 'ValueType' had been previously changed to 'T'.
+    This makes things consistent by choosing 'T' as the
+    simpler form, more consistent with 'optional' and
+    'variant'.
+
+commit 09e4674b0b6ab2f74bfe5a14120edea874115779
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Tue Feb 28 07:27:01 2017 +0100
+
+    [expr.prim.lambda] Move syntactic restriction on decl-specifier-seq to the front.
+
+    Per CWG guidance.
+
+commit 763a3fda5cec74d17371ddf4957f1f522331ebb0
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Nov 30 19:17:52 2016 +0100
+
+    [expr.prim.lambda] Split specification of lambda expressions into subsections.
+
+    Fixes #1155.
+
+commit 8139f2f9ec81cf4b8c24640f968880241dd23231
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Thu Nov 17 19:51:44 2016 +0000
+
+    Move specification of deprecated headers to Annex D
+
+commit c9354b33e1de8e0cf6dc42a73c733e1d8a34e7e0
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Wed Mar 15 18:29:49 2017 -0700
+
+    Update value of __cplusplus to 201703L.
+
+    Fixes #1513 and NB CA 15 and US 83 (C++17 CD).
+
+commit 8baa18cbbf33a9b73711638b13a4960e15179c6d
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Wed Mar 15 18:29:13 2017 -0700
+
+    Add acknowledgement of ECMAScript trademark.
+
+    Fixes NB GB 10 (C++17 CD).
+
+commit 4d53b8b250751aae7768955f75eb7f27db08d83e
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Wed Mar 15 12:55:55 2017 -0700
+
+    Editorial fixes for P0317R1.
+
+    [directory_entry.mods] Improve singular/plural, add commas.
+
+    [class.directory_iterator] Reorder words to more closely align xref with
+    the term for which it is a reference, add comma.
+
+commit dd42ed5d6e04e623992e0464e49323a2b6a1f518
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Sun Mar 12 14:34:57 2017 -0700
+
+    [atomics.flag] Replace "shall be" with "is" when describing properties
+    of the implementation, for consistency with changes made by P0558R1.
+
+commit 49caa2b829256f8198ed649ca3f5057bde96a2c7
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sun Mar 5 09:19:33 2017 -1000
+
+    [func.search] Add missing period
+
+commit 4f0891849e4799367174cc8783a3d88b6ff6b95a
+Author: Jonathan Wakely <cxx@kayari.org>
+Date:   Fri Mar 3 02:36:27 2017 +0000
+
+    [meta.trans] replace "shall name" with "names" in traits tables
+
+commit 42c6d5cc8ed83ba4b48b8b94d51b7a317d577a46
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Tue Dec 20 21:45:21 2016 +0100
+
+    [lib] For showing complexity, use $N \log N$
+    and not $N \log(N)$ or other variants.
+
+    Partially addresses #1088.
+
+commit 42c5a2ce36d7403ca37cb8b038aa37065c353ba4
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Tue Dec 20 23:45:26 2016 +0100
+
+    [intro.refs] Add normative references to LIA-1 and IEEE 754.
+
+    Fixes #237.
+
+commit bdff8687ccb470564400597403d484ad02890f24
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Feb 10 21:25:42 2017 +0100
+
+    [any] Use 'contained value' consistently.
+
+    This harmonizes the use of 'constained value' across
+    optional, variant, and any, with appropriate index
+    entries.
+
+    Fixes #1401.
+
+commit 6a5edb752b88c448dce4cba528de307d79966b9e
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Thu Feb 9 21:42:49 2017 +0100
+
+    Harmonize punctuation for 'ill-formed, no diagnostic required'
+
+    Fixes #1450.
+
+commit 40f3fb37986ecff07567cc4601fac334fee8aff9
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Feb 8 15:35:43 2017 +0100
+
+    [basic.types] Remove excessive references to [basic.type.qualifier].
+
+    Fixes #1419.
+
+commit ee930ef3ee97f244d278ac3f762ec5f167dc005a
+Author: Jonathan Wakely <cxx@kayari.org>
+Date:   Thu Mar 2 02:20:48 2017 +0000
+
+    [rand.dist.bern.negbin] Fix index for k member
+
+commit bbcf0ea60c63d741bc51818633c70df2690e99b4
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Wed Mar 1 13:34:52 2017 -1000
+
+    Add a note to the definition of literal type to indicate that it is not
+    a guarantee that such an object can be created in a constant expression.
+
+    Wording from John Spicer / CWG.
+
+    Addresses NB GB 68 (C++17 CD).
+
+commit be54f2e8e12c54071692ef3ebd6e49f6e3255a27
+Author: Jakub Wilk <jwilk@jwilk.net>
+Date:   Tue Feb 28 19:17:32 2017 +0100
+
+    [diff.decl] Fix typo (#1494)
+
+commit 2f6aff7e71cc33243671d1e501911d331af61fa3
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Mon Feb 27 16:23:46 2017 -1000
+
+    [basic.stc] Fix introductory sentence on dynamic storage duration to
+    match later more-normative rule: it applies to objects, not storage.
+
+    Fixes NB JP 3 (C++17 CD).
+
+commit ec4ca6fc07907ea817152970c45d4c04c86d3c5c
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Mon Feb 27 11:30:27 2017 -0800
+
+    [intro] Promote "Scope", "Normative references", "Terms and definitions"
+    to top-level clauses per ISO directives.
+
+    Modify \definition macro so we can more easily have definitions at
+    different depths in different lists.
+
+commit fe6c8bda60fbca2cd3a488650988ce0a7df20d03
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Fri Feb 24 12:09:31 2017 +0100
+
+    [localization, diff] Remove superfluous 'return 0;' from 'main' in examples. (#1482)
+
+commit 17e28024d81e366a6d1044fa29a0cd1bdf10f77f
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Thu Feb 23 12:32:58 2017 +0100
+
+    [meta.unary.prop, meta.trans.other] Omit unhelpful second argument in static_asserts. (#1479)
+
+commit 33f16cb3417ad21949769d82cae36c1b653e4519
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Thu Feb 23 01:47:09 2017 +0100
+
+    [dcl.attr.nodiscard] Clarify example with reference return type. (#1471)
+
+    Add rationale why a warning is not encouraged for this case.
+
+    Fixes #1470.
+
+commit 7cd42666e143e19bdaf9e62211066cab255fb99f
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Thu Feb 23 01:25:26 2017 +0100
+
+    [expr.mptr.oper] Use defined term 'null member pointer value'. (#1434)
+
+commit 5bc5cbae28d9e741ebc7df996f1f0d230ac4087e
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Tue Feb 21 00:16:14 2017 +0100
+
+    [rand.req.{eng,dist}] Replace square brackets around reference with regular parentheses. (#1481)
+
+commit 44f489bba7c7595077043c7360cf7ff329eeb090
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Sun Feb 19 15:41:48 2017 +0100
+
+    [except.spec] Add missing 'an'. (#1478)
+
+commit 16938d84892051f5c9e2fe4afca578fc57b1c4f3
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sat Feb 18 19:21:13 2017 +0000
+
+    [support.runtime] Remove extraneous and misleading parentheses from names of functions and macros
+
+commit d2fe52eaaf53b6843ab6fe152a2a05e5a7da06fc
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Thu Feb 16 20:54:49 2017 +0100
+
+    [alg.min.max] Enlarge lfloor/rfloor delimiters. (#1455)
+
+commit 7e5537d1e9c7a6d63c9877cf5babde4ddf14807c
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Wed Feb 15 15:38:19 2017 +0100
+
+    Parenthesize some \refs. (#1436)
+
+commit 473966e60653e8e2bc8ed154d8b18a3736f97088
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Thu Feb 9 12:14:12 2017 +0100
+
+    [unord.req] Insert hint is 'p', not 'q' (#1440)
+
+    LWG 2540 changed the hint for insert from 'q'
+    (a valid and dereferenceable iterator) to 'p'
+    (a valid, but not necessarily dereferenceable iterator),
+    but neglected to adjust the description text.
+
+    Fixes #1423.
+
+commit 90c486f80612c3a7fd26ee408631991814f7b81c
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Feb 8 17:21:31 2017 +0100
+
+    [any.assign] Rename T to VT. (#1448)
+
+    These renames were overlooked in commit 8b1f6cc8d73eec0306db1dec66f2da52a03ea274.
+
+    Fixes #1443.
+
diff --git a/papers/n4661.md b/papers/n4661.md new file mode 100644 index 0000000000..a8331e1952 --- /dev/null +++ b/papers/n4661.md @@ -0,0 +1,825 @@ +# N4661 Editors' Report -- Programming Languages -- C++ + +2017-03-20 +Richard Smith (editor) (Google Inc) +Dawn Perchik (co-editor) (Embarcadero Technologies Inc) +Thomas Köppe (co-editor) (Google DeepMind) +`` + +## Acknowledgements + +Special thanks to +the members of the editing committee for the C++17 DIS, namely +Marshall Clow, +Mike Miller, +Ville Voutilainen, +and +Jeffrey Yasskin +for their review of the correctness of the working paper +as modified by the motions from the Kona 2017 meeting. + +Special thanks also to +Jonathan Wakely +and +Alisdair Meredith +for performing edits and editorial review for several of the motions applied since N4640, +and to +Jens Maurer +for performing many of the editorial fixes since N4640. + +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 + + * [N4659](http://wg21.link/n4659) is the current working draft. It replaces [N4640](http://wg21.link/n4640). + * [N4660](http://wg21.link/n4660) is the C++17 DIS. + * N4661 is this Editors' Report. + +The contents of N4659 and N4660 are identical except for the cover sheet and +page headings. + +## Motions incorporated into working draft and C++17 DIS + +### Core working group motions + +CWG motion 1: [Core issue resolutions](http://wg21.link/p0575r1) for 5 issues in "ready" status applied: + + * [1677](http://wg21.link/cwg1677) Constant initialization via aggregate initialization + * [1860](http://wg21.link/cwg1860) What is a "direct member?" + * [2174](http://wg21.link/cwg2174) Unclear rules for friend definitions in templates + * [2205](http://wg21.link/cwg2205) Restrictions on use of alignas + * [2218](http://wg21.link/cwg2218) Ambiguity and namespace aliases + +**The other 7 issues in "ready" status from P0575R1 were applied by CWG Motion 3** + +CWG motion 2: [Core issue resolutions](http://wg21.link/p0576r1) for 5 issues in "tentatively ready" status applied: + + * [2201](http://wg21.link/cwg2201) Cv-qualification of array types + * [2206](http://wg21.link/cwg2206) Composite type of object and function pointers + * [2214](http://wg21.link/cwg2214) Missing requirement on representation of integer values + * [2220](http://wg21.link/cwg2220) Hiding index variable in range-based `for` + * [2224](http://wg21.link/cwg2224) Member subobjects and base-class casts + * [2259](http://wg21.link/cwg2259) Unclear context describing ambiguity + * [2262](http://wg21.link/cwg2262) Attributes for *asm-definition* + +CWG motion 3: [Core issue resolutions](http://wg21.link/p0622r0) for 12 issues in "ready" and "tentatively ready" status applied, resolving 13 issues: + + * [426](http://wg21.link/cwg426) Identically-named variables, one internally and one externally linked, allowed? + * [727](http://wg21.link/cwg727) In-class explicit specializations + * [1622](http://wg21.link/cwg1622) Empty aggregate initializer for union (no changes, resolved by 2272) + * [1710](http://wg21.link/cwg1710) Missing `template` keyword in *class-or-decltype* + * [2196](http://wg21.link/cwg2196) Zero-initialization with virtual base classes + * [2198](http://wg21.link/cwg2198) Linkage of enumerators + * [2211](http://wg21.link/cwg2211) Hiding by lambda captures and parameters + * [2247](http://wg21.link/cwg2247) Lambda capture and variable argument list + * [2248](http://wg21.link/cwg2248) Problems with sized delete + * [2251](http://wg21.link/cwg2251) Unreachable enumeration list-initialization + * [2268](http://wg21.link/cwg2268) Unions with mutable members in constant expressions revisited + * [2272](http://wg21.link/cwg2272) Implicit initialization of aggregate members of reference type + * [2276](http://wg21.link/cwg2276) Dependent `noexcept` and function type-dependence + +CWG motion 4: [P0612R0 "NB comment CH 2: volatile"](http://wg21.link/p0612r0), resolving 1 NB comment: + + * CH 2: Clarify whether volatile semantics require volatile objects or merely volatile-qualified glvalues + +CWG motion 5: [P0613R0 "NB comment GB15: Resolution of Core Issue 2011"](http://wg21.link/p0613r0), resolving 1 NB comment and 1 issue: + + * GB 15, [2011](http://wg21.link/cwg2011) Unclear effect of reference capture of reference + +CWG motion 6: [P0298R3 "A `byte` type definition"](http://wg21.link/p0298r3), resolving 3 NB comments: + + * CA 11, US 72: Adopt [P0257R1 "A `byte` type for increased type safety"](http://wg21.link/p0257r1) with modifications + * US 22: Adopt [P0298R1 "A `byte` type definition"](http://wg21.link/p0298r1) + +CWG motion 7: [P0615R0 "Renaming for structured bindings"](http://wg21.link/p0615r0) + +CWG motion 8: [P0620R0 "Drafting for class template argument deduction issues"](http://wg21.link/p0620r0), resolving 3 NB comments: + + * US 94, GB 13, FI 21: Support class template argument deduction in `T{x1, x2, ...}` syntax + +CWG motion 9: [P0270R3 "Removing C dependencies from signal handler wording"](http://wg21.link/p0270r3) **with changes, see below**, resolving 1 NB comment: + + * CA 1: Adopt [P0270R1 "Removing C dependencies from signal handler wording"](http://wg21.link/p0270r1) + +CWG motion 10: [P0250R3 "Wording improvements for initialization and thread ids"](http://wg21.link/p0250r3), resolving 2 issues in "concurrency" status: + + * [1784](http://wg21.link/cwg1784) Concurrent execution during static local initialization + * [2046](http://wg21.link/cwg2046) Incomplete thread specifications + +CWG motion 11a applies to the Modules TS. + +CWG motion 11b was not approved. + +### Library working group motions + +#### Issue resolutions + +LWG motion 1 applies to the Coroutines TS. + +LWG motion 2: [Library issue resolutions](http://wg21.link/p0165r4) for 22 issues in "Ready" and "Tentatively Ready" status applied, resolving 23 issues: + + * [2260](http://wg21.link/lwg2260) Missing requirement for `Allocator::pointer` + * [2768](http://wg21.link/lwg2768) `any_cast` and move semantics (no changes, resolved by 2769) + * [2769](http://wg21.link/lwg2769) Redundant `const` in the return type of `any_cast(const any&)` + * [2781](http://wg21.link/lwg2781) Contradictory requirements for `std::function` and `std::reference_wrapper` + * [2782](http://wg21.link/lwg2782) `scoped_allocator_adaptor` constructors must be constrained + * [2784](http://wg21.link/lwg2784) Resolution to [LWG 2484](http://wg21.link/lwg2484) is missing "otherwise, no effects" and is hard to parse + * [2785](http://wg21.link/lwg2785) `quoted` should work with `basic_string_view` + * [2786](http://wg21.link/lwg2786) Annex C should mention `shared_ptr` changes for array support + * [2787](http://wg21.link/lwg2787) [file_status.cons] doesn't match class definition + * [2789](http://wg21.link/lwg2789) Equivalence of contained objects + * [2794](http://wg21.link/lwg2794) Missing requirements for allocator pointers + * [2795](http://wg21.link/lwg2795) [global.functions] provides incorrect example of ADL use + * [2804](http://wg21.link/lwg2804) Unconditional `constexpr` default constructor for `istream_iterator` + * [2824](http://wg21.link/lwg2824) `list::sort` should say that the order of elements is unspecified if an exception is thrown + * [2826](http://wg21.link/lwg2826) `string_view` iterators use old wording + * [2834](http://wg21.link/lwg2834) Resolution to [LWG 2223](http://wg21.link/lwg2223) is missing wording about end iterators + * [2835](http://wg21.link/lwg2835) Resolution to [LWG 2536](http://wg21.link/lwg2536) seems to misspecify `` + * [2837](http://wg21.link/lwg2837) `gcd` and `lcm` should support a wider range of input values + * [2838](http://wg21.link/lwg2838) `is_literal_type` specification needs a little cleanup + * [2842](http://wg21.link/lwg2842) `in_place_t` check for `optional::optional(U&&)` should decay `U` + * [2850](http://wg21.link/lwg2850) `std::function` move constructor does unnecessary work + * [2853](http://wg21.link/lwg2853) Possible inconsistency in specification of `erase` in [vector.modifiers] + * [2855](http://wg21.link/lwg2855) `std::throw_with_nested("string_literal")` + +**Resolution of [2812](http://wg21.link/lwg2812) "Range access is available with ``" not applied, as this issue had already been resolved editorially** + +LWG motion 3: [Library issue resolutions](http://wg21.link/p0610r0) for 3 issues in "Review" status applied: + + * [2676](http://wg21.link/lwg2676) Provide `filesystem::path` overloads for "File-based streams" + * [2790](http://wg21.link/lwg2790) Missing specification of `istreambuf_iterator::operator->` + * [2796](http://wg21.link/lwg2796) `tuple` should be a literal type + +#### Filesystem + +LWG motion 4: [P0317R1 "Directory entry caching for filesystem"](http://wg21.link/p0317r1) **with changes, see below** + +LWG motion 5: [P0492R2 "Proposed resolution of C++17 National Body comments for filesystems"](http://wg21.link/p0492r2), resolving 31 NB comments and 2 issues: + + * US 32: Meaning of [fs.conform.9945] unclear + * US 33: Definition of "canonical path" problematic + * US 34: Are there attributes of a file that are not an aspect of the file system? + * US 36: Symbolic links themselves are attached to a directory via (hard) links + * US 37: The term "redundant current directory (*dot*) elements" is not defined + * US 43: Concerns about encoded character types + * US 44, [2798](http://wg21.link/lwg2798): Definition of `path` in terms of a string requires leaky abstraction + * US 45: Generic format portability compromised by unspecified *root-name* (no changes, resolved by US 73, CA 2) + * US 46: *filename* can be empty so productions for *relative-path* are redundant + * US 47: `.` and `..` already match the *name* production + * US 48: Multiple separators are often meaningful in a *root-name* + * US 51: Failing to add `/` when appending empty string prevents useful applications (no changes, resolved by US 74, CA 3) + * US 52, [2665](http://wg21.link/lwg2665): `remove_filename` postcondition is not by itself a definition + * US 53: `remove_filename`'s name does not correspond to its behavior (no changes, resolved by US 52, US 60) + * US 54: `remove_filename` is broken + * US 55: `replace_extension`'s use of `path` as parameter is inappropriate + * US 58: `parent_path` behavior for root paths is useless (no changes, resolved by US 77, CA 6) + * US 60: `path("/foo/").filename() == path(".")` is surprising + * US 61: Leading dots in `filename` should not begin an extension (no changes, resolved by US 74, CA 3) + * US 62: It is important that `stem() + extension() == filename()` (no changes, resolved by US 74, CA 3) + * US 63: `lexically_normal` inconsistently treats trailing `/` but not `/..` as directory (no changes, resolved by US 37, US 74, CA 3) + * US 73, CA 2: *root-name* is effectively implementation defined + * US 74, CA 3: The term "pathname" is ambiguous in some contexts + * US 77, CA 6: `operator/` and other `append`s not useful if arg has *root-name* + * US 78, CA 7: Member `absolute` in [fs.op.absolute] is overspecified for non-POSIX-like O/S + * Late 36: `permissions` `error_code` overload should be `noexcept` (no changes, resolved by Late 37) + * Late 37: `permissions` actions should be separate parameter + +LWG motion 6: [P0430R2 "File system library on non-POSIX-like operating systems"](http://wg21.link/p0430r2), resolving 6 NB comments: + + * US 75, CA 4: Extra flag in `path` constructors is needed + * US 76, CA 5: *root-name* definition is over-specified. + * US 79, CA 8: Some operation functions are overspecified for implementation-defined file types + +#### Parallel algorithms + +LWG motion 7: [P0452R1 "Unifying `` parallel algorithms"](http://wg21.link/p0452r1), partially resolving 2 NB comments: + + * US 161: `inner_product` should use *`GENERALIZED_SUM`* + * US 184: `inner_product` should not have `ExecutionPolicy` overload + +LWG motion 8: [P0518R1 "Allowing copies as arguments to function objects given to parallel algorithms"](http://wg21.link/p0518r1), resolving 1 NB comment: + + * CH 11: Allow parallel algorithms to make copies of their arguments + +LWG motion 9: [P0523R1 "Complexity of parallel algorithms"](http://wg21.link/p0523r1), partially resolving 1 NB comment: + + * CH 10: Relax complexity specifications for parallel algorithms + +LWG motion 10: [P0574R1 "Algorithm complexity constraints and parallel overloads"](http://wg21.link/p0574r1), partially resolving 1 NB comment: + + * CH 10: Relax complexity specifications for parallel algorithms + +LWG motion 11: [P0467R2 "Iterator concerns for parallel algorithms"](http://wg21.link/p0467r2), partially resolving 2 NB comments: + + * US 156: Relax iterator requirements for parallel algorithms + * US 162: Relax parallel `adjacent_difference` specification to permit parallelization + +LWG motion 12: [P0623R0 "Final C++17 parallel algorithms fixes"](http://wg21.link/p0623r0), partially resolving 3 NB comments: + + * US 161: `inner_product` should use *`GENERALIZED_SUM`* + * US 162: Relax parallel `adjacent_difference` specification to permit parallelization + * US 184: `inner_product` should not have `ExecutionPolicy` overload + +#### NB response papers + +LWG motion 13: [P0604R0 "Resolving GB 55, US 84, US 85, US 86"](http://wg21.link/p0604r0), resolving 4 NB comments: + + * GB 55, US 85: Fix `is_callable` and `result_of` to not use a function type as their interface + * US 84: More clearly distinguish `*INVOKE(f, t1, t2, ..., tN)*` and `*INVOKE(f, t1, t2, ..., tN, R)*` + * US 86: Rename `is_callable` to `is_invocable` + +LWG motion 14: [P0607R0 "`inline` variables for the standard library"](http://wg21.link/p0607r0), resolving 2 NB comments: + + * FI 9, GB28: Use `inline` variables for library tag types + +LWG motion 15: [P0618R0 "Deprecating ``"](http://wg21.link/p0618r0), resolving 3 NB comments: + + * GB 57: Deprecate `` + * US 64, CA 9: Preserve references to UCS2 + +LWG motion 16: **Revert [P0181R1 "Ordered By Default"](http://wg21.link/p0181r1)**, applied by 2016-06 LWG Motion 21, resolving 1 NB comment: + + * FI 18: Revert addition of `default_order` + +LWG motion 17: [P0156R2 "Variadic lock guard"](http://wg21.link/p0156r2), resolving 2 NB comments: + + * FI 8, GB 61: Revert making `lock_guard` variadic + +LWG motion 18: [P0599R1 "`noexcept` for `hash` functions"](http://wg21.link/p0599r1), resolving 1 NB comment: + + * US 140: Some or all `hash` specializations should be `noexcept` + +LWG motion 19: [P0433R2 "Integrating template deduction for class templates into the standard library"](http://wg21.link/p0433r2), resolving 2 NB comments and 3 issues: + + * US 7, US 19 (remaining parts after P0512R0), US 147, US 148, US 150: Provide suitable deduction guides for the standard library + +**Despite the claims of this paper and the wording of Motion 19, +this paper is unrelated to US 14** + +#### NB issue resolutions + +LWG motion 20: [Library issue resolutions](http://wg21.link/p0625r0) for 23 issues in "Immediate" status applied, resolving 20 NB comments: + + * CH 7, [2904](http://wg21.link/lwg2904): Make `variant` move-assignment more exception safe + * GB 36, [2866](http://wg21.link/lwg2866): Incorrect derived classes constraints + * GB 49, [2806](http://wg21.link/lwg2806): Base class of `bad_optional_access` + * GB 53, [2807](http://wg21.link/lwg2807): `std::invoke` should use `std::is_nothrow_callable` + * GB 54, [2868](http://wg21.link/lwg2868): Missing specification of `bad_any_cast::what()` + * US 107, [2872](http://wg21.link/lwg2872): Add definition for "direct-non-list-initialization" + * US 111, [2890](http://wg21.link/lwg2890): The definition of "object state" applies only to class types + * US 111, [2900](http://wg21.link/lwg2900): The copy and move constructors of `optional` are not `constexpr` + * US 118, [2903](http://wg21.link/lwg2903): The form of initialization for the emplace-constructors is not specified + * US 122, [2801](http://wg21.link/lwg2801): Default-constructibility of `unique_ptr` + * US 123, [2905](http://wg21.link/lwg2905): `is_constructible_v | P | D const &>` should be `false` when `D` is not copy constructible + * US 124, [2873](http://wg21.link/lwg2873): Add `noexcept` to several `shared_ptr` related functions + * US 125, [2874](http://wg21.link/lwg2874): Constructor `shared_ptr::shared_ptr(Y*)` should be constrained + * US 126, [2875](http://wg21.link/lwg2875): `shared_ptr::shared_ptr(Y* | D | […])` constructors should be constrained + * US 127, [2802](http://wg21.link/lwg2802): `shared_ptr` constructor requirements for a deleter + * US 129, [2876](http://wg21.link/lwg2876): `shared_ptr::shared_ptr(const weak_ptr&)` constructor should be constrained + * US 135, [2908](http://wg21.link/lwg2908): The less-than operator for shared pointers could do more + * US 145, [2861](http://wg21.link/lwg2861): `basic_string` should require that `charT` match `traits::char_type` + * US 153, [2878](http://wg21.link/lwg2878): Missing DefaultConstructible requirement for `istream_iterator` default constructor + * US 165, [2921](http://wg21.link/lwg2921): `packaged_task` and type-erased allocators + * [2788](http://wg21.link/lwg2788): `basic_string` range mutators unintentionally require a default constructible allocator + * [2857](http://wg21.link/lwg2857): `{variant,optional,any}::emplace` should return the constructed value + * [2934](http://wg21.link/lwg2934): `optional` doesn't compare with `T` + +**Note: the resolutions of issues 2894 and 2911 in P0625R0 are not included in this motion** + +LWG motion 20a was not approved. + +LWG motion 20b: [Library issue resolution](http://wg21.link/p0625r0) for 1 issue in "Immediate" status applied, resolving 1 NB comment: + + * US 143, [2911](http://wg21.link/lwg2911): An `is_aggregate_type` trait is needed + +#### Non-NB-comment papers + +LWG motion 21: [P0558R1 "Resolving `atomic` named base class inconsistencies"](http://wg21.link/p0558r1) + +LWG motion 22: [P0548R1 "`common_type` and `duration`"](http://wg21.link/p0548r1) + +LWG motion 23 applies to the Ranges TS. + +## Notable editorial changes + +### Motions + + * CWG 6: In application of P0298R3, updated introductory sentence of [cstddef.syn] + to avoid claiming that `std::byte` is part of ISO C's `` header. + + * CWG 9: Change to [csignal.syn] was not applied, because the desired normative + effect had already been accomplished by [P0175R1](http://wg21.link/p0175r1), + which was applied at the previous meeting and removed the baseline text for + this change. The effect of the merge is that `std::signal` is *not* required + to itself have C language linkage (but its parameter and returned function + pointer types are). Also added subclause to house description of signal + handlers, rather than including it in the `` header synopsis. + + * LWG 4: The normative description of `directory_entry::is_directory` is + specified in terms of a non-existent `file_status` member, and either the + `status` or `symlink_status` members could have been intended. After + [consulting with LWG](http://lists.isocpp.org/lib/2017/03/2262.php), + this usage of `file_status` has been replaced by `status`. + +### NB comments + + * `__cplusplus` macro value updated from `201402L` to `201703L`, resolving + NB comments CA 15 and US 83. + + * Added acknowledgement of ECMAScript trademark, resolving NB comment GB 10. + + * Added normative references to LIA-1 and IEEE 754. + + * Added note to definition of literal type, resolving NB comment GB 68. + + * Made introductory sentence of [basic.stc] consistent with later normative + wording, resolving NB comment JP 3, as directed by CWG. + +### ISO Directives + + * Promoted "Scope", "Normative references", and "Terms and definitions" to + top-level Clauses as required by ISO Directives. + + * Updated introductory text of "Normative references" and "Terms and definitions" + to match those specified by ISO Directives. + +### Content rearrangement + + * [fs.path.generic]: rearranged *pathname* grammar to avoid long paragraphs of + text in descriptive elements and refactored to fix ambiguities in the + grammar, after consultation with LWG. + + * [expr.prim.lambda]: split out subclauses for the closure type and captures; + reviewed by CWG at Kona 2017. + + * Move specification of deprecated standard library headers into Annex D, + after consultation with LWG. + +### Stable name changes + + * A "Cross references from ISO C++ 2014" section has been added, listing all + stable names from C++ 2014 that do not appear within the C++ 2017 standard, + and where the corresponding text can be found (if it still exists). + + * Systematic review and cleanup of filesystem stable names: + [class.path] -> [fs.class.path] + [path.generic] -> [fs.path.generic] + [path.cvt] -> [fs.path.cvt] + [path.fmt.cvt] -> [fs.path.fmt.cvt] + [path.type.cvt] -> [fs.path.type.cvt] + [path.req] -> [fs.path.req] + [path.member] -> [fs.path.member] + [path.construct] -> [fs.path.construct] + [path.assign] -> [fs.path.assign] + [path.append] -> [fs.path.append] + [path.concat] -> [fs.path.concat] + [path.modifiers] -> [fs.path.modifiers] + [path.native.obs] -> [fs.path.native.obs] + [path.generic.obs] -> [fs.path.generic.obs] + [path.compare] -> [fs.path.compare] + [path.decompose] -> [fs.path.decompose] + [path.query] -> [fs.path.query] + [path.gen] -> [fs.path.gen] + [path.itr] -> [fs.path.itr] + [path.non-member] -> [fs.path.nonmember] + [path.io] -> [fs.path.io] + [path.factory] -> [fs.path.factory] + [class.filesystem\_error] -> [fs.class.filesystem\_error] + [enum.path.format] -> [fs.enum.path.format] + [enum.file\_type] -> [fs.enum.file\_type] + [enum.copy\_options] -> [fs.enum.copy.opts] + [enum.perms] -> [fs.enum.perms] + [enum.perm\_options] -> [fs.enum.perm.opts] + [enum.directory\_options] -> [fs.enum.dir.opts] + [class.file\_status] -> [fs.class.file\_status] + [file\_status.cons] -> [fs.file\_status.cons] + [file\_status.obs] -> [fs.file\_status.obs] + [file\_status.mods] -> [fs.file\_status.mods] + [class.directory\_entry] -> [fs.class.directory\_entry] + [directory\_entry.cons] -> [fs.dir.entry.cons] + [directory\_entry.mods] -> [fs.dir.entry.mods] + [directory\_entry.obs] -> [fs.dir.entry.obs] + [class.directory\_iterator] -> [fs.class.directory\_iterator] + [directory\_iterator.members] -> [fs.dir.itr.members] + [directory\_iterator.nonmembers] -> [fs.dir.itr.nonmembers] + [class.rec.dir.itr] -> [fs.class.rec.dir.itr] + [rec.dir.itr.members] -> [fs.rec.dir.itr.members] + [rec.dir.itr.nonmembers] -> [fs.rec.dir.itr.nonmembers] + + * [istreambuf.iterator] 5 subclauses + [istreambuf.iterator::equal], + [istreambuf.iterator::op!=], + [istreambuf.iterator::op\*], + [istreambuf.iterator::op++], + [istreambuf.iterator::op==] + merged into a single [istreambuf.iterator.ops] comprising half a page of text; + + * Several subclauses with stable names containing `::` have been renamed to + instead use `.` as the component separator. + +## Minor editorial fixes + +A log of editorial fixes made since N4640 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/n4640...n4659). + + commit dbf3efe18813054c95abae388c53bf30e96e7e83 + Author: Richard Smith + Date: Mon Mar 20 15:19:47 2017 -0700 + + [intro.refs], [intro.defs] Update introductory text to match latest ISO + Directives. + + commit 32825151765e214d79103a137aa29a9a4357687f + Author: Richard Smith + Date: Mon Mar 20 15:00:51 2017 -0700 + + Replace "this International Standard" with "this document" in some + places where it is a clear improvement. + + The 7th Edition of the ISO Directives no longer require us to use + "this International Standard" when the document refers to itself. We + retain that phrasing when the reference is to the abstract notion of + the specification as opposed to the text embodying it. + + This is a step towards addressing #1389. + + commit 1798a9b6795d6ee92bf093e2a6256c34212552b1 + Author: Richard Smith + Date: Mon Mar 20 14:14:22 2017 -0700 + + [fs.path.generic] Refactor generic pathname grammar to remove redundancy and ambiguity. + + commit 660d97e40353337b0b6b533903ab16e330855a77 + Author: Eelis van der Weegen + Date: Sat Aug 6 18:02:50 2016 +0200 + + [depr.func.adaptor.typedefs] Clarify that reference_wrapper does not define argument_type for non-nullary member function pointer types. + + commit 95cbc03c20f20d98a53a3e696df6003ec27abc42 + Author: Jens Maurer + Date: Wed Feb 8 16:35:25 2017 +0100 + + [istreambuf.iterator] Join subsections for operations descriptions. + + There was one subsection for every operator, yet everything + fits on half a page. + + Fixes #1429, #1449. + + commit d2b6fb6eefc3c28eb448352cd6d8b0d08e860a66 + Author: Jonathan Wakely + Date: Thu Mar 16 21:27:11 2017 +0000 + + [containers] Rephrase deduction guide constraints + + Replace "is called with" wording that doesn't apply to deduction guides. + + Move rules about qualifying as input iterators or allocators to + [container.requirements.general]. + + commit a7f52d1904e5a6d2d407eb4145ba54552d0b3e69 + Author: Richard Smith + Date: Mon Mar 20 00:07:04 2017 -0700 + + [fs.path.generic] Move descriptions of grammar elements out of the + grammar and into separate paragraphs, and format path grammar as we + format the language grammar. + + Also rephrase description of root-name to use the defined term + "implementation-defined" directly rather than separating it into + "implementations [...] define". + + commit 04a9e5d759b4fea810ed029dd6b6a0d5ebfd224a + Author: Jens Maurer + Date: Fri Feb 10 22:46:20 2017 +0100 + + [fs.op.copy], [fs.op.copy_file] Rephrase requirements on copy_options. + + Use bitmask 'element' phrasing for restrictions on copy_options. + + Fixes #1445. + + commit df9a809a36c34acc0870c5d7869e7549574e1437 + Author: Jens Maurer + Date: Sat Mar 18 23:08:32 2017 +0100 + + [partial.sort] Remove 'It takes' from complexity specification. + + Partially addresses #1088. + + commit 5cf60394dbe171ec16bfbba1459772e40b9cf6e1 + Author: Thomas Köppe + Date: Sat Mar 18 21:21:14 2017 +0000 + + [temp.class.spec.mfunc] Add missing comment to example + + commit cdd6dda21e3273ea63b733c3cfb3b630bb1847eb + Author: Richard Smith + Date: Thu Mar 16 15:37:17 2017 -0700 + + [xref] Add glossary of cross-references between C++14 section labels and + C++17 section labels. + + Fixes #1547. + + commit 88c20950fac6915844143bb73129e2eb1b41d17d + Author: Jonathan Wakely + Date: Thu Mar 16 02:51:38 2017 +0000 + + [filesystem] Shorten stable names and add "fs." prefixes + + [class.path] -> [fs.class.path] + [path.generic] -> [fs.path.generic] + [path.cvt] -> [fs.path.cvt] + [path.fmt.cvt] -> [fs.path.fmt.cvt] + [path.type.cvt] -> [fs.path.type.cvt] + [path.req] -> [fs.path.req] + [path.member] -> [fs.path.member] + [path.construct] -> [fs.path.construct] + [path.assign] -> [fs.path.assign] + [path.append] -> [fs.path.append] + [path.concat] -> [fs.path.concat] + [path.modifiers] -> [fs.path.modifiers] + [path.native.obs] -> [fs.path.native.obs] + [path.generic.obs] -> [fs.path.generic.obs] + [path.compare] -> [fs.path.compare] + [path.decompose] -> [fs.path.decompose] + [path.query] -> [fs.path.query] + [path.gen] -> [fs.path.gen] + [path.itr] -> [fs.path.itr] + [path.non-member] -> [fs.path.nonmember] + [path.io] -> [fs.path.io] + [path.factory] -> [fs.path.factory] + [class.filesystem_error] -> [fs.class.filesystem_error] + [enum.path.format] -> [fs.enum.path.format] + [enum.file_type] -> [fs.enum.file_type] + [enum.copy_options] -> [fs.enum.copy.opts] + [enum.perms] -> [fs.enum.perms] + [enum.perm_options] -> [fs.enum.perm.opts] + [enum.directory_options] -> [fs.enum.dir.opts] + [class.file_status] -> [fs.class.file_status] + [file_status.cons] -> [fs.file_status.cons] + [file_status.obs] -> [fs.file_status.obs] + [file_status.mods] -> [fs.file_status.mods] + [class.directory_entry] -> [fs.class.directory_entry] + [directory_entry.cons] -> [fs.dir.entry.cons] + [directory_entry.mods] -> [fs.dir.entry.mods] + [directory_entry.obs] -> [fs.dir.entry.obs] + [class.directory_iterator] -> [fs.class.directory_iterator] + [directory_iterator.members] -> [fs.dir.itr.members] + [directory_iterator.nonmembers] -> [fs.dir.itr.nonmembers] + [class.rec.dir.itr] -> [fs.class.rec.dir.itr] + [rec.dir.itr.members] -> [fs.rec.dir.itr.members] + [rec.dir.itr.nonmembers] -> [fs.rec.dir.itr.nonmembers] + + commit ad33212fded427f1e0b4e57c53c9e9215318b223 + Author: Alisdair Meredith + Date: Thu Mar 16 11:21:05 2017 -0400 + + [any.modifiers] fix emplace return type for 'any' (#1545) + + LWG issue 2857 was applied verbatim, without noticing + that 'ValueType' had been previously changed to 'T'. + This makes things consistent by choosing 'T' as the + simpler form, more consistent with 'optional' and + 'variant'. + + commit 09e4674b0b6ab2f74bfe5a14120edea874115779 + Author: Jens Maurer + Date: Tue Feb 28 07:27:01 2017 +0100 + + [expr.prim.lambda] Move syntactic restriction on decl-specifier-seq to the front. + + Per CWG guidance. + + commit 763a3fda5cec74d17371ddf4957f1f522331ebb0 + Author: Jens Maurer + Date: Wed Nov 30 19:17:52 2016 +0100 + + [expr.prim.lambda] Split specification of lambda expressions into subsections. + + Fixes #1155. + + commit 8139f2f9ec81cf4b8c24640f968880241dd23231 + Author: Thomas Köppe + Date: Thu Nov 17 19:51:44 2016 +0000 + + Move specification of deprecated headers to Annex D + + commit c9354b33e1de8e0cf6dc42a73c733e1d8a34e7e0 + Author: Richard Smith + Date: Wed Mar 15 18:29:49 2017 -0700 + + Update value of __cplusplus to 201703L. + + Fixes #1513 and NB CA 15 and US 83 (C++17 CD). + + commit 8baa18cbbf33a9b73711638b13a4960e15179c6d + Author: Richard Smith + Date: Wed Mar 15 18:29:13 2017 -0700 + + Add acknowledgement of ECMAScript trademark. + + Fixes NB GB 10 (C++17 CD). + + commit 4d53b8b250751aae7768955f75eb7f27db08d83e + Author: Richard Smith + Date: Wed Mar 15 12:55:55 2017 -0700 + + Editorial fixes for P0317R1. + + [directory_entry.mods] Improve singular/plural, add commas. + + [class.directory_iterator] Reorder words to more closely align xref with + the term for which it is a reference, add comma. + + commit dd42ed5d6e04e623992e0464e49323a2b6a1f518 + Author: Richard Smith + Date: Sun Mar 12 14:34:57 2017 -0700 + + [atomics.flag] Replace "shall be" with "is" when describing properties + of the implementation, for consistency with changes made by P0558R1. + + commit 49caa2b829256f8198ed649ca3f5057bde96a2c7 + Author: Thomas Köppe + Date: Sun Mar 5 09:19:33 2017 -1000 + + [func.search] Add missing period + + commit 4f0891849e4799367174cc8783a3d88b6ff6b95a + Author: Jonathan Wakely + Date: Fri Mar 3 02:36:27 2017 +0000 + + [meta.trans] replace "shall name" with "names" in traits tables + + commit 42c6d5cc8ed83ba4b48b8b94d51b7a317d577a46 + Author: Jens Maurer + Date: Tue Dec 20 21:45:21 2016 +0100 + + [lib] For showing complexity, use $N \log N$ + and not $N \log(N)$ or other variants. + + Partially addresses #1088. + + commit 42c5a2ce36d7403ca37cb8b038aa37065c353ba4 + Author: Jens Maurer + Date: Tue Dec 20 23:45:26 2016 +0100 + + [intro.refs] Add normative references to LIA-1 and IEEE 754. + + Fixes #237. + + commit bdff8687ccb470564400597403d484ad02890f24 + Author: Jens Maurer + Date: Fri Feb 10 21:25:42 2017 +0100 + + [any] Use 'contained value' consistently. + + This harmonizes the use of 'constained value' across + optional, variant, and any, with appropriate index + entries. + + Fixes #1401. + + commit 6a5edb752b88c448dce4cba528de307d79966b9e + Author: Jens Maurer + Date: Thu Feb 9 21:42:49 2017 +0100 + + Harmonize punctuation for 'ill-formed, no diagnostic required' + + Fixes #1450. + + commit 40f3fb37986ecff07567cc4601fac334fee8aff9 + Author: Jens Maurer + Date: Wed Feb 8 15:35:43 2017 +0100 + + [basic.types] Remove excessive references to [basic.type.qualifier]. + + Fixes #1419. + + commit ee930ef3ee97f244d278ac3f762ec5f167dc005a + Author: Jonathan Wakely + Date: Thu Mar 2 02:20:48 2017 +0000 + + [rand.dist.bern.negbin] Fix index for k member + + commit bbcf0ea60c63d741bc51818633c70df2690e99b4 + Author: Richard Smith + Date: Wed Mar 1 13:34:52 2017 -1000 + + Add a note to the definition of literal type to indicate that it is not + a guarantee that such an object can be created in a constant expression. + + Wording from John Spicer / CWG. + + Addresses NB GB 68 (C++17 CD). + + commit be54f2e8e12c54071692ef3ebd6e49f6e3255a27 + Author: Jakub Wilk + Date: Tue Feb 28 19:17:32 2017 +0100 + + [diff.decl] Fix typo (#1494) + + commit 2f6aff7e71cc33243671d1e501911d331af61fa3 + Author: Richard Smith + Date: Mon Feb 27 16:23:46 2017 -1000 + + [basic.stc] Fix introductory sentence on dynamic storage duration to + match later more-normative rule: it applies to objects, not storage. + + Fixes NB JP 3 (C++17 CD). + + commit ec4ca6fc07907ea817152970c45d4c04c86d3c5c + Author: Richard Smith + Date: Mon Feb 27 11:30:27 2017 -0800 + + [intro] Promote "Scope", "Normative references", "Terms and definitions" + to top-level clauses per ISO directives. + + Modify \definition macro so we can more easily have definitions at + different depths in different lists. + + commit fe6c8bda60fbca2cd3a488650988ce0a7df20d03 + Author: Eelis + Date: Fri Feb 24 12:09:31 2017 +0100 + + [localization, diff] Remove superfluous 'return 0;' from 'main' in examples. (#1482) + + commit 17e28024d81e366a6d1044fa29a0cd1bdf10f77f + Author: Eelis + Date: Thu Feb 23 12:32:58 2017 +0100 + + [meta.unary.prop, meta.trans.other] Omit unhelpful second argument in static_asserts. (#1479) + + commit 33f16cb3417ad21949769d82cae36c1b653e4519 + Author: Jens Maurer + Date: Thu Feb 23 01:47:09 2017 +0100 + + [dcl.attr.nodiscard] Clarify example with reference return type. (#1471) + + Add rationale why a warning is not encouraged for this case. + + Fixes #1470. + + commit 7cd42666e143e19bdaf9e62211066cab255fb99f + Author: Eelis + Date: Thu Feb 23 01:25:26 2017 +0100 + + [expr.mptr.oper] Use defined term 'null member pointer value'. (#1434) + + commit 5bc5cbae28d9e741ebc7df996f1f0d230ac4087e + Author: Eelis + Date: Tue Feb 21 00:16:14 2017 +0100 + + [rand.req.{eng,dist}] Replace square brackets around reference with regular parentheses. (#1481) + + commit 44f489bba7c7595077043c7360cf7ff329eeb090 + Author: Eelis + Date: Sun Feb 19 15:41:48 2017 +0100 + + [except.spec] Add missing 'an'. (#1478) + + commit 16938d84892051f5c9e2fe4afca578fc57b1c4f3 + Author: Thomas Köppe + Date: Sat Feb 18 19:21:13 2017 +0000 + + [support.runtime] Remove extraneous and misleading parentheses from names of functions and macros + + commit d2fe52eaaf53b6843ab6fe152a2a05e5a7da06fc + Author: Eelis + Date: Thu Feb 16 20:54:49 2017 +0100 + + [alg.min.max] Enlarge lfloor/rfloor delimiters. (#1455) + + commit 7e5537d1e9c7a6d63c9877cf5babde4ddf14807c + Author: Eelis + Date: Wed Feb 15 15:38:19 2017 +0100 + + Parenthesize some \refs. (#1436) + + commit 473966e60653e8e2bc8ed154d8b18a3736f97088 + Author: Jens Maurer + Date: Thu Feb 9 12:14:12 2017 +0100 + + [unord.req] Insert hint is 'p', not 'q' (#1440) + + LWG 2540 changed the hint for insert from 'q' + (a valid and dereferenceable iterator) to 'p' + (a valid, but not necessarily dereferenceable iterator), + but neglected to adjust the description text. + + Fixes #1423. + + commit 90c486f80612c3a7fd26ee408631991814f7b81c + Author: Jens Maurer + Date: Wed Feb 8 17:21:31 2017 +0100 + + [any.assign] Rename T to VT. (#1448) + + These renames were overlooked in commit 8b1f6cc8d73eec0306db1dec66f2da52a03ea274. + + Fixes #1443. diff --git a/papers/n4687.pdf b/papers/n4687.pdf new file mode 100644 index 0000000000..434402ba51 Binary files /dev/null and b/papers/n4687.pdf differ diff --git a/papers/n4688.html b/papers/n4688.html new file mode 100644 index 0000000000..38466dadb7 --- /dev/null +++ b/papers/n4688.html @@ -0,0 +1,823 @@ +N4688 +

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

+ +

2017-07-30
+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, +Jonathan Wakely, +and Eelis van der Weegen +for performing many of the editorial fixes since N4659.

+ +

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

+ +

New papers

+ +
    +
  • N4687 is the current working draft for C++20. It replaces N4659.
  • +
  • N4688 is this Editors' Report.
  • +
+ +

Motions incorporated into working draft

+ +

Core working group motions

+ +

CWG motion 1: Core issue resolution for 1 issue in "ready" status applied:

+ +
    +
  • 2253 Unnamed bit-fields and zero-initialization
  • +
+ +

CWG motion 2: Core issue resolutions for 6 issues in "tentatively ready" status applied, resolving 8 issues:

+ +
    +
  • 1523 Point of declaration in range-based for
  • +
  • 1704 Type checking in explicit instantiation of variable templates
  • +
  • 1728 Type of an explicit instantiation of a variable template (no changes, resolved by 1704)
  • +
  • 1836 Use of class type being defined in trailing-return-type
  • +
  • 2273 Inheriting constructors vs implicit default constructor
  • +
  • 2277 Ambiguity inheriting constructors with default arguments (no changes, resolved by 2273)
  • +
  • 2287 Pointer-interconvertibility in non-standard-layout unions
  • +
  • 2290 Unclear specification for overload resolution and deleted special member functions
  • +
+ +

CWG motion 3: P0727R0 "Temporary objects vs temporary expressions", resolving 3 core issue:

+ +
    +
  • 943 Is T() a temporary?
  • +
  • 1076 Value categories and lvalue temporaries
  • +
  • 1299 "Temporary objects" vs "temporary expressions"
  • +
+ +

CWG motion 4: P0683R1 "Default member initializers for bit-fields"

+ +

CWG motion 5: P0704R1 "Fixing const-qualified pointers to members"

+ +

CWG motion 6: P0409R2 "Allow lambda capture [=, this]"

+ +

CWG motion 7: P0306R4 "Comma omission and comma deletion"

+ +

CWG motion 8: P0329R4 "Designated initialization"

+ +

CWG motion 9: P0428R2 "Familiar template syntax for generic lambdas"

+ +

CWG motion 10: P0702R1 "Language support for constructor template argument deduction"

+ +

CWG motion 11: P0734R0 "Concepts" with changes, see below

+ +

CWG motion 12 applies to the Modules TS.

+ +

Library working group motions

+ +

LWG motion 13-14 apply to the Coroutines TS.

+ +

LWG motion 15-22 apply to the Ranges TS.

+ +

LWG motion 23-29 apply to the Networking TS.

+ +

LWG motion 30 applies to the Parallelism TS.

+ +

LWG motion 31: Library issue resolutions for 12 issues in "Ready" and "Tentatively Ready" status applied:

+ +
    +
  • 2444 Inconsistent complexity for std::sort_heap
  • +
  • 2593 Moved-from state of Allocators
  • +
  • 2597 std::log misspecified for complex numbers
  • +
  • 2783 stack::emplace() and queue::emplace() should return decltype(auto)
  • +
  • 2932 Constraints on parallel algorithm implementations are underspecified
  • +
  • 2937 Is equivalent("existing_thing", "not_existing_thing") an error?
  • +
  • 2940 result_of specification also needs a little cleanup
  • +
  • 2942 LWG 2873's resolution missed weak_ptr::owner_before
  • +
  • 2954 Specialization of the convenience variable templates should be prohibited
  • +
  • 2961 Bad postcondition for set_default_resource
  • +
  • 2966 Incomplete resolution of US 74
  • +
  • 2974 Diagnose out of bounds tuple_element / variant_alternative
  • +
+ +

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

+ +
    +
  • 2901 variants cannot properly support allocators
  • +
  • 2956 filesystem::canonical() still defined in terms of absolute(p, base)
  • +
+ +

LWG motion 33: P0463R1 "Endian, just endian"

+ +

LWG motion 34: P0682R1: "Repairing elementary string conversions", resolving 1 library issue:

+ +
    +
  • 2955 to_chars / from_chars depend on std::string
  • +
+ +

LWG motion 35: P0739R0 "Some improvements to class template argument deduction integration into the standard library", resolving 2 as-yet-unnumbered library issues

+ +

LWG motion 36: P0674R1 "Extending make_shared to support arrays", resolving 1 library issue:

+ +
    +
  • 2070 allocate_shared should use allocator_traits<A>::construct
  • +
+ +

Notable editorial changes

+ +

Motions

+ +
    +
  • CWG 11: The grammar production for a concept definition missed the trailing ;. +This has been rectified editorially, reflecting the obvious intent of the committee. +Two changes adding "concepts" to lists of entities have not been changed, because +a concept is a template and "templates" in general were already in the relevant list. +Several other changes were made rephrasing the wording to match the prevailing style of +the working draft.
  • +
+ +

Stable name changes

+ +

The "Cross references from ISO C++ 2014" section has been replaced by a +"Cross references from ISO C++ 2017" section.

+ +

Minor editorial fixes

+ +

A log of editorial fixes made since N4659 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 9b13e3785ef95f3c7ac159177a03bccd610b774b
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Sun Jul 30 16:13:25 2017 -0700
+
+    [dcl.array] Consolidate redundant, repetitive, and somewhat incorrect
+    examples and notes on multidimensional arrays.
+
+    Fixes #1645
+
+commit 19c63142301038e843bfd23676e036768ab35c96
+Author: S. B. Tam <cpplearner@outlook.com>
+Date:   Sun Jul 30 23:50:06 2017 +0800
+
+    [expr.const] Move p7 next to p3.
+
+commit bbca26c5e79d52a1622ff0cedeb92897a1350bf9
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Apr 5 20:23:15 2017 +0200
+
+    [expr.type.conv] Clarify if ... otherwise ladder.
+
+    Fixes #1591.
+
+commit 9f16f5ae4a54f2478d268c408100c5a005d3f278
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Jul 22 00:57:55 2017 +0200
+
+    [expr] Use 'possibly converted' for discarded-value expression.
+
+    Fixes #1597.
+
+commit 8d7a1a767f933e917b6bb20eea3e1c5fabf1cc0c
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Mar 29 20:42:39 2017 +0200
+
+    [class.mfct.non-static], [class.this] Define and use cv member function.
+
+    Fixes #447.
+
+commit 1314cc49a106fac2acba29e0e301343f857ba252
+Author: Casey Carter <Casey@Carter.net>
+Date:   Wed May 10 13:24:59 2017 -0700
+
+    Change the return type of monotonic_buffer_resource's deleted assignment
+
+    ... to monotonic_buffer_resource& for consistency with the default definition of the builtin assignment operator. This change has no normative effect, it only eliminates the inconsistency as a potential source of confusion.
+
+    Since the return type of deleted functions is not observable, this change is editorial.
+
+commit c85f24dee9feb613c9454db572cd674234f3159f
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sat Mar 25 16:20:40 2017 +0000
+
+    [string.cons] Consolidate two functions into one description
+
+commit f897604bd8cab510a843153db0133c3d5e13912f
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Jul 22 00:31:23 2017 +0200
+
+    [class.temporary] Remove note giving questionable implementation advice.
+
+    And move the surviving part of the note to before the
+    corresponding example.
+
+    Fixes #1674.
+
+commit 10e4c7437ba63c2975a160e84aecffdbfafd990b
+Author: Hubert Tong <hstong@ca.ibm.com>
+Date:   Mon Jul 24 17:45:16 2017 -0400
+
+    [over.call.object] Reference postfix-expression in call syntax correctly
+
+    The grammar production corresponding to the call syntax has
+    _postfix-expression_ as the callee operand. [over.call.object] appears
+    to refer to this operand as the _primary-expression_ in the syntax.
+
+commit ad966418d82b4e5480ad390a5f75ffbf37385f37
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Fri Jul 28 17:16:07 2017 -0700
+
+    [temp] Add missing ';' to grammar for concept-definition.
+
+    Despite being a normative change, this matches the overwhelmingly
+    obvious intent of the committee.
+
+    Fixes #1686
+
+commit afd6d4f065219067f372dafd1bb590a912775b41
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Fri Jul 28 17:13:28 2017 -0700
+
+    [temp.constr.normal] Give a proper definition for "normalization".
+
+commit 38408888321282f9c0788ec9c40e2bd2f464617b
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Fri Jul 28 16:47:17 2017 -0700
+
+    [temp.constr.order] Fix spacing in example.
+
+commit aa4b1ae864fb85377570ba9775b5d34d79772922
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Fri Jul 28 16:42:40 2017 -0700
+
+    [temp.constr.order] Clarify description of subsumption and ordering by constraints.
+
+commit 508cd59e6c9b23441ce5ed46e5012ccd1a8aed51
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Fri Jul 28 11:24:51 2017 -0700
+
+    [dcl.fct.def] Reword = default ; and = delete ; introductory text for clarity.
+
+commit 182937c038dec15efaf5521d53d06960d6f1d661
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Fri Jul 28 11:20:18 2017 -0700
+
+    [dcl.fct] Move use of "parameter-type-list" to after its definition.
+
+    Split rules on function redeclarations out of rules for determining the
+    type of an individual function.
+
+commit ac6360546cb1eb982cf8d2123ceb2c99a0156b95
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Wed Jul 26 14:22:49 2017 -0700
+
+    [expr.prim.req] Use grammar terms rather than undefined phrases when
+    referring to kinds of *requirement*.
+
+commit ff1242c4aa50958fa0380208eb0f2c45e3a8fea2
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Tue Jul 25 13:49:18 2017 +0100
+
+    [meta.endian] Simplify wording, avoid "shall"
+
+commit 17820beb537c1576fe906228d741b64b9b2e8fc1
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Mon Jul 24 11:22:34 2017 -0700
+
+    [temp] Fix example to use valid expression in requires-clause.
+
+commit 02574b8575c200095aa281d0886a73fe58c00580
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Mon Jul 24 00:37:34 2017 -0700
+
+    [temp.inst] Tweak explanation in example.
+
+commit de236bab92922adc3c38f6fc0eb1fb4ec2a17c16
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Mon Jul 24 00:36:24 2017 -0700
+
+    [temp.inst] Fix typo 'the the'.
+
+commit a76a3886035f484866add3a12af43c3b21143aa1
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Mon Jul 24 00:34:07 2017 -0700
+
+    [temp.concept] Remove redundancy: the global scope is a namespace scope.
+
+commit 9a94a384336cb37974b3a8803dcf2424812ec854
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Mon Jul 24 00:27:55 2017 -0700
+
+    [temp.class.spec] Fix typo "the primary" -> "the primary template".
+
+commit 7240fc98453bad27eb6112ae98b0f8e8fad8e39a
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Mon Jul 24 00:25:43 2017 -0700
+
+    [temp.mem.func] Add introductory text to new example to separate it from the prior example.
+
+commit 99013e76613ec877b912b18b3ffeb9d2b1cf8f1c
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Mon Jul 24 00:20:39 2017 -0700
+
+    [expr.prim.req.compound] Switch to passive voice.
+
+commit 1f1b944f2d849974ae01a5f2c45883d8213c3653
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Mon Jul 24 00:04:15 2017 -0700
+
+    [temp.param] Switch to passive voice.
+
+commit 6568af0b4270bfc1497882a108741fa01ebeaa70
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Sun Jul 23 23:54:34 2017 -0700
+
+    [temp] Add note around example to explain what it's an example of, and
+    add missing paragraph numbers.
+
+commit d37aa67b1bf795d4d98e79a9cc7ca8278608dc4f
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Sun Jul 23 23:48:17 2017 -0700
+
+    [temp] Fix confusion between two different forms of template-declaration.
+
+    When the template-head is followed by a concept-definition, it is not
+    technically followed by a declaration, so avoid claiming that it is.
+
+commit 4d88f30cdbb3d49019935f15340b88b79382c202
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Sun Jul 23 23:38:15 2017 -0700
+
+    [over.over] Switch to passive voice.
+
+commit 78a8901592907f8904ec824b2966414900586869
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Sun Jul 23 23:25:18 2017 -0700
+
+    [expr.prim.req.nested] Remove incorrect (out of date) note.
+
+commit ca3cb945e042dc5bf63edfeeaf6d2e42ce2a3669
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Sun Jul 23 15:01:59 2017 -0700
+
+    [expr.prim.req] Remove redundant note that repeats what the prior example just said.
+
+commit 763a125ca686aae8aaed3fd8f779bf5ad7ca1a5c
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Sun Jul 23 14:58:25 2017 -0700
+
+    [expr.prim.req] Repair meaningless "A requirement is one that [..]" phrasing.
+
+commit fcbeb9e63ad175128a1d7a9f5dc70536f5e2be81
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Sun Jul 23 14:44:30 2017 -0700
+
+    [temp.constr.atomic] Split long paragraph into three.
+
+commit 119b98d70d24612e425fb2ae1b6caffb93689b89
+Author: Jonathan Wakely <cxx@kayari.org>
+Date:   Thu Jul 20 22:30:39 2017 +0100
+
+    [filebuf.virtuals] Refer to return values specified in Effects
+
+    Fixes #1552
+
+commit ecad20efeaf0c244ea6a64d79484a0145a51242b
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Thu Jul 20 09:03:27 2017 -0700
+
+    [expr.mptr.oper] Rephrase wording for symmetry with P0704R1.
+
+commit 32fffbe4796ab0852f7bdf66b6d48d2e2b5e61ea
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Tue Jul 18 21:02:33 2017 +0200
+
+    [iterator.synopsis, template.bitset] Add missing whitespace. (#1673)
+
+commit b7ac9558b63434daa2217b35512225bc3213ebb4
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Sat Jul 15 15:04:54 2017 -0700
+
+    [expr.const] Fix example of integral constant expression conversion to
+    involve integral constant expressions.
+
+    Fixes #1627.
+
+commit cd2cc5c4709f4b8295d71d9fed92f3f2b2393f77
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Sat Jul 15 14:49:27 2017 -0700
+
+    [alg.equal] Fix misapplication of P0467R2: change "no" to "an" in bullet
+    3.2.
+
+    Fixes #1578.
+
+commit b226afc6dcddc427668a47710d13064de23b0167
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Sat Jul 15 14:39:03 2017 -0700
+
+    [stringbuf.virtuals] Note in Returns: element that the return value for
+    non-error cases is specified in the Effects: element.
+
+    Fixes #1552
+
+commit b63b10a9aeb8a7ef0b3f2cbbb9a20be88f0b56b7
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Sat Jul 15 23:21:32 2017 +0200
+
+    [variant.visit], [tuple.apply], [futures.task.members] add cross-references for INVOKE to [func.require]
+
+    Fixes #1480.
+
+commit 8d45c56ea7224266462c6c807987676bcf35e93e
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Sat Jul 15 14:13:14 2017 -0700
+
+    Add missing index entries for 'alignas', alignof', 'noexcept'.
+
+commit 6114f86c1479a9ebf3b27fae694e9157a1a12423
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sat Jul 15 15:51:17 2017 -0400
+
+    Move reference to LIA-1 into a new section 'Bibliography'
+
+commit 488ef200887417bfa6124896549c09447a8c2fa9
+Author: JF Bastien <github@jfbastien.com>
+Date:   Mon Jul 10 22:39:29 2017 -0400
+
+    Clarify a note on cmpxchg
+
+    The "thus" part absolutely does not follow from the preceding note text, and isn't even correct on its own. Since this is a note I assume this is an editorial change and doesn't need an issue.
+
+commit f268d45e51ddadcb21036185900a602c9a502413
+Author: Jonathan Wakely <cxx@kayari.org>
+Date:   Mon Jul 10 17:43:08 2017 +0100
+
+    [filesystem_error.members] Rename to [fs.filesystem_error.members]
+
+    Fixes #1633
+
+commit 331b6a67d4fa55d1f8d4c9eb300c4aa7ce63d27e
+Author: Jonathan Wakely <cxx@kayari.org>
+Date:   Mon Jul 10 17:41:18 2017 +0100
+
+    [stringbuf.virtuals] balance parentheses in seekoff table
+
+commit 48c0e75206dc98cfcb5ea88ebe29fa8858f6448a
+Author: Jonathan Wakely <cxx@kayari.org>
+Date:   Wed Jun 28 11:42:56 2017 +0100
+
+    [memory.syn] Add reinterpret_pointer_cast to synopsis
+
+commit 921ef046dc2daab44f6c7638aef3a03f85a06909
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Apr 7 21:14:43 2017 +0200
+
+    Replace 'encouraged' with 'should'.
+
+    Consistent with ISO Directives, Part 2, encouragement for
+    implementations is supposed to use 'should', not 'encouraged'.
+
+    Fixes #1601.
+
+commit 89fccb39352b0c30b07272e38487dbf9fb67ed76
+Author: Eelis van der Weegen <eelis@eelis.net>
+Date:   Sat Apr 8 12:45:21 2017 +0200
+
+    [temp.deduct.type] Use \cv instead of \grammarterm{cv-list}.
+
+commit 0740877e0dd13b15c411f4b8f1fc489ecffec52f
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Apr 5 23:10:33 2017 +0200
+
+    [string.streams], [file.streams] Use simple-template-id when naming base classes.
+
+    Fixes #1551.
+
+commit 0207b6c6c40a884292a2a7ff1ea8c8a7d08b9d9f
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Apr 5 21:14:24 2017 +0200
+
+    Spell 'well-defined' with a hyphen when it is an adjective.
+
+    Fixes #1587.
+
+commit 2044cbd25d588150bb0a19cc8df2992a88a29e1e
+Author: Richard Smith <richard-github@metafoo.co.uk>
+Date:   Sat Jul 15 11:41:57 2017 -0700
+
+    [basic.def.odr] Replace mid-sentence period with "; and"
+
+commit 95ac3d662c788cdabc382509be4c273e5c80b334
+Author: lewissbaker <lewissbaker@users.noreply.github.com>
+Date:   Thu Jul 6 21:42:46 2017 +0930
+
+    [stmt.if] Fix spelling mistake in 'if constexpr' wording. (#1653)
+
+commit 48da313836eb57fd8282649c6c17b50a9cb97c3a
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Tue Jun 20 14:59:57 2017 -0700
+
+    [lex.string] Remove mention of trigraphs from raw string literal example.
+
+    Fixes #1635.
+
+commit 1268aa09067159b94a6f83267d0a539b81dbbdc6
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Tue Jun 20 14:45:07 2017 -0700
+
+    [meta.unary.prop] Fix typo 'remove_all_extents<T>' which should say
+    'remove_all_extents_t<T>', introduced editorially in commit 79974877.
+
+    Fixes #1644.
+
+commit c92319d1caf3462e1a3a745ea3947d56c974383a
+Author: Evan Wallace <onlyone@senet.com.au>
+Date:   Mon Jun 19 01:56:28 2017 +1000
+
+    [basic.stc.dynamic.safety] Update cross-reference to effects of using invalid pointer values. (#1636)
+
+    Updated the Note describing "invalid pointer values" to refer to [basic.stc] rather than [basic.stc.dynamic.deallocation].
+
+    The relevant description of "invalid pointer values" reads:
+    "Indirection through an invalid pointer value and passing an invalid pointer value to a deallocation function have undefined behavior. Any other use of an invalid pointer value has implementation-defined behavior."
+
+    Previously the reference was correct, as this text was in [basic.stc.dynamic.deallocation]/4, but the text was moved to [basic.stc]/4 by P0137R1; without updating the reference.
+
+    The Note also incorrectly claims that using an invalid pointer value is always undefined, when it can be implementation defined in certain cases, but I did not fix this in this commit; as updating the reference makes this nuance sufficiently clear.
+
+    This is an editorial issue as it only changes non-normative text.
+
+commit 5eeec28487dd99e9e2441fc3e64e33b7a957a8fe
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Sat Jun 17 15:45:17 2017 +0200
+
+    For 'signal-safe', refer to [support.signal], not [csignal.syn]. (#1640)
+
+commit 8c005473ba69d52314d5c399c9c9adb6429cc7ed
+Author: Zhihao Yuan <lichray@gmail.com>
+Date:   Thu May 18 11:36:43 2017 -0500
+
+    [any.nonmembers] fix LWG2769 resolution
+
+    Restores the changes made by #1220
+
+commit e8c2b45b618ef13843dd9fbc3e26f1520c8522a8
+Author: Jonathan Wakely <cxx@kayari.org>
+Date:   Wed May 17 23:06:18 2017 +0100
+
+    [fs.dir.entry.obs] Fix position of error_code arguments
+
+    Fixes #1630
+
+commit ae6271c88727c3fabe7dd8258f8687b369d83d6d
+Author: Jonathan Wakely <cxx@kayari.org>
+Date:   Thu Apr 20 23:06:37 2017 +0100
+
+    [fs.filesystem.syn] Update synopsis for filesystem::absolute
+
+commit c42d836d952219eba62edf1ef47ad763b5e57a54
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Tue Apr 18 11:59:59 2017 +0200
+
+    [streambuf.virt.put] Fix logic error in the specification of the overflow() effects, introduced by 0b640ed8161937d31f31e251c297b658c559a978. (#1613)
+
+commit d5c0fd378f01b1aa9710ac8f2b61a6bc79b27aa5
+Author: Eelis <github.com@contacts.eelis.net>
+Date:   Tue Apr 18 11:57:08 2017 +0200
+
+    [class.protected] Add missing full stop at end of sentence. (#1614)
+
+commit 70a0afc6dfbd5699ab562ebb93b269abde2834ba
+Author: Daniel Grunwald <grunwald@axivion.com>
+Date:   Wed Apr 12 19:19:45 2017 +0200
+
+    [fs.class.path] Add missing semicolon
+
+commit 6debd6037c34befdb156e805912917d154ea658f
+Author: Daniel Grunwald <grunwald@axivion.com>
+Date:   Thu Apr 6 20:47:58 2017 +0200
+
+    [iomanip.syn] Fix std::setfill() template declaration
+
+commit c17b1771be3f51dcea4d7670392ba9052a33c0b1
+Author: Daniel Grunwald <grunwald@axivion.com>
+Date:   Thu Apr 6 20:37:21 2017 +0200
+
+    [cmath.syn] Fix hypot(long double,long double) overload
+
+commit 578c39a0d74543a49da66483059debd7fb1316bc
+Author: Daniel Grunwald <grunwald@axivion.com>
+Date:   Thu Apr 6 20:19:21 2017 +0200
+
+    [cstring.syn], [cwchar.syn] Add a bunch of missing semicolons
+
+commit 07e4d9ceea888564765a2821a0a7d883dd315acb
+Author: Richard Smith <richard@metafoo.co.uk>
+Date:   Tue Apr 11 14:19:51 2017 -0700
+
+    [except.spec] Add missing '~' in comment in example.
+
+    Thanks to Sergey P. Derevyago for reporting this!
+
+commit 98b39118c529e4ed72d707ba325412a61d734f16
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Tue Mar 28 21:55:42 2017 +0200
+
+    [filesystems] Change '!predicate' phrasing to 'predicate is false'.
+
+    Fixes #1535.
+
+commit dff391e0df8e4c8f4bb0eb74ecc6bf2578c18fd0
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Fri Mar 31 21:58:25 2017 +0200
+
+    [lib] Use nullptr, not 0, for null pointer values. (#1586)
+
+    Fixes #208.
+
+commit e030dc8c97ac3da75817ac4867e7c403e55de252
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Tue Mar 28 21:38:48 2017 +0200
+
+    [any.cons] Use 'contained value', not 'contained object'. (#1582)
+
+    Fixes #1580.
+
+commit 389cc2d957a5e9f133c631fa1c23e14bc3dc97fe
+Author: Jonathan Wakely <cxx@kayari.org>
+Date:   Tue Mar 28 16:20:44 2017 +0100
+
+    [any.bad_any_cast] fix incorrect references to bad_any_access
+
+commit a0f6514c5e51714da31a6d0a7aa9a218908a3c86
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sun Mar 26 18:07:52 2017 +0100
+
+    [locale.money.get.members] Fix missing parameter type
+
+commit 5f7e2c6f5711ba3818519ec3b3f2c84d23a8fe93
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sun Mar 26 17:41:45 2017 +0100
+
+    [facet.ctype.char.virtuals] Add missing \pnum
+
+commit b12acc0d4aa1095ed0306e31155c1662205c2437
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Sun Mar 26 16:44:14 2017 +0100
+
+    [category.ctype] Replace unnecessary placeholder type by the usual 'see below'
+
+commit fc9599aea58a7ea7e671f9b304cc1fe3f89c2a8b
+Author: S. B. Tam <cpplearner@outlook.com>
+Date:   Sat Mar 25 20:37:39 2017 +0800
+
+    [utility] Change 'nonzero' to more appropriate words. (#1575)
+
+commit 5d438d2569decb770062966bb347cc4b1eb075b0
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Thu Mar 23 22:14:14 2017 +0100
+
+    [mem.poly.allocator.mem], [string.view.iterators] Replace 'method' with 'member function'.
+
+    Fixes #1573.
+
+commit 6d5ac829064fb264cac2805b0e8fdf193b32b62c
+Author: Jens Maurer <Jens.Maurer@gmx.net>
+Date:   Wed Mar 22 00:25:58 2017 +0100
+
+    [intro.memory] Replace undefined 'field' with 'member' in note.
+
+    Fixes #1569.
+
+commit f04c1dcee22cc5f1dd6d99448f8de4da8ba31ed3
+Author: Thomas Köppe <tkoeppe@google.com>
+Date:   Fri Mar 24 23:54:54 2017 +0000
+
+    [except.handle, except.spec, fs.op.temp_dir_path] Fix typos
+
diff --git a/papers/n4688.md b/papers/n4688.md new file mode 100644 index 0000000000..8ce5443f5a --- /dev/null +++ b/papers/n4688.md @@ -0,0 +1,682 @@ +# N4688 Editors' Report -- Programming Languages -- C++ + +2017-07-30 +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, +Jonathan Wakely, +and Eelis van der Weegen +for performing many of the editorial fixes since N4659. + +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 + + * [N4687](http://wg21.link/n4687) is the current working draft for C++20. It replaces [N4659](http://wg21.link/n4659). + * N4688 is this Editors' Report. + +## Motions incorporated into working draft + +### Core working group motions + +CWG motion 1: [Core issue resolution](http://wg21.link/p0710r1) for 1 issue in "ready" status applied: + + * [2253](http://wg21.link/cwg2253) Unnamed bit-fields and zero-initialization + +CWG motion 2: [Core issue resolutions](http://wg21.link/p0711r0) for 6 issues in "tentatively ready" status applied, resolving 8 issues: + + * [1523](http://wg21.link/cwg1523) Point of declaration in range-based for + * [1704](http://wg21.link/cwg1704) Type checking in explicit instantiation of variable templates + * [1728](http://wg21.link/cwg1728) Type of an explicit instantiation of a variable template (no changes, resolved by 1704) + * [1836](http://wg21.link/cwg1836) Use of class type being defined in trailing-return-type + * [2273](http://wg21.link/cwg2273) Inheriting constructors vs implicit default constructor + * [2277](http://wg21.link/cwg2277) Ambiguity inheriting constructors with default arguments (no changes, resolved by 2273) + * [2287](http://wg21.link/cwg2287) Pointer-interconvertibility in non-standard-layout unions + * [2290](http://wg21.link/cwg2290) Unclear specification for overload resolution and deleted special member functions + +CWG motion 3: [P0727R0 "Temporary objects vs temporary expressions"](http://wg21.link/p0727r0), resolving 3 core issue: + + * [943](http://wg21.link/cwg943) Is `T()` a temporary? + * [1076](http://wg21.link/cwg1076) Value categories and lvalue temporaries + * [1299](http://wg21.link/cwg1299) "Temporary objects" vs "temporary expressions" + +CWG motion 4: [P0683R1 "Default member initializers for bit-fields"](http://wg21.link/p0683r1) + +CWG motion 5: [P0704R1 "Fixing `const`-qualified pointers to members"](http://wg21.link/p0704r1) + +CWG motion 6: [P0409R2 "Allow lambda capture `[=, this]`"](http://wg21.link/p0409r2) + +CWG motion 7: [P0306R4 "Comma omission and comma deletion"](http://wg21.link/p0306r4) + +CWG motion 8: [P0329R4 "Designated initialization"](http://wg21.link/p0329r4) + +CWG motion 9: [P0428R2 "Familiar template syntax for generic lambdas"](http://wg21.link/p0428r2) + +CWG motion 10: [P0702R1 "Language support for constructor template argument deduction"](http://wg21.link/p0702r1) + +CWG motion 11: [P0734R0 "Concepts"](http://wg21.link/p0734r0) **with changes, see below** + +CWG motion 12 applies to the Modules TS. + +### Library working group motions + +LWG motion 13-14 apply to the Coroutines TS. + +LWG motion 15-22 apply to the Ranges TS. + +LWG motion 23-29 apply to the Networking TS. + +LWG motion 30 applies to the Parallelism TS. + +LWG motion 31: [Library issue resolutions](http://wg21.link/p0698r0) for 12 issues in "Ready" and "Tentatively Ready" status applied: + + * [2444](http://wg21.link/lwg2444) Inconsistent complexity for `std::sort_heap` + * [2593](http://wg21.link/lwg2593) Moved-from state of `Allocator`s + * [2597](http://wg21.link/lwg2597) `std::log` misspecified for complex numbers + * [2783](http://wg21.link/lwg2783) `stack::emplace()` and `queue::emplace()` should return `decltype(auto)` + * [2932](http://wg21.link/lwg2932) Constraints on parallel algorithm implementations are underspecified + * [2937](http://wg21.link/lwg2937) Is `equivalent("existing_thing", "not_existing_thing")` an error? + * [2940](http://wg21.link/lwg2940) `result_of` specification also needs a little cleanup + * [2942](http://wg21.link/lwg2942) [LWG 2873](http://wg21.link/lwg2873)'s resolution missed `weak_ptr::owner_before` + * [2954](http://wg21.link/lwg2954) Specialization of the convenience variable templates should be prohibited + * [2961](http://wg21.link/lwg2961) Bad postcondition for `set_default_resource` + * [2966](http://wg21.link/lwg2966) Incomplete resolution of US 74 + * [2974](http://wg21.link/lwg2974) Diagnose out of bounds `tuple_element` / `variant_alternative` + +LWG motion 32: [Library issue resolutions](http://wg21.link/p0699r0) for 2 issues in "Immediate" status applied: + + * [2901](http://wg21.link/lwg2901) `variant`s cannot properly support allocators + * [2956](http://wg21.link/lwg2956) `filesystem::canonical()` still defined in terms of `absolute(p, base)` + +LWG motion 33: [P0463R1 "Endian, just endian"](http://wg21.link/p0463r1) + +LWG motion 34: [P0682R1: "Repairing elementary string conversions"](http://wg21.link/p0682r1), resolving 1 library issue: + + * [2955](http://wg21.link/lwg2955) `to_chars` / `from_chars` depend on `std::string` + +LWG motion 35: [P0739R0 "Some improvements to class template argument deduction integration into the standard library"](http://wg21.link/p0739r0), resolving 2 as-yet-unnumbered library issues + +LWG motion 36: [P0674R1 "Extending `make_shared` to support arrays"](http://wg21.link/p0674r1), resolving 1 library issue: + + * [2070](http://wg21.link/lwg2070) `allocate_shared` should use `allocator_traits::construct` + +## Notable editorial changes + +### Motions + + * CWG 11: The grammar production for a `concept` definition missed the trailing `;`. + This has been rectified editorially, reflecting the obvious intent of the committee. + Two changes adding "concepts" to lists of entities have not been changed, because + a concept is a template and "templates" in general were already in the relevant list. + Several other changes were made rephrasing the wording to match the prevailing style of + the working draft. + +### Stable name changes + +The "Cross references from ISO C++ 2014" section has been replaced by a +"Cross references from ISO C++ 2017" section. + +## Minor editorial fixes + +A log of editorial fixes made since N4659 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/n4659...n4687). + + commit 9b13e3785ef95f3c7ac159177a03bccd610b774b + Author: Richard Smith + Date: Sun Jul 30 16:13:25 2017 -0700 + + [dcl.array] Consolidate redundant, repetitive, and somewhat incorrect + examples and notes on multidimensional arrays. + + Fixes #1645 + + commit 19c63142301038e843bfd23676e036768ab35c96 + Author: S. B. Tam + Date: Sun Jul 30 23:50:06 2017 +0800 + + [expr.const] Move p7 next to p3. + + commit bbca26c5e79d52a1622ff0cedeb92897a1350bf9 + Author: Jens Maurer + Date: Wed Apr 5 20:23:15 2017 +0200 + + [expr.type.conv] Clarify if ... otherwise ladder. + + Fixes #1591. + + commit 9f16f5ae4a54f2478d268c408100c5a005d3f278 + Author: Jens Maurer + Date: Sat Jul 22 00:57:55 2017 +0200 + + [expr] Use 'possibly converted' for discarded-value expression. + + Fixes #1597. + + commit 8d7a1a767f933e917b6bb20eea3e1c5fabf1cc0c + Author: Jens Maurer + Date: Wed Mar 29 20:42:39 2017 +0200 + + [class.mfct.non-static], [class.this] Define and use cv member function. + + Fixes #447. + + commit 1314cc49a106fac2acba29e0e301343f857ba252 + Author: Casey Carter + Date: Wed May 10 13:24:59 2017 -0700 + + Change the return type of monotonic_buffer_resource's deleted assignment + + ... to monotonic_buffer_resource& for consistency with the default definition of the builtin assignment operator. This change has no normative effect, it only eliminates the inconsistency as a potential source of confusion. + + Since the return type of deleted functions is not observable, this change is editorial. + + commit c85f24dee9feb613c9454db572cd674234f3159f + Author: Thomas Köppe + Date: Sat Mar 25 16:20:40 2017 +0000 + + [string.cons] Consolidate two functions into one description + + commit f897604bd8cab510a843153db0133c3d5e13912f + Author: Jens Maurer + Date: Sat Jul 22 00:31:23 2017 +0200 + + [class.temporary] Remove note giving questionable implementation advice. + + And move the surviving part of the note to before the + corresponding example. + + Fixes #1674. + + commit 10e4c7437ba63c2975a160e84aecffdbfafd990b + Author: Hubert Tong + Date: Mon Jul 24 17:45:16 2017 -0400 + + [over.call.object] Reference postfix-expression in call syntax correctly + + The grammar production corresponding to the call syntax has + _postfix-expression_ as the callee operand. [over.call.object] appears + to refer to this operand as the _primary-expression_ in the syntax. + + commit ad966418d82b4e5480ad390a5f75ffbf37385f37 + Author: Richard Smith + Date: Fri Jul 28 17:16:07 2017 -0700 + + [temp] Add missing ';' to grammar for concept-definition. + + Despite being a normative change, this matches the overwhelmingly + obvious intent of the committee. + + Fixes #1686 + + commit afd6d4f065219067f372dafd1bb590a912775b41 + Author: Richard Smith + Date: Fri Jul 28 17:13:28 2017 -0700 + + [temp.constr.normal] Give a proper definition for "normalization". + + commit 38408888321282f9c0788ec9c40e2bd2f464617b + Author: Richard Smith + Date: Fri Jul 28 16:47:17 2017 -0700 + + [temp.constr.order] Fix spacing in example. + + commit aa4b1ae864fb85377570ba9775b5d34d79772922 + Author: Richard Smith + Date: Fri Jul 28 16:42:40 2017 -0700 + + [temp.constr.order] Clarify description of subsumption and ordering by constraints. + + commit 508cd59e6c9b23441ce5ed46e5012ccd1a8aed51 + Author: Richard Smith + Date: Fri Jul 28 11:24:51 2017 -0700 + + [dcl.fct.def] Reword = default ; and = delete ; introductory text for clarity. + + commit 182937c038dec15efaf5521d53d06960d6f1d661 + Author: Richard Smith + Date: Fri Jul 28 11:20:18 2017 -0700 + + [dcl.fct] Move use of "parameter-type-list" to after its definition. + + Split rules on function redeclarations out of rules for determining the + type of an individual function. + + commit ac6360546cb1eb982cf8d2123ceb2c99a0156b95 + Author: Richard Smith + Date: Wed Jul 26 14:22:49 2017 -0700 + + [expr.prim.req] Use grammar terms rather than undefined phrases when + referring to kinds of *requirement*. + + commit ff1242c4aa50958fa0380208eb0f2c45e3a8fea2 + Author: Thomas Köppe + Date: Tue Jul 25 13:49:18 2017 +0100 + + [meta.endian] Simplify wording, avoid "shall" + + commit 17820beb537c1576fe906228d741b64b9b2e8fc1 + Author: Richard Smith + Date: Mon Jul 24 11:22:34 2017 -0700 + + [temp] Fix example to use valid expression in requires-clause. + + commit 02574b8575c200095aa281d0886a73fe58c00580 + Author: Richard Smith + Date: Mon Jul 24 00:37:34 2017 -0700 + + [temp.inst] Tweak explanation in example. + + commit de236bab92922adc3c38f6fc0eb1fb4ec2a17c16 + Author: Richard Smith + Date: Mon Jul 24 00:36:24 2017 -0700 + + [temp.inst] Fix typo 'the the'. + + commit a76a3886035f484866add3a12af43c3b21143aa1 + Author: Richard Smith + Date: Mon Jul 24 00:34:07 2017 -0700 + + [temp.concept] Remove redundancy: the global scope is a namespace scope. + + commit 9a94a384336cb37974b3a8803dcf2424812ec854 + Author: Richard Smith + Date: Mon Jul 24 00:27:55 2017 -0700 + + [temp.class.spec] Fix typo "the primary" -> "the primary template". + + commit 7240fc98453bad27eb6112ae98b0f8e8fad8e39a + Author: Richard Smith + Date: Mon Jul 24 00:25:43 2017 -0700 + + [temp.mem.func] Add introductory text to new example to separate it from the prior example. + + commit 99013e76613ec877b912b18b3ffeb9d2b1cf8f1c + Author: Richard Smith + Date: Mon Jul 24 00:20:39 2017 -0700 + + [expr.prim.req.compound] Switch to passive voice. + + commit 1f1b944f2d849974ae01a5f2c45883d8213c3653 + Author: Richard Smith + Date: Mon Jul 24 00:04:15 2017 -0700 + + [temp.param] Switch to passive voice. + + commit 6568af0b4270bfc1497882a108741fa01ebeaa70 + Author: Richard Smith + Date: Sun Jul 23 23:54:34 2017 -0700 + + [temp] Add note around example to explain what it's an example of, and + add missing paragraph numbers. + + commit d37aa67b1bf795d4d98e79a9cc7ca8278608dc4f + Author: Richard Smith + Date: Sun Jul 23 23:48:17 2017 -0700 + + [temp] Fix confusion between two different forms of template-declaration. + + When the template-head is followed by a concept-definition, it is not + technically followed by a declaration, so avoid claiming that it is. + + commit 4d88f30cdbb3d49019935f15340b88b79382c202 + Author: Richard Smith + Date: Sun Jul 23 23:38:15 2017 -0700 + + [over.over] Switch to passive voice. + + commit 78a8901592907f8904ec824b2966414900586869 + Author: Richard Smith + Date: Sun Jul 23 23:25:18 2017 -0700 + + [expr.prim.req.nested] Remove incorrect (out of date) note. + + commit ca3cb945e042dc5bf63edfeeaf6d2e42ce2a3669 + Author: Richard Smith + Date: Sun Jul 23 15:01:59 2017 -0700 + + [expr.prim.req] Remove redundant note that repeats what the prior example just said. + + commit 763a125ca686aae8aaed3fd8f779bf5ad7ca1a5c + Author: Richard Smith + Date: Sun Jul 23 14:58:25 2017 -0700 + + [expr.prim.req] Repair meaningless "A requirement is one that [..]" phrasing. + + commit fcbeb9e63ad175128a1d7a9f5dc70536f5e2be81 + Author: Richard Smith + Date: Sun Jul 23 14:44:30 2017 -0700 + + [temp.constr.atomic] Split long paragraph into three. + + commit 119b98d70d24612e425fb2ae1b6caffb93689b89 + Author: Jonathan Wakely + Date: Thu Jul 20 22:30:39 2017 +0100 + + [filebuf.virtuals] Refer to return values specified in Effects + + Fixes #1552 + + commit ecad20efeaf0c244ea6a64d79484a0145a51242b + Author: Richard Smith + Date: Thu Jul 20 09:03:27 2017 -0700 + + [expr.mptr.oper] Rephrase wording for symmetry with P0704R1. + + commit 32fffbe4796ab0852f7bdf66b6d48d2e2b5e61ea + Author: Eelis + Date: Tue Jul 18 21:02:33 2017 +0200 + + [iterator.synopsis, template.bitset] Add missing whitespace. (#1673) + + commit b7ac9558b63434daa2217b35512225bc3213ebb4 + Author: Richard Smith + Date: Sat Jul 15 15:04:54 2017 -0700 + + [expr.const] Fix example of integral constant expression conversion to + involve integral constant expressions. + + Fixes #1627. + + commit cd2cc5c4709f4b8295d71d9fed92f3f2b2393f77 + Author: Richard Smith + Date: Sat Jul 15 14:49:27 2017 -0700 + + [alg.equal] Fix misapplication of P0467R2: change "no" to "an" in bullet + 3.2. + + Fixes #1578. + + commit b226afc6dcddc427668a47710d13064de23b0167 + Author: Richard Smith + Date: Sat Jul 15 14:39:03 2017 -0700 + + [stringbuf.virtuals] Note in Returns: element that the return value for + non-error cases is specified in the Effects: element. + + Fixes #1552 + + commit b63b10a9aeb8a7ef0b3f2cbbb9a20be88f0b56b7 + Author: Jens Maurer + Date: Sat Jul 15 23:21:32 2017 +0200 + + [variant.visit], [tuple.apply], [futures.task.members] add cross-references for INVOKE to [func.require] + + Fixes #1480. + + commit 8d45c56ea7224266462c6c807987676bcf35e93e + Author: Richard Smith + Date: Sat Jul 15 14:13:14 2017 -0700 + + Add missing index entries for 'alignas', alignof', 'noexcept'. + + commit 6114f86c1479a9ebf3b27fae694e9157a1a12423 + Author: Thomas Köppe + Date: Sat Jul 15 15:51:17 2017 -0400 + + Move reference to LIA-1 into a new section 'Bibliography' + + commit 488ef200887417bfa6124896549c09447a8c2fa9 + Author: JF Bastien + Date: Mon Jul 10 22:39:29 2017 -0400 + + Clarify a note on cmpxchg + + The "thus" part absolutely does not follow from the preceding note text, and isn't even correct on its own. Since this is a note I assume this is an editorial change and doesn't need an issue. + + commit f268d45e51ddadcb21036185900a602c9a502413 + Author: Jonathan Wakely + Date: Mon Jul 10 17:43:08 2017 +0100 + + [filesystem_error.members] Rename to [fs.filesystem_error.members] + + Fixes #1633 + + commit 331b6a67d4fa55d1f8d4c9eb300c4aa7ce63d27e + Author: Jonathan Wakely + Date: Mon Jul 10 17:41:18 2017 +0100 + + [stringbuf.virtuals] balance parentheses in seekoff table + + commit 48c0e75206dc98cfcb5ea88ebe29fa8858f6448a + Author: Jonathan Wakely + Date: Wed Jun 28 11:42:56 2017 +0100 + + [memory.syn] Add reinterpret_pointer_cast to synopsis + + commit 921ef046dc2daab44f6c7638aef3a03f85a06909 + Author: Jens Maurer + Date: Fri Apr 7 21:14:43 2017 +0200 + + Replace 'encouraged' with 'should'. + + Consistent with ISO Directives, Part 2, encouragement for + implementations is supposed to use 'should', not 'encouraged'. + + Fixes #1601. + + commit 89fccb39352b0c30b07272e38487dbf9fb67ed76 + Author: Eelis van der Weegen + Date: Sat Apr 8 12:45:21 2017 +0200 + + [temp.deduct.type] Use \cv instead of \grammarterm{cv-list}. + + commit 0740877e0dd13b15c411f4b8f1fc489ecffec52f + Author: Jens Maurer + Date: Wed Apr 5 23:10:33 2017 +0200 + + [string.streams], [file.streams] Use simple-template-id when naming base classes. + + Fixes #1551. + + commit 0207b6c6c40a884292a2a7ff1ea8c8a7d08b9d9f + Author: Jens Maurer + Date: Wed Apr 5 21:14:24 2017 +0200 + + Spell 'well-defined' with a hyphen when it is an adjective. + + Fixes #1587. + + commit 2044cbd25d588150bb0a19cc8df2992a88a29e1e + Author: Richard Smith + Date: Sat Jul 15 11:41:57 2017 -0700 + + [basic.def.odr] Replace mid-sentence period with "; and" + + commit 95ac3d662c788cdabc382509be4c273e5c80b334 + Author: lewissbaker + Date: Thu Jul 6 21:42:46 2017 +0930 + + [stmt.if] Fix spelling mistake in 'if constexpr' wording. (#1653) + + commit 48da313836eb57fd8282649c6c17b50a9cb97c3a + Author: Richard Smith + Date: Tue Jun 20 14:59:57 2017 -0700 + + [lex.string] Remove mention of trigraphs from raw string literal example. + + Fixes #1635. + + commit 1268aa09067159b94a6f83267d0a539b81dbbdc6 + Author: Richard Smith + Date: Tue Jun 20 14:45:07 2017 -0700 + + [meta.unary.prop] Fix typo 'remove_all_extents' which should say + 'remove_all_extents_t', introduced editorially in commit 79974877. + + Fixes #1644. + + commit c92319d1caf3462e1a3a745ea3947d56c974383a + Author: Evan Wallace + Date: Mon Jun 19 01:56:28 2017 +1000 + + [basic.stc.dynamic.safety] Update cross-reference to effects of using invalid pointer values. (#1636) + + Updated the Note describing "invalid pointer values" to refer to [basic.stc] rather than [basic.stc.dynamic.deallocation]. + + The relevant description of "invalid pointer values" reads: + "Indirection through an invalid pointer value and passing an invalid pointer value to a deallocation function have undefined behavior. Any other use of an invalid pointer value has implementation-defined behavior." + + Previously the reference was correct, as this text was in [basic.stc.dynamic.deallocation]/4, but the text was moved to [basic.stc]/4 by P0137R1; without updating the reference. + + The Note also incorrectly claims that using an invalid pointer value is always undefined, when it can be implementation defined in certain cases, but I did not fix this in this commit; as updating the reference makes this nuance sufficiently clear. + + This is an editorial issue as it only changes non-normative text. + + commit 5eeec28487dd99e9e2441fc3e64e33b7a957a8fe + Author: Eelis + Date: Sat Jun 17 15:45:17 2017 +0200 + + For 'signal-safe', refer to [support.signal], not [csignal.syn]. (#1640) + + commit 8c005473ba69d52314d5c399c9c9adb6429cc7ed + Author: Zhihao Yuan + Date: Thu May 18 11:36:43 2017 -0500 + + [any.nonmembers] fix LWG2769 resolution + + Restores the changes made by #1220 + + commit e8c2b45b618ef13843dd9fbc3e26f1520c8522a8 + Author: Jonathan Wakely + Date: Wed May 17 23:06:18 2017 +0100 + + [fs.dir.entry.obs] Fix position of error_code arguments + + Fixes #1630 + + commit ae6271c88727c3fabe7dd8258f8687b369d83d6d + Author: Jonathan Wakely + Date: Thu Apr 20 23:06:37 2017 +0100 + + [fs.filesystem.syn] Update synopsis for filesystem::absolute + + commit c42d836d952219eba62edf1ef47ad763b5e57a54 + Author: Eelis + Date: Tue Apr 18 11:59:59 2017 +0200 + + [streambuf.virt.put] Fix logic error in the specification of the overflow() effects, introduced by 0b640ed8161937d31f31e251c297b658c559a978. (#1613) + + commit d5c0fd378f01b1aa9710ac8f2b61a6bc79b27aa5 + Author: Eelis + Date: Tue Apr 18 11:57:08 2017 +0200 + + [class.protected] Add missing full stop at end of sentence. (#1614) + + commit 70a0afc6dfbd5699ab562ebb93b269abde2834ba + Author: Daniel Grunwald + Date: Wed Apr 12 19:19:45 2017 +0200 + + [fs.class.path] Add missing semicolon + + commit 6debd6037c34befdb156e805912917d154ea658f + Author: Daniel Grunwald + Date: Thu Apr 6 20:47:58 2017 +0200 + + [iomanip.syn] Fix std::setfill() template declaration + + commit c17b1771be3f51dcea4d7670392ba9052a33c0b1 + Author: Daniel Grunwald + Date: Thu Apr 6 20:37:21 2017 +0200 + + [cmath.syn] Fix hypot(long double,long double) overload + + commit 578c39a0d74543a49da66483059debd7fb1316bc + Author: Daniel Grunwald + Date: Thu Apr 6 20:19:21 2017 +0200 + + [cstring.syn], [cwchar.syn] Add a bunch of missing semicolons + + commit 07e4d9ceea888564765a2821a0a7d883dd315acb + Author: Richard Smith + Date: Tue Apr 11 14:19:51 2017 -0700 + + [except.spec] Add missing '~' in comment in example. + + Thanks to Sergey P. Derevyago for reporting this! + + commit 98b39118c529e4ed72d707ba325412a61d734f16 + Author: Jens Maurer + Date: Tue Mar 28 21:55:42 2017 +0200 + + [filesystems] Change '!predicate' phrasing to 'predicate is false'. + + Fixes #1535. + + commit dff391e0df8e4c8f4bb0eb74ecc6bf2578c18fd0 + Author: Jens Maurer + Date: Fri Mar 31 21:58:25 2017 +0200 + + [lib] Use nullptr, not 0, for null pointer values. (#1586) + + Fixes #208. + + commit e030dc8c97ac3da75817ac4867e7c403e55de252 + Author: Jens Maurer + Date: Tue Mar 28 21:38:48 2017 +0200 + + [any.cons] Use 'contained value', not 'contained object'. (#1582) + + Fixes #1580. + + commit 389cc2d957a5e9f133c631fa1c23e14bc3dc97fe + Author: Jonathan Wakely + Date: Tue Mar 28 16:20:44 2017 +0100 + + [any.bad_any_cast] fix incorrect references to bad_any_access + + commit a0f6514c5e51714da31a6d0a7aa9a218908a3c86 + Author: Thomas Köppe + Date: Sun Mar 26 18:07:52 2017 +0100 + + [locale.money.get.members] Fix missing parameter type + + commit 5f7e2c6f5711ba3818519ec3b3f2c84d23a8fe93 + Author: Thomas Köppe + Date: Sun Mar 26 17:41:45 2017 +0100 + + [facet.ctype.char.virtuals] Add missing \pnum + + commit b12acc0d4aa1095ed0306e31155c1662205c2437 + Author: Thomas Köppe + Date: Sun Mar 26 16:44:14 2017 +0100 + + [category.ctype] Replace unnecessary placeholder type by the usual 'see below' + + commit fc9599aea58a7ea7e671f9b304cc1fe3f89c2a8b + Author: S. B. Tam + Date: Sat Mar 25 20:37:39 2017 +0800 + + [utility] Change 'nonzero' to more appropriate words. (#1575) + + commit 5d438d2569decb770062966bb347cc4b1eb075b0 + Author: Jens Maurer + Date: Thu Mar 23 22:14:14 2017 +0100 + + [mem.poly.allocator.mem], [string.view.iterators] Replace 'method' with 'member function'. + + Fixes #1573. + + commit 6d5ac829064fb264cac2805b0e8fdf193b32b62c + Author: Jens Maurer + Date: Wed Mar 22 00:25:58 2017 +0100 + + [intro.memory] Replace undefined 'field' with 'member' in note. + + Fixes #1569. + + commit f04c1dcee22cc5f1dd6d99448f8de4da8ba31ed3 + Author: Thomas Köppe + Date: Fri Mar 24 23:54:54 2017 +0000 + + [except.handle, except.spec, fs.op.temp_dir_path] Fix typos + diff --git a/source/access.tex b/source/access.tex index 77ccc72669..0698835c48 100644 --- a/source/access.tex +++ b/source/access.tex @@ -69,8 +69,8 @@ \begin{note} Access control applies to names nominated by \tcode{friend} -declarations~(\ref{class.friend}) and -\grammarterm{using-declaration}{s}~(\ref{namespace.udecl}). +declarations\iref{class.friend} and +\grammarterm{using-declaration}{s}\iref{namespace.udecl}. \end{note} In the case of overloaded function names, access control is applied to the function selected by overload resolution. @@ -109,7 +109,7 @@ the construct is ill-formed. \pnum -All access controls in Clause~\ref{class.access} affect the ability to access a class member +All access controls in \ref{class.access} affect the ability to access a class member name from the declaration of a particular entity, including parts of the declaration preceding the name of the entity being declared and, if the entity is a class, the definitions of members of @@ -167,14 +167,14 @@ \pnum \indextext{argument!access checking and default}% \indextext{access control!default argument}% -The names in a default argument~(\ref{dcl.fct.default}) are +The names in a default argument\iref{dcl.fct.default} are bound at the point of declaration, and access is checked at that point rather than at any points of use of the default argument. Access checking for default arguments in function templates and in member functions of class templates is performed as described in~\ref{temp.inst}. \pnum -The names in a default \grammarterm{template-argument}~(\ref{temp.param}) +The names in a default \grammarterm{template-argument}\iref{temp.param} have their access checked in the context in which they appear rather than at any points of use of the default \grammarterm{template-argument}. \begin{example} \begin{codeblock} @@ -197,7 +197,7 @@ \pnum Member declarations can be labeled by an \grammarterm{access-specifier} -(Clause~\ref{class.derived}): +(\ref{class.derived}): \begin{ncbnftab} access-specifier \terminal{:} member-specification\opt @@ -286,7 +286,7 @@ \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 +If a class is declared to be a base class\iref{class.derived} for another class using the \tcode{public} access specifier, the \tcode{public} @@ -314,7 +314,7 @@ \tcode{protected} members of the base class are accessible as \tcode{private} -members of the derived class\footnote{As specified previously in Clause~\ref{class.access}, +members of the derived class\footnote{As specified previously in \ref{class.access}, private members of a base class remain inaccessible even to derived classes unless \tcode{friend} @@ -369,7 +369,7 @@ \begin{note} A member of a private base class might be inaccessible as an inherited member name, but accessible directly. -Because of the rules on pointer conversions~(\ref{conv.ptr}) and explicit casts~(\ref{expr.cast}), a conversion from a pointer to a derived class to a pointer +Because of the rules on pointer conversions\iref{conv.ptr} and explicit casts\iref{expr.cast}, a conversion from a pointer to a derived class to a pointer to an inaccessible base class might be ill-formed if an implicit conversion is used, but well-formed if an explicit cast is used. For example, @@ -491,7 +491,7 @@ \begin{note} This class can be explicit, e.g., when a \grammarterm{qualified-id} -is used, or implicit, e.g., when a class member access operator~(\ref{expr.ref}) is used (including cases where an implicit +is used, or implicit, e.g., when a class member access operator\iref{expr.ref} is used (including cases where an implicit ``\tcode{this->}'' is added). @@ -684,7 +684,7 @@ \begin{note} A \tcode{friend} declaration may be the \term{declaration} in a \grammarterm{template-declaration} -(Clause~\ref{temp}, \ref{temp.friend}).\end{note} If the +(\ref{temp}, \ref{temp.friend}).\end{note} If the type specifier in a \tcode{friend} declaration designates a (possibly cv-qualified) class type, that class is declared as a friend; otherwise, the \tcode{friend} declaration is ignored. \begin{example} @@ -715,8 +715,8 @@ \pnum \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}). +has the linkage of the namespace of which it is a member\iref{basic.link}. +Otherwise, the function retains its previous linkage\iref{dcl.stc}. \pnum \indextext{declaration!overloaded name and \tcode{friend}}% @@ -744,7 +744,7 @@ \pnum \indextext{friend function!inline}% A function can be defined in a friend declaration of a class if and only if the -class is a non-local class~(\ref{class.local}), the function name is unqualified, +class is a non-local class\iref{class.local}, the function name is unqualified, and the function has namespace scope. \begin{example} @@ -757,11 +757,11 @@ \end{example} \pnum -Such a function is implicitly an inline function~(\ref{dcl.inline}). +Such a function is implicitly an inline function\iref{dcl.inline}. A \tcode{friend} function defined in a class is in the (lexical) scope of the class in which it is defined. -A friend function defined outside the class is not~(\ref{basic.lookup.unqual}). +A friend function defined outside the class is not\iref{basic.lookup.unqual}. \pnum No @@ -779,7 +779,7 @@ \tcode{private}, \tcode{protected} or -\tcode{public}~(\ref{class.mem}) +\tcode{public}\iref{class.mem} portion of the class \grammarterm{member-specification}. @@ -815,7 +815,7 @@ \pnum \indextext{local class!friend}% \indextext{friend!local class and}% -If a friend declaration appears in a local class~(\ref{class.local}) and the +If a friend declaration appears in a local class\iref{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 non-class scope. @@ -853,17 +853,17 @@ \indextext{access control!\idxcode{protected}}% \pnum -An additional access check beyond those described earlier in Clause~\ref{class.access} +An additional access check beyond those described earlier in \ref{class.access} is applied when a non-static data member or non-static member function is a -protected member of its naming class~(\ref{class.access.base})\footnote{This +protected member of its naming class\iref{class.access.base}.\footnote{This additional check does not apply to other members, e.g., static data members or enumerator member constants.} As described earlier, access to a protected member is granted because the reference occurs in a friend or member of some class \tcode{C}. If the access is -to form a pointer to member~(\ref{expr.unary.op}), the +to form a pointer to member\iref{expr.unary.op}, the \grammarterm{nested-name-specifier} shall denote \tcode{C} or a class derived from \tcode{C}. All other accesses involve a (possibly implicit) object -expression~(\ref{expr.ref}). In this case, the class of the object expression shall be +expression\iref{expr.ref}. In this case, the class of the object expression shall be \tcode{C} or a class derived from \tcode{C}. \begin{example} @@ -916,7 +916,7 @@ \indextext{access control!virtual function} \pnum -The access rules (Clause~\ref{class.access}) for a virtual function are determined by its declaration +The access rules\iref{class.access} for a virtual function are determined by its declaration and are not affected by the rules for a function that later overrides it. \begin{example} @@ -984,7 +984,7 @@ \pnum A nested class is a member and as such has the same access rights as any other member. 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. +class; the usual access rules\iref{class.access} shall be obeyed. \begin{example} \indextext{example!nested class definition}% diff --git a/source/algorithms.tex b/source/algorithms.tex index 1a8ffe5d77..a32c43ea77 100644 --- a/source/algorithms.tex +++ b/source/algorithms.tex @@ -5,7 +5,7 @@ \pnum This Clause describes components that \Cpp programs may use to perform -algorithmic operations on containers (Clause~\ref{containers}) and other sequences. +algorithmic operations on containers\iref{containers} and other sequences. \pnum The following subclauses describe components for @@ -1074,7 +1074,7 @@ or \tcode{Input\-Iterator2}, the template argument shall satisfy the -requirements of an input iterator~(\ref{input.iterators}). +requirements of an input iterator\iref{input.iterators}. \item If an algorithm's template parameter is named \tcode{OutputIterator}, @@ -1082,7 +1082,7 @@ or \tcode{Output\-Iterator2}, the template argument shall satisfy the requirements -of an output iterator~(\ref{output.iterators}). +of an output iterator\iref{output.iterators}. \item If an algorithm's template parameter is named \tcode{ForwardIterator}, @@ -1090,7 +1090,7 @@ or \tcode{Forward\-Iterator2}, the template argument shall satisfy the requirements -of a forward iterator~(\ref{forward.iterators}). +of a forward iterator\iref{forward.iterators}. \item If an algorithm's template parameter is named \tcode{BidirectionalIterator}, @@ -1098,7 +1098,7 @@ or \tcode{BidirectionalIterator2}, the template argument shall satisfy the requirements -of a bidirectional iterator~(\ref{bidirectional.iterators}). +of a bidirectional iterator\iref{bidirectional.iterators}. \item If an algorithm's template parameter is named \tcode{RandomAccessIterator}, @@ -1106,7 +1106,7 @@ or \tcode{RandomAccessIterator2}, the template argument shall satisfy the requirements -of a random-access iterator~(\ref{random.access.iterators}). +of a random-access iterator\iref{random.access.iterators}. \end{itemize} \pnum @@ -1116,7 +1116,7 @@ as an argument is modified, then that algorithm has an additional type requirement: The type of that argument shall satisfy the requirements -of a mutable iterator~(\ref{iterator.requirements}). +of a mutable iterator\iref{iterator.requirements}. \begin{note} This requirement does not affect arguments that are named \tcode{OutputIterator}, @@ -1140,7 +1140,7 @@ \pnum The \tcode{Predicate} -parameter is used whenever an algorithm expects a function object~(\ref{function.objects}) +parameter is used whenever an algorithm expects a function object\iref{function.objects} that, when applied to the result of dereferencing the corresponding iterator, returns a value testable as \tcode{true}. @@ -1150,7 +1150,7 @@ as its argument and \tcode{first} as its iterator argument, it should work correctly in the construct -\tcode{pred(*first)} contextually converted to \tcode{bool} (Clause~\ref{conv}). +\tcode{pred(*first)} contextually converted to \tcode{bool}\iref{conv}. The function object \tcode{pred} shall not apply any non-constant @@ -1172,7 +1172,7 @@ as its argument and \tcode{first1} and \tcode{first2} as its iterator arguments, it should work correctly in the construct -\tcode{binary_pred(*first1, *first2)} contextually converted to \tcode{bool} (Clause~\ref{conv}). +\tcode{binary_pred(*first1, *first2)} contextually converted to \tcode{bool}\iref{conv}. \tcode{BinaryPredicate} always takes the first iterator's \tcode{value_type} @@ -1180,7 +1180,7 @@ \tcode{T value} is part of the signature, it should work correctly in the -construct \tcode{binary_pred(*first1, value)} contextually converted to \tcode{bool} (Clause~\ref{conv}). +construct \tcode{binary_pred(*first1, value)} contextually converted to \tcode{bool}\iref{conv}. \tcode{binary_pred} shall not apply any non-constant function through the dereferenced iterators. @@ -1189,7 +1189,7 @@ Unless otherwise specified, algorithms that take function objects as arguments are permitted to copy those function objects freely. Programmers for whom object identity is important should consider using a wrapper class that points to a -noncopied implementation object such as \tcode{reference_wrapper}~(\ref{refwrap}), or some equivalent solution. +noncopied implementation object such as \tcode{reference_wrapper}\iref{refwrap}, or some equivalent solution. \end{note} \pnum @@ -1290,10 +1290,23 @@ \pnum Parallel algorithms have template parameters -named \tcode{ExecutionPolicy}~(\ref{execpol}) +named \tcode{ExecutionPolicy}\iref{execpol} which describe the manner in which the execution of these algorithms may be parallelized and the manner in which they apply the element access functions. +\pnum +If an object is modified by an element access function, +the algorithm will perform no other unsynchronized accesses to that object. +The modifying element access functions are those +which are specified as modifying the object in the relevant concept. +\begin{note} +For example, +\tcode{swap()}, \tcode{++}, \tcode{--}, \tcode{@=}, and assignments +modify the object. +For the assignment and \tcode{@=} operators, +only the left argument is modified. +\end{note} + \pnum Unless otherwise stated, implementations may make arbitrary copies of elements (with type \tcode{T}) from sequences where \tcode{is_trivially_copy_constructible_v} @@ -1303,7 +1316,7 @@ identity of arguments for such input sequences. Users for whom the object identity of the arguments to these function objects is important should consider using a wrapping iterator that returns a non-copied implementation -object such as \tcode{reference_wrapper}~(\ref{refwrap}) or some equivalent +object such as \tcode{reference_wrapper}\iref{refwrap} or some equivalent solution. \end{note} @@ -1321,8 +1334,8 @@ permitted to execute in either the invoking thread of execution or in a thread of execution implicitly created by the library to support parallel algorithm execution. -If the threads of execution created by \tcode{thread}~(\ref{thread.thread.class}) provide concurrent -forward progress guarantees~(\ref{intro.progress}), then a thread of execution +If the threads of execution created by \tcode{thread}\iref{thread.thread.class} provide concurrent +forward progress guarantees\iref{intro.progress}, then a thread of execution implicitly created by the library will provide parallel forward progress guarantees; otherwise, the provided forward progress guarantee is \impldef{forward progress guarantees for implicit threads of parallel algorithms (if not defined for \tcode{thread})}. @@ -1427,7 +1440,7 @@ created by the library, then the invoking thread of execution will either \begin{itemize} -\item temporarily block with forward progress guarantee delegation~(\ref{intro.progress}) +\item temporarily block with forward progress guarantee delegation\iref{intro.progress} on the completion of these library-managed threads of execution, or \item eventually execute an element access function; \end{itemize} @@ -2099,7 +2112,7 @@ \tcode{InputIterator1} and \tcode{InputIterator2} -meet the requirements of random access iterators~(\ref{random.access.iterators}) +meet the requirements of random access iterators\iref{random.access.iterators} and \tcode{last1 - first1 != last2 - first2}, then @@ -2112,7 +2125,7 @@ \end{itemize} \item -For the overloads with no \tcode{ExecutionPolicy}, +For the overloads with an \tcode{ExecutionPolicy}, \begin{itemize} \item if @@ -2418,7 +2431,7 @@ \complexity Exactly \tcode{last - first} applications of the corresponding predicate. \pnum -\remarks Stable~(\ref{algorithm.stable}). +\remarks Stable\iref{algorithm.stable}. \end{itemdescr} \indexlibrary{\idxcode{copy_backward}}% @@ -2593,7 +2606,7 @@ and \range{first2}{first2 + (last1 - first1)} shall not overlap. -\tcode{*(first1 + n)} shall be swappable with~(\ref{swappable.requirements}) +\tcode{*(first1 + n)} shall be swappable with\iref{swappable.requirements} \tcode{*(first2 + n)}. \pnum @@ -2624,7 +2637,7 @@ \pnum \requires \tcode{a} and \tcode{b} shall be dereferenceable. \tcode{*a} shall be -swappable with~(\ref{swappable.requirements}) \tcode{*b}. +swappable with\iref{swappable.requirements} \tcode{*b}. \pnum \effects @@ -2787,7 +2800,7 @@ \tcode{*first} and \tcode{new_value} -shall be writable~(\ref{iterator.requirements.general}) to the +shall be writable\iref{iterator.requirements.general} to the \tcode{result} output iterator. The ranges @@ -2849,7 +2862,7 @@ \requires The expression \tcode{value} -shall be writable~(\ref{iterator.requirements.general}) to the output iterator. The type +shall be writable\iref{iterator.requirements.general} to the output iterator. The type \tcode{Size} shall be convertible to an integral type~(\ref{conv.integral}, \ref{class.conv}). @@ -2962,7 +2975,7 @@ The end of the resulting range. \pnum -\remarks Stable~(\ref{algorithm.stable}). +\remarks Stable\iref{algorithm.stable}. \pnum \complexity @@ -3037,7 +3050,7 @@ applications of the corresponding predicate. \pnum -\remarks Stable~(\ref{algorithm.stable}). +\remarks Stable\iref{algorithm.stable}. \end{itemdescr} \rSec2[alg.unique]{Unique} @@ -3188,7 +3201,7 @@ \begin{itemdescr} \pnum \requires -\tcode{*first} shall be swappable~(\ref{swappable.requirements}). +\tcode{*first} shall be swappable\iref{swappable.requirements}. \pnum \effects @@ -3202,7 +3215,7 @@ \pnum \requires \tcode{BidirectionalIterator} shall satisfy the requirements of -\tcode{ValueSwappable}~(\ref{swappable.requirements}). +\tcode{ValueSwappable}\iref{swappable.requirements}. \pnum \complexity @@ -3277,7 +3290,7 @@ \range{middle}{last} shall be valid ranges. \tcode{ForwardIterator} shall satisfy the requirements of -\tcode{ValueSwappable}~(\ref{swappable.requirements}). The type of \tcode{*first} shall satisfy +\tcode{ValueSwappable}\iref{swappable.requirements}. The type of \tcode{*first} shall satisfy the requirements of \tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) and the requirements of @@ -3368,19 +3381,19 @@ \requires \begin{itemize} \item -\tcode{PopulationIterator} shall satisfy the requirements of an input iterator~(\ref{input.iterators}). +\tcode{PopulationIterator} shall satisfy the requirements of an input iterator\iref{input.iterators}. \item -\tcode{SampleIterator} shall satisfy the requirements of an output iterator~(\ref{output.iterators}). +\tcode{SampleIterator} shall satisfy the requirements of an output iterator\iref{output.iterators}. \item -\tcode{SampleIterator} shall satisfy the additional requirements of a random access iterator~(\ref{random.access.iterators}) -unless \tcode{PopulationIterator} satisfies the additional requirements of a forward iterator~(\ref{forward.iterators}). +\tcode{SampleIterator} shall satisfy the additional requirements of a random access iterator\iref{random.access.iterators} +unless \tcode{PopulationIterator} satisfies the additional requirements of a forward iterator\iref{forward.iterators}. \item -\tcode{PopulationIterator}'s value type shall be writable~(\ref{iterator.requirements.general}) to \tcode{out}. +\tcode{PopulationIterator}'s value type shall be writable\iref{iterator.requirements.general} to \tcode{out}. \item \tcode{Distance} shall be an integer type. \item \tcode{remove_reference_t} -shall meet the requirements of a uniform random bit generator type (\ref{rand.req.urng}) +shall meet the requirements of a uniform random bit generator type\iref{rand.req.urng} whose return type is convertible to \tcode{Distance}. \item \tcode{out} shall not be in the range \range{first}{last}. @@ -3431,11 +3444,11 @@ \pnum \requires \tcode{RandomAccessIterator} shall satisfy the requirements of -\tcode{ValueSwappable}~(\ref{swappable.requirements}). +\tcode{ValueSwappable}\iref{swappable.requirements}. The type \tcode{remove_reference_t} shall meet the requirements of a -uniform random bit generator~(\ref{rand.req.urng}) type whose return type is +uniform random bit generator\iref{rand.req.urng} type whose return type is convertible to \tcode{iterator_traits::difference_type}. @@ -3470,9 +3483,9 @@ \pnum \tcode{Compare} is a function object -type~(\ref{function.objects}). The return value of the function call operation applied to +type\iref{function.objects}. The return value of the function call operation applied to an object of type \tcode{Compare}, when contextually converted to -\tcode{bool} (Clause~\ref{conv}), +\tcode{bool}\iref{conv}, yields \tcode{true} if the first argument of the call is less than the second, and \tcode{false} @@ -3607,7 +3620,7 @@ \pnum \requires \tcode{RandomAccessIterator} shall satisfy the requirements of -\tcode{ValueSwappable}~(\ref{swappable.requirements}). The type +\tcode{ValueSwappable}\iref{swappable.requirements}. The type of \tcode{*first} shall satisfy the requirements of \tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) and of \tcode{MoveAssignable} (Table~\ref{tab:moveassignable}). @@ -3645,7 +3658,7 @@ \pnum \requires \tcode{RandomAccessIterator} shall satisfy the requirements of -\tcode{ValueSwappable}~(\ref{swappable.requirements}). The type +\tcode{ValueSwappable}\iref{swappable.requirements}. The type of \tcode{*first} shall satisfy the requirements of \tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) and of \tcode{MoveAssignable} (Table~\ref{tab:moveassignable}). @@ -3661,7 +3674,7 @@ $N = \tcode{last - first}$, but only $N \log N$ comparisons if there is enough extra memory. \pnum -\remarks Stable~(\ref{algorithm.stable}). +\remarks Stable\iref{algorithm.stable}. \end{itemdescr} \rSec3[partial.sort]{\tcode{partial_sort}} @@ -3696,7 +3709,7 @@ \pnum \requires \tcode{RandomAccessIterator} shall satisfy the requirements of -\tcode{ValueSwappable}~(\ref{swappable.requirements}). The type +\tcode{ValueSwappable}\iref{swappable.requirements}. The type of \tcode{*first} shall satisfy the requirements of \tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) and of \tcode{MoveAssignable} (Table~\ref{tab:moveassignable}). @@ -3758,7 +3771,7 @@ \pnum \requires \tcode{RandomAccessIterator} shall satisfy the requirements of -\tcode{ValueSwappable}~(\ref{swappable.requirements}). The type +\tcode{ValueSwappable}\iref{swappable.requirements}. The type of \tcode{*result_first} shall satisfy the requirements of \tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) and of \tcode{Move\-Assignable} (Table~\ref{tab:moveassignable}). @@ -3893,7 +3906,7 @@ \pnum \requires \tcode{RandomAccessIterator} shall satisfy the requirements of -\tcode{ValueSwappable}~(\ref{swappable.requirements}). The type +\tcode{ValueSwappable}\iref{swappable.requirements}. The type of \tcode{*first} shall satisfy the requirements of \tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) and of \tcode{MoveAssignable} (Table~\ref{tab:moveassignable}). @@ -4201,7 +4214,7 @@ \pnum \requires \tcode{ForwardIterator} shall satisfy the requirements of -\tcode{ValueSwappable}~(\ref{swappable.requirements}). +\tcode{ValueSwappable}\iref{swappable.requirements}. \pnum \effects Places all the elements in the range \range{first}{last} that satisfy \tcode{pred} before all the elements that do not satisfy it. @@ -4240,7 +4253,7 @@ \pnum \requires \tcode{BidirectionalIterator} shall satisfy the requirements of -\tcode{ValueSwappable}~(\ref{swappable.requirements}). The type +\tcode{ValueSwappable}\iref{swappable.requirements}. The type of \tcode{*first} shall satisfy the requirements of \tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) and of \tcode{MoveAssignable} (Table~\ref{tab:moveassignable}). @@ -4306,7 +4319,7 @@ \item For the overload with no \tcode{ExecutionPolicy}, \tcode{InputIterator}'s value type shall be \tcode{CopyAssignable} (Table~\ref{tab:copyassignable}), -and shall be writable~(\ref{iterator.requirements.general}) to the \tcode{out_true} +and shall be writable\iref{iterator.requirements.general} to the \tcode{out_true} and \tcode{out_false} \tcode{OutputIterator}s, and shall be convertible to \tcode{Predicate}'s argument type. @@ -4411,7 +4424,7 @@ \end{itemize} \pnum -\remarks Stable~(\ref{algorithm.stable}). +\remarks Stable\iref{algorithm.stable}. \end{itemdescr} \indexlibrary{\idxcode{inplace_merge}}% @@ -4443,7 +4456,7 @@ The ranges \range{first}{middle} and \range{middle}{last} shall be sorted with respect to \tcode{operator<} or \tcode{comp}. \tcode{BidirectionalIterator} shall satisfy the requirements of -\tcode{ValueSwappable}~(\ref{swappable.requirements}). The type +\tcode{ValueSwappable}\iref{swappable.requirements}. The type of \tcode{*first} shall satisfy the requirements of \tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) and of \tcode{MoveAssignable} (Table~\ref{tab:moveassignable}). @@ -4481,7 +4494,7 @@ \pnum -\remarks Stable~(\ref{algorithm.stable}). +\remarks Stable\iref{algorithm.stable}. \end{itemdescr} \rSec2[alg.set.operations]{Set operations on sorted structures} @@ -4489,7 +4502,7 @@ \pnum This section defines all the basic set operations on sorted structures. They also work with -\tcode{multiset}s~(\ref{multiset}) +\tcode{multiset}s\iref{multiset} containing multiple copies of equivalent elements. The semantics of the set operations are generalized to \tcode{multiset}s @@ -4895,7 +4908,7 @@ \range{first}{last} shall be a valid non-empty heap. \tcode{RandomAccessIterator} shall satisfy the requirements of -\tcode{ValueSwappable}~(\ref{swappable.requirements}). The type +\tcode{ValueSwappable}\iref{swappable.requirements}. The type of \tcode{*first} shall satisfy the requirements of \tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) and of \tcode{MoveAssignable} (Table~\ref{tab:moveassignable}). @@ -4965,7 +4978,7 @@ \pnum \requires The range \range{first}{last} shall be a valid heap. \tcode{RandomAccessIterator} shall satisfy the requirements of -\tcode{ValueSwappable}~(\ref{swappable.requirements}). The type +\tcode{ValueSwappable}\iref{swappable.requirements}. The type of \tcode{*first} shall satisfy the requirements of \tcode{MoveConstructible} (Table~\ref{tab:moveconstructible}) and of \tcode{MoveAssignable} (Table~\ref{tab:moveassignable}). @@ -4977,7 +4990,7 @@ \pnum \complexity -At most $N \log N$ +At most $2N \log N$ comparisons, where $N = \tcode{last - first}$. \end{itemdescr} @@ -5474,7 +5487,7 @@ \pnum \requires \tcode{BidirectionalIterator} shall satisfy the requirements of -\tcode{ValueSwappable}~(\ref{swappable.requirements}). +\tcode{ValueSwappable}\iref{swappable.requirements}. \pnum \effects @@ -5516,7 +5529,7 @@ \pnum \requires \tcode{BidirectionalIterator} shall satisfy the requirements of -\tcode{ValueSwappable}~(\ref{swappable.requirements}). +\tcode{ValueSwappable}\iref{swappable.requirements}. \pnum \effects @@ -5549,7 +5562,7 @@ \indextext{\idxhdr{cstdlib}}% \indexlibrary{\idxhdr{cstdlib}}% \begin{note} -The header \tcode{}~(\ref{cstdlib.syn}) +The header \tcode{}\iref{cstdlib.syn} declares the functions described in this subclause. \end{note} @@ -5577,7 +5590,7 @@ \pnum \throws -Any exception thrown by \tcode{compar()}~(\ref{res.on.exception.handling}). +Any exception thrown by \tcode{compar()}\iref{res.on.exception.handling}. \end{itemdescr} \xref diff --git a/source/atomics.tex b/source/atomics.tex index 0f55b417ca..b02ad72121 100644 --- a/source/atomics.tex +++ b/source/atomics.tex @@ -483,7 +483,7 @@ \begin{itemdescr} \pnum \effects The argument does not carry a dependency to the return -value~(\ref{intro.multithread}). +value\iref{intro.multithread}. \pnum \returns \tcode{y}. @@ -525,14 +525,14 @@ value of 2 indicates that the types are always lock-free. \pnum -The function \tcode{atomic_is_lock_free}~(\ref{atomics.types.operations}) +The function \tcode{atomic_is_lock_free}\iref{atomics.types.operations} indicates whether the object is lock-free. In any given program execution, the result of the lock-free query shall be consistent for all pointers of the same type. \pnum Atomic operations that are not lock-free are considered to potentially -block~(\ref{intro.progress}). +block\iref{intro.progress}. \pnum \begin{note} Operations that are lock-free should also be address-free. That is, @@ -583,7 +583,7 @@ \indexlibrary{\idxcode{atomic}}% \pnum The template argument for -\tcode{T} shall be trivially copyable~(\ref{basic.types}). \begin{note} Type arguments that are +\tcode{T} shall be trivially copyable\iref{basic.types}. \begin{note} Type arguments that are not also statically initializable may be difficult to use. \end{note} \pnum @@ -628,7 +628,7 @@ \begin{itemdescr} \pnum \effects Initializes the object with the value \tcode{desired}. -Initialization is not an atomic operation~(\ref{intro.multithread}). +Initialization is not an atomic operation\iref{intro.multithread}. \begin{note} It is possible to have an access to an atomic object \tcode{A} race with its construction, for example by communicating the address of the just-constructed object \tcode{A} to another thread via @@ -779,7 +779,7 @@ \effects Atomically replaces the value pointed to by \tcode{this} with \tcode{desired}. Memory is affected according to the value of \tcode{order}. -These operations are atomic read-modify-write operations~(\ref{intro.multithread}). +These operations are atomic read-modify-write operations\iref{intro.multithread}. \pnum \returns Atomically returns the value pointed to by \tcode{this} immediately before the effects. @@ -838,7 +838,7 @@ read from the memory pointed to by \tcode{this} during the atomic comparison. If the operation returns \tcode{true}, these operations are atomic read-modify-write -operations~(\ref{intro.multithread}) on the memory +operations\iref{intro.multithread} on the memory pointed to by \tcode{this}. Otherwise, these operations are atomic load operations on that memory. @@ -903,9 +903,7 @@ \begin{note} The \tcode{memcpy} and \tcode{memcmp} semantics of the compare-and-exchange operations may result in failed comparisons for values that compare equal with \tcode{operator==} if the underlying type has padding bits, trap bits, or alternate -representations of the same value. Thus, \tcode{compare_exchange_strong} should be used -with extreme care. On the other hand, \tcode{compare_exchange_weak} should converge -rapidly. \end{note} +representations of the same value.\end{note} \end{itemdescr} \rSec2[atomics.types.int]{Specializations for integers} @@ -1072,7 +1070,7 @@ \tcode{this} with the result of the computation applied to the value pointed to by \tcode{this} and the given \tcode{operand}. Memory is affected according to the value of \tcode{order}. -These operations are atomic read-modify-write operations~(\ref{intro.multithread}). +These operations are atomic read-modify-write operations\iref{intro.multithread}. \pnum \returns Atomically, the value pointed to by \tcode{this} immediately before the effects. @@ -1207,7 +1205,7 @@ \tcode{this} with the result of the computation applied to the value pointed to by \tcode{this} and the given \tcode{operand}. Memory is affected according to the value of \tcode{order}. -These operations are atomic read-modify-write operations~(\ref{intro.multithread}). +These operations are atomic read-modify-write operations\iref{intro.multithread}. \pnum \returns Atomically, the value pointed to by \tcode{this} immediately before the effects. @@ -1239,7 +1237,7 @@ \end{itemdecl} \begin{itemdescr} -\effects Equivalent to: \tcode{return fetch\_add(1);} +\effects Equivalent to: \tcode{return fetch_add(1);} \end{itemdescr} \indexlibrarymember{operator\dcr}{atomic}% @@ -1250,7 +1248,7 @@ \end{itemdecl} \begin{itemdescr} -\effects Equivalent to: \tcode{return fetch\_sub(1);} +\effects Equivalent to: \tcode{return fetch_sub(1);} \end{itemdescr} \indexlibrarymember{operator++}{atomic}% @@ -1384,7 +1382,7 @@ \begin{itemdescr} \pnum \effects Atomically sets the value pointed to by \tcode{object} or by \tcode{this} to \tcode{true}. Memory is affected according to the value of -\tcode{order}. These operations are atomic read-modify-write operations~(\ref{intro.multithread}). +\tcode{order}. These operations are atomic read-modify-write operations\iref{intro.multithread}. \pnum \returns Atomically, the value of the object immediately before the effects. diff --git a/source/back.tex b/source/back.tex index 3ac2a093d3..ec39597f7b 100644 --- a/source/back.tex +++ b/source/back.tex @@ -1,5 +1,20 @@ %!TEX root = std.tex +\chapter{Bibliography} + +The following documents are cited informatively in this document. + +\begin{itemize} +\renewcommand{\labelitemi}{---} +\item + ISO/IEC 10967-1:2012, + \doccite{Information technology --- Language independent arithmetic --- + Part 1: Integer and floating point arithmetic} +\end{itemize} + +The arithmetic specification described in ISO/IEC 10967-1:2012 is +called \defn{LIA-1} in this document. + % FIXME: For unknown reasons, hanging paragraphs are not indented within our % glossaries by default. \let\realglossitem\glossitem @@ -18,9 +33,9 @@ \clearpage \input{xrefdelta} -\renewcommand{\glossaryname}{Cross references from ISO \CppXIV} +\renewcommand{\glossaryname}{Cross references from ISO \CppXVII} \renewcommand{\preglossaryhook}{All section labels from -ISO \CppXIV (ISO/IEC 14882:2014, \doccite{Programming Languages --- \Cpp}) +ISO \CppXVII (ISO/IEC 14882:2017, \doccite{Programming Languages --- \Cpp}) are present in this document, with the exceptions described below.\\} \renewcommand{\leftmark}{\glossaryname} { @@ -39,7 +54,7 @@ \renewcommand{\indexname}{Index of grammar productions} \renewcommand{\preindexhook}{The first page number for each entry is the page in the general text where the grammar production is defined. The second page number is the -corresponding page in the Grammar summary (Annex~\ref{gram}).\\} +corresponding page in the Grammar summary\iref{gram}.\\} \renewcommand{\leftmark}{\indexname} { \raggedright diff --git a/source/basic.tex b/source/basic.tex index 96c2128196..3769455111 100644 --- a/source/basic.tex +++ b/source/basic.tex @@ -32,18 +32,18 @@ parameter pack. \pnum -A \defn{name} is a use of an \grammarterm{identifier}~(\ref{lex.name}), -\grammarterm{operator-function-id}~(\ref{over.oper}), -\grammarterm{literal-operator-id}~(\ref{over.literal}), -\grammarterm{conversion-function-id}~(\ref{class.conv.fct}), or -\grammarterm{template-id}~(\ref{temp.names}) that denotes an entity or +A \defn{name} is a use of an \grammarterm{identifier}\iref{lex.name}, +\grammarterm{operator-function-id}\iref{over.oper}, +\grammarterm{literal-operator-id}\iref{over.literal}, +\grammarterm{conversion-function-id}\iref{class.conv.fct}, or +\grammarterm{template-id}\iref{temp.names} that denotes an entity or label~(\ref{stmt.goto}, \ref{stmt.label}). \pnum Every name that denotes an entity is introduced by a \defn{declaration}. Every name that denotes a label is introduced -either by a \tcode{goto} statement~(\ref{stmt.goto}) or a -\grammarterm{labeled-statement}~(\ref{stmt.label}). +either by a \tcode{goto} statement\iref{stmt.goto} or a +\grammarterm{labeled-statement}\iref{stmt.label}. \pnum A \defn{variable} is introduced by the @@ -56,7 +56,7 @@ whenever a name is encountered it is necessary to determine whether that name denotes one of these entities before continuing to parse the program that contains it. The process that determines this is called -\defnx{name lookup}{lookup!name}~(\ref{basic.lookup}). +\defnx{name lookup}{lookup!name}\iref{basic.lookup}. \pnum Two names are \defnx{the same}{name!same} if @@ -67,8 +67,8 @@ \item they are \grammarterm{conversion-function-id}{s} formed with the same type, or \item they are \grammarterm{template-id}{s} that refer to the same class, -function, or variable~(\ref{temp.type}), or -\item they are the names of literal operators~(\ref{over.literal}) formed with +function, or variable\iref{temp.type}, or +\item they are the names of literal operators\iref{over.literal} formed with the same literal suffix identifier. \end{itemize} @@ -77,7 +77,7 @@ \indextext{linkage}% A name used in more than one translation unit can potentially refer to the same entity in these translation units depending on the -linkage~(\ref{basic.link}) of the name specified in each +linkage\iref{basic.link} of the name specified in each translation unit. \rSec1[basic.def]{Declarations and definitions} @@ -86,17 +86,17 @@ \indextext{declaration!definition versus}% \indextext{declaration}% \indextext{declaration!name}% -A declaration (Clause~\ref{dcl.dcl}) may introduce +A declaration\iref{dcl.dcl} may introduce one or more names into a translation unit or redeclare names introduced by previous declarations. If so, the declaration specifies the interpretation and attributes of these names. A declaration may also have effects including: \begin{itemize} -\item a static assertion (Clause~\ref{dcl.dcl}), -\item controlling template instantiation~(\ref{temp.explicit}), -\item guiding template argument deduction for constructors~(\ref{temp.deduct.guide}), -\item use of attributes (Clause~\ref{dcl.dcl}), and +\item a static assertion\iref{dcl.dcl}, +\item controlling template instantiation\iref{temp.explicit}, +\item guiding template argument deduction for constructors\iref{temp.deduct.guide}, +\item use of attributes\iref{dcl.dcl}, and \item nothing (in the case of an \grammarterm{empty-declaration}). \end{itemize} @@ -107,68 +107,68 @@ \begin{itemize} \item it declares a function -without specifying the function's body~(\ref{dcl.fct.def}), +without specifying the function's body\iref{dcl.fct.def}, \item it contains the \indextext{declaration!\idxcode{extern}}% -\tcode{extern} specifier~(\ref{dcl.stc}) or a +\tcode{extern} specifier\iref{dcl.stc} or a \grammarterm{linkage-specification}\footnote{Appearing inside the braced-enclosed \grammarterm{declaration-seq} in a \grammarterm{linkage-specification} does -not affect whether a declaration is a definition.} -(\ref{dcl.link}) and neither an \grammarterm{initializer} nor a +not affect whether a declaration is a definition.}\iref{dcl.link} +and neither an \grammarterm{initializer} nor a \grammarterm{function-body}, \item \indextext{declaration!static member@\tcode{static} member}% it declares a non-inline static data member in a class -definition (\ref{class.mem},~\ref{class.static}), +definition~(\ref{class.mem}, \ref{class.static}), \item it declares a static data member outside a class definition 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}% -it is a class name declaration~(\ref{class.name}), +it is a class name declaration\iref{class.name}, \item it is an \indextext{declaration!opaque enum}% -\grammarterm{opaque-enum-declaration}~(\ref{dcl.enum}), +\grammarterm{opaque-enum-declaration}\iref{dcl.enum}, \item it is a \indextext{parameter!template}\indextext{template parameter}% -\grammarterm{template-parameter}~(\ref{temp.param}), +\grammarterm{template-parameter}\iref{temp.param}, \item it is a \indextext{declaration!parameter}\indextext{parameter declaration}% -\grammarterm{parameter-declaration}~(\ref{dcl.fct}) in a function +\grammarterm{parameter-declaration}\iref{dcl.fct} in a function \indextext{declarator}% declarator that is not the \grammarterm{declarator} of a \grammarterm{function-definition}, \item it is a \indextext{declaration!\idxcode{typedef}}% -\tcode{typedef} declaration~(\ref{dcl.typedef}), +\tcode{typedef} declaration\iref{dcl.typedef}, \item it is -an \grammarterm{alias-declaration}~(\ref{dcl.typedef}), +an \grammarterm{alias-declaration}\iref{dcl.typedef}, \item it is a -\grammarterm{using-declaration}~(\ref{namespace.udecl}), +\grammarterm{using-declaration}\iref{namespace.udecl}, \item it is -a \grammarterm{deduction-guide}~(\ref{temp.deduct.guide}), +a \grammarterm{deduction-guide}\iref{temp.deduct.guide}, \item it is -a \grammarterm{static_assert-declaration} (Clause~\ref{dcl.dcl}), +a \grammarterm{static_assert-declaration}\iref{dcl.dcl}, \item it is an -\grammarterm{attribute-declaration} (Clause~\ref{dcl.dcl}), +\grammarterm{attribute-declaration}\iref{dcl.dcl}, \item it is an -\grammarterm{empty-declaration} (Clause~\ref{dcl.dcl}), +\grammarterm{empty-declaration}\iref{dcl.dcl}, \item it is -a \grammarterm{using-directive}~(\ref{namespace.udir}), +a \grammarterm{using-directive}\iref{namespace.udir}, \item it is -an explicit instantiation declaration~(\ref{temp.explicit}), or +an explicit instantiation declaration\iref{temp.explicit}, or \item it is -an explicit specialization~(\ref{temp.expl.spec}) whose +an explicit specialization\iref{temp.expl.spec} whose \grammarterm{declaration} is not a definition. \end{itemize} \begin{example} All but one of the following are definitions: @@ -207,19 +207,19 @@ \begin{note} \indextext{implementation-generated}% In some circumstances, \Cpp implementations implicitly define the -default constructor~(\ref{class.ctor}), -copy constructor~(\ref{class.copy}), -move constructor~(\ref{class.copy}), -copy assignment operator~(\ref{class.copy}), -move assignment operator~(\ref{class.copy}), -or destructor~(\ref{class.dtor}) member functions. \end{note} +default constructor\iref{class.ctor}, +copy constructor\iref{class.copy}, +move constructor\iref{class.copy}, +copy assignment operator\iref{class.copy}, +move assignment operator\iref{class.copy}, +or destructor\iref{class.dtor} member functions. \end{note} \begin{example} Given \begin{codeblock} #include struct C { - std::string s; // \tcode{std::string} is the standard library class (Clause~\ref{strings}) + std::string s; // \tcode{std::string} is the standard library class\iref{strings} }; int main() { @@ -249,13 +249,13 @@ \pnum \begin{note} A class name can also be implicitly declared by an -\grammarterm{elaborated-type-specifier}~(\ref{dcl.type.elab}). +\grammarterm{elaborated-type-specifier}\iref{dcl.type.elab}. \end{note} \pnum \indextext{type!incomplete}% A program is ill-formed if the definition of any object gives the object -an incomplete type~(\ref{basic.types}). +an incomplete type\iref{basic.types}. \indextext{object!definition}% \indextext{function!definition}% @@ -270,28 +270,28 @@ \pnum An expression is \defn{potentially evaluated} unless it is an -unevaluated operand (Clause~\ref{expr}) or a subexpression thereof. +unevaluated operand\iref{expr} or a subexpression thereof. The set of \defn{potential results} of an expression \tcode{e} is defined as follows: \begin{itemize} \item If \tcode{e} is an -\grammarterm{id-expression}~(\ref{expr.prim.id}), the set +\grammarterm{id-expression}\iref{expr.prim.id}, the set contains only \tcode{e}. -\item If \tcode{e} is a subscripting operation~(\ref{expr.sub}) with +\item If \tcode{e} is a subscripting operation\iref{expr.sub} with an array operand, the set contains the potential results of that operand. \item If \tcode{e} is a class member access -expression~(\ref{expr.ref}), the set contains the potential results of +expression\iref{expr.ref}, the set contains the potential results of the object expression. \item If \tcode{e} is a pointer-to-member -expression~(\ref{expr.mptr.oper}) whose second operand is a constant +expression\iref{expr.mptr.oper} whose second operand is a constant expression, the set contains the potential results of the object expression. \item If \tcode{e} has the form \tcode{(e1)}, the set contains the potential results of \tcode{e1}. \item If \tcode{e} is a glvalue conditional -expression~(\ref{expr.cond}), the set is the union of the sets of +expression\iref{expr.cond}, the set is the union of the sets of potential results of the second and third operands. -\item If \tcode{e} is a comma expression~(\ref{expr.comma}), the set +\item If \tcode{e} is a comma expression\iref{expr.comma}, the set contains the potential results of the right operand. \item Otherwise, the set is empty. \end{itemize} @@ -314,13 +314,13 @@ \pnum A variable \tcode{x} whose name appears as a potentially-evaluated expression \tcode{ex} is \defn{odr-used} by \tcode{ex} unless -applying the lvalue-to-rvalue conversion (\ref{conv.lval}) to \tcode{x} yields -a constant expression~(\ref{expr.const}) that does not invoke any non-trivial +applying the lvalue-to-rvalue conversion\iref{conv.lval} to \tcode{x} yields +a constant expression\iref{expr.const} that does not invoke any non-trivial functions and, if \tcode{x} is an object, \tcode{ex} is an element of the set of potential results of an expression \tcode{e}, where either the lvalue-to-rvalue -conversion~(\ref{conv.lval}) is applied to \tcode{e}, or \tcode{e} is -a discarded-value expression~(Clause \ref{expr}). +conversion\iref{conv.lval} is applied to \tcode{e}, or \tcode{e} is +a discarded-value expression\iref{expr}. \tcode{this} is odr-used if it appears as a potentially-evaluated expression (including as the result of the implicit transformation in the body of a non-static member function~(\ref{class.mfct.non-static})). @@ -331,14 +331,14 @@ member of a set of overloaded functions~(\ref{basic.lookup}, \ref{over.match}, \ref{over.over}), unless it is a pure virtual function and either its name is not explicitly qualified or -the expression forms a pointer to member~(\ref{expr.unary.op}). +the expression forms a pointer to member\iref{expr.unary.op}. \begin{note} This covers calls to named -functions~(\ref{expr.call}), operator overloading (Clause~\ref{over}), -user-defined conversions~(\ref{class.conv.fct}), allocation functions for -placement \grammarterm{new-expression}{s}~(\ref{expr.new}), as well as non-default -initialization~(\ref{dcl.init}). A constructor selected to copy or move an +functions\iref{expr.call}, operator overloading\iref{over}, +user-defined conversions\iref{class.conv.fct}, allocation functions for +placement \grammarterm{new-expression}{s}\iref{expr.new}, as well as non-default +initialization\iref{dcl.init}. A constructor selected to copy or move an object of class type is odr-used even if the -call is actually elided by the implementation~(\ref{class.copy}). \end{note} An allocation +call is actually elided by the implementation\iref{class.copy}. \end{note} An allocation or deallocation function for a class is odr-used by a \grammarterm{new-expression} appearing in a potentially-evaluated expression as specified in~\ref{expr.new} and~\ref{class.free}. A deallocation function for a @@ -349,7 +349,7 @@ class. A non-placement deallocation function for a class is odr-used by the definition of the destructor of that class, or by being selected by the lookup at the point of definition of a virtual -destructor~(\ref{class.dtor}).\footnote{An implementation is not required +destructor\iref{class.dtor}.\footnote{An implementation is not required to call allocation and deallocation functions from constructors or destructors; however, this is a permissible implementation technique.} @@ -359,12 +359,12 @@ in~\ref{class.copy}. A constructor for a class is odr-used as specified in~\ref{dcl.init}. A destructor for a class is odr-used if it is potentially -invoked~(\ref{class.dtor}). +invoked\iref{class.dtor}. \pnum Every program shall contain exactly one definition of every non-inline function or variable that is odr-used in that program -outside of a discarded statement~(\ref{stmt.if}); no diagnostic required. +outside of a discarded statement\iref{stmt.if}; no diagnostic required. The definition can appear explicitly in the program, it can be found in the standard or a user-defined library, or (when appropriate) it is implicitly defined (see~\ref{class.ctor}, \ref{class.dtor} and @@ -388,47 +388,48 @@ describe in which contexts complete class types are required. A class type \tcode{T} must be complete if: \begin{itemize} -\item an object of type \tcode{T} is defined~(\ref{basic.def}), or +\item an object of type \tcode{T} is defined\iref{basic.def}, or \item a non-static class data member of type \tcode{T} is -declared~(\ref{class.mem}), or +declared\iref{class.mem}, or \item \tcode{T} is used as the allocated type or array element type in a -\grammarterm{new-expression}~(\ref{expr.new}), or +\grammarterm{new-expression}\iref{expr.new}, or \item an lvalue-to-rvalue conversion is applied to a glvalue referring -to an object of type \tcode{T}~(\ref{conv.lval}), or +to an object of type \tcode{T}\iref{conv.lval}, or \item an expression is converted (either implicitly or explicitly) to -type \tcode{T} (Clause~\ref{conv}, \ref{expr.type.conv}, +type \tcode{T} (\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} -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 +or reference to \tcode{T} using a standard conversion\iref{conv}, +a \tcode{dynamic_cast}\iref{expr.dynamic.cast} or +a \tcode{static_cast}\iref{expr.static.cast}, or \item a class member access operator is applied to an expression of type -\tcode{T}~(\ref{expr.ref}), or -\item the \tcode{typeid} operator~(\ref{expr.typeid}) or the -\tcode{sizeof} operator~(\ref{expr.sizeof}) is applied to an operand of +\tcode{T}\iref{expr.ref}, or +\item the \tcode{typeid} operator\iref{expr.typeid} or the +\tcode{sizeof} operator\iref{expr.sizeof} is applied to an operand of type \tcode{T}, or \item a function with a return type or argument type of type \tcode{T} -is defined~(\ref{basic.def}) or called~(\ref{expr.call}), or +is defined\iref{basic.def} or called\iref{expr.call}, or \item a class with a base class of type \tcode{T} is -defined (Clause~\ref{class.derived}), or -\item an lvalue of type \tcode{T} is assigned to~(\ref{expr.ass}), or +defined\iref{class.derived}, or +\item an lvalue of type \tcode{T} is assigned to\iref{expr.ass}, or \item the type \tcode{T} is the subject of an -\tcode{alignof} expression~(\ref{expr.alignof}), or +\tcode{alignof} expression\iref{expr.alignof}, or \item an \grammarterm{exception-declaration} has type \tcode{T}, reference to -\tcode{T}, or pointer to \tcode{T}~(\ref{except.handle}). +\tcode{T}, or pointer to \tcode{T}\iref{except.handle}. \end{itemize} \end{note} \pnum -There can be more than one definition of a class type -(Clause~\ref{class}), enumeration type~(\ref{dcl.enum}), inline function -with external linkage~(\ref{dcl.inline}), inline variable with external -linkage~(\ref{dcl.inline}), class template -(Clause~\ref{temp}), non-static function template~(\ref{temp.fct}), -static data member of a class template~(\ref{temp.static}), member -function of a class template~(\ref{temp.mem.func}), or template +There can be more than one definition of a class type\iref{class}, +enumeration type\iref{dcl.enum}, inline function +with external linkage\iref{dcl.inline}, inline variable with external +linkage\iref{dcl.inline}, class template\iref{temp}, +non-static function template\iref{temp.fct}, +concept\iref{temp.concept}, +static data member of a class template\iref{temp.static}, member +function of a class template\iref{temp.mem.func}, or template specialization for which some template parameters are not specified~(\ref{temp.spec}, \ref{temp.class.spec}) in a program provided that each definition appears in a different translation unit, and @@ -441,14 +442,14 @@ \item in each definition of \tcode{D}, corresponding names, looked up according to~\ref{basic.lookup}, shall refer to an entity defined within the definition of \tcode{D}, or shall refer to the same entity, after -overload resolution~(\ref{over.match}) and after matching of partial -template specialization~(\ref{temp.over}), except that a name can refer to +overload resolution\iref{over.match} and after matching of partial +template specialization\iref{temp.over}, except that a name can refer to \begin{itemize} \item a non-volatile \tcode{const} object with internal or no linkage if the object \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 initialized with a constant expression\iref{expr.const}, \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} @@ -474,11 +475,11 @@ were present in the definition of \tcode{D}; that is, the default argument is subject to the requirements described in this paragraph (and, if the default argument has subexpressions with default arguments, this -requirement applies recursively).\footnote{\ref{dcl.fct.default} -describes how default argument names are looked up.} +requirement applies recursively)\footnote{\ref{dcl.fct.default} +describes how default argument names are looked up.}; and \item if \tcode{D} is a class with an implicitly-declared -constructor~(\ref{class.ctor}), it is as if the constructor was +constructor\iref{class.ctor}, it is as if the constructor was implicitly defined in every translation unit where it is odr-used, and the implicit definition in every translation unit shall call the same constructor for a subobject of \tcode{D}. @@ -513,8 +514,8 @@ If \tcode{D} is a template and is defined in more than one translation unit, then the preceding requirements shall apply both to names from the template's enclosing scope used in the -template definition~(\ref{temp.nondep}), and also to dependent names at -the point of instantiation~(\ref{temp.dep}). If the definitions of +template definition\iref{temp.nondep}, and also to dependent names at +the point of instantiation\iref{temp.dep}. If the definitions of \tcode{D} satisfy all these requirements, then the behavior is 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 @@ -572,9 +573,9 @@ \pnum The names declared by a declaration are introduced into the scope in which the declaration occurs, except that the presence of a -\tcode{friend} specifier~(\ref{class.friend}), certain uses of the -\grammarterm{elaborated-type-specifier}~(\ref{dcl.type.elab}), and -\grammarterm{using-directive}{s}~(\ref{namespace.udir}) alter this general +\tcode{friend} specifier\iref{class.friend}, certain uses of the +\grammarterm{elaborated-type-specifier}\iref{dcl.type.elab}, and +\grammarterm{using-directive}{s}\iref{namespace.udir} alter this general behavior. \pnum @@ -588,17 +589,17 @@ all refer to the same variable, non-static data member, or enumerator, or all refer to functions and function templates; in this case the class name or enumeration name is -hidden~(\ref{basic.scope.hiding}). \begin{note} A namespace name or a +hidden\iref{basic.scope.hiding}. \begin{note} A namespace name or a class template name must be unique in its declarative -region~(\ref{namespace.alias}, Clause~\ref{temp}). \end{note} +region~(\ref{namespace.alias}, \ref{temp}). \end{note} \end{itemize} \begin{note} These restrictions apply to the declarative region into which a name is introduced, which is not necessarily the same as the region in which the declaration occurs. In particular, -\grammarterm{elaborated-type-specifier}{s}~(\ref{dcl.type.elab}) and -friend declarations~(\ref{class.friend}) may introduce a (possibly not +\grammarterm{elaborated-type-specifier}{s}\iref{dcl.type.elab} and +friend declarations\iref{class.friend} may introduce a (possibly not visible) name into an enclosing namespace; these restrictions apply to -that region. Local extern declarations~(\ref{basic.link}) may introduce +that region. Local extern declarations\iref{basic.link} may introduce a name into the declarative region where the declaration appears and also introduce a (possibly not visible) name into an enclosing namespace; these restrictions apply to both regions. \end{note} @@ -612,7 +613,7 @@ \pnum \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 +complete declarator\iref{dcl.decl} and before its \grammarterm{initializer} (if any), except as noted below. \begin{example} \begin{codeblock} @@ -626,7 +627,7 @@ \pnum \begin{note} \indextext{name hiding}% -a name from an outer scope remains visible up +A name from an outer scope remains visible up to the point of declaration of the name that hides it. \begin{example} \begin{codeblock} @@ -639,18 +640,18 @@ \pnum The point of declaration for a class or class template first declared by a \grammarterm{class-specifier} is immediately after the \grammarterm{identifier} or -\grammarterm{simple-template-id} (if any) in its \grammarterm{class-head} -(Clause~\ref{class}). The point of declaration for an enumeration is +\grammarterm{simple-template-id} (if any) in its \grammarterm{class-head}\iref{class}. +The point of declaration for an enumeration is immediately after the \grammarterm{identifier} (if any) in either its -\grammarterm{enum-specifier}~(\ref{dcl.enum}) or its first -\grammarterm{opaque-enum-declaration}~(\ref{dcl.enum}), whichever comes first. +\grammarterm{enum-specifier}\iref{dcl.enum} or its first +\grammarterm{opaque-enum-declaration}\iref{dcl.enum}, whichever comes first. The point of declaration of an alias or alias template immediately follows the \grammarterm{type-id} to which the alias refers. \pnum The point of declaration of a \grammarterm{using-declarator} that does not name a -constructor is immediately after the \grammarterm{using-declarator}~(\ref{namespace.udecl}). +constructor is immediately after the \grammarterm{using-declarator}\iref{namespace.udecl}. \pnum \indextext{declaration!enumerator point of}% @@ -714,14 +715,20 @@ \pnum The point of declaration for an -\grammarterm{injected-class-name} (Clause~\ref{class}) is immediately following +injected-class-name\iref{class} is immediately following the opening brace of the class definition. \pnum The point of declaration for a function-local predefined -variable~(\ref{dcl.fct.def}) is immediately before the +variable\iref{dcl.fct.def} is immediately before the \grammarterm{function-body} of a function definition. +\pnum +The point of declaration for the variable or the structured bindings +declared in the \grammarterm{for-range-declaration} +of a range-based \tcode{for} statement\iref{stmt.ranged} +is immediately after the \grammarterm{for-range-initializer}. + \pnum The point of declaration for a template parameter is immediately after its complete \grammarterm{template-parameter}. \begin{example} @@ -738,7 +745,7 @@ \pnum \begin{note} Friend declarations refer to functions or classes that are members of the nearest enclosing namespace, but they do not introduce -new names into that namespace~(\ref{namespace.memdef}). Function +new names into that namespace\iref{namespace.memdef}. Function declarations at block scope and variable declarations with the \tcode{extern} specifier at block scope refer to declarations that are members of an enclosing namespace, but they do not introduce new names @@ -755,10 +762,10 @@ \pnum \indextext{scope!block}% \indextext{local scope|see{block scope}}% -A name declared in a block~(\ref{stmt.block}) is local to that block; it has +A name declared in a block\iref{stmt.block} is local to that block; it has \defn{block scope}. Its potential scope begins at its point of -declaration~(\ref{basic.scope.pdecl}) and ends at the end of its block. +declaration\iref{basic.scope.pdecl} and ends at the end of its block. A variable declared at block scope is a \defn{local variable}. \pnum @@ -768,7 +775,7 @@ \grammarterm{lambda-declarator}) or of a function-local predefined variable in a function -definition~(\ref{dcl.fct.def}) begins at its point of declaration. If +definition\iref{dcl.fct.def} begins at its point of declaration. If the function has a \grammarterm{function-try-block} the potential scope of a parameter or of a function-local predefined variable @@ -801,7 +808,7 @@ \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 +declarator of a function definition\iref{dcl.fct.def}, names of parameters (if supplied) have function prototype scope, which terminates at the end of the nearest enclosing function declarator. @@ -809,7 +816,7 @@ \pnum \indextext{label!scope of}% -Labels~(\ref{stmt.label}) have \defnx{function scope}{scope!function} and +Labels\iref{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. @@ -824,8 +831,8 @@ declarative region of the namespace are said to be \defn{member names} of the namespace. A namespace member name has namespace scope. Its potential scope includes its namespace from the name's point of -declaration~(\ref{basic.scope.pdecl}) onwards; and for each -\grammarterm{using-directive}~(\ref{namespace.udir}) that nominates the +declaration\iref{basic.scope.pdecl} onwards; and for each +\grammarterm{using-directive}\iref{namespace.udir} that nominates the member's namespace, the member's potential scope includes that portion of the potential scope of the \grammarterm{using-directive} that follows the member's point of declaration. \begin{example} @@ -858,7 +865,7 @@ \pnum A namespace member can also be referred to after the \tcode{::} scope -resolution operator~(\ref{expr.prim}) applied to the name of its +resolution operator\iref{expr.prim} applied to the name of its namespace or the name of a namespace which nominates the member's namespace in a \grammarterm{using-directive}; see~\ref{namespace.qual}. @@ -869,7 +876,7 @@ namespace, called the \defn{global namespace}. A name declared in the global namespace has \defn{global namespace scope} (also called \defn{global scope}). The potential scope of such a name begins at -its point of declaration~(\ref{basic.scope.pdecl}) and ends at the end +its point of declaration\iref{basic.scope.pdecl} and ends at the end of the translation unit that is its declarative region. \indextext{name!global}% A name with global namespace scope is said to be a @@ -906,7 +913,7 @@ body and any portion of the declarator part of such definitions which follows the \grammarterm{declarator-id}, including a \grammarterm{parameter-declaration-clause} and any default -arguments~(\ref{dcl.fct.default})). +arguments\iref{dcl.fct.default}). \pnum \begin{example} @@ -938,13 +945,13 @@ \pnum The name of a class member shall only be used as follows: \begin{itemize} -\item in the scope of its class (as described above) or a class derived -(Clause~\ref{class.derived}) from its class, +\item in the scope of its class (as described above) or a class derived\iref{class.derived} +from its class, \item after the \tcode{.} operator applied to an expression of the type -of its class~(\ref{expr.ref}) or a class derived from its class, +of its class\iref{expr.ref} or a class derived from its class, \item after the \tcode{->} operator applied to a pointer to an object of -its class~(\ref{expr.ref}) or a class derived from its class, -\item after the \tcode{::} scope resolution operator~(\ref{expr.prim}) +its class\iref{expr.ref} or a class derived from its class, +\item after the \tcode{::} scope resolution operator\iref{expr.prim} applied to the name of its class or a class derived from its class. \end{itemize} @@ -953,7 +960,7 @@ \indextext{scope!enumeration} \pnum -The name of a scoped enumerator~(\ref{dcl.enum}) has +The name of a scoped enumerator\iref{dcl.enum} has \defn{enumeration scope}. Its potential scope begins at its point of declaration and terminates at the end of the \grammarterm{enum-specifier}. @@ -995,7 +1002,7 @@ \pnum The potential scope of a template parameter name begins at its point of -declaration~(\ref{basic.scope.pdecl}) and ends at the end of its declarative region. +declaration\iref{basic.scope.pdecl} and ends at the end of its declarative region. \begin{note} This implies that a \grammarterm{template-parameter} can be used in the declaration of subsequent \grammarterm{template-parameter}{s} and their default arguments but cannot be used in preceding \grammarterm{template-parameter}{s} or their @@ -1022,7 +1029,7 @@ The declarative region of the name of a template parameter is nested within the immediately-enclosing declarative region. \begin{note} As a result, a \grammarterm{template-parameter} hides any entity with the same name in an enclosing -scope~(\ref{basic.scope.hiding}). \begin{example} +scope\iref{basic.scope.hiding}. \begin{example} \begin{codeblock} typedef int N; @@ -1035,7 +1042,7 @@ \pnum \begin{note} Because the name of a template parameter cannot be redeclared within its -potential scope~(\ref{temp.local}), a template parameter's scope is often its potential +potential scope\iref{temp.local}, a template parameter's scope is often its potential scope. However, it is still possible for a template parameter name to be hidden; see~\ref{temp.local}. \end{note} @@ -1046,11 +1053,11 @@ \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}). +nested declarative region or derived class\iref{class.member.lookup}. \pnum \indextext{name hiding}% -A class name~(\ref{class.name}) or enumeration name~(\ref{dcl.enum}) can +A class name\iref{class.name} or enumeration name\iref{dcl.enum} can be hidden by the name of a variable, data member, function, or enumerator declared in the same scope. If a class or enumeration name and a variable, data member, function, or enumerator are declared in the same scope (in any order) with the @@ -1063,7 +1070,7 @@ hides the declaration of a member of the class with the same name; see~\ref{basic.scope.class}. The declaration of a member in a derived -class (Clause~\ref{class.derived}) hides the declaration of a member of +class\iref{class.derived} hides the declaration of a member of a base class of the same name; see~\ref{class.member.lookup}. \pnum @@ -1083,30 +1090,30 @@ \pnum The name lookup rules apply uniformly to all names (including -\grammarterm{typedef-name}{s}~(\ref{dcl.typedef}), -\grammarterm{namespace-name}{s} (\ref{basic.namespace}), and -\grammarterm{class-name}{s}~(\ref{class.name})) wherever the grammar allows +\grammarterm{typedef-name}{s}\iref{dcl.typedef}, +\grammarterm{namespace-name}{s}\iref{basic.namespace}, and +\grammarterm{class-name}{s}\iref{class.name}) wherever the grammar allows such names in the context discussed by a particular rule. Name lookup -associates the use of a name with a set of declarations~(\ref{basic.def}) of +associates the use of a name with a set of declarations\iref{basic.def} of that name. The declarations found by name lookup shall either all declare the same entity or shall all declare functions; in the latter case, the declarations are said to form a set of overloaded -functions~(\ref{over.load}). Overload resolution~(\ref{over.match}) -takes place after name lookup has succeeded. The access rules -(Clause~\ref{class.access}) are considered only once name lookup and +functions\iref{over.load}. Overload resolution\iref{over.match} +takes place after name lookup has succeeded. The access rules\iref{class.access} +are considered only once name lookup and function overload resolution (if applicable) have succeeded. Only after name lookup, function overload resolution (if applicable) and access checking have succeeded are the attributes introduced by the name's -declaration used further in expression processing (Clause~\ref{expr}). +declaration used further in expression processing\iref{expr}. \pnum A name ``looked up in the context of an expression'' is looked up as an unqualified name in the scope where the expression is found. \pnum -The injected-class-name of a class (Clause~\ref{class}) is also +The injected-class-name of a class\iref{class} is also considered to be a member of that class for the purposes of name hiding and lookup. @@ -1157,7 +1164,7 @@ \end{codeblock} Because the expression is not a function call, the argument-dependent -name lookup~(\ref{basic.lookup.argdep}) does not apply and the friend +name lookup\iref{basic.lookup.argdep} does not apply and the friend function \tcode{f} is not found. \end{note} \pnum @@ -1179,7 +1186,7 @@ \grammarterm{parameter-declaration-clause} or used in the function body.} shall be declared before its use in the block in which it is used or in one of -its enclosing blocks~(\ref{stmt.block}) or shall be declared before its +its enclosing blocks\iref{stmt.block} or shall be declared before its use in namespace \tcode{N} or, if \tcode{N} is a nested namespace, shall be declared before its use in one of \tcode{N}'s enclosing namespaces. \begin{example} @@ -1211,18 +1218,18 @@ shall be declared in one of the following ways: \begin{itemize} \item before its use in class \tcode{X} or be a member of a base class -of \tcode{X}~(\ref{class.member.lookup}), or +of \tcode{X}\iref{class.member.lookup}, or \item if \tcode{X} is a nested class of class -\tcode{Y}~(\ref{class.nest}), before the definition of \tcode{X} in +\tcode{Y}\iref{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 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 -definition~(\ref{class.nest}).} +definition\iref{class.nest}.} or -\item if \tcode{X} is a local class~(\ref{class.local}) or is a nested +\item if \tcode{X} is a local class\iref{class.local} or is a nested class of a local class, before the definition of class \tcode{X} in a block enclosing the definition of class \tcode{X}, or \item if \tcode{X} is a member of namespace \tcode{N}, or is a nested @@ -1271,7 +1278,7 @@ For the members of a class \tcode{X}, a name used in a member function body, in a default argument, in a \grammarterm{noexcept-specifier}, in the \grammarterm{brace-or-equal-initializer} of a non-static data -member~(\ref{class.mem}), or in the definition of a class member +member\iref{class.mem}, or in the definition of a class member outside of the definition of \tcode{X}, following the member's \grammarterm{declarator-id}\footnote{That is, an unqualified name that occurs, @@ -1282,13 +1289,13 @@ following ways: \begin{itemize} \item before its use in the block in which it is used or in an enclosing -block~(\ref{stmt.block}), or +block\iref{stmt.block}, or \item shall be a member of class \tcode{X} or be a member of a base -class of \tcode{X}~(\ref{class.member.lookup}), or +class of \tcode{X}\iref{class.member.lookup}, or \item if \tcode{X} -is a nested class of class \tcode{Y}~(\ref{class.nest}), shall be a +is a nested class of class \tcode{Y}\iref{class.nest}, shall be a member of \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 the innermost enclosing class),\footnote{This lookup applies whether @@ -1297,7 +1304,7 @@ is defined in a namespace scope enclosing \tcode{X}'s definition.} or -\item if \tcode{X} is a local class~(\ref{class.local}) or is a nested +\item if \tcode{X} is a local class\iref{class.local} or is a nested class of a local class, before the definition of class \tcode{X} in a block enclosing the definition of class \tcode{X}, or @@ -1338,7 +1345,7 @@ \pnum Name lookup for a name used in the definition of a \tcode{friend} -function~(\ref{class.friend}) defined inline in the class granting +function\iref{class.friend} defined inline in the class granting friendship shall proceed as described for lookup in member function definitions. If the \tcode{friend} function is not defined in the class granting friendship, name lookup in the \tcode{friend} function @@ -1349,7 +1356,7 @@ In a \tcode{friend} declaration naming a member function, a name used in the function declarator and not part of a \grammarterm{template-argument} in the \grammarterm{declarator-id} is first looked up in the scope of the -member function's class~(\ref{class.member.lookup}). If it is not found, +member function's class\iref{class.member.lookup}. If it is not found, or if the name is part of a \grammarterm{template-argument} in the \grammarterm{declarator-id}, the look up is @@ -1375,10 +1382,10 @@ \pnum During the lookup for a name used as a default -argument~(\ref{dcl.fct.default}) in a function +argument\iref{dcl.fct.default} in a function \grammarterm{parameter-declaration-clause} or used in the \grammarterm{expression} of a \grammarterm{mem-initializer} for a -constructor~(\ref{class.base.init}), the function parameter names are +constructor\iref{class.base.init}, the function parameter names are visible and hide the names of entities declared in the block, class or namespace scopes containing the function declaration. \begin{note} \ref{dcl.fct.default} further describes the restrictions on the use of @@ -1395,7 +1402,7 @@ \pnum A name used in the definition of a \tcode{static} data member of class -\tcode{X}~(\ref{class.static.data}) (after the \grammarterm{qualified-id} +\tcode{X}\iref{class.static.data} (after the \grammarterm{qualified-id} of the static member) is looked up as if the name was used in a member function of \tcode{X}. \begin{note} \ref{class.static.data} further describes the restrictions on the use of names in the definition of a @@ -1421,8 +1428,8 @@ \end{example} \pnum -A name used in the handler for a \grammarterm{function-try-block} -(Clause~\ref{except}) is looked up as if the name was used in the +A name used in the handler for a \grammarterm{function-try-block}\iref{except} +is looked up as if the name was used in the outermost block of the function definition. In particular, the function parameter names shall not be redeclared in the \grammarterm{exception-declaration} nor in the outermost block of a handler @@ -1440,10 +1447,10 @@ \pnum When the \grammarterm{postfix-expression} in -a function call~(\ref{expr.call}) is an \grammarterm{unqualified-id}, other namespaces not considered -during the usual unqualified lookup~(\ref{basic.lookup.unqual}) may be +a function call\iref{expr.call} is an \grammarterm{unqualified-id}, other namespaces not considered +during the usual unqualified lookup\iref{basic.lookup.unqual} may be searched, and in those namespaces, namespace-scope friend function or -function template declarations~(\ref{class.friend}) not otherwise +function template declarations\iref{class.friend} not otherwise visible may be found. These modifications to the search depend on the types of the arguments (and for template template arguments, the namespace of the template @@ -1511,7 +1518,7 @@ associated namespaces and classes are those associated with the member type together with those associated with \tcode{X}. \end{itemize} -If an associated namespace is an inline namespace~(\ref{namespace.def}), its +If an associated namespace is an inline namespace\iref{namespace.def}, its enclosing namespace is also included in the set. If an associated namespace directly contains inline namespaces, those inline namespaces are also included in the set. @@ -1527,7 +1534,7 @@ \pnum Let \placeholder{X} be the lookup set produced by unqualified -lookup~(\ref{basic.lookup.unqual}) and let \placeholder{Y} be the lookup set produced +lookup\iref{basic.lookup.unqual} and let \placeholder{Y} be the lookup set produced by argument dependent lookup (defined as follows). If \placeholder{X} contains \begin{itemize} \item a declaration of a class member, or @@ -1561,7 +1568,7 @@ \pnum When considering an associated namespace, the lookup is the same as the lookup performed when the associated namespace is used as a -qualifier~(\ref{namespace.qual}) except that: +qualifier\iref{namespace.qual} except that: \begin{itemize} \item Any \grammarterm{using-directive}{s} in the associated namespace are ignored. @@ -1569,7 +1576,7 @@ \item Any namespace-scope friend functions or friend function templates declared in associated classes are visible within their respective namespaces even if they are not visible during an ordinary -lookup~(\ref{class.friend}). +lookup\iref{class.friend}. \item All names except those of (possibly overloaded) functions and function templates are ignored. @@ -1583,7 +1590,7 @@ \indextext{qualification!explicit}% The name of a class or namespace member or enumerator can be referred to after the -\tcode{::} scope resolution operator~(\ref{expr.prim}) applied to a +\tcode{::} scope resolution operator\iref{expr.prim} applied to a \grammarterm{nested-name-specifier} that denotes its class, namespace, or enumeration. If a @@ -1610,7 +1617,7 @@ \pnum \begin{note} Multiply qualified names, such as \tcode{N1::N2::N3::n}, can -be used to refer to members of nested classes~(\ref{class.nest}) or +be used to refer to members of nested classes\iref{class.nest} or members of nested namespaces. \end{note} \pnum @@ -1636,13 +1643,13 @@ \pnum \indextext{operator!scope resolution}% \indextext{scope resolution operator|see{operator, scope resolution}}% -A name prefixed by the unary scope operator \tcode{::}~(\ref{expr.prim}) +A name prefixed by the unary scope operator \tcode{::}\iref{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 whose declaration is visible in global scope because of a -\grammarterm{using-directive}~(\ref{namespace.qual}). The use of \tcode{::} +\grammarterm{using-directive}\iref{namespace.qual}. The use of \tcode{::} allows a global name to be referred to even if its identifier has been -hidden~(\ref{basic.scope.hiding}). +hidden\iref{basic.scope.hiding}. \pnum A name prefixed by a \grammarterm{nested-name-specifier} that @@ -1650,7 +1657,7 @@ of that enumeration. \pnum -If a \grammarterm{pseudo-destructor-name}~(\ref{expr.pseudo}) contains a +If a \grammarterm{pseudo-destructor-name}\iref{expr.pseudo} contains a \grammarterm{nested-name-specifier}, the \grammarterm{type-name}{s} are looked up as types in the scope designated by the \grammarterm{nested-name-specifier}. Similarly, in a @@ -1692,11 +1699,11 @@ 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 -class~(\ref{class.member.lookup}), except for the cases listed below. +class\iref{class.member.lookup}, except for the cases listed below. The name shall represent one or more members of that class or of one of -its base classes (Clause~\ref{class.derived}). \begin{note} A class member +its base classes\iref{class.derived}. \begin{note} A class member can be referred to using a \grammarterm{qualified-id} at any point in its -potential scope~(\ref{basic.scope.class}). \end{note} The exceptions to +potential scope\iref{basic.scope.class}. \end{note} The exceptions to the name lookup rule above are the following: \begin{itemize} \item the lookup for a destructor is as specified @@ -1712,9 +1719,9 @@ \grammarterm{postfix-expression} occurs. \item the lookup for a name specified in a -\grammarterm{using-declaration}~(\ref{namespace.udecl}) also finds class or +\grammarterm{using-declaration}\iref{namespace.udecl} also finds class or enumeration names hidden within the same -scope~(\ref{basic.scope.hiding}). +scope\iref{basic.scope.hiding}. \end{itemize} \pnum @@ -1725,10 +1732,10 @@ and the \grammarterm{nested-name-specifier} nominates a class \tcode{C}: \begin{itemize} \item if the name specified after the \grammarterm{nested-name-specifier}, -when looked up in \tcode{C}, is the injected-class-name of \tcode{C} (Clause~\ref{class}), or +when looked up in \tcode{C}, is the injected-class-name of \tcode{C}\iref{class}, or \item in a \grammarterm{using-declarator} of -a \grammarterm{using-declaration}~(\ref{namespace.udecl}) that is a \grammarterm{member-declaration}, +a \grammarterm{using-declaration}\iref{namespace.udecl} that is a \grammarterm{member-declaration}, if the name specified after the \grammarterm{nested-name-specifier} is the same as the \grammarterm{identifier} or the \grammarterm{simple-template-id}'s \grammarterm{template-name} in the last component of the \grammarterm{nested-name-specifier}, @@ -1777,7 +1784,7 @@ For a namespace \tcode{X} and name \tcode{m}, the namespace-qualified lookup set $S(X, m)$ is defined as follows: Let $S'(X, m)$ be the set of all declarations of \tcode{m} in \tcode{X} and the inline namespace set of -\tcode{X}~(\ref{namespace.def}). If $S'(X, m)$ is not empty, $S(X, m)$ +\tcode{X}\iref{namespace.def}. If $S'(X, m)$ is not empty, $S(X, m)$ is $S'(X, m)$; otherwise, $S(X, m)$ is the union of $S(N_i, m)$ for all namespaces $N_i$ nominated by \grammarterm{using-directive}{s} in \tcode{X} and its inline namespace set. @@ -1787,7 +1794,7 @@ given \tcode{::m} (where X is the global namespace), if $S(X, m)$ is the empty set, the program is ill-formed. Otherwise, if $S(X, m)$ has exactly one member, or if the context of the reference is -a \grammarterm{using-declaration}~(\ref{namespace.udecl}), $S(X, m)$ +a \grammarterm{using-declaration}\iref{namespace.udecl}, $S(X, m)$ is the required set of declarations of \tcode{m}. Otherwise if the use of \tcode{m} is not one that allows a unique declaration to be chosen from @@ -1962,7 +1969,7 @@ the \grammarterm{unqualified-id} shall name a member of the namespace designated by the \grammarterm{nested-name-specifier} -or of an element of the inline namespace set~(\ref{namespace.def}) of that namespace. +or of an element of the inline namespace set\iref{namespace.def} of that namespace. \begin{example} \begin{codeblock} @@ -2005,10 +2012,10 @@ \indextext{type specifier!elaborated} \pnum -An \grammarterm{elaborated-type-specifier}~(\ref{dcl.type.elab}) may be +An \grammarterm{elaborated-type-specifier}\iref{dcl.type.elab} may be used to refer to a previously declared \grammarterm{class-name} or \grammarterm{enum-name} even though the name has been hidden by a non-type -declaration~(\ref{basic.scope.hiding}). +declaration\iref{basic.scope.hiding}. \pnum If the \grammarterm{elaborated-type-specifier} has no @@ -2056,7 +2063,7 @@ 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; // error: \tcode{Glob} is not declared, cannot introduce a qualified type\iref{dcl.type.elab} friend struct Glob; // OK: Refers to (as yet) undeclared \tcode{Glob} at global scope. @\commentellip@ }; @@ -2071,8 +2078,8 @@ }; struct Data; // OK: Redeclares \tcode{Data} at global scope -struct ::Data; // error: cannot introduce a qualified type~(\ref{dcl.type.elab}) -struct Base::Data; // error: cannot introduce a qualified type~(\ref{dcl.type.elab}) +struct ::Data; // error: cannot introduce a qualified type\iref{dcl.type.elab} +struct Base::Data; // error: cannot introduce a qualified type\iref{dcl.type.elab} struct Base::Datum; // error: \tcode{Datum} undefined struct Base::Data* pBase; // OK: refers to nested \tcode{Data} \end{codeblock} @@ -2083,21 +2090,21 @@ \pnum \indextext{lookup!class member}% -In a class member access expression~(\ref{expr.ref}), if the \tcode{.} +In a class member access expression\iref{expr.ref}, if the \tcode{.} or \tcode{->} token is immediately followed by an \grammarterm{identifier} followed by a \tcode{<}, the identifier must be looked up to determine whether the \tcode{<} is the beginning of a template argument -list~(\ref{temp.names}) or a less-than operator. The identifier is first +list\iref{temp.names} or a less-than operator. The identifier is first looked up in the class of the object expression. If the identifier is not found, it is then looked up in the context of the entire \grammarterm{postfix-expression} and shall name a class template. \pnum If the \grammarterm{id-expression} in a class member -access~(\ref{expr.ref}) is an \grammarterm{unqualified-id}, and the type of +access\iref{expr.ref} is an \grammarterm{unqualified-id}, and the type of the object expression is of a class type \tcode{C}, the \grammarterm{unqualified-id} is looked up in the scope of class \tcode{C}. -For a pseudo-destructor call~(\ref{expr.pseudo}), +For a pseudo-destructor call\iref{expr.pseudo}, the \grammarterm{unqualified-id} is looked up in the context of the complete \grammarterm{postfix-expression}. @@ -2146,7 +2153,7 @@ \pnum If the \grammarterm{nested-name-specifier} contains a -\grammarterm{simple-template-id}~(\ref{temp.names}), the names in its +\grammarterm{simple-template-id}\iref{temp.names}, the names in its \grammarterm{template-argument}{s} are looked up in the context in which the entire \grammarterm{postfix-expression} occurs. @@ -2192,8 +2199,8 @@ \pnum \indextext{program}% -A \defn{program} consists of one or more \defnx{translation units}{translation unit} -(Clause~\ref{lex}) linked together. A translation unit consists +A \defn{program} consists of one or more \defnx{translation units}{translation unit}\iref{lex} +linked together. A translation unit consists of a sequence of declarations. \begin{bnf} @@ -2231,7 +2238,7 @@ \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 +A name having namespace scope\iref{basic.scope.namespace} has internal linkage if it is the name of \begin{itemize} \item @@ -2255,13 +2262,13 @@ \item a variable; or \item a function; or \item \indextext{class!linkage of}% -a named class (Clause~\ref{class}), or an unnamed class defined in a +a named class\iref{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 +purposes\iref{dcl.typedef}; or \item \indextext{enumeration!linkage of}% -a named enumeration~(\ref{dcl.enum}), or an unnamed enumeration defined +a named enumeration\iref{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 +for linkage purposes\iref{dcl.typedef}; or \item a template. \end{itemize} @@ -2269,7 +2276,7 @@ In addition, a member function, static data member, a named class or enumeration of class scope, or an unnamed class or enumeration defined in a class-scope typedef declaration such that the class or enumeration -has the typedef name for linkage purposes~(\ref{dcl.typedef}), has +has the typedef name for linkage purposes\iref{dcl.typedef}, has the same linkage, if any, as the name of the class of which it is a member. @@ -2330,37 +2337,37 @@ \pnum \indextext{linkage!no}% Names not covered by these rules have no linkage. Moreover, except as -noted, a name declared at block scope~(\ref{basic.scope.block}) has no +noted, a name declared at block scope\iref{basic.scope.block} has no linkage. A type is said to have linkage if and only if: \begin{itemize} \item it is a class or enumeration type that is named (or has a name for -linkage purposes~(\ref{dcl.typedef})) and the name has linkage; or +linkage purposes\iref{dcl.typedef}) and the name has linkage; or \item it is an unnamed class or unnamed enumeration that is a member of a class with linkage; or -\item it is a specialization of a class template (Clause~\ref{temp})\footnote{A class +\item it is a specialization of a class template\iref{temp}\footnote{A class template has the linkage of the innermost enclosing class or namespace in which it is declared.}; or -\item it is a fundamental type~(\ref{basic.fundamental}); or +\item it is a fundamental type\iref{basic.fundamental}; or -\item it is a compound type~(\ref{basic.compound}) other than a class or +\item it is a compound type\iref{basic.compound} other than a class or enumeration, compounded exclusively from types that have linkage; or -\item it is a cv-qualified~(\ref{basic.type.qualifier}) version of a +\item it is a cv-qualified\iref{basic.type.qualifier} version of a type that has linkage. \end{itemize} A type without linkage shall not be used as the type of a variable or function with external linkage unless \begin{itemize} -\item the entity has C language linkage~(\ref{dcl.link}), or +\item the entity has C language linkage\iref{dcl.link}, or \item the entity is declared within an unnamed -namespace~(\ref{namespace.def}), or +namespace\iref{namespace.def}, or -\item the entity is not odr-used~(\ref{basic.def.odr}) or is defined in +\item the entity is not odr-used\iref{basic.def.odr} or is defined in the same translation unit. \end{itemize} \begin{note} @@ -2393,7 +2400,7 @@ \end{example} \pnum -Two names that are the same (Clause~\ref{basic}) and that are declared +Two names that are the same\iref{basic} and that are declared in different scopes shall denote the same variable, function, type, template or namespace if \begin{itemize} @@ -2404,26 +2411,26 @@ not by inheritance, of the same class; and \item when both names denote functions, the parameter-type-lists of the -functions~(\ref{dcl.fct}) are identical; and +functions\iref{dcl.fct} are identical; and \item when both names denote function templates, the -signatures~(\ref{temp.over.link}) are the same. +signatures\iref{temp.over.link} are the same. \end{itemize} \pnum \indextext{consistency!type declaration}% \indextext{declaration!multiple}% After all adjustments of types (during which -typedefs~(\ref{dcl.typedef}) are replaced by their definitions), the +typedefs\iref{dcl.typedef} are replaced by their definitions), the types specified by all declarations referring to a given variable or function shall be identical, except that declarations for an array object can specify array types that differ by the presence or absence of -a major array bound~(\ref{dcl.array}). A violation of this rule on type +a major array bound\iref{dcl.array}. A violation of this rule on type identity does not require a diagnostic. \pnum \begin{note} Linkage to non-\Cpp declarations can be achieved using a -\grammarterm{linkage-specification}~(\ref{dcl.link}). \end{note}% +\grammarterm{linkage-specification}\iref{dcl.link}. \end{note}% \indextext{linkage|)} \rSec1[basic.start]{Start and termination} @@ -2437,7 +2444,7 @@ Executing a program starts a main thread of execution~(\ref{intro.multithread}, \ref{thread.threads}) in which the \tcode{main} function is invoked, and in which variables of static storage duration -might be initialized~(\ref{basic.start.static}) and destroyed~(\ref{basic.start.term}). +might be initialized\iref{basic.start.static} and destroyed\iref{basic.start.term}. It is \impldef{defining \tcode{main} in freestanding environment} whether a program in a freestanding environment is required to define a \tcode{main} function. \begin{note} In a freestanding environment, start-up and termination is @@ -2460,7 +2467,7 @@ \indextext{\idxcode{argc}}% \indextext{\idxcode{argv}}% -as the type of \tcode{main}~(\ref{dcl.fct}). +as the type of \tcode{main}\iref{dcl.fct}. \indextext{\idxcode{main} function!parameters to}% \indextext{environment!program}% In the latter form, for purposes of exposition, the first function @@ -2470,8 +2477,8 @@ program is run. If \tcode{argc} is nonzero these arguments shall be supplied in \tcode{argv[0]} through \tcode{argv[argc-1]} as pointers to the initial -characters of null-terminated multibyte strings (\ntmbs -s)~(\ref{multibyte.strings}) and \tcode{argv[0]} shall be the pointer to +characters of null-terminated multibyte strings (\ntmbs{}s)\iref{multibyte.strings} +and \tcode{argv[0]} shall be the pointer to the initial character of a \ntmbs that represents the name used to invoke the program or \tcode{""}. The value of \tcode{argc} shall be non-negative. The value of \tcode{argv[argc]} shall be 0. \begin{note} It @@ -2482,12 +2489,12 @@ The function \tcode{main} shall not be used within a program. \indextext{\idxcode{main} function!implementation-defined linkage of}% -The linkage~(\ref{basic.link}) of \tcode{main} is +The linkage\iref{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 \tcode{inline}, \tcode{static}, or \tcode{constexpr} is ill-formed. The \tcode{main} function shall not be declared with a -\grammarterm{linkage-specification}~(\ref{dcl.link}). A program that +\grammarterm{linkage-specification}\iref{dcl.link}. A program that 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 @@ -2501,8 +2508,8 @@ \indextext{termination!program}% Terminating the program without leaving the current block (e.g., by calling the function -\tcode{std::exit(int)} (\ref{support.start.term})) does not destroy any -objects with automatic storage duration~(\ref{class.dtor}). If +\tcode{std::exit(int)}\iref{support.start.term}) does not destroy any +objects with automatic storage duration\iref{class.dtor}. If \tcode{std::exit} is called to end a program during the destruction of an object with static or thread storage duration, the program has undefined behavior. @@ -2543,13 +2550,13 @@ is initialized by a constant initializer for the entity. \indextext{initialization!runtime}% If constant initialization is not performed, a variable with static -storage duration~(\ref{basic.stc.static}) or thread storage -duration~(\ref{basic.stc.thread}) is zero-initialized~(\ref{dcl.init}). +storage duration\iref{basic.stc.static} or thread storage +duration\iref{basic.stc.thread} is zero-initialized\iref{dcl.init}. Together, zero-initialization and constant initialization are called \indextext{initialization!dynamic}% \defn{static initialization}; all other initialization is \defn{dynamic initialization}. -All static initialization strongly happens before~(\ref{intro.races}) +All static initialization strongly happens before\iref{intro.races} any dynamic initialization. \begin{note} The dynamic initialization of non-local variables is described in~\ref{basic.start.dynamic}; that of local static variables is described @@ -2619,8 +2626,8 @@ every translation unit in which \tcode{W} is defined, then \begin{itemize} \item -if the program starts a thread~(\ref{intro.multithread}) -other than the main thread~(\ref{basic.start.main}), +if the program starts a thread\iref{intro.multithread} +other than the main thread\iref{basic.start.main}, the initialization of \tcode{V} strongly happens before the initialization of \tcode{W}; @@ -2650,7 +2657,7 @@ \pnum \indextext{non-initialization odr-use|see{odr-use, non-initialization}}% A \defnx{non-initialization odr-use}{odr-use!non-initialization} -is an odr-use~(\ref{basic.def.odr}) not caused directly or indirectly by +is an odr-use\iref{basic.def.odr} not caused directly or indirectly by the initialization of a non-local static or thread storage duration variable. \pnum @@ -2666,7 +2673,7 @@ \footnote{A non-local variable with static storage duration having initialization with side effects is initialized in this case, -even if it is not itself odr-used (\ref{basic.def.odr},~\ref{basic.stc.static}).} +even if it is not itself odr-used~(\ref{basic.def.odr}, \ref{basic.stc.static}).} It is \impldef{threads and program points at which deferred dynamic initialization is performed} in which threads and at which points in the program such deferred dynamic initialization occurs. \begin{note} @@ -2736,7 +2743,7 @@ \pnum If the initialization of a non-local variable with static or thread storage duration exits via -an exception, \tcode{std::terminate} is called~(\ref{except.terminate}).% +an exception, \tcode{std::terminate} is called\iref{except.terminate}.% \indextext{program!start|)} \rSec2[basic.start.term]{Termination} @@ -2745,18 +2752,18 @@ \indextext{program!termination|(}% \indextext{object!destructor static}% \indextext{\idxcode{main} function!return from}% -Destructors~(\ref{class.dtor}) for initialized objects -(that is, objects whose lifetime~(\ref{basic.life}) has begun) +Destructors\iref{class.dtor} for initialized objects +(that is, objects whose lifetime\iref{basic.life} has begun) with static storage duration, and functions registered with \tcode{std::atexit}, are called as part of a call to \indextext{\idxcode{exit}}% \indexlibrary{\idxcode{exit}}% -\tcode{std::exit}~(\ref{support.start.term}). +\tcode{std::exit}\iref{support.start.term}. The call to \tcode{std::exit} is sequenced before the invocations of the destructors and the registered functions. \begin{note} -Returning from \tcode{main} invokes \tcode{std::exit}~(\ref{basic.start.main}). +Returning from \tcode{main} invokes \tcode{std::exit}\iref{basic.start.main}. \end{note} \pnum @@ -2782,7 +2789,7 @@ of the subobjects is destroyed. If the destruction of an object with static or thread storage duration exits via an exception, -\tcode{std::terminate} is called~(\ref{except.terminate}). +\tcode{std::terminate} is called\iref{except.terminate}. \pnum If a function contains a block-scope object of static or thread storage duration that has been @@ -2797,7 +2804,7 @@ \indexlibrary{\idxcode{atexit}}% If the completion of the initialization of an object with static storage duration strongly happens before a call to \tcode{std::atexit}~(see -\tcode{},~\ref{support.start.term}), the call to the function passed to +\tcode{}, \ref{support.start.term}), the call to the function passed to \tcode{std::atexit} is sequenced before the call to the destructor for the object. If a call to \tcode{std::atexit} strongly happens before the completion of the initialization of an object with static storage duration, the call to the destructor for the @@ -2808,9 +2815,9 @@ \pnum If there is a use of a standard library object or function not permitted within signal -handlers~(\ref{support.runtime}) that does not happen before~(\ref{intro.multithread}) +handlers\iref{support.runtime} that does not happen before\iref{intro.multithread} completion of destruction of objects with static storage duration and execution of -\tcode{std::atexit} registered functions~(\ref{support.start.term}), the program has +\tcode{std::atexit} registered functions\iref{support.start.term}, the program has undefined behavior. \begin{note} If there is a use of an object with static storage duration that does not happen before the object's destruction, the program has undefined behavior. Terminating every thread before a call to \tcode{std::exit} or the exit from @@ -2850,10 +2857,10 @@ \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 +introduced by declarations\iref{basic.def} and implicitly created by +the implementation\iref{class.temporary}. The dynamic storage duration is associated with objects created by a -\grammarterm{new-expression}~(\ref{expr.new}). +\grammarterm{new-expression}\iref{expr.new}. \pnum The storage duration categories apply to references as well. @@ -2862,7 +2869,7 @@ When the end of the duration of a region of storage is reached, the values of all pointers representing the address of any part of that region of storage -become invalid pointer values~(\ref{basic.compound}). +become invalid pointer values\iref{basic.compound}. Indirection through an invalid pointer value and passing an invalid pointer value to a deallocation function have undefined behavior. @@ -2912,7 +2919,7 @@ \pnum A variable with thread storage duration shall be initialized before -its first odr-use~(\ref{basic.def.odr}) and, if constructed, shall be destroyed on thread exit. +its first odr-use\iref{basic.def.odr} and, if constructed, shall be destroyed on thread exit. \rSec2[basic.stc.auto]{Automatic storage duration} @@ -2941,11 +2948,11 @@ \pnum Objects can be created dynamically during program -execution~(\ref{intro.execution}), using +execution\iref{intro.execution}, using \indextext{\idxcode{new}}% -\grammarterm{new-expression}{s}~(\ref{expr.new}), and destroyed using +\grammarterm{new-expression}{s}\iref{expr.new}, and destroyed using \indextext{\idxcode{delete}}% -\grammarterm{delete-expression}{s}~(\ref{expr.delete}). A \Cpp implementation +\grammarterm{delete-expression}{s}\iref{expr.delete}. A \Cpp implementation provides access to, and management of, dynamic storage via the global \defn{allocation functions} \tcode{operator new} and \tcode{operator new[]} and the global \defn{deallocation functions} \tcode{operator @@ -2958,11 +2965,11 @@ \pnum The library provides default definitions for the global allocation and deallocation functions. Some global allocation and deallocation -functions are replaceable~(\ref{new.delete}). A \Cpp program shall +functions are replaceable\iref{new.delete}. A \Cpp program shall provide at most one definition of a replaceable allocation or deallocation function. Any such function definition replaces the default -version provided in the library~(\ref{replacement.functions}). The -following allocation and deallocation functions~(\ref{support.dynamic}) +version provided in the library\iref{replacement.functions}. The +following allocation and deallocation functions\iref{support.dynamic} are implicitly declared in global scope in each translation unit of a program. @@ -3001,7 +3008,7 @@ is ill-formed unless the name has been declared by including the appropriate header. \end{note} Allocation and/or deallocation functions may also be declared and defined for any -class~(\ref{class.free}). +class\iref{class.free}. \pnum Any allocation and/or deallocation functions defined in a \Cpp program, @@ -3017,9 +3024,9 @@ function; a program is ill-formed if an allocation function is declared in a namespace scope other than global scope or declared static in global scope. The return type shall be \tcode{void*}. The first -parameter shall have type \tcode{std::size_t}~(\ref{support.types}). The +parameter shall have type \tcode{std::size_t}\iref{support.types}. The first parameter shall not have an associated default -argument~(\ref{dcl.fct.default}). The value of the first parameter shall +argument\iref{dcl.fct.default}. The value of the first parameter shall be interpreted as the requested size of the allocation. An allocation function can be a function template. Such a template shall declare its return type and first parameter as specified above (that is, template @@ -3035,12 +3042,12 @@ contiguity, and initial value of storage allocated by successive calls to an allocation function are unspecified. The pointer returned shall be suitably aligned so that it can be converted to a pointer to any -suitable complete object type~(\ref{new.delete.single}) +suitable complete object type\iref{new.delete.single} and then used to access the object or array in the storage allocated (until the storage is explicitly deallocated by a call to a corresponding deallocation function). Even if the size of the space requested is zero, the request can fail. If the request succeeds, the -value returned shall be a non-null pointer value~(\ref{conv.ptr}) +value returned shall be a non-null pointer value\iref{conv.ptr} \tcode{p0} different from any previously returned value \tcode{p1}, unless that value \tcode{p1} was subsequently passed to an \tcode{operator} \tcode{delete}. @@ -3057,30 +3064,30 @@ \pnum An allocation function that fails to allocate storage can invoke the -currently installed new-handler function~(\ref{new.handler}), if any. +currently installed new-handler function\iref{new.handler}, if any. \begin{note} \indextext{\idxcode{new_handler}}% A program-supplied allocation function can obtain the address of the currently installed \tcode{new_handler} using the -\tcode{std::get_new_handler} function~(\ref{set.new.handler}). \end{note} +\tcode{std::get_new_handler} function\iref{set.new.handler}. \end{note} If an allocation function that has a non-throwing -exception specification~(\ref{except.spec}) +exception specification\iref{except.spec} fails to allocate storage, it shall return a null pointer. Any other allocation function that fails to allocate storage shall indicate -failure only by throwing an exception~(\ref{except.throw}) of a type -that would match a handler~(\ref{except.handle}) of type -\tcode{std::bad_alloc}~(\ref{bad.alloc}). +failure only by throwing an exception\iref{except.throw} of a type +that would match a handler\iref{except.handle} of type +\tcode{std::bad_alloc}\iref{bad.alloc}. \pnum A global allocation function is only called as the result of a new -expression~(\ref{expr.new}), or called directly using the function call -syntax~(\ref{expr.call}), or called indirectly through calls to the +expression\iref{expr.new}, or called directly using the function call +syntax\iref{expr.call}, or called indirectly through calls to the functions in the \Cpp standard library. \begin{note} In particular, a global allocation function is not called to allocate storage for objects -with static storage duration~(\ref{basic.stc.static}), for objects or references -with thread storage duration~(\ref{basic.stc.thread}), for objects of -type \tcode{std::type_info}~(\ref{expr.typeid}), or for an -exception object~(\ref{except.throw}). +with static storage duration\iref{basic.stc.static}, for objects or references +with thread storage duration\iref{basic.stc.thread}, for objects of +type \tcode{std::type_info}\iref{expr.typeid}, or for an +exception object\iref{except.throw}. \end{note} \rSec3[basic.stc.dynamic.deallocation]{Deallocation functions} @@ -3110,7 +3117,7 @@ \footnote{The global \tcode{operator delete(void*, std::size_t)} precludes use of an allocation function \tcode{void operator new(std::size_t, std::size_t)} as a placement -allocation function (\ref{diff.cpp11.basic}).}; or +allocation function~(\ref{diff.cpp11.basic}).}; or \item exactly three parameters, the type of the second being \tcode{std::size_t} @@ -3134,7 +3141,7 @@ \pnum If the argument given to a deallocation function in the standard library -is a pointer that is not the null pointer value~(\ref{conv.ptr}), the +is a pointer that is not the null pointer value\iref{conv.ptr}, the deallocation function shall deallocate the storage referenced by the pointer, ending the duration of the region of storage. @@ -3146,11 +3153,11 @@ A \defn{traceable pointer object} is \begin{itemize} \item an object of an object pointer -type~(\ref{basic.compound}), or +type\iref{basic.compound}, or \item an object of an integral type that is at least as large as \tcode{std::intptr_t}, or \item a sequence of elements in an array of narrow character -type~(\ref{basic.fundamental}), where the size and alignment of the sequence +type\iref{basic.fundamental}, where the size and alignment of the sequence match those of some object pointer type. \end{itemize} @@ -3171,11 +3178,11 @@ subobjects) designated by an lvalue resulting from indirection through a safely-derived pointer value; -\item the result of well-defined pointer arithmetic~(\ref{expr.add}) using a safely-derived pointer +\item the result of well-defined pointer arithmetic\iref{expr.add} using a safely-derived pointer value; \item the result of a well-defined pointer -conversion~(\ref{conv.ptr},~\ref{expr.cast}) of a safely-derived pointer value; +conversion~(\ref{conv.ptr}, \ref{expr.cast}) of a safely-derived pointer value; \item the result of a \tcode{reinterpret_cast} of a safely-derived pointer value; @@ -3218,9 +3225,9 @@ storage duration that is not a safely-derived pointer value is an invalid pointer value unless the referenced complete object has previously been declared -reachable~(\ref{util.dynamic.safety}). \begin{note} +reachable\iref{util.dynamic.safety}. \begin{note} The effect of using an invalid pointer value (including passing it to a -deallocation function) is undefined, see~\ref{basic.stc.dynamic.deallocation}. +deallocation function) is undefined, see~\ref{basic.stc}. This is true even if the unsafely-derived pointer value might compare equal to some safely-derived pointer value. \end{note} It is \impldef{whether an implementation has relaxed or strict pointer @@ -3233,7 +3240,7 @@ \pnum \indextext{storage duration!class member}% The storage duration of subobjects and reference members -is that of their complete object~(\ref{intro.object}). +is that of their complete object\iref{intro.object}. \indextext{storage duration|)}% \rSec1[basic.life]{Object lifetime} @@ -3259,9 +3266,9 @@ The lifetime of an object \placeholder{o} of type \tcode{T} ends when: \begin{itemize} \item if \tcode{T} is a class type with a non-trivial -destructor~(\ref{class.dtor}), the destructor call starts, or +destructor\iref{class.dtor}, the destructor call starts, or \item the storage which the object occupies is released, -or is reused by an object that is not nested within \placeholder{o}~(\ref{intro.object}). +or is reused by an object that is not nested within \placeholder{o}\iref{intro.object}. \end{itemize} \pnum @@ -3291,7 +3298,7 @@ class type with a non-trivial destructor, the program is not required to call the destructor explicitly before the storage which the object occupies is reused or released; however, if there is no explicit call to -the destructor or if a \grammarterm{delete-expression}~(\ref{expr.delete}) +the destructor or if a \grammarterm{delete-expression}\iref{expr.delete} is not used to release the storage, the destructor shall not be implicitly called and any program that depends on the side effects produced by the destructor has undefined behavior. @@ -3300,7 +3307,7 @@ Before the lifetime of an object has started but after the storage which the object will occupy has been allocated\footnote{For example, before the construction of a global object of -non-POD class type~(\ref{class.cdtor}).} +non-POD class type\iref{class.cdtor}.} or, after the lifetime of an object has ended and before the storage which the object occupied is reused or released, any pointer that represents the address of the storage location where the object will be or was located may be @@ -3308,7 +3315,7 @@ For an object under construction or destruction, see~\ref{class.cdtor}. Otherwise, such a pointer refers to allocated -storage~(\ref{basic.stc.dynamic.deallocation}), and using the pointer as +storage\iref{basic.stc.dynamic.deallocation}, and using the pointer as if the pointer were of type \tcode{void*}, is well-defined. Indirection through such a pointer is permitted but the resulting lvalue may only be used in limited ways, as described below. The @@ -3321,19 +3328,19 @@ the pointer is used to access a non-static data member or call a non-static member function of the object, or \item - the pointer is implicitly converted~(\ref{conv.ptr}) to a pointer + the pointer is implicitly converted\iref{conv.ptr} to a pointer to a virtual base class, or \item the pointer is used as the operand of a - \tcode{static_cast}~(\ref{expr.static.cast}), except when the conversion + \tcode{static_cast}\iref{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 \cv{}~\tcode{char}, \cv{}~\tcode{unsigned char}, or - \cv{}~\tcode{std::byte}~(\ref{cstddef.syn}), or + \cv{}~\tcode{std::byte}\iref{cstddef.syn}, or \item the pointer is used as the operand of a - \tcode{dynamic_cast}~(\ref{expr.dynamic.cast}). + \tcode{dynamic_cast}\iref{expr.dynamic.cast}. \end{itemize} \begin{example} \begin{codeblock} @@ -3374,15 +3381,15 @@ For an object under construction or destruction, see~\ref{class.cdtor}. Otherwise, such a glvalue refers to -allocated storage~(\ref{basic.stc.dynamic.deallocation}), and using the +allocated storage\iref{basic.stc.dynamic.deallocation}, and using the properties of the glvalue that do not depend on its value is well-defined. The program has undefined behavior if: \begin{itemize} \item the glvalue is used to access the object, or \item the glvalue is used to call a non-static member function of the object, or -\item the glvalue is bound to a reference to a virtual base class~(\ref{dcl.init.ref}), or +\item the glvalue is bound to a reference to a virtual base class\iref{dcl.init.ref}, or \item the glvalue is used as the operand of a -\tcode{dynamic_cast}~(\ref{expr.dynamic.cast}) or as the operand of +\tcode{dynamic_cast}\iref{expr.dynamic.cast} or as the operand of \tcode{typeid}. \end{itemize} @@ -3405,7 +3412,7 @@ class type, does not contain any non-static data member whose type is const-qualified or a reference type, and -\item the original object was a most derived object~(\ref{intro.object}) +\item the original object was a most derived object\iref{intro.object} of type \tcode{T} and the new object is a most derived object of type \tcode{T} (that is, they are not base class subobjects). \end{itemize} @@ -3436,13 +3443,13 @@ If these conditions are not met, a pointer to the new object can be obtained from a pointer that represents the address of its storage -by calling \tcode{std::launder}~(\ref{support.dynamic}). +by calling \tcode{std::launder}\iref{support.dynamic}. \end{note} \pnum If a program ends the lifetime of an object of type \tcode{T} with -static~(\ref{basic.stc.static}), thread~(\ref{basic.stc.thread}), -or automatic~(\ref{basic.stc.auto}) +static\iref{basic.stc.static}, thread\iref{basic.stc.thread}, +or automatic\iref{basic.stc.auto} storage duration and if \tcode{T} has a non-trivial destructor,\footnote{That is, an object for which a destructor will be called implicitly---upon exit from the block for an object with @@ -3490,7 +3497,7 @@ \pnum In this section, ``before'' and ``after'' refer to the ``happens before'' -relation~(\ref{intro.multithread}). \begin{note} Therefore, undefined behavior results +relation\iref{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|)} @@ -3504,9 +3511,9 @@ impose requirements on implementations regarding the representation of types. There are two kinds of types: fundamental types and compound types. -Types describe objects (\ref{intro.object}), -references (\ref{dcl.ref}), -or functions (\ref{dcl.fct}). +Types describe objects\iref{intro.object}, +references\iref{dcl.ref}, +or functions\iref{dcl.fct}. \end{note} \pnum @@ -3514,13 +3521,13 @@ \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 +\tcode{T}, the underlying bytes\iref{intro.memory} making up the object can be copied into an array of \tcode{char}, \tcode{unsigned char}, or -\tcode{std::byte}~(\ref{cstddef.syn}).% +\tcode{std::byte}\iref{cstddef.syn}.% \footnote{By using, for example, the library -functions~(\ref{headers}) \tcode{std::memcpy} or \tcode{std::memmove}.} +functions\iref{headers} \tcode{std::memcpy} or \tcode{std::memmove}.} If the content of that array is copied back into the object, the object shall subsequently hold its original value. \begin{example} @@ -3537,9 +3544,9 @@ For any trivially copyable type \tcode{T}, if two pointers to \tcode{T} point to distinct \tcode{T} objects \tcode{obj1} and \tcode{obj2}, where neither \tcode{obj1} nor \tcode{obj2} is a base-class subobject, if the underlying -bytes~(\ref{intro.memory}) making up +bytes\iref{intro.memory} making up \tcode{obj1} are copied into \tcode{obj2},\footnote{By using, for example, -the library functions~(\ref{headers}) \tcode{std::memcpy} or \tcode{std::memmove}.} +the library functions\iref{headers} \tcode{std::memcpy} or \tcode{std::memmove}.} \tcode{obj2} shall subsequently hold the same value as \tcode{obj1}. \begin{example} @@ -3564,7 +3571,10 @@ \indextext{representation!value}% \defn{value representation} of an object is the set of bits that hold -the value of type \tcode{T}. For trivially copyable types, the value representation is +the value of type \tcode{T}. +Bits in the object representation that are not part of the value representation +are \defn{padding bits}. +For trivially copyable types, the value representation is a set of bits in the object representation that determines a \defn{value}, which is one discrete element of an \impldef{values of a trivially copyable type} set of values.\footnote{The @@ -3574,13 +3584,13 @@ \pnum \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 +contexts\iref{dcl.enum}, or an array of unknown 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 -\defnx{incomplete types}{type!incomplete}~(\ref{basic.fundamental}). +\defnx{incomplete types}{type!incomplete}\iref{basic.fundamental}. Objects shall not be defined to have an incomplete type. @@ -3636,26 +3646,26 @@ a function type, not a reference type, and not \cv{}~\tcode{void}. \pnum -Arithmetic types~(\ref{basic.fundamental}), enumeration types, pointer -types, pointer to member types~(\ref{basic.compound}), +Arithmetic types\iref{basic.fundamental}, enumeration types, pointer +types, pointer to member types\iref{basic.compound}, \tcode{std::nullptr_t}, and -cv-qualified~(\ref{basic.type.qualifier}) versions of these +cv-qualified\iref{basic.type.qualifier} versions of these types are collectively called \defnx{scalar types}{scalar type}. Scalar types, -POD classes (Clause~\ref{class}), arrays of such types and +POD classes\iref{class}, arrays of such types and cv-qualified versions of these types are collectively called \defnx{POD types}{type!POD}. -Cv-unqualified scalar types, trivially copyable class types (Clause~\ref{class}), arrays of +Cv-unqualified scalar types, trivially copyable class types\iref{class}, arrays of such types, and cv-qualified versions of these types are collectively called \defn{trivially copyable types}. -Scalar types, trivial class types (Clause~\ref{class}), +Scalar types, trivial class types\iref{class}, arrays of such types and cv-qualified versions of these types are collectively called \defn{trivial types}. Scalar types, standard-layout class -types (Clause~\ref{class}), arrays of such types and +types\iref{class}, arrays of such types and cv-qualified versions of these types are collectively called \defn{standard-layout types}. @@ -3666,14 +3676,14 @@ \item a scalar type; or \item a reference type; or \item an array of literal type; or -\item a possibly cv-qualified class type (Clause~\ref{class}) that +\item a possibly cv-qualified class type\iref{class} that has all of the following properties: \begin{itemize} \item it has a trivial destructor, -\item it is either a closure type~(\ref{expr.prim.lambda.closure}), -an aggregate type~(\ref{dcl.init.aggr}), or +\item it is either a closure type\iref{expr.prim.lambda.closure}, +an aggregate type\iref{dcl.init.aggr}, or has at least one constexpr constructor or constructor template -(possibly inherited~(\ref{namespace.udecl}) from a base class) +(possibly inherited\iref{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 of non-volatile literal type, and @@ -3695,8 +3705,8 @@ 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, -layout-compatible enumerations~(\ref{dcl.enum}), or -layout-compatible standard-layout class types~(\ref{class.mem}). +layout-compatible enumerations\iref{dcl.enum}, or +layout-compatible standard-layout class types\iref{class.mem}. \rSec2[basic.fundamental]{Fundamental types} @@ -3725,13 +3735,13 @@ \defnx{narrow character types}{type!narrow character}. A \tcode{char}, a \tcode{signed char}, and an \tcode{unsigned char} occupy the same amount of storage and have the -same alignment requirements~(\ref{basic.align}); that is, they have the +same alignment requirements\iref{basic.align}; that is, they have the same object representation. For narrow character types, all bits of the object representation participate in the value representation. \begin{note} A bit-field of narrow character type whose length is larger than the number of bits in the object representation of that type has -padding bits; see~\ref{class.bit}. +padding bits; see~\ref{basic.types}. \end{note} For unsigned narrow character types, each possible bit pattern of the value representation @@ -3742,7 +3752,7 @@ For each value \placeholder{i} of type \tcode{unsigned char} in the range 0 to 255 inclusive, there exists a value \placeholder{j} of type \tcode{char} such that the result of an integral -conversion~(\ref{conv.integral}) from \placeholder{i} to \tcode{char} is +conversion\iref{conv.integral} from \placeholder{i} to \tcode{char} is \placeholder{j}, and the result of an integral conversion from \placeholder{j} to \tcode{unsigned char} is \placeholder{i}. @@ -3790,7 +3800,7 @@ ``\tcode{unsigned int}'', ``\tcode{unsigned long int}'', and ``\tcode{unsigned long long int}'', each of which occupies the same amount of storage and has the same alignment -requirements~(\ref{basic.align}) as the corresponding signed integer +requirements\iref{basic.align} as the corresponding signed integer type\footnote{See~\ref{dcl.type.simple} regarding the correspondence between types and the sequences of \grammarterm{type-specifier}{s} that designate them.}; that is, each signed integer type has the same object representation as @@ -3838,9 +3848,9 @@ \indextext{type!underlying!\idxcode{char32_t}}% Type \tcode{wchar_t} is a distinct type whose values can represent distinct codes for all members of the largest extended character set -specified among the supported locales~(\ref{locale}). Type +specified among the supported locales\iref{locale}. Type \tcode{wchar_t} shall have the same size, signedness, and alignment -requirements~(\ref{basic.align}) as one of the other integral types, +requirements\iref{basic.align} as one of the other integral types, called its \defnx{underlying type}{type!underlying!\idxcode{wchar_t}}. Types \tcode{char16_t} and \tcode{char32_t} denote distinct types with the same size, signedness, and alignment as \tcode{uint_least16_t} and \tcode{uint_least32_t}, @@ -3855,13 +3865,13 @@ neither \tcode{true} nor \tcode{false}.} \begin{note} There are no \tcode{signed}, \tcode{unsigned}, \tcode{short}, or \tcode{long bool} types or values. \end{note} Values of type -\tcode{bool} participate in integral promotions~(\ref{conv.prom}). +\tcode{bool} participate in integral promotions\iref{conv.prom}. \pnum 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\iref{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 @@ -3904,7 +3914,7 @@ called \defnx{arithmetic}{type!arithmetic} types. \indextext{\idxcode{numeric_limits}!specializations for arithmetic types}% Specializations of the standard library template -\tcode{std::numeric_limits}~(\ref{support.limits}) shall specify the +\tcode{std::numeric_limits}\iref{support.limits} shall specify the maximum and minimum values of each arithmetic type for an implementation. @@ -3914,19 +3924,19 @@ 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}). +explicitly converted to type \cv{}~\tcode{void}\iref{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 +be used only as an expression statement\iref{stmt.expr}, as an operand +of a comma expression\iref{expr.comma}, as a second or third operand +of \tcode{?:}\iref{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 +the expression in a return statement\iref{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}. \pnum A value of type \tcode{std::nullptr_t} is a null pointer -constant~(\ref{conv.ptr}). Such values participate in the pointer and the +constant\iref{conv.ptr}. Such values participate in the pointer and the pointer to member conversions~(\ref{conv.ptr}, \ref{conv.mem}). \tcode{sizeof(std::nullptr_t)} shall be equal to \tcode{sizeof(void*)}. @@ -3942,45 +3952,45 @@ \indextext{type!compound}% Compound types can be constructed in the following ways: \begin{itemize} -\item \defnx{arrays}{type!array} of objects of a given type,~\ref{dcl.array}; +\item \defnx{arrays}{type!array} of objects of a given type, \ref{dcl.array}; \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}; +\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 -static members of classes) of a given type,~\ref{dcl.ptr}; +static members of classes) of a given type, \ref{dcl.ptr}; \item % \indextext{reference!lvalue}% \indextext{reference!rvalue}% \defnx{references}{reference} to objects or functions of a given -type,~\ref{dcl.ref}. There are two types of references: +type, \ref{dcl.ref}. There are two types of references: \begin{itemize} \item \defn{lvalue reference} \item \defn{rvalue reference} \end{itemize} \item -\defnx{classes}{class} containing a sequence of objects of various types -(Clause~\ref{class}), a set of types, enumerations and functions for -manipulating these objects~(\ref{class.mfct}), and a set of restrictions -on the access to these entities (Clause~\ref{class.access}); +\defnx{classes}{class} containing a sequence of objects of various types\iref{class}, +a set of types, enumerations and functions for +manipulating these objects\iref{class.mfct}, and a set of restrictions +on the access to these entities\iref{class.access}; \item \defnx{unions}{\idxcode{union}}, which are classes capable of containing objects of -different types at different times,~\ref{class.union}; +different types at different times, \ref{class.union}; \item \defnx{enumerations}{\idxcode{enum}}, which comprise a set of named constant values. Each distinct enumeration constitutes a different -\defnx{enumerated type}{type!enumerated},~\ref{dcl.enum}; +\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},% \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 -type within objects of a given class,~\ref{dcl.mptr}. +type within objects of a given class, \ref{dcl.mptr}. \end{itemize} \pnum @@ -3988,7 +3998,7 @@ restrictions are mentioned in~\ref{dcl.ptr}, \ref{dcl.array}, \ref{dcl.fct}, and~\ref{dcl.ref}. Constructing a type such that the number of bytes in its object representation exceeds the maximum value representable in -the type \tcode{std::size_t}~(\ref{support.types}) is ill-formed. +the type \tcode{std::size_t}\iref{support.types} is ill-formed. \pnum \indextext{terminology!pointer}% @@ -4004,16 +4014,16 @@ Except for pointers to static members, text referring to ``pointers'' does not apply to pointers to members. Pointers to incomplete types are allowed although there are restrictions on what can be done with -them~(\ref{basic.align}). +them\iref{basic.align}. \indextext{address}% Every value of pointer type is one of the following: \begin{itemize} \item a \defn{pointer to} an object or function (the pointer is said to \defn{point} to the object or function), or \item -a \defn{pointer past the end of} an object (\ref{expr.add}), or +a \defn{pointer past the end of} an object\iref{expr.add}, or \item -the \defn{null pointer value} (\ref{conv.ptr}) for that type, or +the \defn{null pointer value}\iref{conv.ptr} for that type, or \item an \defn{invalid pointer value}. \end{itemize} @@ -4021,14 +4031,14 @@ pointer type that is a pointer to or past the end of an object \defn{represents the address} of -the first byte in memory~(\ref{intro.memory}) occupied by the object% +the first byte in memory\iref{intro.memory} occupied by the object% \footnote{For an object that is not within its lifetime, this is the first byte in memory that it will occupy or used to occupy.} or the first byte in memory after the end of the storage occupied by the object, respectively. \begin{note} -A pointer past the end of an object~(\ref{expr.add}) +A pointer past the end of an object\iref{expr.add} is not considered to point to an unrelated object of the object's type that might be located at that address. @@ -4037,7 +4047,7 @@ reaches the end of its storage duration; see \ref{basic.stc}. \end{note} -For purposes of pointer arithmetic~(\ref{expr.add}) +For purposes of pointer arithmetic\iref{expr.add} and comparison~(\ref{expr.rel}, \ref{expr.eq}), a pointer past the end of the last element of an array \tcode{x} of $n$ elements @@ -4047,8 +4057,8 @@ pointer types is \impldef{value representation of pointer types}. Pointers to layout-compatible types shall have the same value representation and alignment -requirements~(\ref{basic.align}). -\begin{note} Pointers to over-aligned types~(\ref{basic.align}) have no special +requirements\iref{basic.align}. +\begin{note} Pointers to over-aligned types\iref{basic.align} have no special representation, but their range of valid values is restricted by the extended alignment requirement.\end{note} @@ -4058,13 +4068,13 @@ \item they are the same object, or \item -one is a standard-layout union object and -the other is a non-static data member of that object~(\ref{class.union}), or +one is a union object and +the other is a non-static data member of that object\iref{class.union}, or \item one is a standard-layout class object and the other is the first non-static data member of that object, or, if the object has no non-static data members, -the first base class subobject of that object~(\ref{class.mem}), or +the first base class subobject of that object\iref{class.mem}, or \item there exists an object \placeholder{c} such that \placeholder{a} and \placeholder{c} are pointer-interconvertible, and @@ -4074,7 +4084,7 @@ then they have the same address, and it is possible to obtain a pointer to one from a pointer to the other -via a \tcode{reinterpret_cast}~(\ref{expr.reinterpret.cast}). +via a \tcode{reinterpret_cast}\iref{expr.reinterpret.cast}. \begin{note} An array object and its first element are not pointer-interconvertible, even though they have the same address. @@ -4083,7 +4093,7 @@ \pnum \indextext{pointer|seealso{\tcode{void*}}}% \indextext{\idxcode{void*}!type}% -A pointer to \cv-qualified~(\ref{basic.type.qualifier}) or \cv-unqualified +A pointer to \cv-qualified\iref{basic.type.qualifier} or \cv-unqualified \tcode{void} can be used to point to objects of unknown type. Such a pointer shall be able to hold any object pointer. @@ -4100,15 +4110,15 @@ A type mentioned in~\ref{basic.fundamental} and~\ref{basic.compound} is a \defnx{cv-unqualified type}{type!cv-unqualified}. Each type which is a cv-unqualified complete or incomplete object type or is -\tcode{void}~(\ref{basic.types}) has three corresponding cv-qualified +\tcode{void}\iref{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 -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 -\grammarterm{new-type-id}~(\ref{expr.new}) when the object is created. +type of an object\iref{intro.object} includes the \grammarterm{cv-qualifier}{s} +specified in the \grammarterm{decl-specifier-seq}\iref{dcl.spec}, +\grammarterm{declarator}\iref{dcl.decl}, +\grammarterm{type-id}\iref{dcl.name}, or +\grammarterm{new-type-id}\iref{expr.new} when the object is created. \begin{itemize} \item A \defnx{const object}{object!const} is an object of type \tcode{const T} or a non-mutable subobject of such an object. @@ -4125,17 +4135,17 @@ The cv-qualified or cv-unqualified versions of a type are distinct types; however, they shall have the same representation and -alignment requirements~(\ref{basic.align}).\footnote{The same representation +alignment requirements\iref{basic.align}.\footnote{The same representation and alignment requirements are meant to imply interchangeability as arguments to functions, return values from functions, and non-static data members of unions.} \pnum \indextext{array!\idxcode{const}}% -A compound type~(\ref{basic.compound}) is not cv-qualified by the +A compound type\iref{basic.compound} is not cv-qualified by the cv-qualifiers (if any) of the types from which it is compounded. Any cv-qualifiers applied to an array type -affect the array element type~(\ref{dcl.array}). +affect the array element type\iref{dcl.array}. \pnum See~\ref{dcl.fct} and~\ref{class.this} regarding function @@ -4215,7 +4225,7 @@ as specified by the context in which it appears. \item An \defn{xvalue} is a glvalue that denotes an object or bit-field whose resources can be reused (usually because it is near the end of its lifetime). \begin{example} -Certain kinds of expressions involving rvalue references~(\ref{dcl.ref}) yield xvalues, +Certain kinds of expressions involving rvalue references\iref{dcl.ref} yield xvalues, such as a call to a function whose return type is an rvalue reference or a cast to an rvalue reference type. \end{example} @@ -4234,7 +4244,7 @@ Every expression belongs to exactly one of the fundamental classifications in this taxonomy: lvalue, xvalue, or prvalue. This property of an expression is called its \defn{value category}. \begin{note} The discussion of each built-in operator in -Clause~\ref{expr} indicates the category of the value it yields and the value categories +\ref{expr} indicates the category of the value it yields and the value categories of the operands it expects. For example, the built-in assignment operators expect that the left operand is an lvalue and that the right operand is a prvalue and yield an lvalue as the result. User-defined operators are functions, and the categories of @@ -4254,7 +4264,7 @@ \begin{note} Except when the prvalue is the operand of a \grammarterm{decltype-specifier}, a prvalue of class or array type always has a result object. -For a discarded prvalue, a temporary object is materialized; see Clause~\ref{expr}. +For a discarded prvalue, a temporary object is materialized; see \ref{expr}. \end{note} The \defnx{result}{result!glvalue} of a glvalue is the entity denoted by the expression. @@ -4267,8 +4277,8 @@ \end{note} \begin{note} There are no prvalue bit-fields; if a bit-field is converted to a -prvalue~(\ref{conv.lval}), a prvalue of the type of the bit-field is -created, which might then be promoted~(\ref{conv.prom}). +prvalue\iref{conv.lval}, a prvalue of the type of the bit-field is +created, which might then be promoted\iref{conv.prom}. \end{note} \pnum @@ -4283,13 +4293,13 @@ and rvalues in other significant contexts. \pnum -Unless otherwise indicated~(\ref{expr.call}), +Unless otherwise indicated\iref{expr.call}, a prvalue shall always have complete type or the \tcode{void} type. 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 -always have cv-unqualified types. See Clause~\ref{expr}. +always have cv-unqualified types. See \ref{expr}. \end{note} \pnum @@ -4333,20 +4343,20 @@ \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 at which a given object can be allocated. An object type imposes an alignment requirement on every object of that type; stricter alignment can be requested -using the alignment specifier~(\ref{dcl.align}). +using the alignment specifier\iref{dcl.align}. \pnum \indextext{alignment!fundamental}% 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}). +\tcode{alignof(std::max_align_t)}\iref{support.types}. The alignment required for a type might be different when it is used as the type of a complete object and when it is used as the type of a subobject. \begin{example} \begin{codeblock} @@ -4369,13 +4379,13 @@ 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 +supported\iref{dcl.align}. A type having an extended alignment requirement is an \defnx{over-aligned type}{type!over-aligned}. \begin{note} 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 -an alignment greater than \mname{STDCPP_DEFAULT_NEW_ALIGNMENT}~(\ref{cpp.predefined}). +an alignment greater than \mname{STDCPP_DEFAULT_NEW_ALIGNMENT}\iref{cpp.predefined}. \pnum Alignments are represented as values of the type \tcode{std::size_t}. @@ -4393,11 +4403,11 @@ \pnum The alignment requirement of a complete type can be queried using an -\tcode{alignof} expression~(\ref{expr.alignof}). Furthermore, -the narrow character types~(\ref{basic.fundamental}) shall have the weakest +\tcode{alignof} expression\iref{expr.alignof}. Furthermore, +the narrow character types\iref{basic.fundamental} shall have the weakest alignment requirement. \begin{note} This enables the narrow character types to be used as the -underlying type for an aligned memory area~(\ref{dcl.align}).\end{note} +underlying type for an aligned memory area\iref{dcl.align}.\end{note} \pnum Comparing alignments is meaningful and provides the obvious results: @@ -4409,9 +4419,9 @@ \end{itemize} \pnum -\begin{note} The runtime pointer alignment function~(\ref{ptr.align}) +\begin{note} The runtime pointer alignment function\iref{ptr.align} can be used to obtain an aligned pointer within a buffer; the aligned-storage templates -in the library~(\ref{meta.trans.other}) can be used to obtain aligned storage. +in the library\iref{meta.trans.other} can be used to obtain aligned storage. \end{note} \pnum diff --git a/source/classes.tex b/source/classes.tex index ab1b59fc24..710c95bb5c 100644 --- a/source/classes.tex +++ b/source/classes.tex @@ -13,7 +13,7 @@ \indextext{object class|seealso{class object}}% A class is a type. \indextext{name class|see{class name}}% -Its name becomes a \grammarterm{class-name}~(\ref{class.name}) within its +Its name becomes a \grammarterm{class-name}\iref{class.name} within its scope. \begin{bnf} @@ -23,7 +23,7 @@ \end{bnf} \grammarterm{Class-specifier}{s} and -\grammarterm{elaborated-type-specifier}{s}~(\ref{dcl.type.elab}) are used to +\grammarterm{elaborated-type-specifier}{s}\iref{dcl.type.elab} are used to make \grammarterm{class-name}{s}. An object of a class consists of a (possibly empty) sequence of members and base class objects. @@ -64,8 +64,7 @@ A \grammarterm{class-name} is inserted into the scope in which it is declared immediately after the \grammarterm{class-name} is seen. The \grammarterm{class-name} is also inserted into the scope of the class -itself; this is known as the \grammarterm{injected-class-name}. -\indextext{\idxgram{injected-class-name}}% +itself; this is known as the \defn{injected-class-name}. For purposes of access checking, the injected-class-name is treated as if it were a public member name. \indextext{definition!class}% @@ -81,8 +80,8 @@ \pnum If a class is marked with the \grammarterm{class-virt-specifier} \tcode{final} and it appears -as a \grammarterm{class-or-decltype} in a \grammarterm{base-clause} -(Clause~\ref{class.derived}), the program is ill-formed. Whenever a +as a \grammarterm{class-or-decltype} in a \grammarterm{base-clause}\iref{class.derived}, +the program is ill-formed. Whenever a \grammarterm{class-key} is followed by a \grammarterm{class-head-name}, the \grammarterm{identifier} \tcode{final}, and a colon or left brace, \tcode{final} is interpreted as a \grammarterm{class-virt-specifier}. \begin{example} @@ -116,7 +115,7 @@ A \term{union} is a class defined with the \grammarterm{class-key} \tcode{union}; \indextext{access control!\idxcode{union} default member}% -it holds at most one data member at a time~(\ref{class.union}). +it holds at most one data member at a time\iref{class.union}. \begin{note} Aggregates of class type are described in~\ref{dcl.init.aggr}. \end{note} @@ -133,11 +132,11 @@ is either deleted or trivial, \item that has at least one non-deleted copy constructor, move constructor, copy assignment operator, or move assignment operator, and -\item that has a trivial, non-deleted destructor~(\ref{class.dtor}). +\item that has a trivial, non-deleted destructor\iref{class.dtor}. \end{itemize} A \term{trivial class} is a class that is trivially copyable and -has one or more default constructors~(\ref{class.ctor}), +has one or more default constructors\iref{class.ctor}, all of which are either trivial or deleted and at least one of which is not deleted. \begin{note} In particular, a trivially copyable or trivial class does not have @@ -150,10 +149,10 @@ \item has no non-static data members of type non-standard-layout class (or array of such types) or reference, -\item has no virtual functions~(\ref{class.virtual}) and no -virtual base classes~(\ref{class.mi}), +\item has no virtual functions\iref{class.virtual} and no +virtual base classes\iref{class.mi}, -\item has the same access control (Clause~\ref{class.access}) +\item has the same access control\iref{class.access} for all non-static data members, \item has no non-standard-layout base classes, @@ -167,13 +166,13 @@ as a base class.\footnote{This ensures that two subobjects that have the same class type and that belong to the same most derived object are not allocated at the same -address~(\ref{expr.eq}).} +address\iref{expr.eq}.} \end{itemize} $M(\mathtt{X})$ is defined as follows: \begin{itemize} \item If \tcode{X} is a non-union class type with no (possibly -inherited (Clause~\ref{class.derived})) non-static data members, the set +inherited\iref{class.derived}) non-static data members, the set $M(\mathtt{X})$ is empty. \item If \tcode{X} is a non-union class type whose first non-static data @@ -269,7 +268,7 @@ the \grammarterm{class-specifier} shall refer to a class that was previously declared directly in the class or namespace to which the \grammarterm{nested-name-specifier} refers, -or in an element of the inline namespace set~(\ref{namespace.def}) of that namespace +or in an element of the inline namespace set\iref{namespace.def} of that namespace (i.e., not merely inherited or introduced by a \grammarterm{using-declaration}), and the \grammarterm{class-specifier} shall appear in a namespace enclosing the @@ -310,7 +309,7 @@ \end{codeblock} \indextext{overloading}% -declare an overloaded (Clause~\ref{over}) function \tcode{f()} and not +declare an overloaded\iref{over} function \tcode{f()} and not simply a single function \tcode{f()} twice. For the same reason, \begin{codeblock} @@ -328,11 +327,11 @@ \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 +enclosing scope\iref{basic.scope}. If a class name is declared in a scope where a variable, function, or enumerator of the same name is also declared, then when both declarations are in scope, the class can be referred to only using an -\grammarterm{elaborated-type-specifier}~(\ref{basic.lookup.elab}). +\grammarterm{elaborated-type-specifier}\iref{basic.lookup.elab}. \begin{example} \begin{codeblock} struct stat { @@ -393,7 +392,7 @@ \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 +An \grammarterm{elaborated-type-specifier}\iref{dcl.type.elab} can also be used as a \grammarterm{type-specifier} as part of a declaration. It differs from a class declaration in that if a class of the elaborated name is in scope the elaborated name will refer to it. @@ -429,7 +428,7 @@ \pnum \indextext{class name!\idxcode{typedef}}% -A \grammarterm{typedef-name}~(\ref{dcl.typedef}) that names a class type, +A \grammarterm{typedef-name}\iref{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 where a \grammarterm{class-name} is required, the cv-qualifiers are @@ -467,8 +466,9 @@ \begin{bnf} \nontermdef{member-declarator}\br declarator virt-specifier-seq\opt pure-specifier\opt\br + declarator requires-clause\br declarator brace-or-equal-initializer\opt\br - identifier\opt attribute-specifier-seq\opt{} \terminal{:} constant-expression + identifier\opt{} attribute-specifier-seq\opt{} \terminal{:} constant-expression brace-or-equal-initializer\opt{} \end{bnf} \begin{bnf} @@ -494,10 +494,10 @@ full set of members of the class; no member can be added elsewhere. A \defn{direct member} of a class \tcode{X} is a member of \tcode{X} that was first declared within the \grammarterm{member-specification} of \tcode{X}, -including anonymous union objects~(\ref{class.union.anon}) and direct members thereof. +including anonymous union objects\iref{class.union.anon} and direct members thereof. Members of a class are data members, member -functions~(\ref{class.mfct}), nested types, enumerators, -and member templates~(\ref{temp.mem}) and specializations thereof. +functions\iref{class.mfct}, nested types, enumerators, +and member templates\iref{temp.mem} and specializations thereof. \begin{note} A specialization of a static data member template is a static data member. A specialization of a member function template is a member function. @@ -508,14 +508,14 @@ A \grammarterm{member-declaration} does not declare new members of the class if it is \begin{itemize} -\item a friend declaration~(\ref{class.friend}), +\item a friend declaration\iref{class.friend}, \item a \grammarterm{static_assert-declaration}, -\item a \grammarterm{using-declaration}~(\ref{namespace.udecl}), or +\item a \grammarterm{using-declaration}\iref{namespace.udecl}, or \item an \grammarterm{empty-declaration}. \end{itemize} For any other \grammarterm{member-declaration}, each declared entity -that is not an unnamed bit-field~(\ref{class.bit}) +that is not an unnamed bit-field\iref{class.bit} is a member of the class, and each such \grammarterm{member-declaration} shall either @@ -526,11 +526,11 @@ A \defn{data member} is a non-function member introduced by a \grammarterm{member-declarator}. A \defn{member function} is a member that is a function. -Nested types are classes~(\ref{class.name},~\ref{class.nest}) and -enumerations~(\ref{dcl.enum}) declared in the class and arbitrary types -declared as members by use of a typedef declaration~(\ref{dcl.typedef}) +Nested types are classes~(\ref{class.name}, \ref{class.nest}) and +enumerations\iref{dcl.enum} declared in the class and arbitrary types +declared as members by use of a typedef declaration\iref{dcl.typedef} or \grammarterm{alias-declaration}. -The enumerators of an unscoped enumeration~(\ref{dcl.enum}) defined in the class +The enumerators of an unscoped enumeration\iref{dcl.enum} defined in the class are members of the class. \indextext{member!static}% @@ -540,14 +540,14 @@ A data member or member function may be declared \tcode{static} in its \grammarterm{member-declaration}, in which case it is a \defn{static member} (see~\ref{class.static}) -(a \defn{static data member}~(\ref{class.static.data}) or -\defn{static member function}~(\ref{class.static.mfct}), respectively) +(a \defn{static data member}\iref{class.static.data} or +\defn{static member function}\iref{class.static.mfct}, respectively) of the class. Any other data member or member function is a \defn{non-static member} (a \defn{non-static data member} or \defn{non-static member function}~(\ref{class.mfct.non-static}), respectively). \begin{note} A non-static data member of non-reference -type is a member subobject of a class object~(\ref{intro.object}).\end{note} +type is a member subobject of a class object\iref{intro.object}.\end{note} \pnum A member shall not be declared twice in the @@ -561,13 +561,13 @@ \end{itemize} \begin{note} A single name can denote several member functions provided their types -are sufficiently different (Clause~\ref{over}). +are sufficiently different\iref{over}. \end{note} \pnum \indextext{completely defined}% A class is considered a completely-defined object -type~(\ref{basic.types}) (or complete type) at the closing \tcode{\}} of +type\iref{basic.types} (or complete type) at the closing \tcode{\}} of the \grammarterm{class-specifier}. Within the class \grammarterm{member-specification}, the class is regarded as complete @@ -595,6 +595,26 @@ \end{codeblock} \end{example} +\pnum +In a \grammarterm{member-declarator} for a bit-field, +the \grammarterm{constant-expression} is parsed as +the longest sequence of tokens +that could syntactically form a \grammarterm{constant-expression}. +\begin{example} +\begin{codeblock} +int a; +const int b = 0; +struct S { + int x1 : 8 = 42; // OK, \tcode{"= 42"} is \grammarterm{brace-or-equal-initializer} + int x2 : 8 { 42 }; // OK, \tcode{"\{ 42 \}"} is \grammarterm{brace-or-equal-initializer} + int y1 : true ? 8 : a = 42; // OK, \grammarterm{brace-or-equal-initializer} is absent + int y2 : true ? 8 : b = 42; // error: cannot assign to \tcode{const int} + int y3 : (true ? 8 : b) = 42; // OK, \tcode{"= 42"} is \grammarterm{brace-or-equal-initializer} + int z : 1 || new int { 0 }; // OK, \grammarterm{brace-or-equal-initializer} is absent +}; +\end{codeblock} +\end{example} + \pnum A \grammarterm{brace-or-equal-initializer} shall appear only in the declaration of a data member. (For static data members, @@ -619,9 +639,9 @@ The \grammarterm{member-declarator-list} can be omitted only after a \grammarterm{class-specifier} or an \grammarterm{enum-specifier} or in a -\tcode{friend} declaration~(\ref{class.friend}). A +\tcode{friend} declaration\iref{class.friend}. A \grammarterm{pure-specifier} shall be used only in the declaration of a -virtual function~(\ref{class.virtual}) +virtual function\iref{class.virtual} that is not a \tcode{friend} declaration. \pnum @@ -634,7 +654,7 @@ \grammarterm{virt-specifier}. A \grammarterm{virt-specifier-seq} shall appear only in the declaration of a virtual member -function~(\ref{class.virtual}). +function\iref{class.virtual}. \pnum \indextext{class object!member}% @@ -689,17 +709,17 @@ \pnum \indextext{layout!class object}% Non-static data members of a (non-union) class -with the same access control (Clause~\ref{class.access}) +with the same access control\iref{class.access} are allocated so that later members have higher addresses within a class object. \indextext{allocation!unspecified}% The order of allocation of non-static data members with different access control -is unspecified (Clause~\ref{class.access}). +is unspecified\iref{class.access}. Implementation alignment requirements might cause two adjacent members not to be allocated immediately after each other; so might requirements -for space for managing virtual functions~(\ref{class.virtual}) and -virtual base classes~(\ref{class.mi}). +for space for managing virtual functions\iref{class.virtual} and +virtual base classes\iref{class.mi}. \pnum If \tcode{T} is the name of a class, then each of the following shall @@ -711,7 +731,7 @@ \item every member function of class \tcode{T} \begin{note} This restriction does not apply to constructors, which do not have -names~(\ref{class.ctor}) +names\iref{class.ctor} \end{note}; \item every member of class \tcode{T} that is itself a type; @@ -727,11 +747,11 @@ \pnum In addition, if class \tcode{T} has a user-declared -constructor~(\ref{class.ctor}), every non-static data member of class +constructor\iref{class.ctor}, every non-static data member of class \tcode{T} shall have a name different from \tcode{T}. \pnum -The \defn{common initial sequence} of two standard-layout struct (Clause~\ref{class}) +The \defn{common initial sequence} of two standard-layout struct\iref{class} types is the longest sequence of non-static data members and bit-fields in declaration order, starting with the first such entity in each of the structs, such that corresponding entities @@ -752,19 +772,19 @@ \end{example} \pnum -Two standard-layout struct (Clause~\ref{class}) types are +Two standard-layout struct\iref{class} types are \defnx{layout-compatible classes}{layout-compatible!class} if their common initial sequence comprises all members and bit-fields of -both classes~(\ref{basic.types}). +both classes\iref{basic.types}. \pnum Two standard-layout unions are layout-compatible if they have the same number of non-static data members and corresponding non-static data members (in any order) have layout-compatible -types~(\ref{basic.types}). +types\iref{basic.types}. \pnum -In a standard-layout union with an active member~(\ref{class.union}) +In a standard-layout union with an active member\iref{class.union} of struct type \tcode{T1}, it is permitted to read a non-static data member \tcode{m} of another union member of struct type \tcode{T2} provided \tcode{m} is part of the common initial sequence of \tcode{T1} and \tcode{T2}; @@ -782,7 +802,7 @@ \end{example} \begin{note} Reading a volatile object through a non-volatile glvalue has -undefined behavior (\ref{dcl.type.cv}). +undefined behavior\iref{dcl.type.cv}. \end{note} \pnum @@ -804,16 +824,16 @@ \pnum \indextext{member function!inline}% \indextext{definition!member function}% -A member function may be defined~(\ref{dcl.fct.def}) in its class +A member function may be defined\iref{dcl.fct.def} in its class definition, in which case it is an \term{inline} member -function~(\ref{dcl.inline}), or it may be defined outside of its class +function\iref{dcl.inline}, or it may be defined outside of its class definition if it has already been declared but not defined in its class definition. A member function definition that appears outside of the class definition shall appear in a namespace scope enclosing the class definition. Except for member function definitions that appear outside of a class definition, and except for explicit specializations of member functions of class templates and member function -templates~(\ref{temp.spec}) appearing outside of the class definition, a +templates\iref{temp.spec} appearing outside of the class definition, a member function shall not be redeclared. \pnum @@ -823,7 +843,7 @@ class definition declares the function as \tcode{inline} or \tcode{constexpr}. \begin{note} Member functions of a class in namespace scope have the linkage of that class. -Member functions of a local class~(\ref{class.local}) have no linkage. +Member functions of a local class\iref{class.local} have no linkage. See~\ref{basic.link}. \end{note} @@ -843,7 +863,7 @@ \begin{note} A name used in a member function definition (that is, in the \grammarterm{parameter-declaration-clause} including the default -arguments~(\ref{dcl.fct.default}) or in the member function body) is looked up +arguments\iref{dcl.fct.default} or in the member function body) is looked up as described in~\ref{basic.lookup}. \end{note} \begin{example} @@ -908,11 +928,11 @@ \pnum A non-static member function may be called for an object of -its class type, or for an object of a class derived -(Clause~\ref{class.derived}) from its class type, using the class member -access syntax~(\ref{expr.ref},~\ref{over.match.call}). A non-static +its class type, or for an object of a class derived\iref{class.derived} +from its class type, using the class member +access syntax~(\ref{expr.ref}, \ref{over.match.call}). A non-static member function may also be called directly using the function call -syntax~(\ref{expr.call},~\ref{over.match.call}) from within +syntax~(\ref{expr.call}, \ref{over.match.call}) from within the body of a member function of its class or of a class derived from its class. @@ -923,34 +943,34 @@ \tcode{X}, the behavior is undefined. \pnum -When an \grammarterm{id-expression}~(\ref{expr.prim}) that is not part of a -class member access syntax~(\ref{expr.ref}) and not used to form a -pointer to member~(\ref{expr.unary.op}) is used in +When an \grammarterm{id-expression}\iref{expr.prim} that is not part of a +class member access syntax\iref{expr.ref} and not used to form a +pointer to member\iref{expr.unary.op} is used in a member of class \tcode{X} in a context where \tcode{this} can be -used~(\ref{expr.prim.this}), +used\iref{expr.prim.this}, if name -lookup~(\ref{basic.lookup}) resolves the name in the +lookup\iref{basic.lookup} resolves the name in the \grammarterm{id-expression} to a non-static non-type member of some class \tcode{C}, and if either the \grammarterm{id-expression} is potentially evaluated or \tcode{C} is \tcode{X} or a base class of \tcode{X}, the \grammarterm{id-expression} is transformed into a class -member access expression~(\ref{expr.ref}) using -\tcode{(*this)}~(\ref{class.this}) as the \grammarterm{postfix-expression} +member access expression\iref{expr.ref} using +\tcode{(*this)}\iref{class.this} as the \grammarterm{postfix-expression} to the left of the \tcode{.} operator. \begin{note} If \tcode{C} is not \tcode{X} or a base class of \tcode{X}, the class member access expression is ill-formed. \end{note} Similarly during name lookup, when an -\grammarterm{unqualified-id}~(\ref{expr.prim}) used in the definition of a +\grammarterm{unqualified-id}\iref{expr.prim} used in the definition of a member function for class \tcode{X} resolves to a static member, an enumerator or a nested type of class \tcode{X} or of a base class of \tcode{X}, the \grammarterm{unqualified-id} is transformed into a -\grammarterm{qualified-id}~(\ref{expr.prim}) in which the +\grammarterm{qualified-id}\iref{expr.prim} in which the \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}). +template definition context\iref{temp.dep.type}. \indextext{example!member function}% \begin{example} @@ -985,19 +1005,22 @@ \tcode{n1.tword}, and in the call \tcode{n2.set("def",0,0)}, it refers to \tcode{n2.tword}. The functions \tcode{strlen}, \tcode{perror}, and \tcode{strcpy} are not members of the class \tcode{tnode} and should be -declared elsewhere.\footnote{See, for example, \tcode{}~(\ref{c.strings}).} +declared elsewhere.\footnote{See, for example, \tcode{}\iref{c.strings}.} \end{example} \pnum +\indextext{member function!const}% +\indextext{member function!volatile}% +\indextext{member function!const volatile}% A non-static member function may be declared \tcode{const}, \tcode{volatile}, or \tcode{const} \tcode{volatile}. These \grammarterm{cv-qualifier}{s} affect the type of the \tcode{this} -pointer~(\ref{class.this}). They also affect the function -type~(\ref{dcl.fct}) of the member function; a member function declared -\tcode{const} is a \term{const} member function, a member function -declared \tcode{volatile} is a \term{volatile} member function and a +pointer\iref{class.this}. They also affect the function +type\iref{dcl.fct} of the member function; a member function declared +\tcode{const} is a \defn{const member function}, a member function +declared \tcode{volatile} is a \defn{volatile member function} and a member function declared \tcode{const} \tcode{volatile} is a -\term{const volatile} member function. +\defn{const volatile member function}. \begin{example} \begin{codeblock} @@ -1007,16 +1030,16 @@ }; \end{codeblock} -\tcode{X::g} is a \tcode{const} member function and \tcode{X::h} is a -\tcode{const} \tcode{volatile} member function. +\tcode{X::g} is a const member function and \tcode{X::h} is a +const volatile member function. \end{example} \pnum -A non-static member function may be declared with a \grammarterm{ref-qualifier}~(\ref{dcl.fct}); see~\ref{over.match.funcs}. +A non-static member function may be declared with a \grammarterm{ref-qualifier}\iref{dcl.fct}; see~\ref{over.match.funcs}. \pnum A non-static member function may be declared -\term{virtual}~(\ref{class.virtual}) or \term{pure virtual}~(\ref{class.abstract}). +\term{virtual}\iref{class.virtual} or \term{pure virtual}\iref{class.abstract}. \rSec3[class.this]{The \tcode{this} pointer}% \indextext{\idxcode{this}} @@ -1024,23 +1047,20 @@ \pnum \indextext{this pointer@\tcode{this} pointer|see{\tcode{this}}}% -In the body of a non-static~(\ref{class.mfct}) member function, the +In the body of a non-static\iref{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}% The type of \tcode{this} in a member function of a class \tcode{X} is \tcode{X*}. -\indextext{member function!\idxcode{const}}% If the member function is declared \tcode{const}, the type of \tcode{this} is \tcode{const} \tcode{X*}, -\indextext{member function!\idxcode{volatile}}% if the member function is declared \tcode{volatile}, the type of \tcode{this} is \tcode{volatile} \tcode{X*}, and if the member function 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 -called is accessed through a \tcode{const} access path. \end{note} +\begin{note} Thus in a const member function, the object for which the function is +called is accessed through a const access path. \end{note} \begin{example} \begin{codeblock} @@ -1056,19 +1076,19 @@ The \tcode{a++} in the body of \tcode{s::h} is ill-formed because it tries to modify (a part of) the object for which \tcode{s::h()} is -called. This is not allowed in a \tcode{const} member function because +called. This is not allowed in a const member function because \tcode{this} is a pointer to \tcode{const}; that is, \tcode{*this} has \tcode{const} type. \end{example} \pnum -Similarly, \tcode{volatile} semantics~(\ref{dcl.type.cv}) apply in -\tcode{volatile} member functions when accessing the object and its +Similarly, \tcode{volatile} semantics\iref{dcl.type.cv} apply in +volatile member functions when accessing the object and its non-static data members. \pnum A cv-qualified member function can be called on an -object-expression~(\ref{expr.ref}) only if the object-expression is as +object-expression\iref{expr.ref} only if the object-expression is as cv-qualified or less-cv-qualified than the member function. \begin{example} @@ -1082,7 +1102,7 @@ \end{codeblock} The call \tcode{y.g()} is ill-formed because \tcode{y} is \tcode{const} -and \tcode{s::g()} is a non-\tcode{const} member function, that is, +and \tcode{s::g()} is a non-const member function, that is, \tcode{s::g()} is less-qualified than the object-expression \tcode{y}. \end{example} @@ -1091,7 +1111,7 @@ \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 +Constructors\iref{class.ctor} and destructors\iref{class.dtor} shall not be declared \tcode{const}, \tcode{volatile} or \tcode{const} \tcode{volatile}. \begin{note} However, these functions can be invoked to create and destroy objects with cv-qualified types, @@ -1104,7 +1124,7 @@ \pnum A static member \tcode{s} of class \tcode{X} may be referred to using the \grammarterm{qualified-id} expression \tcode{X::s}; it is not -necessary to use the class member access syntax~(\ref{expr.ref}) to +necessary to use the class member access syntax\iref{expr.ref} to refer to a static member. A static member may be referred to using the class member access syntax, in which case the object expression is evaluated. @@ -1125,7 +1145,7 @@ \pnum A static member may be referred to directly in the scope of its -class or in the scope of a class derived (Clause~\ref{class.derived}) +class or in the scope of a class derived\iref{class.derived} from its class; in this case, the static member is referred to as if a \grammarterm{qualified-id} expression was used, with the \grammarterm{nested-name-specifier} of the \grammarterm{qualified-id} naming @@ -1145,9 +1165,9 @@ \end{example} \pnum -If an \grammarterm{unqualified-id}~(\ref{expr.prim}) is used in the +If an \grammarterm{unqualified-id}\iref{expr.prim} is used in the definition of a static member following the member's -\grammarterm{declarator-id}, and name lookup~(\ref{basic.lookup.unqual}) +\grammarterm{declarator-id}, and name lookup\iref{basic.lookup.unqual} finds that the \grammarterm{unqualified-id} refers to a static member, enumerator, or nested type of the member's class (or of a base class of the member's class), the \grammarterm{unqualified-id} is @@ -1161,8 +1181,8 @@ \pnum -Static members obey the usual class member access rules -(Clause~\ref{class.access}). When used in the declaration of a class +Static members obey the usual class member access rules\iref{class.access}. +When used in the declaration of a class member, the \tcode{static} specifier shall only be used in the member declarations that appear within the \grammarterm{member-specification} of the class definition. @@ -1182,11 +1202,11 @@ \pnum \begin{note} A static member function does not have a \tcode{this} -pointer~(\ref{class.this}). +pointer\iref{class.this}. \end{note} A static member function shall not be \tcode{virtual}. There shall not be a static and a non-static member function with the -same name and the same parameter types~(\ref{over.load}). A +same name and the same parameter types\iref{over.load}. A static member function shall not be declared \tcode{const}, \tcode{volatile}, or \tcode{const volatile}. @@ -1215,7 +1235,7 @@ data member shall be qualified by its class name using the \tcode{::} operator. The \grammarterm{initializer} expression in the definition of a static data member is in the scope of its -class~(\ref{basic.scope.class}). +class\iref{basic.scope.class}. \indextext{example!static member}% \begin{example} @@ -1253,9 +1273,9 @@ its declaration in the class definition can specify a \grammarterm{brace-or-equal-initializer} in which every \grammarterm{initializer-clause} that is an \grammarterm{assignment-expression} -is a constant expression~(\ref{expr.const}). +is a constant expression\iref{expr.const}. The member shall still be defined in a namespace scope if -it is odr-used~(\ref{basic.def.odr}) in the program and the +it is odr-used\iref{basic.def.odr} in the program and the namespace scope definition shall not contain an \grammarterm{initializer}. An inline static data member may be defined in the class definition and may specify a \grammarterm{brace-or-equal-initializer}. If the @@ -1267,7 +1287,7 @@ \pnum \begin{note} There shall be exactly one definition of a static data member -that is odr-used~(\ref{basic.def.odr}) in a program; no diagnostic is required. +that is odr-used\iref{basic.def.odr} in a program; no diagnostic is required. \end{note} Unnamed classes and classes contained directly or indirectly within unnamed classes shall not contain static @@ -1275,7 +1295,7 @@ \pnum \begin{note} -Static data members of a class in namespace scope have the linkage of that class~(\ref{basic.link}). A local class cannot have static data members~(\ref{class.local}). +Static data members of a class in namespace scope have the linkage of that class\iref{basic.link}. A local class cannot have static data members\iref{class.local}. \end{note} \pnum @@ -1285,7 +1305,7 @@ \pnum A static data member shall not be -\tcode{mutable}~(\ref{dcl.stc}). +\tcode{mutable}\iref{dcl.stc}. \rSec2[class.bit]{Bit-fields}% \indextext{bit-field} @@ -1294,7 +1314,7 @@ A \grammarterm{member-declarator} of the form \begin{ncbnftab} -identifier\opt attribute-specifier-seq\opt{} \terminal{:} constant-expression +identifier\opt{} attribute-specifier-seq\opt{} \terminal{:} constant-expression brace-or-equal-initializer\opt{} \end{ncbnftab} \indextext{\idxcode{:}!bit-field declaration}% @@ -1306,9 +1326,8 @@ with a value greater than or equal to zero. The value of the integral constant expression may be larger than the number of bits in the object -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. +representation\iref{basic.types} of the bit-field's type; in such +cases the extra bits are padding bits\iref{basic.types}. \indextext{allocation!implementation-defined bit-field}% Allocation of bit-fields within a class object is \impldef{allocation of bit-fields within a class object}. @@ -1341,7 +1360,7 @@ \pnum \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}). +integral or enumeration type\iref{basic.fundamental}. \indextext{Boolean}% A \tcode{bool} value can successfully be stored in a bit-field of any nonzero size. @@ -1352,7 +1371,7 @@ \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}). +bit-field\iref{dcl.init.ref}. \begin{note} If the initializer for a reference of type \tcode{const} \tcode{T\&} is an lvalue that refers to a bit-field, the reference is bound to a @@ -1366,7 +1385,7 @@ original \tcode{bool} value and the value of the bit-field shall compare equal. If the value of an enumerator is stored into a bit-field of the same enumeration type and the number of bits in the bit-field is large -enough to hold all the values of that enumeration type~(\ref{dcl.enum}), +enough to hold all the values of that enumeration type\iref{dcl.enum}, the original enumerator value and the value of the bit-field shall compare equal. \begin{example} @@ -1469,10 +1488,10 @@ \pnum \indextext{friend function!nested class}% -Like a member function, a friend function~(\ref{class.friend}) defined +Like a member function, a friend function\iref{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 -class~(\ref{class.static}), but it has no special access rights to +class\iref{class.static}, but it has no special access rights to members of an enclosing class. \rSec2[class.nested.type]{Nested type names} @@ -1508,13 +1527,13 @@ In a union, a non-static data member is \defnx{active}{active!union member} if its name refers to an object -whose lifetime has begun and has not ended~(\ref{basic.life}). +whose lifetime has begun and has not ended\iref{basic.life}. At most one of the non-static data members of an object of union type can be active at any time, that is, the value of at most one of the non-static data members can be stored in a union at any time. \begin{note} One special guarantee is made in order to simplify the use of unions: If a standard-layout union contains several standard-layout -structs that share a common initial sequence~(\ref{class.mem}), and +structs that share a common initial sequence\iref{class.mem}, and if a non-static data member of an object of this standard-layout union type is active and is one of the standard-layout structs, it is permitted to inspect the common initial sequence @@ -1539,21 +1558,21 @@ \indextext{destructor!\idxcode{union}}% A union can have member functions (including constructors and destructors), \indextext{restriction!\idxcode{union}}% -but it shall not have virtual~(\ref{class.virtual}) functions. A union shall not have +but it shall not have virtual\iref{class.virtual} functions. A union shall not have base classes. A union shall not be used as a base class. \indextext{restriction!\idxcode{union}}% If a union contains a non-static data member of reference type the program is ill-formed. -\begin{note} Absent default member initializers~(\ref{class.mem}), +\begin{note} Absent default member initializers\iref{class.mem}, if any non-static data member of a union has a non-trivial -default constructor~(\ref{class.ctor}), -copy constructor~(\ref{class.copy}), -move constructor~(\ref{class.copy}), -copy assignment operator~(\ref{class.copy}), -move assignment operator~(\ref{class.copy}), -or destructor~(\ref{class.dtor}), the corresponding member function +default constructor\iref{class.ctor}, +copy constructor\iref{class.copy}, +move constructor\iref{class.copy}, +copy assignment operator\iref{class.copy}, +move assignment operator\iref{class.copy}, +or destructor\iref{class.dtor}, the corresponding member function of the union must be user-provided or it will -be implicitly deleted~(\ref{dcl.fct.def.delete}) for the union. \end{note} +be implicitly deleted\iref{dcl.fct.def.delete} for the union. \end{note} \pnum \begin{example} Consider the following union: @@ -1566,7 +1585,7 @@ }; \end{codeblock} -Since \tcode{std::string}~(\ref{string.classes}) declares non-trivial versions of all of the special +Since \tcode{std::string}\iref{string.classes} declares non-trivial versions of all of the special member functions, \tcode{U} will have an implicitly deleted default constructor, copy/move constructor, copy/move assignment operator, and destructor. @@ -1575,7 +1594,7 @@ \pnum When the left operand of an assignment operator -involves a member access expression~(\ref{expr.ref}) +involves a member access expression\iref{expr.ref} that nominates a union member, it may begin the lifetime of that union member, as described below. @@ -1601,8 +1620,8 @@ Otherwise, $S(\mathtt{E})$ is empty. \end{itemize} In an assignment expression of the form \tcode{E1 = E2} -that uses either the built-in assignment operator~(\ref{expr.ass}) -or a trivial assignment operator~(\ref{class.copy}), +that uses either the built-in assignment operator\iref{expr.ass} +or a trivial assignment operator\iref{class.copy}, for each element \tcode{X} of $S($\tcode{E1}$)$, if modification of \tcode{X} would have undefined behavior under~\ref{basic.life}, an object of the type of \tcode{X} is implicitly created @@ -1613,7 +1632,7 @@ and before the assignment. \begin{note} This ends the lifetime of the previously-active -member of the union, if any~(\ref{basic.life}). +member of the union, if any\iref{basic.life}. \end{note} \begin{example} \begin{codeblock} @@ -1630,7 +1649,7 @@ 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\iref{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, @@ -1706,7 +1725,7 @@ \indextext{access control!anonymous \tcode{union}}% \indextext{restriction!anonymous \tcode{union}}% An anonymous union shall not have \tcode{private} or \tcode{protected} -members (Clause~\ref{class.access}). An anonymous union shall not have +members\iref{class.access}. An anonymous union shall not have member functions. \pnum @@ -1767,7 +1786,7 @@ 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 -shall not odr-use~(\ref{basic.def.odr}) a variable with automatic storage +shall not odr-use\iref{basic.def.odr} a variable with automatic storage duration from an enclosing scope. \begin{example} @@ -1796,7 +1815,7 @@ \pnum An enclosing function has no special access to members of the local -class; it obeys the usual access rules (Clause~\ref{class.access}). +class; it obeys the usual access rules\iref{class.access}. \indextext{member function!local class}% Member functions of a local class shall be defined within their class definition, if they are defined at all. diff --git a/source/compatibility.tex b/source/compatibility.tex index 72889bc128..dbd8b065b8 100644 --- a/source/compatibility.tex +++ b/source/compatibility.tex @@ -8,7 +8,7 @@ This subclause lists the differences between \Cpp and ISO C, by the chapters of this document. -\rSec2[diff.lex]{Clause~\ref{lex}: lexical conventions} +\rSec2[diff.lex]{\ref{lex}: lexical conventions} \ref{lex.key} \change New Keywords\\ @@ -94,7 +94,7 @@ Programs that have a legitimate reason to treat string literals as pointers to potentially modifiable memory are probably rare. -\rSec2[diff.basic]{Clause \ref{basic}: basic concepts} +\rSec2[diff.basic]{\ref{basic}: basic concepts} \ref{basic.def} \change \Cpp does not have ``tentative definitions'' as in C.\\ @@ -195,7 +195,7 @@ \howwide Common. -\rSec2[diff.conv]{Clause \ref{conv}: standard conversions} +\rSec2[diff.conv]{\ref{conv}: standard conversions} \ref{conv.ptr} \change Converting \tcode{void*} to a pointer-to-object type requires casting. @@ -232,7 +232,7 @@ Some ISO C translators will give a warning if the cast is not used. -\rSec2[diff.expr]{Clause \ref{expr}: expressions} +\rSec2[diff.expr]{\ref{expr}: expressions} \ref{expr.call} \change Implicit declaration of functions is not allowed. @@ -303,7 +303,7 @@ \howwide Rare. -\rSec2[diff.stat]{Clause \ref{stmt.stmt}: statements} +\rSec2[diff.stat]{\ref{stmt.stmt}: statements} \ref{stmt.switch}, \ref{stmt.goto} \change It is now invalid to jump past a declaration with explicit or implicit initializer (except across entire block not entered). @@ -349,7 +349,7 @@ For several years, many existing C implementations have produced warnings in this case. -\rSec2[diff.dcl]{Clause \ref{dcl.dcl}: declarations} +\rSec2[diff.dcl]{\ref{dcl.dcl}: declarations} \ref{dcl.stc} \change In \Cpp, the \tcode{static} or \tcode{extern} specifiers can only be applied to names of objects or functions.\\ @@ -533,7 +533,7 @@ Taking the size of an enumerator is not a common C coding practice. -\rSec2[diff.decl]{Clause \ref{dcl.decl}: declarators} +\rSec2[diff.decl]{\ref{dcl.decl}: declarators} \ref{dcl.fct} \change In \Cpp, a function declared with an empty parameter list takes no arguments. @@ -600,6 +600,43 @@ \howwide Common in old programs, but already known to be obsolescent. +\ref{dcl.init.aggr} +\change +In \Cpp, designated initialization support is restricted +compared to the corresponding functionality in C. +In \Cpp, +designators for non-static data members +must be specified in declaration order, +designators for array elements and nested designators +are not supported, +and +designated and non-designated initializers +cannot be mixed in the same initializer list. + +Example: + +\begin{codeblock} +struct A { int x, y; }; +struct B { struct A a; }; +struct A a = {.y = 1, .x = 2}; // valid C, invalid \Cpp +int arr[3] = {[1] = 5}; // valid C, invalid \Cpp +struct B b = {.a.x = 0}; // valid C, invalid \Cpp +struct A c = {.x = 1, 2}; // valid C, invalid \Cpp +\end{codeblock} +\rationale +In \Cpp, members are destroyed in reverse construction order +and the elements of an initializer list are evaluated in lexical order, +so field initializers must be specified in order. +Array designators conflict with \grammarterm{lambda-expression} syntax. +Nested designators are seldom used. +\effect +Deletion of feature that is incompatible with \Cpp. +\difficulty +Syntactic transformation. +\howwide +Out-of-order initializers are common. +The other features are seldom used. + \ref{dcl.init.string} \change In \Cpp, when initializing an array of character with a string, the number of characters in the string (including the terminating \tcode{'\textbackslash 0'}) must not exceed the @@ -624,7 +661,7 @@ Seldom. This style of array initialization is seen as poor coding style. -\rSec2[diff.class]{Clause \ref{class}: classes} +\rSec2[diff.class]{\ref{class}: classes} \ref{class.name} [see also \ref{dcl.typedef}] \change In \Cpp, a class declaration introduces the class name into the scope where it is @@ -751,7 +788,7 @@ \howwide Seldom. -\rSec2[diff.special]{Clause \ref{special}: special member functions} +\rSec2[diff.special]{\ref{special}: special member functions} \ref{class.copy} \change Copying volatile objects. @@ -799,7 +836,7 @@ \howwide Seldom. -\rSec2[diff.cpp]{Clause \ref{cpp}: preprocessing directives} +\rSec2[diff.cpp]{\ref{cpp}: preprocessing directives} \ref{cpp.predefined} \change Whether \mname{STDC} is defined and if so, what its value is, are @@ -826,7 +863,7 @@ ISO \CppIII (ISO/IEC 14882:2003, \doccite{Programming Languages --- \Cpp}), by the chapters of this document. -\rSec2[diff.cpp03.lex]{Clause \ref{lex}: lexical conventions} +\rSec2[diff.cpp03.lex]{\ref{lex}: lexical conventions} \ref{lex.pptoken} \change New kinds of string literals. @@ -885,7 +922,7 @@ Certain integer literals larger than can be represented by \tcode{long} could change from an unsigned integer type to \tcode{signed long long}. -\rSec2[diff.cpp03.conv]{Clause~\ref{conv}: standard conversions} +\rSec2[diff.cpp03.conv]{\ref{conv}: standard conversions} \ref{conv.ptr} \change Only literals are integer null pointer constants. @@ -902,7 +939,7 @@ } \end{codeblock} -\rSec2[diff.cpp03.expr]{Clause \ref{expr}: expressions} +\rSec2[diff.cpp03.expr]{\ref{expr}: expressions} \ref{expr.mul} \change Specify rounding for results of integer \tcode{/} and \tcode{\%}. @@ -925,7 +962,7 @@ bool b2 = &S::operator int && false; // previously \tcode{false}, now ill-formed \end{codeblock} -\rSec2[diff.cpp03.dcl.dcl]{Clause \ref{dcl.dcl}: declarations} +\rSec2[diff.cpp03.dcl.dcl]{\ref{dcl.dcl}: declarations} \ref{dcl.spec} \change Remove \tcode{auto} as a storage class specifier. @@ -936,7 +973,7 @@ Standard, \tcode{auto} indicates that the type of a variable is to be deduced from its initializer expression. -\rSec2[diff.cpp03.dcl.decl]{Clause \ref{dcl.decl}: declarators} +\rSec2[diff.cpp03.dcl.decl]{\ref{dcl.decl}: declarators} \ref{dcl.init.list} \change Narrowing restrictions in aggregate initializers. @@ -951,7 +988,7 @@ int x[] = { 2.0 }; \end{codeblock} -\rSec2[diff.cpp03.special]{Clause \ref{special}: special member functions} +\rSec2[diff.cpp03.special]{\ref{special}: special member functions} \ref{class.ctor}, \ref{class.dtor}, \ref{class.copy} \change Implicitly-declared special member functions are defined as deleted @@ -971,7 +1008,7 @@ (without calling \tcode{std::unexpected}) if their exception specification is non-throwing. -\rSec2[diff.cpp03.temp]{Clause \ref{temp}: templates} +\rSec2[diff.cpp03.temp]{\ref{temp}: templates} \ref{temp.param} \change Remove \tcode{export}. @@ -1006,7 +1043,7 @@ A valid \CppIII program could get a different result than this International Standard. -\rSec2[diff.cpp03.library]{Clause \ref{library}: library introduction} +\rSec2[diff.cpp03.library]{\ref{library}: library introduction} \ref{library} -- \ref{\lastlibchapter} \change New reserved identifiers. @@ -1080,7 +1117,7 @@ \tcode{carries_dependency}, or \tcode{noreturn} as macros is invalid in this International Standard. -\rSec2[diff.cpp03.language.support]{Clause \ref{language.support}: +\rSec2[diff.cpp03.language.support]{\ref{language.support}: language support library} \ref{new.delete.single} @@ -1126,7 +1163,7 @@ throws \tcode{std::bad_alloc} may execute differently in this International Standard. -\rSec2[diff.cpp03.diagnostics]{Clause \ref{diagnostics}: diagnostics library} +\rSec2[diff.cpp03.diagnostics]{\ref{diagnostics}: diagnostics library} \ref{errno} \change Thread-local error numbers. @@ -1135,7 +1172,7 @@ \tcode{errno} being the same across threads may change behavior in this International Standard. -\rSec2[diff.cpp03.utilities]{Clause \ref{utilities}: general utilities library} +\rSec2[diff.cpp03.utilities]{\ref{utilities}: general utilities library} \ref{util.dynamic.safety} \change Minimal support for garbage-collected regions. @@ -1156,7 +1193,7 @@ \tcode{unary_function} or \tcode{binary_function} may fail to compile in this International Standard. -\rSec2[diff.cpp03.strings]{Clause \ref{strings}: strings library} +\rSec2[diff.cpp03.strings]{\ref{strings}: strings library} \ref{string.classes} \change \tcode{basic_string} requirements no longer allow reference-counted @@ -1174,7 +1211,7 @@ Some \tcode{const} member functions, such as \tcode{data} and \tcode{c_str}, no longer invalidate iterators. -\rSec2[diff.cpp03.containers]{Clause \ref{containers}: containers library} +\rSec2[diff.cpp03.containers]{\ref{containers}: containers library} \ref{container.requirements} \change Complexity of \tcode{size()} member functions now constant. @@ -1255,7 +1292,7 @@ \CppIII code that uses this function may fail to compile with this International Standard. -\rSec2[diff.cpp03.algorithms]{Clause \ref{algorithms}: algorithms library} +\rSec2[diff.cpp03.algorithms]{\ref{algorithms}: algorithms library} \ref{algorithms.general} \change Result state of inputs after application of some algorithms. @@ -1267,7 +1304,7 @@ \tcode{std::remove_if} may leave the tail of the input sequence with a different set of values than previously. -\rSec2[diff.cpp03.numerics]{Clause \ref{numerics}: numerics library} +\rSec2[diff.cpp03.numerics]{\ref{numerics}: numerics library} \ref{complex.numbers} \change Specified representation of complex numbers. @@ -1277,7 +1314,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]{\ref{input.output}: input/output library} \ref{istream::sentry}, \ref{ostream::sentry}, @@ -1294,7 +1331,7 @@ \item using \tcode{operator==} to compare to \tcode{false} or \tcode{true}; \item returning a value from a function with a return type of \tcode{bool}; \item initializing members of type \tcode{bool} via aggregate initialization; -\item initializing a \tcode{const bool\&} which would bind to a temporary. +\item initializing a \tcode{const bool\&} which would bind to a temporary object. \end{itemize} \ref{ios::failure} @@ -1333,7 +1370,7 @@ ISO \CppXI (ISO/IEC 14882:2011, \doccite{Programming Languages --- \Cpp}), by the chapters of this document. -\rSec2[diff.cpp11.lex]{Clause \ref{lex}: lexical conventions} +\rSec2[diff.cpp11.lex]{\ref{lex}: lexical conventions} \ref{lex.ppnumber} \change \grammarterm{pp-number} can contain one or more single quotes. @@ -1351,7 +1388,7 @@ // \tcode{int x[2] = \{ 3'4, 5 \};} --- this International Standard \end{codeblock} -\rSec2[diff.cpp11.basic]{Clause \ref{basic}: basic concepts} +\rSec2[diff.cpp11.basic]{\ref{basic}: basic concepts} \ref{basic.stc.dynamic.deallocation} \change New usual (non-placement) deallocator. @@ -1366,17 +1403,17 @@ In this International Standard, however, the declaration of \tcode{operator delete} might match a predefined usual (non-placement) -\tcode{operator delete}~(\ref{basic.stc.dynamic}). If so, the +\tcode{operator delete}\iref{basic.stc.dynamic}. If so, the program is ill-formed, as it was for class member allocation functions and -deallocation functions~(\ref{expr.new}). +deallocation functions\iref{expr.new}. -\rSec2[diff.cpp11.expr]{Clause \ref{expr}: expressions} +\rSec2[diff.cpp11.expr]{\ref{expr}: expressions} \ref{expr.cond} \change A conditional expression with a throw expression as its second or third operand keeps the type and value category of the other operand. -\rationale Formerly mandated conversions (lvalue-to-rvalue (\ref{conv.lval}), -array-to-pointer (\ref{conv.array}), and function-to-pointer (\ref{conv.func}) +\rationale Formerly mandated conversions (lvalue-to-rvalue\iref{conv.lval}, +array-to-pointer\iref{conv.array}, and function-to-pointer\iref{conv.func} standard conversions), especially the creation of the temporary due to lvalue-to-rvalue conversion, were considered gratuitous and surprising. \effect Valid \CppXI code that relies on the conversions may behave differently @@ -1404,7 +1441,7 @@ In \CppXI, the expression yields \tcode{sizeof(const char*)}. In this International Standard, it yields \tcode{sizeof(const char[1])}. -\rSec2[diff.cpp11.dcl.dcl]{Clause \ref{dcl.dcl}: declarations} +\rSec2[diff.cpp11.dcl.dcl]{\ref{dcl.dcl}: declarations} \ref{dcl.constexpr} \change \tcode{constexpr} non-static member functions are not implicitly @@ -1424,7 +1461,7 @@ }; \end{codeblock} -\rSec2[diff.cpp11.dcl.decl]{Clause \ref{dcl.decl}: declarators} +\rSec2[diff.cpp11.dcl.decl]{\ref{dcl.decl}: declarators} \ref{dcl.init.aggr} \change Classes with default member initializers can be aggregates. @@ -1445,7 +1482,7 @@ // performs aggregate initialization in this International Standard \end{codeblock} -\rSec2[diff.cpp11.library]{Clause \ref{library}: library introduction} +\rSec2[diff.cpp11.library]{\ref{library}: library introduction} \ref{headers} \change New header. @@ -1455,7 +1492,7 @@ Valid \CppXI code that \tcode{\#include}{s} a header with that name may be invalid in this International Standard. -\rSec2[diff.cpp11.input.output]{Clause \ref{input.output}: input/output library} +\rSec2[diff.cpp11.input.output]{\ref{input.output}: input/output library} \ref{c.files} \change \tcode{gets} is not defined. @@ -1472,7 +1509,7 @@ ISO \CppXIV (ISO/IEC 14882:2014, \doccite{Programming Languages --- \Cpp}), by the chapters of this document. -\rSec2[diff.cpp14.lex]{Clause \ref{lex}: lexical conventions} +\rSec2[diff.cpp14.lex]{\ref{lex}: lexical conventions} \ref{lex.phases} \indextext{trigraph sequence}% @@ -1501,7 +1538,7 @@ 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} +\rSec2[diff.cpp14.expr]{\ref{expr}: expressions} \ref{expr.post.incr}, \ref{expr.pre.incr} \change @@ -1524,7 +1561,7 @@ \tcode{::operator new(std::size_t, std::align_val_t)} is used instead. -\rSec2[diff.cpp14.dcl.dcl]{Clause \ref{dcl.dcl}: declarations} +\rSec2[diff.cpp14.dcl.dcl]{\ref{dcl.dcl}: declarations} \ref{dcl.stc} \indextext{\idxcode{register} storage class}% @@ -1546,7 +1583,7 @@ auto x2{1, 2}; // was \tcode{std::initializer_list}, now ill-formed \end{codeblock} -\rSec2[diff.cpp14.decl]{Clause \ref{dcl.decl}: declarators} +\rSec2[diff.cpp14.decl]{\ref{dcl.decl}: declarators} \ref{dcl.fct} \change Make exception specifications be part of the type system. @@ -1584,7 +1621,7 @@ derived d2; // still OK \end{codeblock} -\rSec2[diff.cpp14.special]{Clause \ref{special}: special member functions} +\rSec2[diff.cpp14.special]{\ref{special}: special member functions} \ref{class.inhctor.init} \change @@ -1611,7 +1648,7 @@ // in \tcode{A(long)}. \end{codeblock} -\rSec2[diff.cpp14.temp]{Clause \ref{temp}: templates} +\rSec2[diff.cpp14.temp]{\ref{temp}: templates} \ref{temp.deduct.type} \change Allowance to deduce from the type of a non-type template argument. @@ -1630,7 +1667,7 @@ } \end{codeblock} -\rSec2[diff.cpp14.except]{Clause \ref{except}: exception handling} +\rSec2[diff.cpp14.except]{\ref{except}: exception handling} \ref{except.spec} \change Remove dynamic exception specifications. @@ -1651,7 +1688,7 @@ rather than \tcode{unexpected} and might not perform stack unwinding prior to such a call. -\rSec2[diff.cpp14.library]{Clause \ref{library}: library introduction} +\rSec2[diff.cpp14.library]{\ref{library}: library introduction} \ref{namespace.future} \change New reserved namespaces. @@ -1664,7 +1701,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]{\ref{utilities}: general utilities library} \ref{func.wrap} \change Constructors taking allocators removed. @@ -1690,7 +1727,7 @@ std::shared_ptr ptr(std::move(arr)); // error: \tcode{int(*)[]} is not compatible with \tcode{int*} \end{codeblock} -\rSec2[diff.cpp14.string]{Clause \ref{strings}: strings library} +\rSec2[diff.cpp14.string]{\ref{strings}: strings library} \ref{basic.string} \change Non-const \tcode{.data()} member added. @@ -1711,7 +1748,7 @@ int x = f(s.data()); // ill-formed; previously well-formed \end{codeblock} -\rSec2[diff.cpp14.containers]{Clause \ref{containers}: containers library} +\rSec2[diff.cpp14.containers]{\ref{containers}: containers library} \ref{associative.reqmts} \change Requirements change: @@ -1738,7 +1775,7 @@ } \end{codeblock} -\rSec2[diff.cpp14.depr]{Annex~\ref{depr}: compatibility features} +\rSec2[diff.cpp14.depr]{\ref{depr}: compatibility features} \change The class templates @@ -1765,6 +1802,27 @@ \effect A valid \CppXIV program using these identifiers may be ill-formed in this International Standard. +\rSec1[diff.cpp17]{\Cpp and ISO \CppXVII} + +\pnum +\indextext{summary!compatibility with ISO \CppXVII}% +This subclause lists the differences between \Cpp and +ISO \CppXVII (ISO/IEC 14882:2017, \doccite{Programming Languages --- \Cpp}), +by the chapters of this document. + +\rSec2[diff.cpp17.lex]{\ref{lex}: lexical conventions} + +\ref{lex.key} +\change New keywords.\\ +\rationale Required for new features. +The \tcode{requires} keyword is added +to introduce constraints through a \grammarterm{requires-clause} or +a \grammarterm{requires-expression}. The \tcode{concept} keyword is +added to enable the definition of concepts\iref{temp.concept}. +\effect +Valid ISO \CppXVII code using \tcode{concept} or \tcode{requires} +as an identifier is not valid in this International Standard. + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \rSec1[diff.library]{C standard library} \indextext{library!C standard}% @@ -1790,18 +1848,18 @@ nor are the C headers themselves part of \Cpp. \pnum -The \Cpp headers \tcode{}\indextext{\idxhdr{ccomplex}} (\ref{depr.ccomplex.syn}) -and \tcode{}\indextext{\idxhdr{ctgmath}} (\ref{depr.ctgmath.syn}), as well +The \Cpp headers \tcode{}\indextext{\idxhdr{ccomplex}}\iref{depr.ccomplex.syn} +and \tcode{}\indextext{\idxhdr{ctgmath}}\iref{depr.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 from the \Cpp standard library. \pnum -The headers \tcode{}, \tcode{}~(\ref{depr.cstdalign.syn}), -and \tcode{}~(\ref{depr.cstdbool.syn}) are meaningless in \Cpp. Use of +The headers \tcode{}, \tcode{}\iref{depr.cstdalign.syn}, +and \tcode{}\iref{depr.cstdbool.syn} are meaningless in \Cpp. Use of the \Cpp headers \tcode{}, \tcode{}, \tcode{}, -and \tcode{} is deprecated~(\ref{depr.c.headers}). +and \tcode{} is deprecated\iref{depr.c.headers}. \rSec2[diff.mods.to.definitions]{Modifications to definitions} @@ -1811,9 +1869,9 @@ The types \tcode{char16_t} and \tcode{char32_t} are distinct types rather than typedefs to existing integral types. The tokens \tcode{char16_t} and \tcode{char32_t} -are keywords in this International Standard (\ref{lex.key}). +are keywords in this International Standard\iref{lex.key}. They do not appear as macro names defined in -\tcode{}\indexlibrary{\idxhdr{cuchar}}~(\ref{cuchar.syn}). +\tcode{}\indexlibrary{\idxhdr{cuchar}}\iref{cuchar.syn}. \rSec3[diff.wchar.t]{Type \tcode{wchar_t}} @@ -1821,19 +1879,19 @@ The type \tcode{wchar_t} is a distinct type rather than a typedef to an existing integral type. The token \tcode{wchar_t} -is a keyword in this International Standard (\ref{lex.key}). +is a keyword in this International Standard\iref{lex.key}. It does not appear as a type name defined in any of -\tcode{}~(\ref{cstddef.syn})\indexlibrary{\idxhdr{cstddef}}, -\tcode{}~(\ref{cstdlib.syn})\indexlibrary{\idxhdr{cstdlib}}, -or \tcode{}~(\ref{cwchar.syn})\indexlibrary{\idxhdr{cwchar}}. +\tcode{}\iref{cstddef.syn}\indexlibrary{\idxhdr{cstddef}}, +\tcode{}\iref{cstdlib.syn}\indexlibrary{\idxhdr{cstdlib}}, +or \tcode{}\iref{cwchar.syn}\indexlibrary{\idxhdr{cwchar}}. \rSec3[diff.header.assert.h]{Header \tcode{}} \indexlibrary{\idxhdr{assert.h}}% \pnum The token \tcode{static_assert} is a keyword in this International -Standard (\ref{lex.key}). It does not appear as a macro name defined -in \tcode{}\indexlibrary{\idxhdr{cassert}}~(\ref{cassert.syn}). +Standard\iref{lex.key}. It does not appear as a macro name defined +in \tcode{}\indexlibrary{\idxhdr{cassert}}\iref{cassert.syn}. \rSec3[diff.header.iso646.h]{Header \tcode{}} \indexlibrary{\idxhdr{iso646.h}}% @@ -1853,7 +1911,7 @@ and \tcode{xor_eq} are keywords in this International -Standard (\ref{lex.key}). +Standard\iref{lex.key}. They do not appear as macro names defined in \tcode{}. \indexlibrary{\idxhdr{ciso646}}% @@ -1863,17 +1921,17 @@ \pnum The token \tcode{alignas} is a keyword in this International -Standard (\ref{lex.key}). It does not appear as a macro name defined -in \tcode{}\indexlibrary{\idxhdr{cstdalign}}~(\ref{depr.cstdalign.syn}). +Standard\iref{lex.key}. It does not appear as a macro name defined +in \tcode{}\indexlibrary{\idxhdr{cstdalign}}\iref{depr.cstdalign.syn}. \rSec3[diff.header.stdbool.h]{Header \tcode{}} \indexlibrary{\idxhdr{stdbool.h}}% \pnum The tokens \tcode{bool}, \tcode{true}, and \tcode{false} -are keywords in this International Standard (\ref{lex.key}). +are keywords in this International Standard\iref{lex.key}. They do not appear as macro names defined in -\tcode{}\indexlibrary{\idxhdr{cstdbool}}~(\ref{depr.cstdbool.syn}). +\tcode{}\indexlibrary{\idxhdr{cstdbool}}\iref{depr.cstdbool.syn}. \rSec3[diff.null]{Macro \tcode{NULL}} @@ -1881,20 +1939,20 @@ The macro \tcode{NULL}, defined in any of -\tcode{}~(\ref{c.locales})\indexlibrary{\idxhdr{clocale}}, -\tcode{}~(\ref{cstddef.syn})\indexlibrary{\idxhdr{cstddef}}, -\tcode{}~(\ref{cstdio.syn})\indexlibrary{\idxhdr{cstdio}}, -\tcode{} (\ref{cstdlib.syn})\indexlibrary{\idxhdr{cstdlib}}, -\tcode{}~(\ref{cstring.syn})\indexlibrary{\idxhdr{cstring}}, -\tcode{}~(\ref{ctime.syn})\indexlibrary{\idxhdr{ctime}}, -or \tcode{}~(\ref{cwchar.syn})\indexlibrary{\idxhdr{cwchar}}, +\tcode{}\iref{c.locales}\indexlibrary{\idxhdr{clocale}}, +\tcode{}\iref{cstddef.syn}\indexlibrary{\idxhdr{cstddef}}, +\tcode{}\iref{cstdio.syn}\indexlibrary{\idxhdr{cstdio}}, +\tcode{}\iref{cstdlib.syn}\indexlibrary{\idxhdr{cstdlib}}, +\tcode{}\iref{cstring.syn}\indexlibrary{\idxhdr{cstring}}, +\tcode{}\iref{ctime.syn}\indexlibrary{\idxhdr{ctime}}, +or \tcode{}\iref{cwchar.syn}\indexlibrary{\idxhdr{cwchar}}, is an \impldef{definition of \tcode{NULL}} \Cpp null pointer constant in -this International Standard (\ref{support.types}). +this International Standard\iref{support.types}. \rSec2[diff.mods.to.declarations]{Modifications to declarations} \pnum -Header \tcode{}~(\ref{cstring.syn})\indexlibrary{\idxhdr{cstring}}: +Header \tcode{}\iref{cstring.syn}\indexlibrary{\idxhdr{cstring}}: The following functions have different declarations: \begin{itemize} @@ -1908,7 +1966,7 @@ Subclause \ref{cstring.syn} describes the changes. \pnum -Header \tcode{}~(\ref{cwchar.syn})\indexlibrary{\idxhdr{cwchar}}: +Header \tcode{}\iref{cwchar.syn}\indexlibrary{\idxhdr{cwchar}}: The following functions have different declarations: \begin{itemize} @@ -1922,14 +1980,14 @@ Subclause \ref{cwchar.syn} describes the changes. \pnum -Header \tcode{}~(\ref{cstddef.syn})\indexlibrary{\idxhdr{cstddef}} +Header \tcode{}\iref{cstddef.syn}\indexlibrary{\idxhdr{cstddef}} declares the name \tcode{nullptr_t} in addition to the names declared in \tcode{} in the C standard library. \rSec2[diff.mods.to.behavior]{Modifications to behavior} \pnum -Header \tcode{}~(\ref{cstdlib.syn})\indexlibrary{\idxhdr{cstdlib}}: +Header \tcode{}\iref{cstdlib.syn}\indexlibrary{\idxhdr{cstdlib}}: The following functions have different behavior: \begin{itemize} @@ -1941,7 +1999,7 @@ Subclause \ref{support.start.term} describes the changes. \pnum -Header \tcode{}~(\ref{csetjmp.syn})\indexlibrary{\idxhdr{csetjmp}}: +Header \tcode{}\iref{csetjmp.syn}\indexlibrary{\idxhdr{csetjmp}}: The following functions have different behavior: \begin{itemize} @@ -1955,7 +2013,7 @@ \pnum The macro \tcode{offsetof}, defined in -\tcode{}~(\ref{cstddef.syn})\indexlibrary{\idxhdr{cstddef}}, +\tcode{}\iref{cstddef.syn}\indexlibrary{\idxhdr{cstddef}}, accepts a restricted set of \tcode{\placeholder{type}} arguments in this International Standard. Subclause \ref{support.types.layout} describes the change. diff --git a/source/config.tex b/source/config.tex index bd4746bf2d..d96308e84a 100644 --- a/source/config.tex +++ b/source/config.tex @@ -1,8 +1,8 @@ %!TEX root = std.tex %%-------------------------------------------------- %% Version numbers -\newcommand{\docno}{Dxxxx} -\newcommand{\prevdocno}{N4640} +\newcommand{\docno}{N4687} +\newcommand{\prevdocno}{N4659} \newcommand{\cppver}{201703L} %% Release date diff --git a/source/containers.tex b/source/containers.tex index 9b793e43c7..dd36ee6247 100644 --- a/source/containers.tex +++ b/source/containers.tex @@ -59,7 +59,7 @@ 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}), +\tcode{allocator_traits::rebind_traits::\brk{}destroy}\iref{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 @@ -269,7 +269,7 @@ 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}. +The algorithm \tcode{equal()} is defined in \ref{algorithms}. \end{note} \pnum @@ -356,7 +356,7 @@ \pnum If the iterator type of a container belongs to the bidirectional or -random access iterator categories~(\ref{iterator.requirements}), +random access iterator categories\iref{iterator.requirements}, the container is called \term{reversible} and satisfies the additional requirements @@ -453,9 +453,9 @@ \pnum \indextext{container!contiguous}% A \defn{contiguous container} -is a container that supports random access iterators~(\ref{random.access.iterators}) +is a container that supports random access iterators\iref{random.access.iterators} and whose member types \tcode{iterator} and \tcode{const_iterator} -are contiguous iterators~(\ref{iterator.requirements.general}). +are contiguous iterators\iref{iterator.requirements.general}. \pnum Table~\ref{tab:containers.optional.operations} lists operations that are provided @@ -504,7 +504,7 @@ \end{libreqtab5} \begin{note} -The algorithm \tcode{lexicographical_compare()} is defined in Clause~\ref{algorithms}. +The algorithm \tcode{lexicographical_compare()} is defined in \ref{algorithms}. \end{note} \pnum @@ -712,7 +712,7 @@ \begin{itemize} \item The \grammarterm{qualified-id} \tcode{A::value_type} -is valid and denotes a type~(\ref{temp.deduct}). +is valid and denotes a type\iref{temp.deduct}. \item The expression \tcode{declval().allocate(size_t\{\})} is well-formed when treated as an unevaluated operand. @@ -721,7 +721,7 @@ \rSec2[container.requirements.dataraces]{Container data races} \pnum -For purposes of avoiding data races~(\ref{res.on.data.races}), implementations shall +For purposes of avoiding data races\iref{res.on.data.races}, implementations shall consider the following functions to be \tcode{const}: \tcode{begin}, \tcode{end}, \tcode{rbegin}, \tcode{rend}, \tcode{front}, \tcode{back}, \tcode{data}, \tcode{find}, \tcode{lower_bound}, \tcode{upper_bound}, \tcode{equal_range}, \tcode{at} and, except in @@ -775,7 +775,7 @@ \tcode{u} denotes the name of a variable being declared, \tcode{A} denotes \tcode{X::allocator_type} if the \grammarterm{qualified-id} \tcode{X::allocator_type} is valid and denotes a -type~(\ref{temp.deduct}) and +type\iref{temp.deduct} and \tcode{allocator} if it doesn't, \tcode{i} and \tcode{j} denote iterators satisfying input iterator requirements @@ -825,7 +825,7 @@ & \requires\ \tcode{T} shall be \tcode{EmplaceConstructible} into \tcode{X} from \tcode{*i}. For \tcode{vector}, if the iterator does - not meet the forward iterator requirements~(\ref{forward.iterators}), \tcode{T} + not meet the forward iterator requirements\iref{forward.iterators}, \tcode{T} shall also be \tcode{MoveInsertable} into \tcode{X}. Each iterator in the range \range{i}{j} shall be dereferenced exactly once.\br @@ -881,7 +881,7 @@ \requires\ \tcode{T} shall be \tcode{EmplaceConstructible} into \tcode{X} from \tcode{*i}. For \tcode{vector} and \tcode{deque}, \tcode{T} shall also be \tcode{MoveInsertable} into \tcode{X}, \tcode{MoveConstructible}, \tcode{MoveAssignable}, - and swappable~(\ref{swappable.requirements}). + and swappable\iref{swappable.requirements}. Each iterator in the range \range{i}{j} shall be dereferenced exactly once.\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 @@ -913,7 +913,7 @@ \tcode{void} & \requires\ \tcode{T} shall be \tcode{EmplaceConstructible} into \tcode{X} from \tcode{*i} and assignable from \tcode{*i}. For \tcode{vector}, if the iterator does not - meet the forward iterator requirements~(\ref{forward.iterators}), \tcode{T} + meet the forward iterator requirements\iref{forward.iterators}, \tcode{T} shall also be \tcode{MoveInsertable} into \tcode{X}.\br Each iterator in the range \range{i}{j} shall be dereferenced exactly once.\br @@ -990,7 +990,7 @@ is returned. \pnum -For every sequence container defined in this Clause and in Clause~\ref{strings}: +For every sequence container defined in this Clause and in \ref{strings}: \begin{itemize} \item If the constructor \begin{codeblock} @@ -1193,8 +1193,8 @@ \pnum A \term{node handle} is an object that accepts ownership of a single element -from an associative container~(\ref{associative.reqmts}) or an unordered -associative container~(\ref{unord.req}). It may be used to transfer that +from an associative container\iref{associative.reqmts} or an unordered +associative container\iref{unord.req}. It may be used to transfer that ownership to another container with compatible nodes. Containers with compatible nodes have the same node handle type. Elements may be transferred in either direction between container types in the same row of @@ -1488,7 +1488,7 @@ \tcode{Key} and an ordering relation \tcode{Compare} -that induces a strict weak ordering~(\ref{alg.sorting}) on +that induces a strict weak ordering\iref{alg.sorting} on elements of \tcode{Key}. In addition, @@ -1557,7 +1557,7 @@ \pnum The associative containers meet all the requirements of Allocator-aware -containers~(\ref{container.requirements.general}), except that for +containers\iref{container.requirements.general}, except that for \tcode{map} and \tcode{multimap}, the requirements placed on \tcode{value_type} in Table~\ref{tab:containers.container.requirements} apply instead to \tcode{key_type} and \tcode{mapped_type}. \begin{note} For example, in some cases \tcode{key_type} and \tcode{mapped_type} @@ -1580,7 +1580,7 @@ \tcode{a_tran} denotes a possibly \tcode{const} value of type \tcode{X} when the \grammarterm{qualified-id} \tcode{X::key_compare::is_transparent} is valid -and denotes a type~(\ref{temp.deduct}), +and denotes a type\iref{temp.deduct}, \tcode{i} and \tcode{j} satisfy input iterator requirements and refer to elements implicitly convertible to @@ -1594,7 +1594,7 @@ \tcode{t} denotes a value of type \tcode{X::value_type}, \tcode{k} denotes a value of type \tcode{X::key_type} and \tcode{c} denotes a possibly \tcode{const} value of type \tcode{X::key_compare}; -\tcode{kl} is a value such that \tcode{a} is partitioned~(\ref{alg.sorting}) +\tcode{kl} is a value such that \tcode{a} is partitioned\iref{alg.sorting} with respect to \tcode{c(r, kl)}, with \tcode{r} the key value of \tcode{e} and \tcode{e} in \tcode{a}; \tcode{ku} is a value such that \tcode{a} is partitioned with respect to @@ -2033,7 +2033,7 @@ The member function templates \tcode{find}, \tcode{count}, \tcode{lower_bound}, \tcode{upper_bound}, and \tcode{equal_range} shall not participate in overload resolution unless the \grammarterm{qualified-id} \tcode{Compare::is_transparent} is valid -and denotes a type~(\ref{temp.deduct}). +and denotes a type\iref{temp.deduct}. \pnum A deduction guide for an associative container shall not participate in overload resolution @@ -2086,7 +2086,7 @@ \indextext{unordered associative containers!requirements}% \indextext{requirements!container!not required for unordered associated containers}% Unordered associative containers conform to the requirements for -Containers~(\ref{container.requirements}), except that +Containers\iref{container.requirements}, except that the expressions \tcode{a == b} and \tcode{a != b} have different semantics than for the other container types. @@ -2094,7 +2094,7 @@ \pnum Each unordered associative container is parameterized by \tcode{Key}, by a function object type \tcode{Hash} that meets the \tcode{Hash} -requirements~(\ref{hash.requirements}) and acts as a hash function for +requirements\iref{hash.requirements} and acts as a hash function for argument values of type \tcode{Key}, and by a binary predicate \tcode{Pred} that induces an equivalence relation on values of type \tcode{Key}. Additionally, \tcode{unordered_map} and \tcode{unordered_multimap} associate @@ -2174,7 +2174,7 @@ \pnum The unordered associative containers meet all the requirements of Allocator-aware -containers~(\ref{container.requirements.general}), except that for +containers\iref{container.requirements.general}, except that for \tcode{unordered_map} and \tcode{unordered_multimap}, the requirements placed on \tcode{value_type} in Table~\ref{tab:containers.container.requirements} apply instead to \tcode{key_type} and \tcode{mapped_type}. \begin{note} For example, \tcode{key_type} and \tcode{mapped_type} @@ -3116,24 +3116,24 @@ \indextext{\idxcode{array}!contiguous storage}% The header \tcode{} defines a class template for storing fixed-size sequences of objects. -An \tcode{array} is a contiguous container~(\ref{container.requirements.general}). +An \tcode{array} is a contiguous container\iref{container.requirements.general}. An instance of \tcode{array} stores \tcode{N} elements of type \tcode{T}, so that \tcode{size() == N} is an invariant. \pnum \indextext{\idxcode{array}!initialization}% \indextext{\idxcode{array}!as aggregate}% -An \tcode{array} is an aggregate~(\ref{dcl.init.aggr}) that can be +An \tcode{array} is an aggregate\iref{dcl.init.aggr} that can be list-initialized with up to \tcode{N} elements whose types are convertible to \tcode{T}. \pnum \indextext{requirements!container}% An \tcode{array} satisfies all of the requirements of a container and -of a reversible container~(\ref{container.requirements}), except that a default +of a reversible container\iref{container.requirements}, except that a default constructed \tcode{array} object is not empty and that \tcode{swap} does not have constant complexity. An \tcode{array} satisfies some of the requirements of a sequence -container~(\ref{sequence.reqmts}). +container\iref{sequence.reqmts}. Descriptions are provided here only for operations on \tcode{array} that are not described in one of these tables and @@ -3211,7 +3211,7 @@ \pnum \indextext{\idxcode{array}!initialization}% \indextext{requirements!container}% -The conditions for an aggregate~(\ref{dcl.init.aggr}) shall be +The conditions for an aggregate\iref{dcl.init.aggr} shall be met. Class \tcode{array} relies on the implicitly-declared special member functions~(\ref{class.ctor}, \ref{class.dtor}, and \ref{class.copy}) to conform to the container requirements table in~\ref{container.requirements}. @@ -3372,7 +3372,7 @@ A \indexlibrary{\idxcode{deque}}% \tcode{deque} -is a sequence container that supports random access iterators (\ref{random.access.iterators}). +is a sequence container that supports random access iterators\iref{random.access.iterators}. In addition, it supports constant time insert and erase operations at the beginning or the end; insert and erase in the middle take linear time. That is, a deque is especially optimized for pushing and popping elements at the beginning and end. @@ -3383,7 +3383,7 @@ \tcode{deque} satisfies all of the requirements of a container, of a reversible container (given in tables in~\ref{container.requirements}), of a sequence container, -including the optional sequence container requirements~(\ref{sequence.reqmts}), and of an allocator-aware container (Table~\ref{tab:containers.allocatoraware}). +including the optional sequence container requirements\iref{sequence.reqmts}, and of an allocator-aware container (Table~\ref{tab:containers.allocatoraware}). Descriptions are provided here only for operations on \tcode{deque} that are not described in one of these tables @@ -3927,7 +3927,7 @@ \pnum An incomplete type \tcode{T} may be used when instantiating \tcode{forward_list} if the allocator satisfies the -allocator completeness requirements~(\ref{allocator.requirements.completeness}). +allocator completeness requirements\iref{allocator.requirements.completeness}. \tcode{T} shall be complete before any member of the resulting specialization of \tcode{forward_list} is referenced. @@ -4349,7 +4349,7 @@ predicate. \pnum -\remarks Stable~(\ref{algorithm.stable}). +\remarks Stable\iref{algorithm.stable}. \pnum \complexity Exactly \tcode{distance(begin(), end())} applications of the corresponding @@ -4387,7 +4387,7 @@ \begin{itemdescr} \pnum -\requires \tcode{comp} defines a strict weak ordering~(\ref{alg.sorting}), and \tcode{*this} +\requires \tcode{comp} defines a strict weak ordering\iref{alg.sorting}, and \tcode{*this} and \tcode{x} are both sorted according to this ordering. \tcode{get_allocator() == x.get_allocator()}. @@ -4401,7 +4401,7 @@ \tcode{x}. \pnum -\remarks Stable~(\ref{algorithm.stable}). The behavior is undefined if +\remarks Stable\iref{algorithm.stable}. The behavior is undefined if \tcode{get_allocator() != x.get_allocator()}. \pnum @@ -4418,7 +4418,7 @@ \begin{itemdescr} \pnum \requires \tcode{operator<} (for the version with no arguments) or \tcode{comp} (for the -version with a comparison argument) defines a strict weak ordering~(\ref{alg.sorting}). +version with a comparison argument) defines a strict weak ordering\iref{alg.sorting}. \pnum \effects Sorts the list according to the \tcode{operator<} or the \tcode{comp} function object. @@ -4426,7 +4426,7 @@ Does not affect the validity of iterators and references. \pnum -\remarks Stable~(\ref{algorithm.stable}). +\remarks Stable\iref{algorithm.stable}. \pnum \complexity Approximately $N \log N$ comparisons, where $N$ is \tcode{distance(begin(), end())}. @@ -4471,7 +4471,7 @@ is a sequence container that supports bidirectional iterators and allows constant time insert and erase operations anywhere within the sequence, with storage management handled -automatically. Unlike vectors~(\ref{vector}) and deques~(\ref{deque}), +automatically. Unlike vectors\iref{vector} and deques\iref{deque}, fast random access to list elements is not supported, but many algorithms only need sequential access anyway. @@ -4480,7 +4480,7 @@ a reversible container (given in two tables in \ref{container.requirements}), of a sequence container, including most of the optional sequence container -requirements~(\ref{sequence.reqmts}), and of an allocator-aware container +requirements\iref{sequence.reqmts}, and of an allocator-aware container (Table~\ref{tab:containers.allocatoraware}). The exceptions are the \tcode{operator[]} @@ -4646,7 +4646,7 @@ \pnum An incomplete type \tcode{T} may be used when instantiating \tcode{list} if the allocator satisfies the -allocator completeness requirements~(\ref{allocator.requirements.completeness}). +allocator completeness requirements\iref{allocator.requirements.completeness}. \tcode{T} shall be complete before any member of the resulting specialization of \tcode{list} is referenced. @@ -5003,7 +5003,7 @@ \pnum \effects Erases all the elements in the list referred by a list iterator \tcode{i} for which the -following conditions hold: \tcode{*i == value, pred(*i) != false}. +following conditions hold: \tcode{*i == value}, \tcode{pred(*i) != false}. Invalidates only the iterators and references to the erased elements. \pnum @@ -5014,7 +5014,7 @@ \tcode{pred(*i) != false}. \pnum -\remarks Stable~(\ref{algorithm.stable}). +\remarks Stable\iref{algorithm.stable}. \pnum \complexity @@ -5067,7 +5067,7 @@ \begin{itemdescr} \pnum \requires -\tcode{comp} shall define a strict weak ordering~(\ref{alg.sorting}), and both the list and the argument list shall be +\tcode{comp} shall define a strict weak ordering\iref{alg.sorting}, and both the list and the argument list shall be sorted according to this ordering. \pnum @@ -5083,7 +5083,7 @@ \tcode{x}. \pnum -\remarks Stable~(\ref{algorithm.stable}). If \tcode{(\&x != this)} the range \tcode{[x.begin(), x.end())} +\remarks Stable\iref{algorithm.stable}. If \tcode{(\&x != this)} the range \tcode{[x.begin(), x.end())} is empty after the merge. No elements are copied by this operation. The behavior is undefined if \tcode{get_allocator() != x.get_allocator()}. @@ -5129,7 +5129,7 @@ or \tcode{comp} (for the second version) -shall define a strict weak ordering~(\ref{alg.sorting}). +shall define a strict weak ordering\iref{alg.sorting}. \pnum \effects @@ -5139,7 +5139,7 @@ Does not affect the validity of iterators and references. \pnum -\remarks Stable~(\ref{algorithm.stable}). +\remarks Stable\iref{algorithm.stable}. \pnum \complexity @@ -5182,10 +5182,10 @@ A \tcode{vector} satisfies all of the requirements of a container and of a reversible container (given in two tables in~\ref{container.requirements}), of a sequence container, including most of the optional sequence container -requirements~(\ref{sequence.reqmts}), of an allocator-aware container +requirements\iref{sequence.reqmts}, of an allocator-aware container (Table~\ref{tab:containers.allocatoraware}), and, for an element type other than \tcode{bool}, -of a contiguous container~(\ref{container.requirements.general}). +of a contiguous container\iref{container.requirements.general}. The exceptions are the \tcode{push_front}, \tcode{pop_front}, and \tcode{emplace_front} member functions, which are not provided. Descriptions are provided here only for operations on \tcode{vector} @@ -5325,7 +5325,7 @@ \pnum An incomplete type \tcode{T} may be used when instantiating \tcode{vector} if the allocator satisfies the -allocator completeness requirements~(\ref{allocator.requirements.completeness}). +allocator completeness requirements\iref{allocator.requirements.completeness}. \tcode{T} shall be complete before any member of the resulting specialization of \tcode{vector} is referenced. @@ -5791,7 +5791,7 @@ semantics as the primary \tcode{vector} template, except that operations dealing with the \tcode{bool} value type map to bit values in the container storage and -\tcode{allocator_traits::construct}~(\ref{allocator.traits.members}) +\tcode{allocator_traits::construct}\iref{allocator.traits.members} is not used to construct these values. \pnum @@ -5840,7 +5840,7 @@ \begin{itemdescr} \pnum -The specialization is enabled~(\ref{unord.hash}). +The specialization is enabled\iref{unord.hash}. \end{itemdescr} \rSec1[associative]{Associative containers} @@ -6031,8 +6031,8 @@ \pnum A \tcode{map} -satisfies all of the requirements of a container, of a reversible container~(\ref{container.requirements}), of -an associative container~(\ref{associative.reqmts}), and of an allocator-aware container (Table~\ref{tab:containers.allocatoraware}). +satisfies all of the requirements of a container, of a reversible container\iref{container.requirements}, of +an associative container\iref{associative.reqmts}, and of an allocator-aware container (Table~\ref{tab:containers.allocatoraware}). A \tcode{map} also provides most operations described in~\ref{associative.reqmts} @@ -6581,8 +6581,8 @@ \pnum A \tcode{multimap} satisfies all of the requirements of a container and of a -reversible container~(\ref{container.requirements}), of an associative -container~(\ref{associative.reqmts}), and of an allocator-aware container +reversible container\iref{container.requirements}, of an associative +container\iref{associative.reqmts}, and of an allocator-aware container (Table~\ref{tab:containers.allocatoraware}). A \tcode{multimap} @@ -6910,8 +6910,8 @@ \pnum A \tcode{set} satisfies all of the requirements of a container, of a reversible -container~(\ref{container.requirements}), of an associative -container~(\ref{associative.reqmts}), and of an allocator-aware container +container\iref{container.requirements}, of an associative +container\iref{associative.reqmts}, and of an allocator-aware container (Table~\ref{tab:containers.allocatoraware}). A \tcode{set} @@ -7198,8 +7198,8 @@ \pnum A \tcode{multiset} satisfies all of the requirements of a container, of a -reversible container~(\ref{container.requirements}), of an associative -container~(\ref{associative.reqmts}), and of an allocator-aware container +reversible container\iref{container.requirements}, of an associative +container\iref{associative.reqmts}, and of an allocator-aware container (Table~\ref{tab:containers.allocatoraware}). \tcode{multiset} also provides most operations described in~\ref{associative.reqmts} @@ -9248,9 +9248,9 @@ can be used to instantiate \tcode{queue}. In particular, -\tcode{list}~(\ref{list}) +\tcode{list}\iref{list} and -\tcode{deque}~(\ref{deque}) +\tcode{deque}\iref{deque} can be used. \begin{codeblock} @@ -9285,7 +9285,8 @@ void push(const value_type& x) { c.push_back(x); } void push(value_type&& x) { c.push_back(std::move(x)); } template - reference emplace(Args&&... args) { return c.emplace_back(std::forward(args)...); } + decltype(auto) emplace(Args&&... args) + { return c.emplace_back(std::forward(args)...); } void pop() { c.pop_front(); } void swap(queue& q) noexcept(is_nothrow_swappable_v) { using std::swap; swap(c, q.c); } @@ -9499,15 +9500,15 @@ can be used to instantiate \tcode{priority_queue}. In particular, -\tcode{vector}~(\ref{vector}) +\tcode{vector}\iref{vector} and -\tcode{deque}~(\ref{deque}) +\tcode{deque}\iref{deque} can be used. Instantiating \tcode{priority_queue} also involves supplying a function or function object for making priority comparisons; the library assumes that the function or function -object defines a strict weak ordering~(\ref{alg.sorting}). +object defines a strict weak ordering\iref{alg.sorting}. \begin{codeblock} namespace std { @@ -9591,7 +9592,7 @@ \begin{itemdescr} \pnum \requires -\tcode{x} shall define a strict weak ordering~(\ref{alg.sorting}). +\tcode{x} shall define a strict weak ordering\iref{alg.sorting}. \pnum \effects @@ -9619,7 +9620,7 @@ \begin{itemdescr} \pnum \requires -\tcode{x} shall define a strict weak ordering~(\ref{alg.sorting}). +\tcode{x} shall define a strict weak ordering\iref{alg.sorting}. \pnum \effects @@ -9803,10 +9804,10 @@ can be used to instantiate \tcode{stack}. In particular, -\tcode{vector}~(\ref{vector}), -\tcode{list}~(\ref{list}) +\tcode{vector}\iref{vector}, +\tcode{list}\iref{list} and -\tcode{deque}~(\ref{deque}) +\tcode{deque}\iref{deque} can be used. \rSec3[stack.defn]{\tcode{stack} definition} @@ -9841,7 +9842,8 @@ void push(const value_type& x) { c.push_back(x); } void push(value_type&& x) { c.push_back(std::move(x)); } template - reference emplace(Args&&... args) { return c.emplace_back(std::forward(args)...); } + decltype(auto) emplace(Args&&... args) + { return c.emplace_back(std::forward(args)...); } void pop() { c.pop_back(); } void swap(stack& s) noexcept(is_nothrow_swappable_v) { using std::swap; swap(c, s.c); } diff --git a/source/conversions.tex b/source/conversions.tex index e88e8d0b2a..23a88a9fdd 100644 --- a/source/conversions.tex +++ b/source/conversions.tex @@ -9,7 +9,7 @@ \indextext{conversion!standard|(}% \indextext{conversion!implicit}% Standard conversions are implicit conversions with built-in meaning. -Clause~\ref{conv} enumerates the full set of such conversions. A +\ref{conv} enumerates the full set of such conversions. A \indextext{sequence!standard conversion}% \term{standard conversion sequence} is a sequence of standard conversions in the following order: @@ -41,20 +41,20 @@ \begin{itemize} \item When used as operands of operators. The operator's requirements -for its operands dictate the destination type (Clause~\ref{expr}). +for its operands dictate the destination type\iref{expr}. \item When used in the condition of an \tcode{if} statement or iteration statement~(\ref{stmt.select}, \ref{stmt.iter}). The destination type is \tcode{bool}. \item When used in the expression of a \tcode{switch} statement. The -destination type is integral~(\ref{stmt.select}). +destination type is integral\iref{stmt.select}. \item When used as the source expression for an initialization (which includes use as an argument in a function call and use as the expression in a \tcode{return} statement). The type of the entity being initialized is (generally) the destination type. -See~\ref{dcl.init},~\ref{dcl.init.ref}. +See~\ref{dcl.init}, \ref{dcl.init.ref}. \end{itemize} \end{note} @@ -63,7 +63,7 @@ \indextext{conversion!implicit}% \term{implicitly converted} to a type \tcode{T} if and only if the declaration \tcode{T t=e;} is well-formed, for some invented temporary -variable \tcode{t}~(\ref{dcl.init}). +variable \tcode{t}\iref{dcl.init}. \pnum Certain language constructs require that an expression be converted to a Boolean @@ -71,7 +71,7 @@ \indextext{conversion!contextual to \tcode{bool}}% \term{contextually converted to \tcode{bool}} and is well-formed if and only if the declaration \tcode{bool t(e);} is well-formed, for some invented temporary -variable \tcode{t}~(\ref{dcl.init}). +variable \tcode{t}\iref{dcl.init}. \pnum Certain language constructs require conversion to a value having @@ -92,7 +92,7 @@ conversion is the same as performing the corresponding declaration and initialization and then using the temporary variable as the result of the conversion. The result is an lvalue if \tcode{T} is an lvalue reference -type or an rvalue reference to function type~(\ref{dcl.ref}), +type or an rvalue reference to function type\iref{dcl.ref}, an xvalue if \tcode{T} is an rvalue reference to object type, and a prvalue otherwise. The expression \tcode{e} is used as a glvalue if and only if the initialization uses it as a glvalue. @@ -101,7 +101,7 @@ \begin{note} For class types, user-defined conversions are considered as well; see~\ref{class.conv}. In general, an implicit conversion -sequence~(\ref{over.best.ics}) consists of a standard conversion +sequence\iref{over.best.ics} consists of a standard conversion sequence followed by a user-defined conversion followed by another standard conversion sequence. \end{note} @@ -119,7 +119,7 @@ \pnum \indextext{conversion!lvalue-to-rvalue}% \indextext{type!incomplete}% -A glvalue~(\ref{basic.lval}) of a non-function, non-array type \tcode{T} +A glvalue\iref{basic.lval} of a non-function, non-array type \tcode{T} can be converted to a prvalue.\footnote{For historical reasons, this conversion is called the ``lvalue-to-rvalue'' conversion, even though that name does not accurately reflect the taxonomy @@ -141,7 +141,7 @@ \item the evaluation of \tcode{e} results in the evaluation of a member \tcode{ex} of the set of potential results of \tcode{e}, and \tcode{ex} names a variable \tcode{x} that is not odr-used by - \tcode{ex}~(\ref{basic.def.odr}), + \tcode{ex}\iref{basic.def.odr}, \end{itemize} the value contained in the referenced object is not accessed. \begin{example} @@ -165,11 +165,11 @@ \begin{itemize} \item If \tcode{T} is \cv{}~\tcode{std::nullptr_t}, the result is a -null pointer constant~(\ref{conv.ptr}). +null pointer constant\iref{conv.ptr}. \begin{note} Since no value is fetched from memory, -there is no side effect for a volatile access~(\ref{intro.execution}), and -an inactive member of a union~(\ref{class.union}) may be accessed. +there is no side effect for a volatile access\iref{intro.execution}, and +an inactive member of a union\iref{class.union} may be accessed. \end{note} \item Otherwise, if \tcode{T} has a class @@ -199,7 +199,7 @@ An lvalue or rvalue of type ``array of \tcode{N} \tcode{T}'' or ``array of unknown bound of \tcode{T}'' can be converted to a prvalue of type ``pointer to \tcode{T}''. -The temporary materialization conversion~(\ref{conv.rval}) is applied. +The temporary materialization conversion\iref{conv.rval} is applied. The result is a pointer to the first element of the array. \rSec1[conv.func]{Function-to-pointer conversion} @@ -222,7 +222,7 @@ \pnum A prvalue of type \tcode{T} can be converted to an xvalue of type \tcode{T}. -This conversion initializes a temporary object~(\ref{class.temporary}) of type \tcode{T} from the prvalue +This conversion initializes a temporary object\iref{class.temporary} of type \tcode{T} from the prvalue by evaluating the prvalue with the temporary object as its result object, and produces an xvalue denoting the temporary object. \tcode{T} shall be a complete type. @@ -250,12 +250,12 @@ ``$cv_0$ $P_0$ $cv_1$ $P_1$ $\cdots$ $cv_{n-1}$ $P_{n-1}$ $cv_n$ \tcode{U}'' for $n > 0$, \end{indented} where -each $cv_i$ is a set of cv-qualifiers~(\ref{basic.type.qualifier}), and +each $cv_i$ is a set of cv-qualifiers\iref{basic.type.qualifier}, and each $P_i$ is -``pointer to''~(\ref{dcl.ptr}), -``pointer to member of class $C_i$ of type''~(\ref{dcl.mptr}), +``pointer to''\iref{dcl.ptr}, +``pointer to member of class $C_i$ of type''\iref{dcl.mptr}, ``array of $N_i$'', or -``array of unknown bound of''~(\ref{dcl.array}). +``array of unknown bound of''\iref{dcl.array}. If $P_i$ designates an array, the cv-qualifiers $cv_{i+1}$ on the element type are also taken as the cv-qualifiers $cv_i$ of the array. @@ -327,7 +327,7 @@ \pnum \begin{note} Function types (including those used in pointer to member function -types) are never cv-qualified (\ref{dcl.fct}). +types) are never cv-qualified\iref{dcl.fct}. \end{note} \indextext{conversion!qualification|)} @@ -337,7 +337,7 @@ \indextext{promotion!integral}% A prvalue of an integer type other than \tcode{bool}, \tcode{char16_t}, \tcode{char32_t}, or \tcode{wchar_t} whose integer conversion -rank~(\ref{conv.rank}) is less than the rank of \tcode{int} can be +rank\iref{conv.rank} is less than the rank of \tcode{int} can be converted to a prvalue of type \tcode{int} if \tcode{int} can represent all the values of the source type; otherwise, the source prvalue can be converted to a prvalue of type \tcode{unsigned int}. @@ -347,7 +347,7 @@ \indextext{type!underlying!\idxcode{char16_t}}% \indextext{type!underlying!\idxcode{char32_t}}% A prvalue of type \tcode{char16_t}, \tcode{char32_t}, or -\tcode{wchar_t}~(\ref{basic.fundamental}) can be converted to a prvalue +\tcode{wchar_t}\iref{basic.fundamental} can be converted to a prvalue of the first of the following types that can represent all the values of its underlying type: \tcode{int}, \tcode{unsigned int}, \tcode{long int}, \tcode{unsigned long int}, \tcode{long long int}, @@ -359,26 +359,26 @@ \pnum \indextext{type!underlying!enumeration}% 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 +fixed\iref{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_\text{min}$ to $b_\text{max}$ as described in~\ref{dcl.enum}): \tcode{int}, \tcode{unsigned int}, \tcode{long int}, \tcode{unsigned long 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 enumeration type can be converted to a prvalue of the extended integer type with lowest -integer conversion rank~(\ref{conv.rank}) greater than the rank of \tcode{long long} +integer conversion rank\iref{conv.rank} greater than the rank of \tcode{long long} in which all the values of the enumeration can be represented. If there are two such extended types, the signed one is chosen. \pnum A prvalue of an unscoped enumeration type whose underlying type is -fixed~(\ref{dcl.enum}) can be converted to a prvalue of its underlying type. Moreover, +fixed\iref{dcl.enum} can be converted to a prvalue of its underlying type. Moreover, if integral promotion can be applied to its underlying type, a prvalue of an unscoped enumeration type whose underlying type is fixed can also be converted to a prvalue of the promoted underlying type. \pnum -A prvalue for an integral bit-field~(\ref{class.bit}) can be converted +A prvalue for an integral bit-field\iref{class.bit} can be converted to a prvalue of type \tcode{int} if \tcode{int} can represent all the values of the bit-field; otherwise, it can be converted to \tcode{unsigned int} if \tcode{unsigned int} can represent all the @@ -492,7 +492,7 @@ \indextext{pointer!zero}% \indextext{constant!null pointer}% \indextext{value!null pointer}% -A \term{null pointer constant} is an integer literal~(\ref{lex.icon}) with +A \term{null pointer constant} is an integer literal\iref{lex.icon} with value zero or a prvalue of type \tcode{std::nullptr_t}. A null pointer constant can be converted to a pointer type; the @@ -505,7 +505,7 @@ equal. The conversion of a null pointer constant to a pointer to cv-qualified type is a single conversion, and not the sequence of a pointer conversion followed by a qualification -conversion~(\ref{conv.qual}). A null pointer constant of integral type +conversion\iref{conv.qual}. A null pointer constant of integral type can be converted to a prvalue of type \tcode{std::nullptr_t}. \begin{note} The resulting prvalue is not a null pointer value. \end{note} @@ -513,15 +513,15 @@ A prvalue of type ``pointer to \cvqual{cv} \tcode{T}'', where \tcode{T} is an object type, can be converted to a prvalue of type ``pointer to \cvqual{cv} \tcode{void}''. -The pointer value~(\ref{basic.compound}) is unchanged by this conversion. +The pointer value\iref{basic.compound} is unchanged by this conversion. \pnum A prvalue of type ``pointer to \cvqual{cv} \tcode{D}'', where \tcode{D} is a class type, can be converted to a prvalue of type ``pointer to -\cvqual{cv} \tcode{B}'', where \tcode{B} is a base class -(Clause~\ref{class.derived}) of \tcode{D}. If \tcode{B} is an -inaccessible (Clause~\ref{class.access}) or -ambiguous~(\ref{class.member.lookup}) base class of \tcode{D}, a program +\cvqual{cv} \tcode{B}'', where \tcode{B} is a base class\iref{class.derived} +of \tcode{D}. If \tcode{B} is an +inaccessible\iref{class.access} or +ambiguous\iref{class.member.lookup} base class of \tcode{D}, a program that necessitates this conversion is ill-formed. The result of the conversion is a pointer to the base class subobject of the derived class object. The null pointer value is converted to the null pointer value of @@ -533,7 +533,7 @@ \indextext{conversion!pointer to member}% \indextext{constant!null pointer}% \indextext{value!null member pointer}% -A null pointer constant~(\ref{conv.ptr}) can be converted to a pointer +A null pointer constant\iref{conv.ptr} can be converted to a pointer to member type; the result is the \term{null member pointer value} of that type and is distinguishable from any pointer to member not created from a null pointer constant. @@ -542,16 +542,16 @@ the same type shall compare equal. The conversion of a null pointer constant to a pointer to member of cv-qualified type is a single conversion, and not the sequence of a pointer to member conversion -followed by a qualification conversion~(\ref{conv.qual}). +followed by a qualification conversion\iref{conv.qual}. \pnum A prvalue of type ``pointer to member of \tcode{B} of type \cvqual{cv} \tcode{T}'', where \tcode{B} is a class type, can be converted to a prvalue of type ``pointer to member of \tcode{D} of type \cvqual{cv} -\tcode{T}'', where \tcode{D} is a derived class -(Clause~\ref{class.derived}) of \tcode{B}. If \tcode{B} is an -inaccessible (Clause~\ref{class.access}), -ambiguous~(\ref{class.member.lookup}), or virtual~(\ref{class.mi}) base +\tcode{T}'', where \tcode{D} is a derived class\iref{class.derived} +of \tcode{B}. If \tcode{B} is an +inaccessible\iref{class.access}, +ambiguous\iref{class.member.lookup}, or virtual\iref{class.mi} base class of \tcode{D}, or a base class of a virtual base class of \tcode{D}, a program that necessitates this conversion is ill-formed. The result of the conversion refers to the same member as the pointer to @@ -566,7 +566,7 @@ type.\footnote{The rule for conversion of pointers to members (from pointer to member of base to pointer to member of derived) appears inverted compared to the rule for pointers to objects (from pointer to derived to pointer to -base)~(\ref{conv.ptr}, Clause~\ref{class.derived}). This inversion is +base)~(\ref{conv.ptr}, \ref{class.derived}). This inversion is necessary to ensure type safety. Note that a pointer to member is not an object pointer or a function pointer and the rules for conversions @@ -604,7 +604,7 @@ type can be converted to a prvalue of type \tcode{bool}. A zero value, null pointer value, or null member pointer value is converted to \tcode{false}; any other value is converted to \tcode{true}. For -direct-initialization~(\ref{dcl.init}), a prvalue of type +direct-initialization\iref{dcl.init}, a prvalue of type \tcode{std::nullptr_t} can be converted to a prvalue of type \tcode{bool}; the resulting value is \tcode{false}. @@ -645,7 +645,7 @@ \indextext{type!\idxcode{char32_t}}% \item The ranks of \tcode{char16_t}, \tcode{char32_t}, and \tcode{wchar_t} shall equal the ranks of their underlying -types~(\ref{basic.fundamental}). +types\iref{basic.fundamental}. \item The rank of any extended signed integer type relative to another extended signed integer type with the same size is \impldef{rank of extended signed @@ -660,7 +660,7 @@ \begin{note} The integer conversion rank is used in the definition of the integral -promotions~(\ref{conv.prom}) and the usual arithmetic -conversions (Clause~\ref{expr}). +promotions\iref{conv.prom} and the usual arithmetic +conversions\iref{expr}. \end{note}% \indextext{conversion!standard|)} diff --git a/source/cover-reg.tex b/source/cover-reg.tex index 1b3e20c473..0a22c6e18a 100644 --- a/source/cover-reg.tex +++ b/source/cover-reg.tex @@ -75,15 +75,16 @@ \begin{minipage}{\hsize} \begin{indented} +\microtypesetup{activate=false}% ISO copyright office\\ Case postale 56, CH-1211 Geneva 20\\ -Tel. + 41 22 749 01 11\\ +\rlap{Tel.}\hphantom{Fax} + 41 22 749 01 11\\ Fax + 41 22 749 09 47\\ E-mail copyright@iso.org\\ Web www.iso.org \end{indented} \end{minipage} - +\\\\ \hline \end{tabular} diff --git a/source/declarations.tex b/source/declarations.tex index 4645f6d53b..06d75566a7 100644 --- a/source/declarations.tex +++ b/source/declarations.tex @@ -81,7 +81,7 @@ \grammarterm{linkage-specification}{s} are described in~\ref{dcl.link}. \grammarterm{Function-definition}{s} are described in~\ref{dcl.fct.def} and \grammarterm{template-declaration}{s} and -\grammarterm{deduction-guide}{s} are described in Clause~\ref{temp}. +\grammarterm{deduction-guide}{s} are described in \ref{temp}. \grammarterm{Namespace-definition}{s} are described in~\ref{namespace.def}, \grammarterm{using-declaration}{s} are described in~\ref{namespace.udecl} and \grammarterm{using-directive}{s} are described in~\ref{namespace.udir}. @@ -101,7 +101,7 @@ \grammarterm{decl-specifier}{s}, the principal components of a \grammarterm{decl-specifier-seq}, are described in~\ref{dcl.spec}. \grammarterm{declarator}{s}, the components of an -\grammarterm{init-declarator-list}, are described in Clause~\ref{dcl.decl}. +\grammarterm{init-declarator-list}, are described in \ref{dcl.decl}. The \grammarterm{attribute-specifier-seq} appertains to each of the entities declared by the \grammarterm{declarator}{s} @@ -122,12 +122,12 @@ \pnum \indextext{declaration}% \indextext{scope}% -A declaration occurs in a scope~(\ref{basic.scope}); the scope rules are +A declaration occurs in a scope\iref{basic.scope}; the scope rules are summarized in~\ref{basic.lookup}. A declaration that declares a function or defines a class, namespace, template, or function also has one or more scopes nested within it. These nested scopes, in turn, can have declarations nested within them. Unless otherwise stated, utterances in -Clause~\ref{dcl.dcl} about components in, of, or contained by a +\ref{dcl.dcl} about components in, of, or contained by a declaration or subcomponent thereof refer only to those components of the declaration that are \emph{not} nested within scopes nested within the declaration. @@ -137,10 +137,10 @@ \indextext{declarator}% In a \grammarterm{simple-declaration}, the optional \grammarterm{init-declarator-list} can be omitted only when declaring a -class (Clause~\ref{class}) or enumeration~(\ref{dcl.enum}), that is, +class\iref{class} or enumeration\iref{dcl.enum}, that is, when the \grammarterm{decl-specifier-seq} contains either a \grammarterm{class-specifier}, an \grammarterm{elaborated-type-specifier} with -a \grammarterm{class-key}~(\ref{class.name}), or an +a \grammarterm{class-key}\iref{class.name}, or an \grammarterm{enum-specifier}. In these cases and whenever a \grammarterm{class-specifier} or \grammarterm{enum-specifier} is present in the \grammarterm{decl-specifier-seq}, the identifiers in these specifiers @@ -162,14 +162,14 @@ In a \grammarterm{static_assert-declaration}, the \grammarterm{constant-expression} shall be a contextually converted constant expression -of type \tcode{bool}~(\ref{expr.const}). +of type \tcode{bool}\iref{expr.const}. If the value of the expression when so converted is \tcode{true}, the declaration has no effect. Otherwise, the program is ill-formed, and the resulting -diagnostic message~(\ref{intro.compliance}) shall include the text of +diagnostic message\iref{intro.compliance} shall include the text of the \grammarterm{string-literal}, if one is supplied, except that characters not in the basic -source character set~(\ref{lex.charset}) are not required to appear in +source character set\iref{lex.charset} are not required to appear in the diagnostic message. \begin{example} @@ -182,9 +182,9 @@ \pnum A \grammarterm{simple-declaration} with an \grammarterm{identifier-list} is called -a \defn{structured binding declaration}~(\ref{dcl.struct.bind}). +a \defn{structured binding declaration}\iref{dcl.struct.bind}. The \grammarterm{decl-specifier-seq} shall -contain only the \grammarterm{type-specifier} \tcode{auto}~(\ref{dcl.spec.auto}) +contain only the \grammarterm{type-specifier} \tcode{auto}\iref{dcl.spec.auto} and \grammarterm{cv-qualifier}{s}. The \grammarterm{initializer} shall be of the form ``\tcode{=} \grammarterm{assignment-expression}'', @@ -199,10 +199,10 @@ contains exactly one \grammarterm{declarator-id}, which is the name declared by that \grammarterm{init-declarator} and hence one of the names declared by the declaration. The -\grammarterm{defining-type-specifier}{s}~(\ref{dcl.type}) in the +\grammarterm{defining-type-specifier}{s}\iref{dcl.type} in the \grammarterm{decl-specifier-seq} and the recursive \grammarterm{declarator} structure of the \grammarterm{init-declarator} describe a -type~(\ref{dcl.meaning}), which is then associated with the name being +type\iref{dcl.meaning}, which is then associated with the name being declared by the \grammarterm{init-declarator}. \pnum @@ -210,10 +210,10 @@ specifier, the declaration is called a \term{typedef declaration} and the name of each \grammarterm{init-declarator} is declared to be a \grammarterm{typedef-name}, synonymous with its -associated type~(\ref{dcl.typedef}). If the +associated type\iref{dcl.typedef}. If the \grammarterm{decl-specifier-seq} contains no \tcode{typedef} specifier, the declaration is called a \term{function declaration} if -the type associated with the name is a function type~(\ref{dcl.fct}) and +the type associated with the name is a function type\iref{dcl.fct} and an \term{object declaration} otherwise. \pnum @@ -222,11 +222,11 @@ 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}). +initializer\iref{basic.def}. \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. +any appropriate initialization\iref{dcl.init} to be done. \pnum A \grammarterm{nodeclspec-function-declaration} shall declare a @@ -234,9 +234,9 @@ ``implicit int'' rule of C is no longer supported.} \begin{note} A \grammarterm{nodeclspec-function-declaration} can only be used in a -\grammarterm{template-declaration}~(Clause~\ref{temp}), -\grammarterm{explicit-instantiation} (\ref{temp.explicit}), or -\grammarterm{explicit-specialization}~(\ref{temp.expl.spec}). +\grammarterm{template-declaration}\iref{temp}, +\grammarterm{explicit-instantiation}\iref{temp.explicit}, or +\grammarterm{explicit-specialization}\iref{temp.expl.spec}. \end{note} \rSec1[dcl.spec]{Specifiers}% @@ -265,7 +265,7 @@ The optional \grammarterm{attribute-specifier-seq} in a \grammarterm{decl-specifier-seq} appertains to the type determined by the preceding -\grammarterm{decl-specifier}{s}~(\ref{dcl.meaning}). The \grammarterm{attribute-specifier-seq} +\grammarterm{decl-specifier}{s}\iref{dcl.meaning}. The \grammarterm{attribute-specifier-seq} affects the type only for the declaration it appears in, not other declarations involving the same type. @@ -348,25 +348,25 @@ empty (except for an anonymous union declared in a named namespace or in the global namespace, which shall be declared \indextext{specifier!\idxcode{static}}% -\tcode{static}~(\ref{class.union.anon})). The +\tcode{static}\iref{class.union.anon}). The \grammarterm{storage-class-specifier} applies to the name declared by each \grammarterm{init-declarator} in the list and not to any names declared by other specifiers. A \grammarterm{storage-class-specifier} other than \tcode{thread_local} shall not be -specified in an explicit specialization~(\ref{temp.expl.spec}) or an -explicit instantiation~(\ref{temp.explicit}) directive. +specified in an explicit specialization\iref{temp.expl.spec} or an +explicit instantiation\iref{temp.explicit} directive. \pnum \begin{note} A variable declared without a \grammarterm{storage-class-specifier} at block scope or declared as a function parameter -has automatic storage duration by default~(\ref{basic.stc.auto}). +has automatic storage duration by default\iref{basic.stc.auto}. \end{note} \pnum The \tcode{thread_local} specifier -indicates that the named entity has thread storage duration~(\ref{basic.stc.thread}). It +indicates that the named entity has thread storage duration\iref{basic.stc.thread}. It shall be applied only to the names of variables of namespace or block scope and to the names of static data members. @@ -378,13 +378,13 @@ \pnum \indextext{restriction!\idxcode{static}}% The \tcode{static} specifier can be applied only to names of variables and -functions and to anonymous unions~(\ref{class.union.anon}). There can be no +functions and to anonymous unions\iref{class.union.anon}. There can be no \tcode{static} function declarations within a block, nor any \tcode{static} function parameters. A \tcode{static} specifier used in the declaration of a variable declares the variable to have static storage -duration~(\ref{basic.stc.static}), unless accompanied by the +duration\iref{basic.stc.static}, unless accompanied by the \tcode{thread_local} specifier, which declares the variable to have thread -storage duration~(\ref{basic.stc.thread}). A \tcode{static} specifier can be +storage duration\iref{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}% @@ -471,7 +471,7 @@ \pnum The \tcode{mutable} specifier shall appear only in the declaration of -a non-static data member~(\ref{class.mem}) +a non-static data member\iref{class.mem} whose type is neither const-qualified nor a reference type. \begin{example} \begin{codeblock} @@ -486,7 +486,7 @@ The \tcode{mutable} specifier on a class data member nullifies a \tcode{const} specifier applied to the containing class object and permits modification of the mutable class member even though the rest of -the object is \tcode{const}~(\ref{dcl.type.cv}). +the object is \tcode{const}\iref{dcl.type.cv}. \rSec2[dcl.fct.spec]{Function specifiers}% \indextext{specifier!function}% @@ -520,14 +520,14 @@ \pnum Declarations containing the \grammarterm{decl-specifier} \tcode{typedef} declare identifiers that can be used later for naming -fundamental~(\ref{basic.fundamental}) or compound~(\ref{basic.compound}) +fundamental\iref{basic.fundamental} or compound\iref{basic.compound} types. The \tcode{typedef} specifier shall not be combined in a \grammarterm{decl-specifier-seq} with any other kind of specifier except a \grammarterm{defining-type-specifier}, and it shall not be used in the \grammarterm{decl-specifier-seq} of a -\grammarterm{parameter-declaration}~(\ref{dcl.fct}) nor in the +\grammarterm{parameter-declaration}\iref{dcl.fct} nor in the \grammarterm{decl-specifier-seq} of a -\grammarterm{function-definition}~(\ref{dcl.fct.def}). +\grammarterm{function-definition}\iref{dcl.fct.def}. If a \tcode{typedef} specifier appears in a declaration without a \grammarterm{declarator}, the program is ill-formed. @@ -540,13 +540,13 @@ \grammarterm{typedef-name}. Within the scope of its declaration, a \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}. +\ref{dcl.decl}. \indextext{declaration!typedef@\tcode{typedef} as type}% \indextext{equivalence!type}% \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. +declaration\iref{class.name} or enum declaration does. \begin{example} \indextext{example!\idxcode{typedef}}% After @@ -664,12 +664,12 @@ \begin{note} \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 +version thereof, is also a \grammarterm{class-name}\iref{class.name}. If a \grammarterm{typedef-name} is used to identify the subject of an -\grammarterm{elaborated-type-specifier}~(\ref{dcl.type.elab}), a class -definition (Clause~\ref{class}), a constructor -declaration~(\ref{class.ctor}), or a destructor -declaration~(\ref{class.dtor}), the program is ill-formed. +\grammarterm{elaborated-type-specifier}\iref{dcl.type.elab}, a class +definition\iref{class}, a constructor +declaration\iref{class.ctor}, or a destructor +declaration\iref{class.dtor}, the program is ill-formed. \end{note} \begin{example} @@ -693,7 +693,7 @@ If the typedef declaration defines an unnamed class (or enum), the first \grammarterm{typedef-name} declared by the declaration to be that class type (or enum type) is used to denote the class type (or enum type) for -linkage purposes only~(\ref{basic.link}). +linkage purposes only\iref{basic.link}. \begin{example} \begin{codeblock} @@ -717,7 +717,7 @@ the declaration of a function or function template. A function or static data member declared with the \tcode{constexpr} -specifier is implicitly an inline function or variable~(\ref{dcl.inline}). +specifier is implicitly an inline function or variable\iref{dcl.inline}. If any declaration of a function or function template has a \tcode{constexpr} specifier, then all its declarations shall contain the \tcode{constexpr} specifier. \begin{note} An @@ -738,7 +738,7 @@ : x(a), y(x) // OK: definition { square(x); } constexpr pixel small(2); // error: \tcode{square} not defined, so \tcode{small(2)} - // not constant~(\ref{expr.const}) so \tcode{constexpr} not satisfied + // not constant\iref{expr.const} so \tcode{constexpr} not satisfied constexpr void square(int &x) { // OK: definition x *= x; @@ -767,7 +767,7 @@ \begin{itemize} \item -it shall not be virtual~(\ref{class.virtual}); +it shall not be virtual\iref{class.virtual}; \item its return type shall be a literal type; @@ -784,7 +784,7 @@ \begin{itemize} \item an \grammarterm{asm-definition}, \item a \tcode{goto} statement, -\item an identifier label~(\ref{stmt.label}), +\item an identifier label\iref{stmt.label}, \item a \grammarterm{try-block}, or \item a definition of a variable of non-literal type or @@ -848,10 +848,10 @@ \item every non-variant non-static data member and base class subobject -shall be initialized~(\ref{class.base.init}); +shall be initialized\iref{class.base.init}; \item -if the class is a union having variant members~(\ref{class.union}), exactly one of them +if the class is a union having variant members\iref{class.union}, exactly one of them shall be initialized; \item @@ -882,8 +882,8 @@ 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 -constant expression~(\ref{expr.const}), or, -for a constructor, a constant initializer for some object~(\ref{basic.start.static}), +constant expression\iref{expr.const}, or, +for a constructor, a constant initializer for some object\iref{basic.start.static}, the program is ill-formed, no diagnostic required. \begin{example} \begin{codeblock} @@ -924,9 +924,9 @@ \begin{itemize} \item a call to a constexpr -function can appear in a constant expression~(\ref{expr.const}) and +function can appear in a constant expression\iref{expr.const} and \item -copy elision is mandatory in a constant expression~(\ref{class.copy}). +copy elision is mandatory in a constant expression\iref{class.copy}. \end{itemize} \pnum @@ -949,7 +949,7 @@ shall be initialized. In any \tcode{constexpr} variable declaration, the full-expression of the initialization -shall be a constant expression~(\ref{expr.const}). +shall be a constant expression\iref{expr.const}. \begin{example} \begin{codeblock} struct pixel { @@ -970,7 +970,7 @@ \pnum \indextext{specifier!\idxcode{inline}}% \indextext{inline function}% -A function declaration~(\ref{dcl.fct},~\ref{class.mfct}, +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 the implementation that inline substitution of the function body at the @@ -997,7 +997,7 @@ \pnum An inline function or variable shall be defined in every translation unit in which it is odr-used and shall have exactly the same definition in every -case~(\ref{basic.def.odr}). +case\iref{basic.def.odr}. \begin{note} A call to the inline function or a use of the inline variable may be encountered before its definition appears in the translation unit. @@ -1056,7 +1056,7 @@ or a \grammarterm{defining-type-specifier-seq} appertains to the type denoted by the preceding \grammarterm{type-specifier}{s} -or \grammarterm{defining-type-specifier}{s}~(\ref{dcl.meaning}). The +or \grammarterm{defining-type-specifier}{s}\iref{dcl.meaning}. The \grammarterm{attribute-specifier-seq} affects the type only for the declaration it appears in, not other declarations involving the same type. @@ -1107,7 +1107,7 @@ are discussed in \ref{dcl.enum}, -Clause~\ref{class}, +\ref{class}, and \ref{temp.res}, respectively. The remaining \grammarterm{type-specifier}{s} are discussed in the rest of this section. @@ -1135,8 +1135,8 @@ \pnum \begin{note} -Declaring a variable \tcode{const} can affect its linkage~(\ref{dcl.stc}) -and its usability in constant expressions~(\ref{expr.const}). As +Declaring a variable \tcode{const} can affect its linkage\iref{dcl.stc} +and its usability in constant expressions\iref{expr.const}. As described in~\ref{dcl.init}, the definition of an object or subobject of const-qualified type must specify an initializer or be subject to default-initialization. @@ -1150,14 +1150,14 @@ some other access path. \begin{note} Cv-qualifiers are supported by the type system so that they cannot be -subverted without casting~(\ref{expr.const.cast}). +subverted without casting\iref{expr.const.cast}. \end{note} \pnum \indextext{const object@\tcode{const}-object!undefined change to}% -Except that any class member declared \tcode{mutable}~(\ref{dcl.stc}) +Except that any class member declared \tcode{mutable}\iref{dcl.stc} can be modified, any attempt to modify a \tcode{const} object during its -lifetime~(\ref{basic.life}) results in undefined behavior. +lifetime\iref{basic.life} results in undefined behavior. \begin{example} \begin{codeblock} const int ci = 3; // cv-qualified (initialized as required) @@ -1279,19 +1279,19 @@ \indextext{\idxgram{lambda-introducer}}% The \grammarterm{simple-type-specifier} \tcode{auto} is a placeholder for -a type to be deduced~(\ref{dcl.spec.auto}). +a type to be deduced\iref{dcl.spec.auto}. \indextext{deduction!class template arguments}% A \grammarterm{type-specifier} of the form \tcode{typename}\opt{} \grammarterm{nested-name-specifier}\opt{} \grammarterm{template-name} is a placeholder for -a deduced class type~(\ref{dcl.type.class.deduct}). +a deduced class type\iref{dcl.type.class.deduct}. The \grammarterm{template-name} shall name a class template that is not an injected-class-name. The other \grammarterm{simple-type-specifier}{s} specify either a previously-declared type, a type determined from an expression, or one of the -fundamental types~(\ref{basic.fundamental}). +fundamental types\iref{basic.fundamental}. Table~\ref{tab:simple.type.specifiers} summarizes the valid combinations of \grammarterm{simple-type-specifier}{s} @@ -1302,47 +1302,48 @@ {tab:simple.type.specifiers} {ll} \topline -\hdstyle{Specifier(s)} & \hdstyle{Type} \\ \capsep -\grammarterm{type-name} & the type named \\ -\grammarterm{simple-template-id} & the type as defined in~\ref{temp.names} \\ -\grammarterm{template-name} & placeholder for a type to be deduced\\ -char & ``char'' \\ -unsigned char & ``unsigned char'' \\ -signed char & ``signed char'' \\ -char16_t & ``char16_t'' \\ -char32_t & ``char32_t'' \\ -bool & ``bool'' \\ -unsigned & ``unsigned int'' \\ -unsigned int & ``unsigned int'' \\ -signed & ``int'' \\ -signed int & ``int'' \\ -int & ``int'' \\ -unsigned short int & ``unsigned short int'' \\ -unsigned short & ``unsigned short int'' \\ -unsigned long int & ``unsigned long int'' \\ -unsigned long & ``unsigned long int'' \\ -unsigned long long int & ``unsigned long long int''\\ -unsigned long long & ``unsigned long long int''\\ -signed long int & ``long int'' \\ -signed long & ``long int'' \\ -signed long long int & ``long long int'' \\ -signed long long & ``long long int'' \\ -long long int & ``long long int'' \\ -long long & ``long long int'' \\ -long int & ``long int'' \\ -long & ``long int'' \\ -signed short int & ``short int'' \\ -signed short & ``short int'' \\ -short int & ``short int'' \\ -short & ``short int'' \\ -wchar_t & ``wchar_t'' \\ -float & ``float'' \\ -double & ``double'' \\ -long double & ``long double'' \\ -void & ``void'' \\ -auto & placeholder for a type to be deduced\\ -decltype(auto) & placeholder for a type to be deduced\\ -decltype(\grammarterm{expression}) & the type as defined below\\ +\hdstyle{Specifier(s)} & \hdstyle{Type} \\ \capsep +\grammarterm{type-name} & the type named \\ +\grammarterm{simple-template-id} & the type as defined in~\ref{temp.names}\\ +\grammarterm{template-name} & placeholder for a type to be deduced\\ +\tcode{char} & ``\tcode{char}'' \\ +\tcode{unsigned char} & ``\tcode{unsigned char}'' \\ +\tcode{signed char} & ``\tcode{signed char}'' \\ +\tcode{char16_t} & ``\tcode{char16_t}'' \\ +\tcode{char32_t} & ``\tcode{char32_t}'' \\ +\tcode{bool} & ``\tcode{bool}'' \\ +\tcode{unsigned} & ``\tcode{unsigned int}'' \\ +\tcode{unsigned int} & ``\tcode{unsigned int}'' \\ +\tcode{signed} & ``\tcode{int}'' \\ +\tcode{signed int} & ``\tcode{int}'' \\ +\tcode{int} & ``\tcode{int}'' \\ +\tcode{unsigned short int} & ``\tcode{unsigned short int}'' \\ +\tcode{unsigned short} & ``\tcode{unsigned short int}'' \\ +\tcode{unsigned long int} & ``\tcode{unsigned long int}'' \\ +\tcode{unsigned long} & ``\tcode{unsigned long int}'' \\ +\tcode{unsigned long long int} & ``\tcode{unsigned long long int}''\\ +\tcode{unsigned long long} & ``\tcode{unsigned long long int}''\\ +\tcode{signed long int} & ``\tcode{long int}'' \\ +\tcode{signed long} & ``\tcode{long int}'' \\ +\tcode{signed long long int} & ``\tcode{long long int}'' \\ +\tcode{signed long long} & ``\tcode{long long int}'' \\ +\tcode{long long int} & ``\tcode{long long int}'' \\ +\tcode{long long} & ``\tcode{long long int}'' \\ +\tcode{long int} & ``\tcode{long int}'' \\ +\tcode{long} & ``\tcode{long int}'' \\ +\tcode{signed short int} & ``\tcode{short int}'' \\ +\tcode{signed short} & ``\tcode{short int}'' \\ +\tcode{short int} & ``\tcode{short int}'' \\ +\tcode{short} & ``\tcode{short int}'' \\ +\tcode{wchar_t} & ``\tcode{wchar_t}'' \\ +\tcode{float} & ``\tcode{float}'' \\ +\tcode{double} & ``\tcode{double}'' \\ +\tcode{long double} & ``\tcode{long double}'' \\ +\tcode{void} & ``\tcode{void}'' \\ +\tcode{auto} & placeholder for a type to be deduced\\ +\tcode{decltype(auto)} & placeholder for a type to be deduced\\ +\tcode{decltype(}\grammartermnc{expression}\tcode{)} + & the type as defined below\\ \end{simpletypetable} \pnum @@ -1360,14 +1361,14 @@ \begin{itemize} \item if \tcode{e} is an unparenthesized \grammarterm{id-expression} -naming a structured binding~(\ref{dcl.struct.bind}), +naming a structured binding\iref{dcl.struct.bind}, \tcode{decltype(e)} is the referenced type as given in the specification of the structured binding declaration; \item otherwise, if \tcode{e} is an unparenthesized \grammarterm{id-expression} or an unparenthesized class -member access~(\ref{expr.ref}), \tcode{decltype(e)} is the +member access\iref{expr.ref}, \tcode{decltype(e)} is the type of the entity named by \tcode{e}. If there is no such entity, or if \tcode{e} names a set of overloaded functions, the program is ill-formed; @@ -1383,7 +1384,7 @@ \end{itemize} The operand of the \tcode{decltype} specifier is an unevaluated -operand (Clause~\ref{expr}). +operand\iref{expr}. \begin{example} \begin{codeblock} @@ -1404,7 +1405,7 @@ \pnum If the operand of a \grammarterm{decltype-specifier} is a prvalue, -the temporary materialization conversion is not applied~(\ref{conv.rval}) +the temporary materialization conversion is not applied\iref{conv.rval} and no result object is provided for the prvalue. The type of the prvalue may be incomplete. \begin{note} @@ -1436,7 +1437,7 @@ -> 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 + // fails\iref{temp.deduct} because \tcode{A::\tilde{}A()} is implicitly used in its // \grammarterm{decltype-specifier}) } template auto q(T) @@ -1471,8 +1472,8 @@ unless the latter is the sole constituent of a declaration. If an \grammarterm{elaborated-type-specifier} is the sole constituent of a declaration, the declaration is ill-formed unless it is an explicit -specialization~(\ref{temp.expl.spec}), an explicit -instantiation~(\ref{temp.explicit}) or it has one of the following +specialization\iref{temp.expl.spec}, an explicit +instantiation\iref{temp.explicit} or it has one of the following forms: \begin{ncsimplebnf} @@ -1508,7 +1509,7 @@ friend class T; \end{codeblock} -is ill-formed. However, the similar declaration \tcode{friend T;} is allowed~(\ref{class.friend}). +is ill-formed. However, the similar declaration \tcode{friend T;} is allowed\iref{class.friend}. \end{note} \pnum @@ -1522,11 +1523,11 @@ as referring to the definition of the class. Thus, in any \grammarterm{elaborated-type-specifier}, the \tcode{enum} keyword shall be -used to refer to an enumeration~(\ref{dcl.enum}), the \tcode{union} -\grammarterm{class-key} shall be used to refer to a union -(Clause~\ref{class}), and either the \tcode{class} or \tcode{struct} -\grammarterm{class-key} shall be used to refer to a class -(Clause~\ref{class}) declared using the \tcode{class} or \tcode{struct} +used to refer to an enumeration\iref{dcl.enum}, the \tcode{union} +\grammarterm{class-key} shall be used to refer to a union\iref{class}, +and either the \tcode{class} or \tcode{struct} +\grammarterm{class-key} shall be used to refer to a class\iref{class} +declared using the \tcode{class} or \tcode{struct} \grammarterm{class-key}. \begin{example} \begin{codeblock} @@ -1545,39 +1546,28 @@ from an initializer. The \tcode{auto} \grammarterm{type-specifier} is also used to introduce a function type having a \grammarterm{trailing-return-type} or to -signify that a lambda is a generic lambda (\ref{expr.prim.lambda.closure}). +signify that a lambda is a generic lambda\iref{expr.prim.lambda}. The \tcode{auto} \grammarterm{type-specifier} is also used to introduce a -structured binding declaration (\ref{dcl.struct.bind}). +structured binding declaration\iref{dcl.struct.bind}. \pnum The placeholder type can appear with a function declarator in the \grammarterm{decl-specifier-seq}, \grammarterm{type-specifier-seq}, \grammarterm{conversion-function-id}, or \grammarterm{trailing-return-type}, in any context where such a declarator is valid. If the function declarator -includes a \grammarterm{trailing-return-type}~(\ref{dcl.fct}), that +includes a \grammarterm{trailing-return-type}\iref{dcl.fct}, that \grammarterm{trailing-return-type} specifies the declared return type of the function. Otherwise, the function declarator shall declare a function. If the declared return type of the function contains a placeholder type, the return type of the function is deduced from non-discarded \tcode{return} statements, if any, in the body -of the function~(\ref{stmt.if}). - -\pnum -If the \tcode{auto} \grammarterm{type-specifier} appears as one of the -\grammarterm{decl-specifier}{s} in the \grammarterm{decl-specifier-seq} of a -\grammarterm{parameter-declaration} of a \grammarterm{lambda-expression}, the -\indextext{generic lambda!definition of}% -lambda is a \term{generic lambda}~(\ref{expr.prim.lambda.closure}). \begin{example} -\begin{codeblock} -auto glambda = [](int i, auto a) { return i; }; // OK: a generic lambda -\end{codeblock} -\end{example} +of the function\iref{stmt.if}. \pnum The type of a variable declared using \tcode{auto} or \tcode{decltype(auto)} is deduced from its initializer. This use is allowed -in an initializing declaration~(\ref{dcl.init}) of a variable. +in an initializing declaration\iref{dcl.init} of a variable. \tcode{auto} or \tcode{decltype(auto)} shall appear as one of the \grammarterm{decl-specifier}{s} in the \grammarterm{decl-specifier-seq} and the @@ -1611,11 +1601,11 @@ A placeholder type can also be used in the \grammarterm{type-specifier-seq} in the \grammarterm{new-type-id} or \grammarterm{type-id} of a -\grammarterm{new-expression}~(\ref{expr.new}) +\grammarterm{new-expression}\iref{expr.new} and as a \grammarterm{decl-specifier} of the \grammarterm{parameter-declaration}{'s} \grammarterm{decl-specifier-seq} -in a \grammarterm{template-parameter}~(\ref{temp.param}). +in a \grammarterm{template-parameter}\iref{temp.param}. \pnum A program that uses \tcode{auto} or \tcode{decltype(auto)} in a context not @@ -1625,7 +1615,7 @@ If the \grammarterm{init-declarator-list} contains more than one \grammarterm{init-declarator}, they shall all form declarations of variables. The type of each declared variable is determined -by placeholder type deduction~(\ref{dcl.type.auto.deduct}), +by placeholder type deduction\iref{dcl.type.auto.deduct}, and if the type that replaces the placeholder type is not the same in each deduction, the program is ill-formed. @@ -1681,7 +1671,7 @@ \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~(\ref{temp.deduct}). \end{note} +program being ill-formed\iref{temp.deduct}. \end{note} \begin{example} \begin{codeblock} template auto f(T t) { return t; } // return type deduced at instantiation time @@ -1724,10 +1714,10 @@ \pnum A function declared with a return type that uses a placeholder type shall not -be \tcode{virtual}~(\ref{class.virtual}). +be \tcode{virtual}\iref{class.virtual}. \pnum -An explicit instantiation declaration~(\ref{temp.explicit}) does not cause the +An explicit instantiation declaration\iref{temp.explicit} does not cause the instantiation of an entity declared using a placeholder type, but it also does not prevent that entity from being instantiated as needed to determine its type. @@ -1787,7 +1777,7 @@ \pnum If the deduction is for a \tcode{return} statement -and \tcode{e} is a \grammarterm{braced-init-list}~(\ref{dcl.init.list}), +and \tcode{e} is a \grammarterm{braced-init-list}\iref{dcl.init.list}, the program is ill-formed. \pnum @@ -1800,7 +1790,7 @@ invented type template parameter \tcode{U} or, if the initialization is copy-list-initialization, with \tcode{std::initializer_list}. Deduce a value for \tcode{U} using the rules -of template argument deduction from a function call~(\ref{temp.deduct.call}), +of template argument deduction from a function call\iref{temp.deduct.call}, where \tcode{P} is a function template parameter type and the corresponding argument is \tcode{e}. @@ -1860,10 +1850,10 @@ If a placeholder for a deduced class type appears as a \grammarterm{decl-specifier} in the \grammarterm{decl-specifier-seq} -of an initializing declaration~(\ref{dcl.init}) of a variable, +of an initializing declaration\iref{dcl.init} of a variable, the placeholder is replaced by the return type of the function selected by overload resolution -for class template deduction~(\ref{over.match.class.deduct}). +for class template deduction\iref{over.match.class.deduct}. If the \grammarterm{decl-specifier-seq} is followed by an \grammarterm{init-declarator-list} or \grammarterm{member-declarator-list} @@ -1875,10 +1865,10 @@ can also be used in the \grammarterm{type-specifier-seq} in the \grammarterm{new-type-id} or \grammarterm{type-id} -of a \grammarterm{new-expression}~(\ref{expr.new}), +of a \grammarterm{new-expression}\iref{expr.new}, or as the \grammarterm{simple-type-specifier} -in an explicit type conversion (functional notation)~(\ref{expr.type.conv}). +in an explicit type conversion (functional notation)\iref{expr.type.conv}. A placeholder for a deduced class type shall not appear in any other context. @@ -1906,7 +1896,7 @@ \indextext{\idxcode{enum}!type of} \pnum -An enumeration is a distinct type~(\ref{basic.compound}) with named +An enumeration is a distinct type\iref{basic.compound} with named constants. Its name becomes an \grammarterm{enum-name} within its scope. \begin{bnf} @@ -1987,7 +1977,7 @@ \end{note} If an \grammarterm{opaque-enum-declaration} contains a \grammarterm{nested-name-specifier}, -the declaration shall be an explicit specialization~(\ref{temp.expl.spec}). +the declaration shall be an explicit specialization\iref{temp.expl.spec}. \pnum \indextext{constant!enumeration}% @@ -2058,7 +2048,7 @@ The underlying type can be explicitly specified using an \grammarterm{enum-base}. For a scoped enumeration type, the underlying type is \tcode{int} if it is not explicitly specified. In both of these cases, the underlying type is said to be -\term{fixed}. +\defnx{fixed}{type!underlying!fixed}. Following the closing brace of an \grammarterm{enum-specifier}, each enumerator has the type of its enumeration. If the underlying type is fixed, the type of each enumerator @@ -2066,7 +2056,7 @@ type and the \grammarterm{constant-expression} in the \grammarterm{enumerator-definition} shall be a converted constant expression of the underlying -type~(\ref{expr.const}). +type\iref{expr.const}. If the underlying type is not fixed, the type of each enumerator prior to the closing brace is determined as @@ -2076,7 +2066,7 @@ \item If an initializer is specified for an enumerator, the \grammarterm{constant-expression} shall be an integral constant -expression~(\ref{expr.const}). If the expression has +expression\iref{expr.const}. If the expression has unscoped enumeration type, the enumerator has the underlying type of that enumeration type, otherwise it has the same type as the expression. @@ -2093,7 +2083,7 @@ \pnum An enumeration whose underlying type is fixed is an incomplete type from its -point of declaration~(\ref{basic.scope.pdecl}) to immediately after its +point of declaration\iref{basic.scope.pdecl} to immediately after its \grammarterm{enum-base} (if any), at which point it becomes a complete type. An enumeration whose underlying type is not fixed is an incomplete type from its point of declaration to immediately after the closing \tcode{\}} of its @@ -2143,7 +2133,7 @@ \pnum The value of an enumerator or an object of an unscoped enumeration type is -converted to an integer by integral promotion~(\ref{conv.prom}). +converted to an integer by integral promotion\iref{conv.prom}. \begin{example} \indextext{example!enumeration}% \begin{codeblock} @@ -2228,7 +2218,7 @@ the \grammarterm{enum-specifier} shall refer to an enumeration that was previously declared directly in the class or namespace to which the \grammarterm{nested-name-specifier} refers, or -in an element of the inline namespace set~(\ref{namespace.def}) +in an element of the inline namespace set\iref{namespace.def} of that namespace (i.e., not merely inherited or introduced by a \grammarterm{using-declaration}), and the \grammarterm{enum-specifier} shall appear in @@ -2296,12 +2286,12 @@ \pnum Every \grammarterm{namespace-definition} shall appear in the global scope -or in a namespace scope~(\ref{basic.scope.namespace}). +or in a namespace scope\iref{basic.scope.namespace}. \pnum In a \grammarterm{named-namespace-definition}, the \grammarterm{identifier} is the name of the namespace. -If the \grammarterm{identifier}, when looked up~(\ref{basic.lookup.unqual}), +If the \grammarterm{identifier}, when looked up\iref{basic.lookup.unqual}, refers to a \grammarterm{namespace-name} (but not a \grammarterm{namespace-alias}) that was introduced in the namespace in which the \grammarterm{named-namespace-definition} appears @@ -2371,15 +2361,15 @@ Members of an inline namespace can be used in most respects as though they were members of the enclosing namespace. Specifically, the inline namespace and its enclosing namespace are both added to the set of associated namespaces used in -argument-dependent lookup~(\ref{basic.lookup.argdep}) whenever one of them is, -and a \grammarterm{using-directive}~(\ref{namespace.udir}) that names the inline +argument-dependent lookup\iref{basic.lookup.argdep} whenever one of them is, +and a \grammarterm{using-directive}\iref{namespace.udir} that names the inline namespace is implicitly inserted into the enclosing namespace as for an unnamed -namespace~(\ref{namespace.unnamed}). Furthermore, each +namespace\iref{namespace.unnamed}. Furthermore, each member of the inline namespace can subsequently be partially -specialized~(\ref{temp.class.spec}), explicitly -instantiated~(\ref{temp.explicit}), or explicitly specialized~(\ref{temp.expl.spec}) as +specialized\iref{temp.class.spec}, explicitly +instantiated\iref{temp.explicit}, or explicitly specialized\iref{temp.expl.spec} as though it were a member of the enclosing namespace. Finally, looking up a name in the -enclosing namespace via explicit qualification~(\ref{namespace.qual}) will include +enclosing namespace via explicit qualification\iref{namespace.qual} will include members of the inline namespace brought in by the \grammarterm{using-directive} even if there are declarations of that name in the enclosing namespace. @@ -2469,17 +2459,17 @@ \pnum A declaration in a namespace \tcode{N} (excluding declarations in nested scopes) -whose \grammarterm{declarator-id} is an \grammarterm{unqualified-id}~(\ref{dcl.meaning}), -whose \grammarterm{class-head-name} (Clause \ref{class}) or -\grammarterm{enum-head-name}~(\ref{dcl.enum}) is an \grammarterm{identifier}, or +whose \grammarterm{declarator-id} is an \grammarterm{unqualified-id}\iref{dcl.meaning}, +whose \grammarterm{class-head-name}\iref{class} or +\grammarterm{enum-head-name}\iref{dcl.enum} is an \grammarterm{identifier}, or whose \grammarterm{elaborated-type-specifier} is of the form \grammarterm{class-key} -\grammarterm{attribute-specifier-seq}\opt{} \grammarterm{identifier}~(\ref{dcl.type.elab}), or +\grammarterm{attribute-specifier-seq}\opt{} \grammarterm{identifier}\iref{dcl.type.elab}, or 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 -explicit specialization~(\ref{temp.expl.spec}) of a template +An explicit instantiation\iref{temp.explicit} or +explicit specialization\iref{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. @@ -2501,7 +2491,7 @@ \pnum Members of a named namespace can also be defined outside that namespace by explicit -qualification~(\ref{namespace.qual}) of the name being defined, provided +qualification\iref{namespace.qual} of the name being defined, provided that the entity being defined was already declared in the namespace and the definition appears after the point of declaration in a namespace that encloses the declaration's namespace. @@ -2529,15 +2519,15 @@ class, function, class template or function template\footnote{this implies that the name of the class or function is unqualified.} the friend is a member of the innermost enclosing namespace. The \tcode{friend} declaration does not by itself make the name -visible to unqualified lookup~(\ref{basic.lookup.unqual}) or qualified -lookup~(\ref{basic.lookup.qual}). \begin{note} The name of the friend will be +visible to unqualified lookup\iref{basic.lookup.unqual} or qualified +lookup\iref{basic.lookup.qual}. \begin{note} The name of the friend will be visible in its namespace if a matching declaration is provided at namespace scope (either before or after the class definition granting friendship). \end{note} If a friend function or function template is called, its name may be found by the name lookup that considers functions from namespaces and classes associated with the types of the function -arguments~(\ref{basic.lookup.argdep}). If the +arguments\iref{basic.lookup.argdep}. If the name in a \tcode{friend} declaration is neither qualified nor a \grammarterm{template-id} and the declaration is a function or an \grammarterm{elaborated-type-specifier}, the lookup to determine whether @@ -2738,11 +2728,11 @@ destructor for a base class. Since specializations of member templates for conversion functions are not found by name lookup, they are not considered when a \grammarterm{using-declaration} specifies a conversion -function~(\ref{temp.mem}). +function\iref{temp.mem}. \end{note} If a constructor or assignment operator brought from a base class into a derived class has the signature of a copy/move constructor or assignment operator -for the derived class~(\ref{class.copy}), +for the derived class\iref{class.copy}, the \grammarterm{using-declaration} does not by itself suppress the implicit declaration of the derived class member; the member from the base class is hidden or overridden @@ -2791,7 +2781,7 @@ \pnum Members declared by a \grammarterm{using-declaration} can be referred to by explicit qualification just like other member -names~(\ref{namespace.qual}). +names\iref{namespace.qual}. \begin{example} \begin{codeblock} void f(); @@ -2845,8 +2835,8 @@ are not in the set of introduced declarations, so they are not considered when a use of the name is made. Thus, additional overloads added after the \grammarterm{using-declaration} are ignored, but -default function arguments~(\ref{dcl.fct.default}), default template -arguments~(\ref{temp.param}), and template specializations~(\ref{temp.class.spec}, +default function arguments\iref{dcl.fct.default}, default template +arguments\iref{temp.param}, and template specializations~(\ref{temp.class.spec}, \ref{temp.expl.spec}) are considered. \end{note} \begin{example} @@ -2878,13 +2868,13 @@ of that template. If a \grammarterm{using-declaration} names a class template, partial specializations introduced after the \grammarterm{using-declaration} are effectively visible because the primary -template is visible~(\ref{temp.class.spec}). +template is visible\iref{temp.class.spec}. \end{note} \pnum Since a \grammarterm{using-declaration} is a declaration, the restrictions on declarations of the same name in the same declarative -region~(\ref{basic.scope}) also apply to \grammarterm{using-declaration}{s}. +region\iref{basic.scope} also apply to \grammarterm{using-declaration}{s}. \begin{example} \begin{codeblock} @@ -2920,7 +2910,7 @@ \pnum If a function declaration in namespace scope or block scope has the same -name and the same parameter-type-list~(\ref{dcl.fct}) as +name and the same parameter-type-list\iref{dcl.fct} as a function introduced by a \grammarterm{using-declaration}, and the declarations do not declare the same function, the program is ill-formed. If a function template declaration in namespace scope has @@ -2963,7 +2953,7 @@ a derived class, member functions and member function templates in the derived class override and/or hide member functions and member function templates with the same name, -parameter-type-list~(\ref{dcl.fct}), cv-qualification, and \grammarterm{ref-qualifier} (if any) in a base +parameter-type-list\iref{dcl.fct}, cv-qualification, and \grammarterm{ref-qualifier} (if any) in a base class (rather than conflicting). Such hidden or overridden declarations are excluded from the set of declarations introduced by the \grammarterm{using-declarator}. @@ -3021,7 +3011,8 @@ \pnum \indextext{overloading!using-declaration and}% -For the purpose of overload resolution, the functions that are +For the purpose of forming a set of candidates during overload resolution, +the functions that are introduced by a \grammarterm{using-declaration} into a derived class are treated as though they were members of the derived class. In particular, the implicit \tcode{this} parameter shall be treated as if @@ -3030,12 +3021,16 @@ respects the function remains a member of the base class. Likewise, constructors that are introduced by a \grammarterm{using-declaration} are treated as though they were constructors of the derived class -when looking up the constructors of the derived class~(\ref{class.qual}) +when looking up the constructors of the derived class\iref{class.qual} or forming a set of overload candidates~(\ref{over.match.ctor}, \ref{over.match.copy}, \ref{over.match.list}). If such a constructor is selected to perform the initialization of an object of class type, all subobjects other than the base class from which the constructor originated -are implicitly initialized~(\ref{class.inhctor.init}). +are implicitly initialized\iref{class.inhctor.init}. +\begin{note} +A member of a derived class is sometimes preferred to a member of a base class +if they would otherwise be ambiguous\iref{over.match.best}. +\end{note} \pnum \indextext{access control!using-declaration and}% @@ -3107,9 +3102,9 @@ \pnum If a \grammarterm{using-declarator} uses the keyword \tcode{typename} and -specifies a dependent name~(\ref{temp.dep}), the name introduced by the +specifies a dependent name\iref{temp.dep}, the name introduced by the \grammarterm{using-declaration} is treated as a -\grammarterm{typedef-name}~(\ref{dcl.typedef}).% +\grammarterm{typedef-name}\iref{dcl.typedef}.% \indextext{using-declaration|)} \rSec2[namespace.udir]{Using directive}% @@ -3134,7 +3129,7 @@ A \grammarterm{using-directive} specifies that the names in the nominated namespace can be used in the scope in which the \grammarterm{using-directive} appears after the \grammarterm{using-directive}. -During unqualified name lookup~(\ref{basic.lookup.unqual}), the names +During unqualified name lookup\iref{basic.lookup.unqual}, the names appear as if they were declared in the nearest enclosing namespace which contains both the \grammarterm{using-directive} and the nominated namespace. @@ -3177,7 +3172,7 @@ \end{example} \pnum -For unqualified lookup~(\ref{basic.lookup.unqual}), the +For unqualified lookup\iref{basic.lookup.unqual}, the \grammarterm{using-directive} is transitive: if a scope contains a \grammarterm{using-directive} that nominates a second namespace that itself contains \grammarterm{using-directive}{s}, the effect is as if the @@ -3230,7 +3225,7 @@ \pnum -If a namespace is extended~(\ref{namespace.def}) after a +If a namespace is extended\iref{namespace.def} after a \grammarterm{using-directive} for that namespace is given, the additional members of the extended namespace and the members of namespaces nominated by \grammarterm{using-directive}{s} in the @@ -3284,7 +3279,7 @@ \grammarterm{using-directive}{s} in the namespace of the other.\footnote{During name lookup in a class hierarchy, some ambiguities may be resolved by considering whether one member hides the other along some -paths~(\ref{class.member.lookup}). There is no such disambiguation when +paths\iref{class.member.lookup}. There is no such disambiguation when considering the set of names found as a result of following \grammarterm{using-directive}{s}.} \begin{example} @@ -3364,7 +3359,7 @@ otherwise identical. \pnum -Linkage~(\ref{basic.link}) between \Cpp and non-\Cpp code fragments can +Linkage\iref{basic.link} between \Cpp and non-\Cpp code fragments can be achieved using a \grammarterm{linkage-specification}: \indextext{\idxgram{linkage-specification}}% @@ -3412,7 +3407,7 @@ Linkage specifications nest. When linkage specifications nest, the innermost one determines the language linkage. A linkage specification does not establish a scope. A \grammarterm{linkage-specification} shall -occur only in namespace scope~(\ref{basic.scope}). In a +occur only in namespace scope\iref{basic.scope}. In a \grammarterm{linkage-specification}, the specified language linkage applies to the function types of all function declarators, function names with external linkage, and variable names with external linkage declared @@ -3483,7 +3478,7 @@ \pnum If two declarations declare functions with the same name and -parameter-type-list~(\ref{dcl.fct}) to be members of the same +parameter-type-list\iref{dcl.fct} to be members of the same namespace or declare objects with the same name to be members of the same namespace and the declarations give the names different language linkages, the program is ill-formed; no diagnostic is required if the declarations appear in @@ -3547,7 +3542,7 @@ \grammarterm{linkage-specification} is treated as if it contains the \tcode{extern} -specifier~(\ref{dcl.stc}) for the purpose of determining the linkage of the +specifier\iref{dcl.stc} for the purpose of determining the linkage of the declared name and whether it is a definition. Such a declaration shall not specify a storage class. \begin{example} @@ -3693,30 +3688,30 @@ \pnum In an \grammarterm{attribute-list}, an ellipsis may appear only if that \grammarterm{attribute}'s specification permits it. An \grammarterm{attribute} followed -by an ellipsis is a pack expansion~(\ref{temp.variadic}). +by an ellipsis is a pack expansion\iref{temp.variadic}. An \grammarterm{attribute-specifier} that contains no \grammarterm{attribute}{s} has no effect. The order in which the \grammarterm{attribute-token}{s} appear in an \grammarterm{attribute-list} is not significant. If a -keyword~(\ref{lex.key}) -or an alternative token~(\ref{lex.digraph}) that satisfies the syntactic requirements -of an \grammarterm{identifier}~(\ref{lex.name}) is +keyword\iref{lex.key} +or an alternative token\iref{lex.digraph} that satisfies the syntactic requirements +of an \grammarterm{identifier}\iref{lex.name} is contained in an \grammarterm{attribute-token}, it is considered an identifier. No name -lookup~(\ref{basic.lookup}) is performed on any of the identifiers contained in an +lookup\iref{basic.lookup} is performed on any of the identifiers contained in an \grammarterm{attribute-token}. The \grammarterm{attribute-token} determines additional requirements on the \grammarterm{attribute-argument-clause} (if any). \pnum Each \grammarterm{attribute-specifier-seq} is said to \defn{appertain} to some entity or statement, identified by the syntactic context where it appears -(Clause~\ref{stmt.stmt}, Clause~\ref{dcl.dcl}, -Clause~\ref{dcl.decl}). If an \grammarterm{attribute-specifier-seq} that appertains to some +(\ref{stmt.stmt}, \ref{dcl.dcl}, +\ref{dcl.decl}). If an \grammarterm{attribute-specifier-seq} that appertains to some entity or statement contains an \grammarterm{attribute} or \grammarterm{alignment-specifier} that is not allowed to apply to that entity or statement, the program is ill-formed. If an \grammarterm{attribute-specifier-seq} -appertains to a friend declaration~(\ref{class.friend}), that declaration shall be a +appertains to a friend declaration\iref{class.friend}, that declaration shall be a definition. No \grammarterm{attribute-specifier-seq} shall appertain to an explicit -instantiation~(\ref{temp.explicit}). +instantiation\iref{temp.explicit}. \pnum For an \grammarterm{attribute-token} @@ -3752,20 +3747,21 @@ \rSec2[dcl.align]{Alignment specifier}% \indextext{attribute!alignment} +\indextext{\idxcode{alignas}} \pnum An \grammarterm{alignment-specifier} may be applied to a variable or to a class data member, but it shall not be applied to a bit-field, a function -parameter, or an \grammarterm{exception-declaration}~(\ref{except.handle}). +parameter, or an \grammarterm{exception-declaration}\iref{except.handle}. An \grammarterm{alignment-specifier} may also be applied to the declaration or definition of a class (in an -\grammarterm{elaborated-type-specifier}~(\ref{dcl.type.elab}) or -\grammarterm{class-head} (Clause~\ref{class}), respectively) and to the +\grammarterm{elaborated-type-specifier}\iref{dcl.type.elab} or +\grammarterm{class-head}\iref{class}, respectively) and to the declaration or definition of an enumeration (in an \grammarterm{opaque-enum-declaration} or \grammarterm{enum-head}, -respectively~(\ref{dcl.enum})). -An \grammarterm{alignment-specifier} with an ellipsis is a pack expansion~(\ref{temp.variadic}). +respectively\iref{dcl.enum}). +An \grammarterm{alignment-specifier} with an ellipsis is a pack expansion\iref{temp.variadic}. \pnum When the \grammarterm{alignment-specifier} is of the form @@ -3775,7 +3771,7 @@ \item the \grammarterm{constant-expression} shall be an integral constant expression \item if the constant expression does not evaluate to an alignment -value~(\ref{basic.align}), or evaluates to an extended alignment and +value\iref{basic.align}, or evaluates to an extended alignment and the implementation does not support that alignment in the context of the declaration, the program is ill-formed. \end{itemize} @@ -3783,7 +3779,7 @@ \pnum An \grammarterm{alignment-specifier} of the form \tcode{alignas(} \grammarterm{type-id} \tcode{)} has the same -effect as \tcode{alignas(\brk{}alignof(} \grammarterm{type-id}~\tcode{))}~(\ref{expr.alignof}). +effect as \tcode{alignas(\brk{}alignof(} \grammarterm{type-id}~\tcode{))}\iref{expr.alignof}. \pnum The alignment requirement of an entity is the strictest nonzero alignment @@ -3862,8 +3858,8 @@ applied to the \grammarterm{declarator-id} of a \grammarterm{parameter-declaration} in a function declaration or lambda, in which case it specifies that the initialization of the parameter carries a -dependency to~(\ref{intro.multithread}) each lvalue-to-rvalue -conversion~(\ref{conv.lval}) of that object. The attribute may also be applied +dependency to\iref{intro.multithread} each lvalue-to-rvalue +conversion\iref{conv.lval} of that object. The attribute may also be applied to the \grammarterm{declarator-id} of a function declaration, in which case it specifies that the return value, if any, carries a dependency to the evaluation of the function call expression. @@ -3927,7 +3923,6 @@ \tcode{g} carries a dependency into \tcode{g}, but its second call does not. The implementation might need to insert a fence prior to the second call to \tcode{g}. - \end{example}% \indextext{attribute|)}% \indextext{declaration|)} @@ -3982,14 +3977,14 @@ \pnum The \grammarterm{attribute-token} \tcode{fallthrough} -may be applied to a null statement~(\ref{stmt.expr}); +may be applied to a null statement\iref{stmt.expr}; \indextext{statement!fallthrough} such a statement is a fallthrough statement. The \grammarterm{attribute-token} \tcode{fallthrough} shall appear at most once in each \grammarterm{attribute-list} and no \grammarterm{attribute-argument-clause} shall be present. A fallthrough statement may only appear within -an enclosing \tcode{switch} statement~(\ref{stmt.switch}). +an enclosing \tcode{switch} statement\iref{stmt.switch}. The next statement that would be executed after a fallthrough statement shall be a labeled statement whose label is a case label or default label for the same \tcode{switch} statement. @@ -4001,7 +3996,7 @@ a warning that an implementation might otherwise issue for a case or default label that is reachable from another case or default label along some path of execution. -Implementations are encouraged to issue a warning +Implementations should issue a warning if a fallthrough statement is not dynamically reachable. \end{note} @@ -4042,7 +4037,7 @@ \pnum \begin{note} For an entity marked \tcode{maybe_unused}, implementations -are encouraged not to emit a warning that the entity is unused, or +should not emit a warning that the entity is unused, or that the entity is used despite the presence of the attribute. \end{note} @@ -4062,7 +4057,7 @@ assert(b); } \end{codeblock} -Implementations are encouraged not to warn that \tcode{b} is unused, +Implementations should not warn that \tcode{b} is unused, whether or not \tcode{NDEBUG} is defined. \end{example} @@ -4082,9 +4077,9 @@ calls a function previously declared \tcode{nodiscard}, or whose return type is a possibly cv-qualified class or enumeration type marked \tcode{nodiscard}. Appearance of a nodiscard call as -a potentially-evaluated discarded-value expression (Clause~\ref{expr}) +a potentially-evaluated discarded-value expression\iref{expr} is discouraged unless explicitly cast to \tcode{void}. -Implementations are encouraged to issue a warning in such cases. +Implementations should issue a warning in such cases. This is typically because discarding the return value of a nodiscard call has surprising consequences. \end{note} @@ -4121,7 +4116,7 @@ \pnum If a function \tcode{f} is called where \tcode{f} was previously declared with the \tcode{noreturn} attribute and \tcode{f} eventually returns, the behavior is undefined. \begin{note} The function may -terminate by throwing an exception. \end{note} \begin{note} Implementations are encouraged to issue a +terminate by throwing an exception. \end{note} \begin{note} Implementations should issue a warning if a function marked \tcode{[[noreturn]]} might return. \end{note} \pnum diff --git a/source/declarators.tex b/source/declarators.tex index 5c884c27cb..f148e29f1e 100644 --- a/source/declarators.tex +++ b/source/declarators.tex @@ -27,14 +27,15 @@ \begin{bnf} \nontermdef{init-declarator}\br - declarator initializer\opt + declarator initializer\opt\br + declarator requires-clause \end{bnf} \pnum The three components of a \grammarterm{simple-declaration} are the -attributes~(\ref{dcl.attr}), the +attributes\iref{dcl.attr}, the specifiers (\grammarterm{decl-specifier-seq}; \ref{dcl.spec}) and the declarators @@ -83,7 +84,7 @@ S S; S T; // error \end{codeblock} -Another exception is when \tcode{T} is \tcode{auto}~(\ref{dcl.spec.auto}), +Another exception is when \tcode{T} is \tcode{auto}\iref{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 @@ -95,6 +96,32 @@ \end{codeblock} \end{note} +\pnum +The optional \grammarterm{requires-clause}\iref{temp} in an +\grammarterm{init-declarator} or \grammarterm{member-declarator} +shall not be present when the declarator does not declare a +function\iref{dcl.fct}. +% +When present after a declarator, the \grammarterm{requires-clause} +is called the \defnx{trailing \grammarterm{requires-clause}{}}{% +trailing requires-clause@trailing \grammarterm{requires-clause}}. +The trailing \grammarterm{requires-clause} introduces the +\grammarterm{constraint-expression} that results from interpreting +its \grammarterm{constraint-logical-or-expression} as a +\grammarterm{constraint-expression}. +% +\begin{example} +\begin{codeblock} +void f1(int a) requires true; // OK +auto f2(int a) -> bool requires true; // OK +auto f3(int a) requires true -> bool; // error: \grammarterm{requires-clause} precedes \grammarterm{trailing-return-type} +void (*pf)() requires true; // error: constraint on a variable +void g(int (*)() requires true); // error: constraint on a \grammarterm{parameter-declaration} + +auto* p = new void(*)(char) requires true; // error: not a function declaration +\end{codeblock} +\end{example} + \pnum Declarators have the syntax @@ -255,8 +282,7 @@ \pnum A type can also be named (often more easily) by using a -\tcode{typedef} -(\ref{dcl.typedef}). +\tcode{typedef}\iref{dcl.typedef}. \rSec1[dcl.ambig.res]{Ambiguity resolution}% \indextext{ambiguity!declaration versus cast}% @@ -380,14 +406,14 @@ except for the declaration of some special functions~(\ref{class.ctor}, \ref{class.conv}, \ref{class.dtor}, \ref{over.oper}) and for the declaration of template specializations -or partial specializations~(\ref{temp.spec}). +or partial specializations\iref{temp.spec}. When the \grammarterm{declarator-id} is qualified, the declaration shall refer to a previously declared member of the class or namespace to which the qualifier refers (or, in the case of a namespace, of an element of the inline namespace -set of that namespace~(\ref{namespace.def})) or to a specialization thereof; the member +set of that namespace\iref{namespace.def}) or to a specialization thereof; the member shall not merely have been introduced by a \grammarterm{using-declaration} in the scope of the class or namespace nominated by the @@ -468,8 +494,7 @@ \tcode{int} \tcode{unsigned} determine the type -``\tcode{unsigned int}'' -(\ref{dcl.type.simple}). +``\tcode{unsigned int}''\iref{dcl.type.simple}. \end{example} \pnum @@ -536,7 +561,7 @@ The \grammarterm{cv-qualifier}{s} apply to the pointer and not to the object pointed to. -Similarly, the optional \grammarterm{attribute-specifier-seq}~(\ref{dcl.attr.grammar}) appertains to the pointer and not to the object pointed to. +Similarly, the optional \grammarterm{attribute-specifier-seq}\iref{dcl.attr.grammar} appertains to the pointer and not to the object pointed to. \pnum \begin{example} @@ -616,7 +641,7 @@ Forming a function pointer type is ill-formed if the function type has \grammarterm{cv-qualifier}{s} or a \grammarterm{ref-qualifier}; see~\ref{dcl.fct}. -Since the address of a bit-field (\ref{class.bit}) cannot be taken, +Since the address of a bit-field\iref{class.bit} cannot be taken, a pointer can never point to a bit-field. \end{note} @@ -649,7 +674,7 @@ Cv-qualified references are ill-formed except when the cv-qualifiers are introduced through the use of a \grammarterm{typedef-name}~(\ref{dcl.typedef}, \ref{temp.param}) or -\grammarterm{decltype-specifier}~(\ref{dcl.type.simple}), +\grammarterm{decltype-specifier}\iref{dcl.type.simple}, in which case the cv-qualifiers are ignored. \begin{example} @@ -673,12 +698,10 @@ \pnum -\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 +\defn{lvalue reference}, and a reference type that is declared using \tcode{\&\&} is called an -\term{rvalue reference}. Lvalue references and +\defn{rvalue reference}. Lvalue references and rvalue references are distinct types. Except where explicitly noted, they are semantically equivalent and commonly referred to as references. @@ -756,7 +779,7 @@ \pnum It is unspecified whether or not -a reference requires storage (\ref{basic.stc}). +a reference requires storage\iref{basic.stc}. \pnum \indextext{restriction!reference}% @@ -764,13 +787,12 @@ no arrays of references, and no pointers to references. \indextext{initialization!reference}% The declaration of a reference shall contain an -\grammarterm{initializer} -(\ref{dcl.init.ref}) +\grammarterm{initializer}\iref{dcl.init.ref} except when the declaration contains an explicit \tcode{extern} -specifier (\ref{dcl.stc}), -is a class member (\ref{class.mem}) declaration within a class definition, -or is the declaration of a parameter or a return type (\ref{dcl.fct}); see~\ref{basic.def}. +specifier\iref{dcl.stc}, +is a class member\iref{class.mem} declaration within a class definition, +or is the declaration of a parameter or a return type\iref{dcl.fct}; see~\ref{basic.def}. A reference shall be initialized to refer to a valid object or function. \begin{note} \indextext{reference!null}% @@ -785,7 +807,7 @@ \pnum \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 +or a \grammarterm{decltype-specifier}\iref{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}. @@ -843,7 +865,7 @@ 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 +The optional \grammarterm{attribute-specifier-seq}\iref{dcl.attr.grammar} appertains to the pointer-to-member. \pnum @@ -911,7 +933,7 @@ \pnum A pointer to member shall not point to a static member -of a class (\ref{class.static}), +of a class\iref{class.static}, a member with reference type, or ``\cv{}~\tcode{void}''. @@ -957,8 +979,8 @@ a function type or an abstract class type. \indextext{declaration!array}% If the -\grammarterm{constant-expression} -(\ref{expr.const}) is present, it shall be a converted constant +\grammarterm{constant-expression}\iref{expr.const} +is present, it shall be a converted constant expression of type \tcode{std::size_t} and its value shall be greater than zero. The constant expression specifies the @@ -1036,25 +1058,27 @@ or from another array. \pnum -When several ``array of'' specifications are adjacent, a multidimensional -array type is created; +\indextext{declarator!multidimensional array}% +When several ``array of'' specifications are adjacent, a +multidimensional array +type is created; only the first of the constant expressions that specify the bounds of the arrays may be omitted. In addition to declarations in which an incomplete object type is allowed, an array bound may be omitted in some cases in the declaration of a function -parameter~(\ref{dcl.fct}). +parameter\iref{dcl.fct}. An array bound may also be omitted when the declarator is followed by an -\grammarterm{initializer}~(\ref{dcl.init}) or +\grammarterm{initializer}\iref{dcl.init} or when a declarator for a static data member is followed by a -\grammarterm{brace-or-equal-initializer}~(\ref{class.mem}). +\grammarterm{brace-or-equal-initializer}\iref{class.mem}. In both cases the bound is calculated from the number \indextext{array size!default}% of initial elements (say, \tcode{N}) -supplied -(\ref{dcl.init.aggr}), and the type of the identifier of +supplied\iref{dcl.init.aggr}, +and the type of the identifier of \tcode{D} is ``array of \tcode{N} @@ -1066,7 +1090,6 @@ \pnum \begin{example} -\indextext{example!subscripting}% \indextext{example!array}% \begin{codeblock} float fa[17], *afp[17]; @@ -1078,27 +1101,73 @@ pointers to \tcode{float} numbers. -\indextext{declarator!multidimensional array}% -For another example, +\end{example} +\pnum +\begin{example} \begin{codeblock} -static int x3d[3][5][7]; +int x3d[3][5][7]; \end{codeblock} -declares a static three-dimensional array of integers, +declares an array of three elements, +each of which is an array of five elements, +each of which is an array of seven integers. +The overall array can be viewed as a +three-dimensional array of integers, with rank $3 \times 5 \times 7$. -In complete detail, -\tcode{x3d} -is an array of three items; -each item is an array of five arrays; -each of the latter arrays is an array of seven -integers. Any of the expressions \tcode{x3d}, \tcode{x3d[i]}, \tcode{x3d[i][j]}, \tcode{x3d[i][j][k]} -can reasonably appear in an expression. Finally, +can reasonably appear in an expression. +\indextext{example!subscripting}% +The expression +\tcode{x3d[i]} +is equivalent to +\tcode{*(x3d + i)}; +in that expression, +\tcode{x3d} +is subject to the array-to-pointer conversion\iref{conv.array} +and is first converted to +a pointer to a 2-dimensional +array with rank +$5 \times 7$ +that points to the first element of \tcode{x3d}. +Then \tcode{i} is added, +which on typical implementations involves multiplying +\tcode{i} by the +length of the object to which the pointer points, +which is \tcode{sizeof(int)}$ \times 5 \times 7$. +The result of the addition and indirection is +an lvalue denoting +the \tcode{i}\textsuperscript{th} array element of +\tcode{x3d} +(an array of five arrays of seven integers). +If there is another subscript, +the same argument applies again, so +\tcode{x3d[i][j]} is +an lvalue denoting +the \tcode{j}\textsuperscript{th} array element of +the \tcode{i}\textsuperscript{th} array element of +\tcode{x3d} +(an array of seven integers), and +\tcode{x3d[i][j][k]} is +an lvalue denoting +the \tcode{k}\textsuperscript{th} array element of +the \tcode{j}\textsuperscript{th} array element of +the \tcode{i}\textsuperscript{th} array element of +\tcode{x3d} +(an integer). +\end{example} +\begin{note} +The first subscript in the declaration helps determine +the amount of storage consumed by an array +but plays no other part in subscript calculations. +\end{note} + +\pnum +\begin{example} \begin{codeblock} extern int x[10]; struct S { @@ -1123,14 +1192,14 @@ \pnum \begin{note} -Except where it has been declared for a class (\ref{over.sub}), +Except where it has been declared for a class\iref{over.sub}, the subscript operator \tcode{[]} is interpreted in such a way that \tcode{E1[E2]} is identical to -\tcode{*((E1)+(E2))}~(\ref{expr.sub}). +\tcode{*((E1)+(E2))}\iref{expr.sub}. Because of the conversion rules that apply to \tcode{+}, @@ -1150,80 +1219,6 @@ appearance, subscripting is a commutative operation. \end{note} -\pnum -\begin{note} -A consistent rule is followed for -\indextext{array!multidimensional}% -multidimensional arrays. -If -\tcode{E} -is an -\textit{n}-dimensional -array -of rank -$i \times j \times \dotsb \times k$, -then -\tcode{E} -appearing in an expression -that is subject to the array-to-pointer conversion~(\ref{conv.array}) -is converted to -a pointer to an $(n-1)$-dimensional -array with rank -$j \times \dotsb \times k$. -If the -\tcode{*} -operator, either explicitly -or implicitly as a result of subscripting, -is applied to this pointer, -the result is the pointed-to $(n-1)$-dimensional array, -which itself is immediately converted into a pointer. -\begin{example} -Consider - -\begin{codeblock} -int x[3][5]; -\end{codeblock} - -Here -\tcode{x} -is a $3 \times 5$ array of integers. -When -\tcode{x} -appears in an expression, it is converted -to a pointer to (the first of three) five-membered arrays of integers. -In the expression -\tcode{x[i]} -which is equivalent to -\tcode{*(x+i)}, -\tcode{x} -is first converted to a pointer as described; -then -\tcode{x+i} -is converted to the type of -\tcode{x}, -which involves multiplying -\tcode{i} -by the -length of the object to which the pointer points, -namely five integer objects. -The results are added and indirection applied to -yield an array (of five integers), which in turn is converted to -a pointer to the first of the integers. -If there is another subscript the same argument applies -again; this time the result is an integer. -\end{example} -\end{note} - -\pnum -\begin{note} -It follows from all this that arrays in \Cpp are stored -row-wise (last subscript varies fastest) -\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. -\end{note} - \rSec2[dcl.fct]{Functions}% \indextext{declarator!function|(} @@ -1260,7 +1255,7 @@ returning \tcode{T}'', where the optional \tcode{noexcept} is present if and only if -the exception specification~(\ref{except.spec}) is non-throwing. +the exception specification\iref{except.spec} is non-throwing. The optional \grammarterm{attribute-specifier-seq} appertains to the function type. @@ -1361,7 +1356,7 @@ \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 +pack\iref{temp.variadic}, the number of arguments shall be equal to or greater than the number of parameters that do not have a default argument and are not function parameter packs. Where syntactically correct and where ``\tcode{...}'' is not @@ -1399,12 +1394,7 @@ \end{note} \pnum -\indextext{overloading}% \indextext{type!function}% -A single name can be used for several different functions in a single scope; -this is function overloading (Clause~\ref{over}). -All declarations for a function shall agree exactly -in both the return type and the parameter-type-list. The type of a function is determined using the following rules. The type of each parameter (including function parameter packs) is determined from its own @@ -1444,10 +1434,10 @@ or \grammarterm{alias-declaration}, \item the \grammarterm{type-id} in the default argument of a -\grammarterm{type-parameter}~(\ref{temp.param}), or +\grammarterm{type-parameter}\iref{temp.param}, or \item the \grammarterm{type-id} of a \grammarterm{template-argument} for a -\grammarterm{type-parameter}~(\ref{temp.arg.type}). +\grammarterm{type-parameter}\iref{temp.arg.type}. \end{itemize} \begin{example} @@ -1483,7 +1473,8 @@ The return type, the parameter-type-list, the \grammarterm{ref-qualifier}, the \grammarterm{cv-qualifier-seq}, and the exception specification, -but not the default arguments~(\ref{dcl.fct.default}), +but not the default arguments\iref{dcl.fct.default} +or \grammarterm{requires-clause}{s}\iref{temp}, are part of the function type. \begin{note} Function types are checked during the assignments and initializations of @@ -1501,10 +1492,16 @@ declares a function taking three arguments of the specified types, and returning -\tcode{int} -(\ref{dcl.type}). +\tcode{int}\iref{dcl.type}. \end{example} +\pnum +\indextext{overloading}% +A single name can be used for several different functions in a single scope; +this is function overloading\iref{over}. +All declarations for a function shall have equivalent return types, +parameter-type-lists, and \grammarterm{requires-clause}{s}\iref{temp.over.link}. + \pnum \indextext{function return type|see{return type}}% \indextext{return type}% @@ -1520,12 +1517,12 @@ (possibly cv-qualified) class type in the context of the function definition unless the function is -deleted~(\ref{dcl.fct.def.delete}). +deleted\iref{dcl.fct.def.delete}. \pnum \indextext{typedef!function}% A typedef of function type may be used to declare a function but shall not be -used to define a function (\ref{dcl.fct.def}). +used to define a function\iref{dcl.fct.def}. \begin{example} \begin{codeblock} @@ -1538,14 +1535,14 @@ \pnum An identifier can optionally be provided as a parameter name; -if present in a function definition (\ref{dcl.fct.def}), it names a parameter. +if present in a function definition\iref{dcl.fct.def}, it names a parameter. \begin{note} In particular, parameter names are also optional in function definitions and names used for a parameter in different declarations and the definition of a function need not be the same. If a parameter name is present in a function declaration that is not a definition, it cannot be used outside of -its function declarator because that is the extent of its potential scope~(\ref{basic.scope.proto}). +its function declarator because that is the extent of its potential scope\iref{basic.scope.proto}. \end{note} \pnum @@ -1639,13 +1636,13 @@ containing an ellipsis shall only be used in a \grammarterm{parameter-declaration}. Such a \grammarterm{parameter-declaration} is a parameter -pack~(\ref{temp.variadic}). When it is part of a +pack\iref{temp.variadic}. When it is part of a \grammarterm{parameter-declaration-clause}, the parameter pack is a -function parameter pack~(\ref{temp.variadic}). \begin{note} +function parameter pack\iref{temp.variadic}. \begin{note} Otherwise, the \grammarterm{parameter-declaration} is part of a \grammarterm{template-parameter-list} and the parameter pack is a template parameter pack; see~\ref{temp.param}. \end{note} -A function parameter pack is a pack expansion~(\ref{temp.variadic}). +A function parameter pack is a pack expansion\iref{temp.variadic}. \begin{example} \begin{codeblock} @@ -1714,8 +1711,7 @@ of a function declaration or \grammarterm{lambda-declarator} or in a -\grammarterm{template-parameter} -(\ref{temp.param}); +\grammarterm{template-parameter}\iref{temp.param}; in the latter case, the \grammarterm{initializer-clause} shall be an \grammarterm{assignment-expression}. A default argument shall not be specified for a parameter pack. @@ -1789,7 +1785,7 @@ The default argument has the same semantic constraints as the initializer in a declaration of a variable of the parameter type, using the -copy-initialization semantics (\ref{dcl.init}). +copy-initialization semantics\iref{dcl.init}. The names in the default argument are bound, and the semantic constraints are checked, at the point where the default argument appears. @@ -1822,7 +1818,7 @@ names in default arguments are looked up as described in~\ref{basic.lookup.unqual}. Access checking applies to names in default arguments as -described in Clause~\ref{class.access}. +described in \ref{class.access}. \end{note} \pnum @@ -1831,8 +1827,8 @@ outside of the class definition are added to the set of default arguments provided by the member function declaration in the class definition; -the program is ill-formed if a default constructor~(\ref{class.ctor}), -copy or move constructor, or copy or move assignment operator~(\ref{class.copy}) +the program is ill-formed if a default constructor\iref{class.ctor}, +copy or move constructor, or copy or move assignment operator\iref{class.copy} is so declared. Default arguments for a member function of a class template shall be specified on the initial declaration of the member @@ -1899,8 +1895,8 @@ \end{codeblock} \end{example} A non-static member shall not appear in a default argument unless it appears as -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}). +the \grammarterm{id-expression} of a class member access expression\iref{expr.ref} or +unless it is used to form a pointer to member\iref{expr.unary.op}. \begin{example} The declaration of \tcode{X::mem1()} @@ -1921,7 +1917,7 @@ \tcode{X::mem2()} is meaningful, however, since no object is needed to access the static member \tcode{X::b}. -Classes, objects, and members are described in Clause~\ref{class}. +Classes, objects, and members are described in \ref{class}. \end{example} A default argument is not part of the type of a function. @@ -1939,8 +1935,8 @@ \end{codeblock} \end{example} When a declaration of a function is introduced by way of a -\grammarterm{using-declaration} -(\ref{namespace.udecl}), any default argument information associated +\grammarterm{using-declaration}\iref{namespace.udecl}, +any default argument information associated with the declaration is made known as well. If the function is redeclared thereafter in the namespace with additional default arguments, @@ -1951,7 +1947,7 @@ \pnum \indextext{argument and virtual function!default}% -A virtual function call (\ref{class.virtual}) uses the default +A virtual function call\iref{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 object. @@ -1990,7 +1986,8 @@ % \begin{bnf} \nontermdef{function-definition}\br - attribute-specifier-seq\opt decl-specifier-seq\opt declarator virt-specifier-seq\opt function-body + attribute-specifier-seq\opt decl-specifier-seq\opt declarator virt-specifier-seq\opt function-body\br + attribute-specifier-seq\opt decl-specifier-seq\opt declarator requires-clause function-body \end{bnf} \begin{bnf} @@ -2006,7 +2003,7 @@ The optional \grammarterm{attribute-specifier-seq} in a \grammarterm{function-definition} appertains to the function. A \grammarterm{virt-specifier-seq} can be part of a \grammarterm{function-definition} -only if it is a \grammarterm{member-declaration}~(\ref{class.mem}). +only if it is a \grammarterm{member-declaration}\iref{class.mem}. \pnum In a \grammarterm{function-definition}, @@ -2088,8 +2085,8 @@ It is unspecified whether such a variable has an address distinct from that of any other object in the program.\footnote{Implementations are 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.} +implementation\iref{lex.name}. If a predefined variable is not +odr-used\iref{basic.def.odr}, its string value need not be present in the program image.} \begin{example} \begin{codeblock} struct S { @@ -2104,12 +2101,10 @@ \indextext{definition!function!explicitly-defaulted}% \pnum -A function definition of the form: - -\begin{ncbnf} - attribute-specifier-seq\opt decl-specifier-seq\opt declarator virt-specifier-seq\opt{} \terminal{ = default ;} -\end{ncbnf} - +A function definition whose +\grammarterm{function-body} +is of the form +\tcode{= default ;} is called an \grammarterm{explicitly-defaulted} definition. A function that is explicitly defaulted shall @@ -2137,7 +2132,7 @@ If a function that is explicitly defaulted is declared with a \grammarterm{noexcept-specifier} that does not produce the same exception specification -as the implicit declaration~(\ref{except.spec}), then +as the implicit declaration\iref{except.spec}, then \begin{itemize} \item if the function is explicitly defaulted on its first declaration, it is defined as deleted; @@ -2202,12 +2197,10 @@ \indextext{definition!function!deleted}% \pnum -A function definition of the form: - -\begin{ncbnf} - attribute-specifier-seq\opt decl-specifier-seq\opt declarator virt-specifier-seq\opt{} \terminal{ = delete ;} -\end{ncbnf} - +A function definition whose +\grammarterm{function-body} +is of the form +\tcode{= delete ;} is called a \term{deleted definition}. A function with a deleted definition is also called a \term{deleted function}. @@ -2218,7 +2211,7 @@ function. It applies even for references in expressions that are not potentially-evaluated. If a function is overloaded, it is referenced only if the function is selected by overload resolution. The implicit -odr-use~(\ref{basic.def.odr}) of a virtual function does not, by itself, +odr-use\iref{basic.def.odr} of a virtual function does not, by itself, constitute a reference. \end{note} \pnum @@ -2266,12 +2259,12 @@ \end{example} \pnum -A deleted function is implicitly an inline function~(\ref{dcl.inline}). \begin{note} The -one-definition rule~(\ref{basic.def.odr}) applies to deleted definitions. \end{note} +A deleted function is implicitly an inline function\iref{dcl.inline}. \begin{note} The +one-definition rule\iref{basic.def.odr} applies to deleted definitions. \end{note} A deleted definition of a function shall be the first declaration of the function or, for an explicit specialization of a function template, the first declaration of that specialization. -An implicitly declared allocation or deallocation function~(\ref{basic.stc.dynamic}) +An implicitly declared allocation or deallocation function\iref{basic.stc.dynamic} shall not be defined as deleted. \begin{example} \begin{codeblock} @@ -2291,7 +2284,7 @@ A structured binding declaration introduces the \grammarterm{identifier}{s} \tcode{v}$_0$, \tcode{v}$_1$, \tcode{v}$_2$, ... of the -\grammarterm{identifier-list} as names~(\ref{basic.scope.declarative}), +\grammarterm{identifier-list} as names\iref{basic.scope.declarative}, called \defn{structured binding}{s}. Let \cv{} denote the \grammarterm{cv-qualifier}{s} in the \grammarterm{decl-specifier-seq}. First, a @@ -2315,7 +2308,7 @@ The type of the \grammarterm{id-expression} \tcode{e} is called \tcode{E}. \begin{note} -\tcode{E} is never a reference type (Clause~\ref{expr}). +\tcode{E} is never a reference type\iref{expr}. \end{note} \pnum @@ -2345,13 +2338,13 @@ the number of elements in the \grammarterm{identifier-list} shall be equal to the value of that expression. The \grammarterm{unqualified-id} \tcode{get} is looked up -in the scope of \tcode{E} by class member access lookup~(\ref{basic.lookup.classref}), +in the scope of \tcode{E} by class member access lookup\iref{basic.lookup.classref}, and if that finds at least one declaration, the initializer is \tcode{e.get()}. Otherwise, the initializer is \tcode{get(e)}, -where \tcode{get} is looked up in the associated namespaces~(\ref{basic.lookup.argdep}). +where \tcode{get} is looked up in the associated namespaces\iref{basic.lookup.argdep}. In either case, \tcode{get} is interpreted as a \grammarterm{template-id}. \begin{note} -Ordinary unqualified lookup~(\ref{basic.lookup.unqual}) is not performed. +Ordinary unqualified lookup\iref{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$ @@ -2395,8 +2388,8 @@ remainder of~\ref{dcl.init} applies also to initializations specified by other syntactic contexts, such as the initialization -of function parameters (\ref{expr.call}) or -the initialization of return values (\ref{stmt.return}). +of function parameters\iref{expr.call} or +the initialization of return values\iref{stmt.return}. \begin{bnf} \nontermdef{initializer}\br @@ -2416,6 +2409,13 @@ braced-init-list \end{bnf} +\begin{bnf} +\nontermdef{braced-init-list}\br + \terminal{\{} initializer-list \terminal{,\opt} \terminal{\}}\br + \terminal{\{} designated-initializer-list \terminal{,\opt} \terminal{\}}\br + \terminal{\{} \terminal{\}} +\end{bnf} + \begin{bnf} \nontermdef{initializer-list}\br initializer-clause \terminal{...}\opt\br @@ -2423,9 +2423,19 @@ \end{bnf} \begin{bnf} -\nontermdef{braced-init-list}\br - \terminal{\{} initializer-list \terminal{,\opt} \terminal{\}}\br - \terminal{\{} \terminal{\}} +\nontermdef{designated-initializer-list}\br + designated-initializer-clause\br + designated-initializer-list \terminal{,} designated-initializer-clause +\end{bnf} + +\begin{bnf} +\nontermdef{designated-initializer-clause}\br + designator brace-or-equal-initializer +\end{bnf} + +\begin{bnf} +\nontermdef{designator}\br + \terminal{.} identifier \end{bnf} \begin{bnf} @@ -2483,7 +2493,7 @@ \item if \tcode{T} -is a scalar type (\ref{basic.types}), the +is a scalar type\iref{basic.types}, the object is initialized to the value obtained by converting the integer literal \tcode{0} (zero) to @@ -2497,20 +2507,22 @@ if \tcode{T} is a (possibly cv-qualified) non-union class type, +its padding bits\iref{basic.types} are initialized to zero bits and each non-static data member, each non-virtual base class subobject, and, if the object is not a base class subobject, each virtual base class subobject -is zero-initialized and padding is initialized to zero bits; +is zero-initialized; \item if \tcode{T} is a (possibly cv-qualified) union type, +its padding bits\iref{basic.types} are initialized to zero bits and the object's first non-static named data member -is zero-initialized and padding is initialized to zero bits; +is zero-initialized; \item if @@ -2534,11 +2546,11 @@ \item If \tcode{T} -is a (possibly cv-qualified) class type (Clause~\ref{class}), +is a (possibly cv-qualified) class type\iref{class}, constructors are considered. The applicable constructors are -enumerated~(\ref{over.match.ctor}), and the best one for the +enumerated\iref{over.match.ctor}, and the best one for the \grammarterm{initializer} \tcode{()} is chosen through -overload resolution~(\ref{over.match}). The constructor thus selected +overload resolution\iref{over.match}. The constructor thus selected is called, with an empty argument list, to initialize the object. \item @@ -2588,8 +2600,8 @@ \item if \tcode{T} -is a (possibly cv-qualified) class type (Clause~\ref{class}) with -either no default constructor~(\ref{class.ctor}) or a default +is a (possibly cv-qualified) class type\iref{class} with +either no default constructor\iref{class.ctor} or a default constructor that is user-provided or deleted, then the object is default-initialized; \item @@ -2647,7 +2659,7 @@ \tcode{X}. The form \tcode{()} -is permitted in certain other initialization contexts (\ref{expr.new}, +is permitted in certain other initialization contexts~(\ref{expr.new}, \ref{expr.type.conv}, \ref{class.base.init}). \end{note} @@ -2658,7 +2670,7 @@ When storage for an object with automatic or dynamic storage duration is obtained, the object has an \term{indeterminate value}, and if no initialization is performed for the object, that object retains an -indeterminate value until that value is replaced~(\ref{expr.ass}). +indeterminate value until that value is replaced\iref{expr.ass}. \begin{note} Objects with static or thread storage duration are zero-initialized, see~\ref{basic.start.static}. \end{note} If an indeterminate value is produced by an evaluation, the behavior is @@ -2667,17 +2679,17 @@ \begin{itemize} \item If an indeterminate value of -unsigned narrow character type~(\ref{basic.fundamental}) -or \tcode{std::byte} type~(\ref{cstddef.syn}) +unsigned narrow character type\iref{basic.fundamental} +or \tcode{std::byte} type\iref{cstddef.syn} is produced by the evaluation of: \begin{itemize} -\item the second or third operand of a conditional expression~(\ref{expr.cond}), -\item the right operand of a comma expression~(\ref{expr.comma}), +\item the second or third operand of a conditional expression\iref{expr.cond}, +\item the right operand of a comma expression\iref{expr.comma}, \item the operand of a cast or conversion~(\ref{conv.integral}, \ref{expr.type.conv}, \ref{expr.static.cast}, \ref{expr.cast}) to an unsigned narrow character type -or \tcode{std::byte} type~(\ref{cstddef.syn}), or -\item a discarded-value expression (Clause~\ref{expr}), +or \tcode{std::byte} type\iref{cstddef.syn}, or +\item a discarded-value expression\iref{expr}, \end{itemize} then the result of the operation is an indeterminate value. @@ -2686,7 +2698,7 @@ unsigned narrow character type or \tcode{std::byte} type is produced by the evaluation of the right -operand of a simple assignment operator~(\ref{expr.ass}) whose first operand +operand of a simple assignment operator\iref{expr.ass} whose first operand is an lvalue of unsigned narrow character type or \tcode{std::byte} type, @@ -2746,14 +2758,14 @@ \indextext{initialization!direct}% The initialization that occurs in the \tcode{=} form of a \grammarterm{brace-or-equal-initializer} or -\grammarterm{condition} (\ref{stmt.select}), +\grammarterm{condition}\iref{stmt.select}, as well as in argument passing, function return, -throwing an exception (\ref{except.throw}), -handling an exception (\ref{except.handle}), -and aggregate member initialization~(\ref{dcl.init.aggr}), +throwing an exception\iref{except.throw}, +handling an exception\iref{except.handle}, +and aggregate member initialization\iref{dcl.init.aggr}, is called \defn{copy-initialization}. -\begin{note} Copy-initialization may invoke a move~(\ref{class.copy}). \end{note} +\begin{note} Copy-initialization may invoke a move\iref{class.copy}. \end{note} \pnum The initialization that occurs in the forms @@ -2763,11 +2775,11 @@ \end{codeblock} as well as in \tcode{new} -expressions~(\ref{expr.new}), +expressions\iref{expr.new}, \tcode{static_cast} -expressions~(\ref{expr.static.cast}), -functional notation type conversions~(\ref{expr.type.conv}), -\grammarterm{mem-initializer}{s}~(\ref{class.base.init}), and +expressions\iref{expr.static.cast}, +functional notation type conversions\iref{expr.type.conv}, +\grammarterm{mem-initializer}{s}\iref{class.base.init}, and the \grammarterm{braced-init-list} form of a \grammarterm{condition} is called \defn{direct-initialization}. @@ -2786,7 +2798,7 @@ \item If the initializer is a (non-parenthesized) \grammarterm{braced-init-list} or is \tcode{=} \grammarterm{braced-init-list}, the object or reference -is list-initialized~(\ref{dcl.init.list}). +is list-initialized\iref{dcl.init.list}. \item If the destination type is a reference type, see~\ref{dcl.init.ref}. \item @@ -2817,8 +2829,8 @@ type is the same class as, or a derived class of, the class of the destination, constructors are considered. The applicable constructors -are enumerated (\ref{over.match.ctor}), and the best one is chosen -through overload resolution (\ref{over.match}). +are enumerated\iref{over.match.ctor}, and the best one is chosen +through overload resolution\iref{over.match}. The constructor so selected is called to initialize the object, with the initializer expression or \grammarterm{expression-list} as its argument(s). @@ -2829,7 +2841,7 @@ user-defined conversion sequences that can convert from the source type to the destination type or (when a conversion function is used) to a derived class thereof are enumerated as described in~\ref{over.match.copy}, and the best one is chosen through overload -resolution (\ref{over.match}). If the conversion cannot be done or +resolution\iref{over.match}. If the conversion cannot be done or is ambiguous, the initialization is ill-formed. The function selected is called with the initializer expression as its argument; if the function is a constructor, the call is a prvalue @@ -2844,9 +2856,9 @@ Otherwise, if the source type is a (possibly cv-qualified) class type, conversion functions are considered. -The applicable conversion functions are enumerated -(\ref{over.match.conv}), and the best one is chosen through overload -resolution (\ref{over.match}). +The applicable conversion functions are enumerated\iref{over.match.conv}, +and the best one is chosen through overload +resolution\iref{over.match}. The user-defined conversion so selected is called to convert the initializer expression into the object being initialized. @@ -2855,7 +2867,7 @@ \item Otherwise, the initial value of the object being initialized is the (possibly converted) value of the initializer expression. -Standard conversions (Clause~\ref{conv}) will be used, if necessary, +Standard conversions\iref{conv} will be used, if necessary, to convert the initializer expression to the cv-unqualified version of the destination type; no user-defined conversions are considered. @@ -2885,12 +2897,17 @@ \pnum An \grammarterm{initializer-clause} followed by an ellipsis is a -pack expansion~(\ref{temp.variadic}). +pack expansion\iref{temp.variadic}. \pnum If the initializer is a parenthesized \grammarterm{expression-list}, the expressions are evaluated in the order -specified for function calls~(\ref{expr.call}). +specified for function calls\iref{expr.call}. + +\pnum +The same \grammarterm{identifier} +shall not appear in multiple \grammarterm{designator}{s} of a +\grammarterm{designated-initializer-list}. \pnum An object whose initialization has completed @@ -2899,8 +2916,8 @@ is invoked for the initialization. \begin{note} Such an object might have been value-initialized -or initialized by aggregate initialization~(\ref{dcl.init.aggr}) -or by an inherited constructor~(\ref{class.inhctor.init}). +or initialized by aggregate initialization\iref{dcl.init.aggr} +or by an inherited constructor\iref{class.inhctor.init}. \end{note} \pnum @@ -2909,9 +2926,9 @@ is called the \defn{initializing declaration} of that variable. \begin{note} In most cases -this is the defining declaration~(\ref{basic.def}) of the variable, +this is the defining declaration\iref{basic.def} of the variable, but the initializing declaration -of a non-inline static data member~(\ref{class.static.data}) +of a non-inline static data member\iref{class.static.data} might be the declaration within the class definition and not the definition at namespace scope. \end{note} @@ -2926,16 +2943,16 @@ \indextext{\idxcode{\{\}}!initializer list} \pnum -An \defn{aggregate} is an array or a class (Clause~\ref{class}) with +An \defn{aggregate} is an array or a class\iref{class} with \begin{itemize} \item -no user-provided, \tcode{explicit}, or inherited constructors~(\ref{class.ctor}), +no user-provided, \tcode{explicit}, or inherited constructors\iref{class.ctor}, \item -no private or protected non-static data members (Clause~\ref{class.access}), +no private or protected non-static data members\iref{class.access}, \item -no virtual functions~(\ref{class.virtual}), and +no virtual functions\iref{class.virtual}, and \item -no virtual, private, or protected base classes~(\ref{class.mi}). +no virtual, private, or protected base classes\iref{class.mi}. \end{itemize} \begin{note} Aggregate initialization does not allow accessing @@ -2943,14 +2960,13 @@ \end{note} \pnum -\indextext{aggregate!elements}% -The \term{elements} of an aggregate are: +The \defnx{elements}{aggregate!elements} of an aggregate are: \begin{itemize} \item for an array, the array elements in increasing subscript order, or \item for a class, the direct base classes in declaration order, -followed by the direct non-static data members~(\ref{class.mem}) +followed by the direct non-static data members\iref{class.mem} that are not members of an anonymous union, in declaration order. \end{itemize} @@ -2958,15 +2974,53 @@ When an aggregate is initialized by an initializer list as specified in~\ref{dcl.init.list}, the elements of the initializer list are taken as initializers -for the elements of the aggregate, in order. -Each element is copy-initialized -from the corresponding \grammarterm{initializer-clause}. -If the \grammarterm{initializer-clause} is an expression and -a narrowing conversion~(\ref{dcl.init.list}) is required +for the elements of the aggregate. +The \defnx{explicitly initialized elements}{explicitly initialized elements!aggregate} +of the aggregate are determined as follows: +\begin{itemize} +\item +If the initializer list is a \grammarterm{designated-initializer-list}, +the aggregate shall be of class type, +the \grammarterm{identifier} in each \grammarterm{designator} +shall name a direct non-static data member of the class, and +the explicitly initialized elements of the aggregate +are the elements that are, or contain, those members. +\item +If the initializer list is an \grammarterm{initializer-list}, +the explicitly initialized elements of the aggregate +are the first $n$ elements of the aggregate, +where $n$ is the number of elements in the initializer list. +\item +Otherwise, the initializer list must be \tcode{\{\}}, +and there are no explicitly initialized elements. +\end{itemize} + +\pnum +For each explicitly initialized element: +\begin{itemize} +\item +If the element is an anonymous union object and +the initializer list is a \grammarterm{designated-initializer-list}, +the anonymous union object is initialized by the +\grammarterm{designated-initializer-list} \tcode{\{ }\placeholder{D}\tcode{ \}}, +where \placeholder{D} is the \grammarterm{designated-initializer-clause} +naming a member of the anonymous union object. +There shall be only one such \grammarterm{designated-initializer-clause}. +\item +Otherwise, the element is copy-initialized +from the corresponding \grammarterm{initializer-clause} +or the \grammarterm{brace-or-equal-initializer} +of the corresponding \grammarterm{designated-initializer-clause}. +If that initializer is of the form +\grammarterm{assignment-expression} or +\tcode{= }\grammarterm{assignment-expression} +and +a narrowing conversion\iref{dcl.init.list} is required to convert the expression, the program is ill-formed. -\begin{note} If an \grammarterm{initializer-clause} is itself an initializer list, +\begin{note} If an initializer is itself an initializer list, the element is list-initialized, which will result in a recursive application of the rules in this section if the element is an aggregate. \end{note} +\end{itemize} \begin{example} \begin{codeblock} struct A { @@ -3011,6 +3065,79 @@ \tcode{d2.d} with 4. \end{example} +\pnum +For a non-union aggregate, +each element that is not an explicitly initialized element +is initialized as follows: +\begin{itemize} +\item +If the element has a default member initializer\iref{class.mem}, +the element is initialized from that initializer. +\item +Otherwise, if the element is not a reference, the element +is copy-initialized from an empty initializer list\iref{dcl.init.list}. +\item +Otherwise, the program is ill-formed. +\end{itemize} +If the aggregate is a union and the initializer list is empty, then +\begin{itemize} +\item +if any variant member has a default member initializer, +that member is initialized from its default member initializer; +\item +otherwise, the first member of the union (if any) +is copy-initialized from an empty initializer list. +\end{itemize} +\begin{example} + +\begin{codeblock} +struct S { int a; const char* b; int c; int d = b[a]; }; +S ss = { 1, "asdf" }; +\end{codeblock} + +initializes +\tcode{ss.a} +with 1, +\tcode{ss.b} +with \tcode{"asdf"}, +\tcode{ss.c} +with the value of an expression of the form +\tcode{int\{\}} +(that is, \tcode{0}), and \tcode{ss.d} with the value of \tcode{ss.b[ss.a]} +(that is, \tcode{'s'}), and in + +\begin{codeblock} +struct X { int i, j, k = 42; }; +X a[] = { 1, 2, 3, 4, 5, 6 }; +X b[2] = { { 1, 2, 3 }, { 4, 5, 6 } }; +\end{codeblock} + +\tcode{a} and \tcode{b} have the same value + +\begin{codeblock} +struct A { + string a; + int b = 42; + int c = -1; +}; +\end{codeblock} + +\tcode{A\{.c=21\}} has the following steps: +\begin{itemize} +\item Initialize \tcode{a} with \tcode{\{\}} +\item Initialize \tcode{b} with \tcode{= 42} +\item Initialize \tcode{c} with \tcode{= 21} +\end{itemize} +\end{example} + +\pnum +The initializations of the elements of the aggregate +are evaluated in the element order. +That is, +all value computations and side effects associated with a given element +are sequenced before +those of any element that follows it in order. + \pnum An aggregate that is a class can also be initialized with a single expression not enclosed in braces, as described in~\ref{dcl.init}. @@ -3026,7 +3153,7 @@ \tcode{n} shall be greater than zero, is defined as having \tcode{n} -elements~(\ref{dcl.array}). +elements\iref{dcl.array}. \begin{example} \begin{codeblock} @@ -3047,8 +3174,8 @@ \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 +ignored if a suitable \grammarterm{mem-initializer} is present\iref{class.base.init}, +the default member initializer is not considered to initialize the array of unknown bound. \begin{example} \begin{codeblock} @@ -3061,8 +3188,11 @@ \pnum \begin{note} -Static data members and unnamed bit-fields are not considered -elements of the aggregate. +Static data members, +non-static data members of anonymous union members, +and +unnamed bit-fields +are not considered elements of the aggregate. \begin{example} \begin{codeblock} @@ -3088,7 +3218,7 @@ \grammarterm{initializer-list} is ill-formed if the number of \grammarterm{initializer-clause}{s} -exceeds the number of elements to initialize. +exceeds the number of elements of the aggregate. \begin{example} \begin{codeblock} @@ -3098,56 +3228,6 @@ is ill-formed. \end{example} -\pnum -If there are fewer \grammarterm{initializer-clause}{s} in the list than there -are elements in a non-union aggregate, then each element not explicitly initialized -is initialized as follows: -\begin{itemize} -\item -If the element has a default member initializer~(\ref{class.mem}), -the element is initialized from that initializer. -\item -Otherwise, if the element is not a reference, the element -is copy-initialized from an empty initializer list~(\ref{dcl.init.list}). -\item -Otherwise, the program is ill-formed. -\end{itemize} -If the aggregate is a union and the initializer list is empty, then -\begin{itemize} -\item -if any variant member has a default member initializer, -that member is initialized from its default member initializer; -\item -otherwise, the first member of the union (if any) -is copy-initialized from an empty initializer list. -\end{itemize} -\begin{example} - -\begin{codeblock} -struct S { int a; const char* b; int c; int d = b[a]; }; -S ss = { 1, "asdf" }; -\end{codeblock} - -initializes -\tcode{ss.a} -with 1, -\tcode{ss.b} -with \tcode{"asdf"}, -\tcode{ss.c} -with the value of an expression of the form -\tcode{int\{\}} -(that is, \tcode{0}), and \tcode{ss.d} with the value of \tcode{ss.b[ss.a]} -(that is, \tcode{'s'}), and in - -\begin{codeblock} -struct X { int i, j, k = 42; }; -X a[] = { 1, 2, 3, 4, 5, 6 }; -X b[2] = { { 1, 2, 3 }, { 4, 5, 6 } }; -\end{codeblock} - -\tcode{a} and \tcode{b} have the same value -\end{example} - \pnum If a reference member is initialized from its default member initializer and a potentially-evaluated subexpression thereof is an aggregate @@ -3196,7 +3276,7 @@ the \grammarterm{initializer-clause}{s} initialize the elements with the last (rightmost) index of the array -varying the fastest (\ref{dcl.array}). +varying the fastest\iref{dcl.array}. \begin{example} \begin{codeblock} @@ -3311,7 +3391,7 @@ \end{example} \pnum -All implicit type conversions (Clause~\ref{conv}) are considered when +All implicit type conversions\iref{conv} are considered when initializing the element with an \grammarterm{assignment-expression}. If the \grammarterm{assignment-expression} @@ -3359,7 +3439,7 @@ \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}). +class type with a user-provided constructor\iref{class.ctor}. Initialization of these aggregate objects is described in~\ref{class.expl.init}. \end{note} @@ -3372,12 +3452,10 @@ \pnum \indextext{initialization!\idxcode{union}}% -When a union is initialized with a brace-enclosed initializer, -the braces shall only contain an -\grammarterm{initializer-clause} -for the first non-static data member of the union. +When a union is initialized with an initializer list, +there shall not be more than one +explicitly initialized element. \begin{example} - \begin{codeblock} union u { int a; const char* b; }; u a = { 1 }; @@ -3385,6 +3463,8 @@ u c = 1; // error u d = { 0, "asdf" }; // error u e = { "asdf" }; // error +u f = { .b = "asdf" }; +u g = { .a = 1, .b = "asdf" }; // error \end{codeblock} \end{example} @@ -3401,7 +3481,7 @@ \indextext{initialization!character array} \pnum -An array of narrow character type~(\ref{basic.fundamental}), +An array of narrow character type\iref{basic.fundamental}, \tcode{char16_t} array, \tcode{char32_t} array, or \tcode{wchar_t} array @@ -3409,7 +3489,7 @@ narrow string literal, \tcode{char16_t} string literal, \tcode{char32_t} string literal, or wide string literal, respectively, or by an appropriately-typed string literal enclosed in -braces~(\ref{lex.string}). +braces\iref{lex.string}. \indextext{initialization!character array}% Successive characters of the @@ -3449,14 +3529,14 @@ \pnum If there are fewer initializers than there are array elements, each element not -explicitly initialized shall be zero-initialized~(\ref{dcl.init}). +explicitly initialized shall be zero-initialized\iref{dcl.init}. \rSec2[dcl.init.ref]{References}% \indextext{initialization!reference} \pnum A variable whose declared type is -``reference to type \tcode{T}'' (\ref{dcl.ref}) +``reference to type \tcode{T}''\iref{dcl.ref} shall be initialized. \begin{example} @@ -3481,17 +3561,17 @@ A reference cannot be changed to refer to another object after initialization. \indextext{assignment!reference}% \begin{note} -Assignment to a reference assigns to the object referred to by the reference (\ref{expr.ass}). +Assignment to a reference assigns to the object referred to by the reference\iref{expr.ass}. \end{note} \indextext{argument passing!reference and}% -Argument passing (\ref{expr.call}) +Argument passing\iref{expr.call} \indextext{\idxcode{return}!reference and}% -and function value return (\ref{stmt.return}) are initializations. +and function value return\iref{stmt.return} are initializations. \pnum -The initializer can be omitted for a reference only in a parameter declaration -(\ref{dcl.fct}), in the declaration of a function return type, in the declaration of -a class member within its class definition (\ref{class.mem}), and where the +The initializer can be omitted for a reference only in a parameter declaration\iref{dcl.fct}, +in the declaration of a function return type, in the declaration of +a class member within its class definition\iref{class.mem}, and where the \tcode{extern} specifier is explicitly used. \indextext{declaration!extern@\tcode{extern} reference}% @@ -3527,7 +3607,7 @@ \tcode{T2}, a program that necessitates such a binding is ill-formed if \tcode{T1} -is an inaccessible (Clause~\ref{class.access}) or ambiguous (\ref{class.member.lookup}) +is an inaccessible\iref{class.access} or ambiguous\iref{class.member.lookup} base class of \tcode{T2}. @@ -3553,17 +3633,17 @@ 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.} +function\iref{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 -resolution (\ref{over.match})), +functions\iref{over.match.ref} and choosing the best one through overload +resolution\iref{over.match}), \end{itemize} then the reference is bound to the initializer expression lvalue in the first case and to the lvalue result of the conversion in the second case (or, in either case, to the appropriate base class subobject of the object). \begin{note} -The usual lvalue-to-rvalue (\ref{conv.lval}), array-to-pointer -(\ref{conv.array}), and function-to-pointer (\ref{conv.func}) standard +The usual lvalue-to-rvalue\iref{conv.lval}, array-to-pointer\iref{conv.array}, +and function-to-pointer\iref{conv.func} standard conversions are not needed, and therefore are suppressed, when such direct bindings to lvalues are done. \end{note} @@ -3619,8 +3699,8 @@ the result of the conversion in the second case is called the converted initializer. If the converted initializer is a prvalue, -its type \tcode{T4} is adjusted to type ``\cvqual{cv1} \tcode{T4}''~(\ref{conv.qual}) -and the temporary materialization conversion~(\ref{conv.rval}) is applied. +its type \tcode{T4} is adjusted to type ``\cvqual{cv1} \tcode{T4}''\iref{conv.qual} +and the temporary materialization conversion\iref{conv.rval} is applied. In any case, the reference is bound to the resulting glvalue (or to an appropriate base class subobject). @@ -3728,9 +3808,15 @@ \pnum \defnx{List-initialization}{list-initialization} is initialization of an object or reference from a -\grammarterm{braced-init-list}. Such an initializer is called an \term{initializer -list}, and the comma-separated \grammarterm{initializer-clause}{s} of the list are -called the \term{elements} of the initializer list. An initializer list may be empty. +\grammarterm{braced-init-list}. +Such an initializer is called an \term{initializer list}, and +the comma-separated +\grammarterm{initializer-clause}{s} +of the \grammarterm{initializer-list} +or +\grammarterm{designated-initializer-clause}{s} +of the \grammarterm{designated-initializer-list} +are called the \term{elements} of the initializer list. An initializer list may be empty. List-initialization can occur in direct-initialization or copy-initialization contexts; list-initialization in a direct-initialization context is called \defn{direct-list-initialization} and list-initialization in a @@ -3738,16 +3824,16 @@ List-initialization can be used \begin{itemize} -\item as the initializer in a variable definition~(\ref{dcl.init}) -\item as the initializer in a \grammarterm{new-expression}~(\ref{expr.new}) -\item in a return statement~(\ref{stmt.return}) -\item as a \grammarterm{for-range-initializer}~(\ref{stmt.iter}) -\item as a function argument~(\ref{expr.call}) -\item as a subscript~(\ref{expr.sub}) -\item as an argument to a constructor invocation~(\ref{dcl.init},~\ref{expr.type.conv}) -\item as an initializer for a non-static data member~(\ref{class.mem}) -\item in a \grammarterm{mem-initializer}~(\ref{class.base.init}) -\item on the right-hand side of an assignment (\ref{expr.ass}) +\item as the initializer in a variable definition\iref{dcl.init} +\item as the initializer in a \grammarterm{new-expression}\iref{expr.new} +\item in a return statement\iref{stmt.return} +\item as a \grammarterm{for-range-initializer}\iref{stmt.iter} +\item as a function argument\iref{expr.call} +\item as a subscript\iref{expr.sub} +\item as an argument to a constructor invocation~(\ref{dcl.init}, \ref{expr.type.conv}) +\item as an initializer for a non-static data member\iref{class.mem} +\item in a \grammarterm{mem-initializer}\iref{class.base.init} +\item on the right-hand side of an assignment\iref{expr.ass} \end{itemize} \begin{example} @@ -3767,21 +3853,39 @@ A constructor is an \defn{initializer-list constructor} if its first parameter is of type \tcode{std::initializer_list} or reference to possibly cv-qualified \tcode{std::initializer_list} for some type \tcode{E}, and either there are no other -parameters or else all other parameters have default arguments (\ref{dcl.fct.default}). +parameters or else all other parameters have default arguments\iref{dcl.fct.default}. \begin{note} Initializer-list constructors are favored over other constructors in -list-initialization~(\ref{over.match.list}). Passing an initializer list as the argument +list-initialization\iref{over.match.list}. Passing an initializer list as the argument to the constructor template \tcode{template C(T)} of a class \tcode{C} does not create an initializer-list constructor, because an initializer list argument causes the -corresponding parameter to be a non-deduced context~(\ref{temp.deduct.call}). \end{note} +corresponding parameter to be a non-deduced context\iref{temp.deduct.call}. \end{note} The template \tcode{std::initializer_list} is not predefined; if the header \tcode{} is not included prior to a use of \tcode{std::initializer_list} --- even an implicit use in which the type is not -named~(\ref{dcl.spec.auto}) --- the program is ill-formed. +named\iref{dcl.spec.auto} --- the program is ill-formed. \pnum List-initialization of an object or reference of type \tcode{T} is defined as follows: \begin{itemize} +\item +If the \grammarterm{braced-init-list} +contains a \grammarterm{designated-initializer-list}, +\tcode{T} shall be an aggregate class. +The ordered \grammarterm{identifier}{s} +in the \grammarterm{designator}{s} +of the \grammarterm{designated-initializer-list} +shall form a subsequence +of the ordered \grammarterm{identifier}{s} +in the direct non-static data members of \tcode{T}. +Aggregate initialization is performed\iref{dcl.init.aggr}. +\begin{example} +\begin{codeblock} +struct A { int x; int y; int z; }; +A a{.y = 2, .x = 1}; // error: designator order does not match declaration order +A b{.x = 1, .z = 2}; // OK, \tcode{b.y} initialized to \tcode{0} +\end{codeblock} +\end{example} \item If \tcode{T} is an aggregate class and the initializer list has a single element of type \cvqual{cv} \tcode{U}, @@ -3791,11 +3895,11 @@ direct-list-initialization). \item Otherwise, if \tcode{T} is a character array and the initializer list has a -single element that is an appropriately-typed string literal~(\ref{dcl.init.string}), +single element that is an appropriately-typed string literal\iref{dcl.init.string}, initialization is performed as described in that section. \item Otherwise, if \tcode{T} is an aggregate, aggregate initialization is -performed~(\ref{dcl.init.aggr}). +performed\iref{dcl.init.aggr}. \begin{example} \begin{codeblock} @@ -3820,7 +3924,7 @@ \item Otherwise, if \tcode{T} is a class type, constructors are considered. The applicable constructors are enumerated and -the best one is chosen through overload resolution (\ref{over.match},~\ref{over.match.list}). If a narrowing +the best one is chosen through overload resolution~(\ref{over.match}, \ref{over.match.list}). If a narrowing conversion (see below) is required to convert any of the arguments, the program is ill-formed. @@ -3862,10 +3966,10 @@ \end{example} \item Otherwise, if \tcode{T} is an enumeration -with a fixed underlying type~(\ref{dcl.enum}), +with a fixed underlying type\iref{dcl.enum}, the \grammarterm{initializer-list} has a single element \tcode{v}, and the initialization is direct-list-initialization, -the object is initialized with the value \tcode{T(v)}~(\ref{expr.type.conv}); +the object is initialized with the value \tcode{T(v)}\iref{expr.type.conv}; if a narrowing conversion is required to convert \tcode{v} to the underlying type of \tcode{T}, the program is ill-formed. \begin{example} @@ -3966,7 +4070,7 @@ \pnum Within the \grammarterm{initializer-list} of a \grammarterm{braced-init-list}, the \grammarterm{initializer-clause}{s}, including any that result from pack -expansions~(\ref{temp.variadic}), are evaluated in the order in which they +expansions\iref{temp.variadic}, are evaluated in the order in which they appear. That is, every value computation and side effect associated with a given \grammarterm{initializer-clause} is sequenced before every value computation and side effect associated with any \grammarterm{initializer-clause} @@ -3980,14 +4084,14 @@ \pnum An object of type \tcode{std::initializer_list} is constructed from an initializer list as if -the implementation generated and materialized~(\ref{conv.rval}) +the implementation generated and materialized\iref{conv.rval} a prvalue of type ``array of $N$ \tcode{const E}'', where $N$ is the number of elements in the initializer list. Each element of that array is copy-initialized with the corresponding element of the initializer list, and the \tcode{std::initializer_list} object is constructed to refer to that array. \begin{note} A constructor or conversion function selected for the copy shall be -accessible (Clause~\ref{class.access}) in the context of the initializer list. +accessible\iref{class.access} in the context of the initializer list. \end{note} If a narrowing conversion is required to initialize any of the elements, the program is ill-formed. \begin{example} \begin{codeblock} @@ -4008,7 +4112,7 @@ \pnum The array has the same lifetime as any other temporary -object~(\ref{class.temporary}), except that initializing an +object\iref{class.temporary}, except that initializing an \tcode{initializer_list} object from the array extends the lifetime of the array exactly like binding a reference to a temporary. \begin{example} @@ -4036,7 +4140,7 @@ For \tcode{i4}, the \tcode{initializer_list} object is initialized in the constructor's \grammarterm{ctor-initializer} as if by binding a temporary array to a reference member, so the program is -ill-formed~(\ref{class.base.init}). +ill-formed\iref{class.base.init}. \end{example} \begin{note} The implementation is free to allocate the array in read-only memory if an explicit array with the same initializer could be so allocated. \end{note} diff --git a/source/derived.tex b/source/derived.tex index 29ed414d82..8ea764d550 100644 --- a/source/derived.tex +++ b/source/derived.tex @@ -56,50 +56,47 @@ \indextext{type!incomplete}% A \grammarterm{class-or-decltype} shall denote a class type that is not -an incompletely defined class (Clause~\ref{class}). +an incompletely defined class\iref{class}. The class denoted by the \grammarterm{class-or-decltype} of a \grammarterm{base-specifier} is called a -\indextext{base class!direct}% -\term{direct base class} +\defnx{direct base class}{base class!direct} for the class being defined. \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 +ignored\iref{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}% -A class is an \term{indirect} base class of another if it is a base +A class is an \defnx{indirect}{base class!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 classes. \begin{note} -See Clause~\ref{class.access} for the meaning of +See \ref{class.access} for the meaning of \grammarterm{access-specifier}. \end{note} \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 -\indextext{inheritance}% -\term{inherited} +\defnx{inherited}{inheritance} by the derived class. Constructors of a base class can also be inherited as described in~\ref{namespace.udecl}. 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}). +unless their names are hidden or ambiguous\iref{class.member.lookup}. \indextext{operator!scope resolution}% \begin{note} -The scope resolution operator \tcode{::}~(\ref{expr.prim}) can be used +The scope resolution operator \tcode{::}\iref{expr.prim} can be used to refer to a direct or indirect base member explicitly. This allows access to a name that has been redeclared in the derived class. A derived class can itself serve as a base class subject to access control; see~\ref{class.access.base}. A pointer to a derived class can be implicitly converted to a pointer to an accessible unambiguous base -class~(\ref{conv.ptr}). An lvalue of a derived class type can be bound +class\iref{conv.ptr}. An lvalue of a derived class type can be bound to a reference to an accessible unambiguous base -class~(\ref{dcl.init.ref}). +class\iref{dcl.init.ref}. \end{note} \pnum @@ -133,11 +130,11 @@ \pnum A \grammarterm{base-specifier} followed by an ellipsis is a pack -expansion~(\ref{temp.variadic}). +expansion\iref{temp.variadic}. \pnum The order in which the base class subobjects are allocated in the most -derived object~(\ref{intro.object}) is unspecified. +derived object\iref{intro.object} is unspecified. \begin{note} \indextext{directed acyclic graph|see{DAG}}% \indextext{lattice|see{DAG, subobject}}% @@ -161,14 +158,14 @@ \pnum \begin{note} -A base class subobject might have a layout~(\ref{basic.stc}) different +A base class subobject might have a layout\iref{basic.stc} different from the layout of a most derived object of the same type. A base class -subobject might have a polymorphic behavior~(\ref{class.cdtor}) +subobject might have a polymorphic behavior\iref{class.cdtor} different from the polymorphic behavior of a most derived object of the -same type. A base class subobject may be of zero size (Clause~\ref{class}); +same type. A base class subobject may be of zero size\iref{class}; however, two subobjects that have the same class type and that belong to the same most derived object must not be allocated at the same -address~(\ref{expr.eq}). +address\iref{expr.eq}. \end{note} \rSec1[class.mi]{Multiple base classes} @@ -194,9 +191,9 @@ \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}), -cleanup~(\ref{class.dtor}), and storage -layout~(\ref{class.mem},~\ref{class.access.spec}). +semantics of initialization by constructor\iref{class.base.init}, +cleanup\iref{class.dtor}, and storage +layout~(\ref{class.mem}, \ref{class.access.spec}). \end{note} \pnum @@ -232,7 +229,7 @@ class specifier that contains the keyword \tcode{virtual} specifies a \defnx{virtual base class}{base class!virtual}. For each distinct occurrence of a non-virtual base class in the class lattice of the most derived class, -the most derived object~(\ref{intro.object}) shall contain a +the most derived object\iref{intro.object} shall contain a 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. @@ -260,7 +257,7 @@ \end{codeblock} 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}). +ambiguity\iref{class.member.lookup}. \end{note} \pnum @@ -324,13 +321,13 @@ \pnum Member name lookup determines the meaning of a name -(\grammarterm{id-expression}) in a class scope~(\ref{basic.scope.class}). +(\grammarterm{id-expression}) in a class scope\iref{basic.scope.class}. Name lookup can result in an \term{ambiguity}, in which case the program is ill-formed. For an \grammarterm{id-expression}, name lookup begins in the class scope of \tcode{this}; for a \grammarterm{qualified-id}, name lookup begins in the scope of the \grammarterm{nested-name-specifier}. Name lookup takes place before access -control~(\ref{basic.lookup}, Clause~\ref{class.access}). +control~(\ref{basic.lookup}, \ref{class.access}). \pnum The following steps define the result of name lookup for a member name @@ -344,7 +341,7 @@ \grammarterm{using-declaration}{s}) were found. In the declaration set, \grammarterm{using-declaration}{s} are replaced by the set of designated members that are not hidden or overridden by members of the -derived class~(\ref{namespace.udecl}), +derived class\iref{namespace.udecl}, and type declarations (including injected-class-names) are replaced by the types they designate. $S(f,C)$ is calculated as follows: @@ -355,13 +352,13 @@ which the lookup occurs. \begin{note} Looking up a name in an -\grammarterm{elaborated-type-specifier}~(\ref{basic.lookup.elab}) or -\grammarterm{base-specifier} (Clause~\ref{class.derived}), for instance, +\grammarterm{elaborated-type-specifier}\iref{basic.lookup.elab} or +\grammarterm{base-specifier}\iref{class.derived}, for instance, ignores all non-type declarations, while looking up a name in a -\grammarterm{nested-name-specifier}~(\ref{basic.lookup.qual}) ignores +\grammarterm{nested-name-specifier}\iref{basic.lookup.qual} ignores function, variable, and enumerator declarations. As another example, looking up a name in a -\grammarterm{using-declaration}~(\ref{namespace.udecl}) includes the +\grammarterm{using-declaration}\iref{namespace.udecl} includes the declaration of a class or enumeration that would ordinarily be hidden by another declaration of that name in the same scope. \end{note} @@ -422,7 +419,7 @@ \pnum \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 +overload resolution\iref{over.match} also takes place before access control. \indextext{example!scope resolution operator}% \indextext{example!explicit qualification}% @@ -547,7 +544,7 @@ \begin{note} Even if the result of name lookup is unambiguous, use of a name found in multiple subobjects might still be -ambiguous~(\ref{conv.mem},~\ref{expr.ref}, \ref{class.access.base}).\end{note} +ambiguous~(\ref{conv.mem}, \ref{expr.ref}, \ref{class.access.base}).\end{note} \begin{example} \begin{codeblock} struct B1 { @@ -577,32 +574,31 @@ \rSec1[class.virtual]{Virtual functions}% \indextext{virtual function|(}% \indextext{type!polymorphic}% -\indextext{class!polymorphic} \pnum \begin{note} Virtual functions support dynamic binding and object-oriented programming. \end{note} A class that declares or inherits a virtual function is -called a \term{polymorphic class}. +called a \defnx{polymorphic class}{class!polymorphic}. \pnum If a virtual member function \tcode{vf} is declared in a class \tcode{Base} and in a class \tcode{Derived}, derived directly or indirectly from \tcode{Base}, a member function \tcode{vf} with the same -name, parameter-type-list~(\ref{dcl.fct}), cv-qualification, and ref-qualifier +name, parameter-type-list\iref{dcl.fct}, cv-qualification, and ref-qualifier (or absence of same) as \tcode{Base::vf} is declared, then \tcode{Derived::vf} is also virtual -(whether or not it is so declared) and it \term{overrides}\footnote{A function with the same name but a different parameter list -(Clause~\ref{over}) as a virtual function is not necessarily virtual and +(whether or not it is so declared) and it \term{overrides}\footnote{A function with the same name but a different parameter list\iref{over} +as a virtual function is not necessarily virtual and does not override. The use of the \tcode{virtual} specifier in the declaration of an overriding function is legal but redundant (has empty -semantics). Access control (Clause~\ref{class.access}) is not considered in +semantics). Access control\iref{class.access} is not considered in determining overriding.} \tcode{Base::vf}. For convenience we say that any virtual function overrides itself. \indextext{overrider!final}% A virtual member function \tcode{C::vf} of a class object \tcode{S} is a \defn{final -overrider} unless the most derived class~(\ref{intro.object}) of which \tcode{S} is a +overrider} unless the most derived class\iref{intro.object} of which \tcode{S} is a base class subobject (if any) declares or inherits another member function that overrides \tcode{vf}. In a derived class, if a virtual member function of a base class subobject has more than one final overrider the program is ill-formed. @@ -690,6 +686,16 @@ \end{codeblock} \end{example} +\pnum +A virtual function shall not have a \grammarterm{requires-clause}. +\begin{example} +\begin{codeblock} +struct A { + virtual void f() requires true; // error: virtual function cannot be constrained\iref{temp.constr.decl} +}; +\end{codeblock} +\end{example} + \pnum Even though destructors are not inherited, a destructor in a derived class overrides a base class destructor declared virtual; @@ -725,7 +731,7 @@ class type \tcode{D}. When the overriding function is called as the final overrider of the overridden function, its result is converted to the type returned by the (statically chosen) overridden -function~(\ref{expr.call}). +function\iref{expr.call}. \begin{example} \indextext{example!virtual function}% \begin{codeblock} @@ -777,13 +783,13 @@ of the object for which it is called (the dynamic type), whereas the interpretation of a call of a non-virtual member function depends only on the type of the pointer or reference denoting that object (the static -type)~(\ref{expr.call}). +type)\iref{expr.call}. \end{note} \pnum \begin{note} The \tcode{virtual} specifier implies membership, so a virtual function -cannot be a non-member~(\ref{dcl.fct.spec}) function. Nor can a virtual +cannot be a non-member\iref{dcl.fct.spec} function. Nor can a virtual function be a static member, since a virtual function call relies on a specific object for determining which function to invoke. A virtual function declared in one class can be declared a \tcode{friend} in @@ -793,8 +799,8 @@ \pnum \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; no diagnostic is -required~(\ref{basic.def.odr}). +pure\iref{class.abstract} in that class, or both; no diagnostic is +required\iref{basic.def.odr}. \indextext{friend!\tcode{virtual} and}% \pnum @@ -884,7 +890,7 @@ \pnum \indextext{operator!scope resolution}% \indextext{virtual function call}% -Explicit qualification with the scope operator~(\ref{expr.prim}) +Explicit qualification with the scope operator\iref{expr.prim} suppresses the virtual call mechanism. \begin{example} \begin{codeblock} @@ -903,14 +909,13 @@ \end{example} \pnum -A function with a deleted definition~(\ref{dcl.fct.def}) shall +A function with a deleted definition\iref{dcl.fct.def} shall 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|)} \rSec1[class.abstract]{Abstract classes}% -\indextext{class!abstract} \pnum \begin{note} @@ -922,21 +927,20 @@ \end{note} \pnum -An \term{abstract class} is a class that can be used only +An \defnx{abstract class}{class!abstract} is a class that can be used only as a base class of some other class; no objects of an abstract class can be created except as subobjects of a class derived from it. A class is abstract if it has at least one \term{pure virtual function}. \begin{note} Such a function might be inherited: see below. \end{note} -\indextext{virtual function!pure}% -A virtual function is specified \term{pure} by using a -\grammarterm{pure-specifier}~(\ref{class.mem}) in the function declaration +A virtual function is specified \defnx{pure}{virtual function!pure} by using a +\grammarterm{pure-specifier}\iref{class.mem} in the function declaration in the class definition. \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}). +with\iref{class.dtor}, the \grammarterm{qualified-id} +syntax\iref{expr.prim}. \begin{example} \indextext{example!pure virtual function}% \begin{codeblock} @@ -1019,7 +1023,7 @@ Member functions can be called from a constructor (or destructor) of an abstract class; \indextext{virtual function call!undefined pure}% -the effect of making a virtual call~(\ref{class.virtual}) to a pure +the effect of making a virtual call\iref{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|)} diff --git a/source/diagnostics.tex b/source/diagnostics.tex index b30f0fe6dc..4fe7925c52 100644 --- a/source/diagnostics.tex +++ b/source/diagnostics.tex @@ -24,7 +24,7 @@ \rSec1[std.exceptions]{Exception classes} \pnum -The \Cpp standard library provides classes to be used to report certain errors~(\ref{res.on.exception.handling}) in +The \Cpp standard library provides classes to be used to report certain errors\iref{res.on.exception.handling} in \Cpp programs. In the error model reflected in these classes, errors are divided into two broad categories: @@ -561,19 +561,19 @@ except that a macro named \tcode{static_assert} is not defined. -\xref ISO C~7.2. +\xref ISO C 7.2 \rSec2[assertions.assert]{The \tcode{assert} macro} \pnum An expression \tcode{assert(E)} -is a constant subexpression~(\ref{defns.const.subexpr}), if +is a constant subexpression\iref{defns.const.subexpr}, if \begin{itemize} \item \tcode{NDEBUG} is defined at the point where \tcode{assert} is last defined or redefined, or \item -\tcode{E} contextually converted to \tcode{bool}~(Clause~\ref{conv}) +\tcode{E} contextually converted to \tcode{bool}\iref{conv} is a constant subexpression that evaluates to the value \tcode{true}. \end{itemize} @@ -758,7 +758,7 @@ \pnum The meaning of the macros in this header is defined by the POSIX standard. -\xref ISO C~7.5. +\xref ISO C 7.5 \rSec1[syserr]{System error support} @@ -769,7 +769,7 @@ \pnum Components described in this subclause shall not change the value of -\tcode{errno}~(\ref{errno}). +\tcode{errno}\iref{errno}. Implementations should leave the error states provided by other libraries unchanged. @@ -795,10 +795,10 @@ class system_error; template - struct is_error_code_enum : public false_type {}; + struct is_error_code_enum : public false_type {}; template - struct is_error_condition_enum : public false_type {}; + struct is_error_condition_enum : public false_type {}; enum class errc { address_family_not_supported, // \tcode{EAFNOSUPPORT} @@ -911,10 +911,10 @@ template <> struct hash; // \ref{syserr}, system error support - template inline constexpr bool is_error_code_enum_v - = is_error_code_enum::value; - template inline constexpr bool is_error_condition_enum_v - = is_error_condition_enum::value; + template + inline constexpr bool is_error_code_enum_v = is_error_code_enum::value; + template + inline constexpr bool is_error_condition_enum_v = is_error_condition_enum::value; } \end{codeblock} @@ -1077,7 +1077,7 @@ \pnum \returns \tcode{less()(this, \&rhs)}. -\begin{note} \tcode{less}~(\ref{comparisons}) provides a total ordering for pointers. \end{note} +\begin{note} \tcode{less}\iref{comparisons} provides a total ordering for pointers. \end{note} \end{itemdescr} \rSec3[syserr.errcat.derived]{Program defined classes derived from \tcode{error_category}} @@ -1383,7 +1383,7 @@ \pnum The class \tcode{error_condition} describes an object used to hold values identifying error conditions. \begin{note} \tcode{error_condition} values are portable abstractions, -while \tcode{error_code} values~(\ref{syserr.errcode}) are implementation specific. \end{note} +while \tcode{error_code} values\iref{syserr.errcode} are implementation specific. \end{note} \indexlibrary{\idxcode{error_condition}}% \begin{codeblock} @@ -1649,7 +1649,7 @@ \end{itemdecl} \begin{itemdescr} -\pnum The specializations are enabled~(\ref{unord.hash}). +\pnum The specializations are enabled\iref{unord.hash}. \end{itemdescr} \rSec2[syserr.syserr]{Class \tcode{system_error}} @@ -1665,7 +1665,7 @@ \pnum \begin{note} If an error represents an out-of-memory condition, implementations are -encouraged to throw an exception object of type \tcode{bad_alloc}~(\ref{bad.alloc}) rather +encouraged to throw an exception object of type \tcode{bad_alloc}\iref{bad.alloc} rather than \tcode{system_error}. \end{note} \indexlibrary{\idxcode{system_error}}% diff --git a/source/exceptions.tex b/source/exceptions.tex index 605371f2e2..ce99ca1f12 100644 --- a/source/exceptions.tex +++ b/source/exceptions.tex @@ -49,14 +49,14 @@ \end{bnf} The optional \grammarterm{attribute-specifier-seq} in an \grammarterm{exception-declaration} -appertains to the parameter of the catch clause~(\ref{except.handle}). +appertains to the parameter of the catch clause\iref{except.handle}. \pnum \indextext{exception handling!try block}% \indextext{exception handling!handler}% \indextext{try block|see{exception handling, try block}}% \indextext{handler|see{exception handling, handler}}% -A \grammarterm{try-block} is a \grammarterm{statement} (Clause~\ref{stmt.stmt}). +A \grammarterm{try-block} is a \grammarterm{statement}\iref{stmt.stmt}. \begin{note} Within this Clause ``try block'' is taken to mean both \grammarterm{try-block} and \grammarterm{function-try-block}. \end{note} @@ -181,7 +181,7 @@ \pnum In this section, ``before'' and ``after'' refer to the -``sequenced before'' relation~(\ref{intro.execution}). +``sequenced before'' relation\iref{intro.execution}. \rSec1[except.throw]{Throwing an exception}% \indextext{exception handling!throwing}% @@ -191,12 +191,12 @@ Throwing an exception transfers control to a handler. \begin{note} An exception can be thrown from one of the following contexts: -\grammarterm{throw-expression}{s}~(\ref{expr.throw}), -allocation functions~(\ref{basic.stc.dynamic.allocation}), -\tcode{dynamic_cast}~(\ref{expr.dynamic.cast}), -\tcode{typeid}~(\ref{expr.typeid}), -\grammarterm{new-expression}{s}~(\ref{expr.new}), and standard library -functions~(\ref{structure.specifications}). +\grammarterm{throw-expression}{s}\iref{expr.throw}, +allocation functions\iref{basic.stc.dynamic.allocation}, +\tcode{dynamic_cast}\iref{expr.dynamic.cast}, +\tcode{typeid}\iref{expr.typeid}, +\grammarterm{new-expression}{s}\iref{expr.new}, and standard library +functions\iref{structure.specifications}. \end{note} An object is passed and the type of that object determines which handlers can catch it. @@ -244,7 +244,7 @@ \indextext{exception handling!handler}% \indextext{exception handling!nearest handler}% When an exception is thrown, control is transferred to the nearest handler with -a matching type~(\ref{except.handle}); ``nearest'' means the handler +a matching type\iref{except.handle}; ``nearest'' means the handler for which the \grammarterm{compound-statement} or \grammarterm{ctor-initializer} @@ -259,7 +259,7 @@ \defnx{exception object}{exception handling!exception object}. An lvalue denoting the temporary is used to initialize the variable declared in the matching -\grammarterm{handler}~(\ref{except.handle}). +\grammarterm{handler}\iref{except.handle}. If the type of the exception object would be an incomplete type or a pointer to an incomplete type other than \cv{}~\tcode{void} the program is ill-formed. @@ -283,7 +283,7 @@ declared in the \grammarterm{exception-declaration} in the handler; \item -when an object of type \tcode{std::exception_ptr}~(\ref{propagation}) +when an object of type \tcode{std::exception_ptr}\iref{propagation} that refers to the exception object is destroyed, before the destructor of \tcode{std::exception_ptr} returns. \end{itemize} @@ -291,7 +291,7 @@ Among all points of potential destruction for the exception object, there is an unspecified last one where the exception object is destroyed. -All other points happen before that last one~(\ref{intro.races}). +All other points happen before that last one\iref{intro.races}. \begin{note} No other thread synchronization is implied in exception handling. \end{note} @@ -309,14 +309,14 @@ the copy-initialization as well as the constructor selected for a copy-initialization considering the thrown object as an lvalue shall be non-deleted and accessible, even if the copy/move operation is -elided~(\ref{class.copy}). -The destructor is potentially invoked~(\ref{class.dtor}). +elided\iref{class.copy}. +The destructor is potentially invoked\iref{class.dtor}. \pnum \indextext{exception handling!rethrow}% \indextext{rethrow|see{exception handling, rethrow}}% An exception is considered caught when a handler for that exception -becomes active~(\ref{except.handle}). +becomes active\iref{except.handle}. \begin{note} An exception can have active handlers and still be considered uncaught if it is rethrown. @@ -326,16 +326,16 @@ \indextext{exception handling!terminate called@\tcode{terminate} called}% \indextext{\idxcode{terminate}!called}% If the exception handling mechanism -handling an uncaught exception~(\ref{except.uncaught}) +handling an uncaught exception\iref{except.uncaught} directly invokes a function that exits via an -exception, \tcode{std::terminate} is called~(\ref{except.terminate}). +exception, \tcode{std::terminate} is called\iref{except.terminate}. \begin{example} \begin{codeblock} struct C { C() { } C(const C&) { if (std::uncaught_exceptions()) { - throw 0; // throw during copy to handler's \grammarterm{exception-declaration} object~(\ref{except.handle}) + throw 0; // throw during copy to handler's \grammarterm{exception-declaration} object\iref{except.handle} } } }; @@ -343,7 +343,7 @@ int main() { try { throw C(); // calls \tcode{std::terminate()} if construction of the handler's - // \grammarterm{exception-declaration} object is not elided~(\ref{class.copy}) + // \grammarterm{exception-declaration} object is not elided\iref{class.copy} } catch(C) { } } \end{codeblock} @@ -370,7 +370,7 @@ but not yet destroyed, since the try block was entered. If an exception is thrown during the destruction of temporaries or -local variables for a \tcode{return} statement~(\ref{stmt.return}), +local variables for a \tcode{return} statement\iref{stmt.return}, the destructor for the returned object (if any) is also invoked. The objects are destroyed in the reverse order of the completion of their construction. @@ -392,7 +392,7 @@ } \end{codeblock} At \#1, the returned object of type \tcode{A} is constructed. -Then, the local variable \tcode{b} is destroyed~(\ref{stmt.jump}). +Then, the local variable \tcode{b} is destroyed\iref{stmt.jump}. Next, the local variable \tcode{y} is destroyed, causing stack unwinding, resulting in the destruction of the returned object, @@ -407,7 +407,7 @@ the destructor is invoked for each of the object's direct subobjects and, for a complete object, virtual base class subobjects, -whose initialization has completed~(\ref{dcl.init}) +whose initialization has completed\iref{dcl.init} and whose destructor has not yet begun execution, except that in the case of destruction, the variant members of a union-like class are not destroyed. @@ -427,8 +427,8 @@ \pnum \begin{note} -If the object was allocated by a \grammarterm{new-expression}~(\ref{expr.new}), -the matching deallocation function~(\ref{basic.stc.dynamic.deallocation}), +If the object was allocated by a \grammarterm{new-expression}\iref{expr.new}, +the matching deallocation function\iref{basic.stc.dynamic.deallocation}, if any, is called to free the storage occupied by the object. \end{note} @@ -502,12 +502,12 @@ \begin{itemize} \item% -a standard pointer conversion~(\ref{conv.ptr}) not involving conversions +a standard pointer conversion\iref{conv.ptr} not involving conversions to pointers to private or protected or ambiguous classes \item% -a function pointer conversion~(\ref{conv.fctptr}) +a function pointer conversion\iref{conv.fctptr} \item% -a qualification conversion~(\ref{conv.qual}), or +a qualification conversion\iref{conv.qual}, or \end{itemize} @@ -522,7 +522,7 @@ whose operand is an integer literal with value zero does not match a handler of pointer or pointer to member type. A handler of reference to array or function type -is never a match for any exception object~(\ref{expr.throw}). +is never a match for any exception object\iref{expr.throw}. \end{note} \begin{example} @@ -586,8 +586,8 @@ of the same thread. \pnum -A handler is considered active when initialization is complete for -the parameter (if any) of the catch clause. +A handler is considered \defnx{active}{exception handling!handler!active} when +initialization is complete for the parameter (if any) of the catch clause. \begin{note} The stack will have been unwound at that point. \end{note} @@ -610,7 +610,7 @@ whether or not the stack is unwound before this call to \tcode{std::terminate()} is \impldef{stack unwinding before call to -\tcode{std::terminate()}}~(\ref{except.terminate}). +\tcode{std::terminate()}}\iref{except.terminate}. \pnum Referring to any non-static member or base class of an object @@ -628,7 +628,7 @@ constructors of namespace-scope objects with static storage duration are not caught by a \grammarterm{function-try-block} on -the \tcode{main} function~(\ref{basic.start.main}). +the \tcode{main} function\iref{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. @@ -660,9 +660,9 @@ \begin{itemize} \item if \tcode{T} is a base class of \tcode{E}, the variable is -copy-initialized~(\ref{dcl.init}) from the corresponding base class subobject +copy-initialized\iref{dcl.init} from the corresponding base class subobject of the exception object; -\item otherwise, the variable is copy-initialized~(\ref{dcl.init}) +\item otherwise, the variable is copy-initialized\iref{dcl.init} from the exception object. \end{itemize} @@ -697,7 +697,7 @@ The exception specification is either defined implicitly, or defined explicitly by using a \grammarterm{noexcept-specifier} -as a suffix of a function declarator~(\ref{dcl.fct}). +as a suffix of a function declarator\iref{dcl.fct}. \begin{bnf} \nontermdef{noexcept-specifier}\br @@ -710,19 +710,19 @@ \indextext{exception specification!noexcept!constant expression and}% In a \grammarterm{noexcept-specifier}, the \grammarterm{constant-expression}, if supplied, shall be a contextually converted constant expression -of type \tcode{bool}~(\ref{expr.const}); +of type \tcode{bool}\iref{expr.const}; that constant expression is the exception specification of the function type in which the \grammarterm{noexcept-specifier} appears. A \tcode{(} token that follows \tcode{noexcept} is part of the \grammarterm{noexcept-specifier} and does not commence an -initializer~(\ref{dcl.init}). +initializer\iref{dcl.init}. The \grammarterm{noexcept-specifier} \tcode{noexcept} without a \grammarterm{constant-expression} is equivalent to the \grammarterm{noexcept-specifier} \tcode{noexcept(true)}. The \grammarterm{noexcept-specifier} \tcode{throw()} -is deprecated~(\ref{depr.except.spec}), and +is deprecated\iref{depr.except.spec}, and equivalent to the \grammarterm{noexcept-specifier} \tcode{noexcept(true)}. @@ -732,11 +732,11 @@ the declaration has a potentially throwing exception specification unless it is a destructor or a deallocation function or is defaulted on its first declaration, -in which cases the exception specfication +in which cases the exception specification is as specified below and no other declaration for that function shall have a \grammarterm{noexcept-specifier}. -In an explicit instantiation~(\ref{temp.explicit}) +In an explicit instantiation\iref{temp.explicit} a \grammarterm{noexcept-specifier} may be specified, but is not required. If a \grammarterm{noexcept-specifier} is specified @@ -784,10 +784,10 @@ \indextext{exception handling!terminate called@\tcode{terminate} called}% \indextext{\idxcode{terminate}!called}% Whenever an exception is thrown -and the search for a handler~(\ref{except.handle}) +and the search for a handler\iref{except.handle} encounters the outermost block of a function with a non-throwing exception specification, -the function \tcode{std::terminate()} is called~(\ref{except.terminate}). +the function \tcode{std::terminate()} is called\iref{except.terminate}. \begin{note} An implementation shall not reject an expression merely because, when executed, it throws or might @@ -815,7 +815,7 @@ \begin{itemize} \item -\tcode{e} is a function call (\ref{expr.call}) +\tcode{e} is a function call\iref{expr.call} whose \grammarterm{postfix-expression} has a function type, or a pointer-to-function type, @@ -826,24 +826,24 @@ (such as an overloaded operator, an allocation function in a \grammarterm{new-expression}, a constructor for a function argument, -or a destructor if \tcode{e} is a full-expression~(\ref{intro.execution})) +or a destructor if \tcode{e} is a full-expression\iref{intro.execution}) that is potentially-throwing, or \item -\tcode{e} is a \grammarterm{throw-expression}~(\ref{expr.throw}), +\tcode{e} is a \grammarterm{throw-expression}\iref{expr.throw}, or \item \tcode{e} is a \tcode{dynamic_cast} expression that casts to a reference type and -requires a runtime check~(\ref{expr.dynamic.cast}), +requires a runtime check\iref{expr.dynamic.cast}, or \item \tcode{e} is a \tcode{typeid} expression applied to a (possibly parenthesized) built-in unary \tcode{*} operator applied to a pointer to a -polymorphic class type~(\ref{expr.typeid}), +polymorphic class type\iref{expr.typeid}, or \item -any of the immediate subexpressions~(\ref{intro.execution}) +any of the immediate subexpressions\iref{intro.execution} of \tcode{e} is potentially-throwing. \end{itemize} @@ -870,7 +870,7 @@ \begin{note} Even though destructors for fully-constructed subobjects are invoked when an exception is thrown -during the execution of a constructor~(\ref{except.ctor}), +during the execution of a constructor\iref{except.ctor}, their exception specifications do not contribute to the exception specification of the constructor, because an exception thrown from such a destructor @@ -883,7 +883,7 @@ or a destructor without a \grammarterm{noexcept-specifier}, is potentially-throwing if and only if any of the destructors -for any of its potentially constructed subojects +for any of its potentially constructed subobjects is potentially throwing. \pnum @@ -895,7 +895,7 @@ in the implicit definition is potentially-throwing. \pnum -A deallocation function~(\ref{basic.stc.dynamic.deallocation}) +A deallocation function\iref{basic.stc.dynamic.deallocation} with no explicit \grammarterm{noexcept-specifier} has a non-throwing exception specification. @@ -920,7 +920,7 @@ // \tcode{D::D()} potentially-throwing, as the \tcode{new} operator may throw \tcode{bad_alloc} or \tcode{bad_array_new_length} // \tcode{D::D(const D\&)} non-throwing // \tcode{D::D(D\&\&)} potentially-throwing, as the default argument for \tcode{B}'s constructor may throw - // \tcode{D::~D()} potentially-throwing + // \tcode{D::\~D()} potentially-throwing }; \end{codeblock} Furthermore, if @@ -939,7 +939,7 @@ \item in an expression, the function is the unique lookup result or the selected member of a set of overloaded functions~(\ref{basic.lookup}, \ref{over.match}, \ref{over.over}); -\item the function is odr-used~(\ref{basic.def.odr}) or, if it appears in an +\item the function is odr-used\iref{basic.def.odr} or, if it appears in an unevaluated operand, would be odr-used if the expression were potentially-evaluated; @@ -969,12 +969,12 @@ \rSec1[except.special]{Special functions} \pnum -The function \tcode{std::terminate()}~(\ref{except.terminate}) +The function \tcode{std::terminate()}\iref{except.terminate} is used by the exception handling mechanism for coping with errors related to the exception handling mechanism itself. The function -\tcode{std::current_exception()}~(\ref{propagation}) and the class -\tcode{std::nested_exception}~(\ref{except.nested}) can be used by a program to +\tcode{std::current_exception()}\iref{propagation} and the class +\tcode{std::nested_exception}\iref{except.nested} can be used by a program to capture the currently handled exception. \rSec2[except.terminate]{The \tcode{std::terminate()} function} @@ -990,63 +990,63 @@ when the exception handling mechanism, after completing the initialization of the exception object but before -activation of a handler for the exception~(\ref{except.throw}), +activation of a handler for the exception\iref{except.throw}, calls a function that exits via an exception, or \item% -when the exception handling mechanism cannot find a handler for a thrown exception~(\ref{except.handle}), or +when the exception handling mechanism cannot find a handler for a thrown exception\iref{except.handle}, or -\item when the search for a handler~(\ref{except.handle}) encounters the +\item when the search for a handler\iref{except.handle} encounters the outermost block of a function -with a non-throwing exception specification~(\ref{except.spec}), or +with a non-throwing exception specification\iref{except.spec}, or \item% -when the destruction of an object during stack unwinding~(\ref{except.ctor}) +when the destruction of an object during stack unwinding\iref{except.ctor} terminates by throwing an exception, or \item% when initialization of a non-local -variable with static or thread storage duration~(\ref{basic.start.dynamic}) +variable with static or thread storage duration\iref{basic.start.dynamic} exits via an exception, or \item% when destruction of an object with static or thread storage duration exits -via an exception~(\ref{basic.start.term}), or +via an exception\iref{basic.start.term}, or \item% when execution of a function registered with \tcode{std::atexit} or \tcode{std::at_quick_exit} -exits via an exception~(\ref{support.start.term}), or +exits via an exception\iref{support.start.term}, or \item% when a -\grammarterm{throw-expression}~(\ref{expr.throw}) +\grammarterm{throw-expression}\iref{expr.throw} with no operand attempts to rethrow an exception and no exception is being -handled~(\ref{except.throw}), or +handled\iref{except.throw}, or \item% when the function \tcode{std::nested_exception::rethrow_nested} is called for an object -that has captured no exception~(\ref{except.nested}), or +that has captured no exception\iref{except.nested}, or \item% when execution of the initial function of a thread exits via -an exception~(\ref{thread.thread.constr}), or +an exception\iref{thread.thread.constr}, or \item% for a parallel algorithm whose \tcode{ExecutionPolicy} specifies such behavior~(\ref{execpol.seq}, \ref{execpol.par}, \ref{execpol.parunseq}), -when execution of an element access function~(\ref{algorithms.parallel.defns}) -of the parallel algorithm exits via an exception~(\ref{algorithms.parallel.exceptions}), or +when execution of an element access function\iref{algorithms.parallel.defns} +of the parallel algorithm exits via an exception\iref{algorithms.parallel.exceptions}, or \item% when the destructor or the copy assignment operator is invoked on an object of type \tcode{std::thread} that refers to a joinable thread -(\ref{thread.thread.destr},~\ref{thread.thread.assign}), or +(\ref{thread.thread.destr}, \ref{thread.thread.assign}), or \item% when a call to a \tcode{wait()}, \tcode{wait_until()}, or \tcode{wait_for()} -function on a condition variable~(\ref{thread.condition.condvar},~\ref{thread.condition.condvarany}) +function on a condition variable~(\ref{thread.condition.condvar}, \ref{thread.condition.condvarany}) fails to meet a postcondition. \end{itemize} @@ -1057,16 +1057,16 @@ \indextext{\idxcode{terminate}}% In such cases, \tcode{std::terminate()} -is called~(\ref{exception.terminate}). +is called\iref{exception.terminate}. In the situation where no matching handler is found, it is \impldef{stack unwinding before call to \tcode{std::terminate()}} whether or not the stack is unwound before \tcode{std::terminate()} is called. -In the situation where the search for a handler~(\ref{except.handle}) encounters the +In the situation where the search for a handler\iref{except.handle} encounters the outermost block of a function -with a non-throwing exception specification~(\ref{except.spec}), it is +with a non-throwing exception specification\iref{except.spec}, it is \impldef{whether stack is unwound before calling \tcode{std::ter\-mi\-nate()} when a \tcode{noexcept} specification is violated} @@ -1085,12 +1085,12 @@ \pnum An exception is considered uncaught -after completing the initialization of the exception object~(\ref{except.throw}) -until completing the activation of a handler for the exception~(\ref{except.handle}). +after completing the initialization of the exception object\iref{except.throw} +until completing the activation of a handler for the exception\iref{except.handle}. This includes stack unwinding. If an exception is rethrown~(\ref{expr.throw}, \ref{propagation}), it is considered uncaught from the point of rethrow until the rethrown exception is caught. -The function \tcode{std::uncaught_exceptions()}~(\ref{uncaught.exceptions}) +The function \tcode{std::uncaught_exceptions()}\iref{uncaught.exceptions} returns the number of uncaught exceptions in the current thread.% \indextext{exception handling|)} diff --git a/source/expressions.tex b/source/expressions.tex index 7b7dfabbb2..5b99d285b2 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -16,7 +16,7 @@ \pnum \indextext{expression|(}% \begin{note} -Clause~\ref{expr} defines the syntax, order of evaluation, and meaning +\ref{expr} defines the syntax, order of evaluation, and meaning of expressions.\footnote{The precedence of operators is not directly specified, but it can be derived from the syntax.} An expression is a sequence of operators and operands that specifies a @@ -28,18 +28,18 @@ \indextext{operator!overloaded}% \begin{note} Operators can be overloaded, that is, given meaning when applied to -expressions of class type~(Clause \ref{class}) or enumeration -type~(\ref{dcl.enum}). Uses of overloaded operators are transformed into +expressions of class type\iref{class} or enumeration +type\iref{dcl.enum}. Uses of overloaded operators are transformed into function calls as described in~\ref{over.oper}. Overloaded operators -obey the rules for syntax and evaluation order specified in Clause~\ref{expr}, +obey the rules for syntax and evaluation order specified in \ref{expr}, but the requirements of operand type and value category are replaced by the rules for function call. Relations between operators, such as \tcode{++a} meaning \tcode{a+=1}, are not guaranteed for overloaded -operators~(\ref{over.oper}). +operators\iref{over.oper}. \end{note} \pnum -Clause~\ref{expr} defines the effects of operators when applied to types +\ref{expr} defines the effects of operators when applied to types for which they have not been overloaded. Operator overloading shall not modify the rules for the \defnx{built-in operators}{operators!built-in}, that is, for operators applied to types for which they are defined by this @@ -48,8 +48,8 @@ considered where necessary to convert the operands to types appropriate for the built-in operator. If a built-in operator is selected, such conversions will be applied to the operands before the operation is -considered further according to the rules in Clause~\ref{expr}; -see~\ref{over.match.oper},~\ref{over.built}. +considered further according to the rules in \ref{expr}; +see~\ref{over.match.oper}, \ref{over.built}. \pnum \indextext{exception!arithmetic}% @@ -70,7 +70,7 @@ \pnum \indextext{expression!reference}% If an expression initially has the type ``reference to -\tcode{T}''~(\ref{dcl.ref},~\ref{dcl.init.ref}), the type is adjusted to +\tcode{T}''~(\ref{dcl.ref}, \ref{dcl.init.ref}), the type is adjusted to \tcode{T} prior to any further analysis. The expression designates the object or function denoted by the reference, and the expression is an lvalue or an xvalue, depending on the expression. @@ -124,20 +124,25 @@ \pnum In some contexts, \defnx{unevaluated operands}{unevaluated operand} -appear~(\ref{expr.typeid}, \ref{expr.sizeof}, \ref{expr.unary.noexcept}, \ref{dcl.type.simple}). +appear~(\ref{expr.prim.req}, +\ref{expr.typeid}, +\ref{expr.sizeof}, +\ref{expr.unary.noexcept}, +\ref{dcl.type.simple}, +\ref{temp}). An unevaluated operand is not evaluated. \begin{note} In an unevaluated operand, a non-static class member may be -named~(\ref{expr.prim}) and naming of objects or functions does not, by -itself, require that a definition be provided~(\ref{basic.def.odr}). -An unevaluated operand is considered a full-expression~(\ref{intro.execution}). +named\iref{expr.prim} and naming of objects or functions does not, by +itself, require that a definition be provided\iref{basic.def.odr}. +An unevaluated operand is considered a full-expression\iref{intro.execution}. \end{note} \pnum Whenever a glvalue expression appears as an operand of an operator that expects a prvalue for that operand, the -lvalue-to-rvalue~(\ref{conv.lval}), array-to-pointer~(\ref{conv.array}), -or function-to-pointer~(\ref{conv.func}) standard conversions are +lvalue-to-rvalue\iref{conv.lval}, array-to-pointer\iref{conv.array}, +or function-to-pointer\iref{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 @@ -149,7 +154,7 @@ \pnum Whenever a prvalue expression appears as an operand of an operator that expects a glvalue for that operand, the -temporary materialization conversion~(\ref{conv.rval}) is +temporary materialization conversion\iref{conv.rval} is applied to convert the expression to an xvalue. \pnum @@ -161,7 +166,7 @@ which are defined as follows: \begin{itemize} -\item If either operand is of scoped enumeration type~(\ref{dcl.enum}), no conversions +\item If either operand is of scoped enumeration type\iref{dcl.enum}, no conversions are performed; if the other operand does not have the same type, the expression is ill-formed. @@ -174,7 +179,7 @@ \item Otherwise, if either operand is \tcode{float}, the other shall be converted to \tcode{float}. -\item Otherwise, the integral promotions~(\ref{conv.prom}) shall be +\item Otherwise, the integral promotions\iref{conv.prom} shall be performed on both operands.\footnote{As a consequence, operands of type \tcode{bool}, \tcode{char16_t}, \tcode{char32_t}, \tcode{wchar_t}, or an enumerated type are converted to some integral type.} @@ -209,9 +214,9 @@ \pnum In some contexts, an expression only appears for its side effects. Such an expression is called a \defn{discarded-value expression}. -The array-to-pointer~(\ref{conv.array}) -and function-to-pointer~(\ref{conv.func}) standard conversions are not -applied. The lvalue-to-rvalue conversion~(\ref{conv.lval}) is applied +The array-to-pointer\iref{conv.array} +and function-to-pointer\iref{conv.func} standard conversions are not +applied. The lvalue-to-rvalue conversion\iref{conv.lval} is applied if and only if the expression is a glvalue of volatile-qualified type and it is one of the following: @@ -219,26 +224,26 @@ \begin{itemize} \item \tcode{(} \grammarterm{expression} \tcode{)}, where \grammarterm{expression} is one of these expressions, -\item \grammarterm{id-expression}~(\ref{expr.prim.id}), -\item subscripting~(\ref{expr.sub}), -\item class member access~(\ref{expr.ref}), -\item indirection~(\ref{expr.unary.op}), -\item pointer-to-member operation~(\ref{expr.mptr.oper}), -\item conditional expression~(\ref{expr.cond}) where both the second and the +\item \grammarterm{id-expression}\iref{expr.prim.id}, +\item subscripting\iref{expr.sub}, +\item class member access\iref{expr.ref}, +\item indirection\iref{expr.unary.op}, +\item pointer-to-member operation\iref{expr.mptr.oper}, +\item conditional expression\iref{expr.cond} where both the second and the third operands are one of these expressions, or -\item comma expression~(\ref{expr.comma}) where the right operand is one of +\item comma expression\iref{expr.comma} where the right operand is one of these expressions. \end{itemize} \begin{note} Using an overloaded operator causes a function call; the above covers only operators with built-in meaning. \end{note} -If the expression is a prvalue after this optional conversion, -the temporary materialization conversion~(\ref{conv.rval}) is applied. +If the (possibly converted) expression is a prvalue, +the temporary materialization conversion\iref{conv.rval} is applied. \begin{note} If the expression is an lvalue of class type, it must have a volatile copy constructor to initialize the -temporary that is the result object of the lvalue-to-rvalue +temporary object that is the result object of the lvalue-to-rvalue conversion. \end{note} The glvalue expression is evaluated and its value is discarded. @@ -247,13 +252,13 @@ expressions may be represented in greater precision and range than that required by the type; the types are not changed\ thereby.\footnote{The cast and assignment operators must still perform their specific -conversions as described in~\ref{expr.cast},~\ref{expr.static.cast} +conversions as described in~\ref{expr.cast}, \ref{expr.static.cast} and~\ref{expr.ass}.} \pnum The \defnx{cv-combined type}{type!cv-combined} of two types \tcode{T1} and \tcode{T2} is a type \tcode{T3} -similar to \tcode{T1} whose cv-qualification signature~(\ref{conv.qual}) is: +similar to \tcode{T1} whose cv-qualification signature\iref{conv.qual} is: \begin{itemize} \item for every $i > 0$, $cv^3_i$ is the union of @@ -301,7 +306,7 @@ \item if \tcode{T1} is ``pointer to \cvqual{cv1} \tcode{C1}'' and \tcode{T2} is ``pointer to \cvqual{cv2} \tcode{C2}'', where \tcode{C1} is reference-related to \tcode{C2} or \tcode{C2} is -reference-related to \tcode{C1}~(\ref{dcl.init.ref}), the cv-combined type +reference-related to \tcode{C1}\iref{dcl.init.ref}, the cv-combined type of \tcode{T1} and \tcode{T2} or the cv-combined type of \tcode{T2} and \tcode{T1}, respectively; @@ -309,11 +314,11 @@ if \tcode{T1} is ``pointer to member of \tcode{C1} of type \cvqual{cv1} \tcode{U1}'' and \tcode{T2} is ``pointer to member of \tcode{C2} of type \cvqual{cv2} \tcode{U2}'' where \tcode{C1} is reference-related to \tcode{C2} or \tcode{C2} is reference-related to -\tcode{C1}~(\ref{dcl.init.ref}), the cv-combined type of \tcode{T2} and \tcode{T1} or the cv-combined type +\tcode{C1}\iref{dcl.init.ref}, the cv-combined type of \tcode{T2} and \tcode{T1} or the cv-combined type of \tcode{T1} and \tcode{T2}, respectively; \item -if \tcode{T1} and \tcode{T2} are similar types~(\ref{conv.qual}), the cv-combined type of \tcode{T1} and +if \tcode{T1} and \tcode{T2} are similar types\iref{conv.qual}, the cv-combined type of \tcode{T1} and \tcode{T2}; \item @@ -344,7 +349,8 @@ \terminal{(} expression \terminal{)}\br id-expression\br lambda-expression\br - fold-expression + fold-expression\br + requires-expression \end{bnf} \rSec2[expr.prim.literal]{Literals} @@ -355,7 +361,7 @@ \indextext{constant}% \grammarterm{literal} is a primary expression. -Its type depends on its form~(\ref{lex.literal}). +Its type depends on its form\iref{lex.literal}. A string literal is an lvalue; all other literals are prvalues. \rSec2[expr.prim.this]{This} @@ -363,8 +369,8 @@ \pnum \indextext{\idxcode{this}}% The keyword \tcode{this} names a pointer to the object for which a non-static member -function~(\ref{class.this}) is invoked or a non-static data member's -initializer~(\ref{class.mem}) is evaluated. +function\iref{class.this} is invoked or a non-static data member's +initializer\iref{class.mem} is evaluated. \pnum If a declaration declares a member function or member function template of a @@ -376,11 +382,12 @@ the declaration of a static member function (although its type and value category are defined within a static member function as they are within a non-static member function). \begin{note} This is because declaration matching does not -occur until the complete declarator is known. \end{note} Unlike the object -expression in other contexts, \tcode{*this} is not required to be of complete -type for purposes of class member access~(\ref{expr.ref}) outside the member -function body. \begin{note} Only class members declared prior to the declaration -are visible. \end{note} +occur until the complete declarator is known. \end{note} +\begin{note} +In a \grammarterm{trailing-return-type}, +the class being defined is not required to be complete +for purposes of class member access\iref{expr.ref}. +Class members declared later are not visible. \begin{example} \begin{codeblock} struct A { @@ -391,12 +398,13 @@ template auto A::f(int t) -> decltype(t + g()); \end{codeblock} \end{example} +\end{note} \pnum Otherwise, if a \grammarterm{member-declarator} declares a non-static data -member~(\ref{class.mem}) of a class \tcode{X}, the expression \tcode{this} is +member\iref{class.mem} of a class \tcode{X}, the expression \tcode{this} is a prvalue of type ``pointer to \tcode{X}'' within the -optional default member initializer~(\ref{class.mem}). It shall not appear elsewhere +optional default member initializer\iref{class.mem}. It shall not appear elsewhere in the \grammarterm{member-declarator}. \pnum @@ -443,7 +451,7 @@ \grammarterm{primary-expression}. \begin{note} An \grammarterm{id-expression} can appear after \tcode{.} and \tcode{->} -operators~(\ref{expr.ref}). +operators\iref{expr.ref}. \end{note} \pnum @@ -451,13 +459,13 @@ non-static member function of a class can only be used: \begin{itemize} -\item as part of a class member access~(\ref{expr.ref}) in which the +\item as part of a class member access\iref{expr.ref} in which the object expression refers to the member's class\footnote{This also applies when the object expression is an implicit \tcode{(*this)}~(\ref{class.mfct.non-static}).} or a class derived from that class, or -\item to form a pointer to member~(\ref{expr.unary.op}), or +\item to form a pointer to member\iref{expr.unary.op}, or \item if that \grammarterm{id-expression} denotes a non-static data member and it appears in an unevaluated operand. @@ -473,6 +481,54 @@ \end{example} \end{itemize} +\pnum +An \grammarterm{id-expression} +that denotes the specialization of a concept\iref{temp.concept} +results in a prvalue of type \tcode{bool}. +The expression is \tcode{true} if +the concept's normalized +\grammarterm{constraint-expression}\iref{temp.constr.decl} +is satisfied\iref{temp.constr.constr} +by the specified template arguments +and \tcode{false} otherwise. +\begin{example} +\begin{codeblock} +template concept C = true; +static_assert(C); // OK +\end{codeblock} +\end{example} +\begin{note} +A concept's constraints are also considered +when using a template name\iref{temp.names} +and during overload resolution\iref{over}, +and they are compared +during the the partial ordering of constraints\iref{temp.constr.order}. +\end{note} + +\pnum +A program that refers +explicitly or implicitly +to a function with a \grammarterm{requires-clause} +whose \grammarterm{constraint-expression} is not satisfied, +other than to declare it, +is ill-formed. +\begin{example} +\begin{codeblock} +void f(int) requires false; + +void g() { + f(0); // error: cannot call \tcode{f} + void (*p1)(int) = f; // error: cannot take the address of \tcode{f} + decltype(f)* p2 = nullptr; // error: the type \tcode{decltype(f)} is invalid +} +\end{codeblock} +In each case, the constraints of \tcode{f} are not satisfied. +In the declaration of \tcode{p2}, +those constraints are required to be satisfied +even though +\tcode{f} is an unevaluated operand\iref{expr}. +\end{example} + \rSec3[expr.prim.id.unqual]{Unqualified names} \begin{bnf} @@ -489,7 +545,7 @@ \pnum \indextext{identifier}% An \grammarterm{identifier} is an \grammarterm{id-expression} provided it has -been suitably declared (Clause~\ref{dcl.dcl}). +been suitably declared\iref{dcl.dcl}. \begin{note} For \grammarterm{operator-function-id}{s}, see~\ref{over.oper}; for \grammarterm{conversion-function-id}{s}, see~\ref{class.conv.fct}; for @@ -504,7 +560,7 @@ The type of the expression is the type of the \grammarterm{identifier}. The result is the entity denoted by the identifier. The expression is an lvalue if the entity is a function, variable, or data member and a prvalue otherwise; -it is a bit-field if the identifier designates a bit-field~(\ref{dcl.struct.bind}). +it is a bit-field if the identifier designates a bit-field\iref{dcl.struct.bind}. \rSec3[expr.prim.id.qual]{Qualified names} @@ -536,9 +592,9 @@ \pnum A \grammarterm{nested-name-specifier} that denotes a class, optionally -followed by the keyword \tcode{template}~(\ref{temp.names}), and then -followed by the name of a member of either that class~(\ref{class.mem}) -or one of its base classes (Clause~\ref{class.derived}), is a +followed by the keyword \tcode{template}\iref{temp.names}, and then +followed by the name of a member of either that class\iref{class.mem} +or one of its base classes\iref{class.derived}, is a \indextext{id!qualified}% \grammarterm{qualified-id};~\ref{class.qual} describes name lookup for class members that appear in \grammarterm{qualified-id}{s}. The result is the @@ -547,24 +603,24 @@ prvalue otherwise. \begin{note} A class member can be referred to using a \grammarterm{qualified-id} at any -point in its potential scope~(\ref{basic.scope.class}). +point in its potential scope\iref{basic.scope.class}. \end{note} Where \grammarterm{class-name} \tcode{::\tilde}~\grammarterm{class-name} is used, the two \grammarterm{class-name}{s} shall refer to the same class; this -notation names the destructor~(\ref{class.dtor}). +notation names the destructor\iref{class.dtor}. 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 -\grammarterm{class-name}~(\ref{class.name}). +\grammarterm{class-name}\iref{class.name}. \end{note} \pnum The \grammarterm{nested-name-specifier} \tcode{::} names the global namespace. A \grammarterm{nested-name-specifier} that names a -namespace~(\ref{basic.namespace}), optionally followed by the keyword -\tcode{template}~(\ref{temp.names}), and then followed by the name of a member +namespace\iref{basic.namespace}, optionally followed by the keyword +\tcode{template}\iref{temp.names}, and then followed by the name of a member of that namespace (or the name of a member of a namespace made visible by a \grammarterm{using-directive}), is a \indextext{id!qualified}% @@ -575,7 +631,7 @@ \pnum A \grammarterm{nested-name-specifier} that denotes an -enumeration~(\ref{dcl.enum}), followed by the name of an +enumeration\iref{dcl.enum}, followed by the name of an enumerator of that enumeration, is a \grammarterm{qualified-id} that refers to the enumerator. The result is the enumerator. The type of the result is the type of the enumeration. The result is a prvalue. @@ -594,7 +650,8 @@ \begin{bnf} \nontermdef{lambda-expression}\br - lambda-introducer lambda-declarator\opt compound-statement + lambda-introducer lambda-declarator\opt{} compound-statement\br + lambda-introducer \tcode{<} template-parameter-list \tcode{>} lambda-declarator\opt{} compound-statement \end{bnf} \begin{bnf} @@ -623,8 +680,8 @@ \pnum A \grammarterm{lambda-expression} is a prvalue whose result object is called the \defn{closure object}. A -\grammarterm{lambda-expression} shall not appear in an unevaluated operand -(Clause~\ref{expr}), in a \grammarterm{template-argument}, +\grammarterm{lambda-expression} shall not appear in an unevaluated operand\iref{expr}, +in a \grammarterm{template-argument}, in an \grammarterm{alias-declaration}, in a typedef declaration, or in the declaration of a function or function template outside its function body and default arguments. @@ -633,7 +690,7 @@ \end{note} \begin{note} A closure object behaves like a function -object~(\ref{function.objects}).\end{note} +object\iref{function.objects}.\end{note} \pnum In the \grammarterm{decl-specifier-seq} of the \grammarterm{lambda-declarator}, @@ -657,6 +714,19 @@ \end{codeblock} \end{example} +\pnum +A lambda is a \defn{generic lambda} +if the \tcode{auto} \grammarterm{type-specifier} appears as one of the +\grammarterm{decl-specifier}{s} in the \grammarterm{decl-specifier-seq} of a +\grammarterm{parameter-declaration} of the \grammarterm{lambda-expression}, +or if the lambda has a \grammarterm{template-parameter-list}. +\begin{example} +\begin{codeblock} +int i = [](int i, auto a) { return i; }(3, 4); // OK: a generic lambda +int j = [](T t, int i) { return i; }(3, 4); // OK: a generic lambda +\end{codeblock} +\end{example} + \rSec3[expr.prim.lambda.closure]{Closure types}% \pnum @@ -669,9 +739,9 @@ The closure type is declared in the smallest block scope, class scope, or namespace scope that contains the corresponding \grammarterm{lambda-expression}. \begin{note} This determines the set of namespaces and -classes associated with the closure type~(\ref{basic.lookup.argdep}). The parameter +classes associated with the closure type\iref{basic.lookup.argdep}. The parameter types of a \grammarterm{lambda-declarator} do not affect these associated namespaces and -classes. \end{note} The closure type is not an aggregate type~(\ref{dcl.init.aggr}). +classes. \end{note} The closure type is not an aggregate type\iref{dcl.init.aggr}. An implementation may define the closure type differently from what is described below provided this does not alter the observable behavior of the program other than by changing: @@ -679,12 +749,12 @@ \begin{itemize} \item the size and/or alignment of the closure type, -\item whether the closure type is trivially copyable (Clause~\ref{class}), +\item whether the closure type is trivially copyable\iref{class}, -\item whether the closure type is a standard-layout class (Clause~\ref{class}), +\item whether the closure type is a standard-layout class\iref{class}, or -\item whether the closure type is a POD class (Clause~\ref{class}). +\item whether the closure type is a POD class\iref{class}. \end{itemize} An implementation shall not add members of rvalue reference type to the closure @@ -692,18 +762,20 @@ \pnum The closure type for a non-generic \grammarterm{lambda-expression} has a public -inline function call operator~(\ref{over.call}) whose parameters and return type +inline function call operator\iref{over.call} whose parameters and return type are described by the \grammarterm{lambda-expression}'s \grammarterm{parameter-declaration-clause} and \grammarterm{trailing-return-type} respectively. For a generic lambda, the closure type has a public inline function call -operator member template~(\ref{temp.mem}) whose -\grammarterm{template-parameter-list} consists of one invented type +operator member template\iref{temp.mem} whose +\grammarterm{template-parameter-list} consists of +the specified \grammarterm{template-parameter-list}, if any, +to which is appended one invented type \grammarterm{template-parameter} for each occurrence of \tcode{auto} in the lambda's \grammarterm{parameter-declaration-clause}, in order of appearance. The invented type \grammarterm{template-parameter} is a parameter pack if the corresponding \grammarterm{parameter-declaration} declares a function -parameter pack~(\ref{dcl.fct}). The return type and function parameters of the +parameter pack\iref{dcl.fct}. The return type and function parameters of the function call operator template are derived from the \grammarterm{lambda-expression}{'s} \grammarterm{trailing-return-type} and \grammarterm{parameter-declaration-clause} by replacing each occurrence of @@ -744,7 +816,7 @@ is a constexpr function if either the corresponding \grammarterm{lambda-expression}{'s} \grammarterm{parameter-declaration-clause} is followed by \tcode{constexpr}, or -it satisfies the requirements for a constexpr function~(\ref{dcl.constexpr}). +it satisfies the requirements for a constexpr function\iref{dcl.constexpr}. \begin{note} Names referenced in the \grammarterm{lambda-declarator} are looked up in the context in which the \grammarterm{lambda-expression} appears. \end{note} @@ -793,7 +865,7 @@ The closure type for a non-generic \grammarterm{lambda-expression} with no \grammarterm{lambda-capture} has a conversion function to pointer to -function with \Cpp language linkage~(\ref{dcl.link}) having +function with \Cpp language linkage\iref{dcl.link} having the same parameter and return types as the closure type's function call operator. The conversion is to ``pointer to \tcode{noexcept} function'' if the function call operator @@ -806,7 +878,7 @@ For a generic lambda with no \grammarterm{lambda-capture}, the closure type has a conversion function template to pointer to function. The conversion function template has the same invented -\grammarterm{template-parameter-list}, and the pointer to function has the same +template parameter list, and the pointer to function has the same parameter types, as the function call operator template. The return type of the pointer to function shall behave as if it were a \grammarterm{decltype-specifier} denoting the return type of the corresponding @@ -886,7 +958,7 @@ \pnum The conversion function or conversion function template is public, constexpr, non-virtual, non-explicit, const, and has a non-throwing exception -specification~(\ref{except.spec}). +specification\iref{except.spec}. \begin{example} \begin{codeblock} auto Fwd = [](int (*fp)(int), auto a) { return fp(a); }; @@ -902,9 +974,9 @@ \pnum The \grammarterm{lambda-expression}'s \grammarterm{compound-statement} yields the -\grammarterm{function-body}~(\ref{dcl.fct.def}) of the function call operator, but for -purposes of name lookup~(\ref{basic.lookup}), determining the type and value of -\tcode{this}~(\ref{class.this}) and transforming \grammarterm{id-expression}{s} +\grammarterm{function-body}\iref{dcl.fct.def} of the function call operator, but for +purposes of name lookup\iref{basic.lookup}, determining the type and value of +\tcode{this}\iref{class.this} and transforming \grammarterm{id-expression}{s} referring to non-static class members into class member access expressions using \tcode{(*this)}~(\ref{class.mfct.non-static}), the \grammarterm{compound-statement} is considered in the context of the \grammarterm{lambda-expression}. \begin{example} @@ -929,19 +1001,19 @@ \pnum The closure type associated with a \grammarterm{lambda-expression} has no default constructor and a deleted copy assignment operator. It has a -defaulted copy constructor and a defaulted move constructor~(\ref{class.copy}). +defaulted copy constructor and a defaulted move constructor\iref{class.copy}. \begin{note} These special member functions are implicitly defined as usual, and might therefore be defined as deleted. \end{note} \pnum The closure type associated with a \grammarterm{lambda-expression} has an -implicitly-declared destructor~(\ref{class.dtor}). +implicitly-declared destructor\iref{class.dtor}. \pnum A member of a closure type shall not be -explicitly instantiated~(\ref{temp.explicit}), -explicitly specialized~(\ref{temp.expl.spec}), or -named in a \tcode{friend} declaration~(\ref{class.friend}). +explicitly instantiated\iref{temp.explicit}, +explicitly specialized\iref{temp.expl.spec}, or +named in a \tcode{friend} declaration\iref{class.friend}. \rSec3[expr.prim.lambda.capture]{Captures}% @@ -997,7 +1069,10 @@ by \tcode{\&}. If a \grammarterm{lambda-capture} includes a \grammarterm{capture-default} that is \tcode{=}, each \grammarterm{simple-capture} of that \grammarterm{lambda-capture} shall -be of the form ``\tcode{\&} \grammarterm{identifier}'' or ``\tcode{* this}''. +be of the form +``\tcode{\&} \grammarterm{identifier}'', +``\tcode{this}'', +or ``\tcode{* this}''. \begin{note} The form \tcode{[\&,this]} is redundant but accepted for compatibility with ISO \CppXIV. \end{note} Ignoring appearances in @@ -1009,9 +1084,10 @@ struct S2 { void f(int i); }; void S2::f(int i) { [&, i]{ }; // OK + [&, this, i]{ }; // OK, equivalent to \tcode{[\&, i]} [&, &i]{ }; // error: \tcode{i} preceded by \tcode{\&} when \tcode{\&} is the default [=, *this]{ }; // OK - [=, this]{ }; // error: \tcode{this} when \tcode{=} is the default + [=, this]{ }; // OK, equivalent to \tcode{[=]} [i, i]{ }; // error: \tcode{i} repeated [this, *this]{ }; // error: \tcode{this} appears twice } @@ -1020,7 +1096,7 @@ \pnum A \grammarterm{lambda-expression} whose smallest enclosing scope is a block -scope~(\ref{basic.scope.block}) is a \defn{local lambda expression}; any other +scope\iref{basic.scope.block} is a \defn{local lambda expression}; any other \grammarterm{lambda-expression} shall not have a \grammarterm{capture-default} or \grammarterm{simple-capture} in its \grammarterm{lambda-introducer}. The \defn{reaching scope} of a local lambda expression @@ -1030,7 +1106,7 @@ \pnum The \grammarterm{identifier} in a \grammarterm{simple-capture} is looked up using the -usual rules for unqualified name lookup~(\ref{basic.lookup.unqual}); each such lookup +usual rules for unqualified name lookup\iref{basic.lookup.unqual}; each such lookup shall find an entity. An entity that is designated by a \grammarterm{simple-capture} is said to be \defn{explicitly captured}, and shall be \tcode{*this} @@ -1094,11 +1170,11 @@ the entity (i.e., \tcode{*this} or a variable) if the \grammarterm{compound-statement}: \begin{itemize} -\item odr-uses~(\ref{basic.def.odr}) the entity (in the case of a variable), -\item odr-uses~(\ref{basic.def.odr}) \tcode{this} +\item odr-uses\iref{basic.def.odr} the entity (in the case of a variable), +\item odr-uses\iref{basic.def.odr} \tcode{this} (in the case of the object designated by \tcode{*this}), or \item names the entity in a potentially-evaluated -expression~(\ref{basic.def.odr}) where the enclosing full-expression depends on +expression\iref{basic.def.odr} where the enclosing full-expression depends on a generic lambda parameter declared within the reaching scope of the \grammarterm{lambda-expression}. \end{itemize} @@ -1128,11 +1204,11 @@ \pnum An entity is \defn{captured} if it is captured explicitly or implicitly. An entity -captured by a \grammarterm{lambda-expression} is odr-used~(\ref{basic.def.odr}) in the scope +captured by a \grammarterm{lambda-expression} is odr-used\iref{basic.def.odr} in the scope containing the \grammarterm{lambda-expression}. If \tcode{*this} is captured by a local lambda expression, its nearest enclosing function shall be a non-static member function. If a \grammarterm{lambda-expression} or an instantiation of the function call -operator template of a generic lambda odr-uses~(\ref{basic.def.odr}) \tcode{this} or a +operator template of a generic lambda odr-uses\iref{basic.def.odr} \tcode{this} or a variable with automatic storage duration from its reaching scope, that entity shall be captured by the \grammarterm{lambda-expression}. If a \grammarterm{lambda-expression} captures an entity and that entity is not defined or @@ -1223,7 +1299,7 @@ \pnum Every \grammarterm{id-expression} within the \grammarterm{compound-statement} of a -\grammarterm{lambda-expression} that is an odr-use~(\ref{basic.def.odr}) of an +\grammarterm{lambda-expression} that is an odr-use\iref{basic.def.odr} of an entity captured by copy is transformed into an access to the corresponding unnamed data member of the closure type. \begin{note} An \grammarterm{id-expression} that is not an odr-use refers to @@ -1232,7 +1308,7 @@ entity. \end{note} If \tcode{*this} is captured by copy, each odr-use of \tcode{this} is transformed into a pointer to the corresponding unnamed data member of the closure type, -cast~(\ref{expr.cast}) to the type of \tcode{this}. \begin{note} The cast ensures that the +cast\iref{expr.cast} to the type of \tcode{this}. \begin{note} The cast ensures that the transformed expression is a prvalue. \end{note} An \grammarterm{id-expression} within the \grammarterm{compound-statement} of a \grammarterm{lambda-expression} @@ -1348,7 +1424,7 @@ \pnum A \grammarterm{simple-capture} followed by an ellipsis is a pack -expansion~(\ref{temp.variadic}). An \grammarterm{init-capture} followed by an +expansion\iref{temp.variadic}. An \grammarterm{init-capture} followed by an ellipsis is ill-formed. \begin{example} \begin{codeblock} @@ -1366,7 +1442,7 @@ \pnum A fold expression performs a fold of a template parameter -pack~(\ref{temp.variadic}) over a binary operator. +pack\iref{temp.variadic} over a binary operator. \begin{bnf} \nontermdef{fold-expression}\br @@ -1398,7 +1474,7 @@ are collectively called \defnx{unary folds}{unary fold}. In a unary fold, the \grammarterm{cast-expression} -shall contain an unexpanded parameter pack~(\ref{temp.variadic}). +shall contain an unexpanded parameter pack\iref{temp.variadic}. \pnum \indextext{fold!binary}% @@ -1432,6 +1508,345 @@ \end{codeblock} \end{example} \indextext{expression!fold|)}% + +\rSec2[expr.prim.req]{Requires expressions} +\indextext{expression!requires|(}% + +\pnum +A \grammarterm{requires-expression} provides a concise way to express +requirements on template arguments +that can be checked by name lookup\iref{basic.lookup} +or by checking properties of types and expressions. + +\begin{bnf} +\nontermdef{requires-expression}\br + \terminal{requires} requirement-parameter-list\opt{} requirement-body +\end{bnf} + +\begin{bnf} +\nontermdef{requirement-parameter-list}\br + \terminal{(} parameter-declaration-clause\opt{} \terminal{)} +\end{bnf} + +\begin{bnf} +\nontermdef{requirement-body}\br + \terminal{\{} requirement-seq \terminal{\}} +\end{bnf} + +\begin{bnf} +\nontermdef{requirement-seq}\br + requirement\br + requirement-seq requirement +\end{bnf} + +\begin{bnf} +\nontermdef{requirement}\br + simple-requirement\br + type-requirement\br + compound-requirement\br + nested-requirement +\end{bnf} + +\pnum +A \grammarterm{requires-expression} is a prvalue of type \tcode{bool} +whose value is described below. +Expressions appearing within a \grammarterm{requirement-body} +are unevaluated operands\iref{expr}. + +\pnum +\begin{example} +A common use of \grammarterm{requires-expression}{}s is to define +requirements in concepts such as the one below: +\begin{codeblock} +template + concept R = requires (T i) { + typename T::type; + {*i} -> const typename T::type&; + }; +\end{codeblock} +A \grammarterm{requires-expression} can also be used in a +\grammarterm{requires-clause}\iref{temp} as a way of writing ad hoc +constraints on template arguments such as the one below: +\begin{codeblock} +template + requires requires (T x) { x + x; } + T add(T a, T b) { return a + b; } +\end{codeblock} +The first \tcode{requires} introduces the +\grammarterm{requires-clause}, and the second +introduces the \grammarterm{requires-expression}. +\end{example} + +\pnum +A \grammarterm{requires-expression} may introduce local parameters using a +\grammarterm{parameter-declaration-clause}\iref{dcl.fct}. +A local parameter of a \grammarterm{requires-expression} shall not have a +default argument. +Each name introduced by a local parameter is in scope from the point +of its declaration until the closing brace of the +\grammarterm{requirement-body}. +These parameters have no linkage, storage, or lifetime; they are only used +as notation for the purpose of defining \grammarterm{requirement}{}s. +The \grammarterm{parameter-declaration-clause} of a +\grammarterm{requirement-parameter-list} +shall not terminate with an ellipsis. +\begin{example} +\begin{codeblock} +template +concept C = requires(T t, ...) { // error: terminates with an ellipsis + t; +}; +\end{codeblock} +\end{example} + +\pnum +\indextext{requirement}% +The \grammarterm{requirement-body} contains +a sequence of \grammarterm{requirement}{}s. +These \grammarterm{requirement}{}s may refer to local +parameters, template parameters, and any other declarations visible from the +enclosing context. + +\pnum +The substitution of template arguments into a \grammarterm{requires-expression} +may result in the formation of invalid types or expressions in its +requirements or the violation of the semantic constraints of those requirements. +In such cases, the \grammarterm{requires-expression} evaluates to \tcode{false}; +it does not cause the program to be ill-formed. +The substitution and semantic constraint checking +proceeds in lexical order and stops when a condition that +determines the result of the \grammarterm{requires-expression} is encountered. +If substitution (if any) and semantic constraint checking succeed, +the \grammarterm{requires-expression} evaluates to \tcode{true}. +\begin{note} +If a \grammarterm{requires-expression} contains invalid types or expressions in +its requirements, and it does not appear within the declaration of a templated +entity, then the program is ill-formed. +\end{note} +If the substitution of template arguments into a \grammarterm{requirement} +would always result in a substitution failure, the program is ill-formed; +no diagnostic required. +\begin{example} +\begin{codeblock} +template concept C = +requires { + new int[-(int)sizeof(T)]; // ill-formed, no diagnostic required +}; +\end{codeblock} +\end{example} + +\rSec3[expr.prim.req.simple]{Simple requirements} +\indextext{requirement!simple}% + +\begin{bnf} +\nontermdef{simple-requirement}\br + expression \terminal{;} +\end{bnf} + +\pnum +A \grammarterm{simple-requirement} asserts +the validity of an \grammarterm{expression}. +\begin{note} +The enclosing \grammarterm{requires-expression} will evaluate to \tcode{false} +if substitution of template arguments into the \grammarterm{expression} fails. +The \grammarterm{expression} is an unevaluated operand\iref{expr}. +\end{note} +\begin{example} +\begin{codeblock} +template concept C = + requires (T a, T b) { + a + b; // \tcode{C} is \tcode{true} if \tcode{a + b} is a valid expression + }; +\end{codeblock} +\end{example} + +\rSec3[expr.prim.req.type]{Type requirements} +\indextext{requirement!type}% + +\begin{bnf} +\nontermdef{type-requirement}\br + \terminal{typename} nested-name-specifier\opt type-name \terminal{;} +\end{bnf} + +\pnum +A \grammarterm{type-requirement} asserts the validity of a type. +\begin{note} +The enclosing \grammarterm{requires-expression} will evaluate to \tcode{false} +if substitution of template arguments fails. +\end{note} +\begin{example} +\begin{codeblock} +template struct S; +template using Ref = T&; + +template concept C = requires { + typename T::inner; // required nested member name + typename S; // required class template specialization + typename Ref; // required alias template substitution, fails if \tcode{T} is void +}; +\end{codeblock} +\end{example} + +\pnum +A \grammarterm{type-requirement} that names a class template specialization +does not require that type to be complete\iref{basic.types}. + +\rSec3[expr.prim.req.compound]{Compound requirements} +\indextext{requirement!compound}% + +\begin{bnf} +\nontermdef{compound-requirement}\br + \terminal{\{} expression \terminal{\}} \terminal{noexcept}\opt{} return-type-requirement\opt{} \terminal{;} +\end{bnf} + +\begin{bnf} +\nontermdef{return-type-requirement}\br + trailing-return-type\br + \terminal{->} cv-qualifier-seq\opt{} constrained-parameter cv-qualifier-seq\opt{} abstract-declarator\opt{} +\end{bnf} + +\pnum +A \grammarterm{compound-requirement} asserts properties +of the \grammarterm{expression} \tcode{E}. Substitution +of template arguments (if any) and verification of +semantic properties proceed in the following order: + +\begin{itemize} +\item Substitution of template arguments (if any) +into the \grammarterm{expression} is performed. + +\item If the \tcode{noexcept} specifier is present, +\tcode{E} shall not be a potentially-throwing expression\iref{except.spec}. + +\item If the \grammarterm{return-type-requirement} is present, then: + +\begin{itemize} +\item Substitution of template arguments (if any) +into the \grammarterm{return-type-requirement} is performed. + +\item If the \grammarterm{return-type-requirement} is a +\grammarterm{trailing-return-type}, +%%% FIXME: is -> shall be +\tcode{E} is implicitly convertible to +the type named by the \grammarterm{trailing-return-type}. +If conversion fails, the enclosing \grammarterm{requires-expression} +is \tcode{false}. + +\item If the \grammarterm{return-type-requirement} +starts with a \grammarterm{constrained-parameter}\iref{temp.param}, +the \grammarterm{expression} is deduced against +an invented function template \tcode{F} +using the rules in \ref{temp.deduct.call}. +\tcode{F} is a \tcode{void} function template +with a single type template parameter \tcode{T} +declared with the \grammarterm{constrained-parameter}. +A \grammarterm{cv-qualifier-seq} \cv{} is formed +as the union of \tcode{const} and \tcode{volatile} specifiers +around the \grammarterm{constrained-parameter}. +\tcode{F} has a single \grammarterm{parameter} +whose \grammarterm{type-specifier} is \cv{}~\tcode{T} +followed by the \grammarterm{abstract-declarator}. +%%% FIXME: Remove this; if deduction fails, the construct should +%%% be ill-formed. +If deduction fails, +the enclosing \grammarterm{requires-expression} is \tcode{false}. +\end{itemize} +\end{itemize} + +\begin{example} +\begin{codeblock} +template concept C1 = requires(T x) { + {x++}; +}; +\end{codeblock} +The \grammarterm{compound-requirement} in \tcode{C1} +requires that \tcode{x++} is a valid expression. +It is equivalent to a \grammarterm{simple-requirement} +with the same \grammarterm{expression}. + +\begin{codeblock} +template concept C2 = requires(T x) { + {*x} -> typename T::inner; +}; +\end{codeblock} + +The \grammarterm{compound-requirement} in \tcode{C2} +requires that \tcode{*x} is a valid expression, +that \tcode{typename T::inner} is a valid type, and +that \tcode{*x} is implicitly convertible to +\tcode{typename T::inner}. + +\begin{codeblock} +template concept C3 = requires (T t, U u) { + t == u; +}; +template concept C4 = requires(T x) { + {*x} -> C3 const&; +}; +\end{codeblock} +The \grammarterm{compound-requirement} +requires that \tcode{*x} be deduced +as an argument for the invented function: +\begin{codeblock} +template X> void f(X const&); +\end{codeblock} +In this case, deduction only succeeds if +an expression of the type deduced for \tcode{X} +can be compared to an \tcode{int} +with the \tcode{==} operator. + +\begin{codeblock} +template concept C5 = + requires(T x) { + {g(x)} noexcept; + }; +\end{codeblock} + +The \grammarterm{compound-requirement} in \tcode{C5} +requires that \tcode{g(x)} is a valid expression and +that \tcode{g(x)} is non-throwing. +\end{example} + +\rSec3[expr.prim.req.nested]{Nested requirements} +\indextext{requirement!nested}% + +\begin{bnf} +\nontermdef{nested-requirement}\br + \terminal{requires} constraint-expression \terminal{;} +\end{bnf} + +\pnum +A \grammarterm{nested-requirement} can be used +to specify additional constraints in terms of local parameters. +The \grammarterm{constraint-expression} +shall be satisfied\iref{temp.constr.decl} +by the substituted template arguments, if any. +Substitution of template arguments into a \grammarterm{nested-requirement} +does not result in substitution into the \grammarterm{constraint-expression} +other than as specified in \ref{temp.constr.decl}. +\begin{example} +\begin{codeblock} +template concept C = sizeof(U) == 1; + +template concept D = requires (T t) { + requires C; +}; +\end{codeblock} +\tcode{D} is satisfied if \tcode{sizeof(decltype (+t)) == 1}\iref{temp.constr.atomic}. +\end{example} + +\pnum +A local parameter shall only appear as an unevaluated operand\iref{expr} +within the \grammarterm{constraint-expression}. +\begin{example} +\begin{codeblock} +template concept C = requires (T a) { + requires sizeof(a) == 4; // OK + requires a == 0; // error: evaluation of a constraint variable +} +\end{codeblock} +\end{example} +\indextext{expression!requires|)} \indextext{expression!primary|)} \rSec1[expr.post]{Postfix expressions}% @@ -1484,7 +1899,7 @@ \tcode{static_cast}, \tcode{reinterpret_cast}, or \tcode{const_cast} may be the product of replacing a \tcode{>{>}} token by two consecutive \tcode{>} -tokens~(\ref{temp.names}).\end{note} +tokens\iref{temp.names}.\end{note} \rSec2[expr.sub]{Subscripting} @@ -1526,17 +1941,17 @@ For a call to a non-member function or to a static member function, the postfix expression shall be either an lvalue that refers to a function (in which case the function-to-pointer standard -conversion~(\ref{conv.func}) is suppressed on the postfix expression), +conversion\iref{conv.func} is suppressed on the postfix expression), or it shall have function pointer type. Calling a function through an expression whose function type is different from the function type of the called function's -definition results in undefined behavior~(\ref{dcl.link}). For a call to a non-static +definition results in undefined behavior\iref{dcl.link}. For a call to a non-static member function, the postfix expression shall be an -implicit~(\ref{class.mfct.non-static},~\ref{class.static}) or explicit -class member access~(\ref{expr.ref}) whose \grammarterm{id-expression} is a +implicit~(\ref{class.mfct.non-static}, \ref{class.static}) or explicit +class member access\iref{expr.ref} whose \grammarterm{id-expression} is a function member name, or a pointer-to-member -expression~(\ref{expr.mptr.oper}) selecting a function member; the call is as a member of +expression\iref{expr.mptr.oper} selecting a function member; the call is as a member of the class object referred to by the object expression. In the case of an implicit class member access, the implied object is the one pointed to by \tcode{this}. @@ -1545,11 +1960,11 @@ \tcode{(*this).f()} (see~\ref{class.mfct.non-static}). \end{note} If a function or member function name is used, the name can be -overloaded (Clause~\ref{over}), in which case the appropriate function +overloaded\iref{over}, in which case the appropriate function shall be selected according to the rules in~\ref{over.match}. If the selected function is non-virtual, or if the \grammarterm{id-expression} in the class member access expression is a \grammarterm{qualified-id}, that function is -called. Otherwise, its final overrider~(\ref{class.virtual}) in the dynamic type +called. Otherwise, its final overrider\iref{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}. \begin{note} @@ -1563,13 +1978,13 @@ \pnum \begin{note} If a function or member function name is used, and name -lookup~(\ref{basic.lookup}) does not find a declaration of that name, +lookup\iref{basic.lookup} does not find a declaration of that name, the program is ill-formed. No function is implicitly declared by such a call. \end{note} \pnum -If the \grammarterm{postfix-expression} designates a destructor~(\ref{class.dtor}), +If the \grammarterm{postfix-expression} designates a destructor\iref{class.dtor}, the type of the function call expression is \tcode{void}; otherwise, the type of the function call expression is the return type of the statically chosen function (i.e., ignoring the \tcode{virtual} keyword), @@ -1581,18 +1996,18 @@ \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 +When a function is called, each parameter\iref{dcl.fct} shall be +initialized~(\ref{dcl.init}, \ref{class.copy}, \ref{class.ctor}) with its corresponding argument. If the function is a non-static member -function, the \tcode{this} parameter of the function~(\ref{class.this}) +function, the \tcode{this} parameter of the function\iref{class.this} shall be initialized with a pointer to the object of the call, converted -as if by an explicit type conversion~(\ref{expr.cast}). +as if by an explicit type conversion\iref{expr.cast}. \begin{note} There is no access or ambiguity checking on this conversion; the access checking and disambiguation are done as part of the (possibly implicit) class member access operator. -See~\ref{class.member.lookup},~\ref{class.access.base}, +See~\ref{class.member.lookup}, \ref{class.access.base}, and~\ref{expr.ref}. \end{note} When a function is called, the parameters that have object type shall @@ -1613,8 +2028,8 @@ 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 -particular, if the function called has a \grammarterm{function-try-block} -(Clause~\ref{except}) with a handler that could handle the exception, +particular, if the function called has a \grammarterm{function-try-block}\iref{except} +with a handler that could handle the exception, this handler is not considered. \end{example} @@ -1666,7 +2081,7 @@ \pnum The result of a function call is the -result of the operand of the evaluated \tcode{return} statement~(\ref{stmt.return}) +result of the operand of the evaluated \tcode{return} statement\iref{stmt.return} in the called function (if any), except in a virtual function call if the return type of the final overrider is different from the return type of the statically @@ -1683,12 +2098,12 @@ \indextext{argument!reference}% 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 +parameter is of a reference type\iref{dcl.ref}; if the reference is to a const-qualified type, \tcode{const_cast} is required to be used to cast away the constness in order to modify the argument's value. Where a parameter is of \tcode{const} reference type a temporary object is introduced if -needed~(\ref{dcl.type},~\ref{lex.literal},~\ref{lex.string},~\ref{dcl.array},~\ref{class.temporary}). +needed~(\ref{dcl.type}, \ref{lex.literal}, \ref{lex.string}, \ref{dcl.array}, \ref{class.temporary}). In addition, it is possible to modify the values of non-constant objects through pointer parameters. \end{note} @@ -1697,9 +2112,9 @@ \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}). +arguments\iref{dcl.fct.default}) or more arguments (by using the ellipsis, +\tcode{...}, or a function parameter pack\iref{dcl.fct}) than the number of +parameters in the function definition\iref{dcl.fct.def}. \begin{note} This implies that, except where the ellipsis (\tcode{...}) or a function parameter pack is used, a parameter is available for each argument. @@ -1709,35 +2124,35 @@ \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}). +argument by invoking \tcode{va_arg}\iref{support.runtime}. \begin{note} This paragraph does not apply to arguments passed to a function parameter pack. -Function parameter packs are expanded during template instantiation~(\ref{temp.variadic}), +Function parameter packs are expanded during template instantiation\iref{temp.variadic}, thus each such argument has a corresponding parameter when a function template specialization is actually called. \end{note} The -lvalue-to-rvalue~(\ref{conv.lval}), array-to-pointer~(\ref{conv.array}), -and function-to-pointer~(\ref{conv.func}) standard conversions are +lvalue-to-rvalue\iref{conv.lval}, array-to-pointer\iref{conv.array}, +and function-to-pointer\iref{conv.func} standard conversions are performed on the argument expression. An argument that has type \cv{}~\tcode{std::nullptr_t} is converted -to type \tcode{void*}~(\ref{conv.ptr}). +to type \tcode{void*}\iref{conv.ptr}. After these conversions, if the argument does not have arithmetic, enumeration, pointer, pointer to member, or class type, the program is ill-formed. Passing a potentially-evaluated -argument of class type (Clause~\ref{class}) having a non-trivial +argument of class type\iref{class} having a non-trivial copy constructor, a non-trivial move constructor, or a 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\iref{conv.prom}, or a floating-point type that is subject to the +floating-point promotion\iref{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}% Recursive calls are permitted, except to the \tcode{main} -function~(\ref{basic.start.main}). +function\iref{basic.start.main}. \pnum A function call is an lvalue @@ -1753,8 +2168,8 @@ \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 +A \grammarterm{simple-type-specifier}\iref{dcl.type.simple} or +\grammarterm{typename-specifier}\iref{temp.res} followed by a parenthesized optional \grammarterm{expression-list} or by a \grammarterm{braced-init-list} (the initializer) @@ -1765,22 +2180,22 @@ for a deduced class type, it is replaced by the return type of the function selected by overload resolution -for class template deduction~(\ref{over.match.class.deduct}) +for class template deduction\iref{over.match.class.deduct} for the remainder of this section. \pnum If the initializer is a parenthesized single expression, -the type conversion expression is equivalent (in -definedness, and if defined in meaning) to the corresponding cast -expression~(\ref{expr.cast}). +the type conversion expression is equivalent +to the corresponding cast +expression\iref{expr.cast}. \indextext{type!incomplete}% -If the type is \cv{}~\tcode{void} +Otherwise, 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. Otherwise, the expression is a prvalue of the specified type -whose result object is direct-initialized~(\ref{dcl.init}) +whose result object is direct-initialized\iref{dcl.init} with the initializer. For an expression of the form \tcode{T()}, \tcode{T} shall not be an array type. @@ -1829,7 +2244,7 @@ \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 +\tcode{template}\iref{temp.names}, and then followed by an \grammarterm{id-expression}, is a postfix expression. The postfix expression before the dot or arrow is evaluated;\footnote{If the class member access expression is evaluated, the subexpression evaluation happens even if the @@ -1843,9 +2258,15 @@ \pnum \indextext{type!incomplete}% For the first option (dot) the first expression -shall be a glvalue having complete class type. +shall be a glvalue having class type. For the second option (arrow) the first expression -shall be a prvalue having pointer to complete class type. +shall be a prvalue having pointer to class type. +In both cases, the class type shall be complete +unless the class member access appears in the definition of that class. +\begin{note} +If the class is incomplete, lookup in the complete class type +is required to refer to the same declaration\iref{basic.scope.class}. +\end{note} The expression \tcode{E1->E2} is converted to the equivalent form \tcode{(*(E1)).E2}; the remainder of \ref{expr.ref}~will address only the first option (dot).\footnote{Note that @@ -1854,8 +2275,8 @@ \grammarterm{id-expression} shall name a member of the class or of one of its base classes. \begin{note} -Because the name of a class is inserted in its class scope -(Clause~\ref{class}), the name of a class is also considered a nested +Because the name of a class is inserted in its class scope\iref{class}, +the name of a class is also considered a nested member of that class. \end{note} \begin{note} @@ -1903,7 +2324,7 @@ ``\cvqual{cq12} \cvqual{vq12} \tcode{T}''. \item If \tcode{E2} is a (possibly overloaded) member function, function -overload resolution~(\ref{over.match}) is used to determine whether +overload resolution\iref{over.match} is used to determine whether \tcode{E1.E2} refers to a static or a non-static member function. \begin{itemize} @@ -1919,9 +2340,9 @@ parameter-type-list \cvqual{cv} \grammarterm{ref-qualifier}\opt{} returning \tcode{T}'', then \tcode{E1.E2} is a prvalue. The expression designates a non-static member function. The expression can be used only as the -left-hand operand of a member function call~(\ref{class.mfct}). +left-hand operand of a member function call\iref{class.mfct}. \begin{note} Any redundant set of parentheses surrounding the expression -is ignored~(\ref{expr.prim}). \end{note} The type of \tcode{E1.E2} is +is ignored\iref{expr.prim}. \end{note} The type of \tcode{E1.E2} is ``function of parameter-type-list \cvqual{cv} returning \tcode{T}''. \end{itemize} @@ -1936,8 +2357,8 @@ \pnum If \tcode{E2} is a non-static data member or a non-static member function, the program is ill-formed if the class of which \tcode{E2} is -directly a member is an ambiguous base~(\ref{class.member.lookup}) of -the naming class~(\ref{class.access.base}) of \tcode{E2}. +directly a member is an ambiguous base\iref{class.member.lookup} of +the naming class\iref{class.access.base} of \tcode{E2}. \begin{note} The program is also ill-formed if the naming class is an ambiguous base of the class type of the object expression; see~\ref{class.access.base}. @@ -2000,7 +2421,7 @@ \indextext{type!incomplete}% \tcode{T} shall be a pointer or reference to a complete class type, or ``pointer to \cvqual{cv} \tcode{void}''. The \tcode{dynamic_cast} operator shall not cast -away constness~(\ref{expr.const.cast}). +away constness\iref{expr.const.cast}. \pnum If \tcode{T} is a pointer type, \tcode{v} shall be a prvalue of a @@ -2030,7 +2451,7 @@ 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\iref{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 @@ -2050,7 +2471,7 @@ \pnum Otherwise, \tcode{v} shall be a pointer to or a glvalue of a polymorphic -type~(\ref{class.virtual}). +type\iref{class.virtual}. \pnum If \tcode{T} is ``pointer to \cvqual{cv} \tcode{void}'', then the result @@ -2082,8 +2503,8 @@ \pnum The value of a failed cast to pointer type is the null pointer value of the required result type. A failed cast to reference type throws -an exception~(\ref{except.throw}) of a type that would match a -handler~(\ref{except.handle}) of type \tcode{std::bad_cast}~(\ref{bad.cast}). +an exception\iref{except.throw} of a type that would match a +handler\iref{except.handle} of type \tcode{std::bad_cast}\iref{bad.cast}. \indextext{\idxcode{bad_cast}}% \indexlibrary{\idxcode{bad_cast}}% @@ -2128,7 +2549,7 @@ The result of a \tcode{typeid} expression is an lvalue of static type \indextext{\idxcode{type_info}}% \indexlibrary{\idxcode{type_info}}% -\tcode{const} \tcode{std::type_info}~(\ref{type.info}) and dynamic type \tcode{const} +\tcode{const} \tcode{std::type_info}\iref{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 @@ -2140,33 +2561,33 @@ \pnum When \tcode{typeid} is applied to a glvalue expression whose type is a -polymorphic class type~(\ref{class.virtual}), the result refers to a +polymorphic class type\iref{class.virtual}, the result refers to a \tcode{std::type_info} object representing the type of the most derived -object~(\ref{intro.object}) (that is, the dynamic type) to which the +object\iref{intro.object} (that is, the dynamic type) to which the glvalue refers. If the glvalue expression is obtained by applying the unary \tcode{*} operator to a pointer\footnote{If \tcode{p} is an expression of pointer type, then \tcode{*p}, \tcode{(*p)}, \tcode{*(p)}, \tcode{((*p))}, \tcode{*((p))}, and so on all meet this requirement.} -and the pointer is a null pointer value~(\ref{conv.ptr}), the -\tcode{typeid} expression throws an exception~(\ref{except.throw}) of +and the pointer is a null pointer value\iref{conv.ptr}, the +\tcode{typeid} expression throws an exception\iref{except.throw} of a type that would match a handler of type \indextext{\idxcode{bad_typeid}}% \indexlibrary{\idxcode{bad_typeid}}% \tcode{std::bad_typeid} -exception~(\ref{bad.typeid}). +exception\iref{bad.typeid}. \pnum When \tcode{typeid} is applied to an expression other than a glvalue of a polymorphic class type, the result refers to a \tcode{std::type_info} object representing the static type of the expression. -Lvalue-to-rvalue~(\ref{conv.lval}), array-to-pointer~(\ref{conv.array}), -and function-to-pointer~(\ref{conv.func}) conversions are not applied to +Lvalue-to-rvalue\iref{conv.lval}, array-to-pointer\iref{conv.array}, +and function-to-pointer\iref{conv.func} conversions are not applied to the expression. If the expression is a prvalue, -the temporary materialization conversion~(\ref{conv.rval}) +the temporary materialization conversion\iref{conv.rval} is applied. -The expression is an unevaluated operand (Clause~\ref{expr}). +The expression is an unevaluated operand\iref{expr}. \pnum When \tcode{typeid} is applied to a \grammarterm{type-id}, the result @@ -2198,7 +2619,7 @@ \end{example} \pnum -If the header \tcode{}~(\ref{type.info}) is not included prior +If the header \tcode{}\iref{type.info} is not included prior to a use of \tcode{typeid}, the program is ill-formed. \pnum @@ -2220,20 +2641,20 @@ or an rvalue reference to function type, the result is an lvalue; if \tcode{T} is an rvalue reference to object type, the result is an xvalue; otherwise, the result is a prvalue. The \tcode{static_cast} operator shall not cast -away constness~(\ref{expr.const.cast}). +away constness\iref{expr.const.cast}. \pnum \indextext{cast!static!reference}% \indextext{cast!reference}% An lvalue of type ``\cvqual{cv1} \tcode{B}'', where \tcode{B} is a class type, can be cast to type ``reference to \cvqual{cv2} \tcode{D}'', where -\tcode{D} is a class derived (Clause~\ref{class.derived}) from \tcode{B}, +\tcode{D} is a class derived\iref{class.derived} from \tcode{B}, if \cvqual{cv2} is the same cv-qualification as, or greater cv-qualification than, \cvqual{cv1}. If \tcode{B} is a virtual base class of \tcode{D} or a base class of a virtual base class of \tcode{D}, or if no valid standard conversion from ``pointer to \tcode{D}'' -to ``pointer to \tcode{B}'' exists~(\ref{conv.ptr}), the program is ill-formed. +to ``pointer to \tcode{B}'' exists\iref{conv.ptr}, the program is ill-formed. An xvalue of type ``\cvqual{cv1} \tcode{B}'' can be cast to type ``rvalue reference to \cvqual{cv2} \tcode{D}'' with the same constraints as for an lvalue of @@ -2258,28 +2679,28 @@ of type ``\cvqual{cv1} \tcode{T1}'' can be cast to type ``rvalue reference to \cvqual{cv2} \tcode{T2}'' if ``\cvqual{cv2} \tcode{T2}'' is reference-compatible with ``\cvqual{cv1} -\tcode{T1}''~(\ref{dcl.init.ref}). If the value is not a bit-field, +\tcode{T1}''\iref{dcl.init.ref}. If the value is not a bit-field, the result refers to the object or the specified base class subobject -thereof; otherwise, the lvalue-to-rvalue conversion~(\ref{conv.lval}) +thereof; otherwise, the lvalue-to-rvalue conversion\iref{conv.lval} is applied to the bit-field and the resulting prvalue is used as the \grammarterm{expression} of the \tcode{static_cast} for the remainder of this section. -If \tcode{T2} is an inaccessible (Clause~\ref{class.access}) or -ambiguous~(\ref{class.member.lookup}) base class of \tcode{T1}, +If \tcode{T2} is an inaccessible\iref{class.access} or +ambiguous\iref{class.member.lookup} base class of \tcode{T1}, a program that necessitates such a cast is ill-formed. \pnum An expression \tcode{e} can be explicitly converted to a type \tcode{T} -if there is an implicit conversion sequence~(\ref{over.best.ics}) +if there is an implicit conversion sequence\iref{over.best.ics} from \tcode{e} to \tcode{T}, or -if overload resolution for a direct-initialization~(\ref{dcl.init}) +if overload resolution for a direct-initialization\iref{dcl.init} of an object or reference of type \tcode{T} from \tcode{e} -would find at least one viable function~(\ref{over.match.viable}). +would find at least one viable function\iref{over.match.viable}. If \tcode{T} is a reference type, the effect is the same as performing the declaration and initialization \begin{codeblock} T t(e); \end{codeblock} -for some invented temporary variable \tcode{t}~(\ref{dcl.init}) +for some invented temporary variable \tcode{t}\iref{dcl.init} and then using the temporary variable as the result of the conversion. Otherwise, the result object is direct-initialized from \tcode{e}. \begin{note} @@ -2295,10 +2716,10 @@ \pnum Any expression can be explicitly converted to type \cv{}~\tcode{void}, in which case it becomes a discarded-value -expression (Clause~\ref{expr}). +expression\iref{expr}. \begin{note} However, if the value is in a temporary -object~(\ref{class.temporary}), the destructor for that +object\iref{class.temporary}, the destructor for that object is not executed until the usual time, and the value of the object is preserved for the purpose of executing the destructor. @@ -2306,13 +2727,13 @@ \pnum -The inverse of any standard conversion sequence (Clause~\ref{conv}) not containing an -lvalue-to-rvalue~(\ref{conv.lval}), -array-to-pointer~(\ref{conv.array}), -function-to-pointer~(\ref{conv.func}), -null pointer~(\ref{conv.ptr}), null member pointer~(\ref{conv.mem}), -boolean~(\ref{conv.bool}), or -function pointer~(\ref{conv.fctptr}) +The inverse of any standard conversion sequence\iref{conv} not containing an +lvalue-to-rvalue\iref{conv.lval}, +array-to-pointer\iref{conv.array}, +function-to-pointer\iref{conv.func}, +null pointer\iref{conv.ptr}, null member pointer\iref{conv.mem}, +boolean\iref{conv.bool}, or +function pointer\iref{conv.fctptr} conversion, can be performed explicitly using \tcode{static_cast}. A program is ill-formed if it uses \tcode{static_cast} to perform the inverse of an ill-formed standard conversion sequence. @@ -2328,16 +2749,16 @@ \end{example} \pnum -The lvalue-to-rvalue~(\ref{conv.lval}), -array-to-pointer~(\ref{conv.array}), and -function-to-pointer~(\ref{conv.func}) conversions are applied to the +The lvalue-to-rvalue\iref{conv.lval}, +array-to-pointer\iref{conv.array}, and +function-to-pointer\iref{conv.func} conversions are applied to the operand. Such a \tcode{static_cast} is subject to the restriction that the explicit conversion does not cast away -constness~(\ref{expr.const.cast}), and the following additional rules +constness\iref{expr.const.cast}, and the following additional rules for specific cases: \pnum -A value of a scoped enumeration type~(\ref{dcl.enum}) can be explicitly converted to an +A value of a scoped enumeration type\iref{dcl.enum} can be explicitly converted to an 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 @@ -2352,11 +2773,11 @@ \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, +within the range of the enumeration values\iref{dcl.enum}. Otherwise, the behavior is undefined. A value of floating-point type can also be explicitly converted to an enumeration type. The resulting value is the same as converting the original value to the -underlying type of the enumeration~(\ref{conv.fpint}), and subsequently to +underlying type of the enumeration\iref{conv.fpint}, and subsequently to the enumeration type. \pnum @@ -2364,15 +2785,15 @@ \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 -(Clause~\ref{class.derived}) from \tcode{B}, +\cvqual{cv2} \tcode{D}'', where \tcode{D} is a class derived\iref{class.derived} +from \tcode{B}, if \cvqual{cv2} is the same cv-qualification as, or greater cv-qualification than, \cvqual{cv1}. If \tcode{B} is a virtual base class of \tcode{D} or a base class of a virtual base class of \tcode{D}, or if no valid standard conversion from ``pointer to \tcode{D}'' -to ``pointer to \tcode{B}'' exists~(\ref{conv.ptr}), the program is ill-formed. -The null pointer value~(\ref{conv.ptr}) is converted +to ``pointer to \tcode{B}'' exists\iref{conv.ptr}, the program is ill-formed. +The null pointer value\iref{conv.ptr} is converted to the null pointer value of the destination type. If the prvalue of type ``pointer to \cvqual{cv1} \tcode{B}'' points to a \tcode{B} that is actually a subobject of an object of type \tcode{D}, the resulting @@ -2384,7 +2805,7 @@ A prvalue of type ``pointer to member of \tcode{D} of type \cvqual{cv1} \tcode{T}'' can be converted to a prvalue of type ``pointer to member of \tcode{B} of type \cvqual{cv2} \tcode{T}'', where \tcode{B} is a base -class (Clause~\ref{class.derived}) of \tcode{D}, +class\iref{class.derived} of \tcode{D}, if \cvqual{cv2} is the same cv-qualification as, or greater cv-qualification than, \cvqual{cv1}.\footnote{Function types (including those used in pointer to member function @@ -2392,8 +2813,8 @@ If no valid standard conversion from ``pointer to member of \tcode{B} of type \tcode{T}'' to ``pointer to member of \tcode{D} of type \tcode{T}'' -exists~(\ref{conv.mem}), the program is ill-formed. -The null member pointer value~(\ref{conv.mem}) is converted to the null +exists\iref{conv.mem}, the program is ill-formed. +The null member pointer value\iref{conv.mem} is converted to the null member pointer value of the destination type. If class \tcode{B} contains the original member, or is a base or derived class of the class containing the original member, the resulting pointer to member points @@ -2416,7 +2837,7 @@ then the resulting pointer value is unspecified. Otherwise, if the original pointer value points to an object \placeholder{a}, and there is an object \placeholder{b} of type \tcode{T} (ignoring cv-qualification) -that is pointer-interconvertible~(\ref{basic.compound}) with \placeholder{a}, +that is pointer-interconvertible\iref{basic.compound} with \placeholder{a}, the result is a pointer to \placeholder{b}. Otherwise, the pointer value is unchanged by the conversion. \begin{example} @@ -2440,14 +2861,14 @@ If \tcode{T} is an lvalue reference type or an rvalue reference to function type, the result is an lvalue; if \tcode{T} is an rvalue reference to object type, the result is an xvalue; otherwise, the result is a prvalue and the -lvalue-to-rvalue~(\ref{conv.lval}), array-to-pointer~(\ref{conv.array}), -and function-to-pointer~(\ref{conv.func}) standard conversions are +lvalue-to-rvalue\iref{conv.lval}, array-to-pointer\iref{conv.array}, +and function-to-pointer\iref{conv.func} standard conversions are performed on the expression \tcode{v}. Conversions that can be performed explicitly using \tcode{reinterpret_cast} are listed below. No other conversion can be performed explicitly using \tcode{reinterpret_cast}. \pnum -The \tcode{reinterpret_cast} operator shall not cast away constness~(\ref{expr.const.cast}). +The \tcode{reinterpret_cast} operator shall not cast away constness\iref{expr.const.cast}. An expression of integral, enumeration, pointer, or pointer-to-member type can be explicitly converted to its own type; such a cast yields the value of its operand. @@ -2496,7 +2917,7 @@ \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 +type\iref{dcl.fct} that is not the same as the type used in the definition of the function is undefined. \end{note} Except that converting @@ -2535,7 +2956,7 @@ pointer value. \pnum -The null pointer value~(\ref{conv.ptr}) is converted to the null pointer value +The null pointer value\iref{conv.ptr} is converted to the null pointer value of the destination type. \begin{note} A null pointer constant of type \tcode{std::nullptr_t} cannot be converted to a @@ -2552,7 +2973,7 @@ function types or both object types.\footnote{\tcode{T1} and \tcode{T2} may have different \cv-qualifiers, subject to the overall restriction that a \tcode{reinterpret_cast} cannot cast away -constness.} The null member pointer value~(\ref{conv.mem}) is converted to the +constness.} The null member pointer value\iref{conv.mem} is converted to the null member pointer value of the destination type. The result of this conversion is unspecified, except in the following cases: @@ -2582,8 +3003,8 @@ \tcode{*} operators (and similarly for \tcode{reinterpret_cast(x)}). \end{note} No temporary is created, no copy is made, and -constructors~(\ref{class.ctor}) or conversion -functions~(\ref{class.conv}) are not called.\footnote{This +constructors\iref{class.ctor} or conversion +functions\iref{class.conv} are not called.\footnote{This is sometimes referred to as a \defn{type pun}.} \rSec2[expr.const.cast]{Const cast} @@ -2596,8 +3017,8 @@ lvalue; if \tcode{T} is an rvalue reference to object type, the result is an xvalue; otherwise, the result is a prvalue and the -lvalue-to-rvalue~(\ref{conv.lval}), array-to-pointer~(\ref{conv.array}), -and function-to-pointer~(\ref{conv.func}) standard conversions are +lvalue-to-rvalue\iref{conv.lval}, array-to-pointer\iref{conv.array}, +and function-to-pointer\iref{conv.func} standard conversions are performed on the expression \tcode{v}. Conversions that can be performed explicitly using \tcode{const_cast} are listed below. No other conversion shall be performed explicitly using \tcode{const_cast}. @@ -2609,7 +3030,7 @@ \end{note} \pnum -For two similar types \tcode{T1} and \tcode{T2}~(\ref{conv.qual}), +For two similar types \tcode{T1} and \tcode{T2}\iref{conv.qual}, a prvalue of type \tcode{T1} may be explicitly converted to the type \tcode{T2} using a \tcode{const_cast}. The result of a \tcode{const_cast} refers to the original entity. @@ -2643,12 +3064,12 @@ The result of a reference \tcode{const_cast} refers to the original object if the operand is a glvalue and -to the result of applying the temporary materialization conversion~(\ref{conv.rval}) otherwise. +to the result of applying the temporary materialization conversion\iref{conv.rval} otherwise. \pnum -A null pointer value~(\ref{conv.ptr}) is converted to the null pointer +A null pointer value\iref{conv.ptr} is converted to the null pointer value of the destination type. The null member pointer -value~(\ref{conv.mem}) is converted to the null member pointer value of +value\iref{conv.mem} is converted to the null member pointer value of the destination type. \pnum @@ -2658,7 +3079,7 @@ \tcode{const_cast} that casts away a const-qualifier\footnote{\tcode{const_cast} is not limited to conversions that cast away a const-qualifier.} -may produce undefined behavior~(\ref{dcl.type.cv}). +may produce undefined behavior\iref{dcl.type.cv}. \end{note} \pnum @@ -2666,7 +3087,7 @@ A conversion from a type \tcode{T1} to a type \tcode{T2} \defnx{casts away constness}{casting away constness} if \tcode{T1} and \tcode{T2} are different, -there is a cv-decomposition~(\ref{conv.qual}) of \tcode{T1} +there is a cv-decomposition\iref{conv.qual} of \tcode{T1} yielding \placeholder{n} such that \tcode{T2} has a cv-decomposition of the form @@ -2778,11 +3199,11 @@ of some class \tcode{C} with type \tcode{T}, the result has type ``pointer to member of class \tcode{C} of type \tcode{T}'' and is a prvalue designating \tcode{C::m}. 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}) +\tcode{T}'' and is a prvalue that is the address of the designated object\iref{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 cv-qualification. \end{note} -For purposes of pointer arithmetic~(\ref{expr.add}) and +For purposes of pointer arithmetic\iref{expr.add} and comparison~(\ref{expr.rel}, \ref{expr.eq}), an object that is not an array element whose address is taken in this way is considered to belong to an array with one @@ -2801,7 +3222,7 @@ \end{example} \begin{note} A pointer to member formed from a \tcode{mutable} non-static data -member~(\ref{dcl.stc}) does not reflect the \tcode{mutable} specifier +member\iref{dcl.stc} does not reflect the \tcode{mutable} specifier associated with the non-static data member. \end{note} @@ -2816,7 +3237,7 @@ \tcode{qualified-id}, because there is no implicit conversion from a \grammarterm{qualified-id} for a non-static member function to the type ``pointer to member function'' as there is from an lvalue of function -type to the type ``pointer to function''~(\ref{conv.func}). Nor is +type to the type ``pointer to function''\iref{conv.func}. Nor is \tcode{\&unqualified-id} a pointer to member, even within the scope of the \grammarterm{unqualified-id}'s class. \end{note} @@ -2829,7 +3250,7 @@ \pnum \indextext{overloaded function!address of}% -The address of an overloaded function (Clause~\ref{over}) can be taken +The address of an overloaded function\iref{over} can be taken only in a context that uniquely determines which version of the overloaded function is referred to (see~\ref{over.over}). \begin{note} @@ -2858,8 +3279,8 @@ \pnum \indextext{operator!logical negation}% The operand of the logical negation operator \tcode{!} is contextually -converted to \tcode{bool} -(Clause~\ref{conv}); its value is \tcode{true} +converted to \tcode{bool}\iref{conv}; +its value is \tcode{true} if the converted operand is \tcode{false} and \tcode{false} otherwise. The type of the result is \tcode{bool}. @@ -2901,8 +3322,8 @@ The expression \tcode{++x} is equivalent to \tcode{x+=1}. \indextext{operator!\idxcode{+=}}% \begin{note} -See the discussions of addition~(\ref{expr.add}) and assignment -operators~(\ref{expr.ass}) for information on conversions. +See the discussions of addition\iref{expr.add} and assignment +operators\iref{expr.ass} for information on conversions. \end{note} \pnum @@ -2924,7 +3345,7 @@ \indextext{byte}% The \tcode{sizeof} operator yields the number of bytes in the object representation of its operand. The operand is either an expression, -which is an unevaluated operand (Clause~\ref{expr}), or a parenthesized +which is an unevaluated operand\iref{expr}, or a parenthesized \grammarterm{type-id}. \indextext{type!incomplete}% The \tcode{sizeof} operator shall not be applied to an expression that @@ -2934,7 +3355,7 @@ \tcode{sizeof(char)}, \tcode{sizeof(signed char)} and \tcode{sizeof(unsigned char)} are \tcode{1}. The result of \tcode{sizeof} applied to any other fundamental -type~(\ref{basic.fundamental}) is \impldef{\tcode{sizeof} applied to +type\iref{basic.fundamental} is \impldef{\tcode{sizeof} applied to fundamental types other than \tcode{char}, \tcode{signed char}, and \tcode{unsigned char}}. \begin{note} @@ -2955,7 +3376,7 @@ When applied to a class, the result is the number of bytes in an object of that class including any padding required for placing objects of that type in an array. The size of a most derived class shall be greater than -zero~(\ref{intro.object}). The result of applying \tcode{sizeof} to a +zero\iref{intro.object}. The result of applying \tcode{sizeof} to a base class subobject is the size of the base class type.\footnote{The actual size of a base class subobject may be less than the result of applying \tcode{sizeof} to the subobject, due to virtual base classes @@ -2970,19 +3391,19 @@ but shall not be applied directly to a function. \pnum -The lvalue-to-rvalue~(\ref{conv.lval}), -array-to-pointer~(\ref{conv.array}), and -function-to-pointer~(\ref{conv.func}) standard conversions are not +The lvalue-to-rvalue\iref{conv.lval}, +array-to-pointer\iref{conv.array}, and +function-to-pointer\iref{conv.func} standard conversions are not applied to the operand of \tcode{sizeof}. If the operand is a prvalue, -the temporary materialization conversion~(\ref{conv.rval}) +the temporary materialization conversion\iref{conv.rval} is applied. \pnum The identifier in a \tcode{sizeof...} expression shall name a parameter pack. The \tcode{sizeof...} operator yields the number of arguments provided for the parameter pack \grammarterm{identifier}. -A \tcode{sizeof...} expression is a pack expansion~(\ref{temp.variadic}). +A \tcode{sizeof...} expression is a pack expansion\iref{temp.variadic}. \begin{example} \begin{codeblock} @@ -3013,12 +3434,12 @@ \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 +\grammarterm{type-id}\iref{dcl.name} or \grammarterm{new-type-id} to which it is applied. The type of that object is the \defnx{allocated type}{type!allocated}. \indextext{type!incomplete}% This type shall be a complete object type, but not an abstract class type or array -thereof~(\ref{intro.object},~\ref{basic.types},~\ref{class.abstract}). +thereof~(\ref{intro.object}, \ref{basic.types}, \ref{class.abstract}). \begin{note} Because references are not objects, references cannot be created by \grammarterm{new-expression}{s}. @@ -3066,7 +3487,7 @@ \indextext{storage duration!dynamic}% Entities created by a \grammarterm{new-expression} have dynamic storage -duration~(\ref{basic.stc.dynamic}). +duration\iref{basic.stc.dynamic}. \begin{note} \indextext{\idxcode{new}!scoping and}% The lifetime of such an entity is not necessarily restricted to the @@ -3078,7 +3499,7 @@ the array. \pnum -If a placeholder type~(\ref{dcl.spec.auto}) appears in the +If a placeholder type\iref{dcl.spec.auto} appears in the \grammarterm{type-specifier-seq} of a \grammarterm{new-type-id} or \grammarterm{type-id} of a \grammarterm{new-expression}, the allocated type is deduced as follows: @@ -3088,7 +3509,7 @@ \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}): +declaration\iref{dcl.spec.auto}: \begin{codeblock} T x @\textrm{\placeholder{init}}@ ; @@ -3139,7 +3560,7 @@ Instead, the explicitly parenthesized version of the \tcode{new} operator can be used to create objects of compound -types~(\ref{basic.compound}): +types\iref{basic.compound}: \begin{codeblock} new (int (*[10])()); @@ -3167,7 +3588,7 @@ \pnum Every \grammarterm{constant-expression} in a \grammarterm{noptr-new-declarator} shall be a converted constant -expression~(\ref{expr.const}) of type \tcode{std::size_t} and +expression\iref{expr.const} of type \tcode{std::size_t} and shall evaluate to a strictly positive value. \indextext{\idxcode{new}}% The \grammarterm{expression} in a \grammarterm{noptr-new-declarator} is @@ -3192,19 +3613,19 @@ \item the expression is of class type and its value before application of the second -standard conversion~(\ref{over.ics.user})\footnote{If the conversion function +standard conversion\iref{over.ics.user}\footnote{If the conversion function returns a signed integer type, the second standard conversion converts to the unsigned type \tcode{std::size_t} and thus thwarts any attempt to detect a negative value afterwards.} is less than zero; \item its value is such that the size of the allocated object would exceed the -\impldef{maximum size of an allocated object} limit (Annex~\ref{implimits}); or +\impldef{maximum size of an allocated object} limit\iref{implimits}; or \item the \grammarterm{new-initializer} is a \grammarterm{braced-init-list} and the number of array elements for which initializers are provided (including the -terminating \tcode{'\textbackslash 0'} in a string literal~(\ref{lex.string})) exceeds the +terminating \tcode{'\textbackslash 0'} in a string literal\iref{lex.string}) exceeds the number of elements to initialize. \end{itemize} @@ -3218,13 +3639,13 @@ \begin{itemize} \item if the allocation function that would have been called -has a non-throwing exception specification~(\ref{except.spec}), +has a non-throwing exception specification\iref{except.spec}, the value of the \grammarterm{new-expression} is the null pointer value of the required result type; \item otherwise, the \grammarterm{new-expression} terminates by throwing an -exception of a type that would match a handler~(\ref{except.handle}) of type -\tcode{std::bad_array_new_length}~(\ref{new.badlength}). +exception of a type that would match a handler\iref{except.handle} of type +\tcode{std::bad_array_new_length}\iref{new.badlength}. \end{itemize} \end{itemize} When the value of the \grammarterm{expression} is zero, the allocation @@ -3232,10 +3653,10 @@ \pnum A \grammarterm{new-expression} may obtain storage for the object by calling an -allocation function~(\ref{basic.stc.dynamic.allocation}). If +allocation function\iref{basic.stc.dynamic.allocation}. If the \grammarterm{new-expression} terminates by throwing an exception, it may release storage by calling a deallocation -function~(\ref{basic.stc.dynamic.deallocation}). If the allocated type +function\iref{basic.stc.dynamic.deallocation}. If the allocated type is a non-array type, the allocation function's name is \indextext{\idxcode{operator new}}% \indextext{\idxcode{operator delete}}% @@ -3250,10 +3671,10 @@ \begin{note} An implementation shall provide default definitions for the global allocation -functions~(\ref{basic.stc.dynamic},~\ref{new.delete.single},~\ref{new.delete.array}). +functions~(\ref{basic.stc.dynamic}, \ref{new.delete.single}, \ref{new.delete.array}). A \Cpp program can provide alternative definitions of -these functions~(\ref{replacement.functions}) and/or class-specific -versions~(\ref{class.free}). +these functions\iref{replacement.functions} and/or class-specific +versions\iref{class.free}. The set of allocation and deallocation functions that may be called by a \grammarterm{new-expression} may include functions that do not perform allocation or deallocation; @@ -3337,7 +3758,7 @@ result of the \grammarterm{new-expression} and the address returned by the allocation function shall be an integral multiple of the strictest fundamental -alignment requirement~(\ref{basic.align}) of any object type whose size +alignment requirement\iref{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}% @@ -3419,19 +3840,19 @@ \pnum \begin{note} Unless an allocation function has a non-throwing -exception specification~(\ref{except.spec}), +exception specification\iref{except.spec}, it indicates failure to allocate storage by throwing a \indextext{\idxcode{bad_alloc}}% \indexlibrary{\idxcode{bad_alloc}}% \tcode{std::bad_alloc} exception~(\ref{basic.stc.dynamic.allocation}, -Clause~\ref{except},~\ref{bad.alloc}); +\ref{except}, \ref{bad.alloc}); it returns a non-null pointer otherwise. If the allocation function has a non-throwing exception specification, it returns null to indicate failure to allocate storage and a non-null pointer otherwise. \end{note} If the allocation function is a non-allocating -form~(\ref{new.delete.placement}) that returns null, +form\iref{new.delete.placement} that returns null, the behavior is undefined. Otherwise, if the allocation function returns null, initialization shall not be @@ -3460,7 +3881,7 @@ \begin{itemize} \item If the \grammarterm{new-initializer} is omitted, the object is -default-initialized~(\ref{dcl.init}). \begin{note} If no initialization +default-initialized\iref{dcl.init}. \begin{note} If no initialization is performed, the object has an indeterminate value. \end{note} \item Otherwise, the \grammarterm{new-initializer} is interpreted according to @@ -3480,10 +3901,10 @@ \pnum If the \grammarterm{new-expression} creates an object or an array of objects of class type, access and ambiguity control are done for the -allocation function, the deallocation function~(\ref{class.free}), and -the constructor~(\ref{class.ctor}). If the \grammarterm{new-expression} +allocation function, the deallocation function\iref{class.free}, and +the constructor\iref{class.ctor}. If the \grammarterm{new-expression} creates an array of objects of class type, the destructor is potentially -invoked~(\ref{class.dtor}). +invoked\iref{class.dtor}. \pnum \indextext{\idxcode{new}!exception and}% @@ -3514,19 +3935,19 @@ \pnum A declaration of a placement deallocation function matches the declaration of a placement allocation function if it has the same number -of parameters and, after parameter transformations~(\ref{dcl.fct}), all +of parameters and, after parameter transformations\iref{dcl.fct}, all parameter types except the first are identical. If the lookup finds a single matching deallocation function, that function will be called; otherwise, no deallocation function will be called. If the lookup finds a usual deallocation function -with a parameter of type \tcode{std::size_t}~(\ref{basic.stc.dynamic.deallocation}) +with a parameter of type \tcode{std::size_t}\iref{basic.stc.dynamic.deallocation} and that function, considered as a placement deallocation function, would have been selected as a match for the allocation function, the program is ill-formed. For a non-placement allocation function, the normal deallocation function lookup is used to find the matching deallocation -function~(\ref{expr.delete}) +function\iref{expr.delete} \begin{example} \begin{codeblock} @@ -3563,7 +3984,7 @@ \indextext{expression!\idxcode{delete}}% \indextext{\idxcode{delete}}% The \grammarterm{delete-expression} operator destroys a most derived -object~(\ref{intro.object}) or array created by a +object\iref{intro.object} or array created by a \grammarterm{new-expression}. \begin{bnf} @@ -3579,8 +4000,8 @@ empty square brackets can follow the \tcode{delete} keyword if the lambda expression is enclosed in parentheses.} The operand shall be of pointer to object type or of class type. If of -class type, the operand is contextually implicitly converted -(Clause~\ref{conv}) to a pointer to object +class type, the operand is contextually implicitly converted\iref{conv} +to a pointer to object type.\footnote{This implies that an object cannot be deleted using a pointer of type \tcode{void*} because \tcode{void} is not an object type.} @@ -3593,17 +4014,15 @@ type by calling the above-mentioned conversion function, and the converted operand is used in place of the original operand for the remainder of this section. -\indextext{object!delete}% In the first alternative -(\term{delete object}), the value of the operand of \tcode{delete} may +(\defnx{delete object}{object!delete}), the value of the operand of \tcode{delete} may be a null pointer value, a pointer to a non-array object created by a previous \grammarterm{new-expression}, or a pointer to a -subobject~(\ref{intro.object}) representing a base class of such an -object (Clause~\ref{class.derived}). If not, the behavior is undefined. +subobject\iref{intro.object} representing a base class of such an +object\iref{class.derived}. If not, the behavior is undefined. \indextext{array!\idxcode{delete}}% -\indextext{\idxcode{delete}!array}% -In the second alternative (\term{delete array}), the value of the +In the second alternative (\defnx{delete array}{\idxcode{delete}!array}), the value of the operand of \tcode{delete} may be a null pointer value or a pointer value that resulted from @@ -3620,7 +4039,7 @@ \begin{note} 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 +constness\iref{expr.const.cast} of the pointer expression before it is used as the operand of the \grammarterm{delete-expression}. \end{note} @@ -3659,9 +4078,9 @@ \begin{itemize} \item If the allocation call for the \grammarterm{new-expression} for the object to -be deleted was not omitted and the allocation was not extended~(\ref{expr.new}), the +be deleted was not omitted and the allocation was not extended\iref{expr.new}, the \grammarterm{delete-expression} shall call a deallocation -function~(\ref{basic.stc.dynamic.deallocation}). The value returned from the +function\iref{basic.stc.dynamic.deallocation}. The value returned from the allocation call of the \grammarterm{new-expression} shall be passed as the first argument to the deallocation function. @@ -3691,19 +4110,19 @@ \begin{note} An implementation provides default definitions of the global deallocation functions \tcode{operator delete} for -non-arrays~(\ref{new.delete.single}) and +non-arrays\iref{new.delete.single} and \indextext{\idxcode{operator delete}}% -\tcode{operator delete[]} for arrays~(\ref{new.delete.array}). A \Cpp +\tcode{operator delete[]} for arrays\iref{new.delete.array}. A \Cpp program can provide alternative definitions of these -functions~(\ref{replacement.functions}), and/or class-specific -versions~(\ref{class.free}). +functions\iref{replacement.functions}, and/or class-specific +versions\iref{class.free}. \end{note} \pnum When the keyword \tcode{delete} in a \grammarterm{delete-expression} is preceded by the unary \tcode{::} operator, the deallocation function's name is looked up in global scope. Otherwise, the lookup considers class-specific deallocation -functions~(\ref{class.free}). If no class-specific deallocation function is found, +functions\iref{class.free}. If no class-specific deallocation function is found, the deallocation function's name is looked up in global scope. \pnum @@ -3738,7 +4157,7 @@ is executed, the selected deallocation function shall be called with the address of the most-derived object in the \term{delete object} case, or the address of the object suitably adjusted for -the array allocation overhead~(\ref{expr.new}) in the \term{delete array} case, +the array allocation overhead\iref{expr.new} in the \term{delete array} case, as its first argument. If a deallocation function with a parameter of type \tcode{std::align_val_t} @@ -3764,11 +4183,12 @@ \pnum Access and ambiguity control are done for both the deallocation function -and the destructor~(\ref{class.dtor},~\ref{class.free}). +and the destructor~(\ref{class.dtor}, \ref{class.free}). \rSec2[expr.alignof]{Alignof} \pnum +\indextext{\idxcode{alignof}}% \indextext{expression!\idxcode{alignof}}% An \tcode{alignof} expression yields the alignment requirement of its operand type. The operand shall be a \grammarterm{type-id} @@ -3788,10 +4208,11 @@ \rSec2[expr.unary.noexcept]{\tcode{noexcept} operator} \pnum +\indextext{\idxcode{noexcept}}% \indextext{expression!\idxcode{noexcept}}% The \tcode{noexcept} operator determines whether the evaluation of its operand, -which is an unevaluated operand (Clause~\ref{expr}), can throw an -exception~(\ref{except.throw}). +which is an unevaluated operand\iref{expr}, can throw an +exception\iref{except.throw}. \begin{bnf} \nontermdef{noexcept-expression}\br @@ -3804,7 +4225,7 @@ \pnum The result of the \tcode{noexcept} operator is \tcode{true} -unless the \grammarterm{expression} is potentially-throwing~(\ref{except.spec}). +unless the \grammarterm{expression} is potentially-throwing\iref{except.spec}. \indextext{expression!unary|)} \rSec1[expr.cast]{Explicit type conversion (cast notation)}% @@ -3818,12 +4239,12 @@ \begin{note} If \tcode{T} is a non-class type that is cv-qualified, the \grammarterm{cv-qualifier}{s} are discarded when determining the type of the -resulting prvalue; see Clause~\ref{expr}. +resulting prvalue; see \ref{expr}. \end{note} \pnum An explicit type conversion can be expressed using functional -notation~(\ref{expr.type.conv}), a type conversion operator +notation\iref{expr.type.conv}, a type conversion operator (\tcode{dynamic_cast}, \tcode{static_cast}, \tcode{reinterpret_cast}, \tcode{const_cast}), or the \term{cast} notation. @@ -3835,7 +4256,7 @@ \pnum Any type conversion not mentioned below and not explicitly defined by -the user~(\ref{class.conv}) is ill-formed. +the user\iref{class.conv} is ill-formed. \pnum The conversions performed by @@ -3844,10 +4265,10 @@ \indextext{cast!const}% \indextext{cast!static}% \indextext{cast!reinterpret}% -\item a \tcode{const_cast}~(\ref{expr.const.cast}), -\item a \tcode{static_cast}~(\ref{expr.static.cast}), +\item a \tcode{const_cast}\iref{expr.const.cast}, +\item a \tcode{static_cast}\iref{expr.static.cast}, \item a \tcode{static_cast} followed by a \tcode{const_cast}, -\item a \tcode{reinterpret_cast}~(\ref{expr.reinterpret.cast}), or +\item a \tcode{reinterpret_cast}\iref{expr.reinterpret.cast}, or \item a \tcode{reinterpret_cast} followed by a \tcode{const_cast}, \end{itemize} @@ -3948,7 +4369,7 @@ \pnum Abbreviating \term{pm-expression}{}\tcode{.*}\term{cast-expression} as \tcode{E1.*E2}, \tcode{E1} -is called the \term{object expression}. +is called the \defn{object expression}. If the dynamic type of \tcode{E1} does not contain the member to which \tcode{E2} refers, the behavior is undefined. @@ -3993,17 +4414,20 @@ pointed to by \tcode{ptr_to_obj}. \end{example} In a \tcode{.*} expression whose object expression is an rvalue, the program is -ill-formed if the second operand is a pointer to member function with -\grammarterm{ref-qualifier} \tcode{\&}. +ill-formed if the second operand is a pointer to member function +whose \grammarterm{ref-qualifier} is \tcode{\&}, +unless its \grammarterm{cv-qualifier-seq} is \tcode{const}. In a \tcode{.*} expression whose object expression is an lvalue, the program is ill-formed if the second -operand is a pointer to member function with \grammarterm{ref-qualifier} \tcode{\&\&}. +operand is +a pointer to member function +whose \grammarterm{ref-qualifier} is \tcode{\&\&}. The result of a \tcode{.*} expression whose second operand is a pointer to a data member is an lvalue if the first operand is an lvalue and an xvalue otherwise. The result of a \tcode{.*} expression whose second operand is a pointer to a member function is a prvalue. If the second operand is the null -member pointer value~(\ref{conv.mem}), the behavior is undefined. +member pointer value\iref{conv.mem}, the behavior is undefined. \rSec1[expr.mul]{Multiplicative operators}% \indextext{expression!multiplicative operators}% @@ -4129,7 +4553,7 @@ the type of the result is an \impldef{type of \tcode{ptrdiff_t}} signed integral type; this type shall be the same type that is defined as \tcode{std::ptrdiff_t} in the \tcode{} -header~(\ref{support.types}). +header\iref{support.types}. If the expressions \tcode{P} and \tcode{Q} point to, respectively, elements @@ -4149,7 +4573,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 -are not similar~(\ref{conv.qual}), the behavior is undefined. +are not similar\iref{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. \end{note} @@ -4251,9 +4675,9 @@ \pnum The usual arithmetic conversions are performed on operands of arithmetic or enumeration type. If both operands are pointers, pointer -conversions~(\ref{conv.ptr}) and qualification conversions~(\ref{conv.qual}) +conversions\iref{conv.ptr} and qualification conversions\iref{conv.qual} are performed to bring -them to their composite pointer type (Clause~\ref{expr}). +them to their composite pointer type\iref{expr}. After conversions, the operands shall have the same type. \pnum @@ -4274,7 +4698,7 @@ object, or to subobjects of such members, recursively, the pointer to the later declared member compares greater provided the two members -have the same access control (Clause~\ref{class.access}) +have the same access control\iref{class.access} and provided their class is not a union. \item Otherwise, neither pointer compares greater than the other. @@ -4282,7 +4706,7 @@ \end{itemize} \pnum -If two operands \tcode{p} and \tcode{q} compare equal~(\ref{expr.eq}), +If two operands \tcode{p} and \tcode{q} compare equal\iref{expr.eq}, \tcode{p<=q} and \tcode{p>=q} both yield \tcode{true} and \tcode{pq} both yield \tcode{false}. Otherwise, if a pointer \tcode{p} compares greater than a pointer \tcode{q}, \tcode{p>=q}, \tcode{p>q}, @@ -4319,11 +4743,11 @@ \indextext{comparison!pointer}% \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 -qualification conversions~(\ref{conv.qual}) -are performed on both operands to bring them to their composite pointer type -(Clause~\ref{expr}). Comparing pointers is defined as follows: +pointer conversions\iref{conv.ptr}, +function pointer conversions\iref{conv.fctptr}, and +qualification conversions\iref{conv.qual} +are performed on both operands to bring them to their composite pointer type\iref{expr}. +Comparing pointers is defined as follows: \begin{itemize} \item @@ -4335,7 +4759,7 @@ \item Otherwise, if the pointers are both null, both point to the same \indextext{address}% -function, or both represent the same address~(\ref{basic.compound}), +function, or both represent the same address\iref{basic.compound}, they compare equal. \item Otherwise, the pointers compare unequal. @@ -4343,9 +4767,9 @@ \pnum If at least one of the operands is a pointer to member, pointer to member -conversions~(\ref{conv.mem}) and qualification -conversions~(\ref{conv.qual}) are performed on both operands to bring them to -their composite pointer type (Clause~\ref{expr}). +conversions\iref{conv.mem} and qualification +conversions\iref{conv.qual} are performed on both operands to bring them to +their composite pointer type\iref{expr}. Comparing pointers to members is defined as follows: \begin{itemize} @@ -4378,12 +4802,12 @@ \end{example} \item -If both refer to (possibly different) members of the same union~(\ref{class.union}), +If both refer to (possibly different) members of the same union\iref{class.union}, they compare equal. \item Otherwise, two pointers to members compare equal if they would refer to the same member of -the same most derived object~(\ref{intro.object}) or the same subobject if +the same most derived object\iref{intro.object} or the same subobject if indirection with a hypothetical object of the associated class type were performed, otherwise they compare unequal. \begin{example} @@ -4486,8 +4910,8 @@ \pnum The \tcode{\&\&} operator groups left-to-right. The operands are both -contextually converted to \tcode{bool} -(Clause~\ref{conv}). The +contextually converted to \tcode{bool}\iref{conv}. +The result is \tcode{true} if both operands are \tcode{true} and \tcode{false} otherwise. Unlike \tcode{\&}, \tcode{\&\&} guarantees left-to-right evaluation: the second operand is not evaluated if the @@ -4517,8 +4941,8 @@ \pnum The \tcode{||} operator groups left-to-right. The operands are both -contextually converted to \tcode{bool} -(Clause~\ref{conv}). It returns +contextually converted to \tcode{bool}\iref{conv}. +It returns \tcode{true} if either of its operands is \tcode{true}, and \tcode{false} otherwise. Unlike \tcode{|}, \tcode{||} guarantees left-to-right evaluation; moreover, the second operand is not evaluated @@ -4548,8 +4972,8 @@ \pnum Conditional expressions group right-to-left. The first expression is -contextually converted to \tcode{bool} -(Clause~\ref{conv}). It is +contextually converted to \tcode{bool}\iref{conv}. +It is evaluated and if it is \tcode{true}, the result of the conditional expression is the value of the second expression, otherwise that of the third expression. Only one of the second and third expressions is @@ -4566,7 +4990,7 @@ \begin{itemize} \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 +parenthesized) \grammarterm{throw-expression}\iref{expr.throw}; the result is of the type and value category of the other. The \grammarterm{conditional-expression} is a bit-field if that operand is a bit-field. @@ -4590,7 +5014,7 @@ either has (possibly cv-qualified) class type, or if both are glvalues of the same value category and the same type except for cv-qualification, an attempt is made to -form an implicit conversion sequence~(\ref{over.best.ics}) from +form an implicit conversion sequence\iref{over.best.ics} from each of those operands to the type of the other. \begin{note} Properties such as access, whether an operand is a bit-field, or whether @@ -4605,7 +5029,7 @@ \item If \tcode{E2} is an lvalue, the target type is ``lvalue reference to \tcode{T2}'', subject to the constraint that in the conversion the reference must bind -directly~(\ref{dcl.init.ref}) to an lvalue. +directly\iref{dcl.init.ref} to an lvalue. \item If \tcode{E2} is an xvalue, the target type is ``rvalue reference to \tcode{T2}'', @@ -4622,9 +5046,9 @@ \item otherwise, the target type is the type that \tcode{E2} would have after applying the -lvalue-to-rvalue~(\ref{conv.lval}), -array-to-pointer~(\ref{conv.array}), and -function-to-pointer~(\ref{conv.func}) +lvalue-to-rvalue\iref{conv.lval}, +array-to-pointer\iref{conv.array}, and +function-to-pointer\iref{conv.func} standard conversions. \end{itemize} \end{itemize} @@ -4655,15 +5079,15 @@ Otherwise, the result is a prvalue. If the second and third operands do not have the same type, and either has (possibly cv-qualified) class type, overload resolution is used to determine the conversions (if any) -to be applied to the operands~(\ref{over.match.oper},~\ref{over.built}). +to be applied to the operands~(\ref{over.match.oper}, \ref{over.built}). If the overload resolution fails, the program is ill-formed. Otherwise, the conversions thus determined are applied, and the converted operands are used in place of the original operands for the remainder of this section. \pnum -Lvalue-to-rvalue~(\ref{conv.lval}), array-to-pointer~(\ref{conv.array}), -and function-to-pointer~(\ref{conv.func}) standard conversions are +Lvalue-to-rvalue\iref{conv.lval}, array-to-pointer\iref{conv.array}, +and function-to-pointer\iref{conv.func} standard conversions are performed on the second and third operands. After those conversions, one of the following shall hold: @@ -4676,17 +5100,17 @@ type, and the result is of that type. \item One or both of the second and third operands have pointer type; -pointer conversions~(\ref{conv.ptr}), -function pointer conversions~(\ref{conv.fctptr}), and -qualification conversions~(\ref{conv.qual}) +pointer conversions\iref{conv.ptr}, +function pointer conversions\iref{conv.fctptr}, and +qualification conversions\iref{conv.qual} are performed to bring them to their -composite pointer type (Clause~\ref{expr}). The result is of the composite +composite pointer type\iref{expr}. The result is of the composite pointer type. \item One or both of the second and third operands have pointer to member type; -pointer to member conversions~(\ref{conv.mem}) and qualification -conversions~(\ref{conv.qual}) are performed to bring them to their composite -pointer type (Clause~\ref{expr}). The result is of the composite pointer type. +pointer to member conversions\iref{conv.mem} and qualification +conversions\iref{conv.qual} are performed to bring them to their composite +pointer type\iref{expr}. The result is of the composite pointer type. \item Both the second and third operands have type \tcode{std::nullptr_t} or one has @@ -4710,7 +5134,7 @@ \pnum Evaluating a \grammarterm{throw-expression} with an operand throws an -exception~(\ref{except.throw}); the type of the exception object is determined by removing +exception\iref{except.throw}; the type of the exception object is determined by removing any top-level \grammarterm{cv-qualifier}{s} from the static type of the operand and adjusting the type from ``array of \tcode{T}'' or function type \tcode{T} @@ -4720,7 +5144,7 @@ \indextext{exception handling!rethrow}% A \grammarterm{throw-expression} -with no operand rethrows the currently handled exception~(\ref{except.handle}). +with no operand rethrows the currently handled exception\iref{except.handle}. The exception is reactivated with the existing exception object; no new exception object is created. The exception is no longer considered to be caught. @@ -4745,7 +5169,7 @@ evaluating a \grammarterm{throw-expression} with no operand calls -\tcode{std::\brk{}terminate()}~(\ref{except.terminate}). +\tcode{std::\brk{}terminate()}\iref{except.terminate}. \rSec1[expr.ass]{Assignment and compound assignment operators}% \indextext{expression!assignment and compound assignment} @@ -4804,7 +5228,7 @@ \pnum \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 +converted\iref{conv} to the cv-unqualified type of the left operand. \pnum @@ -4812,12 +5236,12 @@ \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 -operator~(\ref{class.copy},~\ref{over.ass}). +operator~(\ref{class.copy}, \ref{over.ass}). \pnum \begin{note} For class objects, assignment is not in general the same as -initialization~(\ref{dcl.init},~\ref{class.ctor},~\ref{class.init},~\ref{class.copy}). +initialization~(\ref{dcl.init}, \ref{class.ctor}, \ref{class.init}, \ref{class.copy}). \end{note} \pnum @@ -4828,8 +5252,8 @@ \impldefplain{value of bit-field that cannot represent!assigned value}. \pnum -The behavior of an expression of the form \tcode{E1} \term{op}\tcode{=} -\tcode{E2} is equivalent to \tcode{E1 = E1} \term{op} \tcode{E2} except +The behavior of an expression of the form \tcode{E1 \placeholder{op}= E2} +is equivalent to \tcode{E1 = E1 \placeholder{op} E2} except that \tcode{E1} is evaluated only once. In \tcode{+=} and \tcode{-=}, \tcode{E1} shall either have arithmetic type or be a pointer to a possibly cv-qualified completely-defined object type. In all other @@ -4885,7 +5309,7 @@ A pair of expressions separated by a comma is evaluated left-to-right; the left expression is -a discarded-value expression (Clause~\ref{expr}). +a discarded-value expression\iref{expr}. Every \indextext{value computation}% value computation and side effect @@ -4896,14 +5320,14 @@ 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 right operand is a bit-field. -If the right operand is a temporary expression~(\ref{class.temporary}), +If the right operand is a temporary expression\iref{class.temporary}, the result is a temporary expression. \pnum In contexts where comma is given a special meaning, \begin{example} in -lists of arguments to functions~(\ref{expr.call}) and lists of -initializers~(\ref{dcl.init}) \end{example} the comma operator as -described in Clause~\ref{expr} can appear only in parentheses. +lists of arguments to functions\iref{expr.call} and lists of +initializers\iref{dcl.init} \end{example} the comma operator as +described in \ref{expr} can appear only in parentheses. \begin{example} \begin{codeblock} @@ -4937,11 +5361,11 @@ An expression \tcode{e} is a \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: +machine\iref{intro.execution}, would evaluate one of the following expressions: \begin{itemize} \item -\tcode{this}~(\ref{expr.prim.this}), except in a constexpr +\tcode{this}\iref{expr.prim.this}, except in a constexpr function or a constexpr constructor that is being evaluated as part of \tcode{e}; @@ -4949,8 +5373,8 @@ an invocation of a function other than 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}) +or an implicit invocation of a trivial destructor\iref{class.dtor} +\begin{note} Overload resolution\iref{over.match} is applied as usual \end{note}; \item @@ -4961,23 +5385,23 @@ 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}); +constexpr constructor\iref{dcl.constexpr}; \item an expression that would exceed the implementation-defined -limits (see Annex~\ref{implimits}); +limits (see \ref{implimits}); \item an operation that would have undefined behavior -as specified in Clauses~\ref{intro} through~\ref{cpp} +as specified in \ref{intro} through \ref{cpp} of this International Standard \begin{note} including, -for example, signed integer overflow~(Clause \ref{expr}), certain -pointer arithmetic~(\ref{expr.add}), division by -zero~(\ref{expr.mul}), or certain shift operations~(\ref{expr.shift}) +for example, signed integer overflow\iref{expr}, certain +pointer arithmetic\iref{expr.add}, division by +zero\iref{expr.mul}, or certain shift operations\iref{expr.shift} \end{note}; \item -an lvalue-to-rvalue conversion~(\ref{conv.lval}) unless +an lvalue-to-rvalue conversion\iref{conv.lval} unless it is applied to \begin{itemize} @@ -4988,7 +5412,7 @@ \item a non-volatile glvalue that refers to a subobject of a string - literal~(\ref{lex.string}), or + literal\iref{lex.string}, or \item a non-volatile glvalue that refers to a non-volatile object @@ -5001,7 +5425,7 @@ \end{itemize} \item -an lvalue-to-rvalue conversion~(\ref{conv.lval}) +an lvalue-to-rvalue conversion\iref{conv.lval} that is applied to a glvalue that refers to a non-active member of a union or a subobject thereof; @@ -5012,8 +5436,8 @@ unless the lifetime of the union object began within the evaluation of \tcode{e}; \item -an assignment expression~(\ref{expr.ass}) -or invocation of an assignment operator~(\ref{class.copy}) +an assignment expression\iref{expr.ass} +or invocation of an assignment operator\iref{class.copy} that would change the active member of a union; \item @@ -5050,7 +5474,7 @@ If the odr-use occurs in an invocation of a function call operator of a closure type, it no longer refers to \tcode{this} or to an enclosing automatic variable -due to the transformation~(\ref{expr.prim.lambda.capture}) +due to the transformation\iref{expr.prim.lambda.capture} of the \grammarterm{id-expression} into an access of the corresponding data member. \begin{example} @@ -5070,13 +5494,13 @@ a conversion from type \cv{}~\tcode{void*} to a pointer-to-object type; \item -a dynamic cast~(\ref{expr.dynamic.cast}); +a dynamic cast\iref{expr.dynamic.cast}; \item -a \tcode{reinterpret_cast}~(\ref{expr.reinterpret.cast}); +a \tcode{reinterpret_cast}\iref{expr.reinterpret.cast}; \item -a pseudo-destructor call~(\ref{expr.pseudo}); +a pseudo-destructor call\iref{expr.pseudo}; \item modification of an object~(\ref{expr.ass}, \ref{expr.post.incr}, @@ -5086,26 +5510,26 @@ whose lifetime began within the evaluation of \tcode{e}; \item -a typeid expression~(\ref{expr.typeid}) whose operand is a glvalue of a +a typeid expression\iref{expr.typeid} whose operand is a glvalue of a polymorphic class type; \item -a \grammarterm{new-expression}~(\ref{expr.new}); +a \grammarterm{new-expression}\iref{expr.new}; \item -a \grammarterm{delete-expression}~(\ref{expr.delete}); +a \grammarterm{delete-expression}\iref{expr.delete}; \item -a relational~(\ref{expr.rel}) or equality~(\ref{expr.eq}) +a relational\iref{expr.rel} or equality\iref{expr.eq} operator where the result is unspecified; or \item -a \grammarterm{throw-expression}~(\ref{expr.throw}). +a \grammarterm{throw-expression}\iref{expr.throw}. \end{itemize} If \tcode{e} satisfies the constraints of a core constant expression, but evaluation of \tcode{e} would evaluate an operation that has undefined behavior -as specified in Clauses~\ref{library} through~\ref{\lastlibchapter} of this +as specified in \ref{library} through \ref{\lastlibchapter} of this International Standard, it is unspecified whether \tcode{e} is a core constant expression. @@ -5155,11 +5579,32 @@ unscoped enumeration type, implicitly converted to a prvalue, where the converted expression is a core constant expression. \begin{note} Such expressions may be -used as bit-field lengths~(\ref{class.bit}), as enumerator -initializers if the underlying type is not fixed~(\ref{dcl.enum}), -and as alignments~(\ref{dcl.align}). +used as bit-field lengths\iref{class.bit}, as enumerator +initializers if the underlying type is not fixed\iref{dcl.enum}, +and as alignments\iref{dcl.align}. \end{note} +\pnum +If an expression of literal class type is used in a context where an +integral constant expression is required, then that expression is +contextually implicitly converted\iref{conv} to an integral or unscoped +enumeration type +and the selected conversion function shall be \tcode{constexpr}. \begin{example} +\begin{codeblock} +struct A { + constexpr A(int i) : val(i) { } + constexpr operator int() const { return val; } + constexpr operator long() const { return 42; } +private: + int val; +}; +template struct X { }; +constexpr A a = alignof(int); +alignas(a) int n; // error: ambiguous conversion +struct B { int n : a; }; // error: ambiguous conversion +\end{codeblock} +\end{example} + \pnum A \defnx{converted constant expression}{expression!converted constant} of type \tcode{T} is an @@ -5169,36 +5614,35 @@ \begin{itemize} \item user-defined conversions, -\item lvalue-to-rvalue conversions~(\ref{conv.lval}), -\item array-to-pointer conversions~(\ref{conv.array}), -\item function-to-pointer conversions~(\ref{conv.func}), -\item qualification conversions~(\ref{conv.qual}), -\item integral promotions~(\ref{conv.prom}), -\item integral conversions~(\ref{conv.integral}) other than narrowing conversions~(\ref{dcl.init.list}), -\item null pointer conversions~(\ref{conv.ptr}) from \tcode{std::nullptr_t}, -\item null member pointer conversions~(\ref{conv.mem}) from \tcode{std::nullptr_t}, and -\item function pointer conversions~(\ref{conv.fctptr}), +\item lvalue-to-rvalue conversions\iref{conv.lval}, +\item array-to-pointer conversions\iref{conv.array}, +\item function-to-pointer conversions\iref{conv.func}, +\item qualification conversions\iref{conv.qual}, +\item integral promotions\iref{conv.prom}, +\item integral conversions\iref{conv.integral} other than narrowing conversions\iref{dcl.init.list}, +\item null pointer conversions\iref{conv.ptr} from \tcode{std::nullptr_t}, +\item null member pointer conversions\iref{conv.mem} from \tcode{std::nullptr_t}, and +\item function pointer conversions\iref{conv.fctptr}, \end{itemize} and where the reference binding (if any) binds directly. \begin{note} Such expressions may be used in \tcode{new} -expressions~(\ref{expr.new}), as case expressions~(\ref{stmt.switch}), +expressions\iref{expr.new}, as case expressions\iref{stmt.switch}, as enumerator initializers if the underlying type is -fixed~(\ref{dcl.enum}), as array bounds~(\ref{dcl.array}), and +fixed\iref{dcl.enum}, as array bounds\iref{dcl.array}, and as non-type template -arguments~(\ref{temp.arg}). +arguments\iref{temp.arg}. \end{note} \indextext{contextually converted constant expression of type \tcode{bool}|see{conversion, contextual}}% \indextext{conversion!contextual to constant expression of type \tcode{bool}}% A \term{contextually converted constant expression of type \tcode{bool}} is -an expression, contextually converted to \tcode{bool}~(Clause\ref{conv}), +an expression, contextually converted to \tcode{bool}\iref{conv}, where the converted expression is a constant expression and the conversion sequence contains only the conversions above. \pnum -\indextext{expression!constant}% -A \term{constant expression} is either +A \defnx{constant expression}{expression!constant} is either a glvalue core constant expression that refers to an entity that is a permitted result of a constant expression (as defined below), or a prvalue core constant expression whose value @@ -5213,7 +5657,7 @@ \item if the value is of pointer type, it contains the address of an object with static storage duration, - the address past the end of such an object~(\ref{expr.add}), + the address past the end of such an object\iref{expr.add}, the address of a function, or a null pointer value, and @@ -5233,7 +5677,7 @@ imposes no restrictions on the accuracy of floating-point operations, it is unspecified whether the evaluation of a floating-point expression during translation yields the same result as the evaluation of the same expression (or the same operations on the same values) during program -execution.\footnote{Nonetheless, implementations are encouraged to provide consistent results, +execution.\footnote{Nonetheless, implementations should provide consistent results, irrespective of whether the evaluation was performed during translation and/or during program execution.} \begin{example} @@ -5245,26 +5689,5 @@ } \end{codeblock} It is unspecified whether the value of \tcode{f()} will be \tcode{true} or \tcode{false}. -\end{example} \end{note} - -\pnum -If an expression of literal class type is used in a context where an -integral constant expression is required, then that expression is -contextually implicitly converted (Clause~\ref{conv}) to an integral or unscoped -enumeration type -and the selected conversion function shall be \tcode{constexpr}. \begin{example} -\begin{codeblock} -struct A { - constexpr A(int i) : val(i) { } - constexpr operator int() const { return val; } - constexpr operator long() const { return 43; } -private: - int val; -}; -template struct X { }; -constexpr A a = 42; -X x; // OK: unique conversion to \tcode{int} -int ary[a]; // error: ambiguous conversion -\end{codeblock} -\end{example}% +\end{example} \end{note}% \indextext{expression|)} diff --git a/source/future.tex b/source/future.tex index 4af3d13879..4bb60c7c1c 100644 --- a/source/future.tex +++ b/source/future.tex @@ -12,7 +12,7 @@ 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}). +\tcode{deprecated} attribute\iref{dcl.attr.deprecated}. \rSec1[depr.static_constexpr]{Redeclaration of \tcode{static constexpr} data members} @@ -39,9 +39,9 @@ user-declared copy assignment operator or a user-declared destructor. The implicit definition of a copy assignment operator as defaulted is deprecated if the class has a user-declared -copy constructor or a user-declared destructor (\ref{class.dtor},~\ref{class.copy}). +copy constructor or a user-declared destructor~(\ref{class.dtor}, \ref{class.copy}). In a future revision of this International Standard, these implicit definitions -could become deleted~(\ref{dcl.fct.def}). +could become deleted\iref{dcl.fct.def}. \rSec1[depr.except.spec]{Deprecated exception specifications} @@ -53,10 +53,10 @@ \pnum For compatibility with prior \Cpp International Standards, the \Cpp standard library provides headers -\tcode{}~(\ref{depr.ccomplex.syn}), -\tcode{}~(\ref{depr.cstdalign.syn}), -\tcode{}~(\ref{depr.cstdbool.syn}), -and \tcode{}~(\ref{depr.ctgmath.syn}). +\tcode{}\iref{depr.ccomplex.syn}, +\tcode{}\iref{depr.cstdalign.syn}, +\tcode{}\iref{depr.cstdbool.syn}, +and \tcode{}\iref{depr.ctgmath.syn}. The use of these headers is deprecated. \rSec2[depr.ccomplex.syn]{Header \tcode{} synopsis} @@ -69,7 +69,7 @@ \pnum The header \tcode{} behaves as if it simply includes the header -\tcode{}~(\ref{complex.syn}). +\tcode{}\iref{complex.syn}. \rSec2[depr.cstdalign.syn]{Header \tcode{} synopsis} @@ -87,7 +87,7 @@ The header \tcode{} and the header \tcode{} shall not define a macro named \tcode{alignas}. -\xref ISO C~7.15. +\xref ISO C 7.15 \rSec2[depr.cstdbool.syn]{Header \tcode{} synopsis} @@ -104,7 +104,7 @@ The header \tcode{} and the header \tcode{} shall not define macros named \tcode{bool}, \tcode{true}, or \tcode{false}. -\xref ISO C~7.18. +\xref ISO C 7.18 \rSec2[depr.ctgmath.syn]{Header \tcode{} synopsis} @@ -116,8 +116,8 @@ \pnum The header \tcode{} simply includes the headers -\tcode{}~(\ref{complex.syn}) -and \tcode{}~(\ref{cmath.syn}). +\tcode{}\iref{complex.syn} +and \tcode{}\iref{cmath.syn}. \pnum \begin{note} The overloads provided in C by type-generic macros are already @@ -185,12 +185,12 @@ header is placed within the global namespace scope, except for the functions described in \ref{sf.cmath}, -the declaration of \tcode{std::byte}~(\ref{cstddef.syn}), and +the declaration of \tcode{std::byte}\iref{cstddef.syn}, and the functions and function templates described in \ref{support.types.byteops}. It is unspecified whether these names are first declared or defined within -namespace scope~(\ref{basic.scope.namespace}) of the namespace +namespace scope\iref{basic.scope.namespace} of the namespace \tcode{std} and are then injected into the global namespace scope by -explicit \grammarterm{using-declaration}{s}~(\ref{namespace.udecl}). +explicit \grammarterm{using-declaration}{s}\iref{namespace.udecl}. \indextext{namespace}% \pnum @@ -231,14 +231,14 @@ public: explicit strstreambuf(streamsize alsize_arg = 0); strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*)); - strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0); + strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = nullptr); strstreambuf(const char* gnext_arg, streamsize n); strstreambuf(signed char* gnext_arg, streamsize n, - signed char* pbeg_arg = 0); + signed char* pbeg_arg = nullptr); strstreambuf(const signed char* gnext_arg, streamsize n); strstreambuf(unsigned char* gnext_arg, streamsize n, - unsigned char* pbeg_arg = 0); + unsigned char* pbeg_arg = nullptr); strstreambuf(const unsigned char* gnext_arg, streamsize n); virtual ~strstreambuf(); @@ -388,11 +388,11 @@ \indextext{unspecified}% \indexlibrary{\idxcode{strstreambuf}!constructor}% \begin{itemdecl} -strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0); +strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = nullptr); strstreambuf(signed char* gnext_arg, streamsize n, - signed char* pbeg_arg = 0); + signed char* pbeg_arg = nullptr); strstreambuf(unsigned char* gnext_arg, streamsize n, - unsigned char* pbeg_arg = 0); + unsigned char* pbeg_arg = nullptr); \end{itemdecl} \begin{itemdescr} @@ -433,20 +433,18 @@ \tcode{n < 0}, \tcode{N} is \tcode{INT_MAX}.\footnote{The function signature +\indexlibrary{\idxcode{strlen}}% \tcode{strlen(const char*)} is declared in -\tcode{} -\indexlibrary{\idxcode{strlen}}% \indextext{\idxhdr{cstring}}% \indexlibrary{\idxhdr{cstring}}% -(\ref{cstring.syn}). +\tcode{}\iref{cstring.syn}. The macro \tcode{INT_MAX} is defined in -\tcode{} \indextext{\idxhdr{climits}}% \indexlibrary{\idxhdr{climits}}% -(\ref{climits.syn}).} +\tcode{}\iref{climits.syn}.} \end{itemize} \pnum @@ -1044,13 +1042,12 @@ \indextext{NTBS}% The constructor is \tcode{strstreambuf(s, n, s + std::strlen(s))}.\footnote{The function signature +\indexlibrary{\idxcode{strlen}}% \tcode{strlen(const char*)} is declared in -\tcode{} -\indexlibrary{\idxcode{strlen}}% \indextext{\idxhdr{cstring}}% \indexlibrary{\idxhdr{cstring}}% -(\ref{cstring.syn}).} +\tcode{}\iref{cstring.syn}.} \end{itemize} \end{itemdescr} @@ -1288,7 +1285,7 @@ \rSec2[depr.weak.result_type]{Weak result types} \pnum -A call wrapper~(\ref{func.def}) may have a \defn{weak result type}. +A call wrapper\iref{func.def} may have a \defn{weak result type}. If it does, the type of its member type \tcode{result_type} is based on the type \tcode{T} of the wrapper's target object: \begin{itemize} @@ -1297,7 +1294,7 @@ \item if \tcode{T} is a pointer to member function, \tcode{result_type} shall be a synonym for the return type of \tcode{T}; \item if \tcode{T} is a class type -and the \grammarterm{qualified-id} \tcode{T::result_type} is valid and denotes a type~(\ref{temp.deduct}), +and the \grammarterm{qualified-id} \tcode{T::result_type} is valid and denotes a type\iref{temp.deduct}, then \tcode{result_type} shall be a synonym for \tcode{T::result_type}; \item otherwise \tcode{result_type} shall not be defined. \end{itemize} @@ -1315,7 +1312,7 @@ for function objects that take two arguments. \pnum -The following member names are defined in addition to names specified in Clause~\ref{function.objects}: +The following member names are defined in addition to names specified in \ref{function.objects}: \indexlibrarymember{result_type}{owner_less}% \indexlibrarymember{first_argument_type}{owner_less}% @@ -1396,7 +1393,7 @@ }; template class reference_wrapper { - public : + public: using result_type = @\seebelow@; // not always defined using argument_type = @\seebelow@; // not always defined using first_argument_type = @\seebelow@; // not always defined @@ -1514,14 +1511,12 @@ using result_type = T; }; - template - class function { + template class function { public: using argument_type = T1; }; - template - class function { + template class function { public: using first_argument_type = T1; using second_argument_type = T2; @@ -1531,7 +1526,7 @@ \indexlibrary{\idxcode{reference_wrapper}!weak result type}% \pnum -\tcode{reference_wrapper} has a weak result type~(\ref{depr.weak.result_type}). +\tcode{reference_wrapper} has a weak result type\iref{depr.weak.result_type}. If \tcode{T} is a function type, \tcode{result_type} shall be a synonym for the return type of \tcode{T}. @@ -1545,7 +1540,7 @@ \item a function type or a pointer to function type taking one argument of type \tcode{T1} \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}); +is valid and denotes a type\iref{temp.deduct}; the type \tcode{T1} is \tcode{T::argument_type}. \end{itemize} @@ -1562,7 +1557,7 @@ \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}); +are both valid and both denote types\iref{temp.deduct}; the type \tcode{T1} is \tcode{T::first_argument_type} and the type \tcode{T2} is \tcode{T::second_argument_type}. \end{itemize} @@ -1570,19 +1565,19 @@ \indexlibrarymember{result_type}{hash}% \indexlibrarymember{argument_type}{hash}% \pnum -All enabled specializations \tcode{hash} of \tcode{hash}~(\ref{unord.hash}) +All enabled specializations \tcode{hash} of \tcode{hash}\iref{unord.hash} provide two nested types, \tcode{result_type} and \tcode{argument_type}, which shall be synonyms for \tcode{size_t} and \tcode{Key}, respectively. \indexlibrary{\idxcode{bind}!weak result type}% \pnum The forwarding call wrapper \tcode{g} -returned by a call to \tcode{bind(f, bound_args...)}~(\ref{func.bind.bind}) -shall have a weak result type~(\ref{depr.weak.result_type}). +returned by a call to \tcode{bind(f, bound_args...)}\iref{func.bind.bind} +shall have a weak result type\iref{depr.weak.result_type}. \pnum The forwarding call wrapper \tcode{g} -returned by a call to \tcode{bind(f, bound_args...)}~(\ref{func.bind.bind}) +returned by a call to \tcode{bind(f, bound_args...)}\iref{func.bind.bind} shall have a nested type \tcode{result_type} defined as a synonym for \tcode{R}. \indexlibrarymember{result_type}{mem_fn}% @@ -1622,7 +1617,7 @@ where \tcode{Ret} is \tcode{pm}{'s} return type. \pnum -The following member names are defined in addition to names specified in Clause~\ref{containers}: +The following member names are defined in addition to names specified in \ref{containers}: \indexlibrarymember{result_type}{map::value_compare}% \indexlibrarymember{first_argument_type}{map::value_compare}% @@ -1676,7 +1671,7 @@ \pnum Negators \tcode{not1} and \tcode{not2} take a unary and a binary predicate, respectively, -and return their logical negations~(\ref{expr.unary.op}). +and return their logical negations\iref{expr.unary.op}. \indexlibrary{\idxcode{unary_negate}}% \indexlibrarymember{argument_type}{unary_negate}% @@ -1816,11 +1811,11 @@ A pointer to the initial element of an array of storage of size \tcode{n} \tcode{* sizeof(T)}, aligned appropriately for objects of type \tcode{T}. It is \impldef{support for over-aligned types} whether over-aligned types are -supported~(\ref{basic.align}). +supported\iref{basic.align}. \pnum \remarks -The storage is obtained by calling \tcode{::operator new(std::size_t)}~(\ref{new.delete}), +The storage is obtained by calling \tcode{::operator new(std::size_t)}\iref{new.delete}, but it is unspecified when or how often this function is called. \pnum @@ -1902,7 +1897,7 @@ \tcode{OutputIterator} is required to have its \tcode{operator*} return an object for which \tcode{operator\&} is defined and returns a pointer to \tcode{T}, and is also required to satisfy the requirements of an output -iterator~(\ref{output.iterators}). +iterator\iref{output.iterators}. \indexlibrary{\idxcode{raw_storage_iterator}!constructor}% \begin{itemdecl} @@ -2028,7 +2023,7 @@ Obtains a pointer to uninitialized, contiguous storage for $N$ adjacent objects of type \tcode{T}, for some non-negative number $N$. It is \impldef{support for over-aligned types} whether over-aligned types are -supported~(\ref{basic.align}). +supported\iref{basic.align}. \pnum \remarks @@ -2102,9 +2097,9 @@ \cv{}~\tcode{void}, or arrays of unknown bound. \pnum -\tcode{is_literal_type} is a \tcode{UnaryTypeTrait}~(\ref{meta.rqmts}) +\tcode{is_literal_type} is a \tcode{UnaryTypeTrait}\iref{meta.rqmts} with a base characteristic of \tcode{true_type} -if \tcode{T} is a literal type~(\ref{basic.types}), and +if \tcode{T} is a literal type\iref{basic.types}, and \tcode{false_type} otherwise. The partial specialization \tcode{result_of} is a \tcode{TransformationTrait} whose member typedef \tcode{type} is defined @@ -2113,7 +2108,8 @@ \pnum The behavior of a program that adds specializations for -\tcode{is_literal_type} or \tcode{is_literal_type_v} is undefined. +any of the templates defined in this subclause is undefined, +unless explicitly permitted by the specification of the corresponding template. \rSec1[depr.iterator.primitives]{Deprecated iterator primitives} @@ -2598,7 +2594,7 @@ public: using state_type = typename Codecvt::state_type; - explicit wbuffer_convert(streambuf* bytebuf = 0, + explicit wbuffer_convert(streambuf* bytebuf = nullptr, Codecvt* pcvt = new Codecvt, state_type state = state_type()); @@ -2685,7 +2681,7 @@ \indexlibrary{\idxcode{wbuffer_convert}!constructor}% \begin{itemdecl} explicit wbuffer_convert( - streambuf* bytebuf = 0, + streambuf* bytebuf = nullptr, Codecvt* pcvt = new Codecvt, state_type state = state_type()); \end{itemdecl} diff --git a/source/grammar.tex b/source/grammar.tex index 7ac4257d2f..96e779c393 100644 --- a/source/grammar.tex +++ b/source/grammar.tex @@ -3,11 +3,11 @@ \pnum \indextext{grammar}% \indextext{summary!syntax}% -This summary of \Cpp\ grammar is intended to be an aid to comprehension. +This summary of \Cpp grammar is intended to be an aid to comprehension. It is not an exact statement of the language. In particular, the grammar described here accepts -a superset of valid \Cpp\ constructs. -Disambiguation rules (\ref{stmt.ambig}, \ref{dcl.spec}, \ref{class.member.lookup}) +a superset of valid \Cpp constructs. +Disambiguation rules~(\ref{stmt.ambig}, \ref{dcl.spec}, \ref{class.member.lookup}) must be applied to distinguish expressions from declarations. Further, access control, ambiguity, and type rules must be used to weed out syntactically valid but meaningless constructs. @@ -17,10 +17,10 @@ \pnum \indextext{keyword}% New context-dependent keywords are introduced into a program by -\tcode{typedef}~(\ref{dcl.typedef}), -\tcode{namespace}~(\ref{namespace.def}), -class~(Clause \ref{class}), enumeration~(\ref{dcl.enum}), and -\tcode{template}~(Clause \ref{temp}) +\tcode{typedef}\iref{dcl.typedef}, +\tcode{namespace}\iref{namespace.def}, +class\iref{class}, enumeration\iref{dcl.enum}, and +\tcode{template}\iref{temp} declarations. \begin{ncbnf} @@ -54,9 +54,8 @@ \end{ncbnf} Note that a -\grammarterm{typedef-name}\ +\grammarterm{typedef-name} naming a class is also a -\grammarterm{class-name}\ -(\ref{class.name}). +\grammarterm{class-name}\iref{class.name}. \FlushAndPrintGrammar diff --git a/source/intro.tex b/source/intro.tex index d309ed55be..c43e357c35 100644 --- a/source/intro.tex +++ b/source/intro.tex @@ -45,9 +45,6 @@ \item ISO/IEC 10646-1:1993, \doccite{Information technology --- Universal Multiple-Octet Coded Character Set (UCS) --- Part 1: Architecture and Basic Multilingual Plane} -\item ISO/IEC 10967-1:2012, \doccite{Information technology --- -Language independent arithmetic --- Part 1: -Integer and floating point arithmetic} \item ISO/IEC/IEEE 60559:2011, \doccite{Information technology --- Microprocessor Systems --- Floating-Point arithmetic} \item ISO 80000-2:2009, \doccite{Quantities and units --- @@ -59,8 +56,8 @@ The library described in Clause 7 of ISO/IEC 9899:2011 is hereinafter called the \defnx{C standard library}{C!standard library}.% -\footnote{With the qualifications noted in Clauses~\ref{\firstlibchapter} -through~\ref{\lastlibchapter} and in~\ref{diff.library}, the C standard +\footnote{With the qualifications noted in \ref{\firstlibchapter} +through \ref{\lastlibchapter} and in \ref{diff.library}, the C standard library is a subset of the \Cpp standard library.} \pnum @@ -70,10 +67,6 @@ \pnum The ECMAScript Language Specification described in Standard Ecma-262 is hereinafter called \defn{ECMA-262}. - -\pnum -The arithmetic specification described in ISO/IEC 10967-1:2012 is -hereinafter called \defn{LIA-1}. \indextext{references!normative|)} \rSec0[intro.defs]{Terms and definitions} @@ -98,16 +91,14 @@ \pnum \ref{definitions} -defines additional terms that are used only in Clauses~\ref{library} -through~\ref{\lastlibchapter} and Annex~\ref{depr}. +defines additional terms that are used only in \ref{library} +through \ref{\lastlibchapter} and \ref{depr}. \pnum Terms that are used only in a small portion of this document are defined where they are used and italicized where they are defined. -\def\definition{\definitionx{\section}}% - \indexdefn{access}% \definition{access}{defns.access} \defncontext{execution-time action} to read or modify the value of an object @@ -116,18 +107,18 @@ \indexdefn{argument!function call expression} \definition{argument}{defns.argument} \defncontext{function call expression} expression in the -comma-separated list bounded by the parentheses~(\ref{expr.call}) +comma-separated list bounded by the parentheses\iref{expr.call} \indexdefn{argument}% \indexdefn{argument!function-like macro}% \definition{argument}{defns.argument.macro} \defncontext{function-like macro} sequence of preprocessing tokens in the -comma-separated list bounded by the parentheses~(\ref{cpp.replace}) +comma-separated list bounded by the parentheses\iref{cpp.replace} \indexdefn{argument}% \indexdefn{argument!throw expression}% \definition{argument}{defns.argument.throw} -\defncontext{throw expression} the operand of \tcode{throw}~(\ref{expr.throw}) +\defncontext{throw expression} the operand of \tcode{throw}\iref{expr.throw} \indexdefn{argument}% \indexdefn{argument!template instantiation}% @@ -136,7 +127,7 @@ \grammarterm{constant-expression}, \grammarterm{type-id}, or \grammarterm{id-expression} in the comma-separated -list bounded by the angle brackets~(\ref{temp.arg}) +list bounded by the angle brackets\iref{temp.arg} \indexdefn{block}% \definition{block}{defns.block} @@ -157,13 +148,13 @@ \indexdefn{type!dynamic}% \definition{dynamic type}{defns.dynamic.type} -\defncontext{glvalue} type of the most derived object~(\ref{intro.object}) to which the +\defncontext{glvalue} type of the most derived object\iref{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\iref{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 +from \tcode{B}\iref{class.derived}, the dynamic type of the +expression \tcode{*p} is ``\tcode{D}''. References\iref{dcl.ref} are treated similarly. \end{example} @@ -173,7 +164,7 @@ \indexdefn{program!ill-formed}% \definition{ill-formed program}{defns.ill.formed} -program that is not well-formed~(\ref{defns.well.formed}) +program that is not well-formed\iref{defns.well.formed} \indexdefn{behavior!implementation-defined}% \definition{implementation-defined behavior}{defns.impl.defined} @@ -195,7 +186,7 @@ character set of either the source or the execution environment\\ \begin{note} The extended character set is a superset of the basic character -set~(\ref{lex.charset}).\end{note} +set\iref{lex.charset}.\end{note} \indexdefn{parameter}% \indexdefn{parameter!function}% @@ -219,14 +210,25 @@ \indexdefn{signature}% \definition{signature}{defns.signature} -\defncontext{function} name, parameter type list~(\ref{dcl.fct}), and enclosing namespace (if any)\\ +\defncontext{function} +name, +parameter type list\iref{dcl.fct}, +enclosing namespace (if any), +and +\grammarterm{requires-clause}\iref{temp.constr.decl} (if any) \begin{note} Signatures are used as a basis for name mangling and linking.\end{note} \indexdefn{signature}% \definition{signature}{defns.signature.templ} -\defncontext{function template} name, parameter type list~(\ref{dcl.fct}), enclosing namespace (if any), -return type, and template parameter list +\defncontext{function template} +name, +parameter type list\iref{dcl.fct}, +enclosing namespace (if any), +return type, +\grammarterm{template-head}, +and +\grammarterm{requires-clause}\iref{temp.constr.decl} (if any) \indexdefn{signature}% \definition{signature}{defns.signature.spec} @@ -235,15 +237,27 @@ \indexdefn{signature}% \definition{signature}{defns.signature.member} -\defncontext{class member function} name, parameter type list~(\ref{dcl.fct}), class of which the -function is a member, \cv-qualifiers (if any), -and \grammarterm{ref-qualifier} (if any) +\defncontext{class member function} +name, +parameter type list\iref{dcl.fct}, +class of which the function is a member, +\cv-qualifiers (if any), +\grammarterm{ref-qualifier} (if any), +and +\grammarterm{requires-clause}\iref{temp.constr.decl} (if any) \indexdefn{signature}% \definition{signature}{defns.signature.member.templ} -\defncontext{class member function template} name, parameter type list~(\ref{dcl.fct}), class of which the -function is a member, \cv-qualifiers (if any), -\grammarterm{ref-qualifier} (if any), return type (if any), and template parameter list +\defncontext{class member function template} +name, +parameter type list\iref{dcl.fct}, +class of which the function is a member, +\cv-qualifiers (if any), +\grammarterm{ref-qualifier} (if any), +return type (if any), +\grammarterm{template-head}, +and +\grammarterm{requires-clause}\iref{temp.constr.decl} (if any) \indexdefn{signature}% \definition{signature}{defns.signature.member.spec} @@ -252,7 +266,7 @@ \indexdefn{type!static}% \definition{static type}{defns.static.type} -type of an expression~(\ref{basic.types}) resulting from +type of an expression\iref{basic.types} resulting from analysis of the program without considering execution semantics\\ \begin{note} The static type of an expression depends only on the form of the program in @@ -278,7 +292,7 @@ issuance of a diagnostic message). Many erroneous program constructs do not engender undefined behavior; they are required to be diagnosed. Evaluation of a constant expression never exhibits behavior explicitly -specified as undefined~(\ref{expr.const}). +specified as undefined\iref{expr.const}. \end{note} \indexdefn{behavior!unspecified}% @@ -293,7 +307,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\iref{basic.def.odr}.% \indextext{definitions|)} \rSec0[intro]{General principles} @@ -343,7 +357,7 @@ If a program contains no violations of the rules in this International Standard, a conforming implementation shall, within its resource limits, accept and correctly execute\footnote{``Correct execution'' can include undefined behavior, depending on -the data being processed; see Clause~\ref{intro.defs} and~\ref{intro.execution}.} +the data being processed; see \ref{intro.defs} and~\ref{intro.execution}.} that program. \item \indextext{message!diagnostic}% @@ -369,7 +383,7 @@ \indextext{conformance requirements!classes}% \indextext{conformance requirements!class templates}% For classes and class templates, the library Clauses specify partial -definitions. Private members~(Clause~\ref{class.access}) are not +definitions. Private members\iref{class.access} are not specified, but each implementation shall supply them to complete the definitions according to the description in the library Clauses. @@ -380,15 +394,15 @@ \pnum The names defined in the library have namespace -scope~(\ref{basic.namespace}). A \Cpp translation -unit~(\ref{lex.phases}) obtains access to these names by including the -appropriate standard library header~(\ref{cpp.include}). +scope\iref{basic.namespace}. A \Cpp translation +unit\iref{lex.phases} obtains access to these names by including the +appropriate standard library header\iref{cpp.include}. \pnum The templates, classes, functions, and objects in the library have -external linkage~(\ref{basic.link}). The implementation provides +external linkage\iref{basic.link}. The implementation provides definitions for standard library entities, as necessary, while combining -translation units to form a complete \Cpp program~(\ref{lex.phases}).% +translation units to form a complete \Cpp program\iref{lex.phases}.% \indextext{conformance requirements!library|)} \pnum @@ -398,7 +412,7 @@ implementation is one in which execution may take place without the benefit of an operating system, and has an \impldef{required libraries for freestanding implementation} set of libraries that includes certain language-support -libraries~(\ref{compliance}). +libraries\iref{compliance}. \pnum A conforming implementation may have extensions (including @@ -421,27 +435,27 @@ \pnum \indextext{standard!structure of|(}% \indextext{standard!structure of}% -Clauses~\ref{lex} through~\ref{cpp} describe the \Cpp programming +\ref{lex} through \ref{cpp} describe the \Cpp programming language. That description includes detailed syntactic specifications in -a form described in~\ref{syntax}. For convenience, Annex~\ref{gram} +a form described in~\ref{syntax}. For convenience, \ref{gram} repeats all such syntactic specifications. \pnum -Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter} and Annex~\ref{depr} +\ref{\firstlibchapter} through \ref{\lastlibchapter} and \ref{depr} (the \defn{library clauses}) describe the \Cpp standard library. That description includes detailed descriptions of the entities and macros -that constitute the library, in a form described in Clause~\ref{library}. +that constitute the library, in a form described in \ref{library}. \pnum -Annex~\ref{implimits} recommends lower bounds on the capacity of conforming +\ref{implimits} recommends lower bounds on the capacity of conforming implementations. \pnum -Annex~\ref{diff} summarizes the evolution of \Cpp since its first +\ref{diff} summarizes the evolution of \Cpp since its first published description, and explains in detail the differences between \Cpp and C\@. Certain features of \Cpp exist solely for compatibility -purposes; Annex~\ref{depr} describes those features. +purposes; \ref{depr} describes those features. \pnum Throughout this document, each example is introduced by @@ -494,7 +508,7 @@ \defn{byte}. A byte is at least large enough to contain any member of the basic \indextext{character set!basic execution}% -execution character set~(\ref{lex.charset}) +execution character set\iref{lex.charset} and the eight-bit code units of the Unicode UTF-8 encoding form and is composed of a contiguous sequence of bits,\footnote{The number of bits in a byte is reported by the macro @@ -515,7 +529,7 @@ features of the language, such as references and virtual functions, might involve additional memory locations that are not accessible to programs but are managed by the implementation. \end{note} Two or more threads of -execution~(\ref{intro.multithread}) can access separate memory +execution\iref{intro.multithread} can access separate memory locations without interfering with each other. \pnum @@ -542,7 +556,7 @@ } \end{codeblock} -contains four separate memory locations: The field \tcode{a} and bit-fields +contains four separate memory locations: The member \tcode{a} and bit-fields \tcode{d} and \tcode{e.ee} are each separate memory locations, and can be modified concurrently without interfering with each other. The bit-fields \tcode{b} and \tcode{c} together constitute the fourth memory location. The @@ -557,38 +571,38 @@ The constructs in a \Cpp program create, destroy, refer to, access, and manipulate objects. An \defn{object} is created -by a definition~(\ref{basic.def}), -by a \grammarterm{new-expression}~(\ref{expr.new}), -when implicitly changing the active member of a union~(\ref{class.union}), +by a definition\iref{basic.def}, +by a \grammarterm{new-expression}\iref{expr.new}, +when implicitly changing the active member of a union\iref{class.union}, or when a temporary object is created~(\ref{conv.rval}, \ref{class.temporary}). An object occupies a region of storage -in its period of construction~(\ref{class.cdtor}), -throughout its lifetime~(\ref{basic.life}), +in its period of construction\iref{class.cdtor}, +throughout its lifetime\iref{basic.life}, and -in its period of destruction~(\ref{class.cdtor}). +in its period of destruction\iref{class.cdtor}. \begin{note} A function is not an object, regardless of whether or not it occupies storage in the way that objects do. \end{note} The properties of an object are determined when the object is created. An object can have a -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}). +name\iref{basic}. An object has a storage +duration\iref{basic.stc} which influences its +lifetime\iref{basic.life}. An object has a +type\iref{basic.types}. Some objects are -polymorphic~(\ref{class.virtual}); the implementation +polymorphic\iref{class.virtual}; the implementation generates information associated with each such object that makes it possible to determine that object's type during program execution. For other objects, the interpretation of the values found therein is -determined by the type of the \grammarterm{expression}{s} (Clause~\ref{expr}) +determined by the type of the \grammarterm{expression}{s}\iref{expr} used to access them. \pnum \indextext{subobject}% Objects can contain other objects, called \defnx{subobjects}{subobject}. A subobject can be -a \defn{member subobject}~(\ref{class.mem}), a \defn{base class subobject} -(Clause~\ref{class.derived}), or an array element. +a \defn{member subobject}\iref{class.mem}, a \defn{base class subobject}\iref{class.derived}, +or an array element. \indextext{object!complete}% An object that is not a subobject of any other object is called a \defn{complete object}. @@ -607,7 +621,7 @@ \end{itemize} \begin{note} If the subobject contains a reference member or a \tcode{const} subobject, -the name of the original subobject cannot be used to access the new object~(\ref{basic.life}). +the name of the original subobject cannot be used to access the new object\iref{basic.life}. \end{note} \begin{example} \begin{codeblock} @@ -615,7 +629,7 @@ union U { X x; float f; }; void tong() { U u = {{ 1 }}; - u.f = 5.f; // OK, creates new subobject of \tcode{u} (\ref{class.union}) + u.f = 5.f; // OK, creates new subobject of \tcode{u}\iref{class.union} X *p = new (&u.x) X {2}; // OK, creates new subobject of \tcode{u} assert(p->n == 2); // OK assert(*std::launder(&u.x.n) == 2); // OK @@ -626,10 +640,10 @@ \pnum \indextext{object!providing storage for}% -If a complete object is created~(\ref{expr.new}) +If a complete object is created\iref{expr.new} in storage associated with another object \placeholder{e} of type ``array of $N$ \tcode{unsigned char}'' or -of type ``array of $N$ \tcode{std::byte}''~(\ref{cstddef.syn}), +of type ``array of $N$ \tcode{std::byte}''\iref{cstddef.syn}, that array \defn{provides storage} for the created object if: \begin{itemize} @@ -644,7 +658,7 @@ If that portion of the array previously provided storage for another object, the lifetime of that object ends -because its storage was reused~(\ref{basic.life}). +because its storage was reused\iref{basic.life}. \end{note} \begin{example} \begin{codeblock} @@ -698,7 +712,7 @@ \end{itemize} \pnum -If a complete object, a data member~(\ref{class.mem}), or an array element is of +If a complete object, a data member\iref{class.mem}, or an array element is of class type, its type is considered the \defn{most derived class}, to distinguish it from the class type of any base class subobject; an object of a most derived class type or of a non-class type is called a @@ -706,10 +720,10 @@ \pnum \indextext{most derived object!bit-field}% -Unless it is a bit-field~(\ref{class.bit}), a most derived object shall have a +Unless it is a bit-field\iref{class.bit}, a most derived object shall have a nonzero size and shall occupy one or more bytes of storage. Base class subobjects may have zero size. An object of trivially copyable or -standard-layout type~(\ref{basic.types}) shall occupy contiguous bytes of +standard-layout type\iref{basic.types} shall occupy contiguous bytes of storage. \pnum @@ -728,7 +742,7 @@ otherwise, they have distinct addresses.\footnote{Under the ``as-if'' rule an implementation is allowed to store two objects at the same machine address or not store an object at all if the program cannot observe the -difference~(\ref{intro.execution}).} +difference\iref{intro.execution}.} \begin{example} \begin{codeblock} @@ -741,7 +755,7 @@ \pnum \begin{note} \Cpp provides a variety of fundamental types and several ways of composing -new types from existing types~(\ref{basic.types}). +new types from existing types\iref{basic.types}. \end{note}% \indextext{object model|)} @@ -786,7 +800,7 @@ Certain other aspects and operations of the abstract machine are described in this International Standard as unspecified (for example, evaluation of expressions in a \grammarterm{new-initializer} if the allocation -function fails to allocate memory~(\ref{expr.new})). Where possible, this +function fails to allocate memory\iref{expr.new}). Where possible, this International Standard defines a set of allowable behaviors. These define the nondeterministic aspects of the abstract machine. An instance of the abstract machine can thus have more than one possible execution @@ -815,7 +829,7 @@ \pnum An instance of each object with automatic storage -duration~(\ref{basic.stc.auto}) is associated with each entry into its +duration\iref{basic.stc.auto} is associated with each entry into its block. Such an object exists and retains its last-stored value during the execution of the block and while the block is suspended (by a call of a function or receipt of a signal). @@ -915,20 +929,20 @@ 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}), +the constituent expressions of \tcode{e}'s operands\iref{expr}, \item any function call that \tcode{e} implicitly invokes, \item -if \tcode{e} is a \grammarterm{lambda-expression}~(\ref{expr.prim.lambda}), +if \tcode{e} is a \grammarterm{lambda-expression}\iref{expr.prim.lambda}, the initialization of the entities captured by copy and the constituent expressions of the \grammarterm{initializer} of the \grammarterm{init-capture}{s}, \item -if \tcode{e} is a function call~(\ref{expr.call}) or implicitly invokes a function, -the constituent expressions of each default argument~(\ref{dcl.fct.default}) +if \tcode{e} is a function call\iref{expr.call} or implicitly invokes a function, +the constituent expressions of each default argument\iref{dcl.fct.default} used in the call, or \item -if \tcode{e} creates an aggregate object~(\ref{dcl.init.aggr}), -the constituent expressions of each default member initializer~(\ref{class.mem}) +if \tcode{e} creates an aggregate object\iref{dcl.init.aggr}, +the constituent expressions of each default member initializer\iref{class.mem} used in the initialization. \end{itemize} @@ -945,16 +959,16 @@ A \defn{full-expression} is \begin{itemize} \item -an unevaluated operand (Clause \ref{expr}), +an unevaluated operand\iref{expr}, \item -a \grammarterm{constant-expression}~(\ref{expr.const}), +a \grammarterm{constant-expression}\iref{expr.const}, \item -an \grammarterm{init-declarator} (Clause \ref{dcl.decl}) or -a \grammarterm{mem-initializer}~(\ref{class.base.init}), +an \grammarterm{init-declarator}\iref{dcl.decl} or +a \grammarterm{mem-initializer}\iref{class.base.init}, including the constituent expressions of the initializer, \item an invocation of a destructor generated at the end of the lifetime -of an object other than a temporary object~(\ref{class.temporary}), or +of an object other than a temporary object\iref{class.temporary}, or \item an expression that is not a subexpression of another expression and that is not otherwise part of a full-expression. @@ -1001,14 +1015,14 @@ \begin{note} The evaluation of a full-expression can include the evaluation of subexpressions that are not lexically part of the full-expression. For example, subexpressions involved in evaluating -default arguments~(\ref{dcl.fct.default}) are considered to +default arguments\iref{dcl.fct.default} are considered to be created in the expression that calls the function, not the expression that defines the default argument. \end{note} \pnum \indextext{value computation|(}% Reading an object designated by a \tcode{volatile} -glvalue~(\ref{basic.lval}), modifying an object, calling a library I/O +glvalue\iref{basic.lval}, modifying an object, calling a library I/O 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 @@ -1024,7 +1038,7 @@ \pnum \defnx{Sequenced before}{sequenced before} is an asymmetric, transitive, pair-wise relation between -evaluations executed by a single thread~(\ref{intro.multithread}), which induces +evaluations executed by a single thread\iref{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} (or, equivalently, \placeholder{B} is \defn{sequenced after} \placeholder{A}), @@ -1069,10 +1083,10 @@ operator are sequenced before the value computation of the result of the operator. If a \indextext{side effects}% -side effect on a memory location~(\ref{intro.memory}) is unsequenced +side effect on a memory location\iref{intro.memory} is unsequenced relative to either another side effect on the same memory location or a value computation using the value of any object in the same memory location, -and they are not potentially concurrent~(\ref{intro.multithread}), +and they are not potentially concurrent\iref{intro.multithread}, the behavior is undefined. \begin{note} The next section imposes similar, but more complex restrictions on @@ -1118,7 +1132,7 @@ \begin{example} Evaluation of a \grammarterm{new-expression} invokes one or more allocation and constructor functions; see~\ref{expr.new}. For another example, -invocation of a conversion function~(\ref{class.conv.fct}) can arise in +invocation of a conversion function\iref{class.conv.fct} can arise in contexts in which no function call syntax appears. \end{example} The sequencing constraints on the execution of the called function (as @@ -1149,9 +1163,9 @@ the initial call to the top-level function of the new thread is executed by the new thread, not by the creating thread. \end{note} Every thread in a program can potentially access every object and function in a program.\footnote{An object -with automatic or thread storage duration~(\ref{basic.stc}) is associated with +with automatic or thread storage duration\iref{basic.stc} is associated with one specific thread, and can be accessed by a different thread only indirectly -through a pointer or reference~(\ref{basic.compound}).} Under a hosted +through a pointer or reference\iref{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 International Standard. The execution of the entire program consists of an execution @@ -1180,12 +1194,12 @@ \pnum Two expression evaluations \defn{conflict} if one of them modifies a memory -location~(\ref{intro.memory}) and the other one reads or modifies the same +location\iref{intro.memory} and the other one reads or modifies the same memory location. \pnum -The library defines a number of atomic operations (Clause~\ref{atomics}) and -operations on mutexes (Clause~\ref{thread}) that are specially identified as +The library defines a number of atomic operations\iref{atomics} and +operations on mutexes\iref{thread} that are specially identified as synchronization operations. These operations play a special role in making assignments in one thread visible to another. A synchronization operation on one or more memory locations is either a consume operation, an acquire operation, a @@ -1231,7 +1245,7 @@ \pnum Certain library calls \defn{synchronize with} other library calls performed by another thread. For example, an atomic store-release synchronizes with a -load-acquire that takes its value from the store~(\ref{atomics.order}). +load-acquire that takes its value from the store\iref{atomics.order}. \begin{note} Except in the specified cases, reading a later value does not necessarily ensure visibility as described below. Such a requirement would sometimes interfere with efficient implementation. \end{note} \begin{note} The @@ -1249,7 +1263,7 @@ \begin{itemize} \item \placeholder{B} is an invocation of any specialization of -\tcode{std::kill_dependency}~(\ref{atomics.order}), or +\tcode{std::kill_dependency}\iref{atomics.order}, or \item \placeholder{A} is the left operand of a built-in logical AND (\tcode{\&\&}, see~\ref{expr.log.and}) or logical OR (\tcode{||}, see~\ref{expr.log.or}) @@ -1259,7 +1273,7 @@ operator, or \item \placeholder{A} is the left operand of the built-in comma (\tcode{,}) -operator~(\ref{expr.comma}); \end{itemize} or +operator\iref{expr.comma}; \end{itemize} or \item \placeholder{A} writes a scalar object or bit-field \placeholder{M}, \placeholder{B} reads the value written by \placeholder{A} from \placeholder{M}, and \placeholder{A} is sequenced before \placeholder{B}, or @@ -1517,12 +1531,12 @@ \pnum Executions of atomic functions -that are either defined to be lock-free~(\ref{atomics.flag}) -or indicated as lock-free~(\ref{atomics.lockfree}) +that are either defined to be lock-free\iref{atomics.flag} +or indicated as lock-free\iref{atomics.lockfree} are \defnx{lock-free executions}{lock-free execution}. \begin{itemize} \item - If there is only one thread that is not blocked~(\ref{defns.block}) + If there is only one thread that is not blocked\iref{defns.block} in a standard library function, a lock-free execution in that thread shall complete. \begin{note} @@ -1567,7 +1581,7 @@ \end{itemize} \pnum -An invocation of a standard library function that blocks~(\ref{defns.block}) +An invocation of a standard library function that blocks\iref{defns.block} is considered to continuously execute execution steps while waiting for the condition that it blocks on to be satisfied. \begin{example} @@ -1605,11 +1619,11 @@ It is \impldef{whether the thread that executes \tcode{main} and the threads created by \tcode{std::thread} provide concurrent forward progress guarantees} whether the implementation-created thread of execution that executes -\tcode{main}~(\ref{basic.start.main}) and the threads of execution created by -\tcode{std::thread}~(\ref{thread.thread.class}) provide concurrent forward progress +\tcode{main}\iref{basic.start.main} and the threads of execution created by +\tcode{std::thread}\iref{thread.thread.class} provide concurrent forward progress guarantees. \begin{note} -General-purpose implementations are encouraged to provide these guarantees. +General-purpose implementations should provide these guarantees. \end{note} \pnum diff --git a/source/iostreams.tex b/source/iostreams.tex index 5b5f008b1d..d213d4ff59 100644 --- a/source/iostreams.tex +++ b/source/iostreams.tex @@ -21,19 +21,19 @@ as summarized in Table~\ref{tab:iostreams.lib.summary}. \begin{libsumtab}{Input/output library summary}{tab:iostreams.lib.summary} -\ref{iostreams.requirements} & Requirements & \\ \rowsep -\ref{iostream.forward} & Forward declarations & \tcode{} \\ \rowsep -\ref{iostream.objects} & Standard iostream objects & \tcode{} \\ \rowsep -\ref{iostreams.base} & Iostreams base classes & \tcode{} \\ \rowsep -\ref{stream.buffers} & Stream buffers & \tcode{} \\ \rowsep -\ref{iostream.format} & Formatting and manipulators & \tcode{} \\ - & & \tcode{} \\ - & & \tcode{} \\ \rowsep -\ref{string.streams} & String streams & \tcode{} \\ \rowsep -\ref{file.streams} & File streams & \tcode{} \\ \rowsep -\ref{filesystems} & File systems & \tcode{} \\ \rowsep -\ref{c.files} & C library files & \tcode{} \\ - & & \tcode{} \\ +\ref{iostreams.requirements} & Requirements & \\ \rowsep +\ref{iostream.forward} & Forward declarations & \tcode{} \\ \rowsep +\ref{iostream.objects} & Standard iostream objects & \tcode{} \\ \rowsep +\ref{iostreams.base} & Iostreams base classes & \tcode{} \\ \rowsep +\ref{stream.buffers} & Stream buffers & \tcode{} \\ \rowsep +\ref{iostream.format} & Formatting and manipulators & \tcode{} \\ + & & \tcode{} \\ + & & \tcode{} \\ \rowsep +\ref{string.streams} & String streams & \tcode{} \\ \rowsep +\ref{file.streams} & File streams & \tcode{} \\ \rowsep +\ref{filesystems} & File systems & \tcode{} \\ \rowsep +\ref{c.files} & C library files & \tcode{} \\ + & & \tcode{} \\ \end{libsumtab} \pnum @@ -53,7 +53,7 @@ \rSec2[iostream.limits.imbue]{Imbue limitations} \pnum -No function described in Clause~\ref{input.output} except for +No function described in \ref{input.output} except for \tcode{ios_base::imbue} and \tcode{basic_filebuf::pubimbue} causes any instance of @@ -61,8 +61,8 @@ or \tcode{basic_streambuf::imbue} to be called. -If any user function called from a function declared in Clause~\ref{input.output} or -as an overriding virtual function of any class declared in Clause~\ref{input.output} +If any user function called from a function declared in \ref{input.output} or +as an overriding virtual function of any class declared in \ref{input.output} calls \tcode{imbue}, the behavior is undefined. @@ -70,7 +70,7 @@ \rSec2[iostreams.limits.pos]{Positioning type limitations} \pnum -The classes of Clause~\ref{input.output} with template arguments +The classes of \ref{input.output} with template arguments \tcode{charT} and \tcode{traits} @@ -92,7 +92,7 @@ \tcode{streampos} or when \tcode{traits::\brk{}off_type} is not \tcode{streamoff}}. \pnum -In the classes of Clause~\ref{input.output}, a template parameter with name +In the classes of \ref{input.output}, a template parameter with name \tcode{charT} represents a member of the set of types containing \tcode{char}, \tcode{wchar_t}, and any other \impldef{set of character types that iostreams templates can be instantiated for} character types that satisfy the requirements for a character on which any of @@ -101,10 +101,10 @@ \rSec2[iostreams.threadsafety]{Thread safety} \pnum -Concurrent access to a stream object (\ref{string.streams},~\ref{file.streams}), stream buffer -object~(\ref{stream.buffers}), or C Library stream~(\ref{c.files}) by multiple threads may result in -a data race~(\ref{intro.multithread}) unless otherwise specified~(\ref{iostream.objects}). -\begin{note} Data races result in undefined behavior~(\ref{intro.multithread}). \end{note} +Concurrent access to a stream object~(\ref{string.streams}, \ref{file.streams}), stream buffer +object\iref{stream.buffers}, or C Library stream\iref{c.files} by multiple threads may result in +a data race\iref{intro.multithread} unless otherwise specified\iref{iostream.objects}. +\begin{note} Data races result in undefined behavior\iref{intro.multithread}. \end{note} \pnum If one thread makes a library call \textit{a} that writes a value to a stream @@ -178,16 +178,16 @@ class basic_iostream; template , - class Allocator = allocator> + class Allocator = allocator> class basic_stringbuf; template , - class Allocator = allocator> + class Allocator = allocator> class basic_istringstream; template , - class Allocator = allocator> + class Allocator = allocator> class basic_ostringstream; template , - class Allocator = allocator> + class Allocator = allocator> class basic_stringstream; template > @@ -392,17 +392,16 @@ the type \tcode{FILE} declared in -\tcode{} \indextext{\idxhdr{cstdio}}% \indexlibrary{\idxhdr{cstdio}}% -(\ref{cstdio.syn}). +\tcode{}\iref{cstdio.syn}. \pnum The header \tcode{} declares objects that associate objects with the standard C streams provided for by the functions declared in -\tcode{}~(\ref{c.files}), and includes all the headers necessary to use +\tcode{}\iref{c.files}, and includes all the headers necessary to use these objects. \indexlibrary{\idxhdr{cstdio}}% @@ -410,7 +409,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}~(\ref{basic.start.main}) begins execution.\footnote{If it is possible for them to do so, implementations are encouraged to +of \tcode{main}\iref{basic.start.main} begins execution.\footnote{If it is possible for them to do so, implementations should 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 @@ -431,9 +430,9 @@ as specified in the C standard library. \pnum -Concurrent access to a synchronized~(\ref{ios.members.static}) standard iostream object's formatted and unformatted input~(\ref{istream}) and output~(\ref{ostream}) functions or a standard C stream by multiple threads shall not result in a data race~(\ref{intro.multithread}). \begin{note} Users must still synchronize concurrent use of these objects and streams by multiple threads if they wish to avoid interleaved characters. \end{note} +Concurrent access to a synchronized\iref{ios.members.static} standard iostream object's formatted and unformatted input\iref{istream} and output\iref{ostream} functions or a standard C stream by multiple threads shall not result in a data race\iref{intro.multithread}. \begin{note} Users must still synchronize concurrent use of these objects and streams by multiple threads if they wish to avoid interleaved characters. \end{note} -\xref~ISO C 7.21.2. +\xref ISO C 7.21.2 \rSec2[narrow.stream.objects]{Narrow stream objects} @@ -452,7 +451,7 @@ declared in \indextext{\idxhdr{cstdio}}% \indexlibrary{\idxhdr{cstdio}}% -\tcode{}~(\ref{cstdio.syn}). +\tcode{}\iref{cstdio.syn}. \pnum After the object @@ -462,7 +461,7 @@ returns \tcode{\&cout}. Its state is otherwise the same as required for -\tcode{basic_ios::init}~(\ref{basic.ios.cons}). +\tcode{basic_ios::init}\iref{basic.ios.cons}. \end{itemdescr} \indexlibrary{\idxcode{cout}}% @@ -480,7 +479,7 @@ declared in \indextext{\idxhdr{cstdio}}% \indexlibrary{\idxhdr{cstdio}}% -\tcode{}~(\ref{cstdio.syn}). +\tcode{}\iref{cstdio.syn}. \end{itemdescr} \indexlibrary{\idxcode{cerr}}% @@ -498,7 +497,7 @@ declared in \indextext{\idxhdr{cstdio}}% \indexlibrary{\idxhdr{cstdio}}% -\tcode{}~(\ref{cstdio.syn}). +\tcode{}\iref{cstdio.syn}. \pnum After the object @@ -507,7 +506,7 @@ \tcode{cerr.flags() \& unitbuf} is nonzero and \tcode{cerr.tie()} returns \tcode{\&cout}. Its state is otherwise the same as required for -\tcode{basic_ios::init}~(\ref{basic.ios.cons}). +\tcode{basic_ios::init}\iref{basic.ios.cons}. \end{itemdescr} \indexlibrary{\idxcode{clog}}% @@ -525,7 +524,7 @@ declared in \indextext{\idxhdr{cstdio}}% \indexlibrary{\idxhdr{cstdio}}% -\tcode{}~(\ref{cstdio.syn}). +\tcode{}\iref{cstdio.syn}. \end{itemdescr} \rSec2[wide.stream.objects]{Wide stream objects} @@ -545,7 +544,7 @@ declared in \indextext{\idxhdr{cstdio}}% \indexlibrary{\idxhdr{cstdio}}% -\tcode{}~(\ref{cstdio.syn}). +\tcode{}\iref{cstdio.syn}. \pnum After the object @@ -555,7 +554,7 @@ returns \tcode{\&wcout}. Its state is otherwise the same as required for -\tcode{basic_ios::init}~(\ref{basic.ios.cons}). +\tcode{basic_ios::init}\iref{basic.ios.cons}. \end{itemdescr} \indexlibrary{\idxcode{wcout}}% @@ -573,7 +572,7 @@ declared in \indextext{\idxhdr{cstdio}}% \indexlibrary{\idxhdr{cstdio}}% -\tcode{}~(\ref{cstdio.syn}). +\tcode{}\iref{cstdio.syn}. \end{itemdescr} \indexlibrary{\idxcode{wcerr}}% @@ -591,7 +590,7 @@ declared in \indextext{\idxhdr{cstdio}}% \indexlibrary{\idxhdr{cstdio}}% -\tcode{}~(\ref{cstdio.syn}). +\tcode{}\iref{cstdio.syn}. \pnum After the object @@ -600,7 +599,7 @@ \tcode{wcerr.flags() \& unitbuf} is nonzero and \tcode{wcerr.tie()} returns \tcode{\&wcout}. Its state is otherwise the same as required for -\tcode{basic_ios::init}~(\ref{basic.ios.cons}). +\tcode{basic_ios::init}\iref{basic.ios.cons}. \end{itemdescr} \indexlibrary{\idxcode{wclog}}% @@ -618,7 +617,7 @@ declared in \indextext{\idxhdr{cstdio}}% \indexlibrary{\idxhdr{cstdio}}% -\tcode{}~(\ref{cstdio.syn}). +\tcode{}\iref{cstdio.syn}. \end{itemdescr} \rSec1[iostreams.base]{Iostreams base classes} @@ -959,7 +958,7 @@ \pnum The type \tcode{fmtflags} -is a bitmask type~(\ref{bitmask.types}). +is a bitmask type\iref{bitmask.types}. Setting its elements has the effects indicated in Table~\ref{tab:iostreams.fmtflags.effects}. \begin{libefftab}{\tcode{fmtflags} effects}{tab:iostreams.fmtflags.effects} @@ -1022,7 +1021,7 @@ \pnum The type \tcode{iostate} -is a bitmask type~(\ref{bitmask.types}) +is a bitmask type\iref{bitmask.types} that contains the elements indicated in Table~\ref{tab:iostreams.iostate.effects}. \begin{libefftab}{\tcode{iostate} effects}{tab:iostreams.iostate.effects} @@ -1058,7 +1057,7 @@ \pnum The type \tcode{openmode} -is a bitmask type~(\ref{bitmask.types}). +is a bitmask type\iref{bitmask.types}. It contains the elements indicated in Table~\ref{tab:iostreams.openmode.effects}. \begin{libefftab}{\tcode{openmode} effects}{tab:iostreams.openmode.effects} @@ -1088,7 +1087,7 @@ \pnum The type \tcode{seekdir} -is an enumerated type~(\ref{enumerated.types}) +is an enumerated type\iref{enumerated.types} that contains the elements indicated in Table~\ref{tab:iostreams.seekdir.effects}. \begin{libefftabmean}{\tcode{seekdir} effects}{tab:iostreams.seekdir.effects} @@ -1122,10 +1121,10 @@ \tcode{Init} describes an object whose construction ensures the construction of the eight objects declared in -\tcode{}~(\ref{iostream.objects}) that associate file +\tcode{}\iref{iostream.objects} that associate file stream buffers with the standard C streams provided for by the functions declared in -\tcode{}~(\ref{cstdio.syn}). +\tcode{}\iref{cstdio.syn}. \pnum For the sake of exposition, the maintained data is presented here as: @@ -1320,7 +1319,7 @@ \pnum \effects Calls each registered callback pair -\tcode{(fn, index)}~(\ref{ios.base.callback}) +\tcode{(fn, index)}\iref{ios.base.callback} as \tcode{(*fn)(imbue_event, *this, index)} at such a time that a call to @@ -1366,7 +1365,7 @@ \pnum \returns \tcode{true} -if the previous state of the standard iostream objects~(\ref{iostream.objects}) +if the previous state of the standard iostream objects\iref{iostream.objects} was synchronized and otherwise returns \tcode{false}. The first time it is called, @@ -1432,7 +1431,7 @@ \pnum \remarks Concurrent access to this function by multiple threads shall not result in a data -race~(\ref{intro.multithread}). +race\iref{intro.multithread}. \end{itemdescr} \indexlibrarymember{iword}{ios_base}% @@ -1544,10 +1543,10 @@ Registers the pair \tcode{(fn, index)} such that during calls to -\tcode{imbue()}~(\ref{ios.base.locales}), +\tcode{imbue()}\iref{ios.base.locales}, \tcode{copyfmt()}, or -\tcode{\~{}ios_base()}~(\ref{ios.base.cons}), +\tcode{\~{}ios_base()}\iref{ios.base.cons}, the function \tcode{fn} is called with argument @@ -1598,13 +1597,13 @@ Destroys an object of class \tcode{ios_base}. Calls each registered callback pair -\tcode{(fn, index)}~(\ref{ios.base.callback}) as +\tcode{(fn, index)}\iref{ios.base.callback} as \tcode{(*fn)(\brk{}erase_event, *this, index)} at such time that any \tcode{ios_base} member function called from within \tcode{fn} -has well defined results. +has well-defined results. \end{itemdescr} \rSec2[fpos]{Class template \tcode{fpos}} @@ -1841,7 +1840,7 @@ \pnum \effects Constructs an object of class -\tcode{basic_ios}~(\ref{ios.base.cons}) +\tcode{basic_ios}\iref{ios.base.cons} leaving its member objects uninitialized. The object shall be initialized by calling \tcode{basic_ios::init} @@ -1977,12 +1976,12 @@ \pnum \effects Calls -\tcode{ios_base::imbue(loc)}~(\ref{ios.base.locales}) +\tcode{ios_base::imbue(loc)}\iref{ios.base.locales} and if \tcode{rdbuf() != 0} then -\tcode{rdbuf()->pubimbue(loc)} (\ref{streambuf.locales}). +\tcode{rdbuf()->pubimbue(loc)}\iref{streambuf.locales}. \pnum \returns @@ -2226,7 +2225,7 @@ If \tcode{((state | (rdbuf() ? goodbit : badbit)) \& exceptions()) == 0}, returns. Otherwise, the function throws an object of class -\tcode{basic_ios::failure}~(\ref{ios::failure}), +\tcode{basic_ios::failure}\iref{ios::failure}, constructed with \impldef{argument values to construct \tcode{basic_ios::failure}} argument values.% @@ -2243,7 +2242,7 @@ Calls \tcode{clear(rdstate() | state)} (which may throw -\tcode{basic_ios::failure}~(\ref{ios::failure})). +\tcode{basic_ios::failure}\iref{ios::failure}). \end{itemdescr} \indexlibrarymember{good}{basic_ios}% @@ -2722,7 +2721,7 @@ \pnum \begin{note} The more obvious use of \tcode{ios_base::hex} to specify hexadecimal floating-point format would -change the meaning of existing well defined programs. \CppIII +change the meaning of existing well-defined programs. \CppIII gives no meaning to the combination of \tcode{fixed} and \tcode{scientific}.\end{note} @@ -3199,7 +3198,7 @@ If a read position is available, returns \tcode{egptr() - gptr()}. Otherwise returns -\tcode{showmanyc()} (\ref{streambuf.virt.get}). +\tcode{showmanyc()}\iref{streambuf.virt.get}. \end{itemdescr} \indexlibrarymember{snextc}{basic_streambuf}% @@ -3610,7 +3609,7 @@ \pnum \returns \tcode{-1} on failure. -What constitutes failure is determined by each derived class~(\ref{filebuf.virtuals}). +What constitutes failure is determined by each derived class\iref{filebuf.virtuals}. \pnum \default @@ -3939,7 +3938,7 @@ The pending sequence is defined as the concatenation of \begin{itemize} \item -the empty sequence if \tcode{pbase()} is not null, otherwise the +the empty sequence if \tcode{pbase()} is null, otherwise the \tcode{pptr() - pbase()} characters beginning at \tcode{pbase()}, followed by @@ -4105,7 +4104,7 @@ @\textit{T1}@ resetiosflags(ios_base::fmtflags mask); @\textit{T2}@ setiosflags (ios_base::fmtflags mask); @\textit{T3}@ setbase(int base); - template @\textit{T4}@ setfill(charT c); + template @\textit{T4}@ setfill(charT c); @\textit{T5}@ setprecision(int n); @\textit{T6}@ setw(int n); template @\textit{T7}@ get_money(moneyT& mon, bool intl = false); @@ -4146,7 +4145,7 @@ template > class basic_istream : virtual public basic_ios { public: - // types (inherited from \tcode{basic_ios} (\ref{ios})): + // types (inherited from \tcode{basic_ios}\iref{ios}): using char_type = charT; using int_type = typename traits::int_type; using pos_type = typename traits::pos_type; @@ -4273,7 +4272,7 @@ then the input function, except as explicitly noted otherwise, completes its actions and does \tcode{setstate(eofbit)}, which may throw -\tcode{ios_base::failure}~(\ref{iostate.flags}), before returning. +\tcode{ios_base::failure}\iref{iostate.flags}, before returning. \pnum If one of these called functions throws an exception, then unless explicitly noted otherwise, @@ -4302,7 +4301,7 @@ \effects Constructs an object of class \tcode{basic_istream}, initializing the base class subobject with -\tcode{basic_ios::init(sb)}~(\ref{basic.ios.cons}). +\tcode{basic_ios::init(sb)}\iref{basic.ios.cons}. \pnum \postconditions @@ -4481,7 +4480,7 @@ During preparation, the constructor may call \tcode{setstate(failbit)} (which may throw -\tcode{ios_base::\brk{}failure}~(\ref{iostate.flags}))\footnote{The sentry +\tcode{ios_base::\brk{}failure}\iref{iostate.flags})\footnote{The sentry constructor and destructor can also perform additional \indextext{implementation-dependent}% @@ -4569,7 +4568,7 @@ \pnum As in the case of the inserters, these extractors depend on the locale's -\tcode{num_get<>}~(\ref{locale.num.get}) object to perform parsing the input +\tcode{num_get<>}\iref{locale.num.get} object to perform parsing the input 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: @@ -4669,7 +4668,7 @@ \pnum \returns \tcode{pf(*this)}.\footnote{See, for example, the function signature -\tcode{ws(basic_istream\&)}~(\ref{istream.manip}).% +\tcode{ws(basic_istream\&)}\iref{istream.manip}.% \indexlibrary{\idxcode{ws}}}% \end{itemdescr} @@ -4702,7 +4701,7 @@ \effects Calls \tcode{pf(*this)}.\footnote{See, for example, the function signature -\tcode{dec(ios_base\&)}~(\ref{basefield.manip}).} +\tcode{dec(ios_base\&)}\iref{basefield.manip}.} This extractor does not behave as a formatted input function (as described in~\ref{istream.formatted.reqmts}). @@ -4767,7 +4766,7 @@ If the function extracted no characters, it calls \tcode{setstate(failbit)}, which may throw -\tcode{ios_base::\brk{}failure}~(\ref{iostate.flags}). +\tcode{ios_base::\brk{}failure}\iref{iostate.flags}. \pnum \returns @@ -4809,11 +4808,11 @@ \begin{itemdescr} \pnum \effects -Behaves as an unformatted input function (\ref{istream.unformatted}). +Behaves as an unformatted input function\iref{istream.unformatted}. If \tcode{sb} is null, calls \tcode{setstate(fail\-bit)}, which may throw -\tcode{ios_base::failure}~(\ref{iostate.flags}). +\tcode{ios_base::failure}\iref{iostate.flags}. After a sentry object is constructed, extracts characters from \tcode{*this} @@ -4833,14 +4832,14 @@ If the function inserts no characters, it calls \tcode{setstate(failbit)}, which may throw -\tcode{ios_base::\brk{}failure}~(\ref{iostate.flags}). +\tcode{ios_base::\brk{}failure}\iref{iostate.flags}. If it inserted no characters because it caught an exception thrown while extracting characters from \tcode{*this} and \tcode{failbit} is on in -\tcode{exceptions()}~(\ref{iostate.flags}), +\tcode{exceptions()}\iref{iostate.flags}, then the caught exception is rethrown. \pnum @@ -4930,7 +4929,7 @@ Otherwise, the function calls \tcode{setstate(failbit)}, which may throw -\tcode{ios_base::failure}~(\ref{iostate.flags}), +\tcode{ios_base::failure}\iref{iostate.flags}, \pnum \returns @@ -4958,7 +4957,7 @@ Otherwise, the function calls \tcode{setstate(failbit)} (which may throw -\tcode{ios_base::failure}~(\ref{iostate.flags})). +\tcode{ios_base::failure}\iref{iostate.flags}). \pnum \returns @@ -5002,7 +5001,7 @@ If the function stores no characters, it calls \tcode{setstate(failbit)} (which may throw -\tcode{ios_base::\brk{}failure}~(\ref{iostate.flags})). +\tcode{ios_base::\brk{}failure}\iref{iostate.flags}). In any case, if \tcode{n} is greater than zero it then stores a null character into the next successive location of the array. @@ -5061,7 +5060,7 @@ If the function inserts no characters, it calls \tcode{setstate(failbit)}, which may throw -\tcode{ios_base::\brk{}failure}~(\ref{iostate.flags}). +\tcode{ios_base::\brk{}failure}\iref{iostate.flags}. \pnum \returns @@ -5133,7 +5132,7 @@ If the function extracts no characters, it calls \tcode{setstate(failbit)} (which may throw -\tcode{ios_base::\brk{}failure}~(\ref{iostate.flags})).\footnote{This implies an +\tcode{ios_base::\brk{}failure}\iref{iostate.flags}).\footnote{This implies an empty input line will not cause \tcode{failbit} to be set.} @@ -5203,7 +5202,7 @@ Characters are extracted until any of the following occurs: \begin{itemize} \item -\tcode{n != numeric_limits::max()}~(\ref{numeric.limits}) +\tcode{n != numeric_limits::max()}\iref{numeric.limits} and \tcode{n} characters have been extracted so far \item @@ -5211,7 +5210,7 @@ (in which case the function calls \tcode{setstate(eofbit)}, which may throw -\tcode{ios_base::failure}~(\ref{iostate.flags})); +\tcode{ios_base::failure}\iref{iostate.flags}); \item \tcode{traits::eq_int_type(traits::to_int_type(c), delim)} for the next available input character \tcode{c} @@ -5283,7 +5282,7 @@ (in which case the function calls \tcode{setstate(failbit | eofbit)}, which may throw -\tcode{ios_base::failure}~(\ref{iostate.flags})). +\tcode{ios_base::failure}\iref{iostate.flags}). \end{itemize} \pnum @@ -5315,7 +5314,7 @@ calls \tcode{setstate(eofbit)} (which may throw -\tcode{ios_base::failure}~(\ref{iostate.flags})), +\tcode{ios_base::failure}\iref{iostate.flags}), and extracts no characters; \begin{itemize} \item @@ -5363,7 +5362,7 @@ calls \tcode{setstate(badbit)} (which may throw -\tcode{ios_base::failure}~(\ref{iostate.flags})). +\tcode{ios_base::failure}\iref{iostate.flags}). \begin{note} This function extracts no characters, so the value returned by the next call to @@ -5405,7 +5404,7 @@ calls \tcode{setstate(badbit)} (which may throw -\tcode{ios_base::failure}~(\ref{iostate.flags})). +\tcode{ios_base::failure}\iref{iostate.flags}). \begin{note} This function extracts no characters, so the value returned by the next call to @@ -5440,7 +5439,7 @@ calls \tcode{setstate(badbit)} (which may throw -\tcode{ios_base::failure}~(\ref{iostate.flags}), +\tcode{ios_base::failure}\iref{iostate.flags}, and returns \tcode{-1}. Otherwise, returns zero. @@ -5532,12 +5531,12 @@ \begin{itemdescr} \pnum \effects -Behaves as an unformatted input function (\ref{istream.unformatted}), except that it does not count the number of characters extracted and -does not affect the value returned by subsequent calls to is.gcount(). After +Behaves as an unformatted input function\iref{istream.unformatted}, except that it does not count the number of characters extracted and +does not affect the value returned by subsequent calls to \tcode{is.gcount()}. After constructing a sentry object extracts characters as long as the next available character \tcode{c} is whitespace or until there are no more characters in the sequence. Whitespace characters are distinguished with the same criterion as used by -\tcode{sentry::sentry}~(\ref{istream::sentry}). +\tcode{sentry::sentry}\iref{istream::sentry}. If \tcode{ws} stops extracting characters because there are no more available it sets @@ -5624,9 +5623,9 @@ \effects Constructs an object of class \tcode{basic_iostream}, initializing the base class subobjects with -\tcode{basic_istream(sb)}~(\ref{istream}) +\tcode{basic_istream(sb)}\iref{istream} and -\tcode{basic_ostream(sb)}~(\ref{ostream}). +\tcode{basic_ostream(sb)}\iref{ostream}. \pnum \postconditions @@ -5706,7 +5705,7 @@ template > class basic_ostream : virtual public basic_ios { public: - // types (inherited from \tcode{basic_ios} (\ref{ios})): + // types (inherited from \tcode{basic_ios}\iref{ios}): using char_type = charT; using int_type = typename traits::int_type; using pos_type = typename traits::pos_type; @@ -5851,7 +5850,7 @@ \effects Constructs an object of class \tcode{basic_ostream}, initializing the base class subobject with -\tcode{basic_ios::init(sb)}~(\ref{basic.ios.cons}). +\tcode{basic_ios::init(sb)}\iref{basic.ios.cons}. \pnum \postconditions @@ -5969,7 +5968,7 @@ During preparation, the constructor may call \tcode{setstate(failbit)} (which may throw -\tcode{ios_base::\brk{}failure}~(\ref{iostate.flags}))\footnote{The +\tcode{ios_base::\brk{}failure}\iref{iostate.flags})\footnote{The \tcode{sentry} constructor and destructor can also perform additional @@ -6271,7 +6270,7 @@ \returns \tcode{pf(*this)}.\footnote{See, for example, the function signature \indexlibrary{\idxcode{endl}}% -\tcode{endl(basic_ostream\&)}~(\ref{ostream.manip}).} +\tcode{endl(basic_ostream\&)}\iref{ostream.manip}.} \end{itemdescr} \indexlibrarymember{operator<<}{basic_ostream}% @@ -6292,7 +6291,7 @@ \returns \tcode{*this}.\footnote{See, for example, the function signature \indexlibrary{\idxcode{dec}}% -\tcode{dec(ios_base\&)}~(\ref{basefield.manip}).} +\tcode{dec(ios_base\&)}\iref{basefield.manip}.} \end{itemdescr} \indexlibrarymember{operator<<}{basic_ostream}% @@ -6321,7 +6320,7 @@ \begin{itemdescr} \pnum \effects -Behaves as an unformatted output function (\ref{ostream.unformatted}). +Behaves as an unformatted output function\iref{ostream.unformatted}. After the sentry object is constructed, if \tcode{sb} is null calls @@ -6349,7 +6348,7 @@ If the function inserts no characters, it calls \tcode{setstate(failbit)} (which may throw -\tcode{ios_base::\brk{}failure}~(\ref{iostate.flags})). +\tcode{ios_base::\brk{}failure}\iref{iostate.flags}). If an exception was thrown while extracting a character, the function sets \tcode{failbit} @@ -6378,7 +6377,7 @@ \end{codeblock} where \tcode{s} is an \impldef{NTCTS in \tcode{basic_ostream\& op\-er\-ator<<(nullptr_t)}} -NTCTS~(\ref{defns.ntcts}). +NTCTS\iref{defns.ntcts}. \end{itemdescr} \rSec4[ostream.inserters.character]{Character inserter function templates} @@ -6402,7 +6401,7 @@ \begin{itemdescr} \pnum \effects -Behaves as a formatted output function~(\ref{ostream.formatted.reqmts}) +Behaves as a formatted output function\iref{ostream.formatted.reqmts} of \tcode{out}. Constructs a character sequence \tcode{seq}. If \tcode{c} has type \tcode{char} @@ -6445,7 +6444,7 @@ Behaves like a formatted inserter (as described in~\ref{ostream.formatted.reqmts}) of \tcode{out}. Creates a character sequence \tcode{seq} of \tcode{n} characters starting at \tcode{s}, each widened using -\tcode{out.widen()}~(\ref{basic.ios.members}), +\tcode{out.widen()}\iref{basic.ios.members}, where \tcode{n} is the number that would be computed as if by: \begin{itemize} \item @@ -6526,7 +6525,7 @@ Otherwise, calls \tcode{setstate(badbit)} (which may throw -\tcode{ios_base::failure}~(\ref{iostate.flags})). +\tcode{ios_base::failure}\iref{iostate.flags}). \pnum \returns @@ -6558,7 +6557,7 @@ (in which case the function calls \tcode{setstate(badbit)}, which may throw -\tcode{ios_base::failure}~(\ref{iostate.flags})). +\tcode{ios_base::failure}\iref{iostate.flags}). \end{itemize} \pnum @@ -6584,7 +6583,7 @@ calls \tcode{setstate(badbit)} (which may throw -\tcode{ios_base::failure}~(\ref{iostate.flags})). +\tcode{ios_base::failure}\iref{iostate.flags}). Otherwise, if the sentry object returns \tcode{false}, does nothing. \pnum @@ -6947,11 +6946,11 @@ \begin{itemdescr} \pnum \requires The type \tcode{moneyT} shall be either \tcode{long double} or a -specialization of the \tcode{basic_string} template (Clause~\ref{strings}). +specialization of the \tcode{basic_string} template\iref{strings}. \pnum \effects The expression \tcode{in >> get_money(mon, intl)} described below -behaves as a formatted input function~(\ref{istream.formatted.reqmts}). +behaves as a formatted input function\iref{istream.formatted.reqmts}. \pnum \returns An object of unspecified type such that if @@ -6987,13 +6986,13 @@ \begin{itemdescr} \pnum \requires The type \tcode{moneyT} shall be either \tcode{long double} or a -specialization of the \tcode{basic_string} template (Clause~\ref{strings}). +specialization of the \tcode{basic_string} template\iref{strings}. \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 << put_money(mon, intl)} behaves as a -formatted output function~(\ref{ostream.formatted.reqmts}) that calls +formatted output function\iref{ostream.formatted.reqmts} that calls \tcode{f(out, mon, intl)}, where the function \tcode{f} is defined as: \begin{codeblock} @@ -7113,7 +7112,7 @@ \tcode{charT} and with member type \tcode{traits_type}, which in the second and third forms is the same as \tcode{traits}, then the expression \tcode{out << quoted(s, delim, escape)} -behaves as a formatted output function~(\ref{ostream.formatted.reqmts}) +behaves as a formatted output function\iref{ostream.formatted.reqmts} of \tcode{out}. This forms a character sequence \tcode{seq}, initially consisting of the following elements: \begin{itemize} @@ -7148,8 +7147,8 @@ and \tcode{traits}, respectively, then the expression \tcode{in >> quoted(s, delim, escape)} behaves as if it extracts the following characters from \tcode{in} using -\tcode{operator>>(basic_istream\&, charT\&)}~(\ref{istream.extractors}) -which may throw \tcode{ios_base::failure}~(\ref{ios::failure}): +\tcode{operator>>(basic_istream\&, charT\&)}\iref{istream.extractors} +which may throw \tcode{ios_base::failure}\iref{ios::failure}: \begin{itemize} \item If the first character extracted is equal to \tcode{delim}, as determined by \tcode{traits_type::eq}, then: @@ -7334,7 +7333,7 @@ Constructs an object of class \tcode{basic_stringbuf}, initializing the base class with -\tcode{basic_streambuf()}~(\ref{streambuf.cons}), and initializing +\tcode{basic_streambuf()}\iref{streambuf.cons}, and initializing \tcode{mode} with \tcode{which}. @@ -7356,7 +7355,7 @@ Constructs an object of class \tcode{basic_stringbuf}, initializing the base class with -\tcode{basic_streambuf()}~(\ref{streambuf.cons}), and initializing +\tcode{basic_streambuf()}\iref{streambuf.cons}, and initializing \tcode{mode} with \tcode{which}. Then calls \tcode{str(s)}. @@ -7571,6 +7570,7 @@ \pnum \returns +As specified above, or \tcode{traits::eof()} to indicate failure. @@ -7624,6 +7624,7 @@ \pnum \returns +As specified above, or \tcode{traits::eof()} to indicate failure. @@ -7664,8 +7665,8 @@ positions the output sequence \\ \rowsep \tcode{(which \& (ios_base::in |}\br \tcode{ios_base::out)) ==}\br -\tcode{(ios_base::in) |}\br -\tcode{ios_base::out))}\br +\tcode{(ios_base::in |}\br +\tcode{ios_base::out)}\br and \tcode{way ==} either\br \tcode{ios_base::beg} or\br \tcode{ios_base::end} & @@ -7698,7 +7699,7 @@ If \tcode{(newoff + off) < 0}, or if \tcode{newoff + off} refers to an uninitialized -character (\ref{stringbuf.members}), +character\iref{stringbuf.members}, the positioning operation fails. Otherwise, the function assigns \tcode{xbeg + newoff + off} @@ -7827,9 +7828,9 @@ Constructs an object of class \tcode{basic_istringstream}, initializing the base class with -\tcode{basic_istream(\&sb)} +\tcode{basic_istream(\&sb)}\iref{istream} and initializing \tcode{sb} with -\tcode{basic_stringbuf(which | ios_base::in))}~(\ref{stringbuf.cons}). +\tcode{basic_string\-buf(which | ios_base::in))}\iref{stringbuf.cons}. \end{itemdescr} \indexlibrary{\idxcode{basic_istringstream}!constructor}% @@ -7845,9 +7846,9 @@ Constructs an object of class \tcode{basic_istringstream}, initializing the base class with -\tcode{basic_istream(\&sb)} +\tcode{basic_istream(\&sb)}\iref{istream} and initializing \tcode{sb} with -\tcode{basic_stringbuf(str, which | ios_base::in))}~(\ref{stringbuf.cons}). +\tcode{basic_string\-buf(str, which | ios_base::in))}\iref{stringbuf.cons}. \end{itemdescr} \indexlibrary{\idxcode{basic_istringstream}!constructor}% @@ -8013,11 +8014,11 @@ \pnum \effects Constructs an object of class -\tcode{basic_ostringstream}, +\tcode{basic_ostringstream}, initializing the base class with -\tcode{basic_ostream(\brk{}\&sb)} +\tcode{basic_ostream(\&sb)}\iref{ostream} and initializing \tcode{sb} with -\tcode{basic_stringbuf(which | \brk{}ios_base::out))}~(\ref{stringbuf.cons}). +\tcode{basic_string\-buf(which | ios_base::out))}\iref{stringbuf.cons}. \end{itemdescr} \indexlibrary{\idxcode{basic_ostringstream}!constructor}% @@ -8033,9 +8034,9 @@ Constructs an object of class \tcode{basic_ostringstream}, initializing the base class with -\tcode{basic_ostream(\&sb)} +\tcode{basic_ostream(\&sb)}\iref{ostream} and initializing \tcode{sb} with -\tcode{basic_stringbuf(str, which | ios_base::out))}~(\ref{stringbuf.cons}). +\tcode{basic_string\-buf(str, which | ios_base::out))}\iref{stringbuf.cons}. \end{itemdescr} \indexlibrary{\idxcode{basic_ostringstream}!constructor}% @@ -8204,11 +8205,11 @@ Constructs an object of class \tcode{basic_stringstream}, initializing the base class with -\tcode{basic_iostream(\&sb)} +\tcode{basic_iostream(\&sb)}\iref{iostream.cons} and initializing \tcode{sb} with -\tcode{basic_stringbuf(which)}. +\tcode{basic_string\-buf(which)}. \end{itemdescr} \indexlibrary{\idxcode{basic_stringstream}!constructor}% @@ -8224,11 +8225,11 @@ Constructs an object of class \tcode{basic_stringstream}, initializing the base class with -\tcode{basic_iostream(\&sb)} +\tcode{basic_iostream(\&sb)}\iref{iostream.cons} and initializing \tcode{sb} with -\tcode{basic_stringbuf(str, which)}. +\tcode{basic_string\-buf(str, which)}. \end{itemdescr} \indexlibrary{\idxcode{basic_stringstream}!constructor}% @@ -8384,7 +8385,7 @@ \pnum In this subclause, member functions taking arguments of \tcode{const filesystem::path::value_type*} -are only be provided on systems where \tcode{filesystem::path::value_type}~(\ref{fs.class.path}) is not \tcode{char}. +are only be provided on systems where \tcode{filesystem::path::value_type}\iref{fs.class.path} is not \tcode{char}. \begin{note} These functions enable class \tcode{path} support for systems with a wide native path character type, such as \tcode{wchar_t}. \end{note} @@ -8510,7 +8511,7 @@ Constructs an object of class \tcode{basic_filebuf}, initializing the base class with -\tcode{basic_streambuf()}~(\ref{streambuf.cons}). +\tcode{basic_streambuf()}\iref{streambuf.cons}. \pnum \postconditions @@ -8700,7 +8701,7 @@ are declared, in \indextext{\idxhdr{cstdio}}% \indexlibrary{\idxhdr{cstdio}}% -\tcode{}~(\ref{cstdio.syn}).} +\tcode{}\iref{cstdio.syn}.} \pnum If the repositioning operation fails, calls @@ -8785,7 +8786,7 @@ \pnum \effects Behaves the same as -\tcode{basic_streambuf::showmanyc()}~(\ref{streambuf.virtuals}). +\tcode{basic_streambuf::showmanyc()}\iref{streambuf.virtuals}. \indexlibrary{\idxcode{showmanyc}!\idxcode{basic_streambuf}}% \pnum @@ -8911,6 +8912,7 @@ \pnum \returns +As specified above, or \tcode{traits::eof()} to indicate failure. @@ -9141,7 +9143,7 @@ If the file is not positioned at its beginning and the encoding of the current locale as determined by \tcode{a_codecvt.encoding()} -is state-dependent~(\ref{locale.codecvt.virtuals}) +is state-dependent\iref{locale.codecvt.virtuals} then that facet is the same as the corresponding facet of \tcode{loc}. @@ -9238,10 +9240,9 @@ Constructs an object of class \tcode{basic_ifstream}, initializing the base class with -\tcode{basic_istream(\&sb)} +\tcode{basic_istream(\&sb)}\iref{istream.cons} and initializing \tcode{sb} with -\tcode{basic_filebuf())}~(\ref{istream.cons}, -\ref{filebuf.cons}). +\tcode{basic_filebuf())}\iref{filebuf.cons}. \end{itemdescr} \indexlibrary{\idxcode{basic_ifstream}!constructor}% @@ -9256,12 +9257,11 @@ \pnum \effects Constructs an object of class -\tcode{basic_ifstream}, +\tcode{basic_ifstream}, initializing the base class with -\tcode{basic_istream(\&sb)} +\tcode{basic_istream(\&sb)}\iref{istream.cons} and initializing \tcode{sb} with -\tcode{basic_filebuf())}~(\ref{istream.cons}, -\ref{filebuf.cons}), +\tcode{basic_filebuf())}\iref{filebuf.cons}, then calls \tcode{rdbuf()->open(s, mode | ios_base::in)}. If that function returns a null pointer, calls @@ -9377,7 +9377,7 @@ otherwise calls \tcode{setstate(failbit)} (which may throw -\tcode{ios_base::failure}) (\ref{iostate.flags}). +\tcode{ios_base::failure})\iref{iostate.flags}. \end{itemdescr} \indexlibrarymember{open}{basic_ifstream}% @@ -9406,7 +9406,7 @@ calls \tcode{setstate(failbit)} (which may throw -\tcode{ios_base::failure})~(\ref{iostate.flags}). +\tcode{ios_base::failure})\iref{iostate.flags}. \end{itemdescr} \rSec2[ofstream]{Class template \tcode{basic_ofstream}} @@ -9488,10 +9488,9 @@ Constructs an object of class \tcode{basic_ofstream}, initializing the base class with -\tcode{basic_ostream(\&sb)} +\tcode{basic_ostream(\&sb)}\iref{ostream.cons} and initializing \tcode{sb} with -\tcode{basic_filebuf())}~(\ref{ostream.cons}, -\ref{filebuf.cons}). +\tcode{basic_filebuf())}\iref{filebuf.cons}. \end{itemdescr} \indexlibrary{\idxcode{basic_ofstream}!constructor}% @@ -9508,10 +9507,9 @@ Constructs an object of class \tcode{basic_ofstream}, initializing the base class with -\tcode{basic_ostream(\&sb)} +\tcode{basic_ostream(\&sb)}\iref{ostream.cons} and initializing \tcode{sb} with -\tcode{basic_filebuf())}~(\ref{ostream.cons}, -\ref{filebuf.cons}), +\tcode{basic_filebuf())}\iref{filebuf.cons}, then calls \tcode{rdbuf()->open(s, mode | ios_base::out)}. If that function returns a null pointer, calls @@ -9627,7 +9625,7 @@ otherwise calls \tcode{setstate(\brk{}failbit)} (which may throw -\tcode{ios_base::failure}) (\ref{iostate.flags}). +\tcode{ios_base::failure})\iref{iostate.flags}. \end{itemdescr} \indexlibrarymember{close}{basic_ofstream}% @@ -9643,7 +9641,7 @@ and, if that function fails (returns a null pointer), calls \tcode{setstate(\brk{}failbit)} (which may throw -\tcode{ios_base::failure})~(\ref{iostate.flags}). +\tcode{ios_base::failure})\iref{iostate.flags}. \end{itemdescr} \indexlibrarymember{open}{basic_ofstream}% @@ -9747,7 +9745,7 @@ Constructs an object of class \tcode{basic_fstream}, initializing the base class with -\tcode{basic_iostream(\&sb)} +\tcode{basic_iostream(\&sb)}\iref{iostream.cons} and initializing \tcode{sb} with @@ -9770,7 +9768,7 @@ Constructs an object of class \tcode{basic_fstream}, initializing the base class with -\tcode{basic_iostream(\&sb)} +\tcode{basic_iostream(\&sb)}\iref{iostream.cons} and initializing \tcode{sb} with @@ -9894,7 +9892,7 @@ otherwise calls \tcode{setstate(failbit)} (which may throw -\tcode{ios_base::failure})~(\ref{iostate.flags}). +\tcode{ios_base::failure})\iref{iostate.flags}. \end{itemdescr} \indexlibrarymember{open}{basic_fstream}% @@ -9927,7 +9925,7 @@ calls \tcode{setstate(failbit)} (which may throw -\tcode{ios_base::failure})~(\ref{iostate.flags}). +\tcode{ios_base::failure})\iref{iostate.flags}. \end{itemdescr} \rSec1[filesystems]{File systems} @@ -9946,16 +9944,16 @@ \rSec3[fs.conform.9945]{POSIX conformance} \pnum -Some behavior is specified by reference to POSIX (\ref{fs.norm.ref}). How such behavior is actually implemented is unspecified. +Some behavior is specified by reference to POSIX\iref{fs.norm.ref}. How such behavior is actually implemented is unspecified. \begin{note} This constitutes an ``as if'' rule allowing implementations to call native operating system or other APIs. \end{note} \pnum -Implementations are encouraged to provide such behavior as it is defined by +Implementations should provide such behavior as it is defined by POSIX. Implementations shall document any behavior that differs from the behavior defined by POSIX. Implementations that do not support exact POSIX -behavior are encouraged to provide behavior as close to POSIX behavior as is reasonable given the +behavior should provide behavior as close to POSIX behavior as is reasonable given the limitations of actual operating systems and file systems. If an implementation cannot provide any reasonable behavior, the implementation shall report an error as specified in~\ref{fs.err.report}. \begin{note} This allows users to rely on an exception being thrown or @@ -9975,7 +9973,7 @@ \rSec3[fs.conform.os]{Operating system dependent behavior conformance} \pnum Some behavior is specified as being -operating system dependent (\ref{fs.def.osdep}). The operating system an +operating system dependent\iref{fs.def.osdep}. The operating system an implementation is dependent upon is \impldef{operating system on which implementation depends}. @@ -9986,7 +9984,7 @@ \rSec3[fs.race.behavior]{File system race behavior} \pnum -Behavior is undefined if calls to functions provided by this subclause introduce a file system race~(\ref{fs.def.race}). +Behavior is undefined if calls to functions provided by this subclause introduce a file system race\iref{fs.def.race}. \pnum If the possibility of a file system race would make it unreliable for a @@ -10010,8 +10008,6 @@ \rSec2[fs.definitions]{Terms and definitions} -\def\definition{\definitionx{\subsubsection}}% - \definition{absolute path}{fs.def.absolute.path} A path that unambiguously identifies the location of a file without reference to an additional starting @@ -10026,7 +10022,7 @@ \definition{file}{fs.def.file} An object within a file system that holds user or system data. Files can be written to, or read from, or both. A file has certain attributes, including type. File types include regular files -and directories. Other types of files, such as symbolic links~(\ref{fs.def.symlink}), +and directories. Other types of files, such as symbolic links\iref{fs.def.symlink}, may be supported by the implementation. \definition{file system}{fs.def.filesystem} @@ -10055,7 +10051,7 @@ \end{itemize} \definition{hard link}{fs.def.hardlink} -A link~(\ref{fs.def.link}) to an existing file. Some +A link\iref{fs.def.link} to an existing file. Some file systems support multiple hard links to a file. If the last hard link to a file is removed, the file itself is removed. \begin{note} A hard link can be thought of as a shared-ownership smart @@ -10066,8 +10062,8 @@ \definition{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 -wide-character set encoding~(\ref{lex.charset}). +for pathnames\iref{fs.def.pathname}. For wide character strings, the implementation-defined execution +wide-character set encoding\iref{lex.charset}. \definition{native pathname format}{fs.def.native} The operating system dependent pathname format accepted by the host operating system. @@ -10084,7 +10080,7 @@ \item Replace each slash character in the \grammarterm{root-name} with a \grammarterm{preferred-separator}. \item Replace each \grammarterm{directory-separator} with a \grammarterm{preferred-separator}. \begin{note} -The generic pathname grammar~(\ref{fs.path.generic}) defines \grammarterm{directory-separator} as one or more slashes and \grammarterm{preferred-separator}{s}. +The generic pathname grammar\iref{fs.path.generic} defines \grammarterm{directory-separator} as one or more slashes and \grammarterm{preferred-separator}{s}. \end{note} \item Remove each \grammarterm{dot} filename and any immediately following \grammarterm{directory-separator}. \item As long as any appear, remove a non-\grammarterm{dot-dot} filename immediately followed by a \grammarterm{directory-separator} and a \grammarterm{dot-dot} filename, along with any immediately following \grammarterm{directory-separator}. @@ -10120,7 +10116,7 @@ \definition{pathname}{fs.def.pathname} A character string that represents the name of a path. Pathnames are -formatted according to the generic pathname format grammar~(\ref{fs.path.generic}) or an +formatted according to the generic pathname format grammar\iref{fs.path.generic} or an operating system dependent native pathname format. @@ -10133,7 +10129,7 @@ \definition{relative path}{fs.def.rel.path} A path that is not absolute, and as such, only unambiguously -identifies the location of a file when resolved~(\ref{fs.def.pathres}) relative to +identifies the location of a file when resolved\iref{fs.def.pathres} relative to an implied starting location. The elements of a path that determine if it is relative are operating system dependent. \begin{note} @@ -10162,7 +10158,7 @@ \pnum Template parameters named \tcode{InputIterator} shall meet the -input iterator requirements~(\ref{input.iterators}) and shall +input iterator requirements\iref{input.iterators} and shall have a value type that is one of the encoded character types. \pnum @@ -10174,7 +10170,7 @@ \pnum Template parameters named \tcode{Allocator} shall meet the -Allocator requirements~(\ref{allocator.requirements}). +Allocator requirements\iref{allocator.requirements}. \rSec3[fs.req.namespace]{Namespaces and headers} @@ -10257,11 +10253,11 @@ using file_time_type = chrono::time_point<@\textit{trivial-clock}@>; // \ref{fs.op.funcs}, filesystem operations - path absolute(const path& p, const path& base = current_path()); + path absolute(const path& p); + path absolute(const path& p, error_code& ec); - path canonical(const path& p, const path& base = current_path()); + path canonical(const path& p); path canonical(const path& p, error_code& ec); - path canonical(const path& p, const path& base, error_code& ec); void copy(const path& from, const path& to); void copy(const path& from, const path& to, error_code& ec) noexcept; @@ -10408,7 +10404,7 @@ \pnum \tcode{\textit{trivial-clock}} is an \impldef{type of filesystem trivial clock} type -that satisfies the \tcode{TrivialClock} requirements~(\ref{time.clock.req}) +that satisfies the \tcode{TrivialClock} requirements\iref{time.clock.req} and that is capable of representing and measuring file time values. Implementations should ensure that the resolution and range of \tcode{file_time_type} reflect the operating system dependent resolution and range @@ -10472,8 +10468,8 @@ \indexlibrary{\idxcode{path}}% \pnum -An object of class \tcode{path} represents a path~(\ref{fs.def.path}) -and contains a pathname~(\ref{fs.def.pathname}). +An object of class \tcode{path} represents a path\iref{fs.def.path} +and contains a pathname\iref{fs.def.pathname}. Such an object is concerned only with the lexical and syntactic aspects of a path. The path does not necessarily exist in external storage, and the pathname is not necessarily valid for the current operating @@ -10518,7 +10514,7 @@ template path& operator=(const Source& source); template - path& assign(const Source& source) + path& assign(const Source& source); template path& assign(InputIterator first, InputIterator last); @@ -10581,10 +10577,10 @@ std::u32string generic_u32string() const; // \ref{fs.path.compare}, compare - int compare(const path& p) const noexcept; - int compare(const string_type& s) const; - int compare(basic_string_view s) const; - int compare(const value_type* s) const; + int compare(const path& p) const noexcept; + int compare(const string_type& s) const; + int compare(basic_string_view s) const; + int compare(const value_type* s) const; // \ref{fs.path.decompose}, decomposition path root_name() const; @@ -10632,7 +10628,7 @@ \indexlibrarymember{preferred_separator}{path}% \pnum The value of the \tcode{preferred_separator} member -is the operating system dependent \grammarterm{preferred-separator} character~(\ref{fs.path.generic}). +is the operating system dependent \grammarterm{preferred-separator} character\iref{fs.path.generic}. \pnum \begin{example} @@ -10710,15 +10706,15 @@ be the same as one \grammarterm{directory-separator} character. \pnum -The filename \grammarterm{dot}~(\ref{fs.def.filename}) is treated as a reference to the current directory. -The filename \grammarterm{dot-dot}~(\ref{fs.def.filename}) is treated as a reference to the parent directory. +The filename \grammarterm{dot}\iref{fs.def.filename} is treated as a reference to the current directory. +The filename \grammarterm{dot-dot}\iref{fs.def.filename} is treated as a reference to the parent directory. What the filename \grammarterm{dot-dot} refers to relative to \grammarterm{root-directory} is \impldef{meaning of \grammarterm{dot-dot} in \grammarterm{root-directory}}. Specific filenames may have special meanings for a particular operating system. \pnum A \grammarterm{root-name} identifies the -starting location for pathname resolution~(\ref{fs.def.pathres}). +starting location for pathname resolution\iref{fs.def.pathres}. If there are no operating system dependent \grammarterm{root-name}{s}, at least one \impldefrootname{} \grammarterm{root-name} is required. \begin{note} Many operating systems define a name @@ -10759,8 +10755,8 @@ \pnum Several functions are defined to accept \term{detected-format} arguments, which are character sequences. A detected-format argument represents a path -using either a pathname in the generic format~(\ref{fs.path.generic}) -or a pathname in the native format~(\ref{fs.def.native}). +using either a pathname in the generic format\iref{fs.path.generic} +or a pathname in the native format\iref{fs.def.native}. Such an argument is taken to be in the generic format if and only if it matches the generic format and is not acceptable to the operating system as a native path. @@ -10791,7 +10787,7 @@ \pnum \begin{note} -A path stores a native format pathname~(\ref{fs.path.native.obs}) +A path stores a native format pathname\iref{fs.path.native.obs} and acts as if it also stores a generic format pathname, related as given below. The implementation may generate the generic format pathname @@ -10829,7 +10825,7 @@ to be converted to is determined by its value type: \begin{itemize} -\item \tcode{char}: The encoding is the native narrow encoding~(\ref{fs.def.native.encode}). +\item \tcode{char}: The encoding is the native narrow encoding\iref{fs.def.native.encode}. The method of conversion, if any, is operating system dependent. \begin{note} For POSIX-based operating systems \tcode{path::value_type} is \tcode{char} @@ -10844,7 +10840,7 @@ strings to identify paths. Changing this behavior would be surprising and error prone. \end{note} -\item \tcode{wchar_t}: The encoding is the native wide encoding~(\ref{fs.def.native.encode}). +\item \tcode{wchar_t}: The encoding is the native wide encoding\iref{fs.def.native.encode}. The method of conversion is unspecified. \begin{note} For Windows-based operating systems \tcode{path::value_type} is \tcode{wchar_t} @@ -10866,7 +10862,7 @@ \rSec3[fs.path.req]{\tcode{path} requirements} \pnum -In addition to the requirements~(\ref{fs.req}), +In addition to the requirements\iref{fs.req}, function template parameters named \tcode{Source} shall be one of: \begin{itemize} @@ -10899,12 +10895,12 @@ \tcode{basic_string} or \tcode{basic_string_view}, or \item the \grammarterm{qualified-id} \tcode{iterator_traits>::value_type} is valid and -denotes a possibly \tcode{const} encoded character type~(\ref{temp.deduct}). +denotes a possibly \tcode{const} encoded character type\iref{temp.deduct}. \end{itemize} \pnum \begin{note} -See path conversions~(\ref{fs.path.cvt}) +See path conversions\iref{fs.path.cvt} for how the value types above and their encodings convert to \tcode{path::value_type} and its encoding. \end{note} @@ -10955,8 +10951,8 @@ \effects Constructs an object of class \tcode{path} for which the pathname in the detected-format of \tcode{source} -has the original value of \tcode{source}~(\ref{fs.path.fmt.cvt}), -converting format if required~(\ref{fs.path.fmt.cvt}). +has the original value of \tcode{source}\iref{fs.path.fmt.cvt}, +converting format if required\iref{fs.path.fmt.cvt}. \tcode{source} is left in a valid but unspecified state. \end{itemdescr} @@ -10970,9 +10966,9 @@ \begin{itemdescr} \pnum -\effects Let \tcode{s} be the effective range of \tcode{source}~(\ref{fs.path.req}) -or the range \range{first}{last}, with the encoding converted if required~(\ref{fs.path.cvt}). -Finds the detected-format of \tcode{s}~(\ref{fs.path.fmt.cvt}) +\effects Let \tcode{s} be the effective range of \tcode{source}\iref{fs.path.req} +or the range \range{first}{last}, with the encoding converted if required\iref{fs.path.cvt}. +Finds the detected-format of \tcode{s}\iref{fs.path.fmt.cvt} and constructs an object of class \tcode{path} for which the pathname in that format is \tcode{s}. \end{itemdescr} @@ -10999,7 +10995,7 @@ \begin{itemize} \item If \tcode{value_type} is \tcode{wchar_t}, converts to the native -wide encoding~(\ref{fs.def.native.encode}) using the \tcode{codecvt<\brk{}wchar_t, char, mbstate_t>} +wide encoding\iref{fs.def.native.encode} using the \tcode{codecvt<\brk{}wchar_t, char, mbstate_t>} facet of \tcode{loc}. \item Otherwise a conversion is performed using the @@ -11008,7 +11004,7 @@ \end{itemize} \pnum -Finds the detected-format of \tcode{s}~(\ref{fs.path.fmt.cvt}) +Finds the detected-format of \tcode{s}\iref{fs.path.fmt.cvt} and constructs an object of class \tcode{path} for which the pathname in that format is \tcode{s}. @@ -11025,7 +11021,7 @@ For POSIX-based operating systems, the path is constructed by first using \tcode{latin1_facet} to convert ISO/IEC 8859-1 encoded \tcode{latin1_string} to a wide character string in the native wide -encoding~(\ref{fs.def.native.encode}). The resulting wide string is then +encoding\iref{fs.def.native.encode}. The resulting wide string is then converted to a narrow character pathname string in the current native narrow encoding. If the native wide encoding is UTF-16 or UTF-32, and the current native narrow @@ -11109,9 +11105,9 @@ \begin{itemdescr} \pnum \effects -Let \tcode{s} be the effective range of \tcode{source}~(\ref{fs.path.req}) -or the range \range{first}{last}, with the encoding converted if required~(\ref{fs.path.cvt}). -Finds the detected-format of \tcode{s}~(\ref{fs.path.fmt.cvt}) +Let \tcode{s} be the effective range of \tcode{source}\iref{fs.path.req} +or the range \range{first}{last}, with the encoding converted if required\iref{fs.path.cvt}. +Finds the detected-format of \tcode{s}\iref{fs.path.fmt.cvt} and sets the pathname in that format to \tcode{s}. \pnum @@ -11381,7 +11377,7 @@ \rSec4[fs.path.native.obs]{\tcode{path} native format observers} \pnum -The string returned by all native format observers is in the native pathname format~(\ref{fs.def.native}). +The string returned by all native format observers is in the native pathname format\iref{fs.def.native}. \indexlibrarymember{native}{path}% \begin{itemdecl} @@ -11451,7 +11447,7 @@ \begin{itemdescr} \pnum -\returns \tcode{pathstring}. +\returns \tcode{native()}. \pnum \remarks Conversion, if any, is performed as specified @@ -11464,7 +11460,7 @@ \pnum Generic format observer functions return strings formatted according to the -generic pathname format (\ref{fs.path.generic}). +generic pathname format\iref{fs.path.generic}. A single slash (\tcode{'/'}) character is used as the \grammarterm{directory-separator}. @@ -11607,7 +11603,7 @@ \begin{itemdescr} \pnum \returns A \tcode{path} composed from the pathname in the generic format, -if \tcode{!empty()}, beginning +if \tcode{empty()} is \tcode{false}, beginning with the first \grammarterm{filename} after \grammarterm{root-path}. Otherwise, \tcode{path()}. \end{itemdescr} @@ -11618,7 +11614,7 @@ \begin{itemdescr} \pnum -\returns \tcode{*this} if \tcode{!has_relative_path()}, +\returns \tcode{*this} if \tcode{has_relative_path()} is \tcode{false}, otherwise a path whose generic format pathname is the longest prefix of the generic format pathname of \tcode{*this} that produces one fewer element in its iteration. @@ -11683,7 +11679,7 @@ \begin{itemdescr} \pnum -\returns a path whose pathname in the generic format is +\returns A path whose pathname in the generic format is the suffix of \tcode{filename()} not included in \tcode{stem()}. \pnum @@ -11810,7 +11806,7 @@ \begin{itemdescr} \pnum \returns \tcode{true} if the pathname in the native format - contains an absolute path (\ref{fs.def.absolute.path}), else \tcode{false}. + contains an absolute path\iref{fs.def.absolute.path}, else \tcode{false}. \pnum \begin{example} \tcode{path("/").is_absolute()} is @@ -11838,7 +11834,7 @@ \begin{itemdescr} \pnum \returns A path whose pathname in the generic format is -the normal form~(\ref{fs.def.normal.form}) of the pathname +the normal form\iref{fs.def.normal.form} of the pathname in the generic format of \tcode{*this}. \pnum @@ -11862,8 +11858,8 @@ \begin{itemdescr} \pnum \returns \tcode{*this} made relative to \tcode{base}. -Does not resolve~(\ref{fs.def.pathres}) symlinks. -Does not first normalize~(\ref{fs.def.normal.form}) \tcode{*this} or \tcode{base}. +Does not resolve\iref{fs.def.pathres} symlinks. +Does not first normalize\iref{fs.def.normal.form} \tcode{*this} or \tcode{base}. \pnum \effects @@ -11912,7 +11908,7 @@ use the operational function \tcode{relative()}. \end{note} \pnum -\begin{note} If normalization~(\ref{fs.def.normal.form}) is needed +\begin{note} If normalization\iref{fs.def.normal.form} is needed to ensure consistent matching of elements, apply \tcode{lexically_normal()} to \tcode{*this}, \tcode{base}, or both. \end{note} @@ -11933,7 +11929,7 @@ use the operational function \tcode{proximate()}. \end{note} \pnum -\begin{note} If normalization~(\ref{fs.def.normal.form}) is needed +\begin{note} If normalization\iref{fs.def.normal.form} is needed to ensure consistent matching of elements, apply \tcode{lexically_normal()} to \tcode{*this}, \tcode{base}, or both. \end{note} @@ -11944,11 +11940,11 @@ \indexlibrary{\idxcode{path}!\idxcode{iterator}}% \pnum Path iterators iterate over the elements of the pathname -in the generic format~(\ref{fs.path.generic}). +in the generic format\iref{fs.path.generic}. \pnum A \tcode{path::iterator} is a constant iterator satisfying all the -requirements of a bidirectional iterator~(\ref{bidirectional.iterators}) +requirements of a bidirectional iterator\iref{bidirectional.iterators} except that, for dereferenceable iterators \tcode{a} and \tcode{b} of type \tcode{path::iterator} @@ -12079,7 +12075,7 @@ 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. +determines if two paths resolve\iref{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} @@ -12168,7 +12164,7 @@ \returns \begin{itemize} \item If \tcode{value_type} is \tcode{char} and the current native - narrow encoding~(\ref{fs.def.native.encode}) is UTF-8, + narrow encoding\iref{fs.def.native.encode} is UTF-8, return \tcode{path(source)} or \tcode{path(first, last)}; otherwise, \item if \tcode{value_type} is \tcode{wchar_t} and the @@ -12184,7 +12180,7 @@ \end{itemize} \pnum -\remarks Argument format conversion (\ref{fs.path.fmt.cvt}) applies to the +\remarks Argument format conversion\iref{fs.path.fmt.cvt} applies to the arguments for these functions. How Unicode encoding conversions are performed is unspecified. @@ -12236,7 +12232,7 @@ objects thrown as exceptions to report file system errors from functions described in this subclause. -\rSec3[filesystem_error.members]{\tcode{filesystem_error} members} +\rSec3[fs.filesystem_error.members]{\tcode{filesystem_error} members} \pnum Constructors are provided that store zero, one, or two paths associated with @@ -12338,7 +12334,7 @@ \begin{itemdescr} \pnum \returns A string containing \tcode{runtime_error::what()}. The exact format is unspecified. - Implementations are encouraged but not required to include \tcode{path1.native_string()} + Implementations should include \tcode{path1.native_string()} if not empty, \tcode{path2.native_string()} if not empty, and \tcode{system_error::what()} strings in the returned string. \end{itemdescr} @@ -12414,7 +12410,7 @@ \indexlibrary{\idxcode{copy_options}}% \pnum The \tcode{enum class} type \tcode{copy_options} -is a bitmask type~(\ref{bitmask.types}) that specifies bitmask constants used to control the semantics of +is a bitmask type\iref{bitmask.types} that specifies bitmask constants used to control the semantics of copy operations. The constants are specified in option groups with the meanings listed in Table~\ref{tab:fs.enum.copy_options}. Constant \tcode{none} is shown in each option group for purposes of exposition; implementations shall provide only a single definition. @@ -12469,7 +12465,7 @@ \indexlibrary{\idxcode{perms}}% \pnum The \tcode{enum class} type \tcode{perms} -is a bitmask type~(\ref{bitmask.types}) that specifies bitmask constants used to identify file +is a bitmask type\iref{bitmask.types} that specifies bitmask constants used to identify file permissions, with the meanings listed in Table~\ref{tab:fs.enum.perms}. \begin{floattable} @@ -12528,7 +12524,7 @@ \indexlibrary{\idxcode{perm_options}}% \pnum The \tcode{enum class} type \tcode{perm_options} -is a bitmask type~(\ref{bitmask.types}) that specifies bitmask constants used to +is a bitmask type\iref{bitmask.types} that specifies bitmask constants used to control the semantics of permissions operations, with the meanings listed in Table~\ref{tab:enum.perm_options}. The bitmask constants are bitmask elements. @@ -12559,7 +12555,7 @@ \indexlibrary{\idxcode{directory_options}}% \pnum The \tcode{enum class} type \tcode{directory_options} is a bitmask - type~(\ref{bitmask.types}) that specifies bitmask constants used to identify + type\iref{bitmask.types} that specifies bitmask constants used to identify directory traversal options, with the meanings listed in Table~\ref{tab:fs.enum.directory_options}. \begin{floattable} @@ -12747,16 +12743,16 @@ such as hard link count, status, symlink status, file size, and last write time. \pnum -Implementations are encouraged to store such additional file attributes +Implementations should store such additional file attributes during directory iteration if their values are available and storing the values would allow the implementation to eliminate file system accesses -by \tcode{directory_entry} observer functions~(\ref{fs.op.funcs}). +by \tcode{directory_entry} observer functions\iref{fs.op.funcs}. Such stored file attribute values are said to be \defnx{cached}{file attributes!cached}. \pnum \begin{note} For purposes of exposition, -class \tcode{directory_iterator}~(\ref{fs.class.directory_iterator}) +class \tcode{directory_iterator}\iref{fs.class.directory_iterator} is shown above as a friend of class \tcode{directory_entry}. Friendship allows the \tcode{directory_iterator} implementation to cache already available attribute values @@ -12859,7 +12855,7 @@ \begin{itemdescr} \pnum \effects Stores the current values of any cached attributes of the file \tcode{p} resolves to. -If an error occurs, an error is reported~(\ref{fs.err.report}) +If an error occurs, an error is reported\iref{fs.err.report} and the values of any cached attributes are unspecified. \pnum @@ -12867,7 +12863,7 @@ \pnum \begin{note} -Implementations of \tcode{directory_iterator}~(\ref{fs.class.directory_iterator}) +Implementations of \tcode{directory_iterator}\iref{fs.class.directory_iterator} are prohibited from directly or indirectly calling the \tcode{refresh} function since it must access the external file system, and the objective of caching is to avoid unnecessary file system accesses. @@ -12901,7 +12897,7 @@ \begin{itemdescr} \pnum -\returns \tcode{exists(this->status())} or \tcode{exists(this->status(), ec)}, respectively. +\returns \tcode{exists(this->status())} or \tcode{exists(this->status(ec))}, respectively. \pnum \throws As specified in~\ref{fs.err.report}. @@ -12915,7 +12911,7 @@ \begin{itemdescr} \pnum -\returns \tcode{is_block_file(this->status())} or \tcode{is_block_file(this->status(), ec)}, respectively. +\returns \tcode{is_block_file(this->status())} or \tcode{is_block_file(this->status(ec))}, respectively. \pnum \throws As specified in~\ref{fs.err.report}. @@ -12929,7 +12925,7 @@ \begin{itemdescr} \pnum -\returns \tcode{is_character_file(this->status())} or \tcode{is_character_file(this->status(), ec)}, respectively. +\returns \tcode{is_character_file(this->status())} or \tcode{is_character_file(this->status(ec))}, respectively. \pnum \throws As specified in~\ref{fs.err.report}. @@ -12943,7 +12939,7 @@ \begin{itemdescr} \pnum -\returns \tcode{is_directory(this->status())} or \tcode{is_directory(this->status(), ec)}, respectively. +\returns \tcode{is_directory(this->status())} or \tcode{is_directory(this->status(ec))}, respectively. \pnum \throws As specified in~\ref{fs.err.report}. @@ -12957,7 +12953,7 @@ \begin{itemdescr} \pnum -\returns \tcode{is_fifo(this->status())} or \tcode{is_fifo(this->status(), ec)}, respectively. +\returns \tcode{is_fifo(this->status())} or \tcode{is_fifo(this->status(ec))}, respectively. \pnum \throws As specified in~\ref{fs.err.report}. @@ -12971,7 +12967,7 @@ \begin{itemdescr} \pnum -\returns \tcode{is_other(this->status())} or \tcode{is_other(this->status(), ec)}, respectively. +\returns \tcode{is_other(this->status())} or \tcode{is_other(this->status(ec))}, respectively. \pnum \throws As specified in~\ref{fs.err.report}. @@ -12985,7 +12981,7 @@ \begin{itemdescr} \pnum -\returns \tcode{is_regular_file(this->status())} or \tcode{is_regular_file(this->status(), ec)}, respectively. +\returns \tcode{is_regular_file(this->status())} or \tcode{is_regular_file(this->status(ec))}, respective\-ly. \pnum \throws As specified in~\ref{fs.err.report}. @@ -12999,7 +12995,7 @@ \begin{itemdescr} \pnum -\returns \tcode{is_socket(this->status())} or \tcode{is_socket(this->status(), ec)}, respectively. +\returns \tcode{is_socket(this->status())} or \tcode{is_socket(this->status(ec))}, respectively. \pnum \throws As specified in~\ref{fs.err.report}. @@ -13013,7 +13009,7 @@ \begin{itemdescr} \pnum -\returns \tcode{is_symlink(this->symlink_status())} or \tcode{is_symlink(this->symlink_status(), ec)}, respectively. +\returns \tcode{is_symlink(this->symlink_status())} or \tcode{is_symlink(this->symlink_status(ec))}, respectively. \pnum \throws As specified in~\ref{fs.err.report}. @@ -13160,11 +13156,11 @@ \pnum An object of type \tcode{directory_iterator} provides an iterator for a sequence of \tcode{directory_entry} elements representing the -path and any cached attribute values~(\ref{fs.class.directory_entry}) +path and any cached attribute values\iref{fs.class.directory_entry} for each file in a directory or in an \impldef{type of a directory-like file} directory-like file type. -\begin{note} For iteration into sub-directories, see class \tcode{recursive_directory_iterator} -(\ref{fs.class.rec.dir.itr}). \end{note} +\begin{note} For iteration into sub-directories, see class \tcode{recursive_directory_iterator}\iref{fs.class.rec.dir.itr}. +\end{note} \begin{codeblock} namespace std::filesystem { @@ -13202,7 +13198,7 @@ \pnum \tcode{directory_iterator} satisfies the requirements of an input -iterator~(\ref{input.iterators}). +iterator\iref{input.iterators}. \pnum If an iterator of type \tcode{directory_iterator} reports an error or @@ -13233,7 +13229,7 @@ \pnum Constructors and non-const \tcode{directory_iterator} member functions -store the values of any cached attributes~(\ref{fs.class.directory_entry}) +store the values of any cached attributes\iref{fs.class.directory_entry} in the \tcode{directory_entry} element returned by \tcode{operator*()}. \tcode{directory_iterator} member functions shall not directly or indirectly call any \tcode{directory_entry} \tcode{refresh} function. @@ -13344,7 +13340,7 @@ \pnum \effects As specified for the prefix increment operation of -Input iterators~(\ref{input.iterators}). +Input iterators\iref{input.iterators}. \pnum \returns \tcode{*this}. @@ -13631,7 +13627,7 @@ \begin{itemdescr} \pnum \effects As specified for the prefix increment operation of -Input iterators~(\ref{input.iterators}), +Input iterators\iref{input.iterators}, except that: \begin{itemize} @@ -13724,7 +13720,7 @@ in external storage. \pnum -\begin{note} Because hardware failures, network failures, file system races~(\ref{fs.def.race}), +\begin{note} Because hardware failures, network failures, file system races\iref{fs.def.race}, and many other kinds of errors occur frequently in file system operations, users should be aware that any filesystem operation function, no matter how apparently innocuous, may encounter an error; see~\ref{fs.err.report}. \end{note} @@ -13740,7 +13736,7 @@ \begin{itemdescr} \pnum \effects Composes an absolute path referencing the same file system location -as \tcode{p} according to the operating system~(\ref{fs.conform.os}). +as \tcode{p} according to the operating system\iref{fs.conform.os}. \pnum \returns The composed path. @@ -13759,7 +13755,7 @@ \begin{note} To resolve symlinks, or perform other sanitization which might require queries to secondary storage, -such as hard disks, consider \tcode{canonical}~(\ref{fs.op.canonical}). +such as hard disks, consider \tcode{canonical}\iref{fs.op.canonical}. \end{note} \pnum @@ -13781,9 +13777,8 @@ \indexlibrary{\idxcode{canonical}}% \begin{itemdecl} -path canonical(const path& p, const path& base = current_path()); +path canonical(const path& p); path canonical(const path& p, error_code& ec); -path canonical(const path& p, const path& base, error_code& ec); \end{itemdecl} \begin{itemdescr} @@ -13794,9 +13789,8 @@ \pnum \returns A path that refers to -the same file system object as \tcode{absolute(p, base)}. For the overload -without a \tcode{base} argument, \tcode{base} is \tcode{current_path()}. -Signatures with argument \tcode{ec} return \tcode{path()} if an error occurs. +the same file system object as \tcode{absolute(p)}. +The signature with argument \tcode{ec} returns \tcode{path()} if an error occurs. \pnum \throws As specified in~\ref{fs.err.report}. @@ -13838,7 +13832,7 @@ \begin{itemdescr} \pnum -\requires At most one element from each option group (\ref{fs.enum.copy.opts}) +\requires At most one element from each option group\iref{fs.enum.copy.opts} is set in \tcode{options}. \pnum @@ -13863,16 +13857,16 @@ \begin{itemize} \item If \tcode{f.type()} or \tcode{t.type()} is an implementation-defined -file type~(\ref{fs.enum.file_type}), then the effects are +file type\iref{fs.enum.file_type}, then the effects are \impldef{effect of \tcode{filesystem::copy}}. \item Otherwise, an error is reported as specified in~\ref{fs.err.report} if: \begin{itemize} -\item \tcode{!exists(f)}, or -\item \tcode{equivalent(from, to)}, or -\item \tcode{is_other(f) || is_other(t)}, or -\item \tcode{is_directory(f) \&\& is_regular_file(t)}. +\item \tcode{exists(f)} is \tcode{false}, or +\item \tcode{equivalent(from, to)} is \tcode{true}, or +\item \tcode{is_other(f) || is_other(t)} is \tcode{true}, or +\item \tcode{is_directory(f) \&\& is_regular_file(t)} is \tcode{true}. \end{itemize} \item @@ -13910,7 +13904,7 @@ \end{codeblock} then: \begin{itemize} -\item If \tcode{!exists(t)}, then \tcode{create_directory(to, from)}. +\item If \tcode{exists(t)} is \tcode{false}, then \tcode{create_directory(to, from)}. \item Then, iterate over the files in \tcode{from}, as if by \begin{codeblock} for (const directory_entry& x : directory_iterator(from)) @@ -14000,7 +13994,7 @@ \begin{itemdescr} \pnum \requires At most one element from each - option group (\ref{fs.enum.copy.opts}) is set + option group\iref{fs.enum.copy.opts} is set in \tcode{options}. \pnum @@ -14010,10 +14004,10 @@ \item Report a file already exists error as specified in~\ref{fs.err.report} if: \begin{itemize} -\item \tcode{!is_regular_file(from)}, or -\item \tcode{exists(to)} and \tcode{!is_regular_file(to)}, or -\item \tcode{exists(to)} and \tcode{equivalent(from, to)}, or -\item \tcode{exists(to)} and +\item \tcode{is_regular_file(from)} is \tcode{false}, or +\item \tcode{exists(to)} is \tcode{true} and \tcode{is_regular_file(to)} is \tcode{false}, or +\item \tcode{exists(to)} is \tcode{true} and \tcode{equivalent(from, to)} is \tcode{true}, or +\item \tcode{exists(to)} is \tcode{true} and \begin{codeblock} (options & (copy_options::skip_existing | copy_options::overwrite_existing | @@ -14025,10 +14019,10 @@ Otherwise, copy the contents and attributes of the file \tcode{from} resolves to, to the file \tcode{to} resolves to, if: \begin{itemize} -\item \tcode{!exists(to)}, or +\item \tcode{exists(to)} is \tcode{false}, or \item \tcode{(options \& copy_options::overwrite_existing) != copy_options::none}, or \item \tcode{(options \& copy_options::update_existing) \: \: != copy_options::none} and \tcode{from} - is more recent than \tcode{to}, determined as if by use of the \tcode{last_write_time} function~(\ref{fs.op.last_write_time}). + is more recent than \tcode{to}, determined as if by use of the \tcode{last_write_time} function\iref{fs.op.last_write_time}. \end{itemize} \item @@ -14313,25 +14307,22 @@ \begin{itemdescr} \pnum -Let \tcode{s1} and \tcode{s2} be \tcode{file_status}s, determined -as if by \tcode{status(p1)} and \tcode{status(p2)}, respectively. - -\pnum -\effects Determines \tcode{s1} and \tcode{s2}. -If \tcode{(!exists(s1) \&\& !exists(s2)) || (is_other(s1) \&\& is_other(s2))} -an error is reported~(\ref{fs.err.report}). - -\pnum -\returns \tcode{true}, if \tcode{s1 == s2} and \tcode{p1} and \tcode{p2} resolve to the same file +\returns \tcode{true}, if \tcode{p1} and \tcode{p2} resolve to the same file system entity, else \tcode{false}. The signature with argument \tcode{ec} returns \tcode{false} if an error occurs. \pnum Two paths are considered to resolve to the same file system entity if two - candidate entities reside on the same device at the same location. This is + candidate entities reside on the same device at the same location. + \begin{note} + On POSIX platforms, this is determined as if by the values of the POSIX \tcode{stat} structure, obtained as if by \tcode{stat()} for the two paths, having equal \tcode{st_dev} values and equal \tcode{st_ino} values. + \end{note} + +\pnum +\remarks \tcode{!exists(p1) || !exists(p2)} is an error. \pnum \throws As specified in~\ref{fs.err.report}. @@ -14386,7 +14377,7 @@ \returns \begin{itemize} \item - If \tcode{!exists(p)} an error is reported~(\ref{fs.err.report}). + If \tcode{exists(p)} is \tcode{false}, an error is reported\iref{fs.err.report}. \item Otherwise, if \tcode{is_regular_file(p)}, the size in bytes of the file \tcode{p} resolves to, determined as if by the value of the POSIX \tcode{stat} @@ -14890,7 +14881,7 @@ resolves to. \end{note} \pnum -\postconditions \tcode{!exists(symlink_status(p))}. +\postconditions \tcode{exists(symlink_status(p))} is \tcode{false}. \pnum \returns \tcode{false} if \tcode{p} did not exist, @@ -14918,7 +14909,7 @@ resolves to. \end{note} \pnum -\postconditions \tcode{!exists(symlink_status(p))}. +\postconditions \tcode{exists(symlink_status(p))} is \tcode{false}. \pnum \returns The number of files removed. The signature with argument @@ -15105,7 +15096,7 @@ \item Otherwise, if the attributes indicate a socket, as if by POSIX \tcode{S_ISSOCK}, returns \tcode{file_status(file_type::socket, prms)}. \item Otherwise, if the attributes indicate an implementation-defined - file type~(\ref{fs.enum.file_type}), + file type\iref{fs.enum.file_type}, returns \tcode{file_status(file_type::\placeholdernc{A}, prms)}, where \tcode{\placeholdernc{A}} is the constant for the \impldef{file type of the file argument of \tcode{filesystem::status}} file type. @@ -15177,8 +15168,8 @@ \begin{itemdescr} \pnum -\returns An unspecifed directory path suitable for temporary files. An error shall be reported if -\tcode{!exists(p) || !is_directory(p)}, where \tcode{p} is the path to be returned. +\returns An unspecified directory path suitable for temporary files. An error shall be reported if +\tcode{exists(p)} is \tcode{false} or \tcode{is_directory(p)} is \tcode{false}, where \tcode{p} is the path to be returned. The signature with argument \tcode{ec} returns \tcode{path()} if an error occurs. @@ -15207,7 +15198,7 @@ \begin{itemdescr} \pnum \returns \tcode{p} with symlinks resolved and - the result normalized~(\ref{fs.def.normal.form}). + the result normalized\iref{fs.def.normal.form}. \pnum \effects Using \tcode{status(p)} or \tcode{status(p, ec)}, respectively, @@ -15226,11 +15217,11 @@ \tcode{path()} is returned at the first error occurrence, if any. \pnum -\postconditions The returned path is in normal form~(\ref{fs.def.normal.form}). +\postconditions The returned path is in normal form\iref{fs.def.normal.form}. \pnum -\remarks Implementations are encouraged - to avoid unnecessary normalization such as +\remarks Implementations should + avoid unnecessary normalization such as when \tcode{canonical} has already been called on the entirety of \tcode{p}. \pnum @@ -15390,10 +15381,10 @@ \pnum Calls to the function \tcode{tmpnam} with an argument that is a null pointer value may -introduce a data race~(\ref{res.on.data.races}) with other calls to \tcode{tmpnam} with +introduce a data race\iref{res.on.data.races} with other calls to \tcode{tmpnam} with an argument that is a null pointer value. -\xref ISO C~7.21. +\xref ISO C 7.21 \rSec2[cinttypes.syn]{Header \tcode{} synopsis} @@ -15551,7 +15542,7 @@ 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: +type\iref{basic.fundamental}, the following function signatures are added: \begin{codeblock} intmax_t abs(intmax_t); imaxdiv_t div(intmax_t, intmax_t); @@ -15561,4 +15552,4 @@ \tcode{imaxdiv_t imaxdiv(intmax_t, intmax_t)}, respectively. \end{itemize} -\xref ISO C~7.8. +\xref ISO C 7.8 diff --git a/source/iterators.tex b/source/iterators.tex index 545bb01b55..a3c4ed98fa 100644 --- a/source/iterators.tex +++ b/source/iterators.tex @@ -5,9 +5,9 @@ \pnum This Clause describes components that \Cpp programs may use to perform -iterations over containers (Clause \ref{containers}), -streams~(\ref{iostream.format}), -and stream buffers~(\ref{stream.buffers}). +iterations over containers\iref{containers}, +streams\iref{iostream.format}, +and stream buffers\iref{stream.buffers}. \pnum The following subclauses describe @@ -249,7 +249,7 @@ \tcode{o} denotes a value of some type that is writable to the output iterator. \begin{note} For an iterator type \tcode{X} there must be an instantiation -of \tcode{iterator_traits}~(\ref{iterator.traits}). \end{note} +of \tcode{iterator_traits}\iref{iterator.traits}. \end{note} \rSec2[iterator.iterators]{Iterator} @@ -258,7 +258,7 @@ taxonomy; every iterator satisfies the \tcode{Iterator} requirements. This set of requirements specifies operations for dereferencing and incrementing an iterator. Most algorithms will require additional operations to -read~(\ref{input.iterators}) or write~(\ref{output.iterators}) values, or +read\iref{input.iterators} or write\iref{output.iterators} values, or to provide a richer set of iterator movements~(\ref{forward.iterators}, \ref{bidirectional.iterators}, \ref{random.access.iterators}). @@ -267,8 +267,8 @@ \begin{itemize} \item \tcode{X} satisfies the \tcode{CopyConstructible}, \tcode{CopyAssignable}, and -\tcode{Destructible} requirements~(\ref{utility.arg.requirements}) and lvalues -of type \tcode{X} are swappable (\ref{swappable.requirements}), and +\tcode{Destructible} requirements\iref{utility.arg.requirements} and lvalues +of type \tcode{X} are swappable\iref{swappable.requirements}, and \item the expressions in Table~\ref{tab:iterator.requirements} are valid and have the indicated semantics. @@ -307,7 +307,7 @@ satisfies the requirements of an input iterator for the value type \tcode{T} if -\tcode{X} satisfies the \tcode{Iterator}~(\ref{iterator.iterators}) and +\tcode{X} satisfies the \tcode{Iterator}\iref{iterator.iterators} and \tcode{EqualityComparable} (Table~\ref{tab:equalitycomparable}) requirements and the expressions in Table~\ref{tab:iterator.input.requirements} are valid and have the indicated semantics. @@ -412,7 +412,7 @@ A class or pointer type \tcode{X} satisfies the requirements of an output iterator -if \tcode{X} satisfies the \tcode{Iterator} requirements~(\ref{iterator.iterators}) +if \tcode{X} satisfies the \tcode{Iterator} requirements\iref{iterator.iterators} and the expressions in Table~\ref{tab:iterator.output.requirements} are valid and have the indicated semantics. @@ -480,10 +480,10 @@ satisfies the requirements of a forward iterator if \begin{itemize} -\item \tcode{X} satisfies the requirements of an input iterator~(\ref{input.iterators}), +\item \tcode{X} satisfies the requirements of an input iterator\iref{input.iterators}, \item \tcode{X} satisfies the \tcode{DefaultConstructible} -requirements~(\ref{utility.arg.requirements}), +requirements\iref{utility.arg.requirements}, \item if \tcode{X} is a mutable iterator, \tcode{reference} is a reference to \tcode{T}; if \tcode{X} is a constant iterator, \tcode{reference} is a reference to \tcode{const T}, @@ -745,7 +745,7 @@ template constexpr auto operator-( const reverse_iterator& x, - const reverse_iterator& y) ->decltype(y.base() - x.base()); + const reverse_iterator& y) -> decltype(y.base() - x.base()); template constexpr reverse_iterator operator+( @@ -904,7 +904,7 @@ may be defined as \tcode{void}. \pnum -If \tcode{Iterator} has valid~(\ref{temp.deduct}) member +If \tcode{Iterator} has valid\iref{temp.deduct} member types \tcode{difference_type}, \tcode{value_type}, \tcode{pointer}, \tcode{reference}, and \tcode{iterator_category}, \tcode{iterator_traits} @@ -1254,27 +1254,27 @@ \pnum The template parameter \tcode{Iterator} -shall meet all the requirements of a Bidirectional Iterator~(\ref{bidirectional.iterators}). +shall meet all the requirements of a Bidirectional Iterator\iref{bidirectional.iterators}. \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\iref{random.access.iterators} if any of the members \tcode{operator+}~(\ref{reverse.iter.op+}), \tcode{operator-}~(\ref{reverse.iter.op-}), \tcode{operator+=}~(\ref{reverse.iter.op+=}), \tcode{operator-=}~(\ref{reverse.iter.op-=}), -\tcode{operator[]}~(\ref{reverse.iter.opindex}), +\tcode{operator[]}\iref{reverse.iter.opindex}, or the non-member operators \tcode{operator<}~(\ref{reverse.iter.op<}), \tcode{operator>}~(\ref{reverse.iter.op>}),\\ \tcode{operator<=}~(\ref{reverse.iter.op<=}), \tcode{operator>=}~(\ref{reverse.iter.op>=}), -\tcode{operator-}~(\ref{reverse.iter.opdiff}) +\tcode{operator-}\iref{reverse.iter.opdiff} or -\tcode{operator+}~(\ref{reverse.iter.opsum}) -are referenced in a way that requires instantiation~(\ref{temp.inst}). +\tcode{operator+}\iref{reverse.iter.opsum} +are referenced in a way that requires instantiation\iref{temp.inst}. \rSec3[reverse.iter.ops]{\tcode{reverse_iterator} operations} @@ -2197,11 +2197,11 @@ \pnum The template parameter \tcode{Iterator} shall meet -the requirements of an input iterator~(\ref{input.iterators}). +the requirements of an input iterator\iref{input.iterators}. Additionally, if any of the bidirectional or random access traversal functions are instantiated, the template parameter shall meet the -requirements for a Bidirectional Iterator~(\ref{bidirectional.iterators}) -or a Random Access Iterator~(\ref{random.access.iterators}), respectively. +requirements for a Bidirectional Iterator\iref{bidirectional.iterators} +or a Random Access Iterator\iref{random.access.iterators}, respectively. \rSec3[move.iter.ops]{\tcode{move_iterator} operations} @@ -2562,7 +2562,7 @@ \indexlibrary{\idxcode{istream_iterator}}% The class template \tcode{istream_iterator} -is an input iterator~(\ref{input.iterators}) that +is an input iterator\iref{input.iterators} that reads (using \tcode{operator>>}) successive elements from the input stream for which it was constructed. @@ -2953,7 +2953,7 @@ The class template \tcode{istreambuf_iterator} -defines an input iterator~(\ref{input.iterators}) that +defines an input iterator\iref{input.iterators} that reads successive \textit{characters} from the streambuf for which it was constructed. diff --git a/source/lex.tex b/source/lex.tex index faeeb96f47..de222b019f 100644 --- a/source/lex.tex +++ b/source/lex.tex @@ -30,10 +30,10 @@ \indextext{compilation!separate|(}% The text of the program is kept in units called \defnx{source files}{source file} in this International -Standard. A source file together with all the headers~(\ref{headers}) -and source files included~(\ref{cpp.include}) via the preprocessing +Standard. A source file together with all the headers\iref{headers} +and source files included\iref{cpp.include} via the preprocessing directive \tcode{\#include}, less any source lines skipped by any of the -conditional inclusion~(\ref{cpp.cond}) preprocessing directives, is +conditional inclusion\iref{cpp.cond} preprocessing directives, is called a \defn{translation unit}. \begin{note} A \Cpp program need not all be translated at the same time. \end{note} @@ -41,12 +41,12 @@ \pnum \begin{note} Previously translated translation units and instantiation units can be preserved individually or in libraries. The separate -translation units of a program communicate~(\ref{basic.link}) by (for +translation units of a program communicate\iref{basic.link} by (for example) calls to functions whose identifiers have external linkage, manipulation of objects whose identifiers have external linkage, or manipulation of data files. Translation units can be separately translated and then later linked to produce an executable -program~(\ref{basic.link}). \end{note}% +program\iref{basic.link}. \end{note}% \indextext{compilation!separate|)} \rSec1[lex.phases]{Phases of translation}% @@ -68,14 +68,14 @@ characters}. Any source file character not in the basic source character -set~(\ref{lex.charset}) is replaced by the +set\iref{lex.charset} is replaced by the \indextext{universal character name}\grammarterm{universal-character-name} that designates that character. An implementation may use any internal encoding, so long as an actual extended character encountered in the source file, and the same extended character expressed in the source file as a \grammarterm{universal-character-name} (e.g., using the \tcode{\textbackslash uXXXX} notation), are handled equivalently -except where this replacement is reverted~(\ref{lex.pptoken}) in a raw string literal. +except where this replacement is reverted\iref{lex.pptoken} in a raw string literal. \indextext{line splicing}% \item Each instance of a backslash character (\textbackslash) @@ -93,7 +93,7 @@ to the file. \item The source file is decomposed into preprocessing -tokens~(\ref{lex.pptoken}) and sequences of white-space characters +tokens\iref{lex.pptoken} and sequences of white-space characters (including comments). A source file shall not end in a partial preprocessing token or in a partial comment.\footnote{A partial preprocessing token would arise from a source file @@ -109,7 +109,7 @@ unspecified. The process of dividing a source file's characters into preprocessing tokens is context-dependent. \begin{example} -see the handling of \tcode{<} within a \tcode{\#include} preprocessing +See the handling of \tcode{<} within a \tcode{\#include} preprocessing directive. \end{example} @@ -117,7 +117,7 @@ expanded, and \tcode{_Pragma} unary operator expressions are executed. If a character sequence that matches the syntax of a \grammarterm{universal-character-name} is produced by token -concatenation~(\ref{cpp.concat}), the behavior is undefined. A +concatenation\iref{cpp.concat}, the behavior is undefined. A \tcode{\#include} preprocessing directive causes the named header or source file to be processed from phase 1 through phase 4, recursively. All preprocessing directives are then deleted. @@ -135,11 +135,11 @@ \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\iref{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 -tokens~(\ref{temp.names}).\end{note} \begin{note} Source files, translation +tokens\iref{temp.names}.\end{note} \begin{note} Source files, translation units and translated translation units need not necessarily be stored as files, nor need there be any one-to-one correspondence between these entities and any external representation. The description is conceptual @@ -150,7 +150,7 @@ library. \end{note} Each translated translation unit is examined to produce a list of required instantiations. \begin{note} This may include instantiations which have been explicitly -requested~(\ref{temp.explicit}). \end{note} The definitions of the +requested\iref{temp.explicit}. \end{note} The definitions of the required templates are located. It is \impldef{whether source of translation units must be available to locate template definitions} whether the source of the translation units containing these definitions is required @@ -221,7 +221,7 @@ string literal corresponds to a control character (in either of the ranges 0x00--0x1F or 0x7F--0x9F, both inclusive) or to a character in the basic source character set, the program is ill-formed.\footnote{A sequence of characters resembling a \grammarterm{universal-character-name} in an -\grammarterm{r-char-sequence}~(\ref{lex.string}) does not form a +\grammarterm{r-char-sequence}\iref{lex.string} does not form a \grammarterm{universal-character-name}.} \pnum @@ -262,7 +262,7 @@ \end{bnf} \pnum -Each preprocessing token that is converted to a token~(\ref{lex.token}) +Each preprocessing token that is converted to a token\iref{lex.token} shall have the lexical form of a keyword, an identifier, a literal, an operator, or a punctuator. @@ -278,9 +278,9 @@ \indextext{space!white}% white space; \indextext{comment}% -this consists of comments~(\ref{lex.comment}), or white-space +this consists of comments\iref{lex.comment}, or white-space characters (space, horizontal tab, new-line, vertical tab, and -form-feed), or both. As described in Clause~\ref{cpp}, in certain +form-feed), or both. As described in \ref{cpp}, in certain circumstances during translation phase 4, white space (or the absence thereof) serves as more than preprocessing token separation. White space can appear within a preprocessing token only as part of a header name or @@ -313,8 +313,8 @@ the next preprocessing token is the longest sequence of characters that could constitute a preprocessing token, even if that would cause further lexical analysis to fail, -except that a \grammarterm{header-name}~(\ref{lex.header}) is only formed -within a \tcode{\#include} directive~(\ref{cpp.include}). +except that a \grammarterm{header-name}\iref{lex.header} is only formed +within a \tcode{\#include} directive\iref{cpp.include}. \end{itemize} \begin{example} @@ -356,7 +356,7 @@ \pnum In all respects of the language, each alternative token behaves the -same, respectively, as its primary token, except for its spelling.\footnote{Thus the ``stringized'' values~(\ref{cpp.stringize}) of +same, respectively, as its primary token, except for its spelling.\footnote{Thus the ``stringized'' values\iref{cpp.stringize} of \tcode{[} and \tcode{<:} will be different, maintaining the source spelling, but the tokens can otherwise be freely interchanged. } The set of alternative tokens is defined in @@ -501,8 +501,8 @@ \pnum Preprocessing number tokens lexically include all integer literal -tokens~(\ref{lex.icon}) and all floating literal -tokens~(\ref{lex.fcon}). +tokens\iref{lex.icon} and all floating literal +tokens\iref{lex.fcon}. \pnum A preprocessing number does not have a type or a value; it acquires both @@ -666,99 +666,101 @@ \indextext{keyword|(}% The identifiers shown in Table~\ref{tab:keywords} are reserved for use as keywords (that is, they are unconditionally treated as keywords in -phase 7) except in an \grammarterm{attribute-token}~(\ref{dcl.attr.grammar}): +phase 7) except in an \grammarterm{attribute-token}\iref{dcl.attr.grammar}: \begin{floattable}{Keywords}{tab:keywords} {lllll} \topline \tcode{alignas} & +\tcode{const_cast} & +\tcode{for} & +\tcode{public} & +\tcode{thread_local} \\ + +\tcode{alignof} & \tcode{continue} & \tcode{friend} & \tcode{register} & -\tcode{true} \\ +\tcode{throw} \\ -\tcode{alignof} & +\tcode{asm} & \tcode{decltype} & \tcode{goto} & \tcode{reinterpret_cast} & -\tcode{try} \\ +\tcode{true} \\ -\tcode{asm} & +\tcode{auto} & \tcode{default} & \tcode{if} & -\tcode{return} & -\tcode{typedef} \\ +\tcode{requires} & +\tcode{try} \\ -\tcode{auto} & +\tcode{bool} & \tcode{delete} & \tcode{inline} & -\tcode{short} & -\tcode{typeid} \\ +\tcode{return} & +\tcode{typedef} \\ -\tcode{bool} & +\tcode{break} & \tcode{do} & \tcode{int} & -\tcode{signed} & -\tcode{typename} \\ +\tcode{short} & +\tcode{typeid} \\ -\tcode{break} & +\tcode{case} & \tcode{double} & \tcode{long} & -\tcode{sizeof} & -\tcode{union} \\ +\tcode{signed} & +\tcode{typename} \\ -\tcode{case} & +\tcode{catch} & \tcode{dynamic_cast} & \tcode{mutable} & -\tcode{static} & -\tcode{unsigned} \\ +\tcode{sizeof} & +\tcode{union} \\ -\tcode{catch} & +\tcode{char} & \tcode{else} & \tcode{namespace} & -\tcode{static_assert} & -\tcode{using} \\ +\tcode{static} & +\tcode{unsigned} \\ -\tcode{char} & +\tcode{char16_t} & \tcode{enum} & \tcode{new} & -\tcode{static_cast} & -\tcode{virtual} \\ +\tcode{static_assert} & +\tcode{using} \\ -\tcode{char16_t} & +\tcode{char32_t} & \tcode{explicit} & \tcode{noexcept} & -\tcode{struct} & -\tcode{void} \\ +\tcode{static_cast} & +\tcode{virtual} \\ -\tcode{char32_t} & +\tcode{class} & \tcode{export} & \tcode{nullptr} & -\tcode{switch} & -\tcode{volatile} \\ +\tcode{struct} & +\tcode{void} \\ -\tcode{class} & +\tcode{concept} & \tcode{extern} & \tcode{operator} & -\tcode{template} & -\tcode{wchar_t} \\ +\tcode{switch} & +\tcode{volatile} \\ \tcode{const} & \tcode{false} & \tcode{private} & -\tcode{this} & -\tcode{while} \\ +\tcode{template} & +\tcode{wchar_t} \\ \tcode{constexpr} & \tcode{float} & \tcode{protected} & -\tcode{thread_local} & \\ - -\tcode{const_cast} & -\tcode{for} & -\tcode{public} & -\tcode{throw} & \\ +\tcode{this} & +\tcode{while} \\ \end{floattable} @@ -768,7 +770,7 @@ \pnum Furthermore, the alternative representations shown in Table~\ref{tab:alternative.representations} for certain operators and -punctuators~(\ref{lex.digraph}) are reserved and shall not be used +punctuators\iref{lex.digraph} are reserved and shall not be used otherwise: @@ -804,7 +806,7 @@ \end{bnfkeywordtab} Each \grammarterm{preprocessing-op-or-punc} is converted to a single token -in translation phase 7~(\ref{lex.phases}).% +in translation phase 7\iref{lex.phases}.% \indextext{punctuator|)}% \indextext{operator|)} @@ -1035,7 +1037,7 @@ \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 +an extended integer type\iref{basic.fundamental} can represent its value, it may have that 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 integer literal are unsigned, the extended integer @@ -1518,18 +1520,11 @@ is equivalent to \tcode{"\textbackslash n)\textbackslash \textbackslash \textbackslash na\textbackslash"\textbackslash n"}. The raw string \begin{codeblock} -R"(??)" +R"(x = "\"y\"")" \end{codeblock} -is equivalent to \tcode{"\textbackslash?\textbackslash?"}. The raw string - -\begin{codeblock} -R"#( -)??=" -)#" -\end{codeblock} - -is equivalent to \tcode{"\textbackslash n)\textbackslash?\textbackslash?=\textbackslash"\textbackslash n"}. \end{example} +is equivalent to \tcode{"x = \textbackslash "\textbackslash\textbackslash\textbackslash "y\textbackslash\textbackslash\textbackslash "\textbackslash ""}. +\end{example} \pnum \indextext{string!type of}% @@ -1550,11 +1545,11 @@ \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}). +duration\iref{basic.stc}. \pnum For a UTF-8 string literal, each successive element of the object -representation~(\ref{basic.types}) has the value of the corresponding +representation\iref{basic.types} has the value of the corresponding code unit of the UTF-8 encoding of the string. \pnum @@ -1596,7 +1591,7 @@ \pnum \indextext{concatenation!string}% -In translation phase 6~(\ref{lex.phases}), adjacent \grammarterm{string-literal}{s} are concatenated. If +In translation phase 6\iref{lex.phases}, adjacent \grammarterm{string-literal}{s} are concatenated. If both \grammarterm{string-literal}{s} have the same \grammarterm{encoding-prefix}, the resulting concatenated string literal has that \grammarterm{encoding-prefix}. If one \grammarterm{string-literal} has no \grammarterm{encoding-prefix}, it is treated as a \grammarterm{string-literal} of the same \grammarterm{encoding-prefix} as the other operand. If a UTF-8 string literal token is adjacent to a @@ -1648,12 +1643,12 @@ \indextext{\idxcode{0}!string terminator}% \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 +7\iref{lex.phases}, \tcode{'\textbackslash 0'} is appended to every string literal so that programs that scan a string can find its end. \pnum Escape sequences and \grammarterm{universal-character-name}{s} in non-raw string literals -have the same meaning as in character literals~(\ref{lex.ccon}), except that +have the same meaning as in character literals\iref{lex.ccon}, except that the single quote \tcode{'} is representable either by itself or by the escape sequence \tcode{\textbackslash'}, and the double quote \tcode{"} shall be preceded by a \tcode{\textbackslash}, @@ -1776,11 +1771,11 @@ \pnum A \grammarterm{user-defined-literal} is treated as a call to a literal operator or -literal operator template~(\ref{over.literal}). To determine the form of this call for a +literal operator template\iref{over.literal}. To determine the form of this call for a given \grammarterm{user-defined-literal} \placeholder{L} with \grammarterm{ud-suffix} \placeholder{X}, the \grammarterm{literal-operator-id} whose literal suffix identifier is \placeholder{X} is looked up in the context of \placeholder{L} using the rules for unqualified name -lookup~(\ref{basic.lookup.unqual}). Let \placeholder{S} be the set of declarations found by +lookup\iref{basic.lookup.unqual}. Let \placeholder{S} be the set of declarations found by this lookup. \placeholder{S} shall not be empty. \pnum @@ -1794,7 +1789,7 @@ \end{codeblock} Otherwise, \placeholder{S} shall contain a raw literal operator or a literal operator -template~(\ref{over.literal}) but not both. If \placeholder{S} contains a raw literal operator, +template\iref{over.literal} but not both. If \placeholder{S} contains a raw literal operator, the literal \placeholder{L} is treated as a call of the form \begin{codeblock} @@ -1824,7 +1819,7 @@ \end{codeblock} Otherwise, \placeholder{S} shall contain a raw literal operator or a literal operator -template~(\ref{over.literal}) but not both. If \placeholder{S} contains a raw literal operator, +template\iref{over.literal} but not both. If \placeholder{S} contains a raw literal operator, the \grammarterm{literal} \placeholder{L} is treated as a call of the form \begin{codeblock} @@ -1857,7 +1852,7 @@ \pnum If \placeholder{L} is a \grammarterm{user-defined-character-literal}, let \placeholder{ch} be the literal without its \grammarterm{ud-suffix}. -\placeholder{S} shall contain a literal operator~(\ref{over.literal}) whose only parameter has +\placeholder{S} shall contain a literal operator\iref{over.literal} whose only parameter has the type of \placeholder{ch} and the literal \placeholder{L} is treated as a call of the form @@ -1884,7 +1879,7 @@ \end{example} \pnum -In translation phase 6~(\ref{lex.phases}), adjacent string literals are concatenated and +In translation phase 6\iref{lex.phases}, adjacent string literals are concatenated and \grammarterm{user-defined-string-literal}{s} are considered string literals for that purpose. During concatenation, \grammarterm{ud-suffix}{es} are removed and ignored and the concatenation process occurs as described in~\ref{lex.string}. At the end of phase diff --git a/source/lib-intro.tex b/source/lib-intro.tex index c9bfbbd03b..2b6082e46c 100644 --- a/source/lib-intro.tex +++ b/source/lib-intro.tex @@ -11,16 +11,16 @@ how a conforming implementation may provide the entities in the library. \pnum -The following subclauses describe the definitions~(\ref{definitions}), method of -description~(\ref{description}), and organization~(\ref{organization}) of the -library. Clause~\ref{requirements}, Clauses~\ref{\firstlibchapter} -through~\ref{\lastlibchapter}, and Annex~\ref{depr} specify the contents of the +The following subclauses describe the definitions\iref{definitions}, method of +description\iref{description}, and organization\iref{organization} of the +library. \ref{requirements}, \ref{\firstlibchapter} +through \ref{\lastlibchapter}, and \ref{depr} specify the contents of the library, as well as library requirements and constraints on both well-formed \Cpp programs and conforming implementations. \pnum Detailed specifications for each of the components in the library are in -Clauses~\ref{\firstlibchapter}--\ref{\lastlibchapter}, as shown in +\ref{\firstlibchapter}--\ref{\lastlibchapter}, as shown in Table~\ref{tab:library.categories}. \begin{libsumtabbase}{Library categories}{tab:library.categories}{Clause}{Category} @@ -40,24 +40,24 @@ \end{libsumtabbase} \pnum -The language support library (Clause~\ref{language.support}) provides components that are +The language support library\iref{language.support} provides components that are required by certain parts of the \Cpp language, such as memory allocation~(\ref{expr.new}, -\ref{expr.delete}) and exception processing (Clause~\ref{except}). +\ref{expr.delete}) and exception processing\iref{except}. \pnum -The diagnostics library (Clause~\ref{diagnostics}) provides a consistent framework for +The diagnostics library\iref{diagnostics} provides a consistent framework for reporting errors in a \Cpp program, including predefined exception classes. \pnum -The general utilities library (Clause~\ref{utilities}) includes components used +The general utilities library\iref{utilities} includes components used by other library elements, such as a predefined storage allocator for dynamic -storage management~(\ref{basic.stc.dynamic}), and components used +storage management\iref{basic.stc.dynamic}, and components used as infrastructure in \Cpp programs, such as tuples, function wrappers, and time facilities. \pnum -The strings library (Clause~\ref{strings}) provides support for manipulating text represented +The strings library\iref{strings} provides support for manipulating text represented as sequences of type \tcode{char}, sequences of type @@ -69,16 +69,16 @@ and sequences of any other character-like type. \pnum -The localization library (Clause~\ref{localization}) provides extended internationalization +The localization library\iref{localization} provides extended internationalization support for text processing. \pnum -The containers (Clause~\ref{containers}), iterators (Clause~\ref{iterators}), -and algorithms (Clause~\ref{algorithms}) libraries provide a \Cpp program with access +The containers\iref{containers}, iterators\iref{iterators}, +and algorithms\iref{algorithms} libraries provide a \Cpp program with access to a subset of the most widely used algorithms and data structures. \pnum -The numerics library (Clause~\ref{numerics}) provides +The numerics library\iref{numerics} provides numeric algorithms and complex number components that extend support for numeric processing. The \tcode{valarray} @@ -89,21 +89,21 @@ The random number component provides facilities for generating pseudo-random numbers. \pnum -The input/output library (Clause~\ref{input.output}) provides the +The input/output library\iref{input.output} provides the \tcode{iostream} components that are the primary mechanism for \Cpp program input and output. They can be used with other elements of the library, particularly strings, locales, and iterators. \pnum -The regular expressions library (Clause~\ref{re}) provides regular expression matching and searching. +The regular expressions library\iref{re} provides regular expression matching and searching. \pnum -The atomic operations library (Clause~\ref{atomics}) allows more fine-grained +The atomic operations library\iref{atomics} allows more fine-grained concurrent access to shared data than is possible with locks. \pnum -The thread support library (Clause~\ref{thread}) provides components to create +The thread support library\iref{thread} provides components to create and manage threads, including mutual exclusion and interthread communication. \rSec1[library.c]{The C standard library} @@ -129,20 +129,18 @@ \pnum \begin{note} -Clause \ref{intro.defs} defines additional terms used elsewhere in this International Standard. +\ref{intro.defs} defines additional terms used elsewhere in this International Standard. \end{note} -\def\definition{\definitionx{\subsection}}% - \definition{arbitrary-positional stream}{defns.arbitrary.stream} \indexdefn{stream!arbitrary-positional}% -a stream (described in Clause~\ref{input.output}) that can seek to any integral position within +a stream (described in \ref{input.output}) that can seek to any integral position within the length of the stream\\ \begin{note} Every arbitrary-positional stream is also a repositional stream. \end{note} \definition{character}{defns.character} \indexdefn{character}% -\defncontext{Clauses~\ref{strings}, \ref{localization}, \ref{input.output}, and~\ref{re}} +\defncontext{\ref{strings}, \ref{localization}, \ref{input.output}, and~\ref{re}} any object which, when treated sequentially, can represent text\\ @@ -166,13 +164,13 @@ \begin{note} It is used for one of the template parameters of the string, iostream, and regular expression class templates. -A character container type is a POD~(\ref{basic.types}) type. +A character container type is a POD\iref{basic.types} type. \end{note} \definition{comparison function}{defns.comparison} \indexdefn{function!comparison}% -an operator function~(\ref{over.oper}) for any of the equality~(\ref{expr.eq}) or -relational~(\ref{expr.rel}) operators +an operator function\iref{over.oper} for any of the equality\iref{expr.eq} or +relational\iref{expr.rel} operators \definition{component}{defns.component} \indexdefn{component}% @@ -192,8 +190,8 @@ \indexdefn{constant subexpression}% an expression whose evaluation as subexpression of a \grammarterm{conditional-expression} -\tcode{CE}~(\ref{expr.cond}) would not prevent \tcode{CE} -from being a core constant expression~(\ref{expr.const}) +\tcode{CE}\iref{expr.cond} would not prevent \tcode{CE} +from being a core constant expression\iref{expr.const} \definition{deadlock}{defns.deadlock} \indexdefn{deadlock}% @@ -218,8 +216,8 @@ \definition{direct-non-list-initialization}{defns.direct-non-list-init} \indexdefn{direct-non-list-initialization}% -a direct-initialization~(\ref{dcl.init}) -that is not list-initialization~(\ref{dcl.init.list}) +a direct-initialization\iref{dcl.init} +that is not list-initialization\iref{dcl.init.list} \definition{handler function}{defns.handler} \indexdefn{function!handler}% @@ -229,11 +227,11 @@ \begin{note} A \Cpp program may designate a handler function at various points in its execution by supplying a pointer to the function when calling any of the library functions that install -handler functions (Clause~\ref{language.support}). +handler functions\iref{language.support}. \end{note} \definition{iostream class templates}{defns.iostream.templates} -templates, defined in Clause~\ref{input.output}, +templates, defined in \ref{input.output}, that take two template arguments\\ \begin{note} The arguments are named @@ -253,7 +251,7 @@ \definition{modifier function}{defns.modifier} \indexdefn{function!modifier}% -a class member function~(\ref{class.mfct}) other than a constructor, +a class member function\iref{class.mfct} other than a constructor, assignment operator, or destructor that alters the state of an object of the class @@ -276,12 +274,12 @@ \definition{observer function}{defns.observer} \indexdefn{function!observer}% -a class member function~(\ref{class.mfct}) that accesses the state of an object of the class +a class member function\iref{class.mfct} that accesses the state of an object of the class but does not alter that state\\ \begin{note} Observer functions are specified as \tcode{const} -member functions~(\ref{class.this}). +member functions\iref{class.this}. \end{note} \definition{referenceable type}{defns.referenceable} @@ -298,13 +296,13 @@ whose definition is provided by a \Cpp program\\ \begin{note} Only one definition for such a function is in effect for the duration of the program's -execution, as the result of creating the program~(\ref{lex.phases}) and resolving the -definitions of all translation units~(\ref{basic.link}). +execution, as the result of creating the program\iref{lex.phases} and resolving the +definitions of all translation units\iref{basic.link}. \end{note} \definition{repositional stream}{defns.repositional.stream} \indexdefn{stream!repositional}% -a stream (described in Clause~\ref{input.output}) that can seek to a position that was +a stream (described in \ref{input.output}) that can seek to a position that was previously encountered \definition{required behavior}{defns.required.behavior} @@ -357,8 +355,8 @@ \pnum This subclause describes the conventions used to specify the \Cpp standard library. \ref{structure} describes the structure of the normative -Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter} and -Annex~\ref{depr}. \ref{conventions} describes other editorial conventions. +\ref{\firstlibchapter} through \ref{\lastlibchapter} and +\ref{depr}. \ref{conventions} describes other editorial conventions. \rSec2[structure]{Structure of each clause} @@ -428,7 +426,7 @@ Requirements are stated in terms of well-defined expressions that define valid terms of the types that satisfy the requirements. For every set of well-defined expression requirements there is a table that specifies an initial set of the valid expressions and -their semantics. Any generic algorithm (Clause~\ref{algorithms}) that uses the +their semantics. Any generic algorithm\iref{algorithms} that uses the well-defined expression requirements is described in terms of the valid expressions for its template type parameters. @@ -482,7 +480,7 @@ \begin{itemize} \item \requires the preconditions for calling the function \item \effects the actions performed by the function -\item \sync the synchronization operations~(\ref{intro.multithread}) applicable to the function +\item \sync the synchronization operations\iref{intro.multithread} applicable to the function \item \postconditions the observable results established by the function \item \returns a description of the value(s) returned by the function \item \throws any exceptions thrown by the function, and the conditions that would cause the exception @@ -508,16 +506,12 @@ \pnum For non-reserved replacement and handler functions, -Clause~\ref{language.support} specifies two behaviors for the functions in question: +\ref{language.support} specifies two behaviors for the functions in question: their required and default behavior. -The -\term{default behavior} +The \defnx{default behavior}{behavior!default} describes a function definition provided by the implementation. -\indextext{behavior!default}% -The -\term{required behavior} +The \defnx{required behavior}{behavior!required} describes the semantics of a function definition provided by -\indextext{behavior!required}% either the implementation or a \Cpp program. Where no distinction is explicitly made in the description, the behavior described is the required behavior. @@ -535,7 +529,7 @@ \pnum Error conditions specify conditions where a function may fail. The conditions are listed, together with a suitable explanation, as the \tcode{enum class errc} -constants~(\ref{syserr}). +constants\iref{syserr}. \rSec3[structure.see.also]{C library} @@ -550,8 +544,8 @@ This subclause describes several editorial conventions used to describe the contents of the \Cpp standard library. These conventions are for describing -implementation-defined types~(\ref{type.descriptions}), -and member functions~(\ref{functions.within.classes}). +implementation-defined types\iref{type.descriptions}, +and member functions\iref{functions.within.classes}. \rSec3[type.descriptions]{Type descriptions} @@ -573,15 +567,15 @@ the library. \pnum -Certain types defined in Clause~\ref{input.output} are used to describe implementation-defined types. +Certain types defined in \ref{input.output} are used to describe implementation-defined types. \indextext{types!implementation-defined}% They are based on other types, but with added constraints. \rSec4[expos.only.types]{Exposition-only types} \pnum -Several types defined in Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter} -and Annex~\ref{depr} that are used as function parameter or return types are defined +Several types defined in \ref{\firstlibchapter} through \ref{\lastlibchapter} +and \ref{depr} that are used as function parameter or return types are defined for the purpose of exposition only in order to capture their language linkage. The declarations of such types are followed by a comment ending in \textit{exposition only}. \begin{example} @@ -597,12 +591,11 @@ \rSec4[enumerated.types]{Enumerated types} \pnum -Several types defined in Clause~\ref{input.output} are -\term{enumerated types}. -\indextext{type!enumerated}% +Several types defined in \ref{input.output} are +\defnx{enumerated types}{type!enumerated}. Each enumerated type may be implemented as an enumeration or as a synonym for an enumeration.\footnote{Such as an integer type, with constant integer -values~(\ref{basic.fundamental}).} +values\iref{basic.fundamental}.} \pnum The enumerated type \tcode{\placeholder{enumerated}} can be written: @@ -628,14 +621,13 @@ \rSec4[bitmask.types]{Bitmask types} \pnum -Several types defined in Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter} -and Annex~\ref{depr} are -\term{bitmask types}. -\indextext{type!bitmask}% +Several types defined in \ref{\firstlibchapter} through \ref{\lastlibchapter} +and \ref{depr} are +\defnx{bitmask types}{type!bitmask}. Each bitmask type can be implemented as an enumerated type that overloads certain operators, as an integer type, or as a -\tcode{bitset}~(\ref{template.bitset}). +\tcode{bitset}\iref{template.bitset}. \indextext{type!enumerated}% \pnum @@ -731,16 +723,15 @@ uppercase letters in the basic execution character set. \item The -\term{decimal-point character} +\defnx{decimal-point character}{character!decimal-point} is the -\indextext{character!decimal-point}% (single-byte) character used by functions that convert between a (single-byte) character sequence and a value of one of the floating-point types. It is used in the character sequence to denote the beginning of a fractional part. It is -represented in Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter} -and Annex~\ref{depr} by a period, +represented in \ref{\firstlibchapter} through \ref{\lastlibchapter} +and \ref{depr} by a period, \indextext{period}% \tcode{'.'}, which is @@ -748,25 +739,25 @@ locale, but may change during program execution by a call to \tcode{setlocale(int, const char*)},\footnote{declared in -\tcode{}~(\ref{c.locales}). +\tcode{}\iref{c.locales}. \indextext{\idxcode{setlocale}}% \indexlibrary{\idxcode{setlocale}}% \indextext{\idxhdr{clocale}}% \indexlibrary{\idxhdr{clocale}}} or by a change to a \tcode{locale} -object, as described in Clauses~\ref{locales} and~\ref{input.output}. +object, as described in \ref{locales} and \ref{input.output}. \item A \term{character sequence} -is an array object~(\ref{dcl.array}) \tcode{\placeholdernc{A}} that +is an array object\iref{dcl.array} \tcode{\placeholdernc{A}} that can be declared as \tcode{\placeholdernc{T\;A}[\placeholder{N}]}, where \tcode{\placeholder{T}} is any of the types \tcode{char}, \tcode{unsigned char}, or -\tcode{signed char}~(\ref{basic.fundamental}), optionally qualified by any combination of +\tcode{signed char}\iref{basic.fundamental}, optionally qualified by any combination of \tcode{const} or \tcode{volatile}. @@ -781,9 +772,8 @@ \pnum A -\indextext{string!null-terminated byte}% \indextext{NTBS}% -\term{null-terminated byte string}, +\defnx{null-terminated byte string}{string!null-terminated byte}, or \ntbs, is a character sequence whose highest-addressed element with defined content has the value zero @@ -794,7 +784,7 @@ \indexlibrary{\idxhdr{cstring}}% \indextext{NTBS}\footnote{Many of the objects manipulated by function signatures declared in -\tcode{}~(\ref{c.strings}) are character sequences or \ntbs{}s. +\tcode{}\iref{c.strings} are character sequences or \ntbs{}s. \indextext{\idxhdr{cstring}}% \indexlibrary{\idxhdr{cstring}}% The size of some of these character sequences is limited by @@ -820,8 +810,7 @@ \pnum A \indextext{NTBS}% -\indextext{NTBS!static}% -\term{static} \ntbs +\defnx{static}{NTBS!static} \ntbs is an \ntbs with static storage duration.\footnote{A string literal, such as \tcode{"abc"}, @@ -842,16 +831,15 @@ \pnum A -\term{static} \ntmbs +\defnx{static}{NTMBS!static} \ntmbs is an \ntmbs with static storage duration. -\indextext{NTMBS!static}% \indextext{NTMBS}% \rSec3[functions.within.classes]{Functions within classes} \pnum -For the sake of exposition, Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter} -and Annex~\ref{depr} do not describe copy/move constructors, assignment +For the sake of exposition, \ref{\firstlibchapter} through \ref{\lastlibchapter} +and \ref{depr} do not describe copy/move constructors, assignment operators, or (non-virtual) destructors with the same apparent semantics as those that can be generated by default~(\ref{class.ctor}, \ref{class.dtor}, \ref{class.copy}). \indextext{constructor!copy}% @@ -864,19 +852,19 @@ \pnum For the sake of exposition, the library clauses sometimes annotate constructors with \EXPLICIT{}. Such a constructor is conditionally declared -as either explicit or non-explicit~(\ref{class.conv.ctor}). +as either explicit or non-explicit\iref{class.conv.ctor}. \begin{note} This is typically implemented by declaring two such constructors, of which at most one participates in overload resolution. \end{note} \rSec3[objects.within.classes]{Private members} \pnum -Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter} and -Annex~\ref{depr} do not specify the representation of classes, and intentionally -omit specification of class members~(\ref{class.mem}). An implementation may +\ref{\firstlibchapter} through \ref{\lastlibchapter} and +\ref{depr} do not specify the representation of classes, and intentionally +omit specification of class members\iref{class.mem}. An implementation may define static or non-static class members, or both, as needed to implement the -semantics of the member functions specified in Clauses~\ref{\firstlibchapter} -through~\ref{\lastlibchapter} and Annex~\ref{depr}. +semantics of the member functions specified in \ref{\firstlibchapter} +through \ref{\lastlibchapter} and \ref{depr}. \pnum For the sake of exposition, @@ -896,7 +884,7 @@ \pnum This subclause specifies requirements that apply to the entire \Cpp standard library. -Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter} and Annex~\ref{depr} +\ref{\firstlibchapter} through \ref{\lastlibchapter} and \ref{depr} specify the requirements of individual entities within the library. \pnum @@ -925,7 +913,7 @@ \pnum The \Cpp standard library provides definitions for the entities and macros described in the synopses -of the \Cpp standard library headers~(\ref{headers}). +of the \Cpp standard library headers\iref{headers}. \pnum All library entities except @@ -935,9 +923,9 @@ are defined within the namespace \tcode{std} or namespaces nested within namespace -\tcode{std}.\footnote{The C standard library headers (Annex~\ref{depr.c.headers}) also define +\tcode{std}.\footnote{The C standard library headers\iref{depr.c.headers} also define names within the global namespace, while the \Cpp headers for C library -facilities~(\ref{headers}) may also define names within the global namespace.}% +facilities\iref{headers} may also define names within the global namespace.}% \indextext{namespace} It is unspecified whether names declared in a specific namespace are declared directly in that namespace or in an inline namespace inside that @@ -960,7 +948,7 @@ Each element of the \Cpp standard library is declared or defined (as appropriate) in a \term{header}.\footnote{A header is not necessarily a source file, nor are the sequences delimited by \tcode{<} and \tcode{>} in header names necessarily valid source -file names~(\ref{cpp.include}).} +file names\iref{cpp.include}.} \pnum The \Cpp standard library provides the @@ -971,26 +959,31 @@ {llll} \topline \tcode{} & +\tcode{} & +\tcode{} & +\tcode{} \\ + +\tcode{} & \tcode{} & \tcode{} & \tcode{} \\ -\tcode{} & +\tcode{} & \tcode{} & \tcode{} & \tcode{} \\ -\tcode{} & +\tcode{} & \tcode{} & \tcode{} & \tcode{} \\ -\tcode{} & +\tcode{} & \tcode{} & \tcode{} & \tcode{} \\ -\tcode{} & +\tcode{} & \tcode{} & \tcode{} & \tcode{} \\ @@ -1044,11 +1037,6 @@ \tcode{} & \tcode{} & \\ - -\tcode{} & -\tcode{} & -\tcode{} & -\\ \end{floattable} @@ -1105,18 +1093,18 @@ \end{floattable} \pnum -Except as noted in Clauses~\ref{library} through~\ref{\lastlibchapter} -and Annex~\ref{depr}, the contents of each header \tcode{c\placeholder{name}} is +Except as noted in \ref{library} through \ref{\lastlibchapter} +and \ref{depr}, the contents of each header \tcode{c\placeholder{name}} is the same as that of the corresponding header \tcode{\placeholder{name}.h} as -specified in the C standard library (Clause~\ref{intro.refs}). +specified in the C standard library\iref{intro.refs}. In the \Cpp standard library, however, the declarations (except for names which are defined as macros in C) are within -namespace scope~(\ref{basic.scope.namespace}) of the namespace \tcode{std}. +namespace scope\iref{basic.scope.namespace} of the namespace \tcode{std}. It is unspecified whether these names (including any overloads added in -Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter} and Annex~\ref{depr}) +\ref{\firstlibchapter} through \ref{\lastlibchapter} and \ref{depr}) are first declared within the global namespace scope and are then injected into namespace \tcode{std} by explicit -\grammarterm{using-declaration}{s}~(\ref{namespace.udecl}). +\grammarterm{using-declaration}{s}\iref{namespace.udecl}. \pnum Names which are defined as macros in C shall be defined as macros in the \Cpp @@ -1268,11 +1256,10 @@ \pnum Two kinds of implementations are defined: -\term{hosted} +\defnx{hosted}{implementation!hosted} and -\term{freestanding}~(\ref{intro.compliance}). +\term{freestanding}\iref{intro.compliance}. For a hosted implementation, this International Standard -\indextext{implementation!hosted}% describes the set of available headers. \pnum @@ -1302,15 +1289,17 @@ \indextext{\idxhdr{cstdlib}}% \indexlibrary{\idxhdr{cstdlib}}% shall declare at least the functions +\indexlibrary{\idxcode{abort}}% \tcode{abort}, +\indexlibrary{\idxcode{atexit}}% \tcode{atexit}, +\indexlibrary{\idxcode{at_quick_exit}}% \tcode{at_quick_exit}, -\tcode{exit}, -and \tcode{quick_exit} -\indexlibrary{\idxcode{abort}}% -\indexlibrary{\idxcode{atexit}}% \indexlibrary{\idxcode{exit}}% -(\ref{support.start.term}). +\tcode{exit}, +and +\indexlibrary{\idxcode{quick_exit}}% +\tcode{quick_exit}\iref{support.start.term}. The other headers listed in this table shall meet the same requirements as for a hosted implementation. \rSec2[using]{Using the library} @@ -1321,7 +1310,7 @@ This section describes how a \Cpp program gains access to the facilities of the \Cpp standard library. \ref{using.headers} describes effects during translation phase 4, while~\ref{using.linkage} describes effects during phase -8~(\ref{lex.phases}). +8\iref{lex.phases}. \rSec3[using.headers]{Headers} @@ -1330,12 +1319,12 @@ whose contents are made available to a translation unit when it contains the appropriate \indextext{unit!translation}% \tcode{\#include} -preprocessing directive~(\ref{cpp.include}).% +preprocessing directive\iref{cpp.include}.% \indextext{\idxcode{\#include}}% \indextext{source file} \pnum -A translation unit may include library headers in any order (Clause~\ref{lex}). +A translation unit may include library headers in any order\iref{lex}. \indextext{unit!translation}% Each may be included more than once, with no effect different from being included exactly once, except that the effect of including either @@ -1362,10 +1351,10 @@ \rSec3[using.linkage]{Linkage} \pnum -Entities in the \Cpp standard library have external linkage~(\ref{basic.link}). +Entities in the \Cpp standard library have external linkage\iref{basic.link}. Unless otherwise specified, objects and functions have the default \tcode{extern "C++"} -linkage~(\ref{dcl.link}). +linkage\iref{dcl.link}. \pnum \indextext{library!C standard}% @@ -1394,8 +1383,8 @@ \indextext{startup!program}% \pnum See also -replacement functions~(\ref{replacement.functions}), -runtime changes~(\ref{handler.functions}). +replacement functions\iref{replacement.functions}, +runtime changes\iref{handler.functions}. \rSec2[utility.requirements]{Requirements on types and expressions} @@ -1431,8 +1420,8 @@ \pnum In general, a default constructor is not required. Certain container class member function signatures specify \tcode{T()} as a default argument. -\tcode{T()} shall be a well-defined expression~(\ref{dcl.init}) if one of those -signatures is called using the default argument~(\ref{dcl.fct.default}). +\tcode{T()} shall be a well-defined expression\iref{dcl.init} if one of those +signatures is called using the default argument\iref{dcl.fct.default}. \indextext{requirements!\idxcode{EqualityComparable}}% \begin{concepttable}{\tcode{EqualityComparable} requirements}{equalitycomparable} @@ -1460,7 +1449,7 @@ \hdstyle{Expression} & \hdstyle{Return type} & \hdstyle{Requirement} \\ \capsep \tcode{a < b} & convertible to \tcode{bool} & -\tcode{<} is a strict weak ordering relation~(\ref{alg.sorting}) \\ +\tcode{<} is a strict weak ordering relation\iref{alg.sorting} \\ \end{concepttable} \enlargethispage{-3\baselineskip} @@ -1557,13 +1546,13 @@ \pnum The context in which \tcode{swap(t, u)} and \tcode{swap(u, t)} are evaluated shall ensure that a binary non-member function named ``swap'' is selected via overload -resolution~(\ref{over.match}) on a candidate set that includes: +resolution\iref{over.match} on a candidate set that includes: \begin{itemize} \item the two \tcode{swap} function templates defined in -\tcode{}~(\ref{utility}) and +\tcode{}\iref{utility} and -\item the lookup set produced by argument-dependent lookup~(\ref{basic.lookup.argdep}). +\item the lookup set produced by argument-dependent lookup\iref{basic.lookup.argdep}. \end{itemize} \begin{note} If \tcode{T} and \tcode{U} are both fundamental types or arrays of @@ -1581,7 +1570,7 @@ swappable with any rvalue or lvalue, respectively, of type \tcode{T}. \pnum -A type \tcode{X} satisfying any of the iterator requirements~(\ref{iterator.requirements}) +A type \tcode{X} satisfying any of the iterator requirements\iref{iterator.requirements} satisfies the requirements of \tcode{ValueSwappable} if, for any dereferenceable object \tcode{x} of type \tcode{X}, @@ -1642,7 +1631,7 @@ \tcode{DefaultConstructible}, \tcode{CopyConstructible}, \tcode{CopyAssignable}, and \tcode{Destructible}, -\item lvalues of type \tcode{P} are swappable~(\ref{swappable.requirements}), +\item lvalues of type \tcode{P} are swappable\iref{swappable.requirements}, \item the expressions shown in Table~\ref{tab:nullablepointer} are valid and have the indicated semantics, and @@ -1658,7 +1647,7 @@ \pnum An object \tcode{p} of type \tcode{P} can be contextually converted to -\tcode{bool} (Clause~\ref{conv}). The effect shall be as if \tcode{p != nullptr} +\tcode{bool}\iref{conv}. The effect shall be as if \tcode{p != nullptr} had been evaluated in place of \tcode{p}. \pnum @@ -1716,9 +1705,9 @@ A type \tcode{H} meets the \tcode{Hash} requirements if: \begin{itemize} -\item it is a function object type~(\ref{function.objects}), +\item it is a function object type\iref{function.objects}, \item it satisfies the requirements of \tcode{CopyConstructible} and - \tcode{Destructible}~(\ref{utility.arg.requirements}), and + \tcode{Destructible}\iref{utility.arg.requirements}, and \item the expressions shown in Table~\ref{tab:hash} are valid and have the indicated semantics. \end{itemize} @@ -1756,14 +1745,14 @@ This information includes the knowledge of pointer types, the type of their difference, the type of the size of objects in this allocation model, as well as the memory allocation and deallocation primitives for it. All of the -string types (Clause~\ref{strings}), -containers (Clause~\ref{containers}) (except array), -string buffers and string streams (Clause~\ref{input.output}), and -\tcode{match_results} (Clause~\ref{re}) are parameterized in terms of +string types\iref{strings}, +containers\iref{containers} (except array), +string buffers and string streams\iref{input.output}, and +\tcode{match_results}\iref{re} are parameterized in terms of allocators. \pnum -The class template \tcode{allocator_traits}~(\ref{allocator.traits}) supplies +The class template \tcode{allocator_traits}\iref{allocator.traits} supplies a uniform interface to all allocator types. Table~\ref{tab:desc.var.def} describes the types manipulated through allocators. Table~\ref{tab:utilities.allocator.requirements} @@ -1790,7 +1779,7 @@ \hline \lhdr{Variable} & \rhdr{Definition} \\ \capsep \endhead -\tcode{T, U, C} & any \cv-unqualified object type~(\ref{basic.types}) \\ \rowsep +\tcode{T, U, C} & any \cv-unqualified object type\iref{basic.types} \\ \rowsep \tcode{X} & an Allocator class for type \tcode{T} \\ \rowsep \tcode{Y} & the corresponding Allocator class for type \tcode{U} \\ \rowsep \tcode{XX} & the type \tcode{allocator_traits} \\ \rowsep @@ -1815,6 +1804,8 @@ \tcode{args} & a function parameter pack with the pattern \tcode{Args\&\&} \\ \end{libreqtab2} +\newpage + \begin{libreqtab4d} {Allocator requirements} {tab:utilities.allocator.requirements} @@ -1952,7 +1943,7 @@ \tcode{X u = std::move(a);} & & Shall not exit via an exception.\br - \postconditions \tcode{u} is equal to the prior value of \tcode{a}. & \\ \rowsep + \postconditions The value of \tcode{a} is unchanged and is equal to \tcode{u}. & \\ \rowsep \tcode{X u(std::move(b));} & & @@ -2037,21 +2028,21 @@ \tcode{MoveAssignable} requirements (Table~\ref{tab:moveassignable}) and the move operation shall not throw exceptions. If \tcode{X::propagate_on_container_swap::value} is \tcode{true}, -lvalues of type \tcode{X} shall be swappable~(\ref{swappable.requirements}) +lvalues of type \tcode{X} shall be swappable\iref{swappable.requirements} and the \tcode{swap} operation shall not throw exceptions. \pnum An allocator type \tcode{X} shall satisfy the requirements of -\tcode{CopyConstructible}~(\ref{utility.arg.requirements}). +\tcode{CopyConstructible}\iref{utility.arg.requirements}. The \tcode{X::pointer}, \tcode{X::const_pointer}, \tcode{X::void_pointer}, and \tcode{X::const_void_pointer} types shall satisfy the requirements of -\tcode{NullablePointer}~(\ref{nullablepointer.requirements}). +\tcode{NullablePointer}\iref{nullablepointer.requirements}. No constructor, comparison function, copy operation, move operation, or swap operation on these pointer types shall exit via an exception. \tcode{X::pointer} and \tcode{X::const_pointer} shall also satisfy the requirements for -a random access iterator~(\ref{random.access.iterators}) and of -a contiguous iterator~(\ref{iterator.requirements.general}). +a random access iterator\iref{random.access.iterators} and of +a contiguous iterator\iref{iterator.requirements.general}. \pnum Let \tcode{x1} and \tcode{x2} denote objects of (possibly different) types @@ -2134,7 +2125,7 @@ \begin{itemize} \item \tcode{X} is a complete type, and -\item all the member types of \tcode{allocator_traits}~(\ref{allocator.traits}) +\item all the member types of \tcode{allocator_traits}\iref{allocator.traits} other than \tcode{value_type} are complete types. \end{itemize} @@ -2145,11 +2136,11 @@ \pnum This section describes restrictions on \Cpp programs that use the facilities of the \Cpp standard library. The following subclauses specify constraints on the -program's use of namespaces~(\ref{namespace.std}), its use of various reserved -names~(\ref{reserved.names}), its use of headers~(\ref{alt.headers}), its use of -standard library classes as base classes~(\ref{derived.classes}), its -definitions of replacement functions~(\ref{replacement.functions}), and its -installation of handler functions during execution~(\ref{handler.functions}). +program's use of namespaces\iref{namespace.std}, its use of various reserved +names\iref{reserved.names}, its use of headers\iref{alt.headers}, its use of +standard library classes as base classes\iref{derived.classes}, its +definitions of replacement functions\iref{replacement.functions}, and its +installation of handler functions during execution\iref{handler.functions}. \rSec3[namespace.constraints]{Namespace use} @@ -2171,6 +2162,12 @@ must be prepared to work adequately with any user-supplied specialization that meets the minimum requirements of this International Standard.} +\pnum +The behavior of a \Cpp program is undefined +if it declares an explicit or partial specialization +of any standard library variable template, +except where explicitly permitted by the specification of that variable template. + \pnum The behavior of a \Cpp program is undefined if it declares \begin{itemize} @@ -2191,7 +2188,7 @@ original template. \pnum -A translation unit shall not declare namespace \tcode{std} to be an inline namespace~(\ref{namespace.def}). +A translation unit shall not declare namespace \tcode{std} to be an inline namespace\iref{namespace.def}. \rSec4[namespace.posix]{Namespace \tcode{posix}} @@ -2395,7 +2392,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\iref{over.literal} that do not start with an underscore are reserved for future standardization. \rSec3[alt.headers]{Headers} @@ -2403,7 +2400,7 @@ If a file with a name equivalent to the derived file name for one of the \Cpp standard library headers is not provided as part of the implementation, and a file with that name -is placed in any of the standard places for a source file to be included~(\ref{cpp.include}), +is placed in any of the standard places for a source file to be included\iref{cpp.include}, the behavior is undefined.% \indextext{source file}% \indextext{undefined} @@ -2416,19 +2413,19 @@ for a base class in the \Cpp standard \indextext{class!base}% \indextext{library!C++ standard}% -library may be overridden in a derived class defined in the program~(\ref{class.virtual}). +library may be overridden in a derived class defined in the program\iref{class.virtual}. \rSec3[replacement.functions]{Replacement functions} \pnum \indextext{definition!alternate}% -Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter} and Annex~\ref{depr} +\ref{\firstlibchapter} through \ref{\lastlibchapter} and \ref{depr} describe the behavior of numerous functions defined by the \Cpp standard library. Under some circumstances, \indextext{library!C++ standard}% however, certain of these function descriptions also apply to replacement functions defined -in the program~(\ref{definitions}). +in the program\iref{definitions}. \pnum A \Cpp program may provide the definition for any of the following @@ -2474,7 +2471,7 @@ \pnum The program's definitions are used instead of the default versions supplied by -the implementation~(\ref{support.dynamic}). +the implementation\iref{support.dynamic}. Such replacement occurs prior to program startup~(\ref{basic.def.odr}, \ref{basic.start}). \indextext{startup!program}% The program's declarations shall not be specified as @@ -2485,7 +2482,7 @@ \pnum The \Cpp standard library provides a default version of the following handler -function (Clause~\ref{language.support}): +function\iref{language.support}: \begin{itemize} \item @@ -2536,7 +2533,7 @@ \begin{itemize} \item -for replacement functions~(\ref{new.delete}), if the installed replacement function does not +for replacement functions\iref{new.delete}, if the installed replacement function does not implement the semantics of the applicable \required paragraph. @@ -2560,7 +2557,7 @@ \required paragraph. \item -if an incomplete type~(\ref{basic.types}) is used as a template +if an incomplete type\iref{basic.types} is used as a template argument when instantiating a template component, unless specifically allowed for that component. \end{itemize} @@ -2596,11 +2593,12 @@ assume that this parameter is a unique reference to this argument. \begin{note} If the parameter is a generic parameter of the form \tcode{T\&\&} and an lvalue of type -\tcode{A} is bound, the argument binds to an lvalue reference~(\ref{temp.deduct.call}) +\tcode{A} is bound, the argument binds to an lvalue reference\iref{temp.deduct.call} and thus is not covered by the previous sentence. \end{note} \begin{note} If a program casts an lvalue to an xvalue while passing that lvalue to a library function (e.g. by calling the function with the argument \tcode{std::move(x)}), the program -is effectively asking that function to treat that lvalue as a temporary. The implementation +is effectively asking that function to treat that lvalue as a temporary object. +The implementation is free to optimize away aliasing checks which might be needed if the argument was an lvalue. \end{note} \end{itemize} @@ -2612,11 +2610,11 @@ threads may introduce a data race. The conditions under which this may occur are specified in~\ref{res.on.data.races}. \begin{note} Modifying an object of a standard library type that is shared between threads risks undefined behavior unless objects of that type are explicitly -specified as being sharable without data races or the user supplies a locking mechanism. \end{note} +specified as being shareable without data races or the user supplies a locking mechanism. \end{note} \pnum If an object of a standard library type is accessed, and -the beginning of the object's lifetime~(\ref{basic.life}) +the beginning of the object's lifetime\iref{basic.life} does not happen before the access, or the access does not happen before the end of the object's lifetime, the behavior is undefined unless otherwise specified. @@ -2661,10 +2659,10 @@ \pnum Certain types and macros are defined in more than one header. Every such entity shall be defined such that any header that defines it may be -included after any other header that also defines it~(\ref{basic.def.odr}). +included after any other header that also defines it\iref{basic.def.odr}. \pnum -The C standard library headers (\ref{depr.c.headers}) +The C standard library headers\iref{depr.c.headers} shall include only their corresponding \Cpp standard library header, as described in~\ref{headers}. @@ -2692,12 +2690,12 @@ It is unspecified whether any non-member functions in the \Cpp standard library are defined as -\tcode{inline}~(\ref{dcl.inline}). +\tcode{inline}\iref{dcl.inline}. \pnum A call to a non-member function signature -described in Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter} and -Annex~\ref{depr} shall behave as if the implementation declared no additional +described in \ref{\firstlibchapter} through \ref{\lastlibchapter} and +\ref{depr} shall behave as if the implementation declared no additional non-member function signatures.\footnote{A valid \Cpp program always calls the expected library non-member function. An implementation may also define additional non-member functions that would otherwise not @@ -2711,13 +2709,13 @@ Unless otherwise specified, calls made by functions in the standard library to non-operator, non-member functions do not use functions from another namespace which are found through -\term{argument-dependent name lookup}~(\ref{basic.lookup.argdep}). +\term{argument-dependent name lookup}\iref{basic.lookup.argdep}. \begin{note} The phrase ``unless otherwise specified'' applies to cases such as -the swappable with requirements~(\ref{swappable.requirements}). +the swappable with requirements\iref{swappable.requirements}. The exception for overloaded operators allows argument-dependent lookup in cases like that of -\tcode{ostream_iterator::operator=}~(\ref{ostream.iterator.ops}): +\tcode{ostream_iterator::operator=}\iref{ostream.iterator.ops}: \effects \begin{codeblock} @@ -2732,7 +2730,7 @@ \pnum It is unspecified whether any member functions in the \Cpp standard library are defined as -\tcode{inline}~(\ref{dcl.inline}). +\tcode{inline}\iref{dcl.inline}. \pnum For a non-virtual member function described in the \Cpp standard library, @@ -2751,7 +2749,7 @@ \pnum This International Standard explicitly requires that certain standard library functions are -\tcode{constexpr}~(\ref{dcl.constexpr}). An implementation shall not declare +\tcode{constexpr}\iref{dcl.constexpr}. An implementation shall not declare any standard library function signature as \tcode{constexpr} except for those where it is explicitly required. Within any header that provides any non-defining declarations of constexpr @@ -2789,19 +2787,19 @@ \pnum This section specifies requirements that implementations shall meet to prevent data -races~(\ref{intro.multithread}). +races\iref{intro.multithread}. Every standard library function shall meet each requirement unless otherwise specified. Implementations may prevent data races in cases other than those specified below. \pnum A \Cpp standard library function shall not directly or indirectly access -objects~(\ref{intro.multithread}) accessible by threads other than the current thread +objects\iref{intro.multithread} accessible by threads other than the current thread unless the objects are accessed directly or indirectly via the function's arguments, including \tcode{this}. \pnum A \Cpp standard library function shall not directly or indirectly modify -objects~(\ref{intro.multithread}) accessible by threads other than the current thread +objects\iref{intro.multithread} accessible by threads other than the current thread unless the objects are accessed directly or indirectly via the function's non-const arguments, including \tcode{this}. @@ -2828,7 +2826,7 @@ \pnum Unless otherwise specified, \Cpp standard library functions shall perform all operations solely within the current thread if those operations have effects that are -visible~(\ref{intro.multithread}) to users. +visible\iref{intro.multithread} to users. \pnum \begin{note} This allows implementations to parallelize operations if there are no visible @@ -2840,7 +2838,7 @@ \pnum \indextext{protection}% It is unspecified whether any function signature or class described in -Clauses~\ref{\firstlibchapter} through~\ref{\lastlibchapter} and Annex~\ref{depr} is a +\ref{\firstlibchapter} through \ref{\lastlibchapter} and \ref{depr} is a \tcode{friend} of another class in the \Cpp standard library. \indextext{specifier!\idxcode{friend}} @@ -2877,8 +2875,8 @@ Unless explicitly stated otherwise, types with distinct names shall be distinct types.\footnote{There is an implicit exception to this rule for types that are described as synonyms for basic integral types, such as -\tcode{size_t}~(\ref{support.types}) and -\tcode{streamoff}~(\ref{stream.types}).} +\tcode{size_t}\iref{support.types} and +\tcode{streamoff}\iref{stream.types}.} \end{itemize} \pnum @@ -2913,7 +2911,7 @@ exception.\footnote{The functions \tcode{qsort()} and -\tcode{bsearch()}~(\ref{alg.c.library}) meet this condition.} +\tcode{bsearch()}\iref{alg.c.library} meet this condition.} \pnum Destructor operations defined in the \Cpp standard library @@ -2936,7 +2934,7 @@ can report a failure to allocate storage by throwing an exception of type \tcode{bad_alloc}, or a class derived from -\tcode{bad_alloc}~(\ref{bad.alloc}).} +\tcode{bad_alloc}\iref{bad.alloc}.} Implementations should report errors by throwing exceptions of or derived from the standard exception classes~(\ref{bad.alloc}, @@ -2955,7 +2953,7 @@ \indextext{pointer!to traceable object}% Objects constructed by the standard library that may hold a user-supplied pointer value or an integer of type \tcode{std::intptr_t} shall store such values in a traceable -pointer location~(\ref{basic.stc.dynamic.safety}). \begin{note} Other libraries are +pointer location\iref{basic.stc.dynamic.safety}. \begin{note} Other libraries are strongly encouraged to do the same, since not doing so may result in accidental use of pointers that are not safely derived. Libraries that store pointers outside the user's address space should make it appear that they are stored and retrieved from a traceable @@ -2965,17 +2963,17 @@ \pnum Certain functions in the \Cpp standard library report errors via a -\tcode{std::error_code}~(\ref{syserr.errcode.overview}) object. That object's +\tcode{std::error_code}\iref{syserr.errcode.overview} object. That object's \tcode{category()} member shall return \tcode{std::system_category()} for errors originating from the operating system, or a reference to an \impldef{\tcode{error_category} for errors originating outside the operating system} \tcode{error_category} object for errors originating elsewhere. The implementation shall define the possible values of \tcode{value()} for each of these error categories. \begin{example} For operating systems that are based on POSIX, -implementations are encouraged to define the \tcode{std::system_category()} values as +implementations should define the \tcode{std::system_category()} values as identical to the POSIX \tcode{errno} values, with additional values as defined by the operating system's documentation. Implementations for operating systems that are not -based on POSIX are encouraged to define values identical to the operating system's +based on POSIX should define values identical to the operating system's values. For errors that do not originate from the operating system, the implementation may provide enums for the associated values. \end{example} @@ -2983,6 +2981,6 @@ \pnum Objects of types defined in the \Cpp standard library may be moved -from~(\ref{class.copy}). Move operations may be explicitly specified or +from\iref{class.copy}. Move operations may be explicitly specified or implicitly generated. Unless otherwise specified, such moved-from objects shall be placed in a valid but unspecified state. diff --git a/source/limits.tex b/source/limits.tex index d1b2c85773..37d35bd06d 100644 --- a/source/limits.tex +++ b/source/limits.tex @@ -124,10 +124,10 @@ Template arguments in a template declaration [1\,024]. \item% Recursively nested template instantiations, including substitution -during template argument deduction~(\ref{temp.deduct}) [1\,024]. +during template argument deduction\iref{temp.deduct} [1\,024]. \item% Handlers per try block [256]. \item% -Number of placeholders~(\ref{func.bind.place}) [10]. +Number of placeholders\iref{func.bind.place} [10]. \end{itemize} diff --git a/source/locales.tex b/source/locales.tex index 256774c070..de5297bbfd 100644 --- a/source/locales.tex +++ b/source/locales.tex @@ -224,7 +224,7 @@ function template \tcode{has_facet()}. User-defined facets may be installed in a locale, and used identically as -may standard facets~(\ref{facets.examples}). +may standard facets\iref{facets.examples}. \pnum \begin{note} @@ -250,7 +250,7 @@ so that given a locale object \tcode{loc} a \Cpp program can call \tcode{isspace(c, loc)}. -(This eases upgrading existing extractors~(\ref{istream.formatted}).) +(This eases upgrading existing extractors\iref{istream.formatted}.) \end{itemize} \end{note} @@ -282,7 +282,7 @@ object per thread is \impldef{whether locale object is global or per-thread}. Implementations should provide one global locale object per thread. If there is a single global locale object for the entire program, -implementations are not required to avoid data races on it~(\ref{res.on.data.races}). +implementations are not required to avoid data races on it\iref{res.on.data.races}. \rSec3[locale.types]{\tcode{locale} types} @@ -445,7 +445,7 @@ \tcode{OutputIterator} indicates the set of all possible specializations on parameters that satisfy the -requirements of an Input Iterator or an Output Iterator, respectively~(\ref{iterator.requirements}). +requirements of an Input Iterator or an Output Iterator, respectively\iref{iterator.requirements}. A template parameter with name \tcode{C} represents the set @@ -574,7 +574,7 @@ to initialize each facet's \tcode{id} member the first time an instance of the facet is installed into a locale. -This depends only on static storage being zero before constructors run~(\ref{basic.start.static}). +This depends only on static storage being zero before constructors run\iref{basic.start.static}. \end{note} \rSec3[locale.cons]{\tcode{locale} constructors and destructor} @@ -840,8 +840,8 @@ \remarks This member operator template (and therefore \tcode{locale} -itself) satisfies requirements for a comparator predicate template argument -(Clause~\ref{algorithms}) applied to strings. +itself) satisfies requirements for a comparator predicate template argument\iref{algorithms} +applied to strings. \pnum \returns @@ -1007,7 +1007,7 @@ where \tcode{\placeholder{F}} is the \tcode{ctype_base::mask} -value corresponding to that function~(\ref{category.ctype}).\footnote{When +value corresponding to that function\iref{category.ctype}.\footnote{When used in a loop, it is faster to cache the \tcode{ctype<>} facet and use it directly, or use the vector form of @@ -1062,7 +1062,7 @@ and \indexlibrary{\idxcode{width}!\idxcode{ios_base}}% \tcode{width()}, -specify the format of the corresponding datum~(\ref{ios.base}). +specify the format of the corresponding datum\iref{ios.base}. Those functions which need to use other facets call its member \tcode{getloc()} to retrieve the locale imbued there. @@ -1095,21 +1095,21 @@ namespace std { class ctype_base { public: - using mask = @\placeholder{T}@; + using mask = @\seebelow@; // numeric values are for exposition only. - static const mask space = 1 << 0; - static const mask print = 1 << 1; - static const mask cntrl = 1 << 2; - static const mask upper = 1 << 3; - static const mask lower = 1 << 4; - static const mask alpha = 1 << 5; - static const mask digit = 1 << 6; - static const mask punct = 1 << 7; + static const mask space = 1 << 0; + static const mask print = 1 << 1; + static const mask cntrl = 1 << 2; + static const mask upper = 1 << 3; + static const mask lower = 1 << 4; + static const mask alpha = 1 << 5; + static const mask digit = 1 << 6; + static const mask punct = 1 << 7; static const mask xdigit = 1 << 8; - static const mask blank = 1 << 9; - static const mask alnum = alpha | digit; - static const mask graph = alnum | punct; + static const mask blank = 1 << 9; + static const mask alnum = alpha | digit; + static const mask graph = alnum | punct; }; } \end{codeblock} @@ -1117,7 +1117,7 @@ \pnum The type \tcode{mask} -is a bitmask type~(\ref{bitmask.types}). +is a bitmask type\iref{bitmask.types}. \rSec3[locale.ctype]{Class template \tcode{ctype}} @@ -1178,7 +1178,7 @@ for character classing during input parsing. \pnum -The specializations required in Table~\ref{tab:localization.category.facets}~(\ref{locale.category}), namely +The specializations required in Table~\ref{tab:localization.category.facets}\iref{locale.category}, namely \tcode{ctype} and \tcode{ctype}, @@ -1190,8 +1190,7 @@ \indexlibrarymember{ctype}{is}% \begin{itemdecl} bool is(mask m, charT c) const; -const charT* is(const charT* low, const charT* high, - mask* vec) const; +const charT* is(const charT* low, const charT* high, mask* vec) const; \end{itemdecl} \begin{itemdescr} @@ -1204,8 +1203,7 @@ \indexlibrarymember{ctype}{scan_is}% \begin{itemdecl} -const charT* scan_is(mask m, - const charT* low, const charT* high) const; +const charT* scan_is(mask m, const charT* low, const charT* high) const; \end{itemdecl} \begin{itemdescr} @@ -1216,8 +1214,7 @@ \indexlibrarymember{ctype}{scan_not}% \begin{itemdecl} -const charT* scan_not(mask m, - const charT* low, const charT* high) const; +const charT* scan_not(mask m, const charT* low, const charT* high) const; \end{itemdecl} \begin{itemdescr} @@ -1271,8 +1268,7 @@ \indexlibrarymember{ctype}{narrow}% \begin{itemdecl} char narrow(charT c, char dfault) const; -const charT* narrow(const charT* low, const charT* high, char dfault, - char* to) const; +const charT* narrow(const charT* low, const charT* high, char dfault, char* to) const; \end{itemdecl} \begin{itemdescr} @@ -1288,8 +1284,7 @@ \indexlibrarymember{ctype}{do_is}% \begin{itemdecl} bool do_is(mask m, charT c) const; -const charT* do_is(const charT* low, const charT* high, - mask* vec) const; +const charT* do_is(const charT* low, const charT* high, mask* vec) const; \end{itemdecl} \begin{itemdescr} @@ -1414,8 +1409,7 @@ \indexlibrarymember{ctype}{do_widen}% \begin{itemdecl} charT do_widen(char c) const; -const char* do_widen(const char* low, const char* high, - charT* dest) const; +const char* do_widen(const char* low, const char* high, charT* dest) const; \end{itemdecl} \begin{itemdescr} @@ -1432,7 +1426,7 @@ is intended to accept values derived from character literals for conversion to the locale's encoding.} The only characters for which unique transformations are required -are those in the basic source character set~(\ref{lex.charset}). +are those in the basic source character set\iref{lex.charset}. For any named \tcode{ctype} @@ -1462,8 +1456,7 @@ \indexlibrarymember{ctype}{do_narrow}% \begin{itemdecl} char do_narrow(charT c, char dfault) const; -const charT* do_narrow(const charT* low, const charT* high, - char dfault, char* dest) const; +const charT* do_narrow(const charT* low, const charT* high, char dfault, char* dest) const; \end{itemdecl} \begin{itemdescr} @@ -1477,7 +1470,7 @@ \tcode{char} value or values. -For any character \tcode{c} in the basic source character set~(\ref{lex.charset}) +For any character \tcode{c} in the basic source character set\iref{lex.charset} the transformation is such that \begin{codeblock} @@ -1530,6 +1523,7 @@ 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(); }; @@ -1546,15 +1540,12 @@ public: using char_type = char; - explicit ctype(const mask* tab = 0, bool del = false, - size_t refs = 0); + explicit ctype(const mask* tab = nullptr, 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; + 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; @@ -1564,8 +1555,7 @@ 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; + 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@; @@ -1581,12 +1571,9 @@ 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 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, + virtual const char* do_narrow(const char* low, const char* high, char dfault, char* to) const; }; } @@ -1640,8 +1627,7 @@ \indexlibrary{\idxcode{ctype}!constructor}% \begin{itemdecl} -explicit ctype(const mask* tbl = 0, bool del = false, - size_t refs = 0); +explicit ctype(const mask* tbl = nullptr, bool del = false, size_t refs = 0); \end{itemdecl} \begin{itemdescr} @@ -1659,8 +1645,7 @@ \indexlibrarymember{ctype}{is}% \begin{itemdecl} bool is(mask m, char c) const; -const char* is(const char* low, const char* high, - mask* vec) const; +const char* is(const char* low, const char* high, mask* vec) const; \end{itemdecl} \begin{itemdescr} @@ -1685,8 +1670,7 @@ \indexlibrarymember{ctype}{scan_is}% \begin{itemdecl} -const char* scan_is(mask m, - const char* low, const char* high) const; +const char* scan_is(mask m, const char* low, const char* high) const; \end{itemdecl} \begin{itemdescr} @@ -1706,8 +1690,7 @@ \indexlibrarymember{ctype}{scan_not}% \begin{itemdecl} -const char* scan_not(mask m, - const char* low, const char* high) const; +const char* scan_not(mask m, const char* low, const char* high) const; \end{itemdecl} \begin{itemdescr} @@ -1758,8 +1741,7 @@ \indexlibrarymember{ctype}{widen}% \begin{itemdecl} char widen(char c) const; -const char* widen(const char* low, const char* high, - char* to) const; +const char* widen(const char* low, const char* high, char* to) const; \end{itemdecl} \begin{itemdescr} @@ -1775,8 +1757,7 @@ \indexlibrarymember{ctype}{narrow}% \begin{itemdecl} char narrow(char c, char dfault) const; -const char* narrow(const char* low, const char* high, - char dfault, char* to) const; +const char* narrow(const char* low, const char* high, char dfault, char* to) const; \end{itemdecl} \begin{itemdescr} @@ -1830,19 +1811,17 @@ 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 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, +virtual const char* do_narrow(const char* low, const char* high, char dfault, char* to) const; \end{codeblock} +\pnum These functions are described identically as those members of the same name in the \tcode{ctype} -class template~(\ref{locale.ctype.members}). +class template\iref{locale.ctype.members}. \rSec3[locale.codecvt]{Class template \tcode{codecvt}} @@ -1920,7 +1899,7 @@ argument selects the pair of character encodings being mapped between. \pnum -The specializations required in Table~\ref{tab:localization.category.facets}~(\ref{locale.category}) +The specializations required in Table~\ref{tab:localization.category.facets}\iref{locale.category} convert the implementation-defined native character set. \tcode{codecvt} implements a degenerate conversion; @@ -2087,7 +2066,7 @@ A \tcode{codecvt} facet that is used by -\tcode{basic_filebuf}~(\ref{file.streams}) shall have the property that if +\tcode{basic_filebuf}\iref{file.streams} shall have the property that if \begin{codeblock} do_out(state, from, from_end, from_next, to, to_end, to_next) \end{codeblock} @@ -2313,6 +2292,7 @@ public: explicit codecvt_byname(const char*, size_t refs = 0); explicit codecvt_byname(const string&, size_t refs = 0); + protected: ~codecvt_byname(); }; @@ -2343,7 +2323,7 @@ \tcode{num_get} in the subclauses of~\ref{category.numeric} only apply to the specializations required in Tables~\ref{tab:localization.category.facets} -and~\ref{tab:localization.required.specializations}~(\ref{locale.category}), namely +and~\ref{tab:localization.required.specializations}\iref{locale.category}, namely \tcode{num_get}, \tcode{num_get}, \tcode{num_get}, @@ -2353,7 +2333,7 @@ \tcode{num_put}. These specializations refer to the \tcode{ios_base\&} -argument for formatting specifications~(\ref{locale.categories}), +argument for formatting specifications\iref{locale.categories}, and to its imbued locale for the \tcode{numpunct<>} facet to identify all numeric punctuation preferences, @@ -2444,27 +2424,27 @@ \indexlibrarymember{num_get}{get}% \begin{itemdecl} iter_type get(iter_type in, iter_type end, ios_base& str, - ios_base::iostate& err, bool& val) const; + ios_base::iostate& err, bool& val) const; iter_type get(iter_type in, iter_type end, ios_base& str, - ios_base::iostate& err, long& val) const; + ios_base::iostate& err, long& val) const; iter_type get(iter_type in, iter_type end, ios_base& str, - ios_base::iostate& err, long long& val) const; + ios_base::iostate& err, long long& val) const; iter_type get(iter_type in, iter_type end, ios_base& str, - ios_base::iostate& err, unsigned short& val) const; + ios_base::iostate& err, unsigned short& val) const; iter_type get(iter_type in, iter_type end, ios_base& str, - ios_base::iostate& err, unsigned int& val) const; + ios_base::iostate& err, unsigned int& val) const; iter_type get(iter_type in, iter_type end, ios_base& str, - ios_base::iostate& err, unsigned long& val) const; + ios_base::iostate& err, unsigned long& val) const; iter_type get(iter_type in, iter_type end, ios_base& str, - ios_base::iostate& err, unsigned long long& val) const; + ios_base::iostate& err, unsigned long long& val) const; iter_type get(iter_type in, iter_type end, ios_base& str, - ios_base::iostate& err, float& val) const; + ios_base::iostate& err, float& val) const; iter_type get(iter_type in, iter_type end, ios_base& str, - ios_base::iostate& err, double& val) const; + ios_base::iostate& err, double& val) const; iter_type get(iter_type in, iter_type end, ios_base& str, - ios_base::iostate& err, long double& val) const; + ios_base::iostate& err, long double& val) const; iter_type get(iter_type in, iter_type end, ios_base& str, - ios_base::iostate& err, void*& val) const; + ios_base::iostate& err, void*& val) const; \end{itemdecl} \begin{itemdescr} @@ -2478,25 +2458,25 @@ \indexlibrarymember{num_get}{do_get}% \begin{itemdecl} iter_type do_get(iter_type in, iter_type end, ios_base& str, - ios_base::iostate& err, long& val) const; + ios_base::iostate& err, long& val) const; iter_type do_get(iter_type in, iter_type end, ios_base& str, - ios_base::iostate& err, long long& val) const; + ios_base::iostate& err, long long& val) const; iter_type do_get(iter_type in, iter_type end, ios_base& str, - ios_base::iostate& err, unsigned short& val) const; + ios_base::iostate& err, unsigned short& val) const; iter_type do_get(iter_type in, iter_type end, ios_base& str, - ios_base::iostate& err, unsigned int& val) const; + ios_base::iostate& err, unsigned int& val) const; iter_type do_get(iter_type in, iter_type end, ios_base& str, - ios_base::iostate& err, unsigned long& val) const; + ios_base::iostate& err, unsigned long& val) const; iter_type do_get(iter_type in, iter_type end, ios_base& str, - ios_base::iostate& err, unsigned long long& val) const; + ios_base::iostate& err, unsigned long long& val) const; iter_type do_get(iter_type in, iter_type end, ios_base& str, - ios_base::iostate& err, float& val) const; + ios_base::iostate& err, float& val) const; iter_type do_get(iter_type in, iter_type end, ios_base& str, - ios_base::iostate& err, double& val) const; + ios_base::iostate& err, double& val) const; iter_type do_get(iter_type in, iter_type end, ios_base& str, - ios_base::iostate& err, long double& val) const; + ios_base::iostate& err, long double& val) const; iter_type do_get(iter_type in, iter_type end, ios_base& str, - ios_base::iostate& err, void*& val) const; + ios_base::iostate& err, void*& val) const; \end{itemdecl} \begin{itemdescr} @@ -2877,7 +2857,7 @@ Stage 1: Determine a printf conversion specifier \tcode{spec} and determine the characters that would be printed by -\tcode{printf}~(\ref{c.files}) +\tcode{printf}\iref{c.files} given this conversion specifier for \begin{codeblock} @@ -3149,7 +3129,7 @@ \pnum \tcode{numpunct<>} specifies numeric punctuation. -The specializations required in Table~\ref{tab:localization.category.facets}~(\ref{locale.category}), namely +The specializations required in Table~\ref{tab:localization.category.facets}\iref{locale.category}, namely \tcode{numpunct<\brk{}wchar_t>} and \tcode{numpunct}, @@ -3335,17 +3315,18 @@ \begin{codeblock} namespace std { template - class numpunct_byname : public numpunct { - // this class is specialized for \tcode{char} and \tcode{wchar_t}. - public: - using char_type = charT; - using string_type = basic_string; + class numpunct_byname : public numpunct { + // this class is specialized for \tcode{char} and \tcode{wchar_t}. + public: + using char_type = charT; + using string_type = basic_string; - explicit numpunct_byname(const char*, size_t refs = 0); - explicit numpunct_byname(const string&, size_t refs = 0); - protected: - ~numpunct_byname(); - }; + explicit numpunct_byname(const char*, size_t refs = 0); + explicit numpunct_byname(const string&, size_t refs = 0); + + protected: + ~numpunct_byname(); + }; } \end{codeblock} @@ -3389,12 +3370,12 @@ A locale member function template, \tcode{operator()}, uses the collate facet to allow a locale to act directly as the predicate -argument for standard algorithms (Clause~\ref{algorithms}) and containers operating on strings. -The specializations required in Table~\ref{tab:localization.category.facets}~(\ref{locale.category}), namely +argument for standard algorithms\iref{algorithms} and containers operating on strings. +The specializations required in Table~\ref{tab:localization.category.facets}\iref{locale.category}, namely \tcode{collate} and \tcode{collate}, -apply lexicographic ordering~(\ref{alg.lex.comparison}). +apply lexicographic ordering\iref{alg.lex.comparison}. \pnum Each function compares a string of characters @@ -3453,12 +3434,12 @@ if the first string is greater than the second, \tcode{-1} if less, zero otherwise. -The specializations required in Table~\ref{tab:localization.category.facets}~(\ref{locale.category}), namely +The specializations required in Table~\ref{tab:localization.category.facets}\iref{locale.category}, namely \tcode{collate} and \tcode{collate}, implement -a lexicographical comparison~(\ref{alg.lex.comparison}). +a lexicographical comparison\iref{alg.lex.comparison}. \end{itemdescr} \indexlibrarymember{collate}{do_transform}% @@ -3511,6 +3492,7 @@ explicit collate_byname(const char*, size_t refs = 0); explicit collate_byname(const string&, size_t refs = 0); + protected: ~collate_byname(); }; @@ -3531,7 +3513,7 @@ \tcode{time_get} in the subclauses of~\ref{category.time} only apply to the specializations required in Tables~\ref{tab:localization.category.facets} -and~\ref{tab:localization.required.specializations}~(\ref{locale.category}). +and~\ref{tab:localization.required.specializations}\iref{locale.category}. Their members use their \tcode{ios_base\&}, \tcode{ios_base::iostate\&}, @@ -3907,7 +3889,7 @@ \indexlibrarymember{do_get}{time_get}% \begin{itemdecl} iter_type do_get(iter_type s, iter_type end, ios_base& f, - ios_base::iostate& err, tm* t, char format, char modifier) const; + ios_base::iostate& err, tm* t, char format, char modifier) const; \end{itemdecl} \begin{itemdescr} @@ -3959,16 +3941,17 @@ \begin{codeblock} namespace std { template > - class time_get_byname : public time_get { - public: - using dateorder = time_base::dateorder; - using iter_type = InputIterator; + class time_get_byname : public time_get { + public: + using dateorder = time_base::dateorder; + using iter_type = InputIterator; - explicit time_get_byname(const char*, size_t refs = 0); - explicit time_get_byname(const string&, size_t refs = 0); - protected: - ~time_get_byname(); - }; + explicit time_get_byname(const char*, size_t refs = 0); + explicit time_get_byname(const string&, size_t refs = 0); + + protected: + ~time_get_byname(); + }; } \end{codeblock} @@ -4091,7 +4074,7 @@ except that the sequence of characters produced for those specifiers that are described as depending on the C locale are instead \impldef{formatted character sequence generated by \tcode{time_put::do_put} in C -locale}.\footnote{Implementations are encouraged to refer to other standards +locale}.\footnote{Implementations should refer to other standards such as POSIX for these definitions.} @@ -4111,17 +4094,17 @@ \begin{codeblock} namespace std { template > - class time_put_byname : public time_put - { - public: - using char_type = charT; - using iter_type = OutputIterator; + class time_put_byname : public time_put { + public: + using char_type = charT; + using iter_type = OutputIterator; - explicit time_put_byname(const char*, size_t refs = 0); - explicit time_put_byname(const string&, size_t refs = 0); - protected: - ~time_put_byname(); - }; + explicit time_put_byname(const char*, size_t refs = 0); + explicit time_put_byname(const string&, size_t refs = 0); + + protected: + ~time_put_byname(); + }; } \end{codeblock} @@ -4139,7 +4122,7 @@ \tcode{money_get} in the subclauses of~\ref{category.monetary} only apply to the specializations required in Tables~\ref{tab:localization.category.facets} -and~\ref{tab:localization.required.specializations}~(\ref{locale.category}). +and~\ref{tab:localization.required.specializations}\iref{locale.category}. Their members use their \tcode{ios_base\&}, \tcode{ios_base::io\-state\&}, @@ -4188,10 +4171,9 @@ \indexlibrarymember{money_get}{get}% \begin{itemdecl} -iter_type get(iter_type s, iter_type end, bool intl, - ios_base& f, ios_base::iostate& err, - long double& quant) const; -iter_type get(s, iter_type end, bool intl, ios_base&f, +iter_type get(iter_type s, iter_type end, bool intl, ios_base& f, + ios_base::iostate& err, long double& quant) const; +iter_type get(iter_type s, iter_type end, bool intl, ios_base& f, ios_base::iostate& err, string_type& quant) const; \end{itemdecl} @@ -4205,12 +4187,10 @@ \indexlibrarymember{money_get}{do_get}% \begin{itemdecl} -iter_type do_get(iter_type s, iter_type end, bool intl, - ios_base& str, ios_base::iostate& err, - long double& units) const; -iter_type do_get(iter_type s, iter_type end, bool intl, - ios_base& str, ios_base::iostate& err, - string_type& digits) const; +iter_type do_get(iter_type s, iter_type end, bool intl, ios_base& str, + ios_base::iostate& err, long double& units) const; +iter_type do_get(iter_type s, iter_type end, bool intl, ios_base& str, + ios_base::iostate& err, string_type& digits) const; \end{itemdecl} \begin{itemdescr} @@ -4415,10 +4395,8 @@ \indexlibrarymember{money_put}{put}% \begin{itemdecl} -iter_type put(iter_type s, bool intl, ios_base& f, char_type fill, - long double quant) const; -iter_type put(iter_type s, bool intl, ios_base& f, char_type fill, - const string_type& quant) const; +iter_type put(iter_type s, bool intl, ios_base& f, char_type fill, long double quant) const; +iter_type put(iter_type s, bool intl, ios_base& f, char_type fill, const string_type& quant) const; \end{itemdecl} \begin{itemdescr} @@ -4848,7 +4826,7 @@ \begin{itemdescr} \pnum \returns -The specializations required in Table~\ref{tab:localization.required.specializations}~(\ref{locale.category}), namely +The specializations required in Table~\ref{tab:localization.required.specializations}\iref{locale.category}, namely \tcode{moneypunct}, \tcode{moneypunct<\brk{}wchar_t>}, \tcode{moneypunct}, @@ -4871,15 +4849,16 @@ namespace std { template class moneypunct_byname : public moneypunct { - public: - using pattern = money_base::pattern; - using string_type = basic_string; + public: + using pattern = money_base::pattern; + using string_type = basic_string; - explicit moneypunct_byname(const char*, size_t refs = 0); - explicit moneypunct_byname(const string&, size_t refs = 0); - protected: - ~moneypunct_byname(); - }; + explicit moneypunct_byname(const char*, size_t refs = 0); + explicit moneypunct_byname(const string&, size_t refs = 0); + + protected: + ~moneypunct_byname(); + }; } \end{codeblock} @@ -5045,16 +5024,17 @@ \begin{codeblock} namespace std { template - class messages_byname : public messages { - public: - using catalog = messages_base::catalog; - using string_type = basic_string; + class messages_byname : public messages { + public: + using catalog = messages_base::catalog; + using string_type = basic_string; - explicit messages_byname(const char*, size_t refs = 0); - explicit messages_byname(const string&, size_t refs = 0); - protected: - ~messages_byname(); - }; + explicit messages_byname(const char*, size_t refs = 0); + explicit messages_byname(const string&, size_t refs = 0); + + protected: + ~messages_byname(); + }; } \end{codeblock} @@ -5311,10 +5291,10 @@ \pnum Calls to the function \tcode{setlocale} may introduce a data -race~(\ref{res.on.data.races}) with other calls to \tcode{setlocale} or with calls to +race\iref{res.on.data.races} with other calls to \tcode{setlocale} or with calls to the functions listed in Table~\ref{tab:setlocale.data.races}. -\xref ISO C 7.11. +\xref ISO C 7.11 \begin{floattable} {Potential \tcode{setlocale} data races} diff --git a/source/macros.tex b/source/macros.tex index 59dca332d1..b6342dd780 100644 --- a/source/macros.tex +++ b/source/macros.tex @@ -67,20 +67,29 @@ % the range [0,5]. (If it proves necessary, it wouldn't take much % programming to raise the limit from 5 to something larger.) +% Set the xref label for a clause to be "Clause n", not just "n". +\makeatletter +\newcommand{\customlabel}[2]{% +\protected@write \@auxout {}{\string \newlabel {#1}{{#2}{\thepage}{#2}{#1}{}} }% +\hypertarget{#1}{}% +} +\makeatother +\newcommand{\clauselabel}[1]{\customlabel{#1}{Clause \thechapter}} +\newcommand{\annexlabel}[1]{\customlabel{#1}{Annex \thechapter}} % The basic sectioning command. Example: % \Sec1[intro.scope]{Scope} % defines a first-level section whose name is "Scope" and whose short % tag is intro.scope. The square brackets are mandatory. \def\Sec#1[#2]#3{% -\ifcase#1\let\s=\chapter - \or\let\s=\section - \or\let\s=\subsection - \or\let\s=\subsubsection - \or\let\s=\paragraph - \or\let\s=\subparagraph +\ifcase#1\let\s=\chapter\let\l=\clauselabel + \or\let\s=\section\let\l=\label + \or\let\s=\subsection\let\l=\label + \or\let\s=\subsubsection\let\l=\label + \or\let\s=\paragraph\let\l=\label + \or\let\s=\subparagraph\let\l=\label \fi% -\s[#3]{#3\hfill[#2]}\label{#2}\addxref{#2}} +\s[#3]{#3\hfill[#2]}\l{#2}\addxref{#2}} % A convenience feature (mostly for the convenience of the Project % Editor, to make it easy to move around large blocks of text): @@ -91,12 +100,12 @@ % is equivalent to % \Sec2[temp.arg.type]{Template type arguments} \newcounter{SectionDepthBase} -\newcounter{scratch} +\newcounter{SectionDepth} \def\rSec#1[#2]#3{% -\setcounter{scratch}{#1} -\addtocounter{scratch}{\value{SectionDepthBase}} -\Sec{\arabic{scratch}}[#2]{#3}} +\setcounter{SectionDepth}{#1} +\addtocounter{SectionDepth}{\value{SectionDepthBase}} +\Sec{\arabic{SectionDepth}}[#2]{#3}} %%-------------------------------------------------- % Indexing @@ -169,6 +178,7 @@ \newcommand{\defn}[1]{\defnx{#1}{#1}} \newcommand{\term}[1]{\textit{#1}\xspace} \newcommand{\grammarterm}[1]{\textit{#1}\xspace} +\newcommand{\grammartermnc}[1]{\textit{#1}\nocorr} \newcommand{\placeholder}[1]{\textit{#1}} \newcommand{\placeholdernc}[1]{\textit{#1\nocorr}} @@ -182,6 +192,7 @@ \newcommand{\CppIII}{\Cpp 2003\xspace} \newcommand{\CppXI}{\Cpp 2011\xspace} \newcommand{\CppXIV}{\Cpp 2014\xspace} +\newcommand{\CppXVII}{\Cpp 2017\xspace} \newcommand{\opt}{{\ensuremath{_\mathit{opt}}}\xspace} \newcommand{\dcr}{-{-}} \newcommand{\bigoh}[1]{\ensuremath{\mathscr{O}(#1)}} @@ -236,6 +247,9 @@ %% Cross reference \newcommand{\xref}{\textsc{See also:}\xspace} +%% Inline parenthesized reference +\newcommand{\iref}[1]{\nolinebreak[3] (\ref{#1})} + %% NTBS, etc. \newcommand{\NTS}[1]{\textsc{#1}\xspace} \newcommand{\ntbs}{\NTS{ntbs}} @@ -518,11 +532,18 @@ %%-------------------------------------------------- %% Definitions section for "Terms and definitions" \newcommand{\nocontentsline}[3]{} -\newcommand{\definitionx}[3]{% -\addxref{#3}% +\newcommand{\definition}[2]{% +\addxref{#2}% \let\oldcontentsline\addcontentsline% \let\addcontentsline\nocontentsline% -#1[#2]{\hfill[#3]}\vspace{-.3\onelineskip}\label{#3} \textbf{#2}\\*% +\ifcase\value{SectionDepth} + \let\s=\section + \or\let\s=\subsection + \or\let\s=\subsubsection + \or\let\s=\paragraph + \or\let\s=\subparagraph + \fi% +\s[#1]{\hfill[#2]}\vspace{-.3\onelineskip}\label{#2} \textbf{#1}\\*% \let\addcontentsline\oldcontentsline% } \newcommand{\defncontext}[1]{\textlangle#1\textrangle} diff --git a/source/numerics.tex b/source/numerics.tex index d6b313c1db..a4cd5ec728 100644 --- a/source/numerics.tex +++ b/source/numerics.tex @@ -116,7 +116,7 @@ If the distinction between initialization and assignment is important for a class, or if it fails to satisfy any of the other conditions listed above, the programmer should use -\tcode{vector}~(\ref{vector}) instead of +\tcode{vector}\iref{vector} instead of \tcode{valarray} for that class. \end{note} @@ -221,7 +221,7 @@ \begin{note} This International Standard does not require an implementation to support the \tcode{FENV_ACCESS} pragma; -it is \impldef{whether pragma \tcode{FENV_ACCESS} is supported}~(\ref{cpp.pragma}) +it is \impldef{whether pragma \tcode{FENV_ACCESS} is supported}\iref{cpp.pragma} whether the pragma is supported. As a consequence, it is \impldef{whether \tcode{} functions can be used to manage floating-point status} whether these functions can be used to test floating-point status flags, @@ -233,9 +233,9 @@ \pnum The floating-point environment has thread storage -duration~(\ref{basic.stc.thread}). The initial state for a thread's floating-point +duration\iref{basic.stc.thread}. The initial state for a thread's floating-point environment is the state of the floating-point environment of the thread that constructs -the corresponding \tcode{thread} object~(\ref{thread.thread.class}) at the time it +the corresponding \tcode{thread} object\iref{thread.thread.class} at the time it constructed the object. \begin{note} That is, the child thread gets the floating-point state of the parent thread at the time of the child's creation. \end{note} @@ -263,7 +263,7 @@ The specializations \tcode{complex}, \tcode{complex}, and -\tcode{complex} are literal types~(\ref{basic.types}). +\tcode{complex} are literal types\iref{basic.types}. \pnum If the result of a function is not mathematically defined or not in @@ -869,13 +869,13 @@ \tcode{u} is the real part and \tcode{v} -is the imaginary part~(\ref{istream.formatted}). +is the imaginary part\iref{istream.formatted}. \pnum If bad input is encountered, calls \tcode{is.setstate(ios_base::failbit)} (which may throw -\tcode{ios::failure} (\ref{iostate.flags})). +\tcode{ios::failure}\iref{iostate.flags}). \pnum \returns @@ -1162,8 +1162,11 @@ \pnum \returns The complex natural (base-$e$) logarithm of \tcode{x}. For all \tcode{x}, -\tcode{imag(log(x))} lies in the interval \crange{$-\pi$}{$\pi$}, and -when \tcode{x} is a negative real number, \tcode{imag(log(x))} is $\pi$. +\tcode{imag(log(x))} lies in the interval \crange{$-\pi$}{$\pi$}. +\begin{note} +The semantics of this function are intended to be the same in \Cpp +as they are for \tcode{clog} in C. +\end{note} \pnum \remarks @@ -1240,8 +1243,10 @@ \returns The complex square root of \tcode{x}, in the range of the right half-plane. -If the argument is a negative real number, the -value returned lies on the positive imaginary axis. +\begin{note} +The semantics of this function are intended to be the same in \Cpp +as they are for \tcode{csqrt} in C. +\end{note} \pnum \remarks @@ -1414,7 +1419,7 @@ \pnum \indextext{\idxcode{result_type}!entity characterization based on}% Each of the entities specified via this subclause -has an associated arithmetic type~(\ref{basic.fundamental}) +has an associated arithmetic type\iref{basic.fundamental} identified as \tcode{result_type}. With \tcode{T} as the \tcode{result_type} thus associated with such an entity, @@ -1435,7 +1440,7 @@ If integer-valued, an entity may optionally be further characterized as \techterm{signed} or \techterm{unsigned}, -according to \tcode{numeric\_limits::is\_signed}. +according to \tcode{numeric_limits::is_signed}. \pnum Unless otherwise specified, @@ -1493,21 +1498,21 @@ is undefined unless the corresponding template argument is cv-unqualified and satisfies the requirements - of seed sequence~(\ref{rand.req.seedseq}). + of seed sequence\iref{rand.req.seedseq}. \item that has a template type parameter named \tcode{URBG} is undefined unless the corresponding template argument is cv-unqualified and satisfies the requirements - of uniform random bit generator~(\ref{rand.req.urng}). + of uniform random bit generator\iref{rand.req.urng}. \item that has a template type parameter named \tcode{Engine} is undefined unless the corresponding template argument is cv-unqualified and satisfies the requirements - of random number engine~(\ref{rand.req.eng}). + of random number engine\iref{rand.req.eng}. \item that has a template type parameter named \tcode{RealType} @@ -1632,7 +1637,7 @@ \indextext{\idxcode{result_type}!seed sequence requirement}% \tcode{S::result_type} & \tcode{T} - & \tcode{T} is an unsigned integer type~(\ref{basic.fundamental}) + & \tcode{T} is an unsigned integer type\iref{basic.fundamental} of at least 32 bits. & compile-time \\ \rowsep @@ -1759,7 +1764,7 @@ \indextext{\idxcode{result_type}!uniform random bit generator requirement}% \tcode{G::result_type} & \tcode{T} - & \tcode{T} is an unsigned integer type~(\ref{basic.fundamental}). + & \tcode{T} is an unsigned integer type\iref{basic.fundamental}. & compile-time \\ \rowsep \tcode{g()}% @@ -1845,7 +1850,7 @@ \pnum A class \tcode{E} that satisfies the requirements -of a uniform random bit generator~(\ref{rand.req.urng}) +of a uniform random bit generator\iref{rand.req.urng} also satisfies the requirements of a \techterm{random number engine} if the expressions shown @@ -1866,7 +1871,7 @@ \tcode{s} is a value of \tcode{T}; \item \tcode{q} is an lvalue - satisfying the requirements of a seed sequence~(\ref{rand.req.seedseq}); + satisfying the requirements of a seed sequence\iref{rand.req.seedseq}; \item \tcode{z} is a value of type \tcode{unsigned long long}; @@ -1879,7 +1884,7 @@ \tcode{basic_istream}; \end{enumeratea} where \tcode{charT} and \tcode{traits} are constrained -according to Clause~\ref{strings} and Clause~\ref{input.output}. +according to \ref{strings} and \ref{input.output}. \begin{libreqtab4d} {Random number engine requirements} @@ -2033,7 +2038,7 @@ ensures that \tcode{v}'s state is unchanged by the operation and calls \tcode{is.setstate(ios::failbit)} - (which may throw \tcode{ios::failure}~(\ref{iostate.flags})). + (which may throw \tcode{ios::failure}\iref{iostate.flags}). If a textual representation written via \tcode{os << x} was subsequently read via \tcode{is >> v}, then \tcode{x == v} @@ -2262,7 +2267,7 @@ \item \tcode{g}, \tcode{g1}, and \tcode{g2} are lvalues of a type satisfying the requirements - of a uniform random bit generator~(\ref{rand.req.urng}); + of a uniform random bit generator\iref{rand.req.urng}; \item \tcode{os} is an lvalue of the type of some class template specialization \tcode{basic_ostream}; @@ -2272,7 +2277,7 @@ \tcode{basic_istream}; \end{enumeratea} where \tcode{charT} and \tcode{traits} are constrained -according to Clauses~\ref{strings} and \ref{input.output}. +according to \ref{strings} and \ref{input.output}. \begin{libreqtab4d} {Random number distribution requirements} @@ -2294,7 +2299,7 @@ \indextext{\idxcode{result_type}!random number distribution requirement}% \tcode{D::result_type} & \tcode{T} - & \tcode{T} is an arithmetic type~(\ref{basic.fundamental}). + & \tcode{T} is an arithmetic type\iref{basic.fundamental}. & compile-time \\ \rowsep \tcode{D::param_type} @@ -2420,7 +2425,7 @@ ensures that \tcode{d} is unchanged by the operation and calls \tcode{is.setstate(ios::failbit)} - (which may throw \tcode{ios::failure}~(\ref{iostate.flags})). + (which may throw \tcode{ios::failure}\iref{iostate.flags}). \requires \tcode{is} provides a textual representation that was previously written @@ -2665,7 +2670,7 @@ Each type instantiated from a class template specified in this section~\ref{rand.eng} satisfies the requirements -of a random number engine~(\ref{rand.req.eng}) type. +of a random number engine\iref{rand.req.eng} type. \pnum Except where specified otherwise, @@ -2707,7 +2712,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 subclause~\ref{rand.adapt}: +defined in this subclause\iref{rand.eng} and in subclause~\ref{rand.adapt}: \begin{itemize} \item @@ -3215,7 +3220,7 @@ Each type instantiated from a class template specified in this section~\ref{rand.adapt} satisfies the requirements -of a random number engine adaptor~(\ref{rand.req.adapt}) type. +of a random number engine adaptor\iref{rand.req.adapt} type. \pnum Except where specified otherwise, @@ -4022,7 +4027,7 @@ \begin{itemdescr} \pnum\requires \tcode{RandomAccessIterator} - shall meet the requirements of a mutable random access iterator~(\ref{random.access.iterators}). + shall meet the requirements of a mutable random access iterator\iref{random.access.iterators}. Moreover, \tcode{iterator_traits::value_type} shall denote an unsigned integer type @@ -4128,7 +4133,7 @@ \begin{itemdescr} \pnum\requires \tcode{OutputIterator} shall satisfy the requirements - of an output iterator~(\ref{output.iterators}). + of an output iterator\iref{output.iterators}. Moreover, the expression \tcode{*dest = rt} @@ -4235,7 +4240,7 @@ Each type instantiated from a class template specified in this section~\ref{rand.dist} satisfies the requirements -of a random number distribution~(\ref{rand.req.dist}) type. +of a random number distribution\iref{rand.req.dist} type. \pnum Descriptions are provided in this section~\ref{rand.dist} @@ -5863,7 +5868,7 @@ \begin{itemdescr} \pnum\requires \tcode{InputIterator} shall satisfy the requirements - of an input iterator~(\ref{input.iterators}). + of an input iterator\iref{input.iterators}. Moreover, \tcode{iterator_traits::value_type} shall denote a type that is convertible to \tcode{double}. @@ -5898,7 +5903,7 @@ \begin{itemdescr} \pnum\requires Each instance of type \tcode{UnaryOperation} - shall be a function object~(\ref{function.objects}) + shall be a function object\iref{function.objects} whose return type shall be convertible to \tcode{double}. Moreover, \tcode{double} shall be convertible @@ -6078,7 +6083,7 @@ \begin{itemdescr} \pnum\requires Each instance of type \tcode{UnaryOperation} - shall be a function object~(\ref{function.objects}) + shall be a function object\iref{function.objects} whose return type shall be convertible to \tcode{double}. Moreover, \tcode{double} shall be convertible @@ -6113,7 +6118,7 @@ \begin{itemdescr} \pnum\requires Each instance of type \tcode{UnaryOperation} - shall be a function object~(\ref{function.objects}) + shall be a function object\iref{function.objects} whose return type shall be convertible to \tcode{double}. Moreover, \tcode{double} shall be convertible @@ -6299,7 +6304,7 @@ \begin{itemdescr} \pnum\requires Each instance of type \tcode{UnaryOperation} - shall be a function object~(\ref{function.objects}) + shall be a function object\iref{function.objects} whose return type shall be convertible to \tcode{double}. Moreover, \tcode{double} shall be convertible @@ -6334,7 +6339,7 @@ \begin{itemdescr} \pnum\requires Each instance of type \tcode{UnaryOperation} - shall be a function object~(\ref{function.objects}) + shall be a function object\iref{function.objects} whose return type shall be convertible to \tcode{double}. Moreover, \tcode{double} shall be convertible @@ -6387,7 +6392,7 @@ \indextext{\idxhdr{cstdlib}}% \indexlibrary{\idxhdr{cstdlib}}% \begin{note} -The header \tcode{}~(\ref{cstdlib.syn}) +The header \tcode{}\iref{cstdlib.syn} declares the functions described in this subclause. \end{note} @@ -6412,11 +6417,11 @@ \tcode{rand}. It is \impldef{whether \tcode{rand} may introduce a data race} whether the \tcode{rand} function -may introduce data races~(\ref{res.on.data.races}). +may introduce data races\iref{res.on.data.races}. \begin{note} \indexlibrary{\idxcode{rand}!discouraged}% The other random -number generation facilities in this International Standard~(\ref{rand}) are often preferable +number generation facilities in this International Standard\iref{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. @@ -6589,7 +6594,7 @@ are also applicable to this type. This return type shall not add more than two levels of template nesting over the most deeply nested -argument type.\footnote{Annex~\ref{implimits} recommends a minimum number +argument type.\footnote{\ref{implimits} recommends a minimum number of recursively nested template instantiations. This requirement thus indirectly suggests a minimum @@ -6602,7 +6607,7 @@ \item for every function taking a \tcode{const valarray\&} other than \tcode{begin} and -\tcode{end}~(\ref{valarray.range}), +\tcode{end}\iref{valarray.range}, identical functions taking the replacement types shall be added; \item for every function taking two @@ -6627,7 +6632,7 @@ \pnum These library functions are permitted to throw a -\tcode{bad_alloc}~(\ref{bad.alloc}) exception if there are not sufficient resources available +\tcode{bad_alloc}\iref{bad.alloc} exception if there are not sufficient resources available to carry out the operation. Note that the exception is not mandated. @@ -6745,7 +6750,7 @@ by the generalized subscript operators.\footnote{The intent is to specify an array template that has the minimum functionality necessary to address aliasing ambiguities and the proliferation of -temporaries. +temporary objects. Thus, the \tcode{valarray} template is neither a @@ -6787,7 +6792,7 @@ \pnum \effects Constructs a \tcode{valarray} that has length \tcode{n}. -Each element of the array is value-initialized~(\ref{dcl.init}). +Each element of the array is value-initialized\iref{dcl.init}. \end{itemdescr} \indexlibrary{\idxcode{valarray}!constructor}% @@ -6810,7 +6815,7 @@ \begin{itemdescr} \pnum \requires -\tcode{p} points to an array~(\ref{dcl.array}) of at least +\tcode{p} points to an array\iref{dcl.array} of at least \tcode{n} elements. \effects @@ -7029,7 +7034,7 @@ \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 +\tcode{resize(size_t, T)}\iref{valarray.members} is called for that array or until the lifetime of that array ends, whichever happens first. \end{itemdescr} @@ -7436,7 +7441,7 @@ \pnum \begin{example} If the argument has the value -2, -the first two elements of the result will be value-initialized~(\ref{dcl.init}); the third element of the result will be assigned the value +the first two elements of the result will be value-initialized\iref{dcl.init}; the third element of the result will be assigned the value of the first element of the argument; etc. \end{example} \end{itemdescr} @@ -8520,20 +8525,20 @@ \pnum In the \tcode{begin} and \tcode{end} function templates that follow, \unspec{1} is a type that meets the requirements of a mutable random access -iterator~(\ref{random.access.iterators}) -and of a contiguous iterator~(\ref{iterator.requirements.general}) +iterator\iref{random.access.iterators} +and of a contiguous iterator\iref{iterator.requirements.general} whose \tcode{value_type} is the template parameter \tcode{T} and whose \tcode{reference} type is \tcode{T\&}. \unspec{2} is a type that meets the requirements of a constant random access -iterator~(\ref{random.access.iterators}) -and of a contiguous iterator~(\ref{iterator.requirements.general}) +iterator\iref{random.access.iterators} +and of a contiguous iterator\iref{iterator.requirements.general} whose \tcode{value_type} is the template parameter \tcode{T} and whose \tcode{reference} type is \tcode{const T\&}. \pnum The iterators returned by \tcode{begin} and \tcode{end} for an array are guaranteed to be valid until the member function -\tcode{resize(size_t, T)}~(\ref{valarray.members}) is called for that +\tcode{resize(size_t, T)}\iref{valarray.members} is called for that array or until the lifetime of that array ends, whichever happens first. @@ -8797,7 +8802,7 @@ \pnum The requirements on the types of algorithms' arguments that are -described in the introduction to Clause~\ref{algorithms} also +described in the introduction to \ref{algorithms} also apply to the following algorithms. \pnum @@ -8807,7 +8812,7 @@ \tcode{BinaryOperation1}, and \tcode{BinaryOperation2} are used -whenever an algorithm expects a function object~(\ref{function.objects}). +whenever an algorithm expects a function object\iref{function.objects}. \pnum \begin{note} @@ -9152,7 +9157,7 @@ \tcode{InputIterator}'s value type shall be constructible from the type of \tcode{*first}. The result of the expression \tcode{acc + *i} or \tcode{binary_op(acc, *i)} shall be implicitly convertible to \tcode{InputIterator}'s value type. \tcode{acc} -shall be writable~(\ref{iterator.requirements.general}) to the \tcode{result} output iterator. +shall be writable\iref{iterator.requirements.general} to the \tcode{result} output iterator. In the ranges \crange{first}{last} and @@ -9596,7 +9601,7 @@ For the overloads with no \tcode{ExecutionPolicy}, \tcode{InputIterator}'s value type shall be \tcode{MoveAssignable} (Table~\ref{tab:moveassignable}) and shall be constructible from the type of \tcode{*first}. \tcode{acc} (defined below) -shall be writable~(\ref{iterator.requirements.general}) to the \tcode{result} +shall be writable\iref{iterator.requirements.general} to the \tcode{result} output iterator. The result of the expression \tcode{val - acc} or \tcode{binary_op(val, acc)} shall be writable to the \tcode{result} output iterator. @@ -9690,10 +9695,10 @@ \begin{itemdescr} \pnum \requires -\tcode{|m|} and \tcode{|n|} shall +$|\tcode{m}|$ and $|\tcode{n}|$ shall be representable as a value of \tcode{common_type_t}. \begin{note} These requirements ensure, for example, -that \tcode{gcd(m, m) = |m|} is representable as a value of type \tcode{M}. \end{note} +that $\tcode{gcd(m, m)} = |\tcode{m}|$ is representable as a value of type \tcode{M}. \end{note} \pnum \remarks @@ -9703,7 +9708,7 @@ \pnum \returns Zero when \tcode{m} and \tcode{n} are both zero. -Otherwise, returns the greatest common divisor of \tcode{|m|} and \tcode{|n|}. +Otherwise, returns the greatest common divisor of $|\tcode{m}|$ and $|\tcode{n}|$. \pnum \throws @@ -9721,9 +9726,9 @@ \begin{itemdescr} \pnum \requires -\tcode{|m|} and \tcode{|n|} shall +$|\tcode{m}|$ and $|\tcode{n}|$ shall be representable as a value of \tcode{common_type_t}. -The least common multiple of \tcode{|m|} and \tcode{|n|} +The least common multiple of $|\tcode{m}|$ and $|\tcode{n}|$ shall be representable as a value of type \tcode{common_type_t}. \pnum @@ -9734,7 +9739,7 @@ \pnum \returns Zero when either \tcode{m} or \tcode{n} is zero. -Otherwise, returns the least common multiple of \tcode{|m|} and \tcode{|n|}. +Otherwise, returns the least common multiple of $|\tcode{m}|$ and $|\tcode{n}|$. \pnum \throws @@ -10163,7 +10168,7 @@ float hypot(float x, float y); // see \ref{library.c} double hypot(double x, double y); - long double hypot(double x, double y); // see \ref{library.c} + long double hypot(long double x, long double y); // see \ref{library.c} float hypotf(float x, float y); long double hypotl(long double x, long double y); @@ -10500,7 +10505,7 @@ the mathematical special functions described in \ref{sf.cmath}. \begin{note} Several functions have additional overloads in this International Standard, -but they have the same behavior as in the C standard library~(\ref{library.c}). +but they have the same behavior as in the C standard library\iref{library.c}. \end{note} \pnum @@ -10511,7 +10516,7 @@ \item If any argument of arithmetic type corresponding to a \tcode{double} parameter has type \tcode{long double}, - then all arguments of arithmetic type~(\ref{basic.fundamental}) + then all arguments of arithmetic type\iref{basic.fundamental} corresponding to \tcode{double} parameters are effectively cast to \tcode{long double}. \item Otherwise, if any argument of arithmetic type @@ -10540,8 +10545,8 @@ \indextext{\idxhdr{cmath}}% \indexlibrary{\idxhdr{cmath}}% \begin{note} -The headers \tcode{}~(\ref{cstdlib.syn}) and -\tcode{}~(\ref{cmath.syn}) +The headers \tcode{}\iref{cstdlib.syn} and +\tcode{}\iref{cmath.syn} declare the functions described in this subclause. \end{note} @@ -10568,7 +10573,7 @@ If \tcode{abs()} is called with an argument of type \tcode{X} for which \tcode{is_unsigned_v} is \tcode{true} and if \tcode{X} cannot be converted to \tcode{int} -by integral promotion~(\ref{conv.prom}), the program is ill-formed. +by integral promotion\iref{conv.prom}, the program is ill-formed. \begin{note} Arguments that can be promoted to \tcode{int} are permitted for compatibility with C. \end{note} diff --git a/source/overloading.tex b/source/overloading.tex index 58059376e4..64eee93e98 100644 --- a/source/overloading.tex +++ b/source/overloading.tex @@ -5,15 +5,14 @@ \gramSec[gram.over]{Overloading} \pnum -\indextext{declaration!overloaded}% \indextext{overloaded function|see{overloading}}% \indextext{function, overloaded|see{overloading}}% When two or more different declarations are specified for a single name in the same scope, that name is said to be -\defnx{overloaded}{overloading}. -By extension, two declarations in the same scope that declare the same name -but with different types are called -\term{overloaded declarations}. +\defnx{overloaded}{overloading}, +and the declarations +are called +\defnx{overloaded declarations}{declaration!overloaded}. Only function and function template declarations can be overloaded; variable and type declarations cannot be overloaded. @@ -53,7 +52,7 @@ This restriction applies to explicit declarations in a scope, and between such declarations and declarations made through a -\grammarterm{using-declaration}~(\ref{namespace.udecl}). +\grammarterm{using-declaration}\iref{namespace.udecl}. It does not apply to sets of functions fabricated as a result of name lookup (e.g., because of \grammarterm{using-directive}{s}) @@ -68,21 +67,21 @@ \item \indextext{return type!overloading and}% Function declarations that differ only in the return type, -the exception specification~(\ref{except.spec}), or both +the exception specification\iref{except.spec}, or both cannot be overloaded. \item \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 +parameter-type-list\iref{dcl.fct} cannot be overloaded if any of them is a \tcode{static} -member function declaration~(\ref{class.static}). +member function declaration\iref{class.static}. Likewise, member function template declarations with the same name, the same parameter-type-list, and the same template parameter lists cannot be overloaded if any of them is a \tcode{static} member function template declaration. The types of the implicit object parameters constructed for the member -functions for the purpose of overload resolution~(\ref{over.match.funcs}) +functions for the purpose of overload resolution\iref{over.match.funcs} are not considered when comparing parameter-type-lists for enforcement of this rule. In contrast, if there is no @@ -108,10 +107,10 @@ \end{example} \item Member function declarations with the same name and the same -parameter-type-list~(\ref{dcl.fct}) as well as member function template +parameter-type-list\iref{dcl.fct} as well as member function template declarations with the same name, the same parameter-type-list, and the same template parameter lists cannot be overloaded if any of them, but not -all, have a \grammarterm{ref-qualifier}~(\ref{dcl.fct}). \begin{example} +all, have a \grammarterm{ref-qualifier}\iref{dcl.fct}. \begin{example} \begin{codeblock} class Y { @@ -132,7 +131,9 @@ \indextext{equivalent parameter declarations!overloading and}% \begin{note} As specified in~\ref{dcl.fct}, -function declarations that have equivalent parameter declarations declare +function declarations that have equivalent parameter declarations +and \grammarterm{requires-clause}{s}, if any\iref{temp.constr.decl}, +declare the same function and therefore cannot be overloaded: @@ -143,7 +144,7 @@ ``types'' are equivalent. A \tcode{typedef} -is not a separate type, but only a synonym for another type~(\ref{dcl.typedef}). +is not a separate type, but only a synonym for another type\iref{dcl.typedef}. \begin{example} \begin{codeblock} typedef int Int; @@ -177,9 +178,9 @@ \tcode{[]} are equivalent. That is, the array declaration is adjusted to become a pointer -declaration~(\ref{dcl.fct}). +declaration\iref{dcl.fct}. Only the second and subsequent array dimensions are significant in -parameter types~(\ref{dcl.array}). +parameter types\iref{dcl.array}. \begin{example} \begin{codeblock} @@ -200,7 +201,7 @@ \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}). +That is, the function type is adjusted to become a pointer to function type\iref{dcl.fct}. \begin{example} \begin{codeblock} @@ -307,7 +308,8 @@ \pnum Two function declarations of the same name refer to the same function if they -are in the same scope and have equivalent parameter declarations~(\ref{over.load}). +are in the same scope and have equivalent parameter declarations\iref{over.load} +and equivalent \grammarterm{requires-clause}{s}, if any\iref{temp.constr.decl}. A function member of a derived class is \textit{not} in the same scope as a function member of the same name in a base class. @@ -419,29 +421,29 @@ \begin{itemize} \item -invocation of a function named in the function call syntax~(\ref{over.call.func}); +invocation of a function named in the function call syntax\iref{over.call.func}; \item invocation of a function call operator, a pointer-to-function conversion function, a reference-to-pointer-to-function conversion function, or a reference-to-function conversion function on a class object named in the function -call syntax~(\ref{over.call.object}); +call syntax\iref{over.call.object}; \item -invocation of the operator referenced in an expression~(\ref{over.match.oper}); +invocation of the operator referenced in an expression\iref{over.match.oper}; \item -invocation of a constructor for default- or direct-initialization~(\ref{dcl.init}) -of a class object~(\ref{over.match.ctor}); +invocation of a constructor for default- or direct-initialization\iref{dcl.init} +of a class object\iref{over.match.ctor}; \item invocation of a user-defined conversion for -copy-initialization~(\ref{dcl.init}) of a class object~(\ref{over.match.copy}); +copy-initialization\iref{dcl.init} of a class object\iref{over.match.copy}; \item invocation of a conversion function for initialization of an object of a -non-class type from an expression of class type~(\ref{over.match.conv}); and +non-class type from an expression of class type\iref{over.match.conv}; and \item invocation of a conversion function for conversion to a glvalue or class prvalue -to which a reference~(\ref{dcl.init.ref}) -will be directly bound~(\ref{over.match.ref}). +to which a reference\iref{dcl.init.ref} +will be directly bound\iref{over.match.ref}. \end{itemize} Each of these contexts defines the set of candidate functions and @@ -456,10 +458,10 @@ the proper number of arguments and meet certain other conditions) is selected to form a set of \indextext{function!viable}% -viable functions~(\ref{over.match.viable}). +viable functions\iref{over.match.viable}. \item Then the best viable function is selected based on the -implicit conversion sequences~(\ref{over.best.ics}) needed to +implicit conversion sequences\iref{over.best.ics} needed to match each argument to the corresponding parameter of each viable function. \end{itemize} @@ -470,7 +472,7 @@ Otherwise overload resolution fails and the invocation is ill-formed. When overload resolution succeeds, -and the best viable function is not accessible (Clause~\ref{class.access}) in the context +and the best viable function is not accessible\iref{class.access} in the context in which it is used, the program is ill-formed. @@ -559,7 +561,7 @@ \begin{note} No actual type is established for the implicit object parameter of a static member function, and no attempt will be made to determine a -conversion sequence for that parameter~(\ref{over.match.best}). +conversion sequence for that parameter\iref{over.match.best}. \end{note} \pnum @@ -582,7 +584,7 @@ as long as in all other respects the argument can be converted to the type of the implicit object parameter. \begin{note} The fact that such an argument is an rvalue does not -affect the ranking of implicit conversion sequences~(\ref{over.ics.rank}). +affect the ranking of implicit conversion sequences\iref{over.ics.rank}. \end{note} \end{itemize} @@ -625,7 +627,7 @@ no template parameter types. Therefore, except where specified otherwise, function template specializations -and non-template functions~(\ref{dcl.fct}) are treated equivalently +and non-template functions\iref{dcl.fct} are treated equivalently for the remainder of overload resolution.} A given name can refer to one or more function templates and also to a set of overloaded non-template functions. @@ -634,7 +636,7 @@ with the set of non-template candidate functions. \pnum -A defaulted move constructor or assignment operator~(\ref{class.copy}) that is +A defaulted move special function\iref{class.copy} that is defined as deleted is excluded from the set of candidate functions in all contexts. @@ -642,7 +644,7 @@ \indextext{overloading!resolution!function call syntax|(} \pnum -In a function call~(\ref{expr.call}) +In a function call\iref{expr.call} \begin{ncsimplebnf} postfix-expression \terminal{(} expression-list\opt{} \terminal{)} @@ -697,12 +699,12 @@ is generally equivalent to \tcode{(*A).B}, the rest of -Clause~\ref{over} assumes, without loss of generality, that all member +\ref{over} assumes, without loss of generality, that all member function calls have been normalized to the form that uses an object and the \tcode{.} operator. -Furthermore, Clause~\ref{over} assumes that +Furthermore, \ref{over} assumes that the \grammarterm{postfix-expression} that is the left operand of the @@ -722,7 +724,7 @@ member function of \tcode{T} following the rules for looking up names in -classes~(\ref{class.member.lookup}). +classes\iref{class.member.lookup}. The function declarations found by that lookup constitute the set of candidate functions. The argument list is the @@ -731,7 +733,7 @@ the \tcode{.} operator in the normalized member function call as the -implied object argument~(\ref{over.match.funcs}). +implied object argument\iref{over.match.funcs}. \pnum In unqualified function calls, the name is not qualified by an @@ -742,7 +744,7 @@ \grammarterm{primary-expression}. The name is looked up in the context of the function call following the normal rules for name lookup in function -calls~(\ref{basic.lookup}). +calls\iref{basic.lookup}. The function declarations found by that lookup constitute the set of candidate functions. Because of the rules for name lookup, the set of candidate functions @@ -759,7 +761,7 @@ in the call augmented by the addition of an implied object argument as in a qualified function call. If the keyword -\tcode{this}~(\ref{class.this}) is in scope and refers to +\tcode{this}\iref{class.this} is in scope and refers to class \tcode{T}, or a derived class of @@ -793,7 +795,7 @@ \pnum If the -\grammarterm{primary-expression} +\grammarterm{postfix-expression} \tcode{E} in the function call syntax evaluates to a class object of type ``\cv{}~\tcode{T}'', @@ -907,7 +909,7 @@ \pnum If no operand of an operator in an expression has a type that is a class or an enumeration, the operator is assumed to be a built-in operator -and interpreted according to Clause~\ref{expr}. +and interpreted according to \ref{expr}. \begin{note} Because \tcode{.}, @@ -916,11 +918,11 @@ \tcode{::} cannot be overloaded, these operators are always built-in operators interpreted according to -Clause~\ref{expr}. +\ref{expr}. \tcode{?:} cannot be overloaded, but the rules in this subclause are used to determine the conversions to be applied to the second and third operands when they -have class or enumeration type~(\ref{expr.cond}). +have class or enumeration type\iref{expr.cond}. \end{note} \begin{example} @@ -954,7 +956,7 @@ Table~\ref{tab:over.rel.op.func} (where \tcode{@} denotes one of the operators covered in the specified subclause). However, the operands are sequenced in the order prescribed -for the built-in operator (Clause~\ref{expr}). +for the built-in operator\iref{expr}. \begin{floattable}{Relationship between operator and function call notation}{tab:over.rel.op.func} {l|m|m|m} @@ -991,14 +993,14 @@ \tcode{T1} is a complete class type or a class currently being defined, the set of member candidates is the result of the qualified lookup of -\tcode{T1::operator@}~(\ref{over.call.func}); otherwise, the set of member +\tcode{T1::operator@}\iref{over.call.func}; otherwise, the set of member candidates is empty. \item The set of non-member candidates is the result of the unqualified lookup of \tcode{operator@} in the context of the expression according to the usual rules for name -lookup in unqualified function calls~(\ref{basic.lookup.argdep}) except +lookup in unqualified function calls\iref{basic.lookup.argdep} except that all member functions are ignored. However, if no operand has a class type, only those non-member functions in the lookup set that have a first parameter of type @@ -1084,9 +1086,9 @@ If a built-in candidate is selected by overload resolution, the operands of class type are converted to the types of the corresponding parameters of the selected operation function, except that the second standard conversion -sequence of a user-defined conversion sequence~(\ref{over.ics.user}) is not applied. +sequence of a user-defined conversion sequence\iref{over.ics.user} is not applied. Then the operator is treated as the corresponding -built-in operator and interpreted according to Clause~\ref{expr}. +built-in operator and interpreted according to \ref{expr}. \begin{example} \begin{codeblock} struct X { @@ -1133,7 +1135,7 @@ \tcode{->}, and there are no viable functions, then the operator is assumed to be the built-in operator and interpreted according to -Clause~\ref{expr}. +\ref{expr}. \pnum \begin{note} @@ -1164,10 +1166,10 @@ \indextext{overloading!resolution!initialization} \pnum -When objects of class type are direct-initialized~(\ref{dcl.init}), +When objects of class type are direct-initialized\iref{dcl.init}, copy-initialized from an expression of the same or a -derived class type~(\ref{dcl.init}), -or default-initialized~(\ref{dcl.init}), +derived class type\iref{dcl.init}, +or default-initialized\iref{dcl.init}, overload resolution selects the constructor. For direct-initialization or default-initialization that is not in the context of copy-initialization, the @@ -1175,7 +1177,7 @@ all the constructors of the class of the object being initialized. For copy-initialization, the candidate functions are all -the converting constructors~(\ref{class.conv.ctor}) of that +the converting constructors\iref{class.conv.ctor} of that class. The argument list is the \grammarterm{expression-list} or \grammarterm{assignment-expression} @@ -1202,7 +1204,7 @@ \begin{itemize} \item -The converting constructors~(\ref{class.conv.ctor}) of +The converting constructors\iref{class.conv.ctor} of \tcode{T} are candidate functions. \item @@ -1211,8 +1213,8 @@ the non-explicit conversion functions of \tcode{S} and its base classes are considered. -When initializing a temporary to be bound to the first parameter of a -constructor +When initializing a temporary object\iref{class.mem} +to be bound to the first parameter of a constructor where the parameter is of type ``reference to possibly \cv-qualified \tcode{T}'' and the constructor is @@ -1275,11 +1277,11 @@ \tcode{T} or a type that can be converted to type \tcode{T} -via a standard conversion sequence~(\ref{over.ics.scs}) +via a standard conversion sequence\iref{over.ics.scs} are candidate functions. For direct-initialization, those explicit conversion functions that are not hidden within \tcode{S} and yield type \tcode{T} or a type that can be converted -to type \tcode{T} with a qualification conversion~(\ref{conv.qual}) are also +to type \tcode{T} with a qualification conversion\iref{conv.qual} are also candidate functions. Conversion functions that return a cv-qualified type are considered to yield the cv-unqualified version of that type @@ -1332,7 +1334,7 @@ ``\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}) +where ``\cvqual{cv1} \tcode{T}'' is reference-compatible\iref{dcl.init.ref} with ``\cvqual{cv2} \tcode{T2}'', are candidate functions. For direct-initialization, those explicit conversion functions that are not hidden within \tcode{S} and yield @@ -1340,7 +1342,7 @@ \tcode{T2}'' or ``rvalue reference to \cvqual{cv2} \tcode{T2}'', respectively, where \tcode{T2} is the same type as \tcode{T} or can be converted to type \tcode{T} with a qualification -conversion~(\ref{conv.qual}), are also candidate functions. +conversion\iref{conv.qual}, are also candidate functions. \end{itemize} @@ -1362,7 +1364,7 @@ \begin{itemize} \item -Initially, the candidate functions are the initializer-list constructors~(\ref{dcl.init.list}) +Initially, the candidate functions are the initializer-list constructors\iref{dcl.init.list} of the class \tcode{T} and the argument list consists of the initializer list as a single argument. @@ -1377,7 +1379,7 @@ the first phase is omitted. In copy-list-initialization, if an \tcode{explicit} constructor is chosen, the initialization is ill-formed. \begin{note} -This differs from other situations (\ref{over.match.ctor},~\ref{over.match.copy}), +This differs from other situations~(\ref{over.match.ctor}, \ref{over.match.copy}), where only converting constructors are considered for copy-initialization. This restriction only applies if this initialization is part of the final result of overload @@ -1387,18 +1389,17 @@ \indextext{deduction!class template arguments}% \pnum -A set of functions and function templates is formed comprising: - +When resolving a placeholder for a deduced class type\iref{dcl.type.class.deduct} +where the \grammarterm{template-name} names a primary class template \tcode{C}, +a set of functions and function templates is formed comprising: \begin{itemize} \item -For each constructor -of the primary class template -designated by the \grammarterm{template-name}, -if the template is defined, +If \tcode{C} is defined, +for each constructor of \tcode{C}, a function template with the following properties: \begin{itemize} \item -The template parameters are the template parameters of the class template +The template parameters are the template parameters of \tcode{C} followed by the template parameters (including default template arguments) of the constructor, if any. @@ -1406,14 +1407,13 @@ The types of the function parameters are those of the constructor. \item The return type is the class template specialization -designated by the \grammarterm{template-name} +designated by \tcode{C} and template arguments -corresponding to the template parameters -obtained from the class template. +corresponding to the template parameters of \tcode{C}. \end{itemize} \item -If the primary class template \tcode{C} +If \tcode{C} is not defined or does not declare any constructors, an additional function template derived as above from a hypothetical constructor \tcode{C()}. @@ -1448,7 +1448,14 @@ the selected functions and function templates are considered to be the constructors of that class type for the purpose of forming an overload set, and the initializer is provided by the context in which class -template argument deduction was performed. Each such notional constructor +template argument deduction was performed. +As an exception, the first phase in \ref{over.match.list} +(considering initializer-list constructors) +is omitted if the initializer list consists of +a single expression of type \cv{}~\tcode{U}, +where \tcode{U} is a specialization of \tcode{C} or +a class derived from a specialization of \tcode{C}. +Each such notional constructor is considered to be explicit if the function or function template was generated from a constructor or \grammarterm{deduction-guide} that was declared \tcode{explicit}. @@ -1495,10 +1502,13 @@ \pnum From the set of candidate functions constructed for a given -context~(\ref{over.match.funcs}), a set of viable functions is +context\iref{over.match.funcs}, a set of viable functions is chosen, from which the best function will be selected by -comparing argument conversion sequences for the best fit~(\ref{over.match.best}). +comparing argument conversion sequences +and associated constraints\iref{temp.constr.decl} +for the best fit\iref{over.match.best}. The selection of viable functions considers +associated constraints, if any, and relationships between arguments and function parameters other than the ranking of conversion sequences. @@ -1521,10 +1531,10 @@ A candidate function having fewer than \textit{m} parameters is -viable only if it has an ellipsis in its parameter list~(\ref{dcl.fct}). +viable only if it has an ellipsis in its parameter list\iref{dcl.fct}. For the purposes of overload resolution, any argument for which there is no corresponding parameter is -considered to ``match the ellipsis''~(\ref{over.ics.ellipsis}) . +considered to ``match the ellipsis''\iref{over.ics.ellipsis} . \item A candidate function having more than \textit{m} @@ -1532,7 +1542,7 @@ only if the \textit{(m+1)}-st parameter has a default -argument~(\ref{dcl.fct.default}).\footnote{According to~\ref{dcl.fct.default}, +argument\iref{dcl.fct.default}.\footnote{According to~\ref{dcl.fct.default}, parameters following the \textit{(m+1)}-st parameter must also have default arguments.} @@ -1544,11 +1554,15 @@ \end{itemize} \pnum -Second, for +Second, for a function to be viable, if it has associated constraints, +those constraints shall be satisfied\iref{temp.constr.decl}. + +\pnum +Third, for \tcode{F} to be a viable function, there shall exist for each argument an -\term{implicit conversion sequence}~(\ref{over.best.ics}) that +\term{implicit conversion sequence}\iref{over.best.ics} that converts that argument to the corresponding parameter of \tcode{F}. If the parameter has reference type, the implicit conversion sequence @@ -1637,7 +1651,7 @@ or, if not that, \item the context is an initialization by conversion function for direct -reference binding (\ref{over.match.ref}) of a reference to function type, the +reference binding\iref{over.match.ref} of a reference to function type, the 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} @@ -1676,13 +1690,42 @@ according to the partial ordering rules described in~\ref{temp.func.order}, or, if not that, +\item +\tcode{F1} and \tcode{F2} are non-template functions with the same +parameter-type-lists, and \tcode{F1} is more constrained than \tcode{F2} +according to the partial ordering of constraints described in +\ref{temp.constr.order}, or if not that, + +\item +\tcode{F1} is a constructor for a class \tcode{D}, +\tcode{F2} is a constructor for a base class \tcode{B} of \tcode{D}, and +for all arguments +the corresponding parameters of \tcode{F1} and \tcode{F2} have the same type. +\begin{example} +\begin{codeblock} +struct A { + A(int = 0); +}; + +struct B: A { + using A::A; + B(); +}; + +int main() { + B b; // OK, \tcode{B::B()} +} +\end{codeblock} +\end{example} +or, if not that, + \item \tcode{F1} is generated from a -\grammarterm{deduction-guide}~(\ref{over.match.class.deduct}) +\grammarterm{deduction-guide}\iref{over.match.class.deduct} and \tcode{F2} is not, or, if not that, \item -\tcode{F1} is the copy deduction candidate~(\ref{over.match.class.deduct}) +\tcode{F1} is the copy deduction candidate\iref{over.match.class.deduct} and \tcode{F2} is not, or, if not that, \item @@ -1814,7 +1857,7 @@ corresponding parameter of the function being called. The sequence of conversions is an implicit conversion as defined in -Clause~\ref{conv}, which means it is governed by the rules for +\ref{conv}, which means it is governed by the rules for initialization of an object or reference by a single expression~(\ref{dcl.init}, \ref{dcl.init.ref}). @@ -1825,7 +1868,7 @@ parameter. Other properties, such as the lifetime, storage class, alignment, accessibility of the argument, whether the argument is a bit-field, -and whether a function is deleted~(\ref{dcl.fct.def.delete}), are ignored. +and whether a function is deleted\iref{dcl.fct.def.delete}, are ignored. So, although an implicit conversion sequence can be defined for a given argument-parameter pair, the conversion from the argument to the parameter might still @@ -1839,13 +1882,13 @@ \begin{itemize} \item a -\term{standard conversion sequence}~(\ref{over.ics.scs}), +\term{standard conversion sequence}\iref{over.ics.scs}, \item a -\term{user-defined conversion sequence}~(\ref{over.ics.user}), or +\term{user-defined conversion sequence}\iref{over.ics.user}, or \item an -\term{ellipsis conversion sequence}~(\ref{over.ics.ellipsis}). +\term{ellipsis conversion sequence}\iref{over.ics.ellipsis}. \end{itemize} \pnum @@ -1896,7 +1939,7 @@ the parameter. \begin{note} When the parameter has a class type, this is a conceptual conversion -defined for the purposes of Clause~\ref{over}; the actual initialization is +defined for the purposes of \ref{over}; the actual initialization is defined in terms of constructors and is not a conversion. \end{note} Any difference in top-level cv-qualification is @@ -1923,7 +1966,7 @@ There is no such standard conversion; this derived-to-base Conversion exists only in the description of implicit conversion sequences. \end{note} -A derived-to-base Conversion has Conversion rank~(\ref{over.ics.scs}). +A derived-to-base Conversion has Conversion rank\iref{over.ics.scs}. \pnum In all contexts, when converting to the implicit object parameter @@ -1933,7 +1976,7 @@ \pnum If no conversions are required to match an argument to a parameter type, the implicit conversion sequence is the standard -conversion sequence consisting of the identity conversion~(\ref{over.ics.scs}). +conversion sequence consisting of the identity conversion\iref{over.ics.scs}. \pnum If no sequence of conversions can be found to convert an argument @@ -1981,7 +2024,7 @@ \pnum Table~\ref{tab:over.conversions} -summarizes the conversions defined in Clause~\ref{conv} and +summarizes the conversions defined in \ref{conv} and partitions them into four disjoint categories: Lvalue Transformation, Qualification Adjustment, Promotion, and Conversion. \begin{note} @@ -1996,7 +2039,7 @@ \pnum \begin{note} -As described in Clause~\ref{conv}, +As described in \ref{conv}, a standard conversion sequence is either the Identity conversion by itself (that is, no conversion) or consists of one to three conversions from the other @@ -2016,10 +2059,10 @@ also has an associated rank (Exact Match, Promotion, or Conversion). These are used -to rank standard conversion sequences~(\ref{over.ics.rank}). +to rank standard conversion sequences\iref{over.ics.rank}. The rank of a conversion sequence is determined by considering the rank of each conversion in the sequence and the rank of any reference -binding~(\ref{over.ics.ref}). +binding\iref{over.ics.ref}. If any of those has Conversion rank, the sequence has Conversion rank; otherwise, if any of those has Promotion rank, the sequence has Promotion rank; otherwise, the sequence has Exact @@ -2049,14 +2092,14 @@ \pnum A user-defined conversion sequence consists of an initial standard conversion sequence followed by a user-defined -conversion~(\ref{class.conv}) followed by a second standard +conversion\iref{class.conv} followed by a second standard conversion sequence. If the user-defined conversion is specified -by a constructor~(\ref{class.conv.ctor}), the initial standard +by a constructor\iref{class.conv.ctor}, the initial standard conversion sequence converts the source type to the type required by the argument of the constructor. If the user-defined -conversion is specified by a conversion function~(\ref{class.conv.fct}), the +conversion is specified by a conversion function\iref{class.conv.fct}, the initial standard conversion sequence converts the source type to the implicit object parameter of the conversion function. @@ -2094,11 +2137,11 @@ \rSec4[over.ics.ref]{Reference binding} \pnum -When a parameter of reference type binds directly~(\ref{dcl.init.ref}) to an +When a parameter of reference type binds directly\iref{dcl.init.ref} to an argument expression, the implicit conversion sequence is the identity conversion, unless the argument expression has a type that is a derived class of the parameter type, in which case the implicit conversion sequence is a derived-to-base -Conversion~(\ref{over.best.ics}). +Conversion\iref{over.best.ics}. \begin{example} \begin{codeblock} @@ -2111,7 +2154,7 @@ \end{example} If the parameter binds directly to the result of applying a conversion function to the argument expression, the implicit -conversion sequence is a user-defined conversion sequence~(\ref{over.ics.user}), +conversion sequence is a user-defined conversion sequence\iref{over.ics.user}, with the second standard conversion sequence either an identity conversion or, if the conversion function returns an entity of a type that is a derived class of the parameter type, a derived-to-base Conversion. @@ -2160,17 +2203,52 @@ match with the parameter. If the function is selected by overload resolution, the call will nonetheless be ill-formed because of -the prohibition on binding a non-\tcode{const} lvalue reference to a bit-field~(\ref{dcl.init.ref}). +the prohibition on binding a non-\tcode{const} lvalue reference to a bit-field\iref{dcl.init.ref}. \end{example} \rSec4[over.ics.list]{List-initialization sequence} \pnum -When an argument is an initializer list~(\ref{dcl.init.list}), it is not an +When an argument is an initializer list\iref{dcl.init.list}, it is not an expression and special rules apply for converting it to a parameter type. \pnum -If the parameter type is an aggregate class \tcode{X} and the initializer list has a +If the initializer list is a \grammarterm{designated-initializer-list}, +a conversion is only possible if +the parameter has an aggregate type +that can be initialized from the initializer list +according to the rules for aggregate initialization\iref{dcl.init.aggr}, +in which case the implicit conversion sequence is +a user-defined conversion sequence +whose second standard conversion sequence +is an identity conversion. +\begin{note} +Aggregate initialization does not require that +the members are declared in designation order. +If, after overload resolution, the order does not match +for the selected overload, +the initialization of the parameter will be ill-formed\iref{dcl.init.list}. +\begin{example} +\begin{codeblock} +struct A { int x, y; }; +struct B { int y, x; }; +void f(A a, int); // \#1 +void f(B b, ...); // \#2 +void g(A a); // \#3 +void g(B b); // \#4 +void h() { + f({.x = 1, .y = 2}, 0); // OK; calls \#1 + f({.y = 2, .x = 1}, 0); // error: selects \#1, initialization of \tcode{a} fails + // due to non-matching member order\iref{dcl.init.list} + g({.x = 1, .y = 2}); // error: ambiguous between \#3 and \#4 +} +\end{codeblock} +\end{example} +\end{note} + +\pnum +Otherwise, +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} or a class derived from \tcode{X}, the implicit conversion sequence is the one required to convert the element to the parameter type. @@ -2180,7 +2258,7 @@ \footnote{Since there are no parameters of array type, this will only occur as the referenced type of a reference parameter.} and the initializer list has a single element that is an appropriately-typed -string literal~(\ref{dcl.init.string}), the implicit conversion +string literal\iref{dcl.init.string}, the implicit conversion sequence is the identity conversion. \pnum @@ -2278,7 +2356,7 @@ \pnum Otherwise, if the parameter has an aggregate type which can be initialized from the initializer list according to the rules for aggregate -initialization~(\ref{dcl.init.aggr}), the implicit conversion sequence is a +initialization\iref{dcl.init.aggr}, the implicit conversion sequence is a user-defined conversion sequence with the second standard conversion sequence an identity conversion. \begin{example} \begin{codeblock} @@ -2362,13 +2440,13 @@ \begin{itemize} \item -a standard conversion sequence~(\ref{over.ics.scs}) is a better +a standard conversion sequence\iref{over.ics.scs} is a better conversion sequence than a user-defined conversion sequence or an ellipsis conversion sequence, and \item -a user-defined conversion sequence~(\ref{over.ics.user}) is a +a user-defined conversion sequence\iref{over.ics.user} is a better conversion sequence than an ellipsis conversion -sequence~(\ref{over.ics.ellipsis}). +sequence\iref{over.ics.ellipsis}. \end{itemize} \pnum @@ -2435,7 +2513,7 @@ in the paragraph below, or, if not that, -\item \tcode{S1} and \tcode{S2} are reference bindings~(\ref{dcl.init.ref}) and +\item \tcode{S1} and \tcode{S2} are reference bindings\iref{dcl.init.ref} and neither refers to an implicit object parameter of a non-static member function declared without a \grammarterm{ref-qualifier}, and \tcode{S1} binds an rvalue reference to an @@ -2469,7 +2547,7 @@ or, if not that, \item -\tcode{S1} and \tcode{S2} are reference bindings~(\ref{dcl.init.ref}) and +\tcode{S1} and \tcode{S2} are reference bindings\iref{dcl.init.ref} and \tcode{S1} binds an lvalue reference to a function lvalue and \tcode{S2} binds an rvalue reference to a function lvalue \begin{example} @@ -2489,7 +2567,7 @@ differ only in their qualification conversion and yield similar types \tcode{T1} and -\tcode{T2}~(\ref{conv.qual}), respectively, and the cv-qualification signature of type +\tcode{T2}\iref{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} @@ -2507,7 +2585,7 @@ \tcode{S1} and \tcode{S2} -are reference bindings~(\ref{dcl.init.ref}), and the types to which the references +are reference bindings\iref{dcl.init.ref}, and the types to which the references refer are the same type except for top-level cv-qualifiers, and the type to which the reference initialized by \tcode{S2} @@ -2732,7 +2810,7 @@ in such contexts. A function with type \tcode{F} is selected for the function type \tcode{FT} of the target type required in the context if \tcode{F} -(after possibly applying the function pointer conversion~(\ref{conv.fctptr})) +(after possibly applying the function pointer conversion\iref{conv.fctptr}) is identical to \tcode{FT}. \begin{note} That is, the class of which the function is a member is ignored when matching a @@ -2745,19 +2823,19 @@ an object or reference being initialized~(\ref{dcl.init}, \ref{dcl.init.ref}, \ref{dcl.init.list}), \item -the left side of an assignment~(\ref{expr.ass}), +the left side of an assignment\iref{expr.ass}, \item -a parameter of a function~(\ref{expr.call}), +a parameter of a function\iref{expr.call}, \item -a parameter of a user-defined operator~(\ref{over.oper}), +a parameter of a user-defined operator\iref{over.oper}, \item -the return value of a function, operator function, or conversion~(\ref{stmt.return}), +the return value of a function, operator function, or conversion\iref{stmt.return}, \item an explicit type conversion~(\ref{expr.type.conv}, \ref{expr.static.cast}, \ref{expr.cast}), or \item a non-type -\grammarterm{template-parameter}~(\ref{temp.arg.nontype}). +\grammarterm{template-parameter}\iref{temp.arg.nontype}. \end{itemize} The overloaded function name can be preceded by the @@ -2767,12 +2845,12 @@ other than those listed. \begin{note} Any redundant set of parentheses surrounding the overloaded function name is -ignored~(\ref{expr.prim}). +ignored\iref{expr.prim}. \end{note} \pnum If the name is a function template, template argument deduction is -done~(\ref{temp.deduct.funcaddr}), and if the argument deduction succeeds, +done\iref{temp.deduct.funcaddr}, and if the argument deduction succeeds, the resulting template argument list is used to generate a single @@ -2802,12 +2880,24 @@ described in~\ref{expr.unary.op}. \pnum -If more than one function is selected, any -function template specializations +All functions with +associated constraints +that are not satisfied\iref{temp.constr.decl} +are eliminated from the set of selected functions. +If more than one function in the set remains, +all function template specializations in the set are eliminated if the set also contains a function that is not a -function template specialization, and -any given +function template specialization. +Any given non-template function +\tcode{F0} +is eliminated if the set contains a second +non-template function that +is more constrained than +\tcode{F0} +according to +the partial ordering rules of \ref{temp.constr.order}. +Any given function template specialization \tcode{F1} is eliminated if the set contains a second @@ -2926,8 +3016,8 @@ \end{bnfkeywordtab} \begin{note} -The last two operators are function call~(\ref{expr.call}) -and subscripting~(\ref{expr.sub}). +The last two operators are function call\iref{expr.call} +and subscripting\iref{expr.sub}. The operators \tcode{new[]}, \tcode{delete[]}, @@ -2959,8 +3049,7 @@ nor can the preprocessing symbols \tcode{\#} and -\tcode{\#\#} -(Clause~\ref{cpp}). +\tcode{\#\#}\iref{cpp}. \pnum \indextext{call!operator function}% @@ -2968,7 +3057,7 @@ to evaluate the operators they implement~(\ref{over.unary} -- \ref{over.inc}). They can be explicitly called, however, using the \grammarterm{operator-function-id} -as the name of the function in the function call syntax~(\ref{expr.call}). +as the name of the function in the function call syntax\iref{expr.call}. \begin{example} \begin{codeblock} @@ -3028,7 +3117,7 @@ \pnum \indextext{argument!overloaded operator and default}% -An operator function cannot have default arguments~(\ref{dcl.fct.default}), +An operator function cannot have default arguments\iref{dcl.fct.default}, except where explicitly stated below. Operator functions cannot have more or fewer parameters than the @@ -3048,7 +3137,7 @@ \pnum A prefix unary operator shall be implemented by a -non-static member function~(\ref{class.mfct}) with no parameters or a +non-static member function\iref{class.mfct} with no parameters or a non-member function with one parameter. \indextext{unary operator!interpretation of}% Thus, for any prefix unary operator @@ -3080,7 +3169,7 @@ \pnum A binary operator shall be implemented either by a non-static member -function~(\ref{class.mfct}) +function\iref{class.mfct} with one parameter or by a non-member function with two parameters. \indextext{binary operator!interpretation of}% Thus, for any binary operator @@ -3104,7 +3193,7 @@ exactly one parameter. Because a copy assignment operator \tcode{operator=} -is implicitly declared for a class if not declared by the user~(\ref{class.copy}), +is implicitly declared for a class if not declared by the user\iref{class.copy}, a base class assignment operator is always hidden by the copy assignment operator of the derived class. @@ -3182,7 +3271,7 @@ \tcode{T2,} \tcode{T3)} exists and if the operator is selected as the best match function by -the overload resolution mechanism~(\ref{over.match.best}). +the overload resolution mechanism\iref{over.match.best}. \rSec2[over.sub]{Subscripting}% \indextext{subscripting operator!overloaded}% @@ -3208,7 +3297,7 @@ if \tcode{T::op\-er\-a\-tor[]\-(T1)} exists and if the operator is selected as the best match function by -the overload resolution mechanism~(\ref{over.match.best}). +the overload resolution mechanism\iref{over.match.best}. \begin{example} \begin{codeblock} struct X { @@ -3247,7 +3336,7 @@ if \tcode{T::operator->()} exists and if the operator is selected as the best match function by -the overload resolution mechanism~(\ref{over.match}). +the overload resolution mechanism\iref{over.match}. \rSec2[over.inc]{Increment and decrement} \indextext{increment operator!overloaded|see{overloading, increment operator}}% @@ -3343,8 +3432,8 @@ A declaration whose \grammarterm{declarator-id} is a \grammarterm{literal-operator-id} shall be a declaration of a namespace-scope function or function template (it could be a friend -function~(\ref{class.friend})), an explicit instantiation or specialization of a -function template, or a \grammarterm{using-declaration}~(\ref{namespace.udecl}). +function\iref{class.friend}), an explicit instantiation or specialization of a +function template, or a \grammarterm{using-declaration}\iref{namespace.udecl}. A function declared with a \grammarterm{literal-operator-id} is a \term{literal operator}. A function template declared with a \grammarterm{literal-operator-id} is a \term{literal operator template}. @@ -3367,7 +3456,7 @@ const char32_t*, std::size_t \end{codeblock} -If a parameter has a default argument~(\ref{dcl.fct.default}), the program is +If a parameter has a default argument\iref{dcl.fct.default}, the program is ill-formed. \pnum @@ -3379,14 +3468,14 @@ \grammarterm{parameter-declaration-clause} and its \grammarterm{template-parameter-list} shall have a single \grammarterm{template-parameter} that is a non-type template parameter -pack (\ref{temp.variadic}) with element type \tcode{char}. +pack\iref{temp.variadic} with element type \tcode{char}. \pnum Literal operators and literal operator templates shall not have C language linkage. \pnum \begin{note} Literal operators and literal operator templates are usually invoked -implicitly through user-defined literals~(\ref{lex.ext}). However, except for +implicitly through user-defined literals\iref{lex.ext}. However, except for the constraints described above, they are ordinary namespace-scope functions and function templates. In particular, they are looked up like ordinary functions and function templates and they follow the same overload resolution rules. Also, @@ -3402,8 +3491,8 @@ template double operator "" _\u03C0(); // OK: UCN for lowercase pi float operator ""_e(const char*); // OK float operator ""E(const char*); // error: reserved literal suffix~(\ref{usrlit.suffix}, \ref{lex.ext}) -double operator""_Bq(long double); // OK: does not use the reserved identifier \tcode{_Bq}~(\ref{lex.name}) -double operator"" _Bq(long double); // uses the reserved identifier \tcode{_Bq}~(\ref{lex.name}) +double operator""_Bq(long double); // OK: does not use the reserved identifier \tcode{_Bq}\iref{lex.name} +double operator"" _Bq(long double); // uses the reserved identifier \tcode{_Bq}\iref{lex.name} float operator " " B(const char*); // error: non-empty \grammarterm{string-literal} string operator "" 5X(const char*, std::size_t); // error: invalid literal suffix identifier double operator "" _miles(double); // error: invalid \grammarterm{parameter-declaration-clause} @@ -3418,7 +3507,7 @@ \pnum The candidate operator functions that represent the built-in operators -defined in Clause~\ref{expr} are specified in this subclause. +defined in \ref{expr} are specified in this subclause. These candidate functions participate in the operator overload resolution process as described in~\ref{over.match.oper} and are used for no other purpose. @@ -3436,7 +3525,7 @@ As described in~\ref{over.match.oper}, after a built-in operator is selected by overload resolution the expression is subject to the requirements for -the built-in operator given in Clause~\ref{expr}, and therefore to any +the built-in operator given in \ref{expr}, and therefore to any additional semantic constraints given there. If there is a user-written candidate with the same name and parameter types as a built-in @@ -3450,7 +3539,7 @@ In this subclause, the term \defn{promoted integral type} is used to refer to those integral types which are preserved by -integral promotion~(\ref{conv.prom}) (including e.g. +integral promotion\iref{conv.prom} (including e.g. \tcode{int} and \tcode{long} diff --git a/source/preprocessor.tex b/source/preprocessor.tex index fda5256780..81bf2b3b17 100644 --- a/source/preprocessor.tex +++ b/source/preprocessor.tex @@ -141,7 +141,7 @@ semantics. \pnum -When in a group that is skipped~(\ref{cpp.cond}), the directive +When in a group that is skipped\iref{cpp.cond}, the directive syntax is relaxed to allow any sequence of preprocessing tokens to occur between the directive name and the following new-line character. @@ -267,7 +267,7 @@ Each preprocessing token that remains (in the list of preprocessing tokens that will become the controlling expression) after all macro replacements have occurred -shall be in the lexical form of a token~(\ref{lex.token}). +shall be in the lexical form of a token\iref{lex.token}. \pnum Preprocessing directives of the forms @@ -314,7 +314,7 @@ and then each preprocessing token is converted into a token. \begin{note} An alternative -token~(\ref{lex.digraph}) is not an identifier, +token\iref{lex.digraph} is not an identifier, even when its spelling consists entirely of letters and underscores. Therefore it is not subject to this replacement. \end{note} @@ -326,14 +326,14 @@ in~\ref{support.limits}. For the purposes of this token conversion and evaluation all signed and unsigned integer types act as if they have the same representation as, respectively, -\tcode{intmax_t} or \tcode{uintmax_t}~(\ref{cstdint}). +\tcode{intmax_t} or \tcode{uintmax_t}\iref{cstdint}. \begin{note} Thus on an implementation where \tcode{std::numeric_limits::max()} is \tcode{0x7FFF} and \tcode{std::numeric_limits::max()} is \tcode{0xFFFF}, the integer literal \tcode{0x8000} is signed and positive within a \tcode{\#if} expression even though it is unsigned in translation phase -7~(\ref{lex.phases}). +7\iref{lex.phases}. \end{note} This includes interpreting character literals, which may involve converting escape sequences into execution character set members. @@ -528,7 +528,7 @@ \pnum The implementation shall provide unique mappings for sequences consisting of one or more -\grammarterm{nondigit}{s} or \grammarterm{digit}{s}~(\ref{lex.name}) +\grammarterm{nondigit}{s} or \grammarterm{digit}{s}\iref{lex.name} followed by a period (\tcode{.}) and a single @@ -622,7 +622,8 @@ an ellipsis, the number of arguments (including those arguments consisting of no preprocessing tokens) in an invocation of a function-like macro shall -equal the number of parameters in the macro definition. Otherwise, there shall be more arguments in the invocation than there are +equal the number of parameters in the macro definition. +Otherwise, there shall be at least as many arguments in the invocation as there are parameters in the macro definition (excluding the \tcode{...}). There shall exist a \tcode{)} @@ -630,7 +631,9 @@ \pnum \indextext{__VA_ARGS__@\mname{VA_ARGS}}% -The identifier \mname{VA_ARGS} shall occur only in the \grammarterm{replacement-list} +\indextext{__VA_OPT__@\mname{VA_OPT}}% +The identifiers \mname{VA_ARGS} and \mname{VA_OPT} +shall occur only in the \grammarterm{replacement-list} of a function-like macro that uses the ellipsis notation in the parameters. \pnum @@ -675,7 +678,7 @@ (see \ref{lex.phases}, translation phases), they are never scanned for macro names or parameters.} to be replaced by the replacement list of preprocessing tokens -that constitute the remainder of the directive.\footnote{An alternative token~(\ref{lex.digraph}) is not an identifier, +that constitute the remainder of the directive.\footnote{An alternative token\iref{lex.digraph} is not an identifier, even when its spelling consists entirely of letters and underscores. Therefore it is not possible to define a macro whose name is the same as that of an alternative token.} @@ -731,9 +734,10 @@ \indextext{macro!function-like!arguments}% If there is a \tcode{...} immediately preceding the \tcode{)} in the function-like macro -definition, then the trailing arguments, including any separating comma preprocessing +definition, then the trailing arguments (if any), including any separating comma preprocessing tokens, are merged to form a single item: the \term{variable arguments}. The number of arguments so combined is such that, following merger, the number of arguments is +either equal to or one more than the number of parameters in the macro definition (excluding the \tcode{...}). @@ -760,10 +764,60 @@ no other preprocessing tokens are available. \pnum +\indextext{__VA_ARGS__@\mname{VA_ARGS}}% An identifier \mname{VA_ARGS} that occurs in the replacement list shall be treated as if it were a parameter, and the variable arguments shall form the preprocessing tokens used to replace it. +\pnum +\indextext{__VA_OPT__@\mname{VA_OPT}}% +The identifier \mname{VA_OPT} +shall always occur as part of the token sequence +\mname{VA_OPT}\tcode{(}\placeholder{content}\tcode{)}, +where \placeholder{content} is +an arbitrary sequence of \grammarterm{preprocessing-tokens} +other than \mname{VA_OPT}, +which is terminated by the closing \tcode{)} +and skips intervening pairs of matching left and right parentheses. +If \placeholder{content} would be ill-formed +as the replacement list of the current function-like macro, +the program is ill-formed. +The token sequence +\mname{VA_OPT}\tcode{(}\placeholder{content}\tcode{)} +shall be treated as if it were a parameter, +and the preprocessing tokens used to replace it +are defined as follows. +If the variable arguments consist of no tokens, +the replacement consists of +a single placemarker preprocessing token~(\ref{cpp.concat}, \ref{cpp.rescan}). +Otherwise, the replacement consists of +the results of the expansion of \placeholder{content} +as the replacement list of the current function-like macro +before rescanning and further replacement. +\begin{example} +\begin{codeblock} +#define F(...) f(0 __VA_OPT__(,) __VA_ARGS__) +#define G(X, ...) f(0, X __VA_OPT__(,) __VA_ARGS__) +#define SDEF(sname, ...) S sname __VA_OPT__(= { __VA_ARGS__ }) + +F(a, b, c) // replaced by \tcode{f(0, a, b, c)} +F() // replaced by \tcode{f(0)} + +G(a, b, c) // replaced by \tcode{f(0, a, b, c)} +G(a, ) // replaced by \tcode{f(0, a)} +G(a) // replaced by \tcode{f(0, a)} + +SDEF(foo); // replaced by \tcode{S foo;} +SDEF(bar, 1, 2); // replaced by \tcode{S bar = \{ 1, 2 \};} + +#define H1(X, ...) X __VA_OPT__(##) __VA_ARGS__ // ill-formed: \tcode{\#\#} may not appear at + // the beginning of a replacement list\iref{cpp.concat} +#define H2(X, Y, ...) __VA_OPT__(X ## Y,) __VA_ARGS__ + +H2(a, b, c, d) // replaced by \tcode{ab, c, d} +\end{codeblock} +\end{example} + \rSec2[cpp.stringize]{The \tcode{\#} operator}% \indextext{\#\#0 operator@\tcode{\#} operator}% \indextext{stringize|see{\tcode{\#} operator}} @@ -1137,7 +1191,7 @@ \term{line number} of the current source line is one greater than the number of new-line characters read or introduced -in translation phase 1~(\ref{lex.phases}) +in translation phase 1\iref{lex.phases} while processing the source file to the current token. \pnum @@ -1286,7 +1340,7 @@ or \tcode{operator new[](std::size_t)}. \begin{note} Larger alignments will be passed to -\tcode{operator new(std::size_t, std::align_val_t)}, etc.~(\ref{expr.new}). +\tcode{operator new(std::size_t, std::align_val_t)}, etc.\iref{expr.new}. \end{note} \indextext{__TIME__@\mname{TIME}}% @@ -1334,12 +1388,12 @@ \indextext{__STDCPP_STRICT_POINTER_SAFETY__@\mname{STDCPP_STRICT_POINTER_SAFETY}}% \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}). +has strict pointer safety\iref{basic.stc.dynamic.safety}. \indextext{__STDCPP_THREADS__@\mname{STDCPP_THREADS}}% \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}). +can have more than one thread of execution\iref{intro.multithread}. \end{description} diff --git a/source/regex.tex b/source/regex.tex index 44d2c9281a..5e8ce03675 100644 --- a/source/regex.tex +++ b/source/regex.tex @@ -12,7 +12,7 @@ \pnum The following subclauses describe a basic regular expression class template and its -traits that can handle char-like~(\ref{strings.general}) template arguments, +traits that can handle char-like\iref{strings.general} template arguments, two specializations of this class template that handle sequences of \tcode{char} and \tcode{wchar_t}, a class template that holds the result of a regular expression match, a series of algorithms that allow a character @@ -36,6 +36,7 @@ \rSec1[re.def]{Definitions} + \pnum The following definitions shall apply to this Clause: @@ -85,12 +86,12 @@ \pnum This subclause defines requirements on classes representing regular expression traits. \begin{note} The class template -\tcode{regex_traits}, defined in Clause~\ref{re.traits}, +\tcode{regex_traits}, defined in \ref{re.traits}, satisfies these requirements. \end{note} \pnum The class template \tcode{basic_regex}, defined in -Clause~\ref{re.regex}, needs a set of related types and +\ref{re.regex}, needs a set of related types and functions to complete the definition of its semantics. These types and functions are provided as a set of member \grammarterm{typedef-name}{s} and functions in the template parameter \tcode{traits} used by the \tcode{basic_regex} class @@ -112,8 +113,8 @@ type \tcode{charT}; \tcode{u} is an object of type \tcode{X}; \tcode{v} is an object of type \tcode{const X}; \tcode{p} is a value of type \tcode{const charT*}; \tcode{I1} -and \tcode{I2} are input iterators~(\ref{input.iterators}); -\tcode{F1} and \tcode{F2} are forward iterators~(\ref{forward.iterators}); +and \tcode{I2} are input iterators\iref{input.iterators}; +\tcode{F1} and \tcode{F2} are forward iterators\iref{forward.iterators}; \tcode{c} is a value of type \tcode{const charT}; \tcode{s} is an object of type \tcode{X::string_type}; \tcode{cs} is an object of type \tcode{const X::string_type}; @@ -147,7 +148,7 @@ & A type that represents the locale used by the traits class. \indextext{locale} \\ \rowsep \tcode{X::char_class_type} - & A bitmask type~(\ref{bitmask.types}). + & A bitmask type\iref{bitmask.types}. & A bitmask type representing a particular character classification. \indextext{regular expression traits!\idxcode{char_class_type}}% \indextext{\idxcode{char_class_type}!regular expression traits}% @@ -248,7 +249,7 @@ Class template \tcode{regex_traits} satisfies the requirements for a regular expression traits class when it is specialized for \tcode{char} or \tcode{wchar_t}. This class template is described in -the header \tcode{}, and is described in Clause~\ref{re.traits}. +the header \tcode{}, and is described in \ref{re.traits}. \end{note} \rSec1[re.syn]{Header \tcode{} synopsis} @@ -652,7 +653,7 @@ \indexlibrary{\idxcode{syntax_option_type}!\idxcode{grep}}% \indexlibrary{\idxcode{syntax_option_type}!\idxcode{egrep}}% The type \tcode{syntax_option_type} is an \impldef{type of \tcode{syntax_option_type}} bitmask -type~(\ref{bitmask.types}). Setting its elements has the effects listed in +type\iref{bitmask.types}. Setting its elements has the effects listed in Table~\ref{tab:re:syntaxoption}. A valid value of type \tcode{syntax_option_type} shall have at most one of the grammar elements \tcode{ECMAScript}, \tcode{basic}, \tcode{extended}, \tcode{awk}, \tcode{grep}, \tcode{egrep}, set. @@ -786,7 +787,7 @@ \pnum \indexlibrary{\idxcode{match_flag_type}}% The type \tcode{match_flag_type} is an -\impldef{type of \tcode{regex_constants::match_flag_type}} bitmask type~(\ref{bitmask.types}). +\impldef{type of \tcode{regex_constants::match_flag_type}} bitmask type\iref{bitmask.types}. The constants of that type, except for \tcode{match_default} and \tcode{format_default}, are bitmask elements. The \tcode{match_default} and \tcode{format_default} constants are empty bitmasks. @@ -848,7 +849,7 @@ \tcode{match_prev_avail} & \verb!--first! is a valid iterator position. When this flag is set the flags \tcode{match_not_bol} and \tcode{match_not_bow} shall be ignored by the -regular expression algorithms~(\ref{re.alg}) and iterators~(\ref{re.iter}). +regular expression algorithms\iref{re.alg} and iterators\iref{re.iter}. \\ \rowsep % \indexlibrary{\idxcode{format_default}}% @@ -909,7 +910,7 @@ \indexlibrary{\idxcode{error_type}}% \indexlibrary{\idxcode{regex_constants}!\idxcode{error_type}}% The type \tcode{error_type} is an \impldef{type of -\tcode{regex_constants::error_type}} enumerated type~(\ref{enumerated.types}). +\tcode{regex_constants::error_type}} enumerated type\iref{enumerated.types}. Values of type \tcode{error_type} represent the error conditions described in Table~\ref{tab:re:errortype}: @@ -1020,7 +1021,7 @@ using char_type = charT; using string_type = basic_string; using locale_type = locale; - using char_class_type = @{\itshape bitmask_type}@; + using char_class_type = @\placeholdernc{bitmask_type}@; regex_traits(); static size_t length(const char_type* p); @@ -1051,7 +1052,7 @@ \indextext{\idxcode{regex_traits}!specializations}% The specializations \tcode{regex_traits} and \tcode{regex_traits} shall be valid and shall satisfy the -requirements for a regular expression traits class~(\ref{re.req}). +requirements for a regular expression traits class\iref{re.req}. \indexlibrarymember{regex_traits}{char_class_type}% \begin{itemdecl} @@ -1134,7 +1135,7 @@ \end{itemdecl} \begin{itemdescr} -\pnum\returns a sequence of one or more characters that +\pnum\returns A sequence of one or more characters that represents the collating element consisting of the character sequence designated by the iterator range \range{first}{last}. Returns an empty string if the character sequence is not a @@ -1149,7 +1150,7 @@ \end{itemdecl} \begin{itemdescr} -\pnum\returns an unspecified value that represents +\pnum\returns An unspecified value that represents the character classification named by the character sequence designated by the iterator range \range{first}{last}. If the parameter \tcode{icase} is \tcode{true} then the returned mask identifies the @@ -1237,7 +1238,7 @@ \requires The value of \tcode{radix} shall be 8, 10, or 16. \pnum -\returns the value represented by the digit \tcode{ch} in base +\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 \tcode{-1}. \end{itemdescr} @@ -1256,7 +1257,7 @@ data held by \tcode{*this}. \end{note} \pnum -\returns if no locale has been previously imbued then a copy of the +\returns If no locale has been previously imbued then a copy of the global locale in effect at the time of construction of \tcode{*this}, otherwise a copy of the last argument passed to \tcode{imbue}. @@ -1272,7 +1273,7 @@ \begin{itemdescr} \pnum -\returns if no locale has been imbued then a copy of the global locale +\returns If no locale has been imbued then a copy of the global locale in effect at the time of construction of \tcode{*this}, otherwise a copy of the last argument passed to \tcode{imbue}. \end{itemdescr} @@ -1733,7 +1734,7 @@ \begin{itemdescr} \pnum \requires The type \tcode{InputIterator} shall satisfy the requirements for an Input -Iterator~(\ref{input.iterators}). +Iterator\iref{input.iterators}. \pnum \returns \tcode{assign(string_type(first, last), f)}. @@ -2829,7 +2830,7 @@ \begin{itemdescr} \pnum \requires \tcode{ready() == true} and \tcode{OutputIter} shall satisfy the requirements for an -Output Iterator~(\ref{output.iterators}). +Output Iterator\iref{output.iterators}. \pnum \effects Copies the character sequence \range{fmt_first}{fmt_last} to @@ -2979,7 +2980,7 @@ \tcode{m1.suffix() == m2.suffix()}. \end{itemize} \end{itemize} -\begin{note} The algorithm \tcode{equal} is defined in Clause~\ref{algorithms}. \end{note} +\begin{note} The algorithm \tcode{equal} is defined in \ref{algorithms}. \end{note} \end{itemdescr} \indexlibrary{\idxcode{operator"!=}!\idxcode{match_results}}% @@ -3017,7 +3018,7 @@ \begin{itemdescr} \pnum \requires The type \tcode{BidirectionalIterator} shall satisfy the requirements -of a Bidirectional Iterator~(\ref{bidirectional.iterators}). +of a Bidirectional Iterator\iref{bidirectional.iterators}. \pnum \effects Determines whether there is a match between the @@ -3200,7 +3201,7 @@ \begin{itemdescr} \pnum \requires Type \tcode{BidirectionalIterator} shall satisfy the requirements of a Bidirectional -Iterator (\ref{bidirectional.iterators}). +Iterator\iref{bidirectional.iterators}. \pnum \effects Determines whether there is some sub-sequence within \range{first}{last} that matches @@ -4163,8 +4164,8 @@ The behavior of the internal finite state machine representation when used to match a sequence of characters is as described in ECMA-262. The behavior is modified according -to any match_flag_type flags~(\ref{re.matchflag}) specified when using the regular expression -object in one of the regular expression algorithms~(\ref{re.alg}). The behavior is also +to any match_flag_type flags\iref{re.matchflag} specified when using the regular expression +object in one of the regular expression algorithms\iref{re.alg}. The behavior is also localized by interaction with the traits class template parameter as follows: \begin{itemize} \item During matching of a regular expression finite state machine diff --git a/source/special.tex b/source/special.tex index 757f0ec576..c780f8dd48 100644 --- a/source/special.tex +++ b/source/special.tex @@ -15,14 +15,14 @@ \indextext{constructor!move}% \indextext{assignment operator!copy}% \indextext{assignment operator!move}% -The default constructor~(\ref{class.ctor}), -copy constructor and copy assignment operator~(\ref{class.copy}), -move constructor and move assignment operator~(\ref{class.copy}), -and destructor~(\ref{class.dtor}) are +The default constructor\iref{class.ctor}, +copy constructor and copy assignment operator\iref{class.copy}, +move constructor and move assignment operator\iref{class.copy}, +and destructor\iref{class.dtor} are \term{special member functions}. \begin{note} The implementation will implicitly declare these member functions for some class types when the program does not explicitly declare them. -The implementation will implicitly define them if they are odr-used~(\ref{basic.def.odr}). +The implementation will implicitly define them if they are odr-used\iref{basic.def.odr}. See~\ref{class.ctor}, \ref{class.dtor} and~\ref{class.copy}. \end{note} An implicitly-declared special member function is declared at the closing \tcode{\}} of the \grammarterm{class-specifier}. @@ -55,7 +55,7 @@ \pnum \indextext{access control!member function and}% -Special member functions obey the usual access rules (Clause~\ref{class.access}). +Special member functions obey the usual access rules\iref{class.access}. \begin{example} Declaring a constructor \tcode{protected} @@ -64,7 +64,7 @@ \pnum For a class, its non-static data members, its non-virtual direct base classes, -and, if the class is not abstract~(\ref{class.abstract}), its virtual base +and, if the class is not abstract\iref{class.abstract}, its virtual base classes are called its \term{potentially constructed subobjects}. \rSec1[class.ctor]{Constructors}% @@ -74,7 +74,7 @@ \pnum Constructors do not have names. In a declaration of a constructor, the \grammarterm{declarator} is a -function declarator~(\ref{dcl.fct}) of the form +function declarator\iref{dcl.fct} of the form \begin{ncbnf} ptr-declarator \terminal{(} parameter-declaration-clause \terminal{)} noexcept-specifier\opt attribute-specifier-seq\opt @@ -89,20 +89,20 @@ \item in a \grammarterm{member-declaration} that belongs to the \grammarterm{member-specification} of a class but is not a friend -declaration~(\ref{class.friend}), the \grammarterm{id-expression} is the -injected-class-name (Clause~\ref{class}) of the immediately-enclosing class; +declaration\iref{class.friend}, the \grammarterm{id-expression} is the +injected-class-name\iref{class} of the immediately-enclosing class; \item in a \grammarterm{member-declaration} that belongs to the \grammarterm{member-specification} of a class template but is not a friend declaration, the \grammarterm{id-expression} is a \grammarterm{class-name} that -names the current instantiation~(\ref{temp.dep.type}) of the +names the current instantiation\iref{temp.dep.type} of the immediately-enclosing class template; or \item in a declaration at namespace scope or in a friend declaration, the \grammarterm{id-expression} is a \grammarterm{qualified-id} that names a -constructor~(\ref{class.qual}). +constructor\iref{class.qual}. \end{itemize} The \grammarterm{class-name} shall not be a \grammarterm{typedef-name}. In a constructor @@ -124,7 +124,7 @@ A constructor is used to initialize objects of its class type. Because constructors do not have names, they are never found during name lookup; however an explicit type conversion using the functional -notation~(\ref{expr.type.conv}) will cause a constructor to be called to +notation\iref{expr.type.conv} will cause a constructor to be called to initialize an object. \begin{note} For initialization of objects of class type see~\ref{class.init}. @@ -144,16 +144,15 @@ \tcode{const} and \tcode{volatile} -semantics~(\ref{dcl.type.cv}) are not applied on an object under construction. +semantics\iref{dcl.type.cv} are not applied on an object under construction. They come into effect when the constructor for the -most derived object~(\ref{intro.object}) ends. +most derived object\iref{intro.object} ends. \pnum \indextext{constructor!inheritance of}% -\indextext{constructor!default}% \indextext{constructor!non-trivial}% A -\term{default} +\defnx{default}{constructor!default} constructor for a class \tcode{X} is a constructor of class @@ -167,7 +166,7 @@ If there is no user-declared constructor for class \tcode{X}, a non-explicit constructor having no parameters is implicitly declared -as defaulted~(\ref{dcl.fct.def}). +as defaulted\iref{dcl.fct.def}. An implicitly-declared default constructor is an \tcode{inline} \tcode{public} @@ -186,7 +185,7 @@ no variant member of the anonymous union containing \tcode{M} has a default member initializer, -\item any non-static data member with no default member initializer~(\ref{class.mem}) is +\item any non-static data member with no default member initializer\iref{class.mem} is of reference type, \item any non-variant non-static data member of const-qualified type (or array @@ -201,8 +200,8 @@ \item any potentially constructed subobject, except for a non-static data member with a \grammarterm{brace-or-equal-initializer}, has class type \tcode{M} (or array thereof) and either \tcode{M} -has no default constructor or overload resolution -(\ref{over.match}) as applied to find \tcode{M}'s corresponding +has no default constructor or overload resolution\iref{over.match} +as applied to find \tcode{M}'s corresponding constructor results in an ambiguity or in a function that is deleted or inaccessible from the defaulted default constructor, or @@ -218,11 +217,11 @@ \begin{itemize} \item -its class has no virtual functions~(\ref{class.virtual}) and no virtual base -classes~(\ref{class.mi}), and +its class has no virtual functions\iref{class.virtual} and no virtual base +classes\iref{class.mi}, and \item no non-static data member of its class has -a default member initializer~(\ref{class.mem}), and +a default member initializer\iref{class.mem}, and \item all the direct base classes of its class have trivial default constructors, and @@ -236,23 +235,22 @@ \defnx{non-trivial}{constructor!default!non-trivial}. \pnum -\indextext{constructor!implicitly defined}% A default constructor that is defaulted and not defined as deleted is -\term{implicitly defined} -when it is odr-used~(\ref{basic.def.odr}) -to create an object of its class type~(\ref{intro.object}) +\defnx{implicitly defined}{constructor!implicitly defined} +when it is odr-used\iref{basic.def.odr} +to create an object of its class type\iref{intro.object} or when it is explicitly defaulted after its first declaration. The implicitly-defined default constructor performs the set of initializations of the class that would be performed by a user-written default constructor for that class with no -\grammarterm{ctor-initializer}~(\ref{class.base.init}) and an empty +\grammarterm{ctor-initializer}\iref{class.base.init} and an empty \grammarterm{compound-statement}. 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 constexpr constructor~(\ref{dcl.constexpr}), the implicitly-defined +of a constexpr constructor\iref{dcl.constexpr}, the implicitly-defined default constructor is \tcode{constexpr}. Before the defaulted default constructor for a class is implicitly defined, @@ -260,7 +258,7 @@ its non-static data members shall have been implicitly defined. \begin{note} An implicitly-declared default constructor has an -exception specification~(\ref{except.spec}). +exception specification\iref{except.spec}. An explicitly-defaulted definition might have an implicit exception specification, see~\ref{dcl.fct.def}. \end{note} @@ -269,16 +267,16 @@ \indextext{constructor!implicitly called}% Default constructors are called implicitly to create class objects of static, thread, or automatic storage duration~(\ref{basic.stc.static}, \ref{basic.stc.thread}, \ref{basic.stc.auto}) defined -without an initializer~(\ref{dcl.init}), -are called to create class objects of dynamic storage duration~(\ref{basic.stc.dynamic}) created by a +without an initializer\iref{dcl.init}, +are called to create class objects of dynamic storage duration\iref{basic.stc.dynamic} created by a \grammarterm{new-expression} in which the \grammarterm{new-initializer} -is omitted~(\ref{expr.new}), or -are called when the explicit type conversion syntax~(\ref{expr.type.conv}) is +is omitted\iref{expr.new}, or +are called when the explicit type conversion syntax\iref{expr.type.conv} is used. A program is ill-formed if the default constructor for an object -is implicitly used and the constructor is not accessible (Clause~\ref{class.access}). +is implicitly used and the constructor is not accessible\iref{class.access}. \pnum \begin{note} @@ -300,7 +298,7 @@ \pnum \indextext{object!unnamed}% \indextext{constructor!explicit call}% -A functional notation type conversion~(\ref{expr.type.conv}) can be used +A functional notation type conversion\iref{expr.type.conv} can be used to create new objects of its type. \begin{note} The syntax looks like an explicit call of the constructor. @@ -377,25 +375,25 @@ Temporary objects are created \begin{itemize} \item -when a prvalue is materialized so that it can be used as a glvalue~(\ref{conv.rval}), +when a prvalue is materialized so that it can be used as a glvalue\iref{conv.rval}, \item when needed by the implementation to pass or return an object of trivially-copyable type (see below), and \item -when throwing an exception~(\ref{except.throw}). +when throwing an exception\iref{except.throw}. \begin{note} The lifetime of exception objects is described in~\ref{except.throw}. \end{note} \end{itemize} Even when the creation of the temporary object is -unevaluated (Clause~\ref{expr}), +unevaluated\iref{expr}, all the semantic restrictions shall be respected as if the temporary object had been created and later destroyed. \begin{note} -This includes accessibility (Clause~\ref{class.access}) and whether it is deleted, +This includes accessibility\iref{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, +\grammarterm{decltype-specifier}\iref{expr.call}, no temporary is introduced, so the foregoing does not apply to such a prvalue. \end{note} @@ -414,11 +412,11 @@ \item when performing an array-to-pointer conversion or subscripting on an array prvalue~(\ref{conv.array}, \ref{expr.sub}), \item -when initializing an object of type \tcode{std::initializer_list} from a \grammarterm{braced-init-list}~(\ref{dcl.init.list}), +when initializing an object of type \tcode{std::initializer_list} from a \grammarterm{braced-init-list}\iref{dcl.init.list}, \item for certain unevaluated operands~(\ref{expr.typeid}, \ref{expr.sizeof}), and \item -when a prvalue appears as a discarded-value expression (Clause~\ref{expr}). +when a prvalue appears as a discarded-value expression\iref{expr}. \end{itemize} \end{note} \begin{example} Consider the following code: @@ -494,10 +492,10 @@ non-trivial constructor~(\ref{class.ctor}, \ref{class.copy}), it shall ensure that a constructor is called for the temporary object. Similarly, the destructor shall be called for a temporary with a non-trivial -destructor~(\ref{class.dtor}). +destructor\iref{class.dtor}. Temporary objects are destroyed as the last step in evaluating -the full-expression~(\ref{intro.execution}) +the full-expression\iref{intro.execution} that (lexically) contains the point where they were created. This is true even if that evaluation ends in throwing an exception. @@ -515,35 +513,107 @@ 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 -an element of an array with no corresponding initializer~(\ref{dcl.init}). +an element of an array with no corresponding initializer\iref{dcl.init}. The second context is when a copy constructor is called to copy an element of -an array while the entire array is copied~(\ref{expr.prim.lambda.capture},~\ref{class.copy}). +an array while the entire array is copied~(\ref{expr.prim.lambda.capture}, \ref{class.copy}). In either case, if the constructor has one or more default arguments, the destruction of every temporary created in a default argument is sequenced before the construction of the next array element, if any. \pnum The third context is when a reference is bound to a -temporary.\footnote{The same rules apply to initialization of an - \tcode{initializer_list} object~(\ref{dcl.init.list}) with its +temporary object.\footnote{The same rules apply to initialization of an + \tcode{initializer_list} object\iref{dcl.init.list} with its underlying temporary array.} -The temporary to which the reference is bound or the temporary +The temporary object to which the reference is bound or the temporary object that is the complete object of a subobject to which the reference is bound -persists for the lifetime of the reference except: +persists for the lifetime of the reference if the glvalue +to which the reference is bound +was obtained through one of the following: +\begin{itemize} +\item + a temporary materialization conversion\iref{conv.rval}, +\item + \tcode{(} \grammarterm{expression} \tcode{)}, + where \grammarterm{expression} is one of these expressions, +\item + subscripting\iref{expr.sub} of an array operand, + where that operand is one of these expressions, +\item + a class member access\iref{expr.ref} using the \tcode{.} operator + where the left operand is one of these expressions and + the right operand designates a non-static data member of non-reference type, +\item + a pointer-to-member operation\iref{expr.mptr.oper} using the \tcode{.*} operator + where the left operand is one of these expressions and + the right operand is a pointer to data member of non-reference type, +\item + a \tcode{const_cast}\iref{expr.const.cast}, + \tcode{static_cast}\iref{expr.static.cast}, + \tcode{dynamic_cast}\iref{expr.dynamic.cast}, or + \tcode{reinterpret_cast}\iref{expr.reinterpret.cast} + converting, without a user-defined conversion, + a glvalue operand that is one of these expressions + to a glvalue that refers + to the object designated by the operand, or + to its complete object or a subobject thereof, +\item + a conditional expression\iref{expr.cond} that is a glvalue + where the second or third operand is one of these expressions, or +\item + a comma expression\iref{expr.comma} that is a glvalue + where the right operand is one of these expressions. +\end{itemize} +\begin{example} +\begin{codeblock} +template using id = T; + +int&& a = id{1, 2, 3}[i]; // temporary array has same lifetime as \tcode{a} +const int& b = static_cast(0); // temporary \tcode{int} has same lifetime as \tcode{b} +int&& c = cond ? id{1, 2, 3}[i] : static_cast(0); + // exactly one of the two temporaries is lifetime-extended +\end{codeblock} +\end{example} +\begin{note} +An explicit type conversion~(\ref{expr.type.conv}, \ref{expr.cast}) +is interpreted as +a sequence of elementary casts, +covered above. +\begin{example} +\begin{codeblock} +const int& x = (const int&)1; // temporary for value 1 has same lifetime as x +\end{codeblock} +\end{example} +\end{note} +\begin{note} +If a temporary object has a reference member initialized by another temporary object, +lifetime extension applies recursively to such a member's initializer. +\begin{example} +\begin{codeblock} +struct S { + const int& m; +}; +const S& s = S{1}; // both \tcode{S} and \tcode{int} temporaries have lifetime of \tcode{s} +\end{codeblock} +\end{example} +\end{note} +The exceptions to this lifetime rule are: \begin{itemize} -\item A temporary object bound to a reference parameter in a function call~(\ref{expr.call}) +\item A temporary object bound to a reference parameter in a function call\iref{expr.call} persists until the completion of the full-expression containing the call. -\item The lifetime of a temporary bound to the returned value in a function return statement~(\ref{stmt.return}) is not extended; the temporary is destroyed at the end of the full-expression in the return statement. +\item The lifetime of a temporary bound to the returned value in a function return statement\iref{stmt.return} is not extended; the temporary is destroyed at the end of the full-expression in the return statement. -\item A temporary bound to a reference in a \grammarterm{new-initializer}~(\ref{expr.new}) persists until the completion of the full-expression containing the \grammarterm{new-initializer}. \begin{example} +\item A temporary bound to a reference in a \grammarterm{new-initializer}\iref{expr.new} persists until the completion of the full-expression containing the \grammarterm{new-initializer}. +\begin{note} This may introduce a dangling reference. \end{note} +\begin{example} \begin{codeblock} struct S { int mi; const std::pair& mp; }; S a { 1, {2,3} }; -S* p = new S{ 1, {2,3} }; // Creates dangling reference +S* p = new S{ 1, {2,3} }; // creates dangling reference \end{codeblock} -\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{example} \end{itemize} \pnum @@ -657,22 +727,21 @@ \pnum \indextext{conversion!class}% -\indextext{conversion!user-defined}% \indextext{constructor, conversion by|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. These conversions are called -\term{user-defined conversions} -and are used for implicit type conversions (Clause~\ref{conv}), -for initialization~(\ref{dcl.init}), +\defnx{user-defined conversions}{conversion!user-defined} +and are used for implicit type conversions\iref{conv}, +for initialization\iref{dcl.init}, and for explicit type conversions~(\ref{expr.cast}, \ref{expr.static.cast}). \pnum User-defined conversions are applied only where they are unambiguous~(\ref{class.member.lookup}, \ref{class.conv.fct}). -Conversions obey the access control rules (Clause~\ref{class.access}). -Access control is applied after ambiguity resolution~(\ref{basic.lookup}). +Conversions obey the access control rules\iref{class.access}. +Access control is applied after ambiguity resolution\iref{basic.lookup}. \pnum \begin{note} @@ -705,7 +774,7 @@ \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 +Function overload resolution\iref{over.match.best} selects the best conversion function to perform the conversion. \begin{example} \begin{codeblock} @@ -735,8 +804,7 @@ the types of its parameters (if any) to the type of its class. Such a constructor is called a -\indexdefn{constructor!converting}% -\term{converting constructor}. +\defnx{converting constructor}{constructor!converting}. \begin{example} \indextext{Jessie}% @@ -760,12 +828,12 @@ \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}) +constructors, but does so only where the direct-initialization syntax\iref{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}). +or value-initialization\iref{dcl.init}. \begin{example} \begin{codeblock} struct Z { @@ -791,7 +859,7 @@ \pnum A non-explicit -copy/move constructor~(\ref{class.copy}) is a converting constructor. +copy/move constructor\iref{class.copy} is a converting constructor. \begin{note} An implicitly-declared copy/move constructor is not an explicit constructor; it may be called for implicit type conversions. @@ -829,14 +897,14 @@ of a conversion function (if any) shall be neither a \grammarterm{defining-type-specifier} nor \tcode{static}. \indextext{conversion!type of}% -The type of the conversion function~(\ref{dcl.fct}) is +The type of the conversion function\iref{dcl.fct} is ``function taking no parameter returning \grammarterm{conversion-type-id}''. A conversion function is never used to convert a (possibly cv-qualified) object to the (possibly cv-qualified) same object type (or a reference to it), to a (possibly cv-qualified) base class of that type (or a reference to it), or to (possibly cv-qualified) void.\footnote{These conversions are considered -as standard conversions for the purposes of overload resolution~(\ref{over.best.ics}, \ref{over.ics.ref}) and therefore initialization~(\ref{dcl.init}) and explicit casts~(\ref{expr.static.cast}). A conversion to \tcode{void} does not invoke any conversion function~(\ref{expr.static.cast}). +as standard conversions for the purposes of overload resolution~(\ref{over.best.ics}, \ref{over.ics.ref}) and therefore initialization\iref{dcl.init} and explicit casts\iref{expr.static.cast}. A conversion to \tcode{void} does not invoke any conversion function\iref{expr.static.cast}. 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.} @@ -858,7 +926,7 @@ \end{example} \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. +A conversion function may be explicit\iref{dcl.fct.spec}, in which case it is only considered as a user-defined conversion for direct-initialization\iref{dcl.init}. Otherwise, user-defined conversions are not restricted to use in assignments and initializations. \begin{example} \begin{codeblock} class Y { }; @@ -921,7 +989,7 @@ \pnum \indextext{conversion!deduced return type of user-defined}% A conversion function template shall not have a -deduced return type~(\ref{dcl.spec.auto}). +deduced return type\iref{dcl.spec.auto}. \begin{example} \begin{codeblock} struct S { @@ -938,7 +1006,7 @@ \pnum In a declaration of a destructor, the \grammarterm{declarator} is a -function declarator~(\ref{dcl.fct}) of the form +function declarator\iref{dcl.fct} of the form \begin{ncbnf} ptr-declarator \terminal{(} parameter-declaration-clause \terminal{)} noexcept-specifier\opt attribute-specifier-seq\opt @@ -953,16 +1021,16 @@ \item in a \grammarterm{member-declaration} that belongs to the \grammarterm{member-specification} of a class but is not a friend -declaration~(\ref{class.friend}), the \grammarterm{id-expression} is +declaration\iref{class.friend}, the \grammarterm{id-expression} is \tcode{\~}\grammarterm{class-name} and the \grammarterm{class-name} is the -injected-class-name (Clause~\ref{class}) of the immediately-enclosing class; +injected-class-name\iref{class} of the immediately-enclosing class; \item in a \grammarterm{member-declaration} that belongs to the \grammarterm{member-specification} of a class template but is not a friend declaration, the \grammarterm{id-expression} is \tcode{\~}\grammarterm{class-name} and the \grammarterm{class-name} names the -current instantiation~(\ref{temp.dep.type}) of the immediately-enclosing class template; or +current instantiation\iref{temp.dep.type} of the immediately-enclosing class template; or \item in a declaration at namespace scope or in a friend declaration, the @@ -972,7 +1040,7 @@ \end{itemize} The \grammarterm{class-name} shall not be a \grammarterm{typedef-name}. A -destructor shall take no arguments (\ref{dcl.fct}). +destructor shall take no arguments\iref{dcl.fct}. Each \grammarterm{decl-specifier} of the \grammarterm{decl-specifier-seq} of a destructor declaration (if any) shall be \tcode{friend}, \tcode{inline}, or \tcode{virtual}. @@ -993,14 +1061,14 @@ \tcode{const} and \tcode{volatile} -semantics~(\ref{dcl.type.cv}) are not applied on an object under destruction. +semantics\iref{dcl.type.cv} are not applied on an object under destruction. They stop being in effect when the destructor for the -most derived object~(\ref{intro.object}) starts. +most derived object\iref{intro.object} starts. \pnum \begin{note} A declaration of a destructor that does not have a \grammarterm{noexcept-specifier} -has the same exception specification as if had been implicitly declared~(\ref{except.spec}). +has the same exception specification as if had been implicitly declared\iref{except.spec}. \end{note} \pnum @@ -1008,7 +1076,7 @@ \indextext{destructor!default}% If a class has no user-declared destructor, a destructor is implicitly -declared as defaulted~(\ref{dcl.fct.def}). +declared as defaulted\iref{dcl.fct.def}. An implicitly-declared destructor is an \tcode{inline} \tcode{public} @@ -1047,12 +1115,11 @@ \defnx{non-trivial}{destructor!non-trivial}. \pnum -\indextext{destructor!implicitly defined}% A destructor that is defaulted and not defined as deleted is -\term{implicitly defined} -when it is odr-used~(\ref{basic.def.odr}) +\defnx{implicitly defined}{destructor!implicitly defined} +when it is odr-used\iref{basic.def.odr} or when it is explicitly defaulted after its first declaration. \pnum @@ -1075,7 +1142,7 @@ \tcode{X}'s non-virtual direct base classes and, if \tcode{X} -is the type of the most derived class~(\ref{class.base.init}), +is the type of the most derived class\iref{class.base.init}, its destructor calls the destructors for \tcode{X}'s virtual base classes. @@ -1086,7 +1153,7 @@ their constructor (see~\ref{class.base.init}). A \tcode{return} -statement~(\ref{stmt.return}) in a destructor might not directly return to the +statement\iref{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}% @@ -1097,9 +1164,9 @@ \indextext{destructor!virtual}% \indextext{destructor!pure virtual}% A destructor can be declared -\tcode{virtual}~(\ref{class.virtual}) +\tcode{virtual}\iref{class.virtual} or pure -\tcode{virtual}~(\ref{class.abstract}); +\tcode{virtual}\iref{class.abstract}; if any objects of that class or any derived class are created in the program, the destructor shall be defined. If a class has a base class with a virtual destructor, its destructor @@ -1119,11 +1186,11 @@ \begin{itemize} -\item for a constructed object with static storage duration~(\ref{basic.stc.static}) at program termination~(\ref{basic.start.term}), +\item for a constructed object with static storage duration\iref{basic.stc.static} at program termination\iref{basic.start.term}, -\item for a constructed object with thread storage duration~(\ref{basic.stc.thread}) at thread exit, +\item for a constructed object with thread storage duration\iref{basic.stc.thread} at thread exit, -\item for a constructed object with automatic storage duration~(\ref{basic.stc.auto}) when the block in which an object is created exits~(\ref{stmt.dcl}), +\item for a constructed object with automatic storage duration\iref{basic.stc.auto} when the block in which an object is created exits\iref{stmt.dcl}, \item for a constructed temporary object when its lifetime ends~(\ref{conv.rval}, \ref{class.temporary}). \end{itemize} @@ -1132,8 +1199,8 @@ \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 -\grammarterm{delete-expression}~(\ref{expr.delete}) for a constructed object allocated -by a \grammarterm{new-expression}~(\ref{expr.new}); the context of the invocation is the +\grammarterm{delete-expression}\iref{expr.delete} for a constructed object allocated +by a \grammarterm{new-expression}\iref{expr.new}; the context of the invocation is the \grammarterm{delete-expression}. \begin{note} An array of class type contains several subobjects for each of which the destructor is invoked. \end{note} @@ -1145,15 +1212,15 @@ \pnum At the point of definition of a virtual destructor (including an implicit -definition~(\ref{class.copy})), the non-array deallocation function is +definition\iref{class.copy}), the non-array deallocation function is determined as if for the expression \tcode{delete this} appearing in a non-virtual destructor of the destructor's class (see~\ref{expr.delete}). If the lookup fails or if the deallocation function has -a deleted definition~(\ref{dcl.fct.def}), the program is ill-formed. +a deleted definition\iref{dcl.fct.def}, the program is ill-formed. \begin{note} This assures that a deallocation function corresponding to the dynamic type of an object is available for the -\grammarterm{delete-expression}~(\ref{class.free}). +\grammarterm{delete-expression}\iref{class.free}. \end{note} \pnum @@ -1164,7 +1231,7 @@ \grammarterm{type-name} or \grammarterm{decltype-specifier} that denotes the destructor's class type. The invocation of a destructor is subject to the usual rules for member -functions~(\ref{class.mfct}); +functions\iref{class.mfct}; that is, if the object is not of the destructor's class type and 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 @@ -1196,11 +1263,11 @@ \end{example} \begin{note} An explicit destructor call must always be written using -a member access operator~(\ref{expr.ref}) or a \grammarterm{qualified-id}~(\ref{expr.prim}); +a member access operator\iref{expr.ref} or a \grammarterm{qualified-id}\iref{expr.prim}; in particular, the \grammarterm{unary-expression} \tcode{\~{}X()} -in a member function is not an explicit destructor call~(\ref{expr.unary.op}). +in a member function is not an explicit destructor call\iref{expr.unary.op}. \end{note} \pnum @@ -1235,7 +1302,7 @@ \pnum Once a destructor is invoked for an object, the object no longer exists; the behavior is undefined if the destructor is invoked -for an object whose lifetime has ended~(\ref{basic.life}). +for an object whose lifetime has ended\iref{basic.life}. \begin{example} If the destructor for an automatic object is explicitly invoked, and the block is subsequently left in a manner that would ordinarily @@ -1246,7 +1313,7 @@ \begin{note} \indextext{fundamental type!destructor and}% The notation for explicit call of a destructor can be used for any scalar type -name~(\ref{expr.pseudo}). +name\iref{expr.pseudo}. Allowing this makes it possible to write code without having to know if a destructor exists for a given type. For example: @@ -1289,7 +1356,7 @@ \pnum \indextext{\idxcode{delete}}% When an object is deleted with a -\grammarterm{delete-expression}~(\ref{expr.delete}), +\grammarterm{delete-expression}\iref{expr.delete}, a deallocation function \indextext{function!deallocation}% (\tcode{operator delete()} @@ -1298,16 +1365,16 @@ \tcode{operator delete[]()} \indextext{\idxcode{operator delete}}% for arrays) is (implicitly) called to reclaim the storage occupied by -the object~(\ref{basic.stc.dynamic.deallocation}). +the object\iref{basic.stc.dynamic.deallocation}. \pnum Class-specific deallocation function lookup is a part of general deallocation -function lookup~(\ref{expr.delete}) and occurs as follows. +function lookup\iref{expr.delete} and occurs as follows. If the \grammarterm{delete-expression} is used to deallocate a class object whose static type has a virtual destructor, the deallocation function is the one selected at the point of definition of the dynamic type's virtual -destructor~(\ref{class.dtor}).\footnote{A similar provision is not needed for +destructor\iref{class.dtor}.\footnote{A similar provision is not needed for the array version of \tcode{operator} \tcode{delete} because~\ref{expr.delete} requires that in this situation, the static type of the object to be deleted be the same as its dynamic type. @@ -1320,7 +1387,7 @@ identical and the deallocation function's name is looked up in the scope of \tcode{T}. If this lookup fails to find the name, general deallocation function -lookup~(\ref{expr.delete}) continues. +lookup\iref{expr.delete} continues. If the result of the lookup is ambiguous or inaccessible, or if the lookup selects a placement deallocation function, the program is ill-formed. @@ -1426,7 +1493,7 @@ \pnum \begin{note} If a deallocation function has no explicit \grammarterm{noexcept-specifier}, it -has a non-throwing exception specification~(\ref{except.spec}). +has a non-throwing exception specification\iref{except.spec}. \end{note} \rSec1[class.init]{Initialization}% @@ -1499,7 +1566,7 @@ \end{example} \begin{note} \indextext{initialization!overloaded assignment and}% -Overloading of the assignment operator~(\ref{over.ass}) +Overloading of the assignment operator\iref{over.ass} has no effect on initialization. \end{note} @@ -1729,7 +1796,7 @@ \begin{note} The initialization performed by each \grammarterm{mem-initializer} -constitutes a full-expression~(\ref{intro.execution}). +constitutes a full-expression\iref{intro.execution}. Any expression in a \grammarterm{mem-initializer} @@ -1763,10 +1830,10 @@ \begin{itemize} \item if the entity is a non-static data member that has -a default member initializer~(\ref{class.mem}) and either +a default member initializer\iref{class.mem} and either \begin{itemize} -\item the constructor's class is a union~(\ref{class.union}), and no other variant +\item the constructor's class is a union\iref{class.union}, and no other variant member of that union is designated by a \grammarterm{mem-initializer-id} or \item the constructor's class is not a union, and, if the entity is a member of an @@ -1777,12 +1844,12 @@ the entity is initialized from its default member initializer as specified in~\ref{dcl.init}; -\item otherwise, if the entity is an anonymous union or a variant member~(\ref{class.union.anon}), no initialization is performed; +\item otherwise, if the entity is an anonymous union or a variant member\iref{class.union.anon}, no initialization is performed; -\item otherwise, the entity is default-initialized~(\ref{dcl.init}). +\item otherwise, the entity is default-initialized\iref{dcl.init}. \end{itemize} -\begin{note} An abstract class~(\ref{class.abstract}) is never a most derived +\begin{note} An abstract class\iref{class.abstract} is never a most derived class, thus its constructors never initialize virtual base classes, therefore the corresponding \grammarterm{mem-initializer}{s} may be omitted. \end{note} An attempt to initialize more than one non-static data member of a union renders the @@ -1863,9 +1930,9 @@ \pnum In a non-delegating constructor, the destructor for each potentially constructed -subobject of class type is potentially invoked~(\ref{class.dtor}). +subobject of class type is potentially invoked\iref{class.dtor}. \begin{note} This provision ensures that destructors can be called for fully-constructed -subobjects in case an exception is thrown~(\ref{except.ctor}). \end{note} +subobjects in case an exception is thrown\iref{except.ctor}. \end{note} \pnum In a non-delegating constructor, initialization @@ -1873,7 +1940,7 @@ \begin{itemize} \item \indextext{initialization!order of virtual base class}% -First, and only for the constructor of the most derived class~(\ref{intro.object}), +First, and only for the constructor of the most derived class\iref{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 base classes, @@ -1999,8 +2066,8 @@ called for an object under construction. Similarly, an object under construction can be the operand of the \tcode{typeid} -operator~(\ref{expr.typeid}) or of a -\tcode{dynamic_cast}~(\ref{expr.dynamic.cast}). +operator\iref{expr.typeid} or of a +\tcode{dynamic_cast}\iref{expr.dynamic.cast}. However, if these operations are performed in a \grammarterm{ctor-initializer} (or in a function called directly or indirectly from a @@ -2052,7 +2119,7 @@ \pnum \indextext{initializer!pack expansion}% A \grammarterm{mem-initializer} followed by an ellipsis is -a pack expansion~(\ref{temp.variadic}) that initializes the base +a pack expansion\iref{temp.variadic} that initializes the base classes specified by a pack expansion in the \grammarterm{base-specifier-list} for the class. \begin{example} @@ -2072,7 +2139,7 @@ \pnum When a constructor for type \tcode{B} is invoked to initialize an object of a different type \tcode{D} -(that is, when the constructor was inherited~(\ref{namespace.udecl})), +(that is, when the constructor was inherited\iref{namespace.udecl}), initialization proceeds as if a defaulted default constructor were used to initialize the \tcode{D} object and each base class subobject from which the constructor was inherited, @@ -2266,8 +2333,8 @@ \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 -during construction or destruction~(\ref{class.base.init}). +Member functions, including virtual functions\iref{class.virtual}, can be called +during construction or destruction\iref{class.base.init}. When a virtual function is called directly or indirectly from a constructor or from a destructor, including during the construction or destruction of the class's non-static data @@ -2277,7 +2344,7 @@ the function called is the final overrider in the constructor's or destructor's class and not one overriding it in a more-derived class. -If the virtual function call uses an explicit class member access~(\ref{expr.ref}) +If the virtual function call uses an explicit class member access\iref{expr.ref} and the object expression refers to the complete object of \tcode{x} or one of that object's base class subobjects but not \tcode{x} or one of its base class subobjects, the behavior @@ -2321,11 +2388,11 @@ \indextext{\idxcode{typeid}!destruction and}% The \tcode{typeid} -operator~(\ref{expr.typeid}) can be used during construction or destruction~(\ref{class.base.init}). +operator\iref{expr.typeid} can be used during construction or destruction\iref{class.base.init}. When \tcode{typeid} is used in a constructor (including the -\grammarterm{mem-initializer} or default member initializer~(\ref{class.mem}) +\grammarterm{mem-initializer} or default member initializer\iref{class.mem} for a non-static data member) or in a destructor, or used in a function called (directly or indirectly) from a constructor or destructor, if the operand of @@ -2346,8 +2413,8 @@ \indextext{destruction!dynamic cast and}% \indextext{cast!dynamic!construction and}% \indextext{cast!dynamic!destruction and}% -\tcode{dynamic_cast}s~(\ref{expr.dynamic.cast}) can be used during construction -or destruction~(\ref{class.base.init}). When a +\tcode{dynamic_cast}s\iref{expr.dynamic.cast} can be used during construction +or destruction\iref{class.base.init}. When a \tcode{dynamic_cast} is used in a constructor (including the \grammarterm{mem-initializer} or default member initializer @@ -2397,11 +2464,11 @@ \pnum A class object can be copied or moved in two ways: -by initialization~(\ref{class.ctor}, \ref{dcl.init}), including for function argument passing~(\ref{expr.call}) and for function value return~(\ref{stmt.return}); -and by assignment~(\ref{expr.ass}). +by initialization~(\ref{class.ctor}, \ref{dcl.init}), including for function argument passing\iref{expr.call} and for function value return\iref{stmt.return}; +and by assignment\iref{expr.ass}. Conceptually, these two operations are implemented by a -copy/move constructor~(\ref{class.ctor}) -and copy/move assignment operator~(\ref{over.ass}). +copy/move constructor\iref{class.ctor} +and copy/move assignment operator\iref{over.ass}. \pnum \indextext{constructor!copy!inaccessible}% @@ -2410,7 +2477,7 @@ \indextext{assignment operator!move!inaccessible}% A program is ill-formed if the copy/move constructor or the copy/move assignment operator for an object is implicitly odr-used and the special member function -is not accessible (Clause~\ref{class.access}). +is not accessible\iref{class.access}. \begin{note} Copying/moving one object into another using the copy/move constructor or the copy/move assignment operator does not change the layout or size of either @@ -2436,7 +2503,7 @@ or \tcode{const volatile X\&}, and either there are no other parameters -or else all other parameters have default arguments~(\ref{dcl.fct.default}). +or else all other parameters have default arguments\iref{dcl.fct.default}. \begin{example} \tcode{X::X(const X\&)} and @@ -2459,7 +2526,7 @@ first parameter is of type \tcode{X\&\&}, \tcode{const X\&\&}, \tcode{volatile X\&\&}, or \tcode{const volatile X\&\&}, and either there are no other parameters or else all other parameters have default -arguments~(\ref{dcl.fct.default}). +arguments\iref{dcl.fct.default}. \begin{example} \tcode{Y::Y(Y\&\&)} is a move constructor. \begin{codeblock} struct Y { @@ -2543,13 +2610,12 @@ \end{example} \pnum -\indextext{constructor!copy!implicitly declared}% If the class definition does not explicitly declare a copy constructor, -a non-explicit one is declared \term{implicitly}. +a non-explicit one is declared \defnx{implicitly}{constructor!copy!implicitly declared}. If the class definition declares a move constructor or move assignment operator, the implicitly declared copy constructor is defined as deleted; otherwise, it is defined as -defaulted~(\ref{dcl.fct.def}). +defaulted\iref{dcl.fct.def}. The latter case is deprecated if the class has a user-declared copy assignment operator or a user-declared destructor. @@ -2618,14 +2684,14 @@ \tcode{public} member of its class. A defaulted copy/\brk{}move constructor for a class - \tcode{X} is defined as deleted~(\ref{dcl.fct.def.delete}) if \tcode{X} has: + \tcode{X} is defined as deleted\iref{dcl.fct.def.delete} if \tcode{X} has: \begin{itemize} \item a variant member with a non-trivial corresponding constructor and \tcode{X} is a union-like class, \item a potentially constructed subobject type \tcode{M} (or array thereof) that cannot be copied/moved because - overload resolution (\ref{over.match}), as applied to find + overload resolution\iref{over.match}, as applied to find \tcode{M}'s corresponding constructor, results in an ambiguity or a function that is deleted or inaccessible from the @@ -2658,8 +2724,8 @@ \item class \tcode{X} -has no virtual functions~(\ref{class.virtual}) -and no virtual base classes~(\ref{class.mi}), and +has no virtual functions\iref{class.virtual} +and no virtual base classes\iref{class.mi}, and \item the constructor selected to copy/move each direct base class subobject is trivial, and @@ -2682,14 +2748,14 @@ that is defaulted and not defined as deleted is \term{implicitly defined} -if it is odr-used~(\ref{basic.def.odr}) +if it is odr-used\iref{basic.def.odr} or when it is explicitly defaulted after its first declaration. \begin{note} The copy/move constructor is implicitly defined even if the implementation elided -its odr-use (\ref{basic.def.odr}, \ref{class.temporary}). +its odr-use~(\ref{basic.def.odr}, \ref{class.temporary}). \end{note} If the implicitly-defined constructor would satisfy the requirements of a -constexpr constructor~(\ref{dcl.constexpr}), the implicitly-defined +constexpr constructor\iref{dcl.constexpr}, the implicitly-defined constructor is \tcode{constexpr}. \pnum @@ -2700,7 +2766,7 @@ shall have been implicitly defined. \begin{note} An implicitly-declared copy/move constructor has an -implied exception specification~(\ref{except.spec}). +implied exception specification\iref{except.spec}. \end{note} \pnum @@ -2734,7 +2800,7 @@ \pnum The implicitly-defined copy/move constructor for a union -\tcode{X} copies the object representation~(\ref{basic.types}) of \tcode{X}.% +\tcode{X} copies the object representation\iref{basic.types} of \tcode{X}.% \indextext{constructor!move|)}% \indextext{constructor!copy|)} @@ -2792,12 +2858,12 @@ \end{note} \pnum -\indextext{assignment operator!copy!implicitly declared}% If the class definition does not explicitly declare a copy assignment operator, -one is declared \term{implicitly}. If the class definition declares a move +one is declared \defnx{implicitly}{assignment operator!copy!implicitly declared}. +If the class definition declares a move constructor or move assignment operator, the implicitly declared copy assignment operator is defined as deleted; otherwise, it is defined as -defaulted~(\ref{dcl.fct.def}). +defaulted\iref{dcl.fct.def}. The latter case is deprecated if the class has a user-declared copy constructor or a user-declared destructor. The implicitly-declared copy assignment operator for a class @@ -2935,7 +3001,7 @@ \item a direct non-static data member of class type \tcode{M} (or array thereof) or a direct base class \tcode{M} that cannot be copied/moved because overload resolution - (\ref{over.match}), as applied to find \tcode{M}'s corresponding + \iref{over.match}, as applied to find \tcode{M}'s corresponding assignment operator, results in an ambiguity or a function that is deleted or inaccessible from the defaulted assignment operator. @@ -2950,9 +3016,9 @@ Because a copy/move assignment operator is implicitly declared for a class if not declared by the user, a base class copy/move assignment operator is always hidden -by the corresponding assignment operator of a derived class~(\ref{over.ass}). +by the corresponding assignment operator of a derived class\iref{over.ass}. A -\grammarterm{using-declaration}~(\ref{namespace.udecl}) that brings in from a base class an assignment operator +\grammarterm{using-declaration}\iref{namespace.udecl} that brings in from a base class an assignment operator with a parameter type that could be that of a copy/move assignment operator for the derived class is not considered an explicit declaration of such an @@ -2976,8 +3042,8 @@ \item class \tcode{X} -has no virtual functions~(\ref{class.virtual}) -and no virtual base classes~(\ref{class.mi}), and +has no virtual functions\iref{class.virtual} +and no virtual base classes\iref{class.mi}, and \item the assignment operator selected to copy/move each direct base class subobject is trivial, and @@ -3001,7 +3067,7 @@ is \term{implicitly defined} when -it is odr-used~(\ref{basic.def.odr}) (e.g., when it is selected by overload resolution +it is odr-used\iref{basic.def.odr} (e.g., when it is selected by overload resolution to assign to an object of its class type) or when it is explicitly defaulted after its first declaration. The implicitly-defined copy/move assignment operator is \tcode{constexpr} if @@ -3027,7 +3093,7 @@ its non-static data members shall have been implicitly defined. \begin{note} An implicitly-declared copy/move assignment operator has an -implied exception specification~(\ref{except.spec}). +implied exception specification\iref{except.spec}. \end{note} \pnum @@ -3077,7 +3143,7 @@ \pnum The implicitly-defined copy assignment operator for a -union \tcode{X} copies the object representation~(\ref{basic.types}) of \tcode{X}.% +union \tcode{X} copies the object representation\iref{basic.types} of \tcode{X}.% \indextext{assignment operator!move|)}% \indextext{assignment operator!copy|)} @@ -3118,24 +3184,24 @@ when the \grammarterm{expression} is the name of a non-volatile automatic object (other than a function parameter or a variable introduced by the \grammarterm{exception-declaration} of a -\grammarterm{handler}~(\ref{except.handle})) +\grammarterm{handler}\iref{except.handle}) with the same type (ignoring cv-qualification) as the function return type, the copy/move operation can be omitted by constructing the automatic object directly into the function call's return object -\item in a \grammarterm{throw-expression}~(\ref{expr.throw}), when the operand +\item in a \grammarterm{throw-expression}\iref{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 \grammarterm{try-block} (if there is one), the copy/move operation from the -operand to the exception object~(\ref{except.throw}) can be omitted by +operand to the exception object\iref{except.throw} can be omitted by constructing the automatic object directly into the exception object \item when the \grammarterm{exception-declaration} of an -exception handler (Clause~\ref{except}) declares an object of the same +exception handler\iref{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 +object\iref{except.throw}, the copy operation can be omitted by treating 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 @@ -3145,8 +3211,8 @@ \end{itemize} Copy elision is required where an expression is evaluated in a context -requiring a constant expression~(\ref{expr.const}) -and in constant initialization~(\ref{basic.start.static}). +requiring a constant expression\iref{expr.const} +and in constant initialization\iref{basic.start.static}. \begin{note} Copy elision might not be performed if the same expression @@ -3209,13 +3275,13 @@ \pnum 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}) +\item If the \grammarterm{expression} in a \tcode{return} statement\iref{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}, or -\item if the operand of a \grammarterm{throw-expression}~(\ref{expr.throw}) +\item if the operand of a \grammarterm{throw-expression}\iref{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 diff --git a/source/statements.tex b/source/statements.tex index fb7ba2ed20..2242f280a8 100644 --- a/source/statements.tex +++ b/source/statements.tex @@ -35,7 +35,7 @@ \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\iref{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} \grammarterm{type-specifier} appears in the \grammarterm{decl-specifier-seq}, @@ -67,7 +67,7 @@ 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}). +contextually converted to \tcode{bool}\iref{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 @@ -122,7 +122,7 @@ \begin{note} A label may have the same name as another declaration in the same scope or a \grammarterm{template-parameter} from an enclosing scope. Unqualified name -lookup~(\ref{basic.lookup.unqual}) ignores labels. +lookup\iref{basic.lookup.unqual} ignores labels. \end{note} \pnum @@ -143,7 +143,7 @@ \end{bnf} The expression is -a discarded-value expression (Clause~\ref{expr}). +a discarded-value expression\iref{expr}. All \indextext{side effects}% side effects from an expression statement @@ -157,7 +157,7 @@ function calls. A null statement is useful to carry a label just before the \tcode{\}} of a compound statement and to supply a null body to an iteration statement such as a \tcode{while} -statement~(\ref{stmt.while}). +statement\iref{stmt.while}. \end{note} \rSec1[stmt.block]{Compound statement or block}% @@ -180,9 +180,9 @@ statement-seq statement \end{bnf} -A compound statement defines a block scope~(\ref{basic.scope}). +A compound statement defines a block scope\iref{basic.scope}. \begin{note} -A declaration is a \grammarterm{statement}~(\ref{stmt.dcl}). +A declaration is a \grammarterm{statement}\iref{stmt.dcl}. \end{note} \rSec1[stmt.select]{Selection statements}% @@ -205,13 +205,13 @@ \begin{note} An \grammarterm{init-statement} ends with a semicolon. \end{note} -In Clause~\ref{stmt.stmt}, the term \term{substatement} refers to +In \ref{stmt.stmt}, the term \term{substatement} refers to 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, in the \tcode{else} form of the \tcode{if} statement) implicitly defines -a block scope~(\ref{basic.scope}). If the substatement in a +a block scope\iref{basic.scope}. If the substatement in a selection-statement is a single statement and not a \grammarterm{compound-statement}, it is as if it was rewritten to be a compound-statement containing the original substatement. @@ -237,7 +237,7 @@ \indextext{statement!\idxcode{if}} \pnum -If the condition~(\ref{stmt.select}) yields \tcode{true} the first +If the condition\iref{stmt.select} yields \tcode{true} the first substatement is executed. If the \tcode{else} part of the selection statement is present and the condition yields \tcode{false}, the second substatement is executed. If the first substatement is reached via a @@ -251,23 +251,23 @@ \pnum If the \tcode{if} statement is of the form \tcode{if constexpr}, the value of the condition shall be a contextually -converted constant expression of type \tcode{bool}~(\ref{expr.const}); this +converted constant expression of type \tcode{bool}\iref{expr.const}; this form is called a \defn{constexpr if} statement. If the value of the converted condition is \tcode{false}, the first substatement is a \defn{discarded statement}, otherwise the second substatement, if -present, is a discarded statement. During the instantation of an -enclosing templated entity (Clause~\ref{temp}), if the condition is +present, is a discarded statement. During the instantiation of an +enclosing templated entity\iref{temp}, if the condition is not value-dependent after its instantiation, the discarded substatement (if any) is not instantiated. \begin{note} -Odr-uses~(\ref{basic.def.odr}) in a discarded statement do not require +Odr-uses\iref{basic.def.odr} in a discarded statement do not require an entity to be defined. \end{note} A \tcode{case} or \tcode{default} label appearing within such an \tcode{if} statement shall be associated with a \tcode{switch} -statement~(\ref{stmt.switch}) within the same \tcode{if} statement. -A label~(\ref{stmt.label}) declared in a substatement of a constexpr if -statement shall only be referred to by a statement~(\ref{stmt.goto}) in +statement\iref{stmt.switch} within the same \tcode{if} statement. +A label\iref{stmt.label} declared in a substatement of a constexpr if +statement shall only be referred to by a statement\iref{stmt.goto} in the same substatement. \begin{example} \begin{codeblock} @@ -336,10 +336,10 @@ \pnum The condition shall be of integral type, enumeration type, or class type. If of class type, the -condition is contextually implicitly converted (Clause~\ref{conv}) to +condition is contextually implicitly converted\iref{conv} to an integral or enumeration type. If the (possibly converted) type is subject to integral -promotions~(\ref{conv.prom}), the condition is converted +promotions\iref{conv.prom}, the condition is converted to the promoted type. Any statement within the \tcode{switch} statement can be labeled with one or @@ -351,7 +351,7 @@ \end{ncbnf} where the \grammarterm{constant-expression} shall be -a converted constant expression~(\ref{expr.const}) of the +a converted constant expression\iref{expr.const} of the adjusted type of the switch condition. No two of the case constants in the same switch shall have the same value after conversion. @@ -384,7 +384,7 @@ \pnum \tcode{case} and \tcode{default} labels in themselves do not alter the flow of control, which continues unimpeded across such labels. To exit -from a switch, see \tcode{break},~\ref{stmt.break}. +from a switch, see \tcode{break}, \ref{stmt.break}. \begin{note} Usually, the substatement that is the subject of a switch is compound and \tcode{case} and \tcode{default} labels appear on the top-level @@ -453,7 +453,7 @@ \pnum The substatement in an \grammarterm{iteration-statement} implicitly defines -a block scope~(\ref{basic.scope}) which is entered and exited each time +a block scope\iref{basic.scope} which is entered and exited each time through the loop. \indextext{scope!\idxgram{iteration-statement}}% @@ -498,7 +498,7 @@ \pnum In the \tcode{while} statement the substatement is executed repeatedly -until the value of the condition~(\ref{stmt.select}) becomes +until the value of the condition\iref{stmt.select} becomes \tcode{false}. The test takes place before each execution of the substatement. @@ -506,7 +506,7 @@ \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} +declaration\iref{basic.scope.pdecl} to the end of the \tcode{while} \grammarterm{statement}. A \tcode{while} statement of the form \begin{codeblock} @@ -553,7 +553,7 @@ \indextext{statement!\idxcode{do}} \pnum -The expression is contextually converted to \tcode{bool} (Clause~\ref{conv}); +The expression is contextually converted to \tcode{bool}\iref{conv}; if that conversion is ill-formed, the program is ill-formed. \pnum @@ -592,7 +592,7 @@ re-evaluating \grammarterm{condition}. \begin{note} Thus the first statement specifies initialization for the loop; the -condition~(\ref{stmt.select}) specifies a test, sequenced before each +condition\iref{stmt.select} specifies a test, sequenced before each iteration, such that the loop is exited when the condition becomes \tcode{false}; the expression often specifies incrementing that is sequenced after each iteration. @@ -671,15 +671,15 @@ \item if the \grammarterm{for-range-initializer} is an expression of class type \tcode{C}, the \grammarterm{unqualified-id}{s} \tcode{begin} and \tcode{end} are looked up in the scope of \tcode{C} -as if by class member access lookup~(\ref{basic.lookup.classref}), and if either +as if by class member access lookup\iref{basic.lookup.classref}, and if either (or both) finds at least one declaration, \placeholder{begin-expr} and \placeholder{end-expr} are \tcode{__range.begin()} and \tcode{__range.end()}, respectively; \item otherwise, \placeholder{begin-expr} and \placeholder{end-expr} are \tcode{begin(__range)} and \tcode{end(__range)}, respectively, where \tcode{begin} and \tcode{end} are looked -up in the associated namespaces~(\ref{basic.lookup.argdep}). -\begin{note} Ordinary unqualified lookup~(\ref{basic.lookup.unqual}) is not +up in the associated namespaces\iref{basic.lookup.argdep}. +\begin{note} Ordinary unqualified lookup\iref{basic.lookup.unqual} is not performed. \end{note} \end{itemize} \end{itemize} @@ -724,7 +724,7 @@ \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 +duration\iref{basic.stc.auto} that have been constructed in that scope are destroyed in the reverse order of their construction. \begin{note} For temporaries, see~\ref{class.temporary}. \end{note} Transfer out of a loop, out of a block, or back past @@ -739,7 +739,7 @@ \tcode{std::exit()} or \indextext{\idxcode{abort}}% \indexlibrary{\idxcode{abort}}% -\tcode{std::abort()}~(\ref{support.start.term}), for example) without +\tcode{std::abort()}\iref{support.start.term}, for example) without destroying class objects with automatic storage duration. \end{note} @@ -813,8 +813,8 @@ 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 -destructor~(\ref{class.dtor}). +\cv{}~\tcode{void}, a constructor\iref{class.ctor}, or a +destructor\iref{class.dtor}. \indextext{\idxcode{return}!constructor and}% \indextext{\idxcode{return}!constructor and}% A return statement with an operand of type \tcode{void} shall be used only @@ -824,13 +824,13 @@ \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. +by copy-initialization\iref{dcl.init} from the operand. \begin{note} A return statement can involve an invocation of a constructor to perform a copy or move of the operand if it is not a prvalue or if its type differs from the return type of the function. A copy operation associated with a return statement may be elided or -converted to a move operation if an automatic storage duration variable is returned~(\ref{class.copy}). +converted to a move operation if an automatic storage duration variable is returned\iref{class.copy}. \end{note} \begin{example} \begin{codeblock} @@ -845,14 +845,14 @@ 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}) +other than \tcode{main}\iref{basic.start.main} results in undefined behavior. \pnum The copy-initialization of the result of the call is sequenced before the destruction of temporaries at the end of the full-expression established by the operand of the return statement, which, in turn, is sequenced -before the destruction of local variables~(\ref{stmt.jump}) of the block +before the destruction of local variables\iref{stmt.jump} of the block enclosing the return statement. \rSec2[stmt.goto]{The \tcode{goto} statement}% @@ -862,7 +862,7 @@ The \tcode{goto} statement unconditionally transfers control to the statement labeled by the identifier. The identifier shall be a \indextext{label}% -label~(\ref{stmt.label}) located in the current function. +label\iref{stmt.label} located in the current function. \rSec1[stmt.dcl]{Declaration statement}% \indextext{statement!declaration} @@ -887,11 +887,11 @@ \pnum \indextext{block!initialization in}% \indextext{initialization!automatic}% -Variables with automatic storage duration~(\ref{basic.stc.auto}) are +Variables with automatic storage duration\iref{basic.stc.auto} are initialized each time their \grammarterm{declaration-statement} is executed. \indextext{local variable!destruction of}% Variables with automatic storage duration declared in the block are -destroyed on exit from the block~(\ref{stmt.jump}). +destroyed on exit from the block\iref{stmt.jump}. \pnum \indextext{initialization!jump past}% @@ -902,7 +902,7 @@ 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}\iref{dcl.init}. \begin{example} \begin{codeblock} @@ -926,8 +926,8 @@ \indextext{initialization!local \tcode{static}}% \indextext{initialization!local \tcode{thread_local}}% Dynamic initialization of a block-scope variable with -static storage duration~(\ref{basic.stc.static}) or -thread storage duration~(\ref{basic.stc.thread}) is performed +static storage duration\iref{basic.stc.static} or +thread storage duration\iref{basic.stc.thread} is performed the first time control passes through its declaration; such a variable is considered initialized upon the completion of its initialization. If the initialization exits by throwing an exception, the initialization is not @@ -967,7 +967,7 @@ There is an ambiguity in the grammar involving \grammarterm{expression-statement}{s} and \grammarterm{declaration}{s}: An \grammarterm{expression-statement} with a function-style explicit type -conversion~(\ref{expr.type.conv}) as its leftmost subexpression can be +conversion\iref{expr.type.conv} as its leftmost subexpression can be indistinguishable from a \grammarterm{declaration} where the first \grammarterm{declarator} starts with a \tcode{(}. In those cases the \grammarterm{statement} is a \grammarterm{declaration}. @@ -982,7 +982,7 @@ of many examples. \begin{example} Assuming \tcode{T} is a -\grammarterm{simple-type-specifier}~(\ref{dcl.type}), +\grammarterm{simple-type-specifier}\iref{dcl.type}, \begin{codeblock} T(a)->m = 7; // expression-statement diff --git a/source/strings.tex b/source/strings.tex index 063bfc211e..8ee9d010a9 100644 --- a/source/strings.tex +++ b/source/strings.tex @@ -5,10 +5,10 @@ \pnum This Clause describes components for manipulating sequences of -any non-array POD~(\ref{basic.types}) type. -Such types are called \term{char-like types},\indextext{char-like type} +any non-array POD\iref{basic.types} type. +Such types are called \defnx{char-like types}{char-like type}, and objects of -char-like types are called \term{char-like objects}\indextext{char-like object} or +char-like types are called \defnx{char-like objects}{char-like object} or simply \term{characters}. \pnum @@ -45,8 +45,8 @@ that satisfy those requirements. \pnum -Most classes specified in Clauses~\ref{string.classes} -and~\ref{input.output} need a set of related types and functions to complete +Most classes specified in \ref{string.classes} +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 \tcode{traits} used by each such template. This subclause defines the @@ -218,7 +218,7 @@ The type \tcode{char_type} is used to refer to the character container type -in the implementation of the library classes defined in~\ref{string.classes} and Clause~\ref{input.output}. +in the implementation of the library classes defined in~\ref{string.classes} and \ref{input.output}. \end{itemdescr} \indexlibrarymember{int_type}{char_traits}% @@ -307,7 +307,7 @@ \pnum The requirements for the members of these specializations are given in -Clause~\ref{char.traits.require}. +\ref{char.traits.require}. \rSec3[char.traits.specializations.char]{\tcode{struct char_traits}} @@ -605,9 +605,8 @@ template<> struct char_traits; // \ref{basic.string}, \tcode{basic_string} - template, - class Allocator = allocator> - class basic_string; + template, class Allocator = allocator> + class basic_string; template basic_string @@ -752,14 +751,14 @@ using wstring = basic_string; // \ref{string.conversions}, numeric conversions - int stoi(const string& str, size_t* idx = 0, int base = 10); - long stol(const string& str, size_t* idx = 0, int base = 10); - unsigned long stoul(const string& str, size_t* idx = 0, int base = 10); - long long stoll(const string& str, size_t* idx = 0, int base = 10); - unsigned long long stoull(const string& str, size_t* idx = 0, int base = 10); - float stof(const string& str, size_t* idx = 0); - double stod(const string& str, size_t* idx = 0); - long double stold(const string& str, size_t* idx = 0); + int stoi(const string& str, size_t* idx = nullptr, int base = 10); + long stol(const string& str, size_t* idx = nullptr, int base = 10); + unsigned long stoul(const string& str, size_t* idx = nullptr, int base = 10); + long long stoll(const string& str, size_t* idx = nullptr, int base = 10); + unsigned long long stoull(const string& str, size_t* idx = nullptr, int base = 10); + float stof(const string& str, size_t* idx = nullptr); + double stod(const string& str, size_t* idx = nullptr); + long double stold(const string& str, size_t* idx = nullptr); string to_string(int val); string to_string(unsigned val); string to_string(long val); @@ -770,14 +769,14 @@ string to_string(double val); string to_string(long double val); - int stoi(const wstring& str, size_t* idx = 0, int base = 10); - long stol(const wstring& str, size_t* idx = 0, int base = 10); - unsigned long stoul(const wstring& str, size_t* idx = 0, int base = 10); - long long stoll(const wstring& str, size_t* idx = 0, int base = 10); - unsigned long long stoull(const wstring& str, size_t* idx = 0, int base = 10); - float stof(const wstring& str, size_t* idx = 0); - double stod(const wstring& str, size_t* idx = 0); - long double stold(const wstring& str, size_t* idx = 0); + int stoi(const wstring& str, size_t* idx = nullptr, int base = 10); + long stol(const wstring& str, size_t* idx = nullptr, int base = 10); + unsigned long stoul(const wstring& str, size_t* idx = nullptr, int base = 10); + long long stoll(const wstring& str, size_t* idx = nullptr, int base = 10); + unsigned long long stoull(const wstring& str, size_t* idx = nullptr, int base = 10); + float stof(const wstring& str, size_t* idx = nullptr); + double stod(const wstring& str, size_t* idx = nullptr); + long double stold(const wstring& str, size_t* idx = nullptr); wstring to_wstring(int val); wstring to_wstring(unsigned val); wstring to_wstring(long val); @@ -797,8 +796,7 @@ namespace pmr { template > - using basic_string = - std::basic_string>; + using basic_string = std::basic_string>; using string = basic_string; using u16string = basic_string; @@ -841,10 +839,10 @@ \tcode{Allocator} class passed as a template parameter to allocate and free storage for the contained char-like objects.\footnote{\tcode{Allocator::value_type} must name the same type -as \tcode{charT}~(\ref{string.require}).} +as \tcode{charT}\iref{string.require}.} \pnum -A \tcode{basic_string} is a contiguous container~(\ref{container.requirements.general}). +A \tcode{basic_string} is a contiguous container\iref{container.requirements.general}. \pnum In all cases, @@ -859,13 +857,13 @@ a \term{length} error is associated with exceptions of type -\tcode{length_error}~(\ref{length.error}); +\tcode{length_error}\iref{length.error}; \indexlibrary{\idxcode{length_error}}% \item an \term{out-of-range} error is associated with exceptions of type -\tcode{out_of_range}~(\ref{out.of.range}). +\tcode{out_of_range}\iref{out.of.range}. \indexlibrary{\idxcode{out_of_range}}% \end{itemize} @@ -1165,7 +1163,7 @@ obtained as described in \ref{container.requirements.general}. In every specialization \tcode{basic_string}, the type \tcode{traits} shall satisfy -the character traits requirements~(\ref{char.traits}), and +the character traits requirements\iref{char.traits}, and the type \tcode{traits::char_type} shall name the same type as \tcode{charT}. \pnum @@ -1176,8 +1174,8 @@ \begin{itemize} \item as an argument to any standard library function taking a reference to non-const \tcode{basic_string} as an argument.\footnote{For example, as an argument to non-member -functions \tcode{swap()}~(\ref{string.special}), -\tcode{operator>{}>()}~(\ref{string.io}), and \tcode{getline()}~(\ref{string.io}), or as +functions \tcode{swap()}\iref{string.special}, +\tcode{operator>{}>()}\iref{string.io}, and \tcode{getline()}\iref{string.io}, or as an argument to \tcode{basic_string::swap()}.} \item Calling non-const member functions, except @@ -1232,11 +1230,11 @@ \begin{libefftabvalue} {\tcode{basic_string(const basic_string\&)} effects} {tab:strings.ctr.cpy} -\tcode{data()} & -points at the first element of an allocated copy of the array -whose first element is pointed at by \tcode{str.data()} \\ -\tcode{size()} & \tcode{str.size()} \\ -\tcode{capacity()} & a value at least as large as \tcode{size()} \\ +\tcode{data()} & points at the first element of an allocated + copy of the array whose first element is + pointed at by \tcode{str.data()} \\ +\tcode{size()} & \tcode{str.size()} \\ +\tcode{capacity()} & a value at least as large as \tcode{size()} \\ \end{libefftabvalue} \end{itemdescr} @@ -1244,6 +1242,8 @@ \begin{itemdecl} basic_string(const basic_string& str, size_type pos, const Allocator& a = Allocator()); +basic_string(const basic_string& str, size_type pos, size_type n, + const Allocator& a = Allocator()); \end{itemdecl} \begin{itemdescr} @@ -1258,26 +1258,8 @@ Constructs an object of class \tcode{basic_string} and determines the effective length \tcode{rlen} of the initial string -value as \tcode{str.size() - pos}, -as indicated in Table~\ref{tab:strings.ctr.2}. -\end{itemdescr} - -\indexlibrary{\idxcode{basic_string}!constructor}% -\begin{itemdecl} -basic_string(const basic_string& str, size_type pos, size_type n, - const Allocator& a = Allocator()); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\throws -\tcode{out_of_range} if \tcode{pos > str.size()}. - -\pnum -\effects -Constructs an object of class \tcode{basic_string} -and determines the effective length \tcode{rlen} of the initial string -value as the smaller of \tcode{n} and \tcode{str.size() - pos}, +value as \tcode{str.size() - pos} in the first form and +as the smaller of \tcode{str.size() - pos} and \tcode{n} in the second form, as indicated in Table~\ref{tab:strings.ctr.2}. \begin{libefftabvalue} @@ -1295,8 +1277,7 @@ \indexlibrary{\idxcode{basic_string}!constructor}% \begin{itemdecl} template - basic_string(const T& t, size_type pos, size_type n, - const Allocator& a = Allocator()); + basic_string(const T& t, size_type pos, size_type n, const Allocator& a = Allocator()); \end{itemdecl} \begin{itemdescr} @@ -1316,8 +1297,7 @@ \indexlibrary{\idxcode{basic_string}!constructor}% \begin{itemdecl} -explicit basic_string(basic_string_view sv, - const Allocator& a = Allocator()); +explicit basic_string(basic_string_view sv, const Allocator& a = Allocator()); \end{itemdecl} \begin{itemdescr} @@ -1327,8 +1307,7 @@ \indexlibrary{\idxcode{basic_string}!constructor}% \begin{itemdecl} -basic_string(const charT* s, size_type n, - const Allocator& a = Allocator()); +basic_string(const charT* s, size_type n, const Allocator& a = Allocator()); \end{itemdecl} \begin{itemdescr} @@ -1492,7 +1471,7 @@ \pnum \remarks Shall not participate in overload resolution if \tcode{InputIterator} is a type that does not qualify as an input iterator, -or if \tcode{Allocator} is a type that does not qualify as an allocator~(\ref{container.requirements.general}). +or if \tcode{Allocator} is a type that does not qualify as an allocator\iref{container.requirements.general}. \end{itemdescr} \indexlibrarymember{operator=}{basic_string}% @@ -1541,7 +1520,7 @@ \begin{itemdescr} \pnum \effects -Move assigns as a sequence container~(\ref{container.requirements}), +Move assigns as a sequence container\iref{container.requirements}, except that iterators, pointers and references may be invalidated. \pnum @@ -4231,7 +4210,7 @@ \begin{itemdescr} \pnum \effects -Behaves as a formatted input function~(\ref{istream.formatted.reqmts}). +Behaves as a formatted input function\iref{istream.formatted.reqmts}. After constructing a \tcode{sentry} object, if the sentry converts to \tcode{true}, calls @@ -4272,7 +4251,7 @@ If the function extracts no characters, it calls \tcode{is.setstate(ios::failbit)}, which may throw -\tcode{ios_base::fail\-ure}~(\ref{iostate.flags}). +\tcode{ios_base::fail\-ure}\iref{iostate.flags}. \pnum \returns @@ -4310,7 +4289,7 @@ \begin{itemdescr} \pnum \effects -Behaves as an unformatted input function~(\ref{istream.unformatted}), +Behaves as an unformatted input function\iref{istream.unformatted}, except that it does not affect the value returned by subsequent calls to \tcode{basic_istream<>::gcount()}. After constructing a @@ -4335,13 +4314,13 @@ \textit{c} (in which case, \textit{c} -is extracted but not appended)~(\ref{iostate.flags}) +is extracted but not appended)\iref{iostate.flags} \item \tcode{str.max_size()} characters are stored (in which case, the function calls -\tcode{is.setstate(ios_base::fail\-bit))}~(\ref{iostate.flags}) +\tcode{is.setstate(ios_base::fail\-bit))}\iref{iostate.flags} \end{itemize} \pnum @@ -4355,7 +4334,7 @@ If the function extracts no characters, it calls \tcode{is.setstate(ios_base::fail\-bit)} which may throw -\tcode{ios_base::fail\-ure}~(\ref{iostate.flags}). +\tcode{ios_base::fail\-ure}\iref{iostate.flags}. \pnum \returns @@ -4388,16 +4367,16 @@ \indexlibrary{\idxcode{stoll}}% \indexlibrary{\idxcode{stoull}}% \begin{itemdecl} -int stoi(const string& str, size_t* idx = 0, int base = 10); -long stol(const string& str, size_t* idx = 0, int base = 10); -unsigned long stoul(const string& str, size_t* idx = 0, int base = 10); -long long stoll(const string& str, size_t* idx = 0, int base = 10); -unsigned long long stoull(const string& str, size_t* idx = 0, int base = 10); +int stoi(const string& str, size_t* idx = nullptr, int base = 10); +long stol(const string& str, size_t* idx = nullptr, int base = 10); +unsigned long stoul(const string& str, size_t* idx = nullptr, int base = 10); +long long stoll(const string& str, size_t* idx = nullptr, int base = 10); +unsigned long long stoull(const string& str, size_t* idx = nullptr, int base = 10); \end{itemdecl} \begin{itemdescr} \pnum -\effects the first two functions call \tcode{strtol(str.c_str(), ptr, base)}, +\effects The first two functions call \tcode{strtol(str.c_str(), ptr, base)}, and the last three functions call \tcode{strtoul(str.c_str(), ptr, base)}, \tcode{strtoll(str.c_str(), ptr, base)}, and \tcode{strtoull(\brk{}str.c_str(), ptr, base)}, respectively. Each function returns the converted result, if any. The @@ -4422,9 +4401,9 @@ \indexlibrary{\idxcode{stod}}% \indexlibrary{\idxcode{stold}}% \begin{itemdecl} -float stof(const string& str, size_t* idx = 0); -double stod(const string& str, size_t* idx = 0); -long double stold(const string& str, size_t* idx = 0); +float stof(const string& str, size_t* idx = nullptr); +double stod(const string& str, size_t* idx = nullptr); +long double stold(const string& str, size_t* idx = nullptr); \end{itemdecl} \begin{itemdescr} @@ -4485,16 +4464,16 @@ \indexlibrary{\idxcode{stoll}}% \indexlibrary{\idxcode{stoull}}% \begin{itemdecl} -int stoi(const wstring& str, size_t* idx = 0, int base = 10); -long stol(const wstring& str, size_t* idx = 0, int base = 10); -unsigned long stoul(const wstring& str, size_t* idx = 0, int base = 10); -long long stoll(const wstring& str, size_t* idx = 0, int base = 10); -unsigned long long stoull(const wstring& str, size_t* idx = 0, int base = 10); +int stoi(const wstring& str, size_t* idx = nullptr, int base = 10); +long stol(const wstring& str, size_t* idx = nullptr, int base = 10); +unsigned long stoul(const wstring& str, size_t* idx = nullptr, int base = 10); +long long stoll(const wstring& str, size_t* idx = nullptr, int base = 10); +unsigned long long stoull(const wstring& str, size_t* idx = nullptr, int base = 10); \end{itemdecl} \begin{itemdescr} \pnum -\effects the first two functions call \tcode{wcstol(str.c_str(), ptr, base)}, +\effects The first two functions call \tcode{wcstol(str.c_str(), ptr, base)}, and the last three functions call \tcode{wcstoul(str.c_str(), ptr, base)}, \tcode{wcstoll(str.c_str(), ptr, base)}, and \tcode{wcstoull(\brk{}str.c_str(), ptr, base)}, respectively. Each function returns the converted result, if any. The @@ -4517,9 +4496,9 @@ \indexlibrary{\idxcode{stod}}% \indexlibrary{\idxcode{stold}}% \begin{itemdecl} -float stof(const wstring& str, size_t* idx = 0); -double stod(const wstring& str, size_t* idx = 0); -long double stold(const wstring& str, size_t* idx = 0); +float stof(const wstring& str, size_t* idx = nullptr); +double stod(const wstring& str, size_t* idx = nullptr); +long double stold(const wstring& str, size_t* idx = nullptr); \end{itemdecl} \begin{itemdescr} @@ -4642,7 +4621,7 @@ \rSec1[string.view]{String view classes} \pnum -The class template \tcode{basic_string_view} describes an object that can refer to a constant contiguous sequence of char-like (\ref{strings.general}) objects with the first element of the sequence at position zero. +The class template \tcode{basic_string_view} describes an object that can refer to a constant contiguous sequence of char-like\iref{strings.general} objects with the first element of the sequence at position zero. In the rest of this section, the type of the char-like objects held in a \tcode{basic_string_view} object is designated by \tcode{charT}. \pnum @@ -4824,7 +4803,7 @@ \end{codeblock} \pnum -In every specialization \tcode{basic_string_view}, the type \tcode{traits} shall satisfy the character traits requirements (\ref{char.traits}), +In every specialization \tcode{basic_string_view}, the type \tcode{traits} shall satisfy the character traits requirements\iref{char.traits}, and the type \tcode{traits::char_type} shall name the same type as \tcode{charT}. \rSec3[string.view.cons]{Construction and assignment} @@ -4897,15 +4876,15 @@ \begin{itemdescr} \pnum A type that meets the requirements -of a constant random access iterator~(\ref{random.access.iterators}) and -of a contiguous iterator~(\ref{iterator.requirements.general}) +of a constant random access iterator\iref{random.access.iterators} and +of a contiguous iterator\iref{iterator.requirements.general} whose \tcode{value_type} is the template parameter \tcode{charT}. \pnum -For a \tcode{basic_string_view str}, any operation that invalidates a pointer in the range \range{str.data()}{str.data() + str.size()} invalidates pointers, iterators, and references returned from \tcode{str}'s methods. +For a \tcode{basic_string_view str}, any operation that invalidates a pointer in the range \range{str.data()}{str.data() + str.size()} invalidates pointers, iterators, and references returned from \tcode{str}'s member functions. \pnum -All requirements on container iterators (\ref{container.requirements}) apply to \tcode{basic_string_view::const_iterator} as well. +All requirements on container iterators\iref{container.requirements} apply to \tcode{basic_string_view::const_iterator} as well. \end{itemdescr} \indexlibrarymember{begin}{basic_string_view}% @@ -5299,7 +5278,7 @@ \pnum Member functions in this section have complexity \bigoh{\tcode{size() * str.size()}} at worst, -although implementations are encouraged to do better. +although implementations should do better. \pnum Each member function of the form @@ -5617,7 +5596,7 @@ \pnum \effects Behaves as a formatted output -function~(\ref{ostream.formatted.reqmts}) of \tcode{os}. Forms a character sequence +function\iref{ostream.formatted.reqmts} of \tcode{os}. Forms a character sequence \tcode{seq}, initially consisting of the elements defined by the range \range{str.begin()}{str.end()}. Determines padding for \tcode{seq} as described in~\ref{ostream.formatted.reqmts}. @@ -5646,10 +5625,10 @@ \begin{itemdescr} \pnum -The specialization is enabled~(\ref{unord.hash}). +The specialization is enabled\iref{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}). +the corresponding string object\iref{basic.string.hash}. \end{note} \end{itemdescr} @@ -5850,17 +5829,17 @@ int strncmp(const char* s1, const char* s2, size_t n); size_t strxfrm(char* s1, const char* s2, size_t n); const void* memchr(const void* s, int c, size_t n); // see \ref{library.c} - void* memchr(void* s, int c, size_t n) // see \ref{library.c} - const char* strchr(const char* s, int c) // see \ref{library.c} - char* strchr(char* s, int c) // see \ref{library.c} + void* memchr(void* s, int c, size_t n); // see \ref{library.c} + const char* strchr(const char* s, int c); // see \ref{library.c} + char* strchr(char* s, int c); // see \ref{library.c} size_t strcspn(const char* s1, const char* s2); - const char* strpbrk(const char* s1, const char* s2) // see \ref{library.c} - char* strpbrk(char* s1, const char* s2) // see \ref{library.c} - const char* strrchr(const char* s, int c) // see \ref{library.c} - char* strrchr(char* s, int c) // see \ref{library.c} + const char* strpbrk(const char* s1, const char* s2); // see \ref{library.c} + char* strpbrk(char* s1, const char* s2); // see \ref{library.c} + const char* strrchr(const char* s, int c); // see \ref{library.c} + char* strrchr(char* s, int c); // see \ref{library.c} size_t strspn(const char* s1, const char* s2); - const char* strstr(const char* s1, const char* s2) // see \ref{library.c} - char* strstr(char* s1, const char* s2) // see \ref{library.c} + const char* strstr(const char* s1, const char* s2); // see \ref{library.c} + char* strstr(char* s1, const char* s2); // see \ref{library.c} char* strtok(char* s1, const char* s2); void* memset(void* s, int c, size_t n); char* strerror(int errnum); @@ -5878,22 +5857,22 @@ \pnum The functions \tcode{strerror} and \tcode{strtok} are not required to avoid data -races~(\ref{res.on.data.races}). +races\iref{res.on.data.races}. \pnum \indextext{signal-safe!\idxcode{memcpy}}% \indextext{signal-safe!\idxcode{memmove}}% -The functions \tcode{memcpy} and \tcode{memmove} are signal-safe~(\ref{csignal.syn}). +The functions \tcode{memcpy} and \tcode{memmove} are signal-safe\iref{support.signal}. \pnum \begin{note} The functions \tcode{strchr}, \tcode{strpbrk}, \tcode{strrchr}, \tcode{strstr}, and \tcode{memchr}, have different signatures in this International Standard, -but they have the same behavior as in the C standard library~(\ref{library.c}). +but they have the same behavior as in the C standard library\iref{library.c}. \end{note} -\xref ISO C~7.24. +\xref ISO C 7.24 \rSec2[cwchar.syn]{Header \tcode{} synopsis} @@ -6014,19 +5993,19 @@ int wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n); size_t wcsxfrm(wchar_t* s1, const wchar_t* s2, size_t n); int wmemcmp(const wchar_t* s1, const wchar_t* s2, size_t n); - const wchar_t* wcschr(const wchar_t* s, wchar_t c) // see \ref{library.c} - wchar_t* wcschr(wchar_t* s, wchar_t c) // see \ref{library.c} + const wchar_t* wcschr(const wchar_t* s, wchar_t c); // see \ref{library.c} + wchar_t* wcschr(wchar_t* s, wchar_t c); // see \ref{library.c} size_t wcscspn(const wchar_t* s1, const wchar_t* s2); - const wchar_t* wcspbrk(const wchar_t* s1, const wchar_t* s2) // see \ref{library.c} - wchar_t* wcspbrk(wchar_t* s1, const wchar_t* s2) // see \ref{library.c} - const wchar_t* wcsrchr(const wchar_t* s, wchar_t c) // see \ref{library.c} - wchar_t* wcsrchr(wchar_t* s, wchar_t c) // see \ref{library.c} + const wchar_t* wcspbrk(const wchar_t* s1, const wchar_t* s2); // see \ref{library.c} + wchar_t* wcspbrk(wchar_t* s1, const wchar_t* s2); // see \ref{library.c} + const wchar_t* wcsrchr(const wchar_t* s, wchar_t c); // see \ref{library.c} + wchar_t* wcsrchr(wchar_t* s, wchar_t c); // see \ref{library.c} size_t wcsspn(const wchar_t* s1, const wchar_t* s2); - const wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2) // see \ref{library.c} - wchar_t* wcsstr(wchar_t* s1, const wchar_t* s2) // see \ref{library.c} + const wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2); // see \ref{library.c} + wchar_t* wcsstr(wchar_t* s1, const wchar_t* s2); // see \ref{library.c} wchar_t* wcstok(wchar_t* s1, const wchar_t* s2, wchar_t** ptr); - const wchar_t* wmemchr(const wchar_t* s, wchar_t c, size_t n) // see \ref{library.c} - wchar_t* wmemchr(wchar_t* s, wchar_t c, size_t n) // see \ref{library.c} + const wchar_t* wmemchr(const wchar_t* s, wchar_t c, size_t n); // see \ref{library.c} + wchar_t* wmemchr(wchar_t* s, wchar_t c, size_t n); // see \ref{library.c} size_t wcslen(const wchar_t* s); wchar_t* wmemset(wchar_t* s, wchar_t c, size_t n); size_t wcsftime(wchar_t* s, size_t maxsize, const wchar_t* format, const struct tm* timeptr); @@ -6060,7 +6039,7 @@ The functions \tcode{wcschr}, \tcode{wcspbrk}, \tcode{wcsrchr}, \tcode{wcsstr}, and \tcode{wmemchr} have different signatures in this International Standard, -but they have the same behavior as in the C standard library~(\ref{library.c}). +but they have the same behavior as in the C standard library\iref{library.c}. \end{note} \xref ISO C 7.29 @@ -6105,8 +6084,8 @@ \indextext{\idxhdr{cwchar}}% \indexlibrary{\idxhdr{cwchar}}% \begin{note} -The headers \tcode{}~(\ref{cstdlib.syn}) -and \tcode{}~(\ref{cwchar.syn}) +The headers \tcode{}\iref{cstdlib.syn} +and \tcode{}\iref{cwchar.syn} declare the functions described in this subclause. \end{note} @@ -6144,7 +6123,7 @@ \pnum \remarks Calls to these functions -may introduce a data race~(\ref{res.on.data.races}) +may introduce a data race\iref{res.on.data.races} with other calls to the same function. \end{itemdescr} @@ -6172,7 +6151,7 @@ \remarks Calling these functions with an \tcode{mbstate_t*} argument that is a null pointer value -may introduce a data race~(\ref{res.on.data.races}) +may introduce a data race\iref{res.on.data.races} with other calls to the same function with an \tcode{mbstate_t*} argument that is a null pointer value. \end{itemdescr} diff --git a/source/styles.tex b/source/styles.tex index b45fdf0fc2..6ad893ab35 100644 --- a/source/styles.tex +++ b/source/styles.tex @@ -86,7 +86,7 @@ %%-------------------------------------------------- % set heading style for annexes -\newcommand{\Annex}[3]{\chapter[#2]{(#3)\protect\\#2\hfill[#1]}\relax\label{#1}} +\newcommand{\Annex}[3]{\chapter[#2]{(#3)\protect\\#2\hfill[#1]}\relax\annexlabel{#1}} \newcommand{\infannex}[2]{\Annex{#1}{#2}{informative}\addxref{#1}} \newcommand{\normannex}[2]{\Annex{#1}{#2}{normative}\addxref{#1}} diff --git a/source/support.tex b/source/support.tex index 23671c4442..b167bce009 100644 --- a/source/support.tex +++ b/source/support.tex @@ -88,7 +88,7 @@ the C standard library header \tcode{}, except that it does not declare the type \tcode{wchar_t}, that it also declares the type \tcode{byte} -and its associated operations~(\ref{support.types.byteops}), +and its associated operations\iref{support.types.byteops}, and as noted in \ref{support.types.nullptr} and \ref{support.types.layout}. @@ -253,7 +253,7 @@ \ref{c.math.abs}. \begin{note} Several functions have additional overloads in this International Standard, -but they have the same behavior as in the C standard library~(\ref{library.c}). +but they have the same behavior as in the C standard library\iref{library.c}. \end{note} \xref ISO C 7.22 @@ -283,6 +283,8 @@ but not \tcode{(void*)0}.} +\xref ISO C 7.19 + \rSec2[support.types.layout]{Sizes, alignments, and offsets} \pnum @@ -294,14 +296,14 @@ accepts a restricted set of \tcode{\placeholder{type}} arguments in this International Standard. Use of the \tcode{offsetof} macro with a \tcode{\placeholder{type}} -other than a standard-layout class (Clause~\ref{class}) +other than a standard-layout class\iref{class} is conditionally-supported.\footnote{Note that \tcode{offsetof} is required to work as specified even if unary \tcode{operator\&} is overloaded for any of the types involved.} The expression \tcode{offsetof(\placeholder{type}, \placeholder{member-designator})} -is never type-dependent~(\ref{temp.dep.expr}) and it is -value-dependent~(\ref{temp.dep.constexpr}) if and only if \tcode{\placeholder{type}} is +is never type-dependent\iref{temp.dep.expr} and it is +value-dependent\iref{temp.dep.constexpr} if and only if \tcode{\placeholder{type}} is dependent. The result of applying the \tcode{offsetof} macro to a static data member or a function member is undefined. No operation invoked by the \tcode{offsetof} macro shall throw an exception and @@ -317,12 +319,12 @@ The type \tcode{size_t} is an \impldef{type of \tcode{size_t}} unsigned integer type that is large enough -to contain the size in bytes of any object. +to contain the size in bytes of any object\iref{expr.sizeof}. \pnum \begin{note} It is recommended that implementations choose types for \tcode{ptrdiff_t} and \tcode{size_t} -whose integer conversion ranks~(\ref{conv.rank}) are no greater than that of +whose integer conversion ranks\iref{conv.rank} are no greater than that of \tcode{signed long int} unless a larger size is necessary to contain all the possible values. \end{note} @@ -331,10 +333,9 @@ \indexlibrary{\idxcode{max_align_t}}% \tcode{max_align_t} is a POD type whose alignment requirement is at least as great as that of every scalar type, and whose alignment -requirement is supported in every context. +requirement is supported in every context\iref{basic.align}. -\xref Alignment~(\ref{basic.align}), Sizeof~(\ref{expr.sizeof}), Additive -operators~(\ref{expr.add}), Free store~(\ref{class.free}), and ISO C~7.19. +\xref ISO C 7.19 \rSec2[support.types.byteops]{\tcode{byte} type operations} @@ -494,11 +495,11 @@ \pnum The headers -\tcode{}~(\ref{limits.syn}), -\tcode{}~(\ref{climits.syn}), and -\tcode{}~(\ref{cfloat.syn}) +\tcode{}\iref{limits.syn}, +\tcode{}\iref{climits.syn}, and +\tcode{}\iref{cfloat.syn} supply characteristics of imple\-mentation-dependent -arithmetic types~(\ref{basic.fundamental}). +arithmetic types\iref{basic.fundamental}. \rSec2[limits.syn]{Header \tcode{} synopsis} \indextext{\idxhdr{limits}}% @@ -717,13 +718,13 @@ \pnum Non-arithmetic standard types, such as -\tcode{complex}~(\ref{complex}), shall not have specializations. +\tcode{complex}\iref{complex}, shall not have specializations. \rSec3[numeric.limits.members]{\tcode{numeric_limits} members} \pnum \indextext{signal-safe!\idxcode{numeric_limits} members}% -Each member function defined in this subclause is signal-safe~(\ref{csignal.syn}). +Each member function defined in this subclause is signal-safe\iref{support.signal}. \indexlibrarymember{min}{numeric_limits}% \begin{itemdecl} @@ -1158,7 +1159,7 @@ \begin{itemdescr} \pnum \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 +\begin{note} All fundamental types\iref{basic.fundamental} are bounded. This member would be \tcode{false} for arbitrary precision types.\end{note} \pnum @@ -1180,7 +1181,7 @@ \pnum \begin{example} -\tcode{is_modulo} is \tcode{false} for signed integer types~(\ref{basic.fundamental}) +\tcode{is_modulo} is \tcode{false} for signed integer types\iref{basic.fundamental} unless an implementation, as an extension to this International Standard, defines signed integer overflow to wrap. \end{example} @@ -1594,14 +1595,14 @@ The header defines all types and macros the same as the C standard library header \tcode{}. -\xref ISO C~7.20. +\xref ISO C 7.20 \rSec1[support.start.term]{Start and termination} \pnum \indextext{\idxhdr{cstdlib}}% \begin{note} -The header \tcode{}~(\ref{cstdlib.syn}) +The header \tcode{}\iref{cstdlib.syn} declares the functions described in this subclause. \end{note} @@ -1619,9 +1620,9 @@ \remarks The program is terminated without executing destructors for objects of automatic, thread, or static storage duration and without calling functions passed to -\tcode{atexit()}~(\ref{basic.start.term}). +\tcode{atexit()}\iref{basic.start.term}. \indextext{signal-safe!\idxcode{_Exit}}% -The function \tcode{_Exit} is signal-safe~(\ref{csignal.syn}). +The function \tcode{_Exit} is signal-safe\iref{support.signal}. \end{itemdescr} \indexlibrary{\idxcode{abort}}% @@ -1639,9 +1640,9 @@ The program is terminated without executing destructors for objects of automatic, thread, or static storage duration and without calling functions passed to -\tcode{atexit()}~(\ref{basic.start.term}). +\tcode{atexit()}\iref{basic.start.term}. \indextext{signal-safe!\idxcode{abort}}% -The function \tcode{abort} is signal-safe~(\ref{csignal.syn}). +The function \tcode{abort} is signal-safe\iref{support.signal}. \end{itemdescr} \indexlibrary{\idxcode{atexit}}% @@ -1658,9 +1659,9 @@ functions register the function pointed to by \tcode{f} to be called without arguments at normal program termination. It is unspecified whether a call to \tcode{atexit()} that does not -happen before~(\ref{intro.multithread}) a call to \tcode{exit()} will succeed. +happen before\iref{intro.multithread} a call to \tcode{exit()} will succeed. \begin{note} The \tcode{atexit()} functions do not introduce a data -race~(\ref{res.on.data.races}). \end{note} +race\iref{res.on.data.races}. \end{note} \pnum \implimits @@ -1692,7 +1693,7 @@ 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 -\tcode{main} function~(\ref{basic.start.main}) +\tcode{main} function\iref{basic.start.main} contains no automatic objects and executes the call to \tcode{exit()}. Control can be transferred directly to such a @@ -1701,7 +1702,7 @@ \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}).% +not provide a handler for a thrown exception, \tcode{std::terminate()} shall be called\iref{except.terminate}.% \indexlibrary{\idxcode{terminate}}% \item @@ -1746,9 +1747,9 @@ \effects The \tcode{at_quick_exit()} functions register the function pointed to by \tcode{f} to be called without arguments when \tcode{quick_exit} is called. It is unspecified whether a call to \tcode{at_quick_exit()} that does not -happen before~(\ref{intro.multithread}) all calls to \tcode{quick_exit} will succeed. \begin{note} The +happen before\iref{intro.multithread} all calls to \tcode{quick_exit} will succeed. \begin{note} The \tcode{at_quick_exit()} functions do not introduce a -data race~(\ref{res.on.data.races}). \end{note} +data race\iref{res.on.data.races}. \end{note} \begin{note} The order of registration may be indeterminate if \tcode{at_quick_exit} was called from more than one thread. @@ -1795,12 +1796,11 @@ \pnum \remarks \indextext{signal-safe!\idxcode{quick_exit}}% -The function \tcode{quick_exit} is signal-safe~(\ref{csignal.syn}) +The function \tcode{quick_exit} is signal-safe\iref{support.signal} when the functions registered with \tcode{at_quick_exit} are. \end{itemdescr} -\xref~\ref{basic.start}, \ref{basic.start.term}, -ISO C~7.22.4. +\xref ISO C 7.22.4 \rSec1[support.dynamic]{Dynamic memory management} @@ -1867,15 +1867,11 @@ void operator delete[](void* ptr, void*) noexcept; \end{codeblock} -\xref~\ref{intro.memory}, \ref{basic.stc.dynamic}, -\ref{expr.new}, \ref{expr.delete}, \ref{class.free}, -\ref{memory}. - \rSec2[new.delete]{Storage allocation and deallocation} \pnum 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 +apply to the library versions of \tcode{operator new} and \tcode{operator delete}. If the value of an alignment argument passed to any of these functions @@ -1900,9 +1896,9 @@ \pnum \effects The -allocation functions~(\ref{basic.stc.dynamic.allocation}) +allocation functions\iref{basic.stc.dynamic.allocation} called by a -\grammarterm{new-expression}~(\ref{expr.new}) +\grammarterm{new-expression}\iref{expr.new} to allocate \tcode{size} bytes of storage. The second form is called for a type with new-extended alignment, @@ -1919,7 +1915,7 @@ \pnum \required -Return a non-null pointer to suitably aligned storage~(\ref{basic.stc.dynamic}), +Return a non-null pointer to suitably aligned storage\iref{basic.stc.dynamic}, or else throw a \tcode{bad_alloc} \indexlibrary{\idxcode{bad_alloc}}% @@ -1940,12 +1936,12 @@ \item Returns a pointer to the allocated storage if the attempt is successful. Otherwise, if the -current \tcode{new_handler}~(\ref{get.new.handler}) is +current \tcode{new_handler}\iref{get.new.handler} is a null pointer value, throws \tcode{bad_alloc}. \item Otherwise, the function calls the current -\tcode{new_handler} function~(\ref{new.handler}). +\tcode{new_handler} function\iref{new.handler}. If the called function returns, the loop repeats. \item The loop terminates when an attempt to allocate the requested storage is @@ -1977,7 +1973,7 @@ \pnum \required -Return a non-null pointer to suitably aligned storage~(\ref{basic.stc.dynamic}), +Return a non-null pointer to suitably aligned storage\iref{basic.stc.dynamic}, or else return a null pointer. Each of these nothrow versions of \tcode{operator new} @@ -2016,9 +2012,9 @@ \pnum \effects The -deallocation functions~(\ref{basic.stc.dynamic.deallocation}) +deallocation functions\iref{basic.stc.dynamic.deallocation} called by a -\grammarterm{delete-expression} +\grammarterm{delete-expression}\iref{expr.delete} to render the value of \tcode{ptr} invalid. \pnum @@ -2049,7 +2045,7 @@ \pnum \requires -If an implementation has strict pointer safety~(\ref{basic.stc.dynamic.safety}) +If an implementation has strict pointer safety\iref{basic.stc.dynamic.safety} then \tcode{ptr} shall be a safely-derived pointer. \pnum @@ -2115,7 +2111,7 @@ \pnum \effects The -deallocation functions~(\ref{basic.stc.dynamic.deallocation}) +deallocation functions\iref{basic.stc.dynamic.deallocation} called by the implementation to render the value of \tcode{ptr} invalid when the constructor invoked from a nothrow @@ -2139,7 +2135,7 @@ \pnum \requires -If an implementation has strict pointer safety~(\ref{basic.stc.dynamic.safety}) +If an implementation has strict pointer safety\iref{basic.stc.dynamic.safety} then \tcode{ptr} shall be a safely-derived pointer. \pnum @@ -2170,9 +2166,9 @@ \pnum \effects The -allocation functions~(\ref{basic.stc.dynamic.allocation}) +allocation functions\iref{basic.stc.dynamic.allocation} called by the array form of a -\grammarterm{new-expression}~(\ref{expr.new}) +\grammarterm{new-expression}\iref{expr.new} to allocate \tcode{size} bytes of storage. The second form is called for a type with new-extended alignment, @@ -2239,7 +2235,7 @@ \pnum \required -Return a non-null pointer to suitably aligned storage~(\ref{basic.stc.dynamic}), +Return a non-null pointer to suitably aligned storage\iref{basic.stc.dynamic}, or else return a null pointer. Each of these nothrow versions of \tcode{operator new[]} @@ -2270,7 +2266,7 @@ \pnum \effects The -deallocation functions~(\ref{basic.stc.dynamic.deallocation}) +deallocation functions\iref{basic.stc.dynamic.deallocation} called by the array form of a \grammarterm{delete-expression} to render the value of \tcode{ptr} invalid. @@ -2303,7 +2299,7 @@ \pnum \requires -If an implementation has strict pointer safety~(\ref{basic.stc.dynamic.safety}) +If an implementation has strict pointer safety\iref{basic.stc.dynamic.safety} then \tcode{ptr} shall be a safely-derived pointer. \pnum @@ -2350,7 +2346,7 @@ \pnum \effects The -deallocation functions~(\ref{basic.stc.dynamic.deallocation}) +deallocation functions\iref{basic.stc.dynamic.deallocation} called by the implementation to render the value of \tcode{ptr} invalid when the constructor invoked from a nothrow @@ -2374,7 +2370,7 @@ \pnum \requires -If an implementation has strict pointer safety~(\ref{basic.stc.dynamic.safety}) +If an implementation has strict pointer safety\iref{basic.stc.dynamic.safety} then \tcode{ptr} shall be a safely-derived pointer. \pnum @@ -2397,7 +2393,7 @@ \pnum These functions are reserved; a \Cpp program may not define functions that displace -the versions in the \Cpp standard library~(\ref{constraints}). +the versions in the \Cpp standard library\iref{constraints}. The provisions of~\ref{basic.stc.dynamic} do not apply to these reserved placement forms of \tcode{operator new} and \tcode{operator delete}. @@ -2453,7 +2449,7 @@ \pnum \requires -If an implementation has strict pointer safety~(\ref{basic.stc.dynamic.safety}) +If an implementation has strict pointer safety\iref{basic.stc.dynamic.safety} then \tcode{ptr} shall be a safely-derived pointer. \pnum @@ -2461,7 +2457,7 @@ Default function called when any part of the initialization in a placement \grammarterm{new-expression} that invokes the library's non-array placement operator new -terminates by throwing an exception~(\ref{expr.new}). +terminates by throwing an exception\iref{expr.new}. \end{itemdescr} \indexlibrary{\idxcode{delete}!\idxcode{operator}}% @@ -2476,7 +2472,7 @@ \pnum \requires -If an implementation has strict pointer safety~(\ref{basic.stc.dynamic.safety}) +If an implementation has strict pointer safety\iref{basic.stc.dynamic.safety} then \tcode{ptr} shall be a safely-derived pointer. \pnum @@ -2484,7 +2480,7 @@ Default function called when any part of the initialization in a placement \grammarterm{new-expression} that invokes the library's array placement operator new -terminates by throwing an exception~(\ref{expr.new}). +terminates by throwing an exception\iref{expr.new}. \end{itemdescr} \rSec3[new.delete.dataraces]{Data races} @@ -2498,10 +2494,10 @@ versions of \tcode{operator delete}, user replacement versions of \tcode{operator delete}, the C standard library function \tcode{free}, and the C standard library function \tcode{realloc} shall not -introduce a data race~(\ref{res.on.data.races}). +introduce a data race\iref{res.on.data.races}. Calls to these functions that allocate or deallocate a particular unit of storage shall occur in a single total order, and each such deallocation call -shall happen before~(\ref{intro.multithread}) the next allocation (if any) in +shall happen before\iref{intro.multithread} the next allocation (if any) in this order. \rSec2[alloc.errors]{Storage allocation errors} @@ -2565,7 +2561,7 @@ \pnum \remarks -The message may be a null-terminated multibyte string~(\ref{multibyte.strings}), +The message may be a null-terminated multibyte string\iref{multibyte.strings}, suitable for conversion and display as a \tcode{wstring}~(\ref{string.classes}, \ref{locale.codecvt}). \end{itemdescr} @@ -2587,7 +2583,7 @@ The class \tcode{bad_array_new_length} defines the type of objects thrown as exceptions by the implementation to report an attempt to allocate an array of size less than zero or -greater than an \impldef{maximum size of an allocated object} limit~(\ref{expr.new}). +greater than an \impldef{maximum size of an allocated object} limit\iref{expr.new}. \indexlibrary{\idxcode{bad_array_new_length}!constructor}% \begin{itemdecl} @@ -2596,7 +2592,7 @@ \begin{itemdescr} \pnum -\effects constructs an object of class \tcode{bad_array_new_length}. +\effects Constructs an object of class \tcode{bad_array_new_length}. \end{itemdescr} \indexlibrarymember{what}{bad_array_new_length}% @@ -2611,7 +2607,7 @@ \pnum \remarks -The message may be a null-terminated multibyte string~(\ref{multibyte.strings}), +The message may be a null-terminated multibyte string\iref{multibyte.strings}, suitable for conversion and display as a \tcode{wstring}~(\ref{string.classes}, \ref{locale.codecvt}). \end{itemdescr} @@ -2630,7 +2626,7 @@ to be called by \tcode{operator new()} or -\tcode{operator new[]()}~(\ref{new.delete}) when they cannot satisfy a request for additional storage. +\tcode{operator new[]()}\iref{new.delete} when they cannot satisfy a request for additional storage. \pnum \required @@ -2698,8 +2694,8 @@ \pnum \requires \tcode{p} represents the address \placeholder{A} of a byte in memory. -An object \placeholder{X} that is within its lifetime~(\ref{basic.life}) -and whose type is similar~(\ref{conv.qual}) to \tcode{T} +An object \placeholder{X} that is within its lifetime\iref{basic.life} +and whose type is similar\iref{conv.qual} to \tcode{T} is located at the address \placeholder{A}. All bytes of storage that would be reachable through the result are reachable through \tcode{p} (see below). @@ -2742,7 +2738,7 @@ struct X { const int n; }; X *p = new X{3}; const int a = p->n; -new (p) X{5}; // \tcode{p} does not point to new object (\ref{basic.life}) because \tcode{X::n} is \tcode{const} +new (p) X{5}; // \tcode{p} does not point to new object\iref{basic.life} because \tcode{X::n} is \tcode{const} const int b = p->n; // undefined behavior const int c = std::launder(p)->n; // OK \end{codeblock} @@ -2823,8 +2819,6 @@ } \end{codeblock} -\xref~\ref{expr.dynamic.cast}, \ref{expr.typeid}. - \rSec2[type.info]{Class \tcode{type_info}} \indexlibrary{\idxcode{type_info}}% @@ -2848,7 +2842,7 @@ \pnum The class \tcode{type_info} -describes type information generated by the implementation. +describes type information generated by the implementation\iref{expr.typeid}. Objects of this class effectively store a pointer to a name for the type, and an encoded value suitable for comparing two types for equality or collating order. The names, encoding rule, and collating sequence for types are all unspecified @@ -2929,7 +2923,7 @@ \pnum \remarks -The message may be a null-terminated multibyte string~(\ref{multibyte.strings}), +The message may be a null-terminated multibyte string\iref{multibyte.strings}, suitable for conversion and display as a \tcode{wstring}~(\ref{string.classes}, \ref{locale.codecvt}) \end{itemdescr} @@ -2956,7 +2950,7 @@ as exceptions by the implementation to report the execution of an invalid \indextext{cast!dynamic}% \tcode{dynamic_cast} -expression~(\ref{expr.dynamic.cast}). +expression\iref{expr.dynamic.cast}. \indexlibrary{\idxcode{bad_cast}!constructor}% \begin{itemdecl} @@ -2996,7 +2990,7 @@ \pnum \remarks -The message may be a null-terminated multibyte string~(\ref{multibyte.strings}), +The message may be a null-terminated multibyte string\iref{multibyte.strings}, suitable for conversion and display as a \tcode{wstring}~(\ref{string.classes}, \ref{locale.codecvt}) \end{itemdescr} @@ -3023,7 +3017,7 @@ thrown as exceptions by the implementation to report a null pointer in a \tcode{typeid} -expression~(\ref{expr.typeid}). +expression\iref{expr.typeid}. \indexlibrary{\idxcode{bad_typeid}!constructor}% \begin{itemdecl} @@ -3063,7 +3057,7 @@ \pnum \remarks -The message may be a null-terminated multibyte string~(\ref{multibyte.strings}), +The message may be a null-terminated multibyte string\iref{multibyte.strings}, suitable for conversion and display as a \tcode{wstring}~(\ref{string.classes}, \ref{locale.codecvt}) \end{itemdescr} @@ -3103,8 +3097,6 @@ } \end{codeblock} -\xref~\ref{except.special}. - \rSec2[exception]{Class \tcode{exception}} \indexlibrary{\idxcode{exception}}% @@ -3192,7 +3184,7 @@ \pnum \remarks -The message may be a null-terminated multibyte string~(\ref{multibyte.strings}), +The message may be a null-terminated multibyte string\iref{multibyte.strings}, suitable for conversion and display as a \tcode{wstring}~(\ref{string.classes}, \ref{locale.codecvt}). The return value remains valid until the exception object from which @@ -3220,7 +3212,7 @@ \tcode{bad_exception} defines the type of the object referenced by the \tcode{exception_ptr} -returned from a call to \tcode{current_exception}~(\ref{propagation}) +returned from a call to \tcode{current_exception}\iref{propagation} when the currently active exception object fails to copy. \indexlibrary{\idxcode{bad_exception}!constructor}% @@ -3261,7 +3253,7 @@ \pnum \remarks -The message may be a null-terminated multibyte string~(\ref{multibyte.strings}), +The message may be a null-terminated multibyte string\iref{multibyte.strings}, suitable for conversion and display as a \tcode{wstring}~(\ref{string.classes}, \ref{locale.codecvt}). \end{itemdescr} @@ -3342,7 +3334,7 @@ \pnum \remarks Called by the implementation when exception -handling must be abandoned for any of several reasons~(\ref{except.terminate}). +handling must be abandoned for any of several reasons\iref{except.terminate}. May also be called directly by the program. \pnum @@ -3365,13 +3357,13 @@ \begin{itemdescr} \pnum \returns -The number of uncaught exceptions~(\ref{except.uncaught}). +The number of uncaught exceptions\iref{except.uncaught}. \pnum \remarks When \tcode{uncaught_exceptions() > 0}, throwing an exception can result in a call of\\ -\tcode{std::terminate()}~(\ref{except.terminate}). +\tcode{std::terminate()}\iref{except.terminate}. \end{itemdescr} \rSec2[propagation]{Exception propagation} @@ -3387,7 +3379,7 @@ \pnum \tcode{exception_ptr} shall satisfy the requirements of -\tcode{NullablePointer}~(\ref{nullablepointer.requirements}). +\tcode{NullablePointer}\iref{nullablepointer.requirements}. \pnum Two non-null values of type \tcode{exception_ptr} are equivalent and compare equal if and @@ -3425,7 +3417,7 @@ \begin{itemdescr} \pnum \returns An \tcode{exception_ptr} object that refers to -the currently handled exception~(\ref{except.handle}) or a copy of the currently +the currently handled exception\iref{except.handle} or a copy of the currently handled exception, or a null \tcode{exception_ptr} object if no exception is being handled. The referenced object shall remain valid at least as long as there is an \tcode{exception_ptr} object that refers to it. @@ -3588,7 +3580,7 @@ The header \tcode{} defines a class template and several support functions related to list-initialization~(see \ref{dcl.init.list}). \indextext{signal-safe!\idxcode{initializer_list} functions}% -All functions specified in this subclause are signal-safe~(\ref{csignal.syn}). +All functions specified in this subclause are signal-safe\iref{support.signal}. \rSec2[initializer_list.syn]{Header \tcode{} synopsis} \indexlibrary{\idxcode{initializer_list}}% @@ -3729,14 +3721,14 @@ \tcode{} (signal handling), \tcode{} (variable arguments), and -\tcode{} (runtime environment \tcode{getenv, system}), +\tcode{} (runtime environment \tcode{getenv}, \tcode{system}), provide further compatibility with C code. \pnum Calls to the function \indexlibrary{\idxcode{getenv}}% -\tcode{getenv}~(\ref{cstdlib.syn}) shall not introduce a data -race~(\ref{res.on.data.races}) provided that nothing modifies the environment. +\tcode{getenv}\iref{cstdlib.syn} shall not introduce a data +race\iref{res.on.data.races} provided that nothing modifies the environment. \begin{note} Calls to the POSIX functions \indexlibrary{\idxcode{setenv}}% \tcode{setenv} and @@ -3745,7 +3737,7 @@ environment. \end{note} \pnum -A call to the \tcode{setlocale} function~(\ref{c.locales}) +A call to the \tcode{setlocale} function\iref{c.locales} may introduce a data race with other calls to the \tcode{setlocale} function or with calls to functions that are affected by the current C locale. The implementation shall behave as if no @@ -3794,8 +3786,8 @@ \tcode{operator\&} is overloaded for the type of \tcode{parmN}.} -If the parameter \tcode{parmN} is a pack expansion~(\ref{temp.variadic}) or -an entity resulting from a lambda capture~(\ref{expr.prim.lambda}), +If the parameter \tcode{parmN} is a pack expansion\iref{temp.variadic} or +an entity resulting from a lambda capture\iref{expr.prim.lambda}, the program is ill-formed, no diagnostic required. If the parameter \tcode{parmN} @@ -3803,7 +3795,7 @@ type that results when passing an argument for which there is no parameter, the behavior is undefined. -\xref ISO C~7.16.1.1. +\xref ISO C 7.16.1.1 \rSec2[csetjmp.syn]{Header \tcode{} synopsis} @@ -3837,7 +3829,7 @@ by \tcode{catch} and \tcode{throw} would invoke any non-trivial destructors for any automatic objects. -\xref ISO C~7.13. +\xref ISO C 7.13 \rSec2[csignal.syn]{Header \tcode{} synopsis} @@ -3891,7 +3883,7 @@ \pnum A \defn{plain lock-free atomic operation} is -an invocation of a function \tcode{f} from Clause~\ref{atomics}, +an invocation of a function \tcode{f} from \ref{atomics}, such that: \begin{itemize} @@ -3940,10 +3932,10 @@ \item initialization of a variable with static storage duration requiring dynamic initialization~(\ref{basic.start.dynamic}, \ref{stmt.dcl})% -\footnote{Such initialization might occur because it is the first odr-use~(\ref{basic.def.odr}) of that variable.}; or +\footnote{Such initialization might occur because it is the first odr-use\iref{basic.def.odr} of that variable.}; or \item -waiting for the completion of the initialization of a variable with static storage duration~(\ref{stmt.dcl}). +waiting for the completion of the initialization of a variable with static storage duration\iref{stmt.dcl}. \end{itemize} A signal handler invocation has undefined behavior if it includes @@ -3955,4 +3947,4 @@ with the first argument equal to the signal number corresponding to the signal that caused the invocation of the handler. -\xref ISO C~7.14. +\xref ISO C 7.14 diff --git a/source/tables.tex b/source/tables.tex index 5dc258ec21..4a9071a20b 100644 --- a/source/tables.tex +++ b/source/tables.tex @@ -161,7 +161,7 @@ { \begin{TableBase} \begin{table}[!htb] - \caption[#1]{\label{tab:#2}#1 \textbf{[#2]}} + \caption[#1]{\label{tab:#2}#1} \begin{center} \begin{tabular}{|#3|} } diff --git a/source/templates.tex b/source/templates.tex index bac69bb1c5..7de89d2069 100644 --- a/source/templates.tex +++ b/source/templates.tex @@ -8,14 +8,20 @@ \indextext{type generator|see{template}} \pnum -A \defn{template} defines a family of classes, functions, or variables, or an alias for a -family of types. +A \defn{template} defines a family of classes, functions, or variables, +an alias for a family of types, or a concept. \indextext{\idxcode{template}}% % \begin{bnf} \nontermdef{template-declaration}\br - \terminal{template <} template-parameter-list \terminal{>} declaration + template-head declaration\br + template-head concept-definition +\end{bnf} + +\begin{bnf} +\nontermdef{template-head}\br + \terminal{template} \terminal{<} template-parameter-list \terminal{>} requires-clause\opt \end{bnf} \begin{bnf} @@ -24,17 +30,46 @@ template-parameter-list \terminal{,} template-parameter \end{bnf} +\begin{bnf} +\nontermdef{requires-clause}\br + \terminal{requires} constraint-logical-or-expression +\end{bnf} + +\begin{bnf} +\nontermdef{constraint-logical-or-expression}\br + constraint-logical-and-expression\br + constraint-logical-or-expression \terminal{||} constraint-logical-and-expression +\end{bnf} + +\begin{bnf} +\nontermdef{constraint-logical-and-expression}\br + primary-expression\br + constraint-logical-and-expression \terminal{\&\&} primary-expression +\end{bnf} + +\begin{bnf} +\nontermdef{concept-definition}\br + \terminal{concept} concept-name \terminal{=} constraint-expression \terminal{;} +\end{bnf} + +\begin{bnf} +\nontermdef{concept-name}\br + identifier +\end{bnf} + \begin{note} The \tcode{>} token following the \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} +tokens\iref{temp.names}.\end{note} +\pnum The \grammarterm{declaration} in a \grammarterm{template-declaration} +(if any) shall \begin{itemize} @@ -50,10 +85,15 @@ \item be an \grammarterm{alias-declaration}. \end{itemize} +\pnum A \grammarterm{template-declaration} is a \grammarterm{declaration}. \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 +if its +\grammarterm{template-head} is followed by +either a \grammarterm{concept-definition} or +a \grammarterm{declaration} that +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}% variable is a \defnx{variable template}{template!variable}. A variable template at class scope is a @@ -95,7 +135,7 @@ class name is a \grammarterm{simple-template-id}, -the declaration declares a class template partial specialization~(\ref{temp.class.spec}). +the declaration declares a class template partial specialization\iref{temp.class.spec}. \end{note} \pnum @@ -109,30 +149,30 @@ \pnum \indextext{template name!linkage of}% -A template name has linkage~(\ref{basic.link}). +A template name has linkage\iref{basic.link}. Specializations (explicit or implicit) of a template that has internal linkage are distinct from all specializations in other translation units. -A template, a template explicit specialization~(\ref{temp.expl.spec}), and a class +A template, a template explicit specialization\iref{temp.expl.spec}, and a class template partial specialization shall not have C linkage. Use of a linkage specification other than \tcode{"C"} or \tcode{"C++"} with any of these constructs is conditionally-supported, with \impldef{semantics of linkage specification on templates} semantics. -Template definitions shall obey the one-definition rule~(\ref{basic.def.odr}). +Template definitions shall obey the one-definition rule\iref{basic.def.odr}. \begin{note} Default arguments for function templates and for member functions of class templates are considered definitions for the purpose of template -instantiation~(\ref{temp.decls}) and must also obey the one-definition rule. +instantiation\iref{temp.decls} and must also obey the one-definition rule. \end{note} \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\iref{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}), +functions\iref{dcl.fct} with the same name or by other function templates +with the same name\iref{temp.over}, a template name declared in namespace scope or in class scope shall be unique in that scope. @@ -142,11 +182,11 @@ \begin{itemize} \item a template, -\item an entity defined~(\ref{basic.def}) or created~(\ref{class.temporary}) +\item an entity defined\iref{basic.def} or created\iref{class.temporary} in a templated entity, \item a member of a templated entity, \item an enumerator for an enumeration that is a templated entity, or -\item the closure type of a \grammarterm{lambda-expression}~(\ref{expr.prim.lambda.closure}) +\item the closure type of a \grammarterm{lambda-expression}\iref{expr.prim.lambda.closure} appearing in the declaration of a templated entity. \end{itemize} @@ -155,12 +195,37 @@ templated entity is a templated entity. \end{note} +\pnum +A \grammarterm{template-declaration} is written +in terms of its template parameters. +The optional \grammarterm{requires-clause} following a +\grammarterm{template-parameter-list} allows the specification of +constraints\iref{temp.constr.decl} on template arguments\iref{temp.arg}. +The \grammarterm{requires-clause} introduces the +\grammarterm{constraint-expression} that results from interpreting +the \grammarterm{constraint-logical-or-expression} as a +\grammarterm{constraint-expression}. +The \grammarterm{constraint-logical-or-expression} of a +\grammarterm{requires-clause} is an unevaluated operand\iref{expr}. +\begin{note} +The expression in a \grammarterm{requires-clause} +uses a restricted grammar to avoid ambiguities. +Parentheses can be used to specify arbitrary expressions +in a \grammarterm{requires-clause}. +\begin{example} +\begin{codeblock} +template requires N == sizeof new unsigned short +int f(); // error: parentheses required around \tcode{==} expression +\end{codeblock} +\end{example} +\end{note} + \pnum A function template, member function of a class template, variable template, or static data member of a class template shall be defined in every translation unit in -which it is implicitly instantiated~(\ref{temp.inst}) unless the -corresponding specialization is explicitly instantiated~(\ref{temp.explicit}) +which it is implicitly instantiated\iref{temp.inst} unless the +corresponding specialization is explicitly instantiated\iref{temp.explicit} in some translation unit; no diagnostic is required. \rSec1[temp.param]{Template parameters} @@ -173,7 +238,8 @@ \begin{bnf} \nontermdef{template-parameter}\br type-parameter\br - parameter-declaration + parameter-declaration\br + constrained-parameter \end{bnf} \begin{bnf} @@ -190,12 +256,36 @@ \terminal{typename} \end{bnf} +\begin{bnf} +\nontermdef{constrained-parameter}\br + qualified-concept-name \terminal{...} identifier\opt\br + qualified-concept-name identifier\opt{} default-template-argument\opt +\end{bnf} + +\begin{bnf} +\nontermdef{qualified-concept-name}\br + nested-name-specifier\opt{} concept-name\br + nested-name-specifier\opt{} partial-concept-id +\end{bnf} + +\begin{bnf} +\nontermdef{partial-concept-id}\br + concept-name \terminal{<} template-argument-list\opt{} \terminal{>} +\end{bnf} + +\begin{bnf} +\nontermdef{default-template-argument}\br + \terminal{=} type-id\br + \terminal{=} id-expression\br + \terminal{=} initializer-clause +\end{bnf} + \begin{note} The \tcode{>} token following the \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} +tokens\iref{temp.names}.\end{note} \pnum There is no semantic difference between @@ -292,14 +382,14 @@ \item \tcode{std::nullptr_t}, or -\item a type that contains a placeholder type~(\ref{dcl.spec.auto}). +\item a type that contains a placeholder type\iref{dcl.spec.auto}. \end{itemize} \pnum \begin{note} Other types are disallowed either explicitly below or implicitly by the rules governing the form of -\grammarterm{template-argument}{s}~(\ref{temp.arg}). +\grammarterm{template-argument}{s}\iref{temp.arg}. \end{note} The top-level \grammarterm{cv-qualifier}{s} @@ -368,11 +458,114 @@ \end{codeblock} \end{example} +\pnum +A \grammarterm{partial-concept-id} is +a \grammarterm{concept-name} followed by +a sequence of \grammarterm{template-argument}{s}. +These template arguments +are used to form a \grammarterm{constraint-expression} +as described below. + +\pnum +A \grammarterm{constrained-parameter} declares +a template parameter +whose kind (type, non-type, template) and type +match that of the prototype parameter\iref{temp.concept} +of the concept designated by +the \grammarterm{qualified-concept-name} in +the \grammarterm{constrained-parameter}. +Let \tcode{X} be the prototype parameter of the designated concept. +The declared template parameter is determined by +the kind of \tcode{X} (type, non-type, template) +and the optional ellipsis in the \grammarterm{constrained-parameter} +as follows. + +\begin{itemize} +\item If \tcode{X} is a type \grammarterm{template-parameter}, +the declared parameter is a type \grammarterm{template-parameter}. + +\item If \tcode{X} is a non-type \grammarterm{template-parameter}, +the declared parameter is a non-type \grammarterm{template-parameter} +having the same type as \tcode{X}. + +\item If \tcode{X} is a template \grammarterm{template-parameter}, +the declared parameter is a template \grammarterm{template-parameter} +having the same \grammarterm{template-parameter-list} as \tcode{X}, +excluding default template arguments. + +\item If the \grammarterm{qualified-concept-name} is followed by an ellipsis, +then the declared parameter is a template parameter pack\iref{temp.variadic}. +\end{itemize} + +\begin{example} +\begin{codeblock} +template concept C1 = true; +template class X> concept C2 = true; +template concept C3 = true; +template concept C4 = true; +template concept C5 = true; + +template void f1(); // OK, \tcode{T} is a type \grammarterm{template-parameter} +template void f2(); // OK, \tcode{X} is a template with one \grammarterm{type-parameter} +template void f3(); // OK, \tcode{N} has type \tcode{int} +template void f4(); // OK, \tcode{Ts} is a template parameter pack of types +template void f5(); // OK, \tcode{T} is a type \grammarterm{template-parameter} +template void f6(); // OK, \tcode{Cs} is a template parameter pack of \tcode{char}s +\end{codeblock} +\end{example} + +\pnum +A \grammarterm{constrained-parameter} introduces +a \grammarterm{constraint-expression}\iref{temp.constr.decl}. +The expression is derived from +the \grammarterm{qualified-concept-name} \tcode{Q} in +the \grammarterm{constrained-parameter}, +its designated concept \tcode{C}, and +the declared template parameter \tcode{P}. + +\begin{itemize} +\item First, a template argument \tcode{A} is formed from \tcode{P}. +If \tcode{P} declares a template parameter pack\iref{temp.variadic} +and \tcode{C} is a variadic concept\iref{temp.concept}, +then \tcode{A} is the pack expansion \tcode{P...}. +Otherwise, +\tcode{A} is the \grammarterm{id-expression} \tcode{P}. + +% FIXME: This does not guarantee that the expression has the same +% namespace qualification as Q. +\item Then, an \grammarterm{id-expression} \tcode{E} is formed as follows. +If \tcode{Q} is a \grammarterm{concept-name}, +then \tcode{E} is \tcode{C}. +Otherwise, +\tcode{Q} is a \grammarterm{partial-concept-id} +of the form \tcode{C}, +and \tcode{E} is \tcode{C}. + +\item Finally, if \tcode{P} declares a template parameter pack +and \tcode{C} is not a variadic concept, +\tcode{E} is adjusted to be the \grammarterm{fold-expression} +\tcode{(E \&\& ...)}\iref{expr.prim.fold}. +\end{itemize} + +\tcode{E} is the introduced \grammarterm{constraint-expression}. +\begin{example} +\begin{codeblock} +template concept C1 = true; +template concept C2 = true; +template concept C3 = true; + +template struct s1; // associates \tcode{C1} +template struct s2; // associates \tcode{(C1 \&\& ...)} +template struct s3; // associates \tcode{C2} +template T> struct s4; // associates \tcode{C3} +\end{codeblock} +\end{example} + \pnum A \defnx{default template-argument}{\idxgram{template-argument}!default} is a -\grammarterm{template-argument}~(\ref{temp.arg}) specified after +\grammarterm{template-argument}\iref{temp.arg} specified after \tcode{=} in a \grammarterm{template-parameter}. @@ -381,7 +574,7 @@ may be specified for any kind of \grammarterm{template-parameter} (type, non-type, template) -that is not a template parameter pack~(\ref{temp.variadic}). +that is not a template parameter pack\iref{temp.variadic}. A default \grammarterm{template-argument} may be specified in a template declaration. @@ -400,12 +593,32 @@ that declaration shall be a definition and shall be the only declaration of the function template in the translation unit. +\pnum +The default \grammarterm{template-argument} +of a \grammarterm{constrained-parameter} +shall match the kind (type, non-type, template) +of the declared template parameter. +\begin{example} +\begin{codeblock} +template concept C1 = true; +template concept C2 = true; +template class X> concept C3 = true; + +template struct S0; + +template struct S1; // OK +template struct S2; // OK +template struct S3; // OK +template struct S4; // error: default argument is not a type +\end{codeblock} +\end{example} + \pnum The set of default \grammarterm{template-argument}{s} available for use is obtained by merging the default arguments from all prior declarations of the template in the -same way default function arguments are~(\ref{dcl.fct.default}). +same way default function arguments are\iref{dcl.fct.default}. \begin{example} \begin{codeblock} @@ -437,9 +650,9 @@ A template parameter pack of a function template shall not be followed by another template parameter unless that template parameter can be deduced from the -parameter-type-list~(\ref{dcl.fct}) of the function template or has a -default argument~(\ref{temp.deduct}). -A template parameter of a deduction guide template (\ref{temp.deduct.guide}) +parameter-type-list\iref{dcl.fct} of the function template or has a +default argument\iref{temp.deduct}. +A template parameter of a deduction guide template\iref{temp.deduct.guide} that does not have a default argument shall be deducible from the parameter-type-list @@ -523,8 +736,8 @@ \grammarterm{type-parameter} with an ellipsis prior to its optional \grammarterm{identifier} or is a \grammarterm{parameter-declaration} that declares a parameter -pack~(\ref{dcl.fct}), then the \grammarterm{template-parameter} -is a template parameter pack~(\ref{temp.variadic}). +pack\iref{dcl.fct}, then the \grammarterm{template-parameter} +is a template parameter pack\iref{temp.variadic}. A template parameter pack that is a \grammarterm{parameter-declaration} whose type contains one or more unexpanded parameter packs is a pack expansion. Similarly, a template parameter pack that is a \grammarterm{type-parameter} with a @@ -550,7 +763,7 @@ \rSec1[temp.names]{Names of template specializations} \pnum -A template specialization~(\ref{temp.spec}) can be referred to by a +A template specialization\iref{temp.spec} can be referred to by a \grammarterm{template-id}: \begin{bnf} @@ -584,7 +797,7 @@ \end{bnf} \begin{note} -The name lookup rules~(\ref{basic.lookup}) are used to associate the use of +The name lookup rules\iref{basic.lookup} are used to associate the use of a name with a template declaration; that is, to identify a name as a \grammarterm{template-name}. @@ -598,7 +811,7 @@ \pnum \indextext{\idxcode{<}!template and}% -After name lookup~(\ref{basic.lookup}) finds that a name is a +After name lookup\iref{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 overloaded functions any member of which is a function template, @@ -647,19 +860,19 @@ if it appears outside of a \grammarterm{template-argument-list} or \grammarterm{decltype-specifier}. In a \grammarterm{qualified-id} of a \grammarterm{declarator-id} or -in a \grammarterm{qualified-id} formed by a \grammarterm{class-head-name} (Clause~\ref{class}) or -\grammarterm{enum-head-name}~(\ref{dcl.enum}), +in a \grammarterm{qualified-id} formed by a \grammarterm{class-head-name}\iref{class} or +\grammarterm{enum-head-name}\iref{dcl.enum}, the keyword \tcode{template} shall not appear at the top level. In a \grammarterm{qualified-id} used as the name in a -\grammarterm{typename-specifier}~(\ref{temp.res}), -\grammarterm{elaborated-type-specifier}~(\ref{dcl.type.elab}), -\grammarterm{using-declaration}~(\ref{namespace.udecl}), or -\grammarterm{class-or-decltype} (Clause~\ref{class.derived}), +\grammarterm{typename-specifier}\iref{temp.res}, +\grammarterm{elaborated-type-specifier}\iref{dcl.type.elab}, +\grammarterm{using-declaration}\iref{namespace.udecl}, or +\grammarterm{class-or-decltype}\iref{class.derived}, an optional keyword \tcode{template} appearing at the top level is ignored. In these contexts, a \tcode{<} token is always assumed to introduce a \grammarterm{template-argument-list}. In all other contexts, when naming a template specialization of -a member of an unknown specialization~(\ref{temp.dep.type}), +a member of an unknown specialization\iref{temp.dep.type}, the member template name shall be prefixed by the keyword \tcode{template}. \begin{example} @@ -731,13 +944,60 @@ A \grammarterm{simple-template-id} that names a class template specialization is a -\grammarterm{class-name} -(Clause~\ref{class}). +\grammarterm{class-name}\iref{class}. \pnum A \grammarterm{template-id} that names an alias template specialization is a \grammarterm{type-name}. +\pnum +When the \grammarterm{template-name} +of a \grammarterm{simple-template-id} +names a constrained non-function template +or +a constrained template \grammarterm{template-parameter}, +%%% FIXME: Do we need to say this? +but not a member template +that is a member of an unknown specialization\iref{temp.res}, +and +all \grammarterm{template-argument}{s} +in the \grammarterm{simple-template-id} +are non-dependent\iref{temp.dep.temp}, +the associated constraints\iref{temp.constr.decl} +of the constrained template +shall be satisfied\iref{temp.constr.constr}. +\begin{example} +\begin{codeblock} +template concept C1 = sizeof(T) != sizeof(int); + +template struct S1 { }; +template using Ptr = T*; + +S1* p; // error: constraints not satisfied +Ptr p; // error: constraints not satisfied + +template +struct S2 { Ptr x; }; // error, no diagnostic required + +template +struct S3 { Ptr x; }; // OK, satisfaction is not required + +S3 x; // error: constraints not satisfied + +template class X> +struct S4 { + X x; // error, no diagnostic required +}; + +template concept C2 = sizeof(T) == 1; + +template struct S { }; + +template struct S; // error: constraints not satisfied +template<> struct S { }; // error: constraints not satisfied +\end{codeblock} +\end{example} + \rSec1[temp.arg]{Template arguments} \pnum @@ -755,7 +1015,7 @@ parameter declared by the template in its \grammarterm{template-parameter-list}. When the parameter declared by the template is a template -parameter pack~(\ref{temp.variadic}), it will correspond to zero or more +parameter pack\iref{temp.variadic}, it will correspond to zero or more \grammarterm{template-argument}{s}. \begin{example} \begin{codeblock} @@ -881,7 +1141,7 @@ \end{example} \pnum -An explicit destructor call~(\ref{class.dtor}) for an object that has a type +An explicit destructor call\iref{class.dtor} for an object that has a type that is a class template specialization may explicitly specify the \grammarterm{template-argument}{s}. \begin{example} @@ -920,7 +1180,7 @@ \pnum When a \grammarterm{simple-template-id} does not name a function, a default \grammarterm{template-argument} is -implicitly instantiated~(\ref{temp.inst}) +implicitly instantiated\iref{temp.inst} when the value of that default argument is needed. \begin{example} \begin{codeblock} @@ -932,7 +1192,7 @@ \pnum A \grammarterm{template-argument} followed by an ellipsis is -a pack expansion~(\ref{temp.variadic}). +a pack expansion\iref{temp.variadic}. \rSec2[temp.arg.type]{Template type arguments} @@ -967,7 +1227,7 @@ \end{codeblock} \end{example} \begin{note} -A template type argument may be an incomplete type~(\ref{basic.types}). +A template type argument may be an incomplete type\iref{basic.types}. \end{note} \rSec2[temp.arg.nontype]{Template non-type arguments} @@ -977,9 +1237,9 @@ contains a placeholder type~(\ref{dcl.spec.auto}, \ref{temp.param}), the deduced parameter type is determined from the type of the \grammarterm{template-argument} -by placeholder type deduction~(\ref{dcl.type.auto.deduct}). +by placeholder type deduction\iref{dcl.type.auto.deduct}. If a deduced parameter type is not permitted -for a \grammarterm{template-parameter} declaration~(\ref{temp.param}), +for a \grammarterm{template-parameter} declaration\iref{temp.param}, the program is ill-formed. \pnum @@ -989,25 +1249,25 @@ \grammarterm{template-parameter} shall be a converted -constant expression~(\ref{expr.const}) +constant expression\iref{expr.const} of the type of the \grammarterm{template-parameter}. For a non-type \grammarterm{template-parameter} of reference or pointer type, the value of the constant expression shall not refer to (or for a pointer type, shall not be the address of): \begin{itemize} -\item a subobject~(\ref{intro.object}), -\item a temporary object~(\ref{class.temporary}), -\item a string literal~(\ref{lex.string}), -\item the result of a \tcode{typeid} expression~(\ref{expr.typeid}), or -\item a predefined \tcode{__func__} variable~(\ref{dcl.fct.def.general}). +\item a subobject\iref{intro.object}, +\item a temporary object\iref{class.temporary}, +\item a string literal\iref{lex.string}, +\item the result of a \tcode{typeid} expression\iref{expr.typeid}, or +\item a predefined \tcode{__func__} variable\iref{dcl.fct.def.general}. \end{itemize} \begin{note} If the \grammarterm{template-argument} represents a set of overloaded functions (or a pointer or member pointer to such), -the matching function is selected from the set~(\ref{over.over}). +the matching function is selected from the set\iref{over.over}. \end{note} \pnum @@ -1042,7 +1302,7 @@ \pnum \begin{note} -A string literal~(\ref{lex.string}) +A string literal\iref{lex.string} is not an acceptable \grammarterm{template-argument}. \begin{example} @@ -1117,7 +1377,7 @@ parameter. \pnum -Any partial specializations~(\ref{temp.class.spec}) associated with the +Any partial specializations\iref{temp.class.spec} associated with the primary class template or primary variable template are considered when a specialization based on the template \grammarterm{template-parameter} @@ -1152,10 +1412,10 @@ \grammarterm{template-parameter-list} of \tcode{P}. Two template parameters match if they are of the same kind (type, non-type, template), for non-type \grammarterm{template-parameter}{s}, their types are -equivalent~(\ref{temp.over.link}), and for template \grammarterm{template-parameter}{s}, +equivalent\iref{temp.over.link}, and for template \grammarterm{template-parameter}{s}, each of their corresponding \grammarterm{template-parameter}{s} matches, recursively. When \tcode{P}'s \grammarterm{template-parameter-list} contains a template parameter -pack~(\ref{temp.variadic}), the template parameter pack will match zero or more template +pack\iref{temp.variadic}, the template parameter pack will match zero or more template parameters or template parameter packs in the \grammarterm{template-parameter-list} of \tcode{A} with the same type and form as the template parameter pack in \tcode{P} (ignoring whether those template parameters are template parameter packs). @@ -1179,7 +1439,6 @@ Z zd; // OK \end{codeblock} \end{example} - \begin{example} \begin{codeblock} template struct eval; @@ -1200,6 +1459,22 @@ eval> eE; // error: \tcode{E} does not match \tcode{TT} in partial specialization \end{codeblock} \end{example} +\begin{example} +\begin{codeblock} +template concept C = requires (T t) { t.f(); }; +template concept D = C && requires (T t) { t.g(); }; + +template class P> struct S { }; + +template struct X { }; +template struct Y { }; +template struct Z { }; + +S s1; // OK, \tcode{X} and \tcode{P} have equivalent constraints +S s2; // error: \tcode{P} is not at least as specialized as \tcode{Y} +S s3; // OK, \tcode{P} is at least as specialized as \tcode{Z} +\end{codeblock} +\end{example} \pnum A template \grammarterm{template-parameter} \tcode{P} is @@ -1209,7 +1484,7 @@ is at least as specialized as the function template corresponding to \tcode{A} according to the partial ordering rules -for function templates~(\ref{temp.func.order}). +for function templates\iref{temp.func.order}. Given an invented class template \tcode{X} with the template parameter list of \tcode{A} (including default arguments): @@ -1226,12 +1501,470 @@ in the template parameter list of the function template, a corresponding template argument \tcode{AA} is formed. If \tcode{PP} declares a parameter pack, -then \tcode{AA} is the pack expansion \tcode{PP...}~(\ref{temp.variadic}); +then \tcode{AA} is the pack expansion \tcode{PP...}\iref{temp.variadic}; otherwise, \tcode{AA} is the \grammarterm{id-expression} \tcode{PP}. \end{itemize} If the rewrite produces an invalid type, then \tcode{P} is not at least as specialized as \tcode{A}. +\rSec1[temp.constr]{Template constraints} + +\pnum +\begin{note} +This section defines the meaning of constraints on template arguments. +The abstract syntax and satisfaction rules are defined +in \ref{temp.constr.constr}. +Constraints are associated with declarations in \ref{temp.constr.decl}. +Declarations are partially ordered by their associated constraints\iref{temp.constr.order}. +\end{note} + +\rSec2[temp.constr.constr]{Constraints} + +\pnum +A \defn{constraint} is a sequence of logical operations and +operands that specifies requirements on template arguments. +The operands of a logical operation are constraints. +There are three different kinds of constraints: +\begin{itemize} +\item conjunctions\iref{temp.constr.op}, +\item disjunctions\iref{temp.constr.op}, and +\item atomic constraints\iref{temp.constr.atomic} +\end{itemize} + +\pnum +In order for a constrained template to be instantiated\iref{temp.spec}, +its associated constraints\iref{temp.constr.decl} +shall be satisfied as described in the following subsections. +\begin{note} +Forming the name of a specialization of +a class template, +a variable template, or +an alias template\iref{temp.names} +requires the satisfaction of its constraints. +Overload resolution\iref{over.match.viable} +requires the satisfaction of constraints +on functions and function templates. +\end{note} + +\rSec3[temp.constr.op]{Logical operations} + +\pnum +There are two binary logical operations on constraints: conjunction +and disjunction. +\begin{note} +These logical operations have no corresponding \Cpp syntax. +For the purpose of exposition, conjunction is spelled +using the symbol $\land$ and disjunction is spelled using the +symbol $\lor$. +The operands of these operations are called the left +and right operands. In the constraint $A \land B$, +$A$ is the left operand, and $B$ is the right operand. +\end{note} + +\pnum +A \defn{conjunction} is a constraint taking two +operands. +To determine if a conjunction is +\defnx{satisfied}{constraint!satisfaction!conjunction}, +the satisfaction of +the first operand is checked. +If that is not satisfied, the conjunction is not satisfied. +Otherwise, the conjunction is satisfied if and only if the second +operand is satisfied. + +\pnum +A \defn{disjunction} is a constraint taking two +operands. +% +To determine if a disjunction is +\defnx{satisfied}{constraint!satisfaction!disjunction}, +the satisfaction of +the first operand is checked. +If that is satisfied, the disjunction is satisfied. +Otherwise, the disjunction is satisfied if and only if the second +operand is satisfied. + +\pnum +\begin{example} +\begin{codeblock} +template + constexpr bool get_value() { return T::value; } + +template + requires (sizeof(T) > 1) && get_value() + void f(T); // has associated constraint \tcode{sizeof(T) > 1 $\land$ get_value()} + +void f(int); + +f('a'); // OK: calls \tcode{f(int)} +\end{codeblock} +In the satisfaction of the associated constraints\iref{temp.constr.decl} +of \tcode{f}, the constraint \tcode{sizeof(char) > 1} is not satisfied; +the second operand is not checked for satisfaction. +\end{example} + +\rSec3[temp.constr.atomic]{Atomic constraints} + +\pnum +An \defn{atomic constraint} is formed from +an expression \tcode{E} +and a mapping from the template parameters +that appear within \tcode{E} to +template arguments involving the +template parameters of the constrained entity, +called the \defn{parameter mapping}\iref{temp.constr.decl}. +\begin{note} +Atomic constraints are formed by constraint normalization\iref{temp.constr.normal}. +\tcode{E} is never a logical AND expression\iref{expr.log.and} +nor a logical OR expression\iref{expr.log.or}. +\end{note} + +\pnum +Two atomic constraints are +\indextext{identical!atomic constraints|see{atomic constraint!identical}}% +\defnx{identical}{atomic constraint!identical} +if they are formed from the same +\grammarterm{expression} +and the targets of the parameter mappings are equivalent +according to the rules for expressions described in \ref{temp.over.link}. + +\pnum +To determine if an atomic constraint is +\defnx{satisfied}{constraint!satisfaction!atomic}, +the parameter mapping and template arguments are +first substituted into its expression. +If substitution results in an invalid type or expression, +the constraint is not satisfied. +Otherwise, the lvalue-to-rvalue conversion\iref{conv.lval} +is performed if necessary, +and \tcode{E} shall be a constant expression of type \tcode{bool}. +The constraint is satisfied if and only if evaluation of \tcode{E} +results in \tcode{true}. +\begin{example} +\begin{codeblock} +template concept C = + sizeof(T) == 4 && !true; // requires atomic constraints + // \tcode{sizeof(T) == 4} and \tcode{!true} + +template struct S { + constexpr operator bool() const { return true; } +}; + +template requires (S{}) +void f(T); // \#1 +void f(int); // \#2 + +void g() { + f(0); // error: expression \tcode{S\{\}} does not have type \tcode{bool} +} // while checking satisfaction of deduced arguments of \#1; + // call is ill-formed even though \#2 is a better match +\end{codeblock} +\end{example} + +\rSec2[temp.constr.decl]{Constrained declarations} + +\pnum +A template declaration\iref{temp} +or function declaration\iref{dcl.fct} +can be constrained by the use of a \grammarterm{requires-clause}. +This allows the specification of constraints for that declaration as +an expression: + +\begin{bnf} +\nontermdef{constraint-expression}\br + logical-or-expression +\end{bnf} + +\pnum +Constraints can also be associated with a declaration through the use of +\grammarterm{constrained-parameter}{s} in a +\grammarterm{template-parameter-list}. +Each of these forms introduces additional \grammarterm{constraint-expression}{s} +that are used to constrain the declaration. + +\pnum +\indextext{constraint!associated|see{associated constraints}}% +A template's \defn{associated constraints} are defined as follows: + +\begin{itemize} +\item If there are no introduced \grammarterm{constraint-expression}{s}, +the declaration has no associated constraints. + +\item Otherwise, if there is a single introduced \grammarterm{constraint-expression}, +the associated constraints are the normal form\iref{temp.constr.normal} +of that expression. + +\item Otherwise, the associated constraints are the normal form of a logical +AND expression\iref{expr.log.and} whose operands are in the +following order: + +\begin{itemize} +\item +the \grammarterm{constraint-expression} introduced by each +\grammarterm{constrained-parameter}\iref{temp.param} in the +declaration's \grammarterm{template-parameter-list}, in +order of appearance, and + +\item +the \grammarterm{constraint-expression} introduced +by a \grammarterm{requires-clause} following a +\grammarterm{template-parameter-list}\iref{temp}, and + +\item +the \grammarterm{constraint-expression} introduced by a trailing +\grammarterm{requires-clause}\iref{dcl.decl} +of a function declaration\iref{dcl.fct}. +\end{itemize} +\end{itemize} + +The formation of the associated constraints +establishes the order in which constraints are instantiated when checking +for satisfaction\iref{temp.constr.constr}. +\begin{example} +\begin{codeblock} +template concept C = true; + +template void f1(T); +template requires C void f2(T); +template void f3(T) requires C; +\end{codeblock} +The functions \tcode{f1}, \tcode{f2}, and \tcode{f3} have the associated +constraint \tcode{C}. + +\begin{codeblock} +template concept C1 = true; +template concept C2 = sizeof(T) > 0; + +template void f4(T) requires C2; +template requires C1 && C2 void f5(T); +\end{codeblock} +The associated constraints of \tcode{f4} and \tcode{f5} +are \tcode{C1 $\land$ C2}. + +\begin{codeblock} +template requires C2 void f6(); +template requires C1 void f7(); +\end{codeblock} +The associated constraints of +\tcode{f6} are \tcode{C1 $\land$ C2}, +and those of +\tcode{f7} are \tcode{C2 $\land$ C1}. +\end{example} + +\rSec2[temp.constr.normal]{Constraint normalization} +\indextext{constraint!normalization|(}% + +\pnum +The \defn{normal form} of an \grammarterm{expression} \tcode{E} is +a constraint\iref{temp.constr.constr} that is defined as follows: +% +\begin{itemize} +\item +The normal form of an expression \tcode{( E )} is +the normal form of \tcode{E}. + +\item +The normal form of an expression \tcode{E1 || E2} is +the disjunction\iref{temp.constr.op} of +the normal forms of \tcode{E1} and \tcode{E2}. + +\item +The normal form of an expression \tcode{E1 \&\& E2} +is the conjunction of +the normal forms of \tcode{E1} and \tcode{E2}. + +\item +The normal form of an \grammarterm{id-expression} of the form +\tcode{C}, where \tcode{C} names a concept, +is the normal form of the \grammarterm{constraint-expression} of \tcode{C}, +after substituting \tcode{A$_1$, A$_2$, ..., A$_n$} for +\tcode{C}{'s} respective template parameters in the +parameter mappings in each atomic constraint. +If any such substitution results in an invalid type or expression, +the program is ill-formed; no diagnostic is required. +\begin{example} +\begin{codeblock} +template concept A = T::value || true; +template concept B = A; +template concept C = B; +\end{codeblock} +Normalization of \tcode{B}{'s} \grammarterm{constraint-expression} +is valid and results in +\tcode{T::value} (with the mapping \tcode{T}$\mapsto$\tcode{U*}) +$\lor$ +\tcode{true} (with an empty mapping), +despite the expression \tcode{T::value} being ill-formed +for a pointer type \tcode{T}. +Normalization of \tcode{C}{'s} \grammarterm{constraint-expression} +results in the program being ill-formed, +because it would form the invalid type \tcode{T\&*} +in the parameter mapping. +\end{example} + +\item +The normal form of any other expression \tcode{E} is +the atomic constraint +whose expression is \tcode{E} and +whose parameter mapping is the identity mapping. +\end{itemize} + +\pnum +The process of obtaining the normal form of a +\grammarterm{constraint-expression} +is called +\defnx{normalization}{normalization|see{constraint, normalization}}. +\begin{note} +Normalization of \grammarterm{constraint-expression}{s} +is performed +when determining the associated constraints\iref{temp.constr.constr} +of a declaration +and +when evaluating the value of an \grammarterm{id-expression} +that names a concept specialization\iref{expr.prim.id}. +\end{note} + +\pnum +\begin{example} +\begin{codeblock} +template concept C1 = sizeof(T) == 1; +template concept C2 = C1() && 1 == 2; +template concept C3 = requires { typename T::type; }; +template concept C4 = requires (T x) { ++x; } + +template void f1(U); // \#1 +template void f2(U); // \#2 +template void f3(U); // \#3 +\end{codeblock} +The associated constraints of \#1 are +\tcode{sizeof(T) == 1} (with mapping \tcode{T}$\mapsto$\tcode{U}) $\land$ \tcode{1 == 2}.\\ +The associated constraints of \#2 are +\tcode{requires \{ typename T::type; \}} (with mapping \tcode{T}$\mapsto$\tcode{U}).\\ +The associated constraints of \#3 are +\tcode{requires (T x) \{ ++x; \}} (with mapping \tcode{T}$\mapsto$\tcode{U}). +\end{example} +\indextext{constraint!normalization|)} + +\rSec2[temp.constr.order]{Partial ordering by constraints} +\indextext{subsume|see{constraint, subsumption}} + +\pnum +A constraint $P$ is said to subsume another constraint $Q$ +if it can be determined that $P$ implies $Q$, up to +the identity\iref{temp.constr.atomic} +of atomic constraints in $P$ and $Q$, +as described below. +\begin{example} +Subsumption does not determine if the atomic constraint +\tcode{N >= 0}\iref{temp.constr.atomic} subsumes \tcode{N > 0} for some +integral template argument \tcode{N}. +\end{example} + +\pnum +In order to determine if a constraint $P$ subsumes a constraint $Q$, +$P$ is transformed into disjunctive normal form, and +$Q$ is transformed into conjunctive normal form\footnote{% +A constraint is in disjunctive normal form when it is a disjunction of +clauses where each clause is a conjunction of atomic constraints. +% +Similarly, a constraint is in conjunctive normal form when it is a conjunction +of clauses where each clause is a disjunction of atomic constraints. +% +\begin{example} +Let $A$, $B$, and $C$ be atomic constraints, which can be grouped +using parentheses. +% +The constraint $A \land (B \lor C)$ is in +conjunctive normal form. +% +Its conjunctive clauses are $A$ and $(B \lor C)$. +% +The disjunctive normal form of the constraint +$A \land (B \lor C)$ +is +$(A \land B) \lor (A \land C)$. +% +Its disjunctive clauses are $(A \land B)$ and +$(A \land C)$. +\end{example}% +}. +% +Then, $P$ \defnx{subsumes}{constraint!subsumption} $Q$ if and only if, +for every disjunctive clause $P_i$ in the disjunctive normal +form of $P$, $P_i$ subsumes every conjunctive clause $Q_j$ +in the conjuctive normal form of $Q$, where + +\begin{itemize} +\item +a disjunctive clause $P_i$ subsumes a conjunctive clause $Q_j$ if and only +if there exists an atomic constraint $P_{ia}$ in $P_i$ for which there exists +an atomic constraint $Q_{jb}$ in $Q_j$ such that $P_{ia}$ subsumes $Q_{jb}$, and + +\item an atomic constraint $A$ subsumes another atomic constraint +$B$ if and only if the $A$ and $B$ are identical using the +rules described in \ref{temp.constr.atomic}. +\end{itemize} +% +\begin{example} +Let $A$ and $B$ be atomic constraints\iref{temp.constr.atomic}. +% +The constraint $A \land B$ subsumes $A$, but $A$ does not subsume $A \land B$. +% +The constraint $A$ subsumes $A \lor B$, but $A \lor B$ does not subsume $A$. +% +Also note that every constraint subsumes itself. +\end{example} + +\pnum +\begin{note} +The subsumption relation defines a partial ordering on constraints. +This partial ordering is used to determine + +\begin{itemize} +\item the best viable candidate of non-template functions\iref{over.match.best}, +\item the address of a non-template function\iref{over.over}, +\item the matching of template template arguments\iref{temp.arg.template}, +\item the partial ordering of class template specializations\iref{temp.class.order}, and +\item the partial ordering of function templates\iref{temp.func.order}. +\end{itemize} +\end{note} + +%%% FIXME: We need to substitute the deductions from partial ordering +%%% into the constraints before comparing them, otherwise they will be +%%% referring to unrelated template parameters. +\pnum +A declaration \tcode{D1} is +\defn{at least as constrained} as +a declaration \tcode{D2} if + +\begin{itemize} +\item \tcode{D1} and \tcode{D2} are both constrained declarations and +\tcode{D1}'s associated constraints subsume those of \tcode{D2}; or + +\item \tcode{D2} has no associated constraints. +\end{itemize} + +\pnum +A declaration \tcode{D1} is \defn{more constrained} +than another declaration \tcode{D2} when \tcode{D1} is at least as +constrained as \tcode{D2}, and \tcode{D2} is not at least as +constrained as \tcode{D1}. +\begin{example} +\begin{codeblock} +template concept C1 = requires(T t) { --t; }; +template concept C2 = C1 && requires(T t) { *t; }; + +template void f(T); // \#1 +template void f(T); // \#2 +template void g(T); // \#3 +template void g(T); // \#4 + +f(0); // selects \#1 +f((int*)0); // selects \#2 +g(true); // selects \#3 because \tcode{C1} is not satisfied +g(0); // selects \#4 +\end{codeblock} +\end{example} + \rSec1[temp.type]{Type equivalence} \pnum @@ -1302,11 +2035,11 @@ \end{example} \pnum -If an expression $e$ is type-dependent~(\ref{temp.dep.expr}), +If an expression $e$ is type-dependent\iref{temp.dep.expr}, \tcode{decltype($e$)} denotes a unique dependent type. Two such \grammarterm{decltype-specifier}{s} refer to the same type only if their \grammarterm{expression}{s} are -equivalent~(\ref{temp.over.link}). +equivalent\iref{temp.over.link}. \begin{note} However, such a type may be aliased, e.g., by a \grammarterm{typedef-name}. \end{note} @@ -1328,20 +2061,37 @@ \end{codeblock} \end{example} \begin{note} -However, this syntax is allowed in class template partial specializations~(\ref{temp.class.spec}). +However, this syntax is allowed in class template partial specializations\iref{temp.class.spec}. \end{note} \pnum For purposes of name lookup and instantiation, -default arguments and \grammarterm{noexcept-specifier}{s} of function -templates and default arguments and \grammarterm{noexcept-specifier}{s} of -member functions of class templates are considered definitions; -each default argument or \grammarterm{noexcept-specifier} is a separate -definition which is unrelated to -the function template definition or to any other default arguments or +default arguments, +\grammarterm{partial-concept-id}{s}, +\grammarterm{requires-clause}{s}\iref{temp}, +and +\grammarterm{noexcept-specifier}{s} +of function templates +and +of member functions of class templates +are considered definitions; +each +default argument, +\grammarterm{partial-concept-id}{s}, +\grammarterm{requires-clause}, +or +\grammarterm{noexcept-specifier} +is a separate definition +which is unrelated +to the templated function definition or +to any other +default arguments +\grammarterm{partial-concept-id}{s}, +\grammarterm{requires-clause}{s}, +or \grammarterm{noexcept-specifier}{s}. For the purpose of instantiation, the substatements of a constexpr if -statement~(\ref{stmt.if}) are considered definitions. +statement\iref{stmt.if} are considered definitions. \pnum Because an \grammarterm{alias-declaration} cannot declare a @@ -1392,8 +2142,8 @@ a member template of a class template is defined outside of the class template definition, the member definition is defined as a template definition in which the -\grammarterm{template-parameter}{s} -are those of the class template. +\grammarterm{template-head} is equivalent to that +of the class template\iref{temp.over.link}. The names of the template parameters used in the definition of the member may be different from the template parameter names used in the class template definition. @@ -1403,7 +2153,6 @@ parameter pack shall be expanded with an ellipsis in the template argument list. \begin{example} - \begin{codeblock} template struct A { void f1(); @@ -1424,6 +2173,26 @@ template void B::f4() { } // error \end{codeblock} +\begin{codeblock} +template concept C = true; +template concept D = true; + +template struct S { + void f(); + void g(); + void h(); + template struct Inner; +}; + +template void S::f() { } // OK: \grammarterm{template-head}{s} match +template void S::g() { } // error: no matching declaration for \tcode{S} + +template requires C // error (no diagnostic required): \grammarterm{template-head}{s} are +void S::h() { } // functionally equivalent but not equivalent + +template template +struct S::Inner { }; // OK +\end{codeblock} \end{example} \pnum @@ -1432,7 +2201,7 @@ explicit specialization or explicit instantiation of a class template, the \grammarterm{class-key} -shall agree in kind with the original class template declaration~(\ref{dcl.type.elab}). +shall agree in kind with the original class template declaration\iref{dcl.type.elab}. \rSec3[temp.mem.func]{Member functions of class templates} @@ -1464,6 +2233,23 @@ return v[i]; } \end{codeblock} + +A constrained member function can be defined out of line: +\begin{codeblock} +template concept C = requires { + typename T::type; +}; + +template struct S { + void f() requires C; + void g() requires C; +}; + +template + void S::f() requires C { } // OK +template + void S::g() { } // error: no matching function in \tcode{S} +\end{codeblock} \end{example} \pnum @@ -1497,7 +2283,7 @@ definition in which it is declared. \begin{note} The member class must be defined before its first use that requires -an instantiation~(\ref{temp.inst}). +an instantiation\iref{temp.inst}. For example, \begin{codeblock} @@ -1572,11 +2358,11 @@ A member template can be defined within or outside its class definition or class template definition. A member template of a class template that is defined outside of its class -template definition shall be specified with the -\grammarterm{template-parameter}{s} -of the class template followed by the -\grammarterm{template-parameter}{s} -of the member template. +template definition shall be specified with +a \grammarterm{template-head} equivalent to that +of the class template followed by +a \grammarterm{template-head} equivalent to that +of the member template\iref{temp.over.link}. \begin{example} \begin{codeblock} template struct string { @@ -1588,14 +2374,30 @@ } \end{codeblock} \end{example} +\begin{example} +\begin{codeblock} +template concept C1 = true; +template concept C2 = sizeof(T) <= 4; + +template struct S { + template void f(U); + template void g(U); +}; + +template template +void S::f(U) { } // OK +template template +void S::g(U) { } // error: no matching function in \tcode{S} +\end{codeblock} +\end{example} \pnum A local class of non-closure type shall not have member templates. -Access control rules (Clause~\ref{class.access}) +Access control rules\iref{class.access} apply to member template names. A destructor shall not be a member template. -A non-template member function~(\ref{dcl.fct}) with a given name +A non-template member function\iref{dcl.fct} with a given name and type and a member function template of the same name, which could be used to generate a specialization of the same type, can both be declared in a class. @@ -1691,7 +2493,7 @@ visible in the context of the use are considered. For each such operator, if argument -deduction succeeds~(\ref{temp.deduct.conv}), the resulting specialization is +deduction succeeds\iref{temp.deduct.conv}, the resulting specialization is used as if found by name lookup. \pnum @@ -1701,8 +2503,8 @@ in a base class. \pnum -Overload resolution~(\ref{over.ics.rank}) and partial -ordering~(\ref{temp.func.order}) are used to select the best conversion function +Overload resolution\iref{over.ics.rank} and partial +ordering\iref{temp.func.order} are used to select the best conversion function among multiple specializations of conversion function templates and/or non-template @@ -1753,13 +2555,13 @@ expansions can occur in the following contexts: \begin{itemize} -\item In a function parameter pack~(\ref{dcl.fct}); the pattern is the +\item In a function parameter pack\iref{dcl.fct}; the pattern is the \grammarterm{parameter-declaration} without the ellipsis. -\item In a \grammarterm{using-declaration}~(\ref{namespace.udecl}); +\item In a \grammarterm{using-declaration}\iref{namespace.udecl}; the pattern is a \grammarterm{using-declarator}. -\item In a template parameter pack that is a pack expansion~(\ref{temp.param}): +\item In a template parameter pack that is a pack expansion\iref{temp.param}: \begin{itemize} \item if the template parameter pack is a \grammarterm{parameter-declaration}; @@ -1770,32 +2572,32 @@ \grammarterm{type-parameter} without the ellipsis. \end{itemize} -\item In an \grammarterm{initializer-list}~(\ref{dcl.init}); +\item In an \grammarterm{initializer-list}\iref{dcl.init}; the pattern is an \grammarterm{initializer-clause}. -\item In a \grammarterm{base-specifier-list} (Clause~\ref{class.derived}); +\item In a \grammarterm{base-specifier-list}\iref{class.derived}; the pattern is a \grammarterm{base-specifier}. -\item In a \grammarterm{mem-initializer-list}~(\ref{class.base.init}) for a +\item In a \grammarterm{mem-initializer-list}\iref{class.base.init} for a \grammarterm{mem-initializer} whose \grammarterm{mem-initializer-id} denotes a base class; the pattern is the \grammarterm{mem-initializer}. -\item In a \grammarterm{template-argument-list}~(\ref{temp.arg}); +\item In a \grammarterm{template-argument-list}\iref{temp.arg}; the pattern is a \grammarterm{template-argument}. -\item In an \grammarterm{attribute-list}~(\ref{dcl.attr.grammar}); the pattern is +\item In an \grammarterm{attribute-list}\iref{dcl.attr.grammar}; the pattern is an \grammarterm{attribute}. -\item In an \grammarterm{alignment-specifier}~(\ref{dcl.align}); the pattern is +\item In an \grammarterm{alignment-specifier}\iref{dcl.align}; the pattern is the \grammarterm{alignment-specifier} without the ellipsis. -\item In a \grammarterm{capture-list}~(\ref{expr.prim.lambda}); the pattern is +\item In a \grammarterm{capture-list}\iref{expr.prim.lambda}; the pattern is a \grammarterm{capture}. -\item In a \tcode{sizeof...} expression~(\ref{expr.sizeof}); the pattern is an +\item In a \tcode{sizeof...} expression\iref{expr.sizeof}; the pattern is an \grammarterm{identifier}. -\item In a \grammarterm{fold-expression} (\ref{expr.prim.fold}); +\item In a \grammarterm{fold-expression}\iref{expr.prim.fold}; the pattern is the \grammarterm{cast-expression} that contains an unexpanded parameter pack. \end{itemize} @@ -1870,7 +2672,7 @@ \begin{itemize} \item if the pack is a template parameter pack, the element is a template -parameter~(\ref{temp.param}) of the corresponding kind (type or +parameter\iref{temp.param} of the corresponding kind (type or non-type) designating the type or value from the template argument; otherwise, @@ -1903,7 +2705,7 @@ \end{example} \pnum -The instantiation of a \tcode{sizeof...} expression~(\ref{expr.sizeof}) produces +The instantiation of a \tcode{sizeof...} expression\iref{expr.sizeof} produces an integral constant containing the number of elements in the parameter pack it expands. @@ -1998,7 +2800,7 @@ function template is found in the specified class or namespace, the friend declaration refers to -the deduced specialization of that function template~(\ref{temp.deduct.decl}), otherwise, +the deduced specialization of that function template\iref{temp.deduct.decl}, otherwise, \item the name shall be an \grammarterm{unqualified-id} that declares (or redeclares) a non-template function. @@ -2079,8 +2881,8 @@ \pnum A template friend declaration specifies that all specializations of that -template, whether they are implicitly instantiated~(\ref{temp.inst}), partially -specialized~(\ref{temp.class.spec}) or explicitly specialized~(\ref{temp.expl.spec}), +template, whether they are implicitly instantiated\iref{temp.inst}, partially +specialized\iref{temp.class.spec} or explicitly specialized\iref{temp.expl.spec}, are friends of the class containing the template friend declaration. \begin{example} \begin{codeblock} @@ -2140,7 +2942,7 @@ \pnum \begin{note} -A friend declaration may first declare a member of an enclosing namespace scope~(\ref{temp.inject}). +A friend declaration may first declare a member of an enclosing namespace scope\iref{temp.inject}. \end{note} \pnum @@ -2164,6 +2966,9 @@ default arguments, nor shall the inline specifier be used in such a declaration. +\pnum +A non-template friend declaration shall not have a \grammarterm{requires-clause}. + \rSec2[temp.class.spec]{Class template partial specializations} \pnum @@ -2182,7 +2987,7 @@ A partial specialization of a class template provides an alternative definition of the template that is used instead of the primary definition when the arguments in a specialization match those given in the partial -specialization~(\ref{temp.class.spec.match}). +specialization\iref{temp.class.spec.match}. The primary template shall be declared before any specializations of that template. A partial specialization shall be declared before the first use of a class template @@ -2193,7 +2998,7 @@ \pnum Each class template partial specialization is a distinct template and definitions shall be provided for the members of a template partial -specialization~(\ref{temp.class.spec.mfunc}). +specialization\iref{temp.class.spec.mfunc}. \pnum \begin{example} @@ -2210,6 +3015,24 @@ the primary template. \end{example} +\pnum +A class template partial specialization may be constrained\iref{temp}. +\begin{example} +\begin{codeblock} +template concept C = true; + +template struct X { }; +template struct X { }; // \#1 +template struct X { }; // \#2 +\end{codeblock} +Both partial specializations are more specialized than the primary template. +\#1 is more specialized because the deduction of its template arguments +from the template argument list of the class template specialization succeeds, +while the reverse does not. +\#2 is more specialized because the template arguments are equivalent, +but the partial specialization is more constrained\iref{temp.constr.order}. +\end{example} + \pnum The template parameters are specified in the angle bracket enclosed list that immediately follows the keyword @@ -2315,14 +3138,14 @@ \end{example} \item The specialization shall be more specialized than the primary -template~(\ref{temp.class.order}). +template\iref{temp.class.order}. \item The template parameter list of a specialization shall not contain default template argument values.\footnote{There is no way in which they could be used.} \item An argument shall not contain an unexpanded parameter pack. If -an argument is a pack expansion~(\ref{temp.variadic}), it shall be +an argument is a pack expansion\iref{temp.variadic}, it shall be the last argument in the template argument list. \end{itemize} @@ -2343,7 +3166,7 @@ generated from that specialization. \item If more than one matching specialization is found, -the partial order rules~(\ref{temp.class.order}) are used to determine +the partial order rules\iref{temp.class.order} are used to determine whether one of the specializations is more specialized than the others. If none of the specializations is more specialized than all of the @@ -2357,7 +3180,9 @@ \pnum A partial specialization matches a given actual template argument list if the template arguments of the partial specialization can be -deduced from the actual template argument list~(\ref{temp.deduct}). +deduced from the actual template argument list\iref{temp.deduct}, +and the deduced template arguments satisfy the associated constraints +of the partial specialization, if any\iref{temp.constr.decl}. \begin{example} \begin{codeblock} template class A { }; // \#1 @@ -2373,6 +3198,19 @@ A a5; // ambiguous: matches \#3 and \#5 \end{codeblock} \end{example} +\begin{example} +\begin{codeblock} +template concept C = requires (T t) { t.f(); }; + +template struct S { }; // \#1 +template struct S { }; // \#2 + +struct Arg { void f(); }; + +S s1; // uses \#1; the constraints of \#2 are not satisfied +S s2; // uses \#2; both constraints are satisfied but \#2 is more specialized +\end{codeblock} +\end{example} \pnum If the template arguments of a partial specialization cannot be deduced @@ -2407,13 +3245,14 @@ the first is \defn{more specialized} than the second if, given the following rewrite to two function templates, the first function template is more specialized than the second according to the ordering rules for function -templates~(\ref{temp.func.order}): +templates\iref{temp.func.order}: \begin{itemize} \item Each of the two -function templates has the same template parameters as -the corresponding partial specialization. +function templates has the same template parameters +and associated constraints\iref{temp.constr.decl} +as the corresponding partial specialization. \item Each function template has a single function parameter @@ -2458,6 +3297,21 @@ and the partial specialization \#4 is more specialized than the partial specialization \#3. \end{example} +\begin{example} +\begin{codeblock} +template concept C = requires (T t) { t.f(); }; +template concept D = C && requires (T t) { t.f(); }; + +template class S { }; +template class S { }; // \#1 +template class S { }; // \#2 + +template void f(S); // A +template void f(S); // B +\end{codeblock} +The partial specialization \#2 is more specialized than \#1 +because \tcode{B} is more specialized than \tcode{A}. +\end{example} \rSec3[temp.class.spec.mfunc]{Members of class template specializations} @@ -2560,7 +3414,7 @@ \pnum A function template can be overloaded with other function templates -and with non-template functions~(\ref{dcl.fct}). +and with non-template functions\iref{dcl.fct}. A non-template function is not related to a function template (i.e., it is never considered to be a specialization), @@ -2570,7 +3424,7 @@ overload resolution of function template specializations with the same name. -If such a non-template function is odr-used~(\ref{basic.def.odr}) in a program, it must be defined; +If such a non-template function is odr-used\iref{basic.def.odr} in a program, it must be defined; it will not be implicitly instantiated using the function template definition.} \rSec3[temp.over.link]{Function template overloading} @@ -2606,11 +3460,11 @@ \pnum Such specializations are distinct functions and do not violate the one-definition -rule~(\ref{basic.def.odr}). +rule\iref{basic.def.odr}. \pnum The signature of a function template -is defined in Clause~\ref{intro.defs}. +is defined in \ref{intro.defs}. The names of the template parameters are significant only for establishing the relationship between the template parameters and the rest of the signature. @@ -2654,15 +3508,15 @@ \end{note} \pnum -\indextext{equivalent!expression|see{expression, equivalent}}% +\indextext{expression!equivalent|see{equivalent, expressions}}% Two expressions involving template parameters are considered -\defnx{equivalent}{expression!equivalent} +\defnx{equivalent}{equivalent!expressions} if two function definitions containing the expressions would satisfy -the one-definition rule~(\ref{basic.def.odr}), except that the tokens used +the one-definition rule\iref{basic.def.odr}, except that the tokens used to name the template parameters may differ as long as a token used to name a template parameter in one expression is replaced by another token that names the same template parameter in the other expression. For -determining whether two dependent names (\ref{temp.dep}) are +determining whether two dependent names\iref{temp.dep} are equivalent, only the name itself is considered, not the result of name lookup in the context of the template. If multiple declarations of the same function template differ in the result of this name lookup, the @@ -2681,33 +3535,71 @@ // was not in scope at the first declaration of \tcode{h()} \end{codeblock} \end{example} -\indextext{equivalent!functionally!expression|see{expression, functionally equivalent}}% -\indextext{functionally equivalent!expression|see{expression, functionally equivalent}}% +\indextext{expression!functionally equivalent|see{functionally equivalent, expressions}}% Two expressions involving template parameters that are not equivalent are -\defnx{functionally equivalent}{expression!functionally equivalent} +\defnx{functionally equivalent}{functionally equivalent!expressions} 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 \grammarterm{template-head}{s} are +\defnx{equivalent}{equivalent!\idxgram{template-head}{s}} if +their \grammarterm{template-parameter-list}{s} have the same length, +corresponding \grammarterm{template-parameter}{s} are equivalent, +and if either has a \grammarterm{requires-clause}, they both have +\grammarterm{requires-clause}{s} and the corresponding +\grammarterm{constraint-expression}{s} are equivalent. +Two \grammarterm{template-parameter}{s} are +\defnx{equivalent}{equivalent!\idxgram{template-parameter}{s}} +under the following conditions: +\begin{itemize} +\item they declare template parameters of the same kind, +\item if either declares a template parameter pack, they both do, +\item if they declare non-type template parameters, they have +equivalent types, +\item if they declare template template parameters, their template +parameters are equivalent, and +\item if either is declared with a \grammarterm{qualified-concept-name}, +they both are, and the \grammarterm{qualified-concept-name}{s} are +equivalent. +\end{itemize} +When determining whether types or \grammarterm{qualified-concept-name}{s} +are equivalent, the rules above are used to compare expressions +involving template parameters. +Two \grammarterm{template-head}{s} are +\defnx{functionally equivalent}{functionally equivalent!\idxgram{template-head}{s}} +if they accept and are satisfied by\iref{temp.constr.constr} +the same set of template argument lists. + +\pnum +\indextext{template!function!equivalent|see{equivalent, function template}}% Two function templates are -\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 +\defnx{equivalent}{equivalent!function templates} +if they +are declared in the same scope, +have the same name, +have equivalent \grammarterm{template-head}{s}, +and +have return types, parameter lists, +and trailing \grammarterm{requires-clause}{s} (if any) +that are equivalent using the rules described above to compare expressions involving template parameters. -\indextext{equivalent!functionally!function template|see{template, function, functionally equivalent}}% -\indextext{functionally equivalent!function template|see{template, function, functionally equivalent}}% +\indextext{equivalent!functionally|see{functionally equivalent}}% +\indextext{template!function!functionally equivalent|see{functionally equivalent!function template}}% Two function templates are -\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 -lists are functionally equivalent using the rules described above to +\defnx{functionally equivalent}{functionally equivalent!function templates} +if they +are declared in the same scope, +have the same name, +accept and are satisfied by the same set of template argument lists, +and +have return types and parameter lists that +are functionally equivalent using the rules described above to compare expressions involving template parameters. -If a program contains declarations of function templates that are +If the validity or meaning of the program depends on +whether two constructs are equivalent, and they are functionally equivalent but not equivalent, the program is ill-formed, no diagnostic required. @@ -2742,7 +3634,7 @@ \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 argument deduction\iref{temp.deduct} may associate the function template specialization with more than one function template declaration. \defnx{Partial ordering}{template!function!partial ordering} of overloaded function template declarations is used in the following contexts @@ -2751,7 +3643,7 @@ \begin{itemize} \item -during overload resolution for a call to a function template specialization~(\ref{over.match.best}); +during overload resolution for a call to a function template specialization\iref{over.match.best}; \item when the address of a function template specialization is taken; \item @@ -2760,8 +3652,8 @@ specialization is selected to match a placement operator new~(\ref{basic.stc.dynamic.deallocation}, \ref{expr.new}); \item -when a friend function declaration~(\ref{temp.friend}), an -explicit instantiation~(\ref{temp.explicit}) or an explicit specialization~(\ref{temp.expl.spec}) refers to +when a friend function declaration\iref{temp.friend}, an +explicit instantiation\iref{temp.explicit} or an explicit specialization\iref{temp.expl.spec} refers to a function template specialization. \end{itemize} @@ -2774,10 +3666,13 @@ one of the templates is more specialized than the other. If so, the more specialized template is the one chosen by the partial ordering process. +If both deductions succeed, the partial ordering selects +the more constrained template as described by the rules in +\ref{temp.constr.order}. \pnum To produce the transformed template, for each type, non-type, or template -template parameter (including template parameter packs~(\ref{temp.variadic}) +template parameter (including template parameter packs\iref{temp.variadic} thereof) synthesize a unique type, value, or class template respectively and substitute it for each occurrence of that parameter in the function type of the template. @@ -2905,7 +3800,7 @@ \pnum A \grammarterm{template-declaration} in which the \grammarterm{declaration} is an -\grammarterm{alias-declaration} (Clause~\ref{dcl.dcl}) declares the +\grammarterm{alias-declaration}\iref{dcl.dcl} declares the \grammarterm{identifier} to be an \defn{alias template}. An alias template is a name for a family of types. The name of the alias template is a \grammarterm{template-name}. @@ -2971,6 +3866,58 @@ \end{codeblock} \end{example} +\rSec2[temp.concept]{Concept definitions} + +\pnum +A \defn{concept} is a template +that defines constraints on its template arguments. + +\pnum +A \grammarterm{concept-definition} +declares a concept. +Its \grammarterm{identifier} becomes a \grammarterm{concept-name} +referring to that concept +within its scope. +\begin{example} +\begin{codeblock} +template +concept C = requires(T x) { + { x == x } -> bool; +}; +template + requires C // \tcode{C} constrains \tcode{f1(T)} in \grammarterm{constraint-expression} +T f1(T x) { return x; } +template // \tcode{C} constrains \tcode{f2(T)} as a \grammarterm{constrained-parameter} +T f2(T x) { return x; } +\end{codeblock} +\end{example} + +\pnum +A \grammarterm{concept-definition} +shall appear at namespace scope\iref{basic.scope.namespace}. + +\pnum +A concept shall not have associated constraints\iref{temp.constr.decl}. + +\pnum +A concept is not instantiated\iref{temp.spec}. +A program that +explicitly instantiates\iref{temp.explicit}, +explicitly specializes\iref{temp.expl.spec}, +or partially specializes a concept is ill-formed. +\begin{note} +An \grammarterm{id-expression} that denotes a concept specialization +is evaluated as an expression\iref{expr.prim.id}. +\end{note} + +\pnum +The first declared template parameter of a concept definition is its +\defnx{prototype parameter}{prototype parameter!concept}. +\indextext{variadic concept|see{concept, variadic}}% +A \defnx{variadic concept}{concept!variadic} +is a concept whose prototype parameter +is a template parameter pack. + \rSec1[temp.res]{Name resolution} \pnum @@ -2984,7 +3931,7 @@ and names declared within the template itself. \item Names dependent on a -\grammarterm{template-parameter}~(\ref{temp.dep}). +\grammarterm{template-parameter}\iref{temp.dep}. \item Names from scopes which are visible within the template definition. \end{itemize} @@ -3026,7 +3973,7 @@ \pnum 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}) +that is not a member of the current instantiation\iref{temp.dep.type} and its \grammarterm{nested-name-specifier} refers to a dependent type, it shall be @@ -3053,7 +4000,7 @@ does not denote a type or a class template, the specialization is ill-formed. -The usual qualified name lookup~(\ref{basic.lookup.qual}) is used to find the +The usual qualified name lookup\iref{basic.lookup.qual} is used to find the \grammarterm{qualified-id} even in the presence of \tcode{typename}. @@ -3081,7 +4028,7 @@ \pnum A qualified name used as the name in a -\grammarterm{class-or-decltype} (Clause~\ref{class.derived}) +\grammarterm{class-or-decltype}\iref{class.derived} or an \grammarterm{elaborated-type-specifier} is implicitly assumed to name a type, without the use of the @@ -3135,10 +4082,10 @@ 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}), -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}). +\begin{note} Such names can be found using unqualified name lookup\iref{basic.lookup.unqual}, +class member lookup\iref{class.qual} into the current instantiation\iref{temp.dep.type}, +or class member access expression lookup\iref{basic.lookup.classref} when the +type of the object expression is the current instantiation\iref{temp.dep.expr}. \end{note} \begin{example} @@ -3160,9 +4107,13 @@ \begin{itemize} \item no valid specialization can be generated for a template -or a substatement of a constexpr if statement~(\ref{stmt.if}) within a template +or a substatement of a constexpr if statement\iref{stmt.if} within a template and the template is not instantiated, or \item +no substitution of template arguments +into a \grammarterm{partial-concept-id} or \grammarterm{requires-clause} +would result in a valid expression, or +\item every valid specialization of a variadic template requires an empty template parameter pack, or \item @@ -3191,7 +4142,7 @@ \item an instantiation uses a default argument or default template argument that had not been defined at the point at which the template was defined, or -\item constant expression evaluation~(\ref{expr.const}) within the template +\item constant expression evaluation\iref{expr.const} within the template instantiation uses \begin{itemize} \item the value of a \tcode{const} object of integral or unscoped enumeration type or @@ -3245,7 +4196,7 @@ the usual lookup rules~(\ref{basic.lookup.unqual}, \ref{basic.lookup.argdep}) are used for non-dependent names. The lookup of names dependent on the template parameters -is postponed until the actual template argument is known~(\ref{temp.dep}). +is postponed until the actual template argument is known\iref{temp.dep}. \begin{example} \begin{codeblock} @@ -3297,7 +4248,7 @@ \tcode{p[i]} cannot be known until it is known what type \tcode{T} -is~(\ref{temp.dep}). +is\iref{temp.dep}. \end{example} \pnum @@ -3336,14 +4287,14 @@ For purposes of name lookup, default arguments and \grammarterm{noexcept-specifier}{s} of function templates and default arguments and \grammarterm{noexcept-specifier}{s} of -member functions of class templates are considered definitions~(\ref{temp.decls}). +member functions of class templates are considered definitions\iref{temp.decls}. \end{note} \rSec2[temp.local]{Locally declared names} \pnum Like normal (non-template) classes, class templates have an -injected-class-name (Clause~\ref{class}). +injected-class-name\iref{class}. The injected-class-name can be used as a \grammarterm{template-name} or a \grammarterm{type-name}. @@ -3403,7 +4354,7 @@ \end{example} \pnum -A lookup that finds an injected-class-name~(\ref{class.member.lookup}) can result in an ambiguity in +A lookup that finds an injected-class-name\iref{class.member.lookup} can result in an ambiguity in certain cases (for example, if it is found in more than one base class). If all of the injected-class-names that are @@ -3515,14 +4466,14 @@ \pnum In the definition of a class template or in the definition of a member of such a template that appears outside of the template definition, -for each non-dependent base class~(\ref{temp.dep.type}), +for each non-dependent base class\iref{temp.dep.type}, if the name of the base class or the name of a member of the base class is the same as the name of a \grammarterm{template-parameter}, the base class name or member name hides the \grammarterm{template-parameter} -name~(\ref{basic.scope.hiding}). +name\iref{basic.scope.hiding}. \begin{example} \begin{codeblock} @@ -3557,7 +4508,7 @@ \defnx{type-dependent}{expression!type-dependent} (that is, its type may depend on a template parameter) or \defnx{value-dependent}{expression!value-dependent} -(that is, its value when evaluated as a constant expression~(\ref{expr.const}) +(that is, its value when evaluated as a constant expression\iref{expr.const} may depend on a template parameter) as described in this subclause. In an expression of the form: @@ -3579,14 +4530,14 @@ \begin{itemize} \item any of the expressions in the \grammarterm{expression-list} is a pack -expansion~(\ref{temp.variadic}), +expansion\iref{temp.variadic}, \item any of the expressions or \grammarterm{braced-init-list}{s} in the \grammarterm{expression-list} -is type-dependent~(\ref{temp.dep.expr}), or +is type-dependent\iref{temp.dep.expr}, or \item the \grammarterm{unqualified-id} @@ -3597,7 +4548,7 @@ If an operand of an operator is a type-dependent expression, the operator also denotes a dependent name. Such names are unbound and -are looked up at the point of the template instantiation~(\ref{temp.point}) in +are looked up at the point of the template instantiation\iref{temp.point} in both the context of the template definition and the context of the point of instantiation. @@ -3627,7 +4578,7 @@ \pnum In the definition of a class or class template, -the scope of a dependent base class~(\ref{temp.dep.type}) +the scope of a dependent base class\iref{temp.dep.type} is not examined during unqualified name lookup either at the point of definition of the class template or member or during an instantiation of @@ -3696,7 +4647,7 @@ \item in the definition of a class template, a nested class of a class template, a member of a class template, or a member of a nested class of a class template, -the injected-class-name (Clause~\ref{class}) of the class template or nested class, +the injected-class-name\iref{class} of the class template or nested class, \item in the definition of a primary class template or a member of a primary class template, the name of the @@ -3715,7 +4666,7 @@ \tcode{<>} (or an equivalent template alias specialization). If the \textit{n}th template parameter is a parameter pack, the \textit{n}th template argument is a pack -expansion~(\ref{temp.variadic}) whose pattern is the name of +expansion\iref{temp.variadic} whose pattern is the name of the parameter pack. \end{itemize} @@ -3727,8 +4678,8 @@ \textit{n}th template parameter of the class template. If the \textit{n}th template parameter is a template -parameter pack~(\ref{temp.variadic}), the \textit{n}th template argument is a pack -expansion~(\ref{temp.variadic}) whose pattern is the name of +parameter pack\iref{temp.variadic}, the \textit{n}th template argument is a pack +expansion\iref{temp.variadic} whose pattern is the name of the template parameter pack. \pnum @@ -3827,9 +4778,9 @@ \item An \grammarterm{id-expression} denoting the member in a class member access -expression~(\ref{expr.ref}) for which the type of the object expression is the +expression\iref{expr.ref} for which the type of the object expression is the current instantiation, and the \grammarterm{id-expression}, when looked -up~(\ref{basic.lookup.classref}), refers to at least one member of a class +up\iref{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 member is found, and the current instantiation has any dependent base classes, @@ -3878,7 +4829,7 @@ base class thereof. \item An \grammarterm{id-expression} denoting the member in a class member access -expression~(\ref{expr.ref}) in which either +expression\iref{expr.ref} in which either \begin{itemize} \item the type of the object expression is the current instantiation, the current instantiation has at least one dependent base class, and name lookup @@ -3969,11 +4920,11 @@ template arguments is a dependent type or an expression that is type-dependent or value-dependent or is a pack expansion \begin{note} -This includes an injected-class-name (Clause \ref{class}) of a class template +This includes an injected-class-name\iref{class} of a class template used without a \grammarterm{template-argument-list}. \end{note}, or \item denoted by \tcode{decltype(}\grammarterm{expression}{}\tcode{)}, -where \grammarterm{expression} is type-dependent~(\ref{temp.dep.expr}). +where \grammarterm{expression} is type-dependent\iref{temp.dep.expr}. \end{itemize} \pnum @@ -3993,7 +4944,7 @@ \pnum \tcode{this} is type-dependent if the class type of the enclosing member function is -dependent~(\ref{temp.dep.type}). +dependent\iref{temp.dep.type}. \pnum An @@ -4013,7 +4964,7 @@ associated by name lookup with a non-type \grammarterm{template-parameter} declared with a type -that contains a placeholder type~(\ref{dcl.spec.auto}), +that contains a placeholder type\iref{dcl.spec.auto}, \item an \grammarterm{identifier} associated by name lookup with one or more @@ -4022,13 +4973,13 @@ \item an \grammarterm{identifier} associated by name lookup with -a structured binding declaration~(\ref{dcl.struct.bind}) whose +a structured binding declaration\iref{dcl.struct.bind} whose \grammarterm{brace-or-equal-initializer} is type-dependent, \item the \grammarterm{identifier} -\tcode{__func__}~(\ref{dcl.fct.def.general}), where any enclosing function is a +\tcode{__func__}\iref{dcl.fct.def.general}, where any enclosing function is a template, a member of a class template, or a generic lambda, \item @@ -4051,7 +5002,7 @@ or if it names a dependent member of the current instantiation that is a static data member of type -``array of unknown bound of \tcode{T}'' for some \tcode{T}~(\ref{temp.static}). +``array of unknown bound of \tcode{T}'' for some \tcode{T}\iref{temp.static}. Expressions of the following forms are type-dependent only if the type specified by the \grammarterm{type-id}, @@ -4095,7 +5046,7 @@ see~\ref{support.types}.\end{note} \pnum -A class member access expression~(\ref{expr.ref}) is +A class member access expression\iref{expr.ref} is type-dependent if the expression refers to a member of the current instantiation and the type of the referenced member is dependent, or the class member access @@ -4213,7 +5164,7 @@ instantiation is value-dependent. An expression of the form \tcode{\&}\grammarterm{cast-expression} is also value-dependent if evaluating \grammarterm{cast-expression} -as a core constant expression~(\ref{expr.const}) succeeds and +as a core constant expression\iref{expr.const} succeeds and the result of the evaluation refers to a templated entity that is an object with static or thread storage duration or a member function. @@ -4283,7 +5234,7 @@ template. \item Declarations from namespaces associated with the types of the -function arguments both from the instantiation context~(\ref{temp.point}) +function arguments both from the instantiation context\iref{temp.point} and from the definition context. \end{itemize} @@ -4367,7 +5318,7 @@ A specialization for any template may have points of instantiation in multiple translation units. If two different points of instantiation give a template specialization -different meanings according to the one-definition rule~(\ref{basic.def.odr}), +different meanings according to the one-definition rule\iref{basic.def.odr}, the program is ill-formed, no diagnostic required. \rSec3[temp.dep.candidate]{Candidate functions} @@ -4381,11 +5332,11 @@ \begin{itemize} \item -For the part of the lookup using unqualified name lookup~(\ref{basic.lookup.unqual}), +For the part of the lookup using unqualified name lookup\iref{basic.lookup.unqual}, only function declarations from the template definition context are found. \item -For the part of the lookup using associated namespaces~(\ref{basic.lookup.argdep}), +For the part of the lookup using associated namespaces\iref{basic.lookup.argdep}, only function declarations found in either the template definition context or the template instantiation context are found. \end{itemize} @@ -4408,9 +5359,9 @@ \pnum As with non-template classes, the names of namespace-scope friend functions of a class template specialization are not visible during -an ordinary lookup unless explicitly declared at namespace scope~(\ref{class.friend}). +an ordinary lookup unless explicitly declared at namespace scope\iref{class.friend}. Such names may be found under the rules for associated -classes~(\ref{basic.lookup.argdep}).\footnote{Friend declarations do not +classes\iref{basic.lookup.argdep}.\footnote{Friend declarations do not introduce new names into any scope, either when the template is declared or when it is instantiated.} \begin{example} @@ -4487,10 +5438,10 @@ \pnum An instantiated template specialization can be either implicitly -instantiated~(\ref{temp.inst}) for a given argument list or be explicitly -instantiated~(\ref{temp.explicit}). +instantiated\iref{temp.inst} for a given argument list or be explicitly +instantiated\iref{temp.explicit}. A specialization is a class, function, or class member that is either -instantiated or explicitly specialized~(\ref{temp.expl.spec}). +instantiated or explicitly specialized\iref{temp.expl.spec}. \pnum For a given template and a given set of @@ -4538,7 +5489,7 @@ \pnum If a function declaration acquired its function type through -a dependent type~(\ref{temp.dep.type}) without using the syntactic form of +a dependent type\iref{temp.dep.type} without using the syntactic form of a function declarator, the program is ill-formed. \begin{example} @@ -4556,8 +5507,8 @@ \pnum \indextext{instantiation!template implicit}% Unless a class template specialization has been explicitly -instantiated~(\ref{temp.explicit}) or explicitly -specialized~(\ref{temp.expl.spec}), +instantiated\iref{temp.explicit} or explicitly +specialized\iref{temp.expl.spec}, the class template specialization is implicitly instantiated when the specialization is referenced in a context that requires a completely-defined object type or when the completeness of the class type affects the semantics @@ -4586,8 +5537,8 @@ \end{codeblock} \end{example} If a class template has been declared, but not defined, -at the point of instantiation~(\ref{temp.point}), -the instantiation yields an incomplete class type~(\ref{basic.types}). +at the point of instantiation\iref{temp.point}, +the instantiation yields an incomplete class type\iref{basic.types}. \begin{example} \begin{codeblock} template class X; @@ -4596,11 +5547,13 @@ \end{example} \begin{note} Within a template declaration, -a local class~(\ref{class.local}) or enumeration and the members of +a local class\iref{class.local} or enumeration and the members of a local class are never considered to be entities that can be separately instantiated (this includes their default arguments, \grammarterm{noexcept-specifier}{s}, and non-static data member -initializers, if any). As a result, the dependent names are looked up, the +initializers, if any, +but not their \grammarterm{partial-concept-id}{s} or \grammarterm{requires-clause}{s}). +As a result, the dependent names are looked up, the semantic constraints are checked, and any templates used are instantiated as part of the instantiation of the entity within which the local class or enumeration is declared. @@ -4710,7 +5663,7 @@ referenced in a context that requires the value of the default argument. \pnum -If the function selected by overload resolution~(\ref{over.match}) +If the function selected by overload resolution\iref{over.match} can be determined without instantiating a class template definition, it is unspecified whether that instantiation actually takes place. \begin{example} @@ -4734,14 +5687,14 @@ \pnum If a function template or a member function template specialization is used in a way that involves overload resolution, -a declaration of the specialization is implicitly instantiated~(\ref{temp.over}). +a declaration of the specialization is implicitly instantiated\iref{temp.over}. \pnum An implementation shall not implicitly instantiate a function template, a variable template, a member template, a non-virtual member function, a member class, a static data member of a class template, or a substatement of a constexpr if -statement (\ref{stmt.if}), unless such instantiation is required. +statement\iref{stmt.if}, unless such instantiation is required. It is unspecified whether or not an implementation implicitly instantiates a virtual member function of a class template if the virtual member function would not otherwise be instantiated. @@ -4803,7 +5756,7 @@ the same template parameters and the same access as that of the function template \tcode{f} used at that point, except that the scope in which a closure type is -declared~(\ref{expr.prim.lambda.closure}) -- and therefore its associated namespaces -- +declared\iref{expr.prim.lambda.closure} -- and therefore its associated namespaces -- remain as determined from the context of the definition for the default argument. This analysis is called @@ -4833,7 +5786,7 @@ \pnum The \grammarterm{noexcept-specifier} of a function template specialization is not instantiated along with the function declaration; it is instantiated -when needed~(\ref{except.spec}). If such an +when needed\iref{except.spec}. If such an \grammarterm{noexcept-specifier} is needed but has not yet been instantiated, the dependent names are looked up, the semantics constraints are checked, and the instantiation of any template used in the @@ -4847,7 +5800,7 @@ \pnum There is an \impldef{maximum depth of recursive template instantiations} quantity -that specifies the limit on the total depth of recursive instantiations~(\ref{implimits}), +that specifies the limit on the total depth of recursive instantiations\iref{implimits}, which could involve more than one template. The result of an infinite recursion in instantiation is undefined. \begin{example} @@ -4862,6 +5815,59 @@ \end{codeblock} \end{example} +\pnum +The \grammarterm{partial-concept-id}{s} and \grammarterm{requires-clause} +of a template specialization or member function +are not instantiated along with the specialization or function itself, +even for a member function of a local class; +substitution into the atomic constraints formed from them is instead performed +as specified in \ref{temp.constr.decl} and \ref{temp.constr.atomic} +when determining whether the constraints are satisfied. +\begin{note} +The satisfaction of constraints is determined during name lookup or overload +resolution\iref{over.match}. +\end{note} +\begin{example} +\begin{codeblock} +template concept C = sizeof(T) > 2; +template concept D = C && sizeof(T) > 4; + +template struct S { + S() requires C { } // \#1 + S() requires D { } // \#2 +}; + +S s1; // error: no matching constructor +S s2; // OK, calls \#2 +\end{codeblock} + +When \tcode{S} is instantiated, both constructors are part of the +specialization. Their constraints are not satisfied, and +they suppress the implicit declaration of a default constructor for +\tcode{S}\iref{class.ctor}, so there is no viable constructor +for \tcode{s1}. +\end{example} +\begin{example} +\begin{codeblock} +template struct S1 { + template + requires false + struct Inner1; // ill-formed, no diagnostic required +}; + +template struct S2 { + template + requires (sizeof(T[-(int)sizeof(T)]) > 1) + struct Inner2; // ill-formed, no diagnostic required +}; +\end{codeblock} +The class \tcode{S1::Inner1} is ill-formed, no diagnostic required, because +it has no valid specializations. +\tcode{S2} is ill-formed, no diagnostic required, since no substitution into +the constraints of its \tcode{Inner2} template would result in a valid +expression. +\end{example} + \rSec2[temp.explicit]{Explicit instantiation} \pnum @@ -4889,13 +5895,18 @@ \pnum If the explicit instantiation is for a class or member class, the -\grammarterm{elaborated-type-specifier} in the \grammarterm{declaration} shall -include a \grammarterm{simple-template-id}. If the explicit instantiation is for +\grammarterm{elaborated-type-specifier} in the \grammarterm{declaration} +shall include a \grammarterm{simple-template-id}; +otherwise, the \grammarterm{declaration} +shall be a \grammarterm{simple-declaration} whose \grammarterm{init-declarator-list} +comprises a single \grammarterm{init-declarator} +that does not have an \grammarterm{initializer}. +If the explicit instantiation is for a function or member function, the \grammarterm{unqualified-id} in the -\grammarterm{declaration} +\grammarterm{declarator} shall be either a \grammarterm{template-id} or, where all template arguments can be deduced, a @@ -4915,14 +5926,14 @@ the name of the class template specialization in the \grammarterm{qualified-id} for the member name shall be a \grammarterm{simple-template-id}. -If the explicit instantiation is for a variable, the -\grammarterm{unqualified-id} in the declaration shall be a -\grammarterm{template-id}. +If the explicit instantiation is for a variable template specialization, +the \grammarterm{unqualified-id} in the \grammarterm{declarator} +shall be a \grammarterm{simple-template-id}. An explicit instantiation shall appear in an enclosing namespace of its template. If the name declared in the explicit instantiation is an unqualified name, the explicit instantiation shall appear in the namespace where its template is declared or, if that -namespace is inline~(\ref{namespace.def}), any namespace from its enclosing +namespace is inline\iref{namespace.def}, any namespace from its enclosing namespace set. \begin{note} Regarding qualified names in declarators, see~\ref{dcl.meaning}. @@ -4956,7 +5967,29 @@ If the \grammarterm{declaration} of the explicit instantiation names an implicitly-declared special member -function (Clause~\ref{special}), the program is ill-formed. +function\iref{special}, the program is ill-formed. + +\pnum +The \grammarterm{declaration} in an \grammarterm{explicit-instantiation} and the \grammarterm{declaration} produced by the corresponding substitution into the templated function, variable, or class are two declarations of the same entity. +\begin{note} +These declarations are required to have matching types as specified in~\ref{basic.link}, except as specified in~\ref{except.spec}. +\begin{example} +\begin{codeblock} +template T var = {}; +template float var; // OK, instantiated variable has type \tcode{float} +template int var[]; // OK, absence of major array bound is permitted +template int *var; // error: instantiated variable has type \tcode{int} + +template auto av = T(); +template int av; // OK, variable with type \tcode{int} can be redeclared with type \tcode{auto} + +template auto f() {} +template void f(); // error: function with deduced return type + // redeclared with non-deduced return type\iref{dcl.spec.auto} +\end{codeblock} +\end{example} +\end{note} +Despite its syntactic form, the \grammarterm{declaration} in an \grammarterm{explicit-instantiation} for a variable is not itself a definition and does not conflict with the definition instantiated by an explicit instantiation definition for that variable. \pnum For a given set of template arguments, if an explicit @@ -4999,7 +6032,7 @@ \grammarterm{template-argument} can be left unspecified in an explicit instantiation of a function template specialization or of a member function template specialization provided -it can be deduced from the type of a function parameter~(\ref{temp.deduct}). +it can be deduced from the type of a function parameter\iref{temp.deduct}. \begin{example} \begin{codeblock} template class Array { @\commentellip@ }; @@ -5010,6 +6043,19 @@ \end{codeblock} \end{example} +\pnum +\begin{note} +An explicit instantiation of a constrained template +shall satisfy that template's associated constraints\iref{temp.constr.decl}. +The satisfaction of constraints is determined +% FIXME: What is a "template name"? Does this mean "simple-template-id"? +when forming the template name of an explicit instantiation +in which all template arguments are specified\iref{temp.names}, +or, for explicit instantiations of function templates, +during template argument deduction\iref{temp.deduct.decl} +when one or more trailing template arguments are left unspecified. +\end{note} + \pnum An explicit instantiation that names a class template specialization is also an explicit @@ -5017,6 +6063,9 @@ of its members (not including members inherited from base classes and members that are templates) that has not been previously explicitly specialized in the translation unit containing the explicit instantiation, +provided that the associated constraints, if any, +of that member are satisfied by the template arguments of the explicit +instantiation~(\ref{temp.constr.decl}, \ref{temp.constr.constr}), except as described below. \begin{note} In addition, it will typically be an explicit instantiation of certain implementation-dependent data about the class. \end{note} @@ -5029,14 +6078,15 @@ \pnum Except for inline functions and variables, declarations with types deduced from their -initializer or return value~(\ref{dcl.spec.auto}), \tcode{const} variables of +initializer or return value\iref{dcl.spec.auto}, \tcode{const} variables of literal types, variables of reference types, and class template specializations, explicit instantiation declarations have the -effect of suppressing the implicit instantiation of the entity to which they -refer. \begin{note} The intent is that an inline function that is the +effect of suppressing the implicit instantiation +of the definition of the entity to which they refer. +\begin{note} The intent is that an inline function that is the subject of an explicit instantiation declaration will still be implicitly -instantiated when odr-used~(\ref{basic.def.odr}) so that the body can be considered for inlining, but +instantiated when odr-used\iref{basic.def.odr} so that the body can be considered for inlining, but that no out-of-line copy of the inline function would be generated in the translation unit.\end{note} @@ -5045,7 +6095,7 @@ and an explicit instantiation definition in the same translation unit, the definition shall follow the declaration. An entity that is the subject of an explicit instantiation declaration and that is also used -in a way that would otherwise cause an implicit instantiation~(\ref{temp.inst}) +in a way that would otherwise cause an implicit instantiation\iref{temp.inst} in the translation unit shall be the subject of an explicit instantiation definition somewhere in the program; otherwise the program is ill-formed, no diagnostic required. @@ -5185,7 +6235,7 @@ precede the explicit specialization for the member of the class template. If such an explicit specialization for the member of a class template names an -implicitly-declared special member function (Clause~\ref{special}), +implicitly-declared special member function\iref{special}, the program is ill-formed. \pnum @@ -5339,7 +6389,7 @@ \grammarterm{simple-template-id} that names a class template explicit specialization that has been declared but not defined can be used exactly like the names of other incompletely-defined -classes~(\ref{basic.types}). +classes\iref{basic.types}. \begin{example} \begin{codeblock} @@ -5370,9 +6420,21 @@ \end{codeblock} \end{example} +\pnum +\begin{note} +An explicit specialization of a constrained template +shall satisfy that template's associated constraints\iref{temp.constr.decl}. +The satisfaction of constraints is determined +when forming the template name of an explicit specialization +in which all template arguments are specified\iref{temp.names}, +or, for explicit specializations of function templates, +during template argument deduction\iref{temp.deduct.decl} +when one or more trailing template arguments are left unspecified. +\end{note} + \pnum A function with the same name as a template and a type that exactly matches that -of a template specialization is not an explicit specialization~(\ref{temp.fct}). +of a template specialization is not an explicit specialization\iref{temp.fct}. \pnum An explicit specialization of a function or variable template is inline @@ -5620,12 +6682,12 @@ \end{itemize} \pnum -Trailing template arguments that can be deduced~(\ref{temp.deduct}) or +Trailing template arguments that can be deduced\iref{temp.deduct} or obtained from default \grammarterm{template-argument}{s} may be omitted from the list of explicit \grammarterm{template-argument}{s}. -A trailing template parameter pack~(\ref{temp.variadic}) not otherwise deduced will be +A trailing template parameter pack\iref{temp.variadic} not otherwise deduced will be deduced to an empty sequence of template arguments. If all of the template arguments can be deduced, they may all be omitted; in this case, the empty template argument list @@ -5657,7 +6719,7 @@ \begin{note} An empty template argument list can be used to indicate that a given use refers to a specialization of a function template even when a -non-template function~(\ref{dcl.fct}) is visible that would otherwise be used. +non-template function\iref{dcl.fct} is visible that would otherwise be used. For example: \begin{codeblock} @@ -5694,7 +6756,7 @@ \end{example} \pnum -Implicit conversions (Clause~\ref{conv}) will be performed on a function argument +Implicit conversions\iref{conv} will be performed on a function argument to convert it to the type of the corresponding function parameter if the parameter type contains no \grammarterm{template-parameter}{s} @@ -5731,9 +6793,9 @@ \pnum \begin{note} -For simple function names, argument dependent lookup~(\ref{basic.lookup.argdep}) +For simple function names, argument dependent lookup\iref{basic.lookup.argdep} applies even when the function name is not visible within the scope of the call. -This is because the call still has the syntactic form of a function call~(\ref{basic.lookup.unqual}). +This is because the call still has the syntactic form of a function call\iref{basic.lookup.unqual}. But when a function template with explicit template arguments is used, the call does not have the correct syntactic form unless there is a function template with that name visible at the point of the call. @@ -5907,6 +6969,9 @@ are replaced with the corresponding deduced or default argument values. If the substitution results in an invalid type, as described above, type deduction fails. +If the function template has associated constraints\iref{temp.constr.decl}, +those constraints are checked for satisfaction\iref{temp.constr.constr}. +If the constraints are not satisfied, type deduction fails. \pnum At certain points in the template argument deduction process it is necessary @@ -6079,7 +7144,7 @@ \item Attempting to create a function type in which a parameter type or the return type is an -abstract class type~(\ref{class.abstract}). +abstract class type\iref{class.abstract}. \end{itemize} \end{note} @@ -6088,12 +7153,12 @@ In the following example, assuming a \tcode{signed char} cannot represent the value 1000, -a narrowing conversion~(\ref{dcl.init.list}) +a narrowing conversion\iref{dcl.init.list} would be required to convert the \grammarterm{template-argument} of type \tcode{int} to \tcode{signed char}, therefore substitution fails for the -second template~(\ref{temp.arg.nontype}). +second template\iref{temp.arg.nontype}. \begin{codeblock} template int f(int); @@ -6117,14 +7182,14 @@ \tcode{std::initializer_list} or \tcode{P$'$[N]} for some \tcode{P$'$} and \tcode{N} and the -argument is a non-empty initializer list~(\ref{dcl.init.list}), then deduction is +argument is a non-empty initializer list\iref{dcl.init.list}, then deduction is performed instead for each element of the initializer list, taking \tcode{P$'$} as a function template parameter type and the initializer element as its argument, and in the \tcode{P$'$[N]} case, if \tcode{N} is a non-type template parameter, \tcode{N} is deduced from the length of the initializer list. Otherwise, an initializer list argument causes the -parameter to be considered a non-deduced context~(\ref{temp.deduct.type}). +parameter to be considered a non-deduced context\iref{temp.deduct.type}. \begin{example} \begin{codeblock} template void f(std::initializer_list); @@ -6161,7 +7226,7 @@ Each deduction deduces template arguments for subsequent positions in the template parameter packs expanded by the function parameter pack. When a function parameter pack appears in a non-deduced -context~(\ref{temp.deduct.type}), the type of that parameter pack is +context\iref{temp.deduct.type}, the type of that parameter pack is never deduced. \begin{example} \begin{codeblock} @@ -6189,7 +7254,7 @@ If \tcode{A} is an array type, the pointer type produced by the array-to-pointer -standard conversion~(\ref{conv.array}) is used in place of +standard conversion\iref{conv.array} is used in place of \tcode{A} for type deduction; otherwise, @@ -6197,7 +7262,7 @@ If \tcode{A} is a function type, the pointer type produced by the -function-to-pointer standard conversion~(\ref{conv.func}) is used in place +function-to-pointer standard conversion\iref{conv.func} is used in place of \tcode{A} for type @@ -6235,7 +7300,7 @@ A \defn{forwarding reference} is an rvalue reference to a cv-unqualified template parameter that does not represent a template parameter of a class template -(during class template argument deduction~(\ref{over.match.class.deduct})). +(during class template argument deduction\iref{over.match.class.deduct}). If \tcode{P} is a forwarding reference and the argument is an lvalue, the type ``lvalue reference to \tcode{A}'' is used in place of \tcode{A} for type deduction. \begin{example} @@ -6291,8 +7356,8 @@ can be another pointer or pointer to member type that can be converted to the deduced \tcode{A} -via a function pointer conversion~(\ref{conv.fctptr}) and/or -qualification conversion~(\ref{conv.qual}). +via a function pointer conversion\iref{conv.fctptr} and/or +qualification conversion\iref{conv.qual}. \item If @@ -6416,7 +7481,7 @@ \pnum Template arguments can be deduced from the type specified when taking -the address of an overloaded function~(\ref{over.over}). +the address of an overloaded function\iref{over.over}. The function template's function type and the specified type are used as the types of \tcode{P} @@ -6426,7 +7491,7 @@ described in~\ref{temp.deduct.type}. \pnum -A placeholder type~(\ref{dcl.spec.auto}) in the return type of a +A placeholder type\iref{dcl.spec.auto} in the return type of a function template is a non-deduced context. If template argument deduction succeeds for such a function, the return type is determined from instantiation of the function body. @@ -6460,7 +7525,7 @@ If \tcode{P} is an array type, the pointer type produced by the -array-to-pointer standard conversion~(\ref{conv.array}) is used in place of +array-to-pointer standard conversion\iref{conv.array} is used in place of \tcode{P} for type deduction; otherwise, @@ -6468,7 +7533,7 @@ If \tcode{P} is a function type, the pointer type produced by the -function-to-pointer standard conversion~(\ref{conv.func}) is used in place of +function-to-pointer standard conversion\iref{conv.func} is used in place of \tcode{P} for type deduction; otherwise, @@ -6600,7 +7665,7 @@ In the context of a call to a conversion function, the return types of the conversion function templates are used. \item -In other contexts~(\ref{temp.func.order}) the function template's function +In other contexts\iref{temp.func.order} the function template's function type is used. \end{itemize} @@ -6885,7 +7950,7 @@ \item A function parameter for which argument deduction cannot be done because the associated function argument is a function, or a set of overloaded -functions~(\ref{over.over}), and one or more of the following apply: +functions\iref{over.over}, and one or more of the following apply: \begin{itemize} \item more than one function matches the function parameter type (resulting in @@ -6896,8 +7961,8 @@ the set of functions supplied as an argument contains one or more function templates. \end{itemize} \item A function parameter for which the associated argument is an initializer -list~(\ref{dcl.init.list}) but the parameter does not have -a type for which deduction from an initializer list is specified~(\ref{temp.deduct.call}). +list\iref{dcl.init.list} but the parameter does not have +a type for which deduction from an initializer list is specified\iref{temp.deduct.call}. \begin{example} \begin{codeblock} template void g(T); @@ -7024,7 +8089,7 @@ \begin{codeblock} T -@\grammarterm{cv-list}@ T +@\cv{}@ T T* T& T&& @@ -7053,7 +8118,7 @@ where \tcode{(T)} represents -a parameter-type-list~(\ref{dcl.fct}) +a parameter-type-list\iref{dcl.fct} where at least one parameter type contains a \tcode{T}, and @@ -7089,7 +8154,7 @@ template argument list of \tcode{A}. Each comparison deduces template arguments for subsequent positions in the template parameter packs expanded by $\texttt{P}_i$. -During partial ordering~(\ref{temp.deduct.partial}), if $\texttt{A}_i$ was +During partial ordering\iref{temp.deduct.partial}, if $\texttt{A}_i$ was originally a pack expansion: \begin{itemize} @@ -7116,16 +8181,16 @@ \pnum Similarly, if \tcode{P} has a form that contains \tcode{(T)}, then each parameter type $\texttt{P}_i$ -of the respective parameter-type-list~(\ref{dcl.fct}) of +of the respective parameter-type-list\iref{dcl.fct} of \tcode{P} is compared with the corresponding parameter type $\texttt{A}_i$ of the corresponding parameter-type-list of \tcode{A}. If \tcode{P} and \tcode{A} are function types that originated from deduction when -taking the address of a function template~(\ref{temp.deduct.funcaddr}) or when -deducing template arguments from a function declaration~(\ref{temp.deduct.decl}) +taking the address of a function template\iref{temp.deduct.funcaddr} or when +deducing template arguments from a function declaration\iref{temp.deduct.decl} and $\texttt{P}_i$ and $\texttt{A}_i$ are parameters of the top-level parameter-type-list of \tcode{P} and \tcode{A}, respectively, -$\texttt{P}_i$ is adjusted if it is a forwarding reference~(\ref{temp.deduct.call}) +$\texttt{P}_i$ is adjusted if it is a forwarding reference\iref{temp.deduct.call} and $\texttt{A}_i$ is an lvalue reference, in which case the type of $\texttt{P}_i$ is changed to be the template parameter type (i.e., \tcode{T\&\&} is changed to simply \tcode{T}). \begin{note} As a result, when $\texttt{P}_i$ is \tcode{T\&\&} @@ -7150,7 +8215,7 @@ of \tcode{A}. Each comparison deduces template arguments for subsequent positions in the template parameter packs expanded by the function parameter pack. -During partial ordering~(\ref{temp.deduct.partial}), if $\texttt{A}_i$ was +During partial ordering\iref{temp.deduct.partial}, if $\texttt{A}_i$ was originally a function parameter pack: \begin{itemize} @@ -7407,7 +8472,7 @@ \pnum \begin{note} Template argument deduction involving parameter -packs~(\ref{temp.variadic}) can deduce zero or more arguments for +packs\iref{temp.variadic} can deduce zero or more arguments for each parameter pack. \end{note} \begin{example} @@ -7436,10 +8501,10 @@ In a declaration whose \grammarterm{declarator-id} refers to a specialization of a function template, template argument deduction is performed to identify the specialization to which the declaration refers. Specifically, this is done -for explicit instantiations~(\ref{temp.explicit}), explicit specializations~(\ref{temp.expl.spec}), -and certain friend declarations~(\ref{temp.friend}). This is also done to +for explicit instantiations\iref{temp.explicit}, explicit specializations\iref{temp.expl.spec}, +and certain friend declarations\iref{temp.friend}. This is also done to determine whether a deallocation function template specialization matches a placement -\tcode{operator new}~(\ref{basic.stc.dynamic.deallocation},~\ref{expr.new}). +\tcode{operator new}~(\ref{basic.stc.dynamic.deallocation}, \ref{expr.new}). In all these cases, \tcode{P} is the type of the function template being considered as a potential match and \tcode{A} is either the function type from the declaration @@ -7449,7 +8514,7 @@ \pnum If, for the set of function templates so considered, there is either no match or -more than one match after partial ordering has been considered~(\ref{temp.func.order}), +more than one match after partial ordering has been considered\iref{temp.func.order}, deduction fails and, in the declaration cases, the program is ill-formed. @@ -7460,8 +8525,8 @@ A function template can be overloaded either by (non-template) functions of its name or by (other) function templates of the same name. When a call to that name is written (explicitly, or implicitly using the -operator notation), template argument deduction~(\ref{temp.deduct}) -and checking of any explicit template arguments~(\ref{temp.arg}) are performed +operator notation), template argument deduction\iref{temp.deduct} +and checking of any explicit template arguments\iref{temp.arg} are performed for each function template to find the template argument values (if any) that can be used with that function template to instantiate a function template specialization that can be invoked with the call arguments. @@ -7593,9 +8658,9 @@ Deduction guides are used when a \grammarterm{template-name} appears as a type specifier -for a deduced class type~(\ref{dcl.type.class.deduct}). +for a deduced class type\iref{dcl.type.class.deduct}. Deduction guides are not found by name lookup. -Instead, when performing class template argument deduction~(\ref{over.match.class.deduct}), +Instead, when performing class template argument deduction\iref{over.match.class.deduct}, any deduction guides declared for the class template are considered. \begin{bnf} @@ -7625,7 +8690,7 @@ The same restrictions apply to the \grammarterm{parameter-declaration-clause} of a deduction guide -as in a function declaration~(\ref{dcl.fct}). +as in a function declaration\iref{dcl.fct}. The \grammarterm{simple-template-id} shall name a class template specialization. The \grammarterm{template-name} diff --git a/source/threads.tex b/source/threads.tex index 99dce2933b..1b26454e71 100644 --- a/source/threads.tex +++ b/source/threads.tex @@ -5,7 +5,7 @@ \pnum The following subclauses describe components to create and manage -threads~(\ref{intro.multithread}), perform mutual exclusion, and communicate conditions +threads\iref{intro.multithread}, perform mutual exclusion, and communicate conditions and values between threads, as summarized in Table~\ref{tab:thread.lib.summary}. @@ -32,7 +32,7 @@ \pnum Some functions described in this Clause are specified to throw exceptions of type -\tcode{system_error}~(\ref{syserr.syserr}). Such exceptions shall be thrown if +\tcode{system_error}\iref{syserr.syserr}. Such exceptions shall be thrown if any of the function's error conditions is detected or a call to an operating system or other underlying API results in an error that prevents the @@ -48,7 +48,7 @@ of \tcode{EPERM} is reported by a POSIX API call used by the implementation. Since POSIX specifies an \tcode{errno} of \tcode{EPERM} when ``the caller does not have the privilege to perform the operation'', the implementation maps \tcode{EPERM} to an -\tcode{error_condition} of \tcode{operation_not_permitted}~(\ref{syserr}) and an exception +\tcode{error_condition} of \tcode{operation_not_permitted}\iref{syserr} and an exception of type \tcode{system_error} is thrown. \end{example} @@ -129,7 +129,7 @@ \pnum Implementation-provided clocks that are used for these functions shall meet the -\tcode{TrivialClock} requirements (\ref{time.clock.req}). +\tcode{TrivialClock} requirements\iref{time.clock.req}. \pnum A function that takes an argument which specifies a timeout will throw if, @@ -155,12 +155,12 @@ ordinary spin lock). \end{note} \pnum -The standard library templates \tcode{unique_lock}~(\ref{thread.lock.unique}), -\tcode{shared_lock}~(\ref{thread.lock.shared}), -\tcode{scoped_lock}~(\ref{thread.lock.scoped}), -\tcode{lock_guard}~(\ref{thread.lock.guard}), \tcode{lock}, -\tcode{try_lock}~(\ref{thread.lock.algorithm}), and -\tcode{condition_variable_any}~(\ref{thread.condition.condvarany}) all operate on user-supplied +The standard library templates \tcode{unique_lock}\iref{thread.lock.unique}, +\tcode{shared_lock}\iref{thread.lock.shared}, +\tcode{scoped_lock}\iref{thread.lock.scoped}, +\tcode{lock_guard}\iref{thread.lock.guard}, \tcode{lock}, +\tcode{try_lock}\iref{thread.lock.algorithm}, and +\tcode{condition_variable_any}\iref{thread.condition.condvarany} all operate on user-supplied lockable objects. The \tcode{BasicLockable} requirements, the \tcode{Lockable} requirements, and the \tcode{TimedLockable} requirements list the requirements imposed by these library types in order to acquire or release ownership of a \tcode{lock} by a given execution agent. @@ -227,8 +227,8 @@ A type \tcode{L} meets the \tcode{TimedLockable} requirements if it meets the \tcode{Lockable} requirements and the following expressions are well-formed and have the specified semantics (\tcode{m} denotes a value of type \tcode{L}, \tcode{rel_time} denotes a value of an -instantiation of \tcode{duration}~(\ref{time.duration}), and \tcode{abs_time} denotes a value -of an instantiation of \tcode{time_point}~(\ref{time.point})). +instantiation of \tcode{duration}\iref{time.duration}, and \tcode{abs_time} denotes a value +of an instantiation of \tcode{time_point}\iref{time.point}). \begin{itemdecl} m.try_lock_for(rel_time) @@ -237,7 +237,7 @@ \begin{itemdescr} \pnum \effects Attempts to acquire a lock for the current execution agent within the relative -timeout~(\ref{thread.req.timing}) specified by \tcode{rel_time}. The function shall not return +timeout\iref{thread.req.timing} specified by \tcode{rel_time}. The function shall not return within the timeout specified by \tcode{rel_time} unless it has obtained a lock on \tcode{m} for the current execution agent. If an exception is thrown then a lock shall not have been acquired for the current execution agent. @@ -256,7 +256,7 @@ \begin{itemdescr} \pnum \effects Attempts to acquire a lock for the current execution agent before the absolute -timeout~(\ref{thread.req.timing}) specified by \tcode{abs_time}. The function shall not return +timeout\iref{thread.req.timing} specified by \tcode{abs_time}. The function shall not return before the timeout specified by \tcode{abs_time} unless it has obtained a lock on \tcode{m} for the current execution agent. If an exception is thrown then a lock shall not have been acquired for the current execution agent. @@ -389,14 +389,14 @@ \pnum An object of type \tcode{thread::id} provides a unique identifier for each thread of execution and a single distinct value for all \tcode{thread} objects that do not represent a thread of -execution~(\ref{thread.thread.class}). Each thread of execution has an +execution\iref{thread.thread.class}. Each thread of execution has an associated \tcode{thread::id} object that is not equal to the \tcode{thread::id} object of any other thread of execution and that is not equal to the \tcode{thread::id} object of any \tcode{thread} object that does not represent threads of execution. \pnum -\tcode{thread::id} shall be a trivially copyable class (Clause~\ref{class}). +\tcode{thread::id} shall be a trivially copyable class\iref{class}. The library may reuse the value of a \tcode{thread::id} of a terminated thread that can no longer be joined. \pnum @@ -495,7 +495,7 @@ \end{itemdecl} \begin{itemdescr} -\pnum The specialization is enabled~(\ref{unord.hash}). +\pnum The specialization is enabled\iref{unord.hash}. \end{itemdescr} \rSec3[thread.thread.constr]{\tcode{thread} constructors} @@ -525,7 +525,7 @@ \placeholdernc{DECAY_COPY}(\brk{}% std::forward(f)), \placeholdernc{DECAY_COPY}(\brk{}% -std::forward(\brk{}args))...)}~(\ref{func.require}) shall be +std::forward(\brk{}args))...)}\iref{func.require} shall be a va\-lid expression. \pnum @@ -654,7 +654,7 @@ \effects\ Blocks until the thread represented by \tcode{*this} has completed. \pnum -\sync The completion of the thread represented by \tcode{*this} synchronizes with~(\ref{intro.multithread}) +\sync The completion of the thread represented by \tcode{*this} synchronizes with\iref{intro.multithread} the corresponding successful \tcode{join()} return. \begin{note} Operations on \tcode{*this} are not synchronized. \end{note} @@ -664,7 +664,7 @@ \pnum \throws \tcode{system_error} when -an exception is required~(\ref{thread.req.exception}). +an exception is required\iref{thread.req.exception}. \pnum \errors @@ -693,7 +693,7 @@ \pnum\postconditions \tcode{get_id() == id()}. \pnum\throws \tcode{system_error} when -an exception is required~(\ref{thread.req.exception}). +an exception is required\iref{thread.req.exception}. \pnum \errors \begin{itemize} @@ -725,7 +725,7 @@ \pnum \returns The number of hardware thread contexts. \begin{note} This value should only be considered to be a hint. \end{note} If this value is not computable or -well defined an implementation should return 0. +well defined, an implementation should return 0. \end{itemdescr} \rSec3[thread.thread.algorithm]{\tcode{thread} specialized algorithms} @@ -787,14 +787,14 @@ \begin{itemdescr} \pnum -\effects Blocks the calling thread for the absolute timeout~(\ref{thread.req.timing}) specified +\effects Blocks the calling thread for the absolute timeout\iref{thread.req.timing} specified by \tcode{abs_time}. \pnum \sync None. \pnum -\throws Timeout-related exceptions~(\ref{thread.req.timing}). +\throws Timeout-related exceptions\iref{thread.req.timing}. \end{itemdescr} \indexlibrarymember{sleep_for}{this_thread}% @@ -805,14 +805,14 @@ \begin{itemdescr} \pnum -\effects Blocks the calling thread for the relative timeout~(\ref{thread.req.timing}) specified +\effects Blocks the calling thread for the relative timeout\iref{thread.req.timing} specified by \tcode{rel_time}. \pnum \sync None. \pnum -\throws Timeout-related exceptions~(\ref{thread.req.timing}). +\throws Timeout-related exceptions\iref{thread.req.timing}. \end{itemdescr} \rSec1[thread.mutex]{Mutual exclusion} @@ -820,7 +820,7 @@ \pnum This section provides mechanisms for mutual exclusion: mutexes, locks, and call once. These mechanisms ease the production of race-free -programs~(\ref{intro.multithread}). +programs\iref{intro.multithread}. \rSec2[mutex.syn]{Header \tcode{} synopsis} \indextext{\idxhdr{mutex}}% @@ -878,7 +878,7 @@ \pnum A mutex object facilitates protection against data races and allows safe synchronization of -data between execution agents~(\ref{thread.req.lockable}). +data between execution agents\iref{thread.req.lockable}. An execution agent \term{owns} a mutex from the time it successfully calls one of the lock functions until it calls unlock. Mutexes can be either recursive or non-recursive, and can grant simultaneous ownership to one or many execution agents. Both @@ -894,7 +894,7 @@ denotes an object of a mutex type. \pnum -The mutex types shall meet the \tcode{Lockable} requirements~(\ref{thread.req.lockable.req}). +The mutex types shall meet the \tcode{Lockable} requirements\iref{thread.req.lockable.req}. \pnum The mutex types shall be \tcode{DefaultConstructible} and \tcode{Destructible}. If @@ -915,9 +915,9 @@ \pnum 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 +atomic operations\iref{intro.multithread}. The lock and unlock operations on 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 +can be viewed as the modification order\iref{intro.multithread} of the mutex. \end{note} \begin{note} Construction and destruction of an object of a mutex type need not be thread-safe; other @@ -944,11 +944,11 @@ \pnum \sync Prior \tcode{unlock()} operations on the same object shall -\term{synchronize with}~(\ref{intro.multithread}) this operation. +\term{synchronize with}\iref{intro.multithread} this operation. \pnum \throws \tcode{system_error} when -an exception is required~(\ref{thread.req.exception}). +an exception is required\iref{thread.req.exception}. \pnum \errors \begin{itemize} @@ -975,8 +975,8 @@ immediately returns. An implementation may fail to obtain the lock even if it is not held by any other thread. \begin{note} This spurious failure is normally uncommon, but allows interesting implementations based on a simple -compare and exchange -(Clause~\ref{atomics}). \end{note} +compare and exchange\iref{atomics}. +\end{note} An implementation should ensure that \tcode{try_lock()} does not consistently return \tcode{false} in the absence of contending mutex acquisitions. @@ -989,7 +989,7 @@ \pnum \sync If \tcode{try_lock()} returns \tcode{true}, prior \tcode{unlock()} operations -on the same object \term{synchronize with}~(\ref{intro.multithread}) this operation. +on the same object \term{synchronize with}\iref{intro.multithread} this operation. \begin{note} Since \tcode{lock()} does not synchronize with a failed subsequent \tcode{try_lock()}, the visibility rules are weak enough that little would be known about the state after a failure, even in the absence of spurious failures. \end{note} @@ -1012,7 +1012,7 @@ \returntype \tcode{void}. \pnum -\sync This operation synchronizes with~(\ref{intro.multithread}) subsequent +\sync This operation synchronizes with\iref{intro.multithread} subsequent lock operations that obtain ownership on the same object. \pnum @@ -1061,8 +1061,8 @@ \pnum The class \tcode{mutex} shall satisfy all of the mutex -requirements~(\ref{thread.mutex.requirements}). It shall be a standard-layout -class (Clause~\ref{class}). +requirements\iref{thread.mutex.requirements}. It shall be a standard-layout +class\iref{class}. \pnum \begin{note} A program may deadlock if the thread that owns a \tcode{mutex} object calls @@ -1105,8 +1105,8 @@ \pnum The class \tcode{recursive_mutex} shall satisfy all of the mutex -requirements~(\ref{thread.mutex.requirements}). It shall be a standard-layout -class (Clause~\ref{class}). +requirements\iref{thread.mutex.requirements}. It shall be a standard-layout +class\iref{class}. \pnum A thread that owns a \tcode{recursive_mutex} object may acquire additional levels of @@ -1135,13 +1135,13 @@ meet the requirements set out below. In this description, \tcode{m} denotes an object of a mutex type, \tcode{rel_time} denotes an object of an -instantiation of \tcode{duration}~(\ref{time.duration}), and \tcode{abs_time} denotes an +instantiation of \tcode{duration}\iref{time.duration}, and \tcode{abs_time} denotes an object of an -instantiation of \tcode{time_point}~(\ref{time.point}). +instantiation of \tcode{time_point}\iref{time.point}. \pnum The timed mutex types shall meet the \tcode{TimedLockable} -requirements~(\ref{thread.req.lockable.timed}). +requirements\iref{thread.req.lockable.timed}. \pnum The expression \tcode{m.try_lock_for(rel_time)} shall be well-formed and have the @@ -1155,7 +1155,7 @@ \pnum \effects The function attempts to obtain ownership of the mutex within the -relative timeout~(\ref{thread.req.timing}) +relative timeout\iref{thread.req.timing} specified by \tcode{rel_time}. If the time specified by \tcode{rel_time} is less than or equal to \tcode{rel_time.zero()}, the function attempts to obtain ownership without blocking (as if by calling \tcode{try_lock()}). The function shall return within the timeout specified by @@ -1172,9 +1172,9 @@ \pnum \sync If \tcode{try_lock_for()} returns \tcode{true}, prior \tcode{unlock()} operations -on the same object \term{synchronize with}~(\ref{intro.multithread}) this operation. +on the same object \term{synchronize with}\iref{intro.multithread} this operation. -\pnum\throws Timeout-related exceptions~(\ref{thread.req.timing}). +\pnum\throws Timeout-related exceptions\iref{thread.req.timing}. \end{itemdescr} \pnum @@ -1191,7 +1191,7 @@ \effects The function attempts to obtain ownership of the mutex. If \tcode{abs_time} has already passed, the function attempts to obtain ownership without blocking (as if by calling \tcode{try_lock()}). The function shall -return before the absolute timeout~(\ref{thread.req.timing}) specified by +return before the absolute timeout\iref{thread.req.timing} specified by \tcode{abs_time} only if it has obtained ownership of the mutex object. \begin{note} As with \tcode{try_lock()}, there is no guarantee that ownership will be obtained if the lock is available, but implementations are expected to make a @@ -1204,10 +1204,10 @@ \pnum \sync If \tcode{try_lock_until()} returns \tcode{true}, prior \tcode{unlock()} -operations on the same object \term{synchronize with}~(\ref{intro.multithread}) +operations on the same object \term{synchronize with}\iref{intro.multithread} this operation. -\pnum\throws Timeout-related exceptions~(\ref{thread.req.timing}). +\pnum\throws Timeout-related exceptions\iref{thread.req.timing}. \end{itemdescr} \rSec4[thread.timedmutex.class]{Class \tcode{timed_mutex}} @@ -1248,8 +1248,8 @@ \pnum The class \tcode{timed_mutex} shall satisfy all of the timed mutex -requirements~(\ref{thread.timedmutex.requirements}). It shall be a standard-layout -class (Clause~\ref{class}). +requirements\iref{thread.timedmutex.requirements}. It shall be a standard-layout +class\iref{class}. \pnum The behavior of a program is undefined if: @@ -1299,8 +1299,8 @@ \pnum The class \tcode{recursive_timed_mutex} shall satisfy all of the timed mutex -requirements~(\ref{thread.timedmutex.requirements}). It shall be a standard-layout -class (Clause~\ref{class}). +requirements\iref{thread.timedmutex.requirements}. It shall be a standard-layout +class\iref{class}. \pnum A thread that owns a \tcode{recursive_timed_mutex} object may acquire additional @@ -1330,7 +1330,7 @@ \pnum The standard library types \tcode{shared_mutex} and \tcode{shared_timed_mutex} are \defn{shared mutex types}. Shared mutex types shall meet the requirements of -mutex types~(\ref{thread.mutex.requirements.mutex}), and additionally +mutex types\iref{thread.mutex.requirements.mutex}, and additionally shall meet the requirements set out below. In this description, \tcode{m} denotes an object of a shared mutex type. @@ -1367,10 +1367,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\iref{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\iref{thread.req.exception}. \pnum \errors @@ -1394,7 +1394,7 @@ \returntype \tcode{void}. \pnum -\sync This operation synchronizes with~(\ref{intro.multithread}) subsequent +\sync This operation synchronizes with\iref{intro.multithread} subsequent \tcode{lock()} operations that obtain ownership on the same object. \pnum @@ -1423,7 +1423,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\iref{intro.multithread} this operation. \pnum @@ -1465,8 +1465,8 @@ \pnum The class \tcode{shared_mutex} shall satisfy all of the -shared mutex requirements~(\ref{thread.sharedmutex.requirements}). -It shall be a standard-layout class (Clause~\ref{class}). +shared mutex requirements\iref{thread.sharedmutex.requirements}. +It shall be a standard-layout class\iref{class}. \pnum The behavior of a program is undefined if: @@ -1484,14 +1484,14 @@ \pnum The standard library type \tcode{shared_timed_mutex} is a \defn{shared timed mutex type}. Shared timed mutex types shall meet the requirements of -timed mutex types~(\ref{thread.timedmutex.requirements}), -shared mutex types~(\ref{thread.sharedmutex.requirements}), and additionally +timed mutex types\iref{thread.timedmutex.requirements}, +shared mutex types\iref{thread.sharedmutex.requirements}, and additionally shall meet the requirements set out below. In this description, \tcode{m} denotes an object of a shared timed mutex type, \tcode{rel_type} denotes an object of an instantiation of -\tcode{duration}~(\ref{time.duration}), and +\tcode{duration}\iref{time.duration}, and \tcode{abs_time} denotes an object of an instantiation of -\tcode{time_point}~(\ref{time.point}). +\tcode{time_point}\iref{time.point}. \pnum The expression \tcode{m.try_lock_shared_for(rel_time)} shall be well-formed and @@ -1504,7 +1504,7 @@ \pnum \effects Attempts to obtain shared lock ownership for the calling thread within the relative -timeout~(\ref{thread.req.timing}) specified by \tcode{rel_time}. If the time +timeout\iref{thread.req.timing} specified by \tcode{rel_time}. If the time specified by \tcode{rel_time} is less than or equal to \tcode{rel_time.zero()}, the function attempts to obtain ownership without blocking (as if by calling \tcode{try_lock_shared()}). The function shall return within the timeout @@ -1524,10 +1524,10 @@ \pnum \sync If \tcode{try_lock_shared_for()} returns \tcode{true}, prior \tcode{unlock()} operations on the same object synchronize -with~(\ref{intro.multithread}) this operation. +with\iref{intro.multithread} this operation. \pnum -\throws Timeout-related exceptions~(\ref{thread.req.timing}). +\throws Timeout-related exceptions\iref{thread.req.timing}. \end{itemdescr} \pnum @@ -1542,7 +1542,7 @@ \effects The function attempts to obtain shared ownership of the mutex. If \tcode{abs_time} has already passed, the function attempts to obtain shared ownership without blocking (as if by calling \tcode{try_lock_shared()}). The -function shall return before the absolute timeout~(\ref{thread.req.timing}) +function shall return before the absolute timeout\iref{thread.req.timing} specified by \tcode{abs_time} only if it has obtained shared ownership of the mutex object. \begin{note} As with \tcode{try_lock()}, there is no guarantee that ownership will be obtained if the lock is available, but implementations are @@ -1559,10 +1559,10 @@ \pnum \sync If \tcode{try_lock_shared_until()} returns \tcode{true}, prior \tcode{unlock()} operations on the same object synchronize -with~(\ref{intro.multithread}) this operation. +with\iref{intro.multithread} this operation. \pnum -\throws Timeout-related exceptions~(\ref{thread.req.timing}). +\throws Timeout-related exceptions\iref{thread.req.timing}. \end{itemdescr} \rSec4[thread.sharedtimedmutex.class]{Class \tcode{shared_timed_mutex}} @@ -1607,8 +1607,8 @@ \pnum The class \tcode{shared_timed_mutex} shall satisfy all of the -shared timed mutex requirements~(\ref{thread.sharedtimedmutex.requirements}). -It shall be a standard-layout class (Clause~\ref{class}). +shared timed mutex requirements\iref{thread.sharedtimedmutex.requirements}. +It shall be a standard-layout class\iref{class}. \pnum The behavior of a program is undefined if: @@ -1681,11 +1681,11 @@ \pnum An object of type \tcode{lock_guard} controls the ownership of a lockable object within a scope. A \tcode{lock_guard} object maintains ownership of a lockable -object throughout the \tcode{lock_guard} object's lifetime~(\ref{basic.life}). +object throughout the \tcode{lock_guard} object's lifetime\iref{basic.life}. The behavior of a program is undefined if the lockable object referenced by \tcode{pm} does not exist for the entire lifetime of the \tcode{lock_guard} object. The supplied \tcode{Mutex} type shall meet the \tcode{BasicLockable} -requirements~(\ref{thread.req.lockable.basic}). +requirements\iref{thread.req.lockable.basic}. \indexlibrary{\idxcode{lock_guard}!constructor}% \begin{itemdecl} @@ -1742,7 +1742,7 @@ using mutex_type = Mutex; // If \tcode{MutexTypes...} consists of the single type \tcode{Mutex} explicit scoped_lock(MutexTypes&... m); - explicit scoped_lock(MutexTypes&... m, adopt_lock_t); + explicit scoped_lock(adopt_lock_t, MutexTypes&... m); ~scoped_lock(); scoped_lock(const scoped_lock&) = delete; @@ -1760,15 +1760,15 @@ \pnum An object of type \tcode{scoped_lock} controls the ownership of lockable objects within a scope. A \tcode{scoped_lock} object maintains ownership of lockable -objects throughout the \tcode{scoped_lock} object's lifetime~(\ref{basic.life}). +objects throughout the \tcode{scoped_lock} object's lifetime\iref{basic.life}. The behavior of a program is undefined if the lockable objects referenced by \tcode{pm} do not exist for the entire lifetime of the \tcode{scoped_lock} object. When \tcode{sizeof...(MutexTypes)} is \tcode{1}, the supplied \tcode{Mutex} type -shall meet the \tcode{BasicLockable} requirements~(\ref{thread.req.lockable.basic}). +shall meet the \tcode{BasicLockable} requirements\iref{thread.req.lockable.basic}. Otherwise, each of the mutex types -shall meet the \tcode{Lockable} requirements~(\ref{thread.req.lockable.req}). +shall meet the \tcode{Lockable} requirements\iref{thread.req.lockable.req}. \indexlibrary{\idxcode{scoped_lock}!constructor}% \begin{itemdecl} @@ -1789,7 +1789,7 @@ \indexlibrary{\idxcode{scoped_lock}!constructor}% \begin{itemdecl} -explicit scoped_lock(MutexTypes&... m, adopt_lock_t); +explicit scoped_lock(adopt_lock_t, MutexTypes&... m); \end{itemdecl} \begin{itemdescr} @@ -1882,16 +1882,16 @@ copyable but are movable. The behavior of a program is undefined if the contained pointer \tcode{pm} is not null and the lockable object pointed to by \tcode{pm} does not exist for the entire remaining -lifetime~(\ref{basic.life}) of the \tcode{unique_lock} object. The supplied +lifetime\iref{basic.life} of the \tcode{unique_lock} object. The supplied \tcode{Mutex} type shall meet the \tcode{BasicLockable} -requirements~(\ref{thread.req.lockable.basic}). +requirements\iref{thread.req.lockable.basic}. \pnum \begin{note} \tcode{unique_lock} meets the \tcode{BasicLockable} requirements. If \tcode{Mutex} -meets the \tcode{Lockable} requirements~(\ref{thread.req.lockable.req}), +meets the \tcode{Lockable} requirements\iref{thread.req.lockable.req}, \tcode{unique_lock} also meets the \tcode{Lockable} requirements; if \tcode{Mutex} -meets the \tcode{TimedLockable} requirements~(\ref{thread.req.lockable.timed}), +meets the \tcode{TimedLockable} requirements\iref{thread.req.lockable.timed}, \tcode{unique_lock} also meets the \tcode{TimedLockable} requirements. \end{note} \rSec4[thread.lock.unique.cons]{\tcode{unique_lock} constructors, destructor, and assignment} @@ -1947,7 +1947,7 @@ \pnum \requires The supplied \tcode{Mutex} type shall meet the \tcode{Lockable} -requirements~(\ref{thread.req.lockable.req}). +requirements\iref{thread.req.lockable.req}. If \tcode{mutex_type} is not a recursive mutex the calling thread does not own the mutex. \pnum @@ -1987,7 +1987,7 @@ \pnum \requires If \tcode{mutex_type} is not a recursive mutex the calling thread does not own the mutex. The supplied \tcode{Mutex} type shall meet the -\tcode{TimedLockable} requirements~(\ref{thread.req.lockable.timed}). +\tcode{TimedLockable} requirements\iref{thread.req.lockable.timed}. \pnum \effects Constructs an object of type \tcode{unique_lock} and calls \tcode{m.try_lock_until(abs_time)}. @@ -2007,7 +2007,7 @@ \begin{itemdescr} \pnum \requires If \tcode{mutex_type} is not a recursive mutex the calling thread does not own the mutex. -The supplied \tcode{Mutex} type shall meet the \tcode{TimedLockable} requirements~(\ref{thread.req.lockable.timed}). +The supplied \tcode{Mutex} type shall meet the \tcode{TimedLockable} requirements\iref{thread.req.lockable.timed}. \pnum \effects Constructs an object of type \tcode{unique_lock} and calls \tcode{m.try_lock_for(rel_time)}. @@ -2069,7 +2069,7 @@ \pnum \throws Any exception thrown by \tcode{pm->lock()}. \tcode{system_error} when an exception -is required~(\ref{thread.req.exception}). +is required\iref{thread.req.exception}. \pnum \errors @@ -2088,7 +2088,7 @@ \begin{itemdescr} \pnum \requires The supplied \tcode{Mutex} shall meet the \tcode{Lockable} -requirements~(\ref{thread.req.lockable.req}). +requirements\iref{thread.req.lockable.req}. \pnum \effects As if by \tcode{pm->try_lock()}. @@ -2102,7 +2102,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\iref{thread.req.exception}. \pnum \errors @@ -2122,7 +2122,7 @@ \begin{itemdescr} \pnum \requires The supplied \tcode{Mutex} type shall meet the \tcode{TimedLockable} -requirements~(\ref{thread.req.lockable.timed}). +requirements\iref{thread.req.lockable.timed}. \pnum \effects As if by \tcode{pm->try_lock_until(abs_time)}. @@ -2136,7 +2136,7 @@ \pnum \throws Any exception thrown by \tcode{pm->try_lock_until()}. \tcode{system_error} when an -exception is required~(\ref{thread.req.exception}). +exception is required\iref{thread.req.exception}. \pnum \errors @@ -2155,7 +2155,7 @@ \begin{itemdescr} \pnum -\requires The supplied \tcode{Mutex} type shall meet the \tcode{TimedLockable} requirements~(\ref{thread.req.lockable.timed}). +\requires The supplied \tcode{Mutex} type shall meet the \tcode{TimedLockable} requirements\iref{thread.req.lockable.timed}. \pnum \effects As if by \tcode{pm->try_lock_for(rel_time)}. @@ -2168,7 +2168,7 @@ \pnum \throws Any exception thrown by \tcode{pm->try_lock_for()}. \tcode{system_error} when an -exception is required (\ref{thread.req.exception}). +exception is required\iref{thread.req.exception}. \pnum \errors @@ -2190,7 +2190,7 @@ \pnum\postconditions \tcode{owns == false}. \pnum\throws \tcode{system_error} when -an exception is required~(\ref{thread.req.exception}). +an exception is required\iref{thread.req.exception}. \pnum \errors \begin{itemize} @@ -2327,13 +2327,13 @@ \tcode{shared_lock} are not copyable but are movable. The behavior of a program is undefined if the contained pointer \tcode{pm} is not null and the lockable object pointed to by \tcode{pm} does not exist for the entire remaining -lifetime~(\ref{basic.life}) of the \tcode{shared_lock} object. The supplied +lifetime\iref{basic.life} of the \tcode{shared_lock} object. The supplied \tcode{Mutex} type shall meet the shared mutex -requirements~(\ref{thread.sharedtimedmutex.requirements}). +requirements\iref{thread.sharedtimedmutex.requirements}. \pnum \begin{note} \tcode{shared_lock} meets the \tcode{TimedLockable} -requirements~(\ref{thread.req.lockable.timed}). \end{note} +requirements\iref{thread.req.lockable.timed}. \end{note} \rSec4[thread.lock.shared.cons]{\tcode{shared_lock} constructors, destructor, and assignment} @@ -2508,7 +2508,7 @@ \pnum \throws Any exception thrown by \tcode{pm->lock_shared()}. -\tcode{system_error} when an exception is required~(\ref{thread.req.exception}). +\tcode{system_error} when an exception is required\iref{thread.req.exception}. \pnum \errors @@ -2537,7 +2537,7 @@ \pnum \throws Any exception thrown by \tcode{pm->try_lock_shared()}. -\tcode{system_error} when an exception is required~(\ref{thread.req.exception}). +\tcode{system_error} when an exception is required\iref{thread.req.exception}. \pnum \errors @@ -2569,7 +2569,7 @@ \pnum \throws Any exception thrown by \tcode{pm->try_lock_shared_until(abs_time)}. -\tcode{system_error} when an exception is required~(\ref{thread.req.exception}). +\tcode{system_error} when an exception is required\iref{thread.req.exception}. \pnum \errors @@ -2597,7 +2597,7 @@ \postconditions \tcode{owns == res}, where \tcode{res} is the value returned by the call to \tcode{pm->try_lock_shared_for(rel_time)}. \pnum -\throws Any exception thrown by \tcode{pm->try_lock_shared_for(rel_time)}. \tcode{system_error} when an exception is required~(\ref{thread.req.exception}). +\throws Any exception thrown by \tcode{pm->try_lock_shared_for(rel_time)}. \tcode{system_error} when an exception is required\iref{thread.req.exception}. \pnum \errors @@ -2621,7 +2621,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\iref{thread.req.exception}. \pnum \errors @@ -2817,12 +2817,12 @@ \pnum \sync For any given \tcode{once_flag}: all active executions occur in a total -order; completion of an active execution synchronizes with~(\ref{intro.multithread}) +order; completion of an active execution synchronizes with\iref{intro.multithread} the start of the next one in this total order; and the returning execution synchronizes with the return from all passive executions. \pnum\throws \tcode{system_error} when -an exception is required~(\ref{thread.req.exception}), or any exception thrown by \tcode{func}. +an exception is required\iref{thread.req.exception}, or any exception thrown by \tcode{func}. \pnum \begin{example} @@ -2998,7 +2998,7 @@ \end{codeblock} \pnum -The class \tcode{condition_variable} shall be a standard-layout class (Clause~\ref{class}). +The class \tcode{condition_variable} shall be a standard-layout class\iref{class}. \indexlibrary{\idxcode{condition_variable}!constructor}% \begin{itemdecl} @@ -3010,7 +3010,7 @@ \effects Constructs an object of type \tcode{condition_variable}. \pnum -\throws \tcode{system_error} when an exception is required~(\ref{thread.req.exception}). +\throws \tcode{system_error} when an exception is required\iref{thread.req.exception}. \pnum \errors @@ -3085,7 +3085,7 @@ \pnum \remarks If the function fails to meet the postcondition, \tcode{terminate()} -shall be called~(\ref{except.terminate}). +shall be called\iref{except.terminate}. \begin{note} This can happen if the re-locking of the mutex throws an exception. \end{note} \pnum @@ -3124,7 +3124,7 @@ \pnum \remarks If the function fails to meet the postcondition, \tcode{terminate()} -shall be called~(\ref{except.terminate}). +shall be called\iref{except.terminate}. \begin{note} This can happen if the re-locking of the mutex throws an exception. \end{note} \pnum @@ -3165,7 +3165,7 @@ \item The function will unblock when signaled by a call to \tcode{notify_one()}, a call to \tcode{notify_all()}, -expiration of the absolute timeout~(\ref{thread.req.timing}) specified by \tcode{abs_time}, +expiration of the absolute timeout\iref{thread.req.timing} specified by \tcode{abs_time}, or spuriously. \item @@ -3175,7 +3175,7 @@ \pnum \remarks If the function fails to meet the postcondition, \tcode{terminate()} -shall be called~(\ref{except.terminate}). +shall be called\iref{except.terminate}. \begin{note} This can happen if the re-locking of the mutex throws an exception. \end{note} \pnum @@ -3184,11 +3184,11 @@ \pnum \returns \tcode{cv_status::timeout} if -the absolute timeout~(\ref{thread.req.timing}) specified by \tcode{abs_time} expired, +the absolute timeout\iref{thread.req.timing} specified by \tcode{abs_time} expired, otherwise \tcode{cv_status::no_timeout}. \pnum\throws Timeout-related -exceptions~(\ref{thread.req.timing}). +exceptions\iref{thread.req.timing}. \end{itemdescr} @@ -3218,13 +3218,13 @@ \pnum \returns \tcode{cv_status::timeout} if -the relative timeout~(\ref{thread.req.timing}) specified by \tcode{rel_time} expired, +the relative timeout\iref{thread.req.timing} specified by \tcode{rel_time} expired, otherwise \tcode{cv_status::no_timeout}. \pnum \remarks If the function fails to meet the postcondition, \tcode{terminate()} -shall be called~(\ref{except.terminate}). +shall be called\iref{except.terminate}. \begin{note} This can happen if the re-locking of the mutex throws an exception. \end{note} \pnum @@ -3233,7 +3233,7 @@ \pnum \throws Timeout-related -exceptions~(\ref{thread.req.timing}). +exceptions\iref{thread.req.timing}. \end{itemdescr} @@ -3269,7 +3269,7 @@ \pnum \remarks If the function fails to meet the postcondition, \tcode{terminate()} -shall be called~(\ref{except.terminate}). +shall be called\iref{except.terminate}. \begin{note} This can happen if the re-locking of the mutex throws an exception. \end{note} \pnum @@ -3282,7 +3282,7 @@ \pnum \throws Timeout-related -exceptions~(\ref{thread.req.timing}) or any exception thrown by \tcode{pred}. +exceptions\iref{thread.req.timing} or any exception thrown by \tcode{pred}. \end{itemdescr} @@ -3321,7 +3321,7 @@ \pnum \remarks If the function fails to meet the postcondition, \tcode{terminate()} -shall be called~(\ref{except.terminate}). +shall be called\iref{except.terminate}. \begin{note} This can happen if the re-locking of the mutex throws an exception. \end{note} \pnum @@ -3334,7 +3334,7 @@ \pnum \throws Timeout-related -exceptions~(\ref{thread.req.timing}) or any exception thrown by \tcode{pred}. +exceptions\iref{thread.req.timing} or any exception thrown by \tcode{pred}. \end{itemdescr} @@ -3342,7 +3342,7 @@ \pnum A \tcode{Lock} type shall meet the \tcode{BasicLockable} -requirements~(\ref{thread.req.lockable.basic}). \begin{note} All of the standard +requirements\iref{thread.req.lockable.basic}. \begin{note} All of the standard mutex types meet this requirement. If a \tcode{Lock} type other than one of the standard mutex types or a \tcode{unique_lock} wrapper for a standard mutex type is used with \tcode{condition_variable_any}, the user must ensure that any @@ -3392,7 +3392,7 @@ \pnum \throws \tcode{bad_alloc} or \tcode{system_error} when an exception is -required~(\ref{thread.req.exception}). +required\iref{thread.req.exception}. \pnum \errors @@ -3469,7 +3469,7 @@ \pnum \remarks If the function fails to meet the postcondition, \tcode{terminate()} -shall be called~(\ref{except.terminate}). +shall be called\iref{except.terminate}. \begin{note} This can happen if the re-locking of the mutex throws an exception. \end{note} \pnum\postconditions \tcode{lock} is locked by the calling thread. @@ -3511,7 +3511,7 @@ \item The function will unblock when signaled by a call to \tcode{notify_one()}, a call to \tcode{notify_all()}, -expiration of the absolute timeout~(\ref{thread.req.timing}) specified by \tcode{abs_time}, +expiration of the absolute timeout\iref{thread.req.timing} specified by \tcode{abs_time}, or spuriously. \item @@ -3521,7 +3521,7 @@ \pnum \remarks If the function fails to meet the postcondition, \tcode{terminate()} -shall be called~(\ref{except.terminate}). +shall be called\iref{except.terminate}. \begin{note} This can happen if the re-locking of the mutex throws an exception. \end{note} \pnum @@ -3529,12 +3529,12 @@ \pnum \returns \tcode{cv_status::timeout} if -the absolute timeout~(\ref{thread.req.timing}) specified by \tcode{abs_time} expired, +the absolute timeout\iref{thread.req.timing} specified by \tcode{abs_time} expired, otherwise \tcode{cv_status::no_timeout}. \pnum \throws Timeout-related -exceptions~(\ref{thread.req.timing}). +exceptions\iref{thread.req.timing}. \end{itemdescr} @@ -3553,13 +3553,13 @@ \pnum \returns \tcode{cv_status::timeout} if -the relative timeout~(\ref{thread.req.timing}) specified by \tcode{rel_time} expired, +the relative timeout\iref{thread.req.timing} specified by \tcode{rel_time} expired, otherwise \tcode{cv_status::no_timeout}. \pnum \remarks If the function fails to meet the postcondition, \tcode{terminate()} -shall be called~(\ref{except.terminate}). +shall be called\iref{except.terminate}. \begin{note} This can happen if the re-locking of the mutex throws an exception. \end{note} \pnum @@ -3567,7 +3567,7 @@ \pnum \throws Timeout-related -exceptions~(\ref{thread.req.timing}). +exceptions\iref{thread.req.timing}. \end{itemdescr} @@ -3692,7 +3692,7 @@ \end{codeblock} \pnum -The \tcode{enum} type \tcode{launch} is a bitmask type~(\ref{bitmask.types}) with +The \tcode{enum} type \tcode{launch} is a bitmask type\iref{bitmask.types} with elements \tcode{launch::async} and \tcode{launch::deferred}. \begin{note} Implementations can provide bitmasks to specify restrictions on task interaction by functions launched by \tcode{async()} applicable to a @@ -3807,7 +3807,7 @@ that potentially blocks to wait for the shared state to be made ready. If a waiting function can return before the state is made ready because of a -timeout~(\ref{thread.req.lockable}), then it is a \term{timed waiting function}, otherwise +timeout\iref{thread.req.lockable}, then it is a \term{timed waiting function}, otherwise it is a \term{non-timed waiting function}. \pnum @@ -3878,25 +3878,25 @@ \pnum Calls to functions that successfully set the stored result of a shared state synchronize -with~(\ref{intro.multithread}) calls to functions +with\iref{intro.multithread} calls to functions successfully detecting the ready state resulting from that setting. The storage of the result (whether normal or exceptional) into the shared state -synchronizes with~(\ref{intro.multithread}) +synchronizes with\iref{intro.multithread} the successful return from a call to a waiting function on the shared state. \pnum Some functions (e.g., \tcode{promise::set_value_at_thread_exit}) delay making the shared state ready until the calling thread exits. The destruction of -each of that thread's objects with thread storage duration~(\ref{basic.stc.thread}) +each of that thread's objects with thread storage duration\iref{basic.stc.thread} is sequenced before making that shared state ready. \pnum -Access to the result of the same shared state may conflict~(\ref{intro.multithread}). +Access to the result of the same shared state may conflict\iref{intro.multithread}. \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}) +avoidance\iref{res.on.data.races}. For example, concurrent accesses through +references returned by \tcode{shared_future::get()}\iref{futures.shared_future} must either use read-only operations or provide additional synchronization. \end{note} @@ -3959,7 +3959,7 @@ \begin{itemdescr} \pnum -\requires \tcode{Alloc} shall be an Allocator~(\ref{allocator.requirements}). +\requires \tcode{Alloc} shall be an Allocator\iref{allocator.requirements}. \end{itemdescr} @@ -3972,7 +3972,7 @@ \begin{itemdescr} \pnum -\effects constructs a \tcode{promise} object and a shared state. The second +\effects Constructs a \tcode{promise} object and a shared state. The second constructor uses the allocator \tcode{a} to allocate memory for the shared state. \end{itemdescr} @@ -3984,7 +3984,7 @@ \begin{itemdescr} \pnum -\effects constructs a new \tcode{promise} object and transfers ownership of the shared state +\effects Constructs a new \tcode{promise} object and transfers ownership of the shared state of \tcode{rhs} (if any) to the newly-constructed object. \pnum @@ -3999,7 +3999,7 @@ \begin{itemdescr} \pnum \effects -Abandons any shared state~(\ref{futures.state}). +Abandons any shared state\iref{futures.state}. \end{itemdescr} \indexlibrarymember{operator=}{promise}% @@ -4010,7 +4010,7 @@ \begin{itemdescr} \pnum \effects -Abandons any shared state~(\ref{futures.state}) and then as if +Abandons any shared state\iref{futures.state} and then as if \tcode{promise(std::move(rhs)).swap(*this)}. \pnum @@ -4069,7 +4069,7 @@ \begin{itemdescr} \pnum \effects Atomically stores the value \tcode{r} in the shared state and -makes that state ready~(\ref{futures.state}). +makes that state ready\iref{futures.state}. \pnum \throws @@ -4101,7 +4101,7 @@ \pnum \effects Atomically stores the exception pointer \tcode{p} in the shared state -and makes that state ready~(\ref{futures.state}). +and makes that state ready\iref{futures.state}. \pnum \throws \tcode{future_error} if its shared state @@ -4196,7 +4196,7 @@ do not share their shared state with other asynchronous return objects. A default-constructed \tcode{future} object has no shared state. A \tcode{future} object with shared state can be created by -functions on asynchronous providers~(\ref{futures.state}) or by the move constructor +functions on asynchronous providers\iref{futures.state} or by the move constructor and shares its shared state with the original asynchronous provider. The result (value or exception) of a \tcode{future} object @@ -4217,7 +4217,7 @@ is undefined. \begin{note} It is valid to move from a future object for which \tcode{valid() == false}. \end{note} -\begin{note} Implementations are encouraged to detect this case and throw an object of type +\begin{note} Implementations should detect this case and throw an object of type \tcode{future_error} with an error condition of \tcode{future_errc::no_state}. \end{note} \indexlibrary{\idxcode{future}}% @@ -4261,7 +4261,7 @@ \begin{itemdescr} \pnum -\effects Constructs an \indexdefn{empty \tcode{future} object}\term{empty} +\effects Constructs an \defnx{empty}{empty \tcode{future} object} \tcode{future} object that does not refer to a shared state. @@ -4299,7 +4299,7 @@ \effects \begin{itemize} \item -Releases any shared state~(\ref{futures.state}); +Releases any shared state\iref{futures.state}; \item destroys \tcode{*this}. \end{itemize} @@ -4315,7 +4315,7 @@ \effects \begin{itemize} \item -Releases any shared state~(\ref{futures.state}). +Releases any shared state\iref{futures.state}. \item move assigns the contents of \tcode{rhs} to \tcode{*this}. \end{itemize} @@ -4364,7 +4364,7 @@ \begin{itemize} \item \tcode{wait()}{s} until the shared state is ready, then retrieves the value stored in the shared state; -\item releases any shared state~(\ref{futures.state}). +\item releases any shared state\iref{futures.state}. \end{itemize} \pnum @@ -4382,7 +4382,7 @@ \end{itemize} \pnum -\throws the stored exception, if an exception was stored in the shared state. +\throws The stored exception, if an exception was stored in the shared state. \pnum \postconditions \tcode{valid() == false}. @@ -4418,10 +4418,10 @@ \begin{itemdescr} \pnum \effects -None if the shared state contains a deferred function~(\ref{futures.async}), +None if the shared state contains a deferred function\iref{futures.async}, otherwise blocks until the shared state is ready or until -the relative timeout~(\ref{thread.req.timing}) specified by \tcode{rel_time} has expired. +the relative timeout\iref{thread.req.timing} specified by \tcode{rel_time} has expired. \pnum \returns @@ -4433,13 +4433,13 @@ \item \tcode{future_status::ready} if the shared state is ready. \item \tcode{future_status::timeout} if the function is returning because the -relative timeout~(\ref{thread.req.timing}) +relative timeout\iref{thread.req.timing} specified by \tcode{rel_time} has expired. \end{itemize} \pnum \throws -timeout-related exceptions~(\ref{thread.req.timing}). +timeout-related exceptions\iref{thread.req.timing}. \end{itemdescr} \indexlibrarymember{wait_until}{future}% @@ -4451,10 +4451,10 @@ \begin{itemdescr} \pnum \effects -None if the shared state contains a deferred function~(\ref{futures.async}), +None if the shared state contains a deferred function\iref{futures.async}, otherwise blocks until the shared state is ready or until -the absolute timeout~(\ref{thread.req.timing}) specified by \tcode{abs_time} has expired. +the absolute timeout\iref{thread.req.timing} specified by \tcode{abs_time} has expired. \pnum \returns @@ -4466,13 +4466,13 @@ \item \tcode{future_status::ready} if the shared state is ready. \item \tcode{future_status::timeout} if the function is returning because the -absolute timeout~(\ref{thread.req.timing}) +absolute timeout\iref{thread.req.timing} specified by \tcode{abs_time} has expired. \end{itemize} \pnum \throws -timeout-related exceptions~(\ref{thread.req.timing}). +timeout-related exceptions\iref{thread.req.timing}. \end{itemdescr} @@ -4486,7 +4486,7 @@ shared state can be created by conversion from a \tcode{future} object and shares its shared state with the -original asynchronous provider~(\ref{futures.state}) of the shared state. +original asynchronous provider\iref{futures.state} of the shared state. The result (value or exception) of a \tcode{shared_future} object can be set by calling a respective function on an @@ -4502,7 +4502,7 @@ \tcode{valid()} on a \tcode{shared_future} object for which \tcode{valid() == false} is undefined. \begin{note} It is valid to copy or move from a \tcode{shared_future} object for which \tcode{valid()} is \tcode{false}. \end{note} -\begin{note} Implementations are encouraged to detect this case and throw an object of type +\begin{note} Implementations should detect this case and throw an object of type \tcode{future_error} with an error condition of \tcode{future_errc::no_state}. \end{note} \indexlibrary{\idxcode{shared_future}}% @@ -4547,8 +4547,8 @@ \begin{itemdescr} \pnum -\effects Constructs an \indexdefn{empty \tcode{shared_future} -object}\term{empty} \tcode{shared_future} object that does not refer to a +\effects Constructs an \defnx{empty}{empty \tcode{shared_future} object} +\tcode{shared_future} object that does not refer to a shared state. \pnum @@ -4599,7 +4599,7 @@ \effects \begin{itemize} \item -Releases any shared state~(\ref{futures.state}); +Releases any shared state\iref{futures.state}; \item destroys \tcode{*this}. \end{itemize} @@ -4615,7 +4615,7 @@ \effects \begin{itemize} \item -Releases any shared state~(\ref{futures.state}); +Releases any shared state\iref{futures.state}; \item move assigns the contents of \tcode{rhs} to \tcode{*this}. \end{itemize} @@ -4642,7 +4642,7 @@ \effects \begin{itemize} \item -Releases any shared state~(\ref{futures.state}); +Releases any shared state\iref{futures.state}; \item assigns the contents of \tcode{rhs} to \tcode{*this}. \begin{note} As a result, \tcode{*this} refers to the same shared state as \tcode{rhs} @@ -4671,7 +4671,7 @@ \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}). +introduce a data race\iref{intro.multithread}. \end{note} \pnum @@ -4698,7 +4698,7 @@ \end{itemize} \pnum -\throws the stored exception, if an exception was stored in the shared state. +\throws The stored exception, if an exception was stored in the shared state. \end{itemdescr} \indexlibrarymember{valid}{shared_future}% @@ -4731,10 +4731,10 @@ \begin{itemdescr} \pnum \effects -None if the shared state contains a deferred function~(\ref{futures.async}), +None if the shared state contains a deferred function\iref{futures.async}, otherwise blocks until the shared state is ready or until -the relative timeout~(\ref{thread.req.timing}) specified by +the relative timeout\iref{thread.req.timing} specified by \tcode{rel_time} has expired. \pnum @@ -4747,13 +4747,13 @@ \item \tcode{future_status::ready} if the shared state is ready. \item \tcode{future_status::timeout} if the function is returning because the -relative timeout~(\ref{thread.req.timing}) +relative timeout\iref{thread.req.timing} specified by \tcode{rel_time} has expired. \end{itemize} \pnum \throws -timeout-related exceptions~(\ref{thread.req.timing}). +timeout-related exceptions\iref{thread.req.timing}. \end{itemdescr} \indexlibrarymember{wait_until}{shared_future}% @@ -4765,10 +4765,10 @@ \begin{itemdescr} \pnum \effects -None if the shared state contains a deferred function~(\ref{futures.async}), +None if the shared state contains a deferred function\iref{futures.async}, otherwise blocks until the shared state is ready or until the -absolute timeout~(\ref{thread.req.timing}) specified by +absolute timeout\iref{thread.req.timing} specified by \tcode{abs_time} has expired. \pnum @@ -4781,13 +4781,13 @@ \item \tcode{future_status::ready} if the shared state is ready. \item \tcode{future_status::timeout} if the function is returning because the -absolute timeout~(\ref{thread.req.timing}) +absolute timeout\iref{thread.req.timing} specified by \tcode{abs_time} has expired. \end{itemize} \pnum \throws -timeout-related exceptions~(\ref{thread.req.timing}). +timeout-related exceptions\iref{thread.req.timing}. \end{itemdescr} \rSec2[futures.async]{Function template \tcode{async}} @@ -4869,7 +4869,7 @@ in the shared state. The shared state is not made ready until the function has completed. The first call to a -non-timed waiting function~(\ref{futures.state}) +non-timed waiting function\iref{futures.state} on an asynchronous return object referring to this shared state shall invoke the deferred function in the thread that called the waiting function. @@ -4899,12 +4899,12 @@ \begin{itemize} \item the invocation of \tcode{async} -synchronizes with~(\ref{intro.multithread}) the invocation of \tcode{f}. \begin{note} +synchronizes with\iref{intro.multithread} the invocation of \tcode{f}. \begin{note} This statement applies even when the corresponding \tcode{future} object is moved to another thread. \end{note}; and \item -the completion of the function \tcode{f} is sequenced before~(\ref{intro.multithread}) the +the completion of the function \tcode{f} is sequenced before\iref{intro.multithread} the shared state is made ready. \begin{note} \tcode{f} might not be called at all, so its completion might never happen. \end{note} \end{itemize} @@ -4916,11 +4916,11 @@ a call to a waiting function on an asynchronous return object that shares the shared state created by this \tcode{async} call shall block until the associated thread has completed, as if joined, or else time -out~(\ref{thread.thread.member}); +out\iref{thread.thread.member}; \item the associated thread completion -synchronizes with~(\ref{intro.multithread}) +synchronizes with\iref{intro.multithread} the return from the first function that successfully detects the ready status of the shared state or @@ -5038,7 +5038,7 @@ \begin{itemdescr} \pnum \requires -\tcode{\placeholdernc{INVOKE}(f, t1, t2, ..., tN)}, where \tcode{t1, t2, ..., tN} are values +\tcode{\placeholdernc{INVOKE}(f, t$_1$, t$_2$, $\dotsc$, t$_N$)}\iref{func.require}, where \tcode{t$_1$, t$_2$, $\dotsc$, t$_N$} are values of the corresponding types in \tcode{ArgTypes...}, shall be a valid expression. Invoking a copy of \tcode{f} shall behave the same as invoking \tcode{f}. @@ -5088,7 +5088,7 @@ \effects \begin{itemize} \item -Releases any shared state~(\ref{futures.state}); +Releases any shared state\iref{futures.state}; \item calls \tcode{packaged_task(std::move(rhs)).swap(*this)}. \end{itemize} @@ -5102,7 +5102,7 @@ \begin{itemdescr} \pnum \effects -Abandons any shared state~(\ref{futures.state}). +Abandons any shared state\iref{futures.state}. \end{itemdescr} \indexlibrarymember{swap}{packaged_task}% @@ -5142,7 +5142,7 @@ \returns A \tcode{future} object that shares the same shared state as \tcode{*this}. \pnum -\throws a \tcode{future_error} object if an error occurs. +\throws A \tcode{future_error} object if an error occurs. \pnum \errors @@ -5160,10 +5160,10 @@ \begin{itemdescr} \pnum -\effects As if by \tcode{\placeholdernc{INVOKE}(f, t1, t2, ..., tN)}, +\effects As if by \tcode{\placeholdernc{INVOKE}(f, t$_1$, t$_2$, $\dotsc$, t$_N$)}\iref{func.require}, where \tcode{f} is the stored task of \tcode{*this} and -\tcode{t1, t2, ..., tN} are the values in \tcode{args...}. If the task returns normally, +\tcode{t$_1$, t$_2$, $\dotsc$, t$_N$} are the values in \tcode{args...}. If the task returns normally, the return value is stored as the asynchronous result in the shared state of \tcode{*this}, otherwise the exception thrown by the task is stored. The shared state of \tcode{*this} is made ready, and any threads blocked in a @@ -5171,7 +5171,7 @@ the shared state of \tcode{*this} to become ready are unblocked. \pnum -\throws a \tcode{future_error} exception object if there is no shared +\throws A \tcode{future_error} exception object if there is no shared state or the stored task has already been invoked. \pnum @@ -5190,12 +5190,12 @@ \begin{itemdescr} \pnum -\effects As if by \tcode{\placeholdernc{INVOKE}(f, t1, t2, ..., tN)}, +\effects As if by \tcode{\placeholdernc{INVOKE}(f, t$_1$, t$_2$, $\dotsc$, t$_N$)}\iref{func.require}, where \tcode{f} is the stored task and -\tcode{t1, t2, ..., tN} are the values in \tcode{args...}. If the task returns normally, +\tcode{t$_1$, t$_2$, $\dotsc$, t$_N$} are the values in \tcode{args...}. If the task returns normally, the return value is stored as the asynchronous result in the shared state of \tcode{*this}, otherwise the exception thrown by the task is stored. In either -case, this shall be done without making that state ready~(\ref{futures.state}) immediately. Schedules +case, this shall be done without making that state ready\iref{futures.state} immediately. Schedules the shared state to be made ready when the current thread exits, after all objects of thread storage duration associated with the current thread have been destroyed. @@ -5222,7 +5222,7 @@ \effects As if \tcode{*this = packaged_task(std::move(f))}, where \tcode{f} is the task stored in \tcode{*this}. \begin{note} This constructs a new shared state for \tcode{*this}. The -old state is abandoned~(\ref{futures.state}). \end{note} +old state is abandoned\iref{futures.state}. \end{note} \pnum \throws @@ -5257,5 +5257,5 @@ \begin{itemdescr} \pnum -\requires \tcode{Alloc} shall be an Allocator~(\ref{allocator.requirements}). +\requires \tcode{Alloc} shall be an Allocator\iref{allocator.requirements}. \end{itemdescr} diff --git a/source/tmp.tex b/source/tmp.tex new file mode 100644 index 0000000000..636a32d0d6 --- /dev/null +++ b/source/tmp.tex @@ -0,0 +1,3785 @@ +%!TEX root = std.tex +\rSec0[over]{Overloading}% +\indextext{overloading|(} + +\gramSec[gram.over]{Overloading} + +\pnum +\indextext{declaration!overloaded}% +\indextext{overloaded function|see{overloading}}% +\indextext{function, overloaded|see{overloading}}% +When two or more different declarations are specified for a single name +in the same scope, that name is said to be +\grammarterm{overloaded}. +By extension, two declarations in the same scope that declare the same name +but with different types are called +\term{overloaded declarations}. +Only function and function template +declarations can be overloaded; variable and type declarations +cannot be overloaded. + +\pnum +When an overloaded function name is used in a call, which overloaded function +declaration is being referenced is determined by comparing the types +of the arguments at the point of use with the types of the parameters +in the overloaded declarations that are visible at the point of use. +This function selection process is called +\term{overload resolution} +and +is defined in~\ref{over.match}. +\begin{example} + +\indextext{overloading!example of}% +\begin{codeblock} +double abs(double); +int abs(int); + +abs(1); // calls \tcode{abs(int);} +abs(1.0); // calls \tcode{abs(double);} +\end{codeblock} +\end{example} + +\rSec1[over.load]{Overloadable declarations} +\indextext{overloading!declarations}% + +\pnum +\indextext{overloading!prohibited}% +Not all function declarations can be overloaded. +Those that cannot be +overloaded are specified here. +A program is ill-formed if it contains +two such non-overloadable declarations in the same scope. +\begin{note} +This restriction applies to explicit declarations in a scope, and between +such declarations and +declarations made through a +\grammarterm{using-declaration}~(\ref{namespace.udecl}). +It does not apply to sets of functions fabricated as a result of +name lookup (e.g., because of +\grammarterm{using-directive}{s}) +or overload resolution +(e.g., for operator functions). +\end{note} + +\pnum +Certain function declarations cannot be overloaded: + +\begin{itemize} +\item +\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}% +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} +member function declaration~(\ref{class.static}). +Likewise, member function template declarations with the same name, +the same parameter-type-list, and the same template parameter lists cannot be +overloaded if any of them is a +\tcode{static} +member function template declaration. +The types of the implicit object parameters constructed for the member +functions for the purpose of overload resolution~(\ref{over.match.funcs}) +are not considered when comparing parameter-type-lists for enforcement of +this rule. +In contrast, if there is no +\tcode{static} +member function declaration among a set of member function +declarations with the same name and the same parameter-type-list, then +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: + +\begin{codeblock} +class X { + static void f(); + void f(); // ill-formed + void f() const; // ill-formed + void f() const volatile; // ill-formed + void g(); + void g() const; // OK: no static \tcode{g} + void g() const volatile; // OK: no static \tcode{g} +}; +\end{codeblock} +\end{example} + +\item Member function declarations with the same name and the same +parameter-type-list~(\ref{dcl.fct}) as well as member function template +declarations with the same name, the same parameter-type-list, and +the same template parameter lists cannot be overloaded if any of them, but not +all, have a \grammarterm{ref-qualifier}~(\ref{dcl.fct}). \begin{example} + +\begin{codeblock} +class Y { + void h() &; + void h() const &; // OK + void h() &&; // OK, all declarations have a ref-qualifier + void i() &; + void i() const; // ill-formed, prior declaration of \tcode{i} + // has a ref-qualifier +}; +\end{codeblock} +\end{example} + +\end{itemize} + +\pnum +\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 +the same function and therefore cannot +be overloaded: + +\begin{itemize} +\item +\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) { @\commentellip@ } +void f(Int i) { @\commentellip@ } // error: redefinition of \tcode{f(int)} +\end{codeblock} +\end{example} + +\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) { @\commentellip@ } +void f(E i) { @\commentellip@ } +\end{codeblock} +\end{example} + +\item +\indextext{overloading!array versus pointer}% +\indextext{array!overloading and pointer versus}% +Parameter declarations that differ only in a pointer +\tcode{*} +versus an array +\tcode{[]} +are equivalent. +That is, the array declaration is adjusted to become a pointer +declaration~(\ref{dcl.fct}). +Only the second and subsequent array dimensions are significant in +parameter types~(\ref{dcl.array}). +\begin{example} + +\begin{codeblock} +int f(char*); +int f(char[]); // same as \tcode{f(char*);} +int f(char[7]); // same as \tcode{f(char*);} +int f(char[9]); // same as \tcode{f(char*);} + +int g(char(*)[10]); +int g(char[5][10]); // same as \tcode{g(char(*)[10]);} +int g(char[7][10]); // same as \tcode{g(char(*)[10]);} +int g(char(*)[20]); // different from \tcode{g(char(*)[10]);} +\end{codeblock} +\end{example} + +\item +\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}). +\begin{example} + +\begin{codeblock} +void h(int()); +void h(int (*)()); // redeclaration of \tcode{h(int())} +void h(int x()) { } // definition of \tcode{h(int())} +void h(int (*x)()) { } // ill-formed: redefinition of \tcode{h(int())} +\end{codeblock} +\end{example} + +\item +\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 +\tcode{volatile} +are equivalent. +That is, the +\tcode{const} +and +\tcode{volatile} +type-specifiers for +each parameter type are ignored when determining which function is being +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) { @\commentellip@ } // definition of \tcode{f(int)} +int f (cInt) { @\commentellip@ } // error: redefinition of \tcode{f(int)} +\end{codeblock} +\end{example} + +Only the +\tcode{const} +and +\tcode{volatile} +type-specifiers at the outermost level of the +parameter type specification are ignored in this fashion; +\tcode{const} +and +\tcode{volatile} +type-specifiers buried within a parameter type specification are significant +and can be used to distinguish overloaded function +declarations.\footnote{When a parameter type includes a function type, +such as in the case of a parameter type that is a pointer to function, the +\tcode{const} +and +\tcode{volatile} +type-specifiers at the outermost level of the parameter type +specifications for the inner function type are also ignored.} +In particular, for any type +\tcode{T}, +``pointer to +\tcode{T}'', +``pointer to +\tcode{const} +\tcode{T}'', +and +``pointer to +\tcode{volatile} +\tcode{T}'' +are considered distinct parameter types, as are +``reference to +\tcode{T}'', +``reference to +\tcode{const} +\tcode{T}'', +and +``reference to +\tcode{volatile} +\tcode{T}''. +\item +\indextext{default initializers!overloading and}% +Two parameter declarations that differ only in their default arguments +are equivalent. +\begin{example} +Consider the following: + +\begin{codeblock} +void f (int i, int j); +void f (int i, int j = 99); // OK: redeclaration of \tcode{f(int, int)} +void f (int i = 88, int j); // OK: redeclaration of \tcode{f(int, int)} +void f (); // OK: overloaded declaration of \tcode{f} + +void prog () { + f (1, 2); // OK: call \tcode{f(int, int)} + f (1); // OK: call \tcode{f(int, int)} + f (); // Error: \tcode{f(int, int)} or \tcode{f()}? +} +\end{codeblock} +\end{example} +\end{itemize} +\end{note} + +\rSec1[over.dcl]{Declaration matching}% +\indextext{overloading!declaration matching}% +\indextext{scope!overloading and}% +\indextext{base class!overloading and} + +\pnum +Two function declarations of the same name refer to the same function if they +are in the same scope and have equivalent parameter declarations~(\ref{over.load}). +A function member of a derived class is +\textit{not} +in the same scope as a function member of the same name in a base class. +\begin{example} + +\begin{codeblock} +struct B { + int f(int); +}; + +struct D : B { + int f(const char*); +}; +\end{codeblock} + +\indextext{name hiding!function}% +\indextext{name hiding!overloading versus}% +Here +\tcode{D::f(const char*)} +hides +\tcode{B::f(int)} +rather than overloading it. + +\indextext{Ben}% +\begin{codeblock} +void h(D* pd) { + pd->f(1); // error: + // \tcode{D::f(const char*)} hides \tcode{B::f(int)} + pd->B::f(1); // OK + pd->f("Ben"); // OK, calls \tcode{D::f} +} +\end{codeblock} +\end{example} + +\pnum +A locally declared function is not in the same scope as a function in +a containing scope. +\begin{example} + +\begin{codeblock} +void f(const char*); +void g() { + extern void f(int); + f("asdf"); // error: \tcode{f(int)} hides \tcode{f(const char*)} + // so there is no \tcode{f(const char*)} in this scope +} + +void caller () { + extern void callee(int, int); + { + extern void callee(int); // hides \tcode{callee(int, int)} + callee(88, 99); // error: only \tcode{callee(int)} in scope + } +} +\end{codeblock} +\end{example} + +\pnum +\indextext{access control!overloading and}% +\indextext{overloading!access control and}% +Different versions of an overloaded member function can be given different +access rules. +\begin{example} + +\begin{codeblock} +class buffer { +private: + char* p; + int size; +protected: + buffer(int s, char* store) { size = s; p = store; } +public: + buffer(int s) { p = new char[size = s]; } +}; +\end{codeblock} +\end{example} + +\rSec1[over.match]{Overload resolution}% +\indextext{overloading!resolution|(}% +\indextext{resolution|see{overloading, resolution}}% +\indextext{ambiguity!overloaded function} + +\pnum +Overload resolution is a mechanism for selecting the best +function to call given a list of expressions that are to be the +arguments of the call and a set of +\term{candidate functions} +that can +be called based on the context of the call. +The selection +criteria for the best function are the number of arguments, how +well the arguments match the parameter-type-list of the +candidate function, +how well (for non-static member functions) the object +matches the implicit object parameter, +and certain other properties of the candidate function. +\begin{note} +The function selected by overload resolution is not +guaranteed to be appropriate for the context. +Other restrictions, +such as the accessibility of the function, can make its use in +the calling context ill-formed. +\end{note} + +\pnum +\indextext{overloading!resolution!contexts}% +Overload resolution selects the function to call in seven distinct +contexts within the language: + +\begin{itemize} +\item +invocation of a function named in the function call syntax~(\ref{over.call.func}); +\item +invocation of a function call operator, a pointer-to-function +conversion function, a reference-to-pointer-to-function conversion +function, or a reference-to-function +conversion function on a class object named in the function +call syntax~(\ref{over.call.object}); +\item +invocation of the operator referenced in an expression~(\ref{over.match.oper}); +\item +invocation of a constructor for default- or direct-initialization~(\ref{dcl.init}) +of a class object~(\ref{over.match.ctor}); +\item +invocation of a user-defined conversion for +copy-initialization~(\ref{dcl.init}) of a class object~(\ref{over.match.copy}); +\item +invocation of a conversion function for initialization of an object of a +non-class type from an expression of class type~(\ref{over.match.conv}); and +\item +invocation of a conversion function for conversion to a glvalue +or class prvalue +to which a reference~(\ref{dcl.init.ref}) +will be directly bound~(\ref{over.match.ref}). +\end{itemize} + +Each of these contexts defines the set of candidate functions and +the list of arguments in its own unique way. +But, once the +candidate functions and argument lists have been identified, the +selection of the best function is the same in all cases: + +\begin{itemize} +\item +First, a subset of the candidate functions (those that have +the proper number of arguments and meet certain other +conditions) is selected to form a set of +\indextext{function!viable}% +viable functions~(\ref{over.match.viable}). +\item +Then the best viable function is selected based on the +implicit conversion sequences~(\ref{over.best.ics}) needed to +match each argument to the corresponding parameter of each +viable function. +\end{itemize} + +\pnum +If a best viable function exists and is unique, overload +resolution succeeds and produces it as the result. +Otherwise +overload resolution fails and the invocation is ill-formed. +When overload resolution succeeds, +and the best viable function is not accessible (Clause~\ref{class.access}) in the context +in which it is used, +the program is ill-formed. + +\rSec2[over.match.funcs]{Candidate functions and argument lists}% +\indextext{overloading!candidate functions|(}% +\indextext{overloading!argument lists|(} + +\pnum +The subclauses of~\ref{over.match.funcs} describe +the set of candidate functions and the argument list submitted to +overload resolution in each of the seven contexts in which +overload resolution is used. +The source transformations and constructions defined +in these subclauses are only for the purpose of describing the +overload resolution process. +An implementation is not required +to use such transformations and constructions. + +\pnum +\indextext{member function!overload resolution and}% +\indextext{function!overload resolution and}% +The set of candidate functions can contain both member and non-member +functions to be resolved against the same argument list. +So that argument and parameter lists are comparable within this +heterogeneous set, a member function is considered to have an +extra parameter, called the +\defn{implicit object parameter}, +which represents the object for which the member function has been +called. +For the purposes of overload resolution, both static and +non-static member functions have an implicit object parameter, +but constructors do not. + +\pnum +Similarly, when appropriate, the context can construct an +argument list that contains an +\defn{implied object argument} +to denote +the object to be operated on. +Since arguments and parameters are +associated by position within their respective lists, the +convention is that the implicit object parameter, if present, is +always the first parameter and the implied object argument, if +present, is always the first argument. + +\pnum +For non-static member functions, the type of the implicit object +parameter is + +\begin{itemize} +\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 +\tcode{\&\&} \grammarterm{ref-qualifier} +\end{itemize} + +where +\tcode{X} +is the class of which the function is a member and +\cv{} +is the cv-qualification on the +member function declaration. +\begin{example} +For a +\tcode{const} +member +function of class +\tcode{X}, +the extra parameter is assumed to have type +``reference to +\tcode{const X}''. +\end{example} +For conversion functions, the function is considered to be a member of the +class of the implied object argument for the purpose of defining the +type of the implicit object parameter. +For non-conversion functions +introduced by a +\grammarterm{using-declaration} +into a derived class, the function is +considered to be a member of the derived class for the purpose of defining +the type of the implicit object parameter. +For static member functions, the implicit object parameter is considered +to match any object (since if the function is selected, the object is +discarded). +\begin{note} +No actual type is established for the implicit object parameter +of a static member function, and no attempt will be made to determine a +conversion sequence for that parameter~(\ref{over.match.best}). +\end{note} + +\pnum +\indextext{implied object argument!implicit conversion sequences}% +During overload resolution, the implied object argument is +indistinguishable from other arguments. +The implicit object +parameter, however, retains its identity since +no user-defined conversions can be applied to achieve a type +match with it. +\indextext{implied object argument!non-static member function and}% +For non-static member functions declared without a \grammarterm{ref-qualifier}, +an additional rule applies: + +\begin{itemize} +\item +even if the implicit object parameter is not +const-qualified, +an rvalue can be bound to the parameter +as long as in all other respects the argument can be +converted to the type of the implicit object parameter. +\begin{note} The fact that such an argument is an rvalue does not +affect the ranking of implicit conversion sequences~(\ref{over.ics.rank}). +\end{note} +\end{itemize} + +\pnum +Because other than in list-initialization only one user-defined conversion +is allowed +in an +implicit conversion sequence, special rules apply when selecting +the best user-defined conversion~(\ref{over.match.best}, +\ref{over.best.ics}). +\begin{example} + +\begin{codeblock} +class T { +public: + T(); +}; + +class C : T { +public: + C(int); +}; +T a = 1; // ill-formed: \tcode{T(C(1))} not tried +\end{codeblock} +\end{example} + +\pnum +In each case where a candidate is a function template, candidate +function template specializations +are generated using template argument deduction~(\ref{temp.over}, +\ref{temp.deduct}). +Those candidates are then handled as candidate +functions in the usual way.\footnote{The process of argument deduction fully +determines the parameter types of +the +function template specializations, +i.e., the parameters of +function template specializations +contain +no template parameter types. +Therefore, except where specified otherwise, +function template specializations +and non-template functions~(\ref{dcl.fct}) are treated equivalently +for the remainder of overload resolution.} +A given name can refer to one or more function templates and also +to a set of overloaded non-template functions. +In such a case, the +candidate functions generated from each function template are combined +with the set of non-template candidate functions. + +\pnum +A defaulted move constructor or assignment operator~(\ref{class.copy}) that is +defined as deleted is excluded from the set of candidate functions in all +contexts. + +\rSec3[over.match.call]{Function call syntax}% +\indextext{overloading!resolution!function call syntax|(} + +\pnum +In a function call~(\ref{expr.call}) + +\begin{ncsimplebnf} +postfix-expression \terminal{(} expression-list\opt{} \terminal{)} +\end{ncsimplebnf} + +if the \grammarterm{postfix-expression} denotes a set of overloaded functions and/or +function templates, overload resolution is applied as specified in \ref{over.call.func}. +If the \grammarterm{postfix-expression} denotes an object of class type, overload +resolution is applied as specified in \ref{over.call.object}. + +\pnum +If the \grammarterm{postfix-expression} denotes the address of a set of overloaded +functions and/or function templates, overload resolution is applied using that set as +described above. If the function selected by overload resolution is a non-static member +function, the program is ill-formed. \begin{note} The resolution of the address of an +overload set in other contexts is described in \ref{over.over}. \end{note} + +\rSec4[over.call.func]{Call to named function} + +\pnum +Of interest in~\ref{over.call.func} are only those function calls in +which the +\grammarterm{postfix-expression} +ultimately contains a name that +denotes one or more functions that might be called. +Such a +\grammarterm{postfix-expression}, +perhaps nested arbitrarily deep in +parentheses, has one of the following forms: + +\begin{ncbnf} +postfix-expression:\br + postfix-expression \terminal{.} id-expression\br + postfix-expression \terminal{->} id-expression\br + primary-expression +\end{ncbnf} + +These represent two syntactic subcategories of function calls: +qualified function calls and unqualified function calls. + +\pnum +In qualified function calls, the name to be resolved is an +\grammarterm{id-expression} +and is preceded by an +\tcode{->} +or +\tcode{.} +operator. +Since the +construct +\tcode{A->B} +is generally equivalent to +\tcode{(*A).B}, +the rest of +Clause~\ref{over} assumes, without loss of generality, that all member +function calls have been normalized to the form that uses an +object and the +\tcode{.} +operator. +Furthermore, Clause~\ref{over} assumes that +the +\grammarterm{postfix-expression} +that is the left operand of the +\tcode{.} +operator +has type ``\cv{}~\tcode{T}'' +where +\tcode{T} +denotes a class\footnote{Note that cv-qualifiers on the type of objects are +significant in overload +resolution for +both glvalue and class prvalue objects.}. +Under this +assumption, the +\grammarterm{id-expression} +in the call is looked up as a +member function of +\tcode{T} +following the rules for looking up names in +classes~(\ref{class.member.lookup}). +The function declarations found by that lookup constitute the set of +candidate functions. +The argument list is the +\grammarterm{expression-list} +in the call augmented by the addition of the left operand of +the +\tcode{.} +operator in the normalized member function call as the +implied object argument~(\ref{over.match.funcs}). + +\pnum +In unqualified function calls, the name is not qualified by an +\tcode{->} +or +\tcode{.} +operator and has the more general form of a +\grammarterm{primary-expression}. +The name is looked up in the context of the function +call following the normal rules for name lookup in function +calls~(\ref{basic.lookup}). +The function declarations found by that lookup constitute the +set of candidate functions. +Because of the rules for name lookup, the set of candidate functions +consists (1) entirely of non-member functions or (2) entirely of +member functions of some class +\tcode{T}. +In case (1), +the argument list is +the same as the +\grammarterm{expression-list} +in the call. +In case (2), the argument list is the +\grammarterm{expression-list} +in the call augmented by the addition of an implied object +argument as in a qualified function call. +If the keyword +\tcode{this}~(\ref{class.this}) is in scope and refers to +class +\tcode{T}, +or a derived class of +\tcode{T}, +then the implied object argument is +\tcode{(*this)}. +If the keyword +\tcode{this} +is not in +scope or refers to another class, then +a contrived object of type +\tcode{T} +becomes the implied object +argument\footnote{An implied object argument must be contrived to +correspond to the implicit object +parameter attributed to member functions during overload resolution. +It is not +used in +the call to the selected function. +Since the member functions all have the +same implicit +object parameter, the contrived object will not be the cause to select or +reject a +function.}. +If the argument list is augmented by a contrived object and overload +resolution selects one of the non-static member functions of +\tcode{T}, +the call is ill-formed. + +\rSec4[over.call.object]{Call to object of class type} + +\pnum +If the +\grammarterm{primary-expression} +\tcode{E} +in the function call syntax evaluates +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}. +The +function call operators of +\tcode{T} +are obtained by ordinary lookup of +the name +\tcode{operator()} +in the context of +\tcode{(E).operator()}. + +\pnum +In addition, for each non-explicit conversion function declared in \tcode{T} of the +form + +\begin{ncsimplebnf} +\terminal{operator} conversion-type-id \terminal{(\,)} cv-qualifier ref-qualifier\opt noexcept-specifier\opt attribute-specifier-seq\opt{} \terminal{;} +\end{ncsimplebnf} + +where +\grammarterm{cv-qualifier} +is the same cv-qualification as, or a greater cv-qualification than, +\cv{}, +and where +\grammarterm{conversion-type-id} +denotes the type ``pointer to function +of ($\tcode{P}_1, \dotsc, \tcode{P}_n$) returning \tcode{R}'', +or the type ``reference to pointer to function +of ($\tcode{P}_1, \dotsc, \tcode{P}_n$) returning \tcode{R}'', +or the type +``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, 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. +Similarly, surrogate +call functions are added to the set of candidate functions for +each non-explicit conversion function declared in a base class of +\tcode{T} +provided the function is not hidden within +\tcode{T} +by another +intervening declaration\footnote{Note that this construction can yield +candidate call functions that cannot be +differentiated one from the other by overload resolution because they have +identical +declarations or differ only in their return type. +The call will be ambiguous +if overload +resolution cannot select a match to the call that is uniquely better than such +undifferentiable functions.}. + +\pnum +If such a surrogate call function is selected by overload +resolution, the corresponding conversion function will be called to convert +\tcode{E} +to the appropriate function pointer or reference, and the function +will then be invoked with the arguments of the call. If the +conversion function cannot be called (e.g., because of an ambiguity), +the program is ill-formed. + +\pnum +The argument list submitted to overload resolution consists of +the argument expressions present in the function call syntax +preceded by the implied object argument +\tcode{(E)}. +\begin{note} +When comparing the +call against the function call operators, the implied object +argument is compared against the implicit object parameter of the +function call operator. +When comparing the call against a +surrogate call function, the implied object argument is compared +against the first parameter of the surrogate call function. +The +conversion function from which the surrogate call function was +derived will be used in the conversion sequence for that +parameter since it converts the implied object argument to the +appropriate function pointer or reference required by that first +parameter. +\end{note} +\begin{example} + +\begin{codeblock} +int f1(int); +int f2(float); +typedef int (*fp1)(int); +typedef int (*fp2)(float); +struct A { + operator fp1() { return f1; } + operator fp2() { return f2; } +} a; +int i = a(1); // calls \tcode{f1} via pointer returned from conversion function +\end{codeblock} +\end{example}% +\indextext{overloading!resolution!function call syntax|)} + +\rSec3[over.match.oper]{Operators in expressions}% +\indextext{overloading!resolution!operators} + +\pnum +If no operand of an operator in an expression has a type that is a class +or an enumeration, the operator is assumed to be a built-in operator +and interpreted according to Clause~\ref{expr}. +\begin{note} +Because +\tcode{.}, +\tcode{.*}, +and +\tcode{::} +cannot be overloaded, +these operators are always built-in operators interpreted according to +Clause~\ref{expr}. +\tcode{?:} +cannot be overloaded, but the rules in this subclause are used to determine +the conversions to be applied to the second and third operands when they +have class or enumeration type~(\ref{expr.cond}). +\end{note} +\begin{example} + +\begin{codeblock} +struct String { + String (const String&); + String (const char*); + operator const char* (); +}; +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. +} +\end{codeblock} +\end{example} + +\pnum +If either operand has a type that is a class or an enumeration, a +user-defined operator function might be declared that implements +this operator or a user-defined conversion can be necessary to +convert the operand to a type that is appropriate for a built-in +operator. +In this case, overload resolution is used to determine +which operator function or built-in operator is to be invoked to implement the +operator. +Therefore, the operator notation is first transformed +to the equivalent function-call notation as summarized in +Table~\ref{tab:over.rel.op.func} +(where \tcode{@} denotes one of the operators covered in the specified subclause). +However, the operands are sequenced in the order prescribed +for the built-in operator (Clause~\ref{expr}). + +\begin{floattable}{Relationship between operator and function call notation}{tab:over.rel.op.func} +{l|m|m|m} +\topline +\hdstyle{Subclause} & \hdstyle{Expression} & \hdstyle{As member function} & \hdstyle{As non-member function} \\ \capsep +\ref{over.unary} & \tcode{@a} & \tcode{(a).operator@ (\,)} & \tcode{operator@(a)} \\ +\ref{over.binary} & \tcode{a@b} & \tcode{(a).operator@ (b)} & \tcode{operator@(a, b)} \\ +\ref{over.ass} & \tcode{a=b} & \tcode{(a).operator= (b)} & \\ +\ref{over.sub} & \tcode{a[b]} & \tcode{(a).operator[](b)} & \\ +\ref{over.ref} & \tcode{a->} & \tcode{(a).operator->(\,)} & \\ +\ref{over.inc} & \tcode{a@} & \tcode{(a).operator@ (0)} & \tcode{operator@(a, 0)} \\ +\end{floattable} + +\pnum +For a unary operator +\tcode{@} +with an operand of a type whose cv-unqualified version is +\tcode{T1}, +and for a binary operator +\tcode{@} +with a left operand of a type whose cv-unqualified version is +\tcode{T1} +and a right operand of a type whose cv-unqualified version is +\tcode{T2}, +three sets of candidate functions, designated +\term{member candidates}, +\term{non-member candidates} +and +\term{built-in candidates}, +are constructed as follows: +\begin{itemize} +\item +If +\tcode{T1} +is a complete class type or a class currently being defined, the set of member candidates is the +result of the qualified lookup of +\tcode{T1::operator@}~(\ref{over.call.func}); otherwise, the set of member +candidates is empty. +\item +The set of non-member candidates is the result of the unqualified lookup of +\tcode{operator@} +in the context of +the expression according to the usual rules for name +lookup in unqualified function calls~(\ref{basic.lookup.argdep}) except +that all member functions are ignored. +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 \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 \cv{}~\tcode{T2}'', +when +\tcode{T2} +is an enumeration type, +are candidate functions. +\item +For the operator +\tcode{,}, +the unary operator +\tcode{\&}, +or the operator +\tcode{->}, +the built-in candidates set is empty. +For all other operators, the built-in candidates include all +of the candidate operator functions defined in~\ref{over.built} that, +compared to the given operator, + +\begin{itemize} +\item +have the same operator name, and +\item +accept the same number of operands, and +\item +accept operand types to which the given operand or +operands can be converted according to \ref{over.best.ics}, and +\item +do not have the same parameter-type-list as any non-member candidate +that is not a function template specialization. +\end{itemize} +\end{itemize} + +\pnum +For the built-in assignment operators, conversions of the left +operand are restricted as follows: + +\begin{itemize} +\item +no temporaries are introduced to hold the left operand, and +\item +no user-defined conversions are applied to the left operand to achieve +a type match with the left-most parameter of a built-in candidate. +\end{itemize} + +\pnum +For all other operators, no such restrictions apply. + +\pnum +The set of candidate functions for overload resolution is the +union of the member candidates, the non-member candidates, and +the built-in candidates. +The argument list contains all of the +operands of the operator. +The best function from the set of candidate functions is selected +according to~\ref{over.match.viable} +and~\ref{over.match.best}.\footnote{If the set of candidate functions is empty, +overload resolution is unsuccessful.} +\begin{example} + +\begin{codeblock} +struct A { + operator int(); +}; +A operator+(const A&, const A&); +void m() { + A a, b; + a + b; // \tcode{operator+(a, b)} chosen over \tcode{int(a) + int(b)} +} +\end{codeblock} +\end{example} + +% USA _136/_28 L6899 USA core-756/734/682 over.match.oper +\pnum +If a built-in candidate is selected by overload resolution, the +operands of class type are converted to the types of the corresponding parameters +of the selected operation function, except that the second standard conversion +sequence of a user-defined conversion sequence~(\ref{over.ics.user}) is not applied. +Then the operator is treated as the corresponding +built-in operator and interpreted according to Clause~\ref{expr}. +\begin{example} +\begin{codeblock} +struct X { + operator double(); +}; + +struct Y { + operator int*(); +}; + +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} + +\pnum +The second operand of operator +\tcode{->} +is ignored in selecting an +\tcode{operator->} +function, and is not an argument when the +\tcode{operator->} +function is called. +When +\tcode{operator->} +returns, the operator +\tcode{->} +is applied to the value returned, with the original second +operand.\footnote{If the value returned by the +\tcode{operator->} +function has class type, this may result in selecting and calling another +\tcode{operator->} +function. +The process repeats until an +\tcode{operator->} +function returns a value of non-class type.} + +\pnum +If the operator is the operator +\tcode{,}, +the unary operator +\tcode{\&}, +or the operator +\tcode{->}, +and there are no viable functions, then the operator is +assumed to be the built-in operator and interpreted according to +Clause~\ref{expr}. + +\pnum +\begin{note} +The lookup rules for operators in expressions are different than +the lookup +rules for operator function names in a function call, as shown in the following +example: + +\begin{codeblock} +struct A { }; +void operator + (A, A); + +struct B { + void operator + (B); + void f (); +}; + +A a; + +void B::f() { + operator+ (a,a); // error: global operator hidden by member + a + a; // OK: calls global \tcode{operator+} +} +\end{codeblock} +\end{note} + +\rSec3[over.match.ctor]{Initialization by constructor}% +\indextext{overloading!resolution!initialization} + +\pnum +When objects of class type are direct-initialized~(\ref{dcl.init}), +copy-initialized from an expression of the same or a +derived class type~(\ref{dcl.init}), +or default-initialized~(\ref{dcl.init}), +overload resolution selects the constructor. +For direct-initialization or default-initialization +that is not in the context of copy-initialization, the +candidate functions are +all the constructors of the class of the object being +initialized. +For copy-initialization, the candidate functions are all +the converting constructors~(\ref{class.conv.ctor}) of that +class. +The argument list is the +\grammarterm{expression-list} or \grammarterm{assignment-expression} +of the \grammarterm{initializer}. + +\rSec3[over.match.copy]{Copy-initialization of class by user-defined conversion}% +\indextext{overloading!resolution!initialization} + +\pnum +Under the conditions specified in~\ref{dcl.init}, as +part of a copy-initialization of an object of class type, a user-defined +conversion can be invoked to convert an initializer expression to the +type of the object being initialized. +Overload resolution is used +to select the user-defined conversion to be invoked. +\begin{note} The conversion performed for indirect binding to a reference to a possibly +cv-qualified class type is determined in terms of a corresponding non-reference +copy-initialization. \end{note} +Assuming that +``\cvqual{cv1} \tcode{T}'' is the type of the object being initialized, with +\tcode{T} +a class type, +the candidate functions are selected as follows: + +\begin{itemize} +\item +The converting constructors~(\ref{class.conv.ctor}) of +\tcode{T} +are candidate functions. +\item +When the type of the initializer expression is a class type +``\cv{}~\tcode{S}'', +the non-explicit conversion functions of +\tcode{S} +and its base classes are considered. +When initializing a temporary to be bound to the first parameter of a +constructor +where the parameter is of type +``reference to possibly \cv-qualified \tcode{T}'' +and the constructor is +called with a single argument in the context of +direct-initialization of an object of type ``\cvqual{cv2} \tcode{T}'', explicit +conversion functions are also considered. +Those that are not hidden within +\tcode{S} +and yield a type whose cv-unqualified version is the same type as +\tcode{T} +or is a derived class thereof +are candidate functions. +Conversion functions that return ``reference to +\tcode{X}'' +return +lvalues or xvalues, depending on the type of reference, of type +\tcode{X} +and are therefore considered to yield +\tcode{X} +for this +process of selecting candidate functions. +\end{itemize} + +\pnum +In both cases, the argument list has one argument, which is the initializer +expression. +\begin{note} +This argument will be compared against +the first parameter of the constructors and against the implicit +object parameter of the conversion functions. +\end{note} + +\rSec3[over.match.conv]{Initialization by conversion function}% +\indextext{overloading!resolution!initialization} + +\pnum +Under the conditions specified in~\ref{dcl.init}, as +part of an initialization of an object of non-class type, +a conversion function can be invoked to convert an initializer +expression of class type to the type of the object +being initialized. +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 +of the initializer expression, with +\tcode{S} +a class type, +the candidate functions are selected as follows: + +\begin{itemize} +\item +The conversion functions of +\tcode{S} +and its base classes are considered. +Those non-explicit conversion functions that are not hidden +within +\tcode{S} +and yield type +\tcode{T} +or a type that can be converted to type +\tcode{T} +via a standard conversion sequence~(\ref{over.ics.scs}) +are candidate functions. +For direct-initialization, those explicit conversion functions that are not +hidden within \tcode{S} and yield type \tcode{T} or a type that can be converted +to type \tcode{T} with a qualification conversion~(\ref{conv.qual}) are also +candidate functions. +Conversion functions that return a cv-qualified type +are considered to yield the cv-unqualified version of that type +for this process of selecting candidate functions. +Conversion functions that return ``reference to +\cvqual{cv2} +\tcode{X}'' +return +lvalues or xvalues, depending on the type of reference, of type +``\cvqual{cv2} +\tcode{X}'' +and are therefore considered to yield +\tcode{X} +for this +process of selecting candidate functions. +\end{itemize} + +\pnum +The argument list has one argument, which is the initializer expression. +\begin{note} +This argument will be compared against +the implicit object parameter of the conversion functions. +\end{note} + +\rSec3[over.match.ref]{Initialization by conversion function for direct reference binding}% +\indextext{overloading!resolution!initialization} + +\pnum +Under the conditions specified in~\ref{dcl.init.ref}, a reference can be bound directly +to a glvalue or class prvalue that is the result of applying a conversion +function to an initializer expression. +Overload resolution is used to select the +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 +of the initializer expression, with +\tcode{S} +a class type, +the candidate functions are selected as follows: +\begin{itemize} +\item +The conversion functions of +\tcode{S} +and its base classes are considered. +Those non-explicit conversion functions that are not hidden within +\tcode{S} +and yield type ``lvalue reference to \cvqual{cv2} \tcode{T2}'' +(when initializing an lvalue reference or an rvalue reference to function) or +``\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}'', +are candidate functions. For direct-initialization, those explicit +conversion functions that are not hidden within \tcode{S} and yield +type ``lvalue reference to \cvqual{cv2} \tcode{T2}'' or ``\cvqual{cv2} +\tcode{T2}'' or ``rvalue reference to \cvqual{cv2} \tcode{T2}'', +respectively, where \tcode{T2} is the same type as \tcode{T} or can be +converted to type \tcode{T} with a qualification +conversion~(\ref{conv.qual}), are also candidate functions. + +\end{itemize} + +\pnum +The argument list has one argument, which is the initializer expression. +\begin{note} +This argument will be compared against +the implicit object parameter of the conversion functions. +\end{note} + +\rSec3[over.match.list]{Initialization by list-initialization}% +\indextext{overloading!resolution!initialization} + +\pnum +When objects of non-aggregate class type \tcode{T} are +list-initialized such that \ref{dcl.init.list} specifies that overload resolution +is performed according to the rules in this section, overload resolution selects the +constructor in two phases: + +\begin{itemize} +\item +Initially, the candidate functions are the initializer-list constructors~(\ref{dcl.init.list}) +of the class \tcode{T} and +the argument list consists of the initializer list as a single argument. + +\item +If no viable initializer-list constructor is found, overload resolution is +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} + +If the initializer list has no elements and \tcode{T} has a default constructor, +the first phase is omitted. +In copy-list-initialization, if an \tcode{explicit} constructor is +chosen, the initialization is ill-formed. \begin{note} +This differs from other situations (\ref{over.match.ctor},~\ref{over.match.copy}), +where only converting constructors are considered for copy-initialization. +This restriction only +applies if this initialization is part of the final result of overload +resolution. \end{note} + +\rSec3[over.match.class.deduct]{Class template argument deduction}% +\indextext{deduction!class template arguments}% + +\pnum +A set of functions and function templates is formed comprising: + +\begin{itemize} +\item +For each constructor +of the primary class template +designated by the \grammarterm{template-name}, +if the template is defined, +a function template with the following properties: +\begin{itemize} +\item +The template parameters are the template parameters of the class template +followed +by the template parameters (including default template arguments) of the constructor, +if any. +\item +The types of the function parameters are those of the constructor. +\item +The return type is the class template specialization +designated by the \grammarterm{template-name} +and template arguments +corresponding to the template parameters +obtained from the class template. +\end{itemize} + +\item +If the primary class template \tcode{C} +is not defined or does not declare any constructors, +an additional function template derived as above +from a hypothetical constructor \tcode{C()}. + +\item +An additional function template derived as above +from a hypothetical constructor \tcode{C(C)}, +called the \defn{copy deduction candidate}. + +\item +For each \grammarterm{deduction-guide}, +a function or function template +with the following properties: + +\begin{itemize} +\item +The template parameters, if any, +and function parameters +are those of the \grammarterm{deduction-guide}. +\item +The return type +is the \grammarterm{simple-template-id} +of the \grammarterm{deduction-guide}. +\end{itemize} +\end{itemize} + +\pnum +Initialization and overload resolution are performed as described +in \ref{dcl.init} and \ref{over.match.ctor}, \ref{over.match.copy}, +or \ref{over.match.list} (as appropriate for the type of initialization +performed) for an object of a hypothetical class type, where +the selected functions and function templates are considered to be the +constructors of that class type for the purpose of forming an overload +set, and the initializer is provided by the context in which class +template argument deduction was performed. Each such notional constructor +is considered to be explicit if the function or function template was +generated from a constructor or \grammarterm{deduction-guide} that was +declared \tcode{explicit}. +All such notional constructors are considered to be +public members of the hypothetical class type. + +\pnum +\begin{example} +\begin{codeblock} +template struct A { + explicit A(const T&, ...) noexcept; // \#1 + A(T&&, ...); // \#2 +}; + +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 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 + +template struct B { + template using TA = T; + template B(U, TA); +}; + +B b{(int*)0, (char*)0}; // OK, deduces \tcode{B} +\end{codeblock} +\end{example}% +\indextext{overloading!argument lists|)}% +\indextext{overloading!candidate functions|)} + +\rSec2[over.match.viable]{Viable functions}% +\indextext{overloading!resolution!viable functions|(} + +\pnum +From the set of candidate functions constructed for a given +context~(\ref{over.match.funcs}), a set of viable functions is +chosen, from which the best function will be selected by +comparing argument conversion sequences for the best fit~(\ref{over.match.best}). +The selection of viable functions considers +relationships between arguments and function parameters other +than the ranking of conversion sequences. + +\pnum +\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. + +\begin{itemize} +\item +If there are +\textit{m} +arguments in the list, all candidate +functions having exactly +\textit{m} +parameters are viable. +\item +A candidate function having fewer than +\textit{m} +parameters is +viable only if it has an ellipsis in its parameter list~(\ref{dcl.fct}). +For the purposes of overload resolution, +any argument for which there is no corresponding parameter is +considered to ``match the ellipsis''~(\ref{over.ics.ellipsis}) . +\item +A candidate function having more than +\textit{m} +parameters is viable +only if the +\textit{(m+1)}-st +parameter has a default +argument~(\ref{dcl.fct.default}).\footnote{According to~\ref{dcl.fct.default}, +parameters following the +\textit{(m+1)}-st +parameter must also have default arguments.} +For the purposes of overload +resolution, the parameter list is truncated on the right, so +that there are exactly +\textit{m} +parameters. +\end{itemize} + +\pnum +Second, for +\tcode{F} +to be a viable function, there shall exist for each +argument an +\term{implicit conversion sequence}~(\ref{over.best.ics}) that +converts that argument to the corresponding parameter of +\tcode{F}. +If the parameter has reference type, the implicit conversion sequence +includes the operation of binding the reference, and the fact that +an lvalue reference to non-\tcode{const} cannot be bound to an rvalue +and that an rvalue reference cannot be bound to an lvalue +can affect +the viability of the function (see~\ref{over.ics.ref}). + +\rSec2[over.match.best]{Best viable function}% +\indextext{overloading!resolution!best viable function|(} + +\pnum +\indextext{conversion!overload resolution and}% +Define ICS\textit{i}(\tcode{F}) as follows: +\begin{itemize} +\item +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 +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.} +otherwise, +\item +let ICS\textit{i}(\tcode{F}) denote the implicit conversion sequence that converts +the \textit{i}-th argument in the list to the type of the +\textit{i}-th +parameter +of viable function +\tcode{F}. +\ref{over.best.ics} defines the implicit conversion sequences and \ref{over.ics.rank} +defines what it means for one implicit conversion sequence to be +a better conversion sequence or worse conversion sequence than +another. +\end{itemize} + +Given these definitions, a viable function +\tcode{F1} +is defined +to be a +\term{better} +function than another viable function +\tcode{F2} +if +for all arguments +\textit{i}, +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}, +ICS\textit{j}(\tcode{F1}) is a better conversion +sequence than ICS\textit{j}(\tcode{F2}), or, if not that, + +\item +the context is an initialization by user-defined conversion +(see~\ref{dcl.init}, +\ref{over.match.conv}, and~\ref{over.match.ref}) +and the standard conversion sequence from the return type of +\tcode{F1} +to the destination type (i.e., the type of the entity being initialized) +is a better conversion sequence than the standard conversion sequence +from the return type of +\tcode{F2} +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 +\end{codeblock} +\end{example} +or, if not that, + +\item the context is an initialization by conversion function for direct +reference binding (\ref{over.match.ref}) of a reference to function type, the +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 +}; +typedef int Fn(); +A a; +Fn& lf = a; // calls \#1 +Fn&& rf = a; // calls \#2 +\end{codeblock} +\end{example} +or, if not that, + +\item +\tcode{F1} +is not a function template specialization and +\tcode{F2} +is a +function template +specialization, or, if not that, + +\item +\tcode{F1} +and +\tcode{F2} +are +function template specializations, +and the function template +for +\tcode{F1} +is more specialized than the template for +\tcode{F2} +according to the partial ordering rules described in~\ref{temp.func.order}, +or, if not that, + +\item +\tcode{F1} is generated from a +\grammarterm{deduction-guide}~(\ref{over.match.class.deduct}) +and \tcode{F2} is not, or, if not that, +\begin{example} +\begin{codeblock} +template struct A { + 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 +\end{codeblock} +\end{example} +\end{itemize} + +\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 +for selecting the best viable function is linear in the number +of viable +functions. +Run a simple tournament to find a function +\tcode{W} +that is not +worse than any +opponent it faced. +Although another function +\tcode{F} +that +\tcode{W} +did not face +might be at least as good as +\tcode{W}, +\tcode{F} +cannot be the best function because at some point in the +tournament +\tcode{F} +encountered another function +\tcode{G} +such that +\tcode{F} +was not better than +\tcode{G}. +Hence, +\tcode{W} +is either +the best function or there is no best function. +So, make a second pass over +the viable +functions to verify that +\tcode{W} +is better than all other functions.} +\begin{example} +\begin{codeblock} +void Fcn(const int*, short); +void Fcn(int*, int); + +int i; +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, 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} +} +\end{codeblock} +\end{example} + +\pnum +If the best viable function resolves to a function for +which multiple declarations were found, and if at least +two of these declarations --- or the declarations they +refer to in the case of +\grammarterm{using-declaration}{s} +--- 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); +} +namespace B { + extern "C" void f(int = 5); +} + +using A::f; +using B::f; + +void use() { + f(3); // OK, default argument was not used for viability + f(); // Error: found default argument twice +} +\end{codeblock} +\end{example} + +\rSec3[over.best.ics]{Implicit conversion sequences}% +\indextext{overloading!resolution!implicit conversions and|(} + +\pnum +An +\term{implicit conversion sequence} +\indextext{sequence!implicit conversion}% +is a sequence of conversions used +to convert an argument in a function call to the type of the +corresponding parameter of the function being called. +The +sequence of conversions is an implicit conversion as defined in +Clause~\ref{conv}, which means it is governed by the rules for +initialization of an object or reference by a single +expression~(\ref{dcl.init}, \ref{dcl.init.ref}). + +\pnum +Implicit conversion sequences are concerned only with the type, +cv-qualification, and value category of the argument and how these +are converted to match the corresponding properties of the +parameter. +Other properties, such as the lifetime, storage class, +alignment, accessibility of the argument, whether the argument is a bit-field, +and whether a function is deleted~(\ref{dcl.fct.def.delete}), are ignored. +So, although an implicit +conversion sequence can be defined for a given argument-parameter +pair, the conversion from the argument to the parameter might still +be ill-formed in the final analysis. + +\pnum +A +well-formed implicit conversion +sequence is one of the following forms: + +\begin{itemize} +\item +a +\term{standard conversion sequence}~(\ref{over.ics.scs}), +\item +a +\grammarterm{user-defined conversion sequence}~(\ref{over.ics.user}), or +\item +an +\term{ellipsis conversion sequence}~(\ref{over.ics.ellipsis}). +\end{itemize} + +\pnum +However, if the target is +\begin{itemize} +\item the first parameter of a constructor or +\item the implicit object parameter of a user-defined conversion function +\end{itemize} +and the constructor or user-defined conversion function is a candidate by +\begin{itemize} +\item \ref{over.match.ctor}, when the argument is the temporary in the second +step of a class copy-initialization, +\item \ref{over.match.copy}, \ref{over.match.conv}, or \ref{over.match.ref} +(in all cases), or +\item the second phase of \ref{over.match.list} +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 \cv{}~\tcode{X}, +\end{itemize} +user-defined conversion sequences are not considered. +\begin{note} +These rules prevent more than one user-defined conversion from being +applied during overload resolution, thereby avoiding infinite recursion. +\end{note} +\begin{example} +\begin{codeblock} + struct Y { Y(int); }; + struct A { operator int(); }; + 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 +\end{codeblock} +\end{example} + +\pnum +For the case where the parameter type is a reference, see~\ref{over.ics.ref}. + +\pnum +When the parameter type is not a reference, the implicit conversion +sequence models a copy-initialization of the parameter from the argument +expression. +The implicit conversion sequence is the one required to convert the +argument expression to a prvalue of the type of +the parameter. +\begin{note} +When the parameter has a class type, this is a conceptual conversion +defined for the purposes of Clause~\ref{over}; the actual initialization is +defined in terms of constructors and is not a conversion. +\end{note} +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 +\tcode{A} +can be initialized from an argument of type +\tcode{const A}. +The implicit conversion sequence for that case is the identity sequence; it +contains no ``conversion'' from +\tcode{const A} +to +\tcode{A}. +\end{example} +When the parameter has a class type and the argument expression has the +same type, the implicit conversion sequence is an identity conversion. +When the parameter has a class type and the argument expression has a +derived class type, the implicit conversion sequence is a +derived-to-base +\indextext{conversion!derived-to-base}% +Conversion from the derived class to the base class. +\begin{note} +There is no such standard conversion; this derived-to-base Conversion exists +only in the description of implicit conversion sequences. +\end{note} +A derived-to-base Conversion has Conversion rank~(\ref{over.ics.scs}). + +\pnum +In all contexts, when converting to the implicit object parameter +or when converting to the left operand of an assignment operation +only standard conversion sequences are allowed. + +\pnum +If no conversions are required to match an argument to a +parameter type, the implicit conversion sequence is the standard +conversion sequence consisting of the identity conversion~(\ref{over.ics.scs}). + +\pnum +If no sequence of conversions can be found to convert an argument +to a parameter type, an implicit conversion sequence cannot be formed. + +\pnum +If several different sequences of conversions exist that each +convert the argument to the parameter type, the implicit +conversion sequence associated with the parameter is defined to be +the unique conversion sequence designated the +\term{ambiguous conversion sequence}. +\indextext{sequence!ambiguous conversion}% +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. +\begin{note} +This rule prevents a function from becoming non-viable because of an ambiguous +conversion sequence for one of its parameters. +\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. + +\pnum +The three forms of implicit conversion sequences mentioned above +are defined in the following subclauses. + +\rSec4[over.ics.scs]{Standard conversion sequences} + +\pnum +Table~\ref{tab:over.conversions} +summarizes the conversions defined in Clause~\ref{conv} and +partitions them into four disjoint categories: Lvalue Transformation, +Qualification Adjustment, Promotion, and Conversion. +\begin{note} +These categories are orthogonal with respect to value category, +cv-qualification, and data representation: the Lvalue Transformations +do not change the cv-qualification or data +representation of the type; the Qualification Adjustments do not +change the value category or data representation of the type; and +the Promotions and Conversions do not change the +value category or cv-qualification of the type. +\end{note} + +\pnum +\begin{note} +As described in Clause~\ref{conv}, +a standard conversion sequence is either the Identity conversion +by itself (that is, no conversion) or consists of one to three +conversions from the other +four categories. +If there are two or more conversions in the sequence, the +conversions are applied in the canonical order: +\textbf{Lvalue Transformation}, +\textbf{Promotion} +or +\textbf{Conversion}, +\textbf{Qualification Adjustment}. +\end{note} + +\pnum +\indextext{conversion rank}% +Each conversion in Table~\ref{tab:over.conversions} +also has an associated rank (Exact +Match, Promotion, or Conversion). +These are used +to rank standard conversion sequences~(\ref{over.ics.rank}). +The rank of a conversion sequence is determined by considering the +rank of each conversion in the sequence and the rank of any reference +binding~(\ref{over.ics.ref}). +If any of those has Conversion rank, the +sequence has Conversion rank; otherwise, if any of those has Promotion rank, +the sequence has Promotion rank; otherwise, the sequence has Exact +Match rank. + +\begin{floattable}{Conversions}{tab:over.conversions}{l|c|c|c} +\topline +\hdstyle{Conversion} & \hdstyle{Category} & \hdstyle{Rank} & \hdstyle{Subclause} \\ \capsep +No conversions required & Identity & & \\ \cline{1-2}\cline{4-4} +Lvalue-to-rvalue conversion & & & \ref{conv.lval} \\ \cline{1-1}\cline{4-4} +Array-to-pointer conversion & Lvalue Transformation & & \ref{conv.array} \\ \cline{1-1}\cline{4-4} +Function-to-pointer conversion & & \rb{Exact Match}& \ref{conv.func} \\ \cline{1-2}\cline{4-4} +Qualification conversions & & & \ref{conv.qual} \\ \cline{1-1}\cline{4-4} +Function pointer conversion & \rb{Qualification Adjustment} & & \ref{conv.fctptr} \\ \hline +Integral promotions & & & \ref{conv.prom} \\ \cline{1-1}\cline{4-4} +Floating-point promotion & \rb{Promotion} & \rb{Promotion} & \ref{conv.fpprom} \\ \hline +Integral conversions & & & \ref{conv.integral} \\ \cline{1-1}\cline{4-4} +Floating-point conversions & & & \ref{conv.double} \\ \cline{1-1}\cline{4-4} +Floating-integral conversions & & & \ref{conv.fpint} \\ \cline{1-1}\cline{4-4} +Pointer conversions & \rb{Conversion} & \rb{Conversion} & \ref{conv.ptr} \\ \cline{1-1}\cline{4-4} +Pointer to member conversions & & & \ref{conv.mem} \\ \cline{1-1}\cline{4-4} +Boolean conversions & & & \ref{conv.bool} \\ +\end{floattable} + +\rSec4[over.ics.user]{User-defined conversion sequences} + +\pnum +A user-defined conversion sequence consists of an initial +standard conversion sequence followed by a user-defined +conversion~(\ref{class.conv}) followed by a second standard +conversion sequence. +If the user-defined conversion is specified +by a constructor~(\ref{class.conv.ctor}), the initial standard +conversion sequence converts the source type to the type required +by the argument of the constructor. +If the user-defined +conversion is specified by a conversion function~(\ref{class.conv.fct}), the +initial standard conversion sequence +converts the source type to the implicit object parameter of the +conversion function. + +\pnum +The second standard conversion sequence converts the result of +the user-defined conversion to the target type for the sequence. +Since an implicit conversion sequence is an initialization, the +special rules for initialization by user-defined conversion apply +when selecting the best user-defined conversion for a +user-defined conversion sequence (see~\ref{over.match.best} and~\ref{over.best.ics}). + +\pnum +If the user-defined conversion is specified by a +specialization of a conversion function template, +the second standard conversion sequence shall have exact match rank. + +\pnum +A conversion of an expression of class type +to the same class type is given Exact Match rank, and +a conversion of an expression of class type +to a base class of that type is given Conversion rank, +in spite of the +fact that a constructor (i.e., a user-defined conversion +function) is called for those cases. + +\rSec4[over.ics.ellipsis]{Ellipsis conversion sequences} + +\pnum +\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}). + +\rSec4[over.ics.ref]{Reference binding} + +\pnum +When a parameter of reference type binds directly~(\ref{dcl.init.ref}) to an +argument expression, the implicit conversion sequence is the identity conversion, +unless the argument expression has a type that is a derived class of the parameter +type, in which case the implicit conversion sequence is a derived-to-base +Conversion~(\ref{over.best.ics}). +\begin{example} + +\begin{codeblock} +struct A {}; +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 +\end{codeblock} +\end{example} +If the parameter binds directly to the result of +applying a conversion function to the argument expression, the implicit +conversion sequence is a user-defined conversion sequence~(\ref{over.ics.user}), +with the second standard conversion sequence either an identity conversion or, +if the conversion function returns an entity of a type that is a derived class +of the parameter type, a derived-to-base Conversion. + +\pnum +When a parameter of reference type is not bound directly to an argument +expression, the conversion sequence is the one required to convert the argument +expression to the referenced type according to~\ref{over.best.ics}. +Conceptually, this conversion sequence corresponds to copy-initializing a +temporary of the referenced type with the argument expression. +Any difference +in top-level cv-qualification is subsumed by the initialization itself and +does not constitute a conversion. + +\pnum +Except for an implicit object parameter, for which see~\ref{over.match.funcs}, a +standard conversion sequence cannot be formed if it requires +binding an lvalue reference +other than a reference to a non-volatile \tcode{const} type +to an rvalue +or binding an rvalue reference to an lvalue other than a function lvalue. +\begin{note} +This means, for example, that a candidate function cannot be a viable +function if it has a non-\tcode{const} lvalue reference parameter (other than +the implicit object parameter) and the corresponding argument +would require a temporary to be created to initialize the lvalue +reference (see~\ref{dcl.init.ref}). +\end{note} + +\pnum +Other restrictions on binding a reference to a particular argument +that are not based on the types of the reference and the argument +do not affect the formation of a standard conversion +sequence, however. +\begin{example} +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. +The formation of implicit conversion sequences +treats the +\tcode{int} +bit-field as an +\tcode{int} +lvalue and finds an exact +match with the parameter. +If the function is selected by overload +resolution, the call will nonetheless be ill-formed because of +the prohibition on binding a non-\tcode{const} lvalue reference to a bit-field~(\ref{dcl.init.ref}). +\end{example} + +\rSec4[over.ics.list]{List-initialization sequence} + +\pnum +When an argument is an initializer list~(\ref{dcl.init.list}), it is not an +expression and special rules apply for converting it to a parameter type. + +\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} +or a class derived from \tcode{X}, the implicit conversion sequence is the one +required to convert the element to the parameter type. + +\pnum +Otherwise, if the parameter type is a character array% +\footnote{Since there are no parameters of array type, +this will only occur as the referenced type of a reference parameter.} +and the initializer list has a single element that is an appropriately-typed +string literal~(\ref{dcl.init.string}), the implicit conversion +sequence is the identity conversion. + +\pnum +Otherwise, if the parameter type is \tcode{std::initializer_list} +and all the elements +of the initializer list can be implicitly converted to \tcode{X}, the implicit +conversion sequence is the worst conversion necessary to convert an element of +the list to \tcode{X}, or if the initializer list has no elements, the identity +conversion. This conversion can be a user-defined conversion even in +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 + +struct A { + A(std::initializer_list); // \#1 + A(std::initializer_list>); // \#2 + A(std::initializer_list); // \#3 +}; +A a{ 1.0,2.0 }; // OK, uses \#1 + +void g(A); +g({ "foo", "bar" }); // OK, uses \#3 + +typedef int IA[3]; +void h(const IA&); +h({ 1, 2, 3 }); // OK: identity conversion +\end{codeblock} +\end{example} + +\pnum +Otherwise, if the parameter type is ``array of \tcode{N} \tcode{X}'', +if there exists an implicit conversion sequence for each element of the array +from the corresponding element of the initializer list (or from \tcode{\{\}} +if there is no such element), the implicit conversion sequence is +the worst such implicit conversion sequence. + +\pnum +Otherwise, if the parameter is a non-aggregate class \tcode{X} and overload +resolution per~\ref{over.match.list} chooses a single best constructor \tcode{C} of +\tcode{X} to perform the initialization of an object of type \tcode{X} from the +argument initializer list: +\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}, +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}. +\item +Otherwise, the implicit conversion sequence is a user-defined +conversion sequence with the second standard conversion sequence an +identity conversion. +\end{itemize} +If multiple constructors are viable but none is better than +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} +\begin{codeblock} +struct A { + A(std::initializer_list); +}; +void f(A); +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 + +void 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")))} + +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"))))} +\end{codeblock} +\end{example} + +\pnum +Otherwise, if the parameter has an aggregate type which can be initialized from +the initializer list according to the rules for aggregate +initialization~(\ref{dcl.init.aggr}), the implicit conversion sequence is a +user-defined conversion sequence with the second standard conversion +sequence an identity conversion. \begin{example} +\begin{codeblock} +struct A { + int m1; + double m2; +}; + +void f(A); +f( {'a', 'b'} ); // OK: \tcode{f(A(int,double))} user-defined conversion +f( {1.0} ); // error: narrowing +\end{codeblock} +\end{example} + +\pnum +Otherwise, if the parameter is a reference, see~\ref{over.ics.ref}. \begin{note} +The rules in this section will apply for initializing the underlying temporary +for the reference. \end{note} \begin{example} +\begin{codeblock} +struct A { + int m1; + double m2; +}; + +void f(const A&); +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} +\end{codeblock} +\end{example} + +\pnum +Otherwise, if the parameter type is not a class: + +\begin{itemize} +\item if the initializer list has one element that is not itself an initializer list, +the implicit conversion sequence is the one required to convert the element to +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 +\end{codeblock} +\end{example} + +\item if the initializer list has no elements, the implicit conversion sequence +is the identity conversion. \begin{example} +\begin{codeblock} +void f(int); +f( { } ); // OK: identity conversion +\end{codeblock} +\end{example} +\end{itemize} + +\pnum +In all cases other than those enumerated above, no conversion is possible. + +\rSec3[over.ics.rank]{Ranking implicit conversion sequences} + +\pnum +This subclause defines a partial ordering of implicit conversion +sequences based on the relationships +\term{better conversion sequence} +and +\term{better conversion}. +If an implicit conversion sequence S1 is +defined by these rules to be a better conversion sequence than +S2, then it is also the case that S2 is a +\term{worse conversion sequence} +than S1. +If conversion sequence S1 is neither better +than nor worse than conversion sequence S2, S1 and S2 are said to +be +\term{indistinguishable conversion sequences}. + +\pnum +When comparing the basic forms of implicit conversion sequences +(as defined in~\ref{over.best.ics}) + +\begin{itemize} +\item +a standard conversion sequence~(\ref{over.ics.scs}) is a better +conversion sequence than a user-defined conversion sequence +or an ellipsis conversion sequence, and +\item +a user-defined conversion sequence~(\ref{over.ics.user}) is a +better conversion sequence than an ellipsis conversion +sequence~(\ref{over.ics.ellipsis}). +\end{itemize} + +\pnum +Two implicit conversion sequences of the same form are +indistinguishable conversion sequences unless one of the +following rules applies: + +\begin{itemize} +\item +List-initialization sequence \tcode{L1} is a better conversion sequence than +list-initialization sequence \tcode{L2} if + +\begin{itemize} +\item +\tcode{L1} converts to \tcode{std::initializer_list} for some \tcode{X} and +\tcode{L2} does not, or, if not that, + +\item +\tcode{L1} converts to type ``array of \tcode{N1} \tcode{T}'', \tcode{L2} converts to +type ``array of \tcode{N2} \tcode{T}'', and \tcode{N1} is smaller than \tcode{N2}, +\end{itemize} +even if one of the other rules in this paragraph would otherwise apply. +\begin{example} +\begin{codeblock} + void f1(int); // \#1 + void f1(std::initializer_list); // \#2 + void g1() { f1({42}); } // chooses \#2 + + void f2(std::pair); // \#3 + void f2(std::initializer_list); // \#4 + void g2() { f2({"foo","bar"}); } // chooses \#4 +\end{codeblock} +\end{example} + +\item +Standard conversion sequence +\tcode{S1} +is a better conversion +sequence than standard conversion sequence +\tcode{S2} +if + +\begin{itemize} +\item +\indextext{subsequence rule!overloading}% +\tcode{S1} +is a proper subsequence of +\tcode{S2} +(comparing the conversion sequences in the canonical form defined +by~\ref{over.ics.scs}, excluding any Lvalue Transformation; +the identity conversion sequence is considered to be a +subsequence of any non-identity conversion sequence) +or, if not that, +\item +the rank of +\tcode{S1} +is better than the rank of +\tcode{S2}, +or +\tcode{S1} +and +\tcode{S2} +have the same rank and are distinguishable by the rules +in the paragraph below, +or, if not that, + +\item \tcode{S1} and \tcode{S2} are reference bindings~(\ref{dcl.init.ref}) and +neither refers to an implicit object parameter of a non-static member function +declared without a \grammarterm{ref-qualifier}, +and \tcode{S1} binds an rvalue reference to an +rvalue and \tcode{S2} binds an lvalue reference +\begin{example} +\begin{codeblock} +int i; +int f1(); +int&& f2(); +int g(const int&); +int g(const int&&); +int j = g(i); // calls \tcode{g(const int\&)} +int k = g(f1()); // calls \tcode{g(const int\&\&)} +int l = g(f2()); // calls \tcode{g(const int\&\&)} + +struct A { + A& operator<<(int); + void p() &; + void p() &&; +}; +A& operator<<(A&&, char); +A() << 1; // calls \tcode{A::operator<<(int)} +A() << 'c'; // calls \tcode{operator<<(A\&\&, char)} +A a; +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} +\end{example} +or, if not that, + +\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} +\begin{codeblock} +int f(void(&)()); // \#1 +int f(void(&&)()); // \#2 +void g(); +int i1 = f(g); // calls \#1 +\end{codeblock} +\end{example} +or, if not that, + +\item +\tcode{S1} +and +\tcode{S2} +differ only in their qualification conversion and yield similar types +\tcode{T1} +and +\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} +\begin{example} +\begin{codeblock} +int f(const volatile int *); +int f(const int *); +int i; +int j = f(&i); // calls \tcode{f(const int*)} +\end{codeblock} +\end{example} +or, if not that, + +\item +\tcode{S1} +and +\tcode{S2} +are reference bindings~(\ref{dcl.init.ref}), and the types to which the references +refer are the same type except for top-level cv-qualifiers, and the type to +which the reference initialized by +\tcode{S2} +refers is more cv-qualified than the type to which the reference initialized by +\tcode{S1} +refers. +\begin{example} +\begin{codeblock} +int f(const int &); +int f(int &); +int g(const int &); +int g(int); + +int i; +int j = f(i); // calls \tcode{f(int \&)} +int k = g(i); // ambiguous + +struct X { + void f() const; + void f(); +}; +void g(const X& a, X b) { + a.f(); // calls \tcode{X::f() const} + b.f(); // calls \tcode{X::f()} +} +\end{codeblock} +\end{example} +\end{itemize} + +\item +User-defined conversion sequence +\tcode{U1} +is a better conversion sequence than another user-defined conversion +sequence +\tcode{U2} +if they contain the same user-defined conversion function or +constructor or they initialize the same class in an aggregate +initialization and in either case the second standard conversion +sequence of +\tcode{U1} +is better than +the second standard conversion sequence of +\tcode{U2}. +\begin{example} + +\begin{codeblock} +struct A { + operator short(); +} a; +int f(int); +int f(float); +int i = f(a); // calls \tcode{f(int)}, because \tcode{short} $\to$ \tcode{int} is + // better than \tcode{short} $\to$ \tcode{float}. +\end{codeblock} +\end{example} + +\end{itemize} + +\pnum +Standard conversion sequences are ordered by their ranks: an Exact Match is a +better conversion than a Promotion, which is a better conversion than +a Conversion. +Two conversion sequences with the same rank are indistinguishable unless +one of the following rules applies: + +\begin{itemize} +\item +A conversion that does not convert a pointer, +a pointer to member, or \tcode{std::nullptr_t} +to +\tcode{bool} +is better than one that does. + +\item +A conversion that promotes an enumeration whose underlying type is fixed to its underlying +type is better than one that promotes to the promoted underlying type, if the two are +different. + +\item +If class +\tcode{B} +is derived directly or indirectly from class +\tcode{A}, +conversion of +\tcode{B*} +to +\tcode{A*} +is better than conversion of +\tcode{B*} +to +\tcode{void*}, +and conversion of +\tcode{A*} +to +\tcode{void*} +is better than conversion +of +\tcode{B*} +to +\tcode{void*}. +\item +If class +\tcode{B} +is derived directly or indirectly from class +\tcode{A} +and class +\tcode{C} +is derived directly or indirectly from +\tcode{B}, + +\begin{itemize} +\item +conversion of +\tcode{C*} +to +\tcode{B*} +is better than conversion of +\tcode{C*} +to +\tcode{A*}, +\begin{example} + +\begin{codeblock} +struct A {}; +struct B : public A {}; +struct C : public B {}; +C* pc; +int f(A*); +int f(B*); +int i = f(pc); // calls \tcode{f(B*)} +\end{codeblock} +\end{example} + +\item +binding of an expression of type +\tcode{C} +to a reference to type +\tcode{B} +is better than binding an expression of type +\tcode{C} +to a reference to type +\tcode{A}, +\item +conversion of +\tcode{A::*} +to +\tcode{B::*} +is better than conversion of +\tcode{A::*} +to +\tcode{C::*}, +\item +conversion of +\tcode{C} +to +\tcode{B} +is better than conversion of +\tcode{C} +to +\tcode{A}, +\item +conversion of +\tcode{B*} +to +\tcode{A*} +is better than conversion of +\tcode{C*} +to +\tcode{A*}, +\item +binding of an expression of type +\tcode{B} +to a reference to type +\tcode{A} +is better than binding an expression of type +\tcode{C} +to a +reference to type +\tcode{A}, +\item +conversion of +\tcode{B::*} +to +\tcode{C::*} +is better than conversion +of +\tcode{A::*} +to +\tcode{C::*}, +and +\item +conversion of +\tcode{B} +to +\tcode{A} +is better than conversion of +\tcode{C} +to +\tcode{A}. +\end{itemize} + +\begin{note} +Compared conversion sequences will have different source types only in the +context of comparing the second standard conversion sequence of an +initialization by user-defined conversion (see~\ref{over.match.best}); in +all other contexts, the source types will be the same and the target +types will be different. +\end{note} +\end{itemize}% +\indextext{overloading!resolution!implicit conversions and|)}% +\indextext{overloading!resolution|)} + +\rSec1[over.over]{Address of overloaded function}% +\indextext{overloading!address of overloaded function}% +\indextext{overloaded function!address of} + +\pnum +A use of an overloaded function name without arguments is resolved +in certain contexts to a function, a pointer to function or a pointer to +member function for a specific function from the overload set. +A function template name is considered to name a set of overloaded functions +in such contexts. +A function with type \tcode{F} is selected for the function type \tcode{FT} +of the target type required in the context if \tcode{F} +(after possibly applying the function pointer conversion~(\ref{conv.fctptr})) +is identical to \tcode{FT}. +\begin{note} +That is, the class of which the function is a member is ignored when matching a +pointer-to-member-function type. +\end{note} +The target can be + +\begin{itemize} +\item +an object or reference being initialized~(\ref{dcl.init}, \ref{dcl.init.ref}, +\ref{dcl.init.list}), +\item +the left side of an assignment~(\ref{expr.ass}), +\item +a parameter of a function~(\ref{expr.call}), +\item +a parameter of a user-defined operator~(\ref{over.oper}), +\item +the return value of a function, operator function, or conversion~(\ref{stmt.return}), +\item +an explicit type conversion~(\ref{expr.type.conv}, \ref{expr.static.cast}, +\ref{expr.cast}), or +\item +a non-type +\grammarterm{template-parameter}~(\ref{temp.arg.nontype}). +\end{itemize} + +The overloaded function name can be preceded by the +\tcode{\&} +operator. +An overloaded function name shall not be used without arguments in contexts +other than those listed. +\begin{note} +Any redundant set of parentheses surrounding the overloaded function name is +ignored~(\ref{expr.prim}). +\end{note} + +\pnum +If the name is a function template, template argument deduction is +done~(\ref{temp.deduct.funcaddr}), and if the argument deduction succeeds, +the +resulting template argument list is +used to generate a single +function template specialization, +which is added to the set of overloaded functions +considered. +\begin{note} +As described in~\ref{temp.arg.explicit}, if deduction fails and the +function template name is followed by an explicit template argument list, +the +\grammarterm{template-id} +is then examined to see whether it identifies a single function template +specialization. If it does, the +\grammarterm{template-id} +is considered to be an lvalue for that function template specialization. +The target type is not used in that determination. +\end{note} + +\pnum +Non-member functions and static member functions +match targets of function pointer type or +reference to function type. +Non-static member functions match targets of +pointer to member function type. +If a non-static member function is selected, the reference to the overloaded +function name is required to have the form of a pointer to member as +described in~\ref{expr.unary.op}. + +\pnum +If more than one function is selected, any +function template specializations +in the set +are eliminated if the set also contains a function that is not a +function template specialization, and +any given +function template specialization +\tcode{F1} +is eliminated if the set contains a second +function template specialization whose function template +is more specialized than the +function template of +\tcode{F1} +according to +the partial ordering rules of~\ref{temp.func.order}. +After such eliminations, +if any, there shall remain exactly one selected function. + +\pnum +\begin{example} +\begin{codeblock} +int f(double); +int f(int); +int (*pfd)(double) = &f; // selects \tcode{f(double)} +int (*pfi)(int) = &f; // selects \tcode{f(int)} +int (*pfe)(...) = &f; // error: type mismatch +int (&rfi)(int) = f; // selects \tcode{f(int)} +int (&rfd)(double) = f; // selects \tcode{f(double)} +void g() { + (int (*)(int))&f; // cast expression as selector +} +\end{codeblock} + +The initialization of +\tcode{pfe} +is ill-formed because no +\tcode{f()} +with type +\tcode{int(...)} +has been declared, and not because of any ambiguity. +For another example, + +\begin{codeblock} +struct X { + int f(int); + static int f(long); +}; + +int (X::*p1)(int) = &X::f; // OK +int (*p2)(int) = &X::f; // error: mismatch +int (*p3)(long) = &X::f; // OK +int (X::*p4)(long) = &X::f; // error: mismatch +int (X::*p5)(int) = &(X::f); // error: wrong syntax for + // pointer to member +int (*p6)(long) = &(X::f); // OK +\end{codeblock} +\end{example} + +\pnum +\begin{note} +If +\tcode{f()} +and +\tcode{g()} +are both overloaded functions, the +cross product of possibilities must be considered +to resolve +\tcode{f(\&g)}, +or the equivalent expression +\tcode{f(g)}. +\end{note} + +\pnum +\indextext{conversion!overload resolution and pointer}% +\begin{note} +Even if \tcode{B} is a public base of \tcode{D}, +we have + +\begin{codeblock} +D* f(); +B* (*p1)() = &f; // error + +void g(D*); +void (*p2)(B*) = &g; // error +\end{codeblock} +\end{note} + +\rSec1[over.oper]{Overloaded operators}% +\indextext{overloading!operator|(}% +\indextext{overloaded operator|see{overloading, operator}}% +\indextext{operator overloading|see{overloading, operator}} + +\pnum +\indextext{operator!overloaded}% +\indextext{function!operator}% +A function declaration having one of the following +\grammarterm{operator-function-id}{s} +as its name declares an +\term{operator function}. +A function template declaration having one of the +following \grammarterm{operator-function-id}{s} as its name +declares an \term{operator function template}. A specialization +of an operator function template is also an operator function. +An operator function is said to +\term{implement} +the operator named in its +\grammarterm{operator-function-id}. + +\begin{bnf} +\nontermdef{operator-function-id}\br + \terminal{operator} operator +\end{bnf} + +\begin{bnfkeywordtab} +\nontermdef{operator} \textnormal{one of}\br +\>new\>delete\>new[]\>delete[]\br +\>+\>-\>*\>/\>\%\>\caret\>\&\>|\>\~\br +\>!\>=\><\>>\>+=\>-=\>*=\>/=\>\%=\br +\>\caret=\>\&=\>|=\><<\>>>\>>>=\><<=\>={=}\>!=\br +\><=\>>=\>\&\&\>|{|}\>++\>-{-}\>,\>->*\>->\br +\>(\,)\>[\,] +\end{bnfkeywordtab} + +\begin{note} +The last two operators are function call~(\ref{expr.call}) +and subscripting~(\ref{expr.sub}). +The operators +\tcode{new[]}, +\tcode{delete[]}, +\tcode{()}, +and +\tcode{[]} +are formed from more than one token. +\end{note} +\indextext{operator!subscripting}% +\indextext{operator!function call}% + +\pnum +Both the unary and binary forms of + +\begin{codeblock} ++ - * & +\end{codeblock} + +can be overloaded. + +\pnum +\indextext{restriction!operator overloading}% +The following operators cannot be overloaded: + +\begin{codeblock} +. .* :: ?: +\end{codeblock} + +nor can the preprocessing symbols +\tcode{\#} +and +\tcode{\#\#} +(Clause~\ref{cpp}). + +\pnum +\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 +\grammarterm{operator-function-id} +as the name of the function in the function call syntax~(\ref{expr.call}). +\begin{example} + +\begin{codeblock} +complex z = a.operator+(b); // \tcode{complex z = a+b;} +void* p = operator new(sizeof(int)*n); +\end{codeblock} +\end{example} + +\pnum +The allocation and deallocation functions, +\tcode{operator} +\tcode{new}, +\tcode{operator} +\tcode{new[]}, +\tcode{operator} +\tcode{delete} +and +\tcode{operator} +\tcode{de\-lete\brk[]}, +are described completely in~\ref{basic.stc.dynamic}. +The attributes and restrictions +found in the rest of this subclause do not apply to them unless explicitly +stated in~\ref{basic.stc.dynamic}. + +\pnum +\indextext{restriction!overloading}% +An operator function +shall either be a non-static member function or be a non-member function that +has at least one parameter whose type is a class, a reference to a class, an +enumeration, or a reference to an enumeration. +It is not possible to change the precedence, grouping, or number of operands +of operators. +The meaning of the operators +\tcode{=}, +(unary) +\tcode{\&}, +and +\tcode{,} +(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}% +Operator functions are inherited in the same manner as other base class +functions. + +\pnum +\indextext{operator}% +The identities among certain predefined operators applied to basic types +(for example, +\tcode{++a} $\equiv$ +\tcode{a+=1}) +need not hold for operator functions. +Some predefined operators, such as +\tcode{+=}, +require an operand to be an lvalue when applied to basic types; +this is not required by operator functions. + +\pnum +\indextext{argument!overloaded operator and default}% +An operator function cannot have default arguments~(\ref{dcl.fct.default}), +except where explicitly stated below. +Operator +functions cannot have more or fewer parameters than the +number required for the corresponding operator, as +described in the rest of this subclause. + +\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}.% +\indextext{overloading!resolution!best viable function|)}% +\indextext{overloading!resolution!viable functions|)} + +\rSec2[over.unary]{Unary operators}% +\indextext{unary operator!overloaded}% +\indextext{overloading!unary operator} + +\pnum +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}% +Thus, for any prefix unary operator +\tcode{@}, +\tcode{@x} +can be interpreted as either +\tcode{x.op\-er\-a\-tor@()} +or +\tcode{operator@(x)}. +If both forms of the operator function have been declared, +the rules in~\ref{over.match.oper} determine which, if any, interpretation is +used. +See~\ref{over.inc} for an explanation of the postfix unary operators +\tcode{++} +and +\tcode{\dcr}. + +\pnum +The unary and binary forms of the same operator are considered to have +the same name. +\begin{note} +Consequently, a unary operator can hide a binary +operator from an enclosing scope, and vice versa. +\end{note} + +\rSec2[over.binary]{Binary operators}% +\indextext{binary operator!overloaded}% +\indextext{overloading!binary operator} + +\pnum +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}% +Thus, for any binary operator +\tcode{@}, +\tcode{x@y} +can be interpreted as either +\tcode{x.op\-er\-a\-tor\-@(y)} +or +\tcode{operator@(x,y)}. +If both forms of the operator function have been declared, +the rules in~\ref{over.match.oper} determine which, if any, interpretation is +used. + +\rSec2[over.ass]{Assignment} +\indextext{assignment operator!overloaded}% +\indextext{overloading!assignment operator} + +\pnum +An assignment operator shall be implemented by a +non-static member function with +exactly one parameter. +Because a copy assignment operator +\tcode{operator=} +is implicitly declared for a class if not declared by the user~(\ref{class.copy}), +a base class assignment operator is always hidden by the copy assignment +operator of the derived class. + +\pnum +Any assignment operator, even the copy and move assignment operators, can be virtual. +\begin{note} +For a derived class +\tcode{D} +with a base class +\tcode{B} +for which a virtual copy/move assignment has been declared, +the copy/move assignment operator in +\tcode{D} +does not override +\tcode{B}'s +virtual copy/move assignment operator. +\begin{example} + +\begin{codeblock} +struct B { + virtual int operator= (int); + virtual B& operator= (const B&); +}; +struct D : B { + virtual int operator= (int); + virtual D& operator= (const B&); +}; + +D dobj1; +D dobj2; +B* bptr = &dobj1; +void f() { + bptr->operator=(99); // calls \tcode{D::operator=(int)} + *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\&)} +} +\end{codeblock} +\end{example} +\end{note} + +\rSec2[over.call]{Function call}% +\indextext{function call operator!overloaded}% +\indextext{overloading!function call operator} + +\pnum +\tcode{operator()} +shall be a non-static member function with an arbitrary number of +parameters. +It can have default arguments. +It implements the function call syntax + +\begin{ncsimplebnf} +postfix-expression \terminal{(} expression-list\opt{} \terminal{)} +\end{ncsimplebnf} + +where the +\grammarterm{postfix-expression} +evaluates to a class object and the possibly empty +\grammarterm{expression-list} +matches the parameter list of an +\tcode{operator()} +member function of the class. +Thus, a call +\tcode{x(arg1,...)} +is interpreted as +\tcode{x.op\-er\-a\-tor()(arg1, ...)} +for a class object +\tcode{x} +of type +\tcode{T} +if +\tcode{T::operator()(T1,} +\tcode{T2,} +\tcode{T3)} +exists and if the operator is selected as the best match function by +the overload resolution mechanism~(\ref{over.match.best}). + +\rSec2[over.sub]{Subscripting}% +\indextext{subscripting operator!overloaded}% +\indextext{overloading!subscripting operator} + +\pnum +\tcode{operator[]} +shall be a non-static member function with exactly one parameter. +It implements the subscripting syntax + +\begin{ncsimplebnf} +postfix-expression \terminal{[} expr-or-braced-init-list \terminal{]} +\end{ncsimplebnf} + +Thus, a subscripting expression +\tcode{x[y]} +is interpreted as +\tcode{x.operator[](y)} +for a class object +\tcode{x} +of type +\tcode{T} +if +\tcode{T::op\-er\-a\-tor[]\-(T1)} +exists and if the operator is selected as the best match function by +the overload resolution mechanism~(\ref{over.match.best}). +\begin{example} +\begin{codeblock} +struct X { + Z operator[](std::initializer_list); +}; +X x; +x[{1,2,3}] = 7; // OK: meaning \tcode{x.operator[](\{1,2,3\})} +int a[10]; +a[{1,2,3}] = 7; // error: built-in subscript operator +\end{codeblock} +\end{example} + +\rSec2[over.ref]{Class member access} +\indextext{member access operator!overloaded}% +\indextext{overloading!member access operator} + +\pnum +\tcode{operator->} +shall be a non-static member function taking no parameters. +It implements the class member access syntax that +uses \tcode{->}. + +\begin{ncsimplebnf} +postfix-expression \terminal{->} \terminal{template\opt} id-expression\\ +postfix-expression \terminal{->} pseudo-destructor-name +\end{ncsimplebnf} + +An expression +\tcode{x->m} +is interpreted as +\tcode{(x.operator->())->m} +for a class object +\tcode{x} +of type +\tcode{T} +if +\tcode{T::operator->()} +exists and if the operator is selected as the best match function by +the overload resolution mechanism~(\ref{over.match}). + +\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}% + +\pnum +The user-defined function called +\tcode{operator++} +implements the prefix and postfix +\tcode{++} +operator. +If this function is a non-static member function with no parameters, or a non-member +function with one parameter, +it defines the prefix increment operator +\tcode{++} +for objects of that type. +If the function is a non-static member function with one parameter (which shall be of type +\tcode{int}) +or a non-member function with two parameters (the second of which shall be of type +\tcode{int}), +it defines the postfix increment operator +\tcode{++} +for objects of that type. +When the postfix increment is called as a result of using the +\tcode{++} +operator, the +\tcode{int} +argument will have value zero.\footnote{Calling +\tcode{operator++} +explicitly, as in expressions like +\tcode{a.operator++(2)}, +has no special properties: +The argument to +\tcode{operator++} +is +\tcode{2}.} +\begin{example} + +\begin{codeblock} +struct X { + X& operator++(); // prefix \tcode{++a} + X operator++(int); // postfix \tcode{a++} +}; + +struct Y { }; +Y& operator++(Y&); // prefix \tcode{++b} +Y operator++(Y&, int); // postfix \tcode{b++} + +void f(X a, Y b) { + ++a; // \tcode{a.operator++();} + a++; // \tcode{a.operator++(0);} + ++b; // \tcode{operator++(b);} + b++; // \tcode{operator++(b, 0);} + + a.operator++(); // explicit call: like \tcode{++a;} + a.operator++(0); // explicit call: like \tcode{a++;} + operator++(b); // explicit call: like \tcode{++b;} + operator++(b, 0); // explicit call: like \tcode{b++;} +} +\end{codeblock} +\end{example} + +\pnum +The prefix and postfix decrement operators +\tcode{-{-}} +are handled analogously. + +\rSec2[over.literal]{User-defined literals}% +\indextext{user-defined literal!overloaded}% +\indextext{overloading!user-defined literal} + +\begin{bnf} +\nontermdef{literal-operator-id}\br + \terminal{operator} string-literal identifier\br + \terminal{operator} user-defined-string-literal +\end{bnf} + +\pnum +The \grammarterm{string-literal} or \grammarterm{user-defined-string-literal} +in a \grammarterm{literal-operator-id} shall have no +\grammarterm{encoding-prefix} and shall contain no characters other than the +implicit terminating \tcode{'\textbackslash 0'}. +The \grammarterm{ud-suffix} of the \grammarterm{user-defined-string-literal} or +the \grammarterm{identifier} in a \grammarterm{literal-operator-id} is called a +\term{literal suffix identifier}. +Some literal suffix identifiers are reserved for future standardization; +see~\ref{usrlit.suffix}. A declaration whose \grammarterm{literal-operator-id} uses +such a literal suffix identifier is ill-formed, no diagnostic required. + +\pnum +A declaration whose \grammarterm{declarator-id} is a +\grammarterm{literal-operator-id} shall be a declaration of a namespace-scope +function or function template (it could be a friend +function~(\ref{class.friend})), an explicit instantiation or specialization of a +function template, or a \grammarterm{using-declaration}~(\ref{namespace.udecl}). +A function declared with a \grammarterm{literal-operator-id} is a \term{literal +operator}. A function template declared with a \grammarterm{literal-operator-id} +is a \term{literal operator template}. + +\pnum +The declaration of a literal operator shall have a +\grammarterm{parameter-declaration-clause} equivalent to one of the following: + +\begin{codeblock} +const char* +unsigned long long int +long double +char +wchar_t +char16_t +char32_t +const char*, std::size_t +const wchar_t*, std::size_t +const char16_t*, std::size_t +const char32_t*, std::size_t +\end{codeblock} + +If a parameter has a default argument~(\ref{dcl.fct.default}), the program is +ill-formed. + +\pnum +A \term{raw literal operator} is a literal operator with a single parameter +whose type is \tcode{const char*}. + +\pnum +The declaration of a literal operator template shall have an empty +\grammarterm{parameter-declaration-clause} and its +\grammarterm{template-parameter-list} shall have a single +\grammarterm{template-parameter} that is a non-type template parameter +pack (\ref{temp.variadic}) with element type \tcode{char}. + +\pnum +Literal operators and literal operator templates shall not have C language linkage. + +\pnum +\begin{note} Literal operators and literal operator templates are usually invoked +implicitly through user-defined literals~(\ref{lex.ext}). However, except for +the constraints described above, they are ordinary namespace-scope functions and +function templates. In particular, they are looked up like ordinary functions +and function templates and they follow the same overload resolution rules. Also, +they can be declared \tcode{inline} or \tcode{constexpr}, they may have internal +or external linkage, they can be called explicitly, their addresses can be +taken, etc. \end{note} + +\pnum +\begin{example} +\begin{codeblock} +void operator "" _km(long double); // OK +string operator "" _i18n(const char*, std::size_t); // OK +template double operator "" _\u03C0(); // OK: UCN for lowercase pi +float operator ""_e(const char*); // OK +float operator ""E(const char*); // error: reserved literal suffix~(\ref{usrlit.suffix}, \ref{lex.ext}) +double operator""_Bq(long double); // OK: does not use the reserved identifier \tcode{_Bq}~(\ref{lex.name}) +double operator"" _Bq(long double); // uses the reserved identifier \tcode{_Bq}~(\ref{lex.name}) +float operator " " B(const char*); // error: non-empty \grammarterm{string-literal} +string operator "" 5X(const char*, std::size_t); // error: invalid literal suffix identifier +double operator "" _miles(double); // error: invalid \grammarterm{parameter-declaration-clause} +template int operator "" _j(const char*); // error: invalid \grammarterm{parameter-declaration-clause} +extern "C" void operator "" _m(long double); // error: C language linkage +\end{codeblock} +\end{example}% +\indextext{overloading!operator|)} + +\rSec1[over.built]{Built-in operators}% +\indextext{overloading!built-in operators and} + +\pnum +The candidate operator functions that represent the built-in operators +defined in Clause~\ref{expr} are specified in this subclause. +These candidate +functions participate in the operator overload resolution process as +described in~\ref{over.match.oper} and are used for no other purpose. +\begin{note} +Because built-in operators take only operands with non-class type, +and operator overload resolution occurs only when an operand expression +originally has class or enumeration type, +operator overload resolution can resolve to a built-in operator only +when an operand has a class type that has a user-defined conversion to +a non-class type appropriate for the operator, or when an operand has +an enumeration type that can be converted to a type appropriate +for the operator. +Also note that some of the candidate operator functions given in this subclause are +more permissive than the built-in operators themselves. +As +described in~\ref{over.match.oper}, after a built-in operator is selected +by overload resolution the expression is subject to the requirements for +the built-in operator given in Clause~\ref{expr}, and therefore to any +additional semantic constraints given there. +If there is a user-written +candidate with the same name and parameter types as a built-in +candidate operator function, the built-in operator function +is hidden and is not included in the set of candidate functions. +\end{note} + +\pnum +\indextext{type!integral!promoted}% +\indextext{type!arithmetic!promoted}% +In this subclause, the term +\defn{promoted integral type} +is used to refer to those integral types which are preserved by +integral promotion~(\ref{conv.prom}) (including e.g. +\tcode{int} +and +\tcode{long} +but excluding e.g. +\tcode{char}). +Similarly, the term +\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 +required, an operand of enumeration type will be acceptable by way of the +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 +(\tcode{\placeholder{T}}, +\cvqual{vq}), +where +\tcode{\placeholder{T}} +is an arithmetic type other than \tcode{bool}, +there exist candidate operator functions of the form + +\begin{codeblock} +@\cvqual{vq} \placeholder{T}@& operator++(@\cvqual{vq} \placeholder{T}@&); +@\placeholder{T}@ operator++(@\cvqual{vq} \placeholder{T}@&, int); +\end{codeblock} + +\pnum +For every pair +(\tcode{\placeholder{T}}, +\cvqual{vq}), +where +\tcode{\placeholder{T}} +is an arithmetic type other than +\tcode{bool}, +there exist candidate operator functions of the form + +\begin{codeblock} +@\cvqual{vq} \placeholder{T}@& operator--(@\cvqual{vq} \placeholder{T}@&); +@\placeholder{T}@ operator--(@\cvqual{vq} \placeholder{T}@&, int); +\end{codeblock} + +\pnum +For every pair +(\tcode{\placeholder{T}}, +\cvqual{vq}), +where +\tcode{\placeholder{T}} +is a cv-qualified or cv-unqualified object type, +there exist candidate operator functions of the form + +\begin{codeblock} +@\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 +\tcode{\placeholder{T}}, +there exist candidate operator functions of the form + +\begin{codeblock} +@\placeholder{T}@& operator*(@\placeholder{T}@*); +\end{codeblock} + +\pnum +For every function type +\tcode{\placeholder{T}} that does not have cv-qualifiers or a \grammarterm{ref-qualifier}, +there exist candidate operator functions of the form + +\begin{codeblock} +@\placeholder{T}@& operator*(@\placeholder{T}@*); +\end{codeblock} + +\pnum +For every type \tcode{\placeholder{T}} there exist candidate operator functions of the form + +\begin{codeblock} +@\placeholder{T}@* operator+(@\placeholder{T}@*); +\end{codeblock} + +\pnum +For every promoted arithmetic type +\tcode{\placeholder{T}}, +there exist candidate operator functions of the form + +\begin{codeblock} +@\placeholder{T}@ operator+(@\placeholder{T}@); +@\placeholder{T}@ operator-(@\placeholder{T}@); +\end{codeblock} + +\pnum +For every promoted integral type +\tcode{\placeholder{T}}, +there exist candidate operator functions of the form + +\begin{codeblock} +@\placeholder{T}@ operator~(@\placeholder{T}@); +\end{codeblock} + +\pnum +For every quintuple +(\tcode{\placeholder{C1}}, +\tcode{\placeholder{C2}}, +\tcode{\placeholder{T}}, +\cvqual{cv1}, +\cvqual{cv2}), +where +\tcode{\placeholder{C2}} +is a class type, +\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, +there exist candidate operator functions of the form + +\begin{codeblock} +@\cvqual{cv12} \placeholder{T}@& operator->*(@\cvqual{cv1} \placeholder{C1}@*, @\cvqual{cv2} \placeholder{T C2}@::*); +\end{codeblock} + +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 +\tcode{\placeholder{L}} +and +\tcode{\placeholder{R}}, +there exist candidate operator functions of the form + +\begin{codeblock} +@\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 +\tcode{\placeholder{LR}} +is the result of the usual arithmetic conversions between types +\tcode{\placeholder{L}} +and +\tcode{\placeholder{R}}. + +\pnum +For every cv-qualified or cv-unqualified object type +\tcode{\placeholder{T}} +there exist candidate operator functions of the form + +\begin{codeblock} +@\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 +\tcode{\placeholder{T}}, +where +\tcode{\placeholder{T}} +is a pointer to object type, +there exist candidate operator functions of the form + +\begin{codeblock} +std::ptrdiff_t operator-(@\placeholder{T}@, @\placeholder{T}@); +\end{codeblock} + +\pnum +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<(@\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 \tcode{\placeholder{T}} or type \tcode{std::nullptr_t} there +exist candidate operator functions of the form + +\begin{codeblock} +bool operator==(@\placeholder{T}@, @\placeholder{T}@); +bool operator!=(@\placeholder{T}@, @\placeholder{T}@); +\end{codeblock} + +\pnum +For every pair of promoted integral types +\tcode{\placeholder{L}} +and +\tcode{\placeholder{R}}, +there exist candidate operator functions of the form + +\begin{codeblock} +@\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 +\tcode{\placeholder{LR}} +is the result of the usual arithmetic conversions between types +\tcode{\placeholder{L}} +and +\tcode{\placeholder{R}}. + +\pnum +For every triple +(\tcode{\placeholder{L}}, +\cvqual{vq}, +\tcode{\placeholder{R}}), +where +\tcode{\placeholder{L}} +is an arithmetic type, +and +\tcode{\placeholder{R}} +is a promoted arithmetic type, +there exist candidate operator functions of the form + +\begin{codeblock} +@\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 (\tcode{\placeholder{T}}, \cvqual{vq}), +where \tcode{\placeholder{T}} is any type, +there exist candidate operator functions of the form + +\begin{codeblock} +@\placeholder{T}@*@\cvqual{vq}@& operator=(@\placeholder{T}@*@\cvqual{vq}@&, @\placeholder{T}@*); +\end{codeblock} + +\pnum +For every pair +(\tcode{\placeholder{T}}, +\cvqual{vq}), +where +\tcode{\placeholder{T}} +is an enumeration or pointer to member type, +there exist candidate operator functions of the form + +\begin{codeblock} +@\cvqual{vq} \placeholder{T}@& operator=(@\cvqual{vq} \placeholder{T}@&, @\placeholder{T}@); +\end{codeblock} + +\pnum +For every pair +(\tcode{\placeholder{T}}, +\cvqual{vq}), +where +\tcode{\placeholder{T}} +is a cv-qualified or cv-unqualified object type, +there exist candidate operator functions of the form + +\begin{codeblock} +@\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 +(\tcode{\placeholder{L}}, +\cvqual{vq}, +\tcode{\placeholder{R}}), +where +\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} +@\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 +There also exist candidate operator functions of the form + +\begin{codeblock} +bool operator!(bool); +bool operator&&(bool, bool); +bool operator||(bool, bool); +\end{codeblock} + +\pnum +For every pair of promoted arithmetic types +\tcode{\placeholder{L}} +and +\tcode{\placeholder{R}}, +there exist candidate operator functions of the form + +\begin{codeblock} +@\placeholder{LR}@ operator?:(bool, @\placeholder{L}@, @\placeholder{R}@); +\end{codeblock} + +where +\tcode{\placeholder{LR}} +is the result of the usual arithmetic conversions between types +\tcode{\placeholder{L}} +and +\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. +The operator +``\tcode{?:}'' +cannot be overloaded. +\end{note} + +\pnum +For every type +\tcode{\placeholder{T}}, +where +\tcode{\placeholder{T}} +is a pointer, pointer-to-member, or scoped enumeration type, there exist candidate operator +functions of the form + +\begin{codeblock} +@\placeholder{T}@ operator?:(bool, @\placeholder{T}@, @\placeholder{T}@); +\end{codeblock}% +\indextext{overloading|)} diff --git a/source/utilities.tex b/source/utilities.tex index 07c7c1073f..3e1176a7e9 100644 --- a/source/utilities.tex +++ b/source/utilities.tex @@ -133,8 +133,7 @@ template class tuple_element; template struct tuple_size>; - template struct tuple_element<0, pair>; - template struct tuple_element<1, pair>; + template struct tuple_element>; template constexpr tuple_element_t>& get(pair&) noexcept; @@ -166,7 +165,7 @@ explicit piecewise_construct_t() = default; }; inline constexpr piecewise_construct_t piecewise_construct{}; - template class tuple; // defined in \tcode{} (\ref{tuple.syn}) + template class tuple; // defined in \tcode{}\iref{tuple.syn} // in-place construction struct in_place_t { @@ -183,70 +182,6 @@ explicit in_place_index_t() = default; }; template inline constexpr in_place_index_t in_place_index{}; -@ -\indexlibrary{\idxcode{chars_format}}% -\indexlibrarymember{scientific}{chars_format}% -\indexlibrarymember{fixed}{chars_format}% -\indexlibrarymember{hex}{chars_format}% -\indexlibrarymember{general}{chars_format}% -@ - // floating-point format for primitive numerical conversion - enum class chars_format { - scientific = @\unspec@, - fixed = @\unspec@, - hex = @\unspec@, - general = fixed | scientific - }; -@ -\indexlibrary{\idxcode{to_chars_result}}% -\indexlibrarymember{ptr}{to_chars_result}% -\indexlibrarymember{ec}{to_chars_result} -@ - // \ref{utility.to.chars}, primitive numerical output conversion - struct to_chars_result { - char* ptr; - error_code ec; - }; - - to_chars_result to_chars(char* first, char* last, @\seebelow@ value, int base = 10); - - to_chars_result to_chars(char* first, char* last, float value); - 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, int precision); - to_chars_result to_chars(char* first, char* last, double value, - chars_format fmt, int precision); - to_chars_result to_chars(char* first, char* last, long double value, - chars_format fmt, int precision); -@ -\indexlibrary{\idxcode{from_chars_result}}% -\indexlibrarymember{ptr}{from_chars_result}% -\indexlibrarymember{ec}{from_chars_result} -@ - // \ref{utility.from.chars}, primitive numerical input conversion - struct from_chars_result { - const char* ptr; - error_code ec; - }; - - from_chars_result from_chars(const char* first, const char* last, - @\seebelow@& value, int base = 10); - - from_chars_result from_chars(const char* first, const char* last, float& value, - chars_format fmt = chars_format::general); - from_chars_result from_chars(const char* first, const char* last, double& value, - chars_format fmt = chars_format::general); - from_chars_result from_chars(const char* first, const char* last, long double& value, - chars_format fmt = chars_format::general); } \end{codeblock} @@ -257,7 +192,7 @@ \pnum The type \tcode{chars_format} -is a bitmask type~(\ref{bitmask.types}) +is a bitmask type\iref{bitmask.types} with elements \tcode{scientific}, \tcode{fixed}, @@ -383,7 +318,7 @@ \pnum \requires -\tcode{a[i]} shall be swappable with~(\ref{swappable.requirements}) \tcode{b[i]} +\tcode{a[i]} shall be swappable with\iref{swappable.requirements} \tcode{b[i]} for all \tcode{i} in the range \range{0}{N}. \pnum @@ -418,9 +353,10 @@ \indextext{signal-safe!\idxcode{forward}}% \indextext{signal-safe!\idxcode{move}}% \indextext{signal-safe!\idxcode{move_if_noexcept}}% -All functions specified in this subclause are signal-safe~(\ref{csignal.syn}). +All functions specified in this subclause are signal-safe\iref{support.signal}. \indexlibrary{\idxcode{forward}}% +\indextext{\idxcode{forward}}% \begin{itemdecl} template constexpr T&& forward(remove_reference_t& t) noexcept; template constexpr T&& forward(remove_reference_t&& t) noexcept; @@ -463,6 +399,7 @@ \end{itemdescr} \indexlibrary{\idxcode{move}!function}% +\indextext{\idxcode{move}}% \begin{itemdecl} template constexpr remove_reference_t&& move(T&& t) noexcept; \end{itemdecl} @@ -532,7 +469,7 @@ \pnum The library provides the function template \tcode{declval} to simplify the definition of -expressions which occur as unevaluated operands (Clause~\ref{expr}). +expressions which occur as unevaluated operands\iref{expr}. \indexlibrary{\idxcode{declval}}% \begin{itemdecl} @@ -541,7 +478,7 @@ \begin{itemdescr} \pnum -\remarks If this function is odr-used~(\ref{basic.def.odr}), the program is ill-formed. +\remarks If this function is odr-used\iref{basic.def.odr}, the program is ill-formed. \pnum \remarks The template parameter \tcode{T} of \tcode{declval} may be an incomplete type. @@ -554,754 +491,490 @@ \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 -template \tcode{common_type}~(\ref{meta.trans.other}). +template \tcode{common_type}\iref{meta.trans.other}. \end{example} -\rSec2[utility.to.chars]{Primitive numeric output conversion} +\rSec1[intseq]{Compile-time integer sequences} -\pnum -All functions named \tcode{to_chars} -convert \tcode{value} into a character string -by successively filling the range -\range{first}{last}, -where \range{first}{last} is required to be a valid range. -If the member \tcode{ec} -of the return value -is such that the value, -when converted to \tcode{bool}, -is \tcode{false}, -the conversion was successful -and the member \tcode{ptr} -is the one-past-the-end pointer of the characters written. -Otherwise, -the member \tcode{ec} has the value \tcode{errc::value_too_large}, -the member \tcode{ptr} has the value \tcode{last}, -and the contents of the range \range{first}{last} are unspecified. +\rSec2[intseq.general]{In general} \pnum -The functions that take a floating-point \tcode{value} -but not a \tcode{precision} parameter -ensure that the string representation -consists of the smallest number of characters -such that -there is at least one digit before the radix point (if present) and -parsing the representation using the corresponding \tcode{from_chars} function -recovers \tcode{value} exactly. +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. \begin{note} -This guarantee applies only if -\tcode{to_chars} and \tcode{from_chars} -are executed on the same implementation. +The \tcode{index_sequence} alias template is provided for the common case of +an integer sequence of type \tcode{size_t}; see also \ref{tuple.apply}. \end{note} +\rSec2[intseq.intseq]{Class template \tcode{integer_sequence}} + +\indexlibrary{\idxcode{integer_sequence}}% +\begin{codeblock} +namespace std { + template + struct integer_sequence { + using value_type = T; + static constexpr size_t size() noexcept { return sizeof...(I); } + }; +} +\end{codeblock} + \pnum -The functions taking a \tcode{chars_format} parameter -determine the conversion specifier for \tcode{printf} as follows: -The conversion specifier is -\tcode{f} if \tcode{fmt} is \tcode{chars_format::fixed}, -\tcode{e} if \tcode{fmt} is \tcode{chars_format::scientific}, -\tcode{a} (without leading \tcode{"0x"} in the result) -if \tcode{fmt} is \tcode{chars_format::hex}, -and -\tcode{g} if \tcode{fmt} is \tcode{chars_format::general}. +\tcode{T} shall be an integer type. -\indexlibrary{\idxcode{to_chars}}% +\rSec2[intseq.make]{Alias template \tcode{make_integer_sequence}} + +\indexlibrary{\idxcode{make_integer_sequence}}% \begin{itemdecl} -to_chars_result to_chars(char* first, char* last, @\seebelow@ value, int base = 10); +template + using make_integer_sequence = integer_sequence; \end{itemdecl} \begin{itemdescr} \pnum -\requires \tcode{base} has a value between 2 and 36 (inclusive). +If \tcode{N} is negative the program is ill-formed. The alias template +\tcode{make_integer_sequence} denotes a specialization of +\tcode{integer_sequence} with \tcode{N} template non-type arguments. +The type \tcode{make_integer_sequence} denotes the type +\tcode{integer_sequence}. +\begin{note} \tcode{make_integer_sequence} denotes the type +\tcode{integer_sequence} \end{note} +\end{itemdescr} + +\rSec1[pairs]{Pairs} + +\rSec2[pairs.general]{In general} \pnum -\effects The value of \tcode{value} is converted -to a string of digits in the given base -(with no redundant leading zeroes). -Digits in the range 10..35 (inclusive) -are represented as lowercase characters \tcode{a}..\tcode{z}. -If \tcode{value} is less than zero, -the representation starts with a minus sign. +The library provides a template for heterogeneous pairs of values. +The library also provides a matching function template to simplify +their construction and several templates that provide access to \tcode{pair} +objects as if they were \tcode{tuple} objects (see~\ref{tuple.helper} +and~\ref{tuple.elem}).% +\indexlibrary{\idxcode{pair}}% +\indextext{\idxcode{pair}!tuple interface to}% +\indextext{\idxcode{tuple}!and pair@and \tcode{pair}}% + +\rSec2[pairs.pair]{Class template \tcode{pair}} + +\indexlibrary{\idxcode{pair}}% +\begin{codeblock} +namespace std { + template + struct pair { + using first_type = T1; + using second_type = T2; + + T1 first; + T2 second; + + pair(const pair&) = default; + pair(pair&&) = default; + @\EXPLICIT@ constexpr pair(); + @\EXPLICIT@ constexpr pair(const T1& x, const T2& y); + template @\EXPLICIT@ constexpr pair(U1&& x, U2&& y); + template @\EXPLICIT@ constexpr pair(const pair& p); + template @\EXPLICIT@ constexpr pair(pair&& p); + template + pair(piecewise_construct_t, tuple first_args, tuple second_args); + + pair& operator=(const pair& p); + template pair& operator=(const pair& p); + pair& operator=(pair&& p) noexcept(@\seebelow@); + template pair& operator=(pair&& p); + + void swap(pair& p) noexcept(@\seebelow@); + }; + + template + pair(T1, T2) -> pair; +} +\end{codeblock} \pnum -\throws Nothing. +Constructors and member functions of \tcode{pair} shall not throw exceptions unless one of +the element-wise operations specified to be called for that operation +throws an exception. \pnum -\remarks -The implementation shall provide overloads -for all signed and unsigned integer types -and \tcode{char} -as the type of the parameter \tcode{value}. -\end{itemdescr} +The defaulted move and copy constructor, respectively, of \tcode{pair} 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 constexpr function. +The destructor of \tcode{pair} shall be a trivial destructor if +\tcode{(is_trivially_destructible_v \&\& is_trivially_destructible_v)} +is \tcode{true}. -\indexlibrary{\idxcode{to_chars}}% +\indexlibrary{\idxcode{pair}!constructor}% \begin{itemdecl} -to_chars_result to_chars(char* first, char* last, float value); -to_chars_result to_chars(char* first, char* last, double value); -to_chars_result to_chars(char* first, char* last, long double value); +@\EXPLICIT@ constexpr pair(); \end{itemdecl} \begin{itemdescr} \pnum -\effects \tcode{value} is converted to a string -in the style of \tcode{printf} -in the \tcode{"C"} locale. -The conversion specifier is \tcode{f} or \tcode{e}, -chosen according to the requirement for a shortest representation -(see above); -a tie is resolved in favor of \tcode{f}. +\effects +Value-initializes \tcode{first} and \tcode{second}. \pnum -\throws Nothing. +\remarks +This constructor shall not participate in overload resolution unless +\tcode{is_default_construct\-ible_v} is \tcode{true} and +\tcode{is_default_constructible_v} is \tcode{true}. +\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 either \tcode{first_type} or +\tcode{second_type} is not implicitly default-constructible. +\begin{note} This behavior can be implemented with a trait that checks +whether a \tcode{const first_type\&} or a \tcode{const second_type\&} +can be initialized with \tcode{\{\}}. \end{note} \end{itemdescr} -\indexlibrary{\idxcode{to_chars}}% +\indexlibrary{\idxcode{pair}!constructor}% \begin{itemdecl} -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); +@\EXPLICIT@ constexpr pair(const T1& x, const T2& y); \end{itemdecl} \begin{itemdescr} \pnum -\requires \tcode{fmt} has the value of -one of the enumerators of \tcode{chars_format}. - -\pnum -\effects \tcode{value} is converted to a string -in the style of \tcode{printf} -in the \tcode{"C"} locale. +\effects +Initializes \tcode{first} with \tcode{x} and \tcode{second} with \tcode{y}. \pnum -\throws Nothing. +\remarks This constructor shall not participate in overload resolution +unless \tcode{is_copy_construct\-ible_v} is \tcode{true} and +\tcode{is_copy_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}. \end{itemdescr} -\indexlibrary{\idxcode{to_chars}}% +\indexlibrary{\idxcode{pair}!constructor}% \begin{itemdecl} -to_chars_result to_chars(char* first, char* last, float value, - chars_format fmt, int precision); -to_chars_result to_chars(char* first, char* last, double value, - chars_format fmt, int precision); -to_chars_result to_chars(char* first, char* last, long double value, - chars_format fmt, int precision); +template @\EXPLICIT@ constexpr pair(U1&& x, U2&& y); \end{itemdecl} \begin{itemdescr} \pnum -\requires \tcode{fmt} has the value of -one of the enumerators of \tcode{chars_format}. - -\pnum -\effects \tcode{value} is converted to a string -in the style of \tcode{printf} -in the \tcode{"C"} locale -with the given precision. +\effects +Initializes \tcode{first} with +\tcode{std::forward(x)} and \tcode{second} +with \tcode{std::forward(y)}. \pnum -\throws Nothing. +\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}. +The constructor is explicit if and only if +\tcode{is_convertible_v} is \tcode{false} or +\tcode{is_convertible_v} is \tcode{false}. \end{itemdescr} -\xref ISO C~7.21.6.1. +\indexlibrary{\idxcode{pair}!constructor}% +\begin{itemdecl} +template @\EXPLICIT@ constexpr pair(const pair& p); +\end{itemdecl} -\rSec2[utility.from.chars]{Primitive numeric input conversion} +\begin{itemdescr} +\pnum +\effects +Initializes members from the corresponding members of the argument. \pnum -All functions named \tcode{from_chars} -analyze the string \range{first}{last} -for a pattern, -where \range{first}{last} is required to be a valid range. -If no characters match the pattern, -\tcode{value} is unmodified, -the member \tcode{ptr} of the return value is \tcode{first} and -the member \tcode{ec} is equal to \tcode{errc::invalid_argument}. -Otherwise, -the characters matching the pattern -are interpreted as a representation -of a value of the type of \tcode{value}. -The member \tcode{ptr} -of the return value -points to the first character -not matching the pattern, -or has the value \tcode{last} -if all characters match. -If the parsed value -is not in the range -representable by the type of \tcode{value}, -\tcode{value} is unmodified and -the member \tcode{ec} of the return value -is equal to \tcode{errc::result_out_of_range}. -Otherwise, -\tcode{value} is set to the parsed value and -the member \tcode{ec} is set -such that the conversion to \tcode{bool} yields \tcode{false}. +\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}. +The constructor is explicit if and only if +\tcode{is_convertible_v} is \tcode{false} or +\tcode{is_convertible_v} is \tcode{false}. +\end{itemdescr} -\indexlibrary{\idxcode{from_chars}}% +\indexlibrary{\idxcode{pair}!constructor}% \begin{itemdecl} -from_chars_result from_chars(const char* first, const char* last, - @\seebelow@&@\itcorr[-1]@ value, int base = 10); +template @\EXPLICIT@ constexpr pair(pair&& p); \end{itemdecl} \begin{itemdescr} \pnum -\requires \tcode{base} has a value between 2 and 36 (inclusive). +\effects +Initializes \tcode{first} with +\tcode{std::forward(p.first)} +and \tcode{second} with +\tcode{std::forward(\brk{}p.second)}. \pnum -\effects The pattern is the expected form of the subject sequence -in the \tcode{"C"} locale -for the given nonzero base, -as described for \tcode{strtol}, -except that no \tcode{"0x"} or \tcode{"0X"} prefix shall appear -if the value of \tcode{base} is 16, -and except that a minus sign -is the only sign that may appear, -and only if \tcode{value} has a signed type. +\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}. +The constructor is explicit if and only if +\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); +\end{itemdecl} +\begin{itemdescr} \pnum -\throws Nothing. +\requires \tcode{is_constructible_v} is \tcode{true} +and \tcode{is_constructible_v} is \tcode{true}. \pnum -\remarks -The implementation shall provide overloads -for all signed and unsigned integer types -and \tcode{char} -as the referenced type of the parameter \tcode{value}. +\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 +an element \tcode{x} of type \tcode{U} within a \tcode{tuple} object means calling +\tcode{std::forward(x)}.) This form of construction, whereby constructor +arguments for \tcode{first} and \tcode{second} are each provided in a separate +\tcode{tuple} object, is called \defn{piecewise construction}. \end{itemdescr} -\indexlibrary{\idxcode{from_chars}}% +\indexlibrarymember{operator=}{pair}% \begin{itemdecl} -from_chars_result from_chars(const char* first, const char* last, float& value, - chars_format fmt = chars_format::general); -from_chars_result from_chars(const char* first, const char* last, double& value, - chars_format fmt = chars_format::general); -from_chars_result from_chars(const char* first, const char* last, long double& value, - chars_format fmt = chars_format::general); +pair& operator=(const pair& p); \end{itemdecl} \begin{itemdescr} \pnum -\requires \tcode{fmt} has the value of -one of the enumerators of \tcode{chars_format}. +\effects Assigns \tcode{p.first} to \tcode{first} and \tcode{p.second} to \tcode{second}. \pnum -\effects The pattern is the expected form of the subject sequence -in the \tcode{"C"} locale, -as described for \tcode{strtod}, -except that -\begin{itemize} -\item -the only sign that may appear is a minus sign; -\item -if \tcode{fmt} has \tcode{chars_format::scientific} set -but not \tcode{chars_format::fixed}, -the otherwise optional exponent part shall appear; -\item -if \tcode{fmt} has \tcode{chars_format::fixed} set -but not \tcode{chars_format::scientific}, -the optional exponent part shall not appear; and -\item -if \tcode{fmt} is \tcode{chars_format::hex}, -the prefix \tcode{"0x"} or \tcode{"0X"} is assumed. -\begin{example} -The string \tcode{0x123} -is parsed to have the value -\tcode{0} -with remaining characters \tcode{x123}. -\end{example} -\end{itemize} -In any case, the resulting \tcode{value} is one of -at most two floating-point values -closest to the value of the string matching the pattern. +\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 -\throws Nothing. +\returns \tcode{*this}. \end{itemdescr} -\xref ISO C~7.22.1.3, ISO C~7.22.1.4. +\indexlibrarymember{operator=}{pair}% +\begin{itemdecl} +template pair& operator=(const pair& p); +\end{itemdecl} -\rSec1[intseq]{Compile-time integer sequences} +\begin{itemdescr} +\pnum +\effects Assigns \tcode{p.first} to \tcode{first} and \tcode{p.second} to \tcode{second}. -\rSec2[intseq.general]{In general} +\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 -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. -\begin{note} -The \tcode{index_sequence} alias template is provided for the common case of -an integer sequence of type \tcode{size_t}; see also \ref{tuple.apply}. -\end{note} +\returns \tcode{*this}. +\end{itemdescr} -\rSec2[intseq.intseq]{Class template \tcode{integer_sequence}} +\indexlibrarymember{operator=}{pair}% +\begin{itemdecl} +pair& operator=(pair&& p) noexcept(@\seebelow@); +\end{itemdecl} -\indexlibrary{\idxcode{integer_sequence}}% +\begin{itemdescr} +\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 be defined as deleted unless +\tcode{is_move_assignable_v} is \tcode{true} +and \tcode{is_move_assignable_v} is \tcode{true}. + +\pnum +\remarks The expression inside \tcode{noexcept} is equivalent to: \begin{codeblock} -namespace std { - template - struct integer_sequence { - using value_type = T; - static constexpr size_t size() noexcept { return sizeof...(I); } - }; -} +is_nothrow_move_assignable_v && is_nothrow_move_assignable_v \end{codeblock} \pnum -\tcode{T} shall be an integer type. - -\rSec2[intseq.make]{Alias template \tcode{make_integer_sequence}} +\returns \tcode{*this}. +\end{itemdescr} -\indexlibrary{\idxcode{make_integer_sequence}}% +\indexlibrarymember{operator=}{pair}% \begin{itemdecl} -template - using make_integer_sequence = integer_sequence; +template pair& operator=(pair&& p); \end{itemdecl} \begin{itemdescr} \pnum -If \tcode{N} is negative the program is ill-formed. The alias template -\tcode{make_integer_sequence} denotes a specialization of -\tcode{integer_sequence} with \tcode{N} template non-type arguments. -The type \tcode{make_integer_sequence} denotes the type -\tcode{integer_sequence}. -\begin{note} \tcode{make_integer_sequence} denotes the type -\tcode{integer_sequence} \end{note} -\end{itemdescr} - -\rSec1[pairs]{Pairs} +\effects +Assigns to \tcode{first} with \tcode{std::forward(p.first)} +and to \tcode{second} with\\ \tcode{std::forward(p.second)}. -\rSec2[pairs.general]{In general} +\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 -The library provides a template for heterogeneous pairs of values. -The library also provides a matching function template to simplify -their construction and several templates that provide access to \tcode{pair} -objects as if they were \tcode{tuple} objects (see~\ref{tuple.helper} -and~\ref{tuple.elem}).% -\indexlibrary{\idxcode{pair}}% -\indextext{\idxcode{pair}!tuple interface to}% -\indextext{\idxcode{tuple}!and pair@and \tcode{pair}}% +\returns \tcode{*this}. +\end{itemdescr} -\rSec2[pairs.pair]{Class template \tcode{pair}} - -\indexlibrary{\idxcode{pair}}% -\begin{codeblock} -namespace std { - template - struct pair { - using first_type = T1; - using second_type = T2; - - T1 first; - T2 second; - - pair(const pair&) = default; - pair(pair&&) = default; - @\EXPLICIT@ constexpr pair(); - @\EXPLICIT@ constexpr pair(const T1& x, const T2& y); - template @\EXPLICIT@ constexpr pair(U1&& x, U2&& y); - template @\EXPLICIT@ constexpr pair(const pair& p); - template @\EXPLICIT@ constexpr pair(pair&& p); - template - pair(piecewise_construct_t, tuple first_args, tuple second_args); - - pair& operator=(const pair& p); - template pair& operator=(const pair& p); - pair& operator=(pair&& p) noexcept(@\seebelow@); - template pair& operator=(pair&& p); - - void swap(pair& p) noexcept(@\seebelow@); - }; - - template - pair(T1, T2) -> pair; -} -\end{codeblock} - -\pnum -Constructors and member functions of \tcode{pair} shall not throw exceptions unless one of -the element-wise operations specified to be called for that operation -throws an exception. +\indexlibrarymember{swap}{pair}% +\begin{itemdecl} +void swap(pair& p) noexcept(@\seebelow@); +\end{itemdecl} +\begin{itemdescr} \pnum -The defaulted move and copy constructor, respectively, of \tcode{pair} 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 constexpr function. -The destructor of \tcode{pair} shall be a trivial destructor if -\tcode{(is_trivially_destructible_v \&\& is_trivially_destructible_v)} -is \tcode{true}. - -\indexlibrary{\idxcode{pair}!constructor}% -\begin{itemdecl} -@\EXPLICIT@ constexpr pair(); -\end{itemdecl} +\requires +\tcode{first} shall be swappable with\iref{swappable.requirements} +\tcode{p.first} and \tcode{second} shall be swappable with \tcode{p.second}. -\begin{itemdescr} \pnum -\effects -Value-initializes \tcode{first} and \tcode{second}. +\effects Swaps +\tcode{first} with \tcode{p.first} and +\tcode{second} with \tcode{p.second}. \pnum -\remarks -This constructor shall not participate in overload resolution unless -\tcode{is_default_construct\-ible_v} is \tcode{true} and -\tcode{is_default_constructible_v} is \tcode{true}. -\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 either \tcode{first_type} or -\tcode{second_type} is not implicitly default-constructible. -\begin{note} This behavior can be implemented with a trait that checks -whether a \tcode{const first_type\&} or a \tcode{const second_type\&} -can be initialized with \tcode{\{\}}. \end{note} +\remarks The expression inside \tcode{noexcept} is equivalent to: +\begin{codeblock} +is_nothrow_swappable_v && is_nothrow_swappable_v +\end{codeblock} \end{itemdescr} -\indexlibrary{\idxcode{pair}!constructor}% +\rSec2[pairs.spec]{Specialized algorithms} + +\indexlibrarymember{operator==}{pair}% \begin{itemdecl} -@\EXPLICIT@ constexpr pair(const T1& x, const T2& y); +template + constexpr bool operator==(const pair& x, const pair& y); \end{itemdecl} \begin{itemdescr} \pnum -\effects -Initializes \tcode{first} with \tcode{x} and \tcode{second} with \tcode{y}. - -\pnum -\remarks This constructor shall not participate in overload resolution -unless \tcode{is_copy_construct\-ible_v} is \tcode{true} and -\tcode{is_copy_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}. +\returns +\tcode{x.first == y.first \&\& x.second == y.second}. \end{itemdescr} -\indexlibrary{\idxcode{pair}!constructor}% +\indexlibrarymember{operator<}{pair}% \begin{itemdecl} -template @\EXPLICIT@ constexpr pair(U1&& x, U2&& y); +template + constexpr bool operator<(const pair& x, const pair& y); \end{itemdecl} \begin{itemdescr} \pnum -\effects -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}. -The constructor is explicit if and only if -\tcode{is_convertible_v} is \tcode{false} or -\tcode{is_convertible_v} is \tcode{false}. +\returns +\tcode{x.first < y.first || (!(y.first < x.first) \&\& x.second < y.second)}. \end{itemdescr} -\indexlibrary{\idxcode{pair}!constructor}% +\indexlibrarymember{operator"!=}{pair}% \begin{itemdecl} -template @\EXPLICIT@ constexpr pair(const pair& p); +template + constexpr bool operator!=(const pair& x, const pair& y); \end{itemdecl} \begin{itemdescr} \pnum -\effects -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}. -The constructor is explicit if and only if -\tcode{is_convertible_v} is \tcode{false} or -\tcode{is_convertible_v} is \tcode{false}. +\returns \tcode{!(x == y)}. \end{itemdescr} -\indexlibrary{\idxcode{pair}!constructor}% +\indexlibrarymember{operator>}{pair}% \begin{itemdecl} -template @\EXPLICIT@ constexpr pair(pair&& p); +template + constexpr bool operator>(const pair& x, const pair& y); \end{itemdecl} \begin{itemdescr} \pnum -\effects -Initializes \tcode{first} with -\tcode{std::forward(p.first)} -and \tcode{second} with -\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}. -The constructor is explicit if and only if -\tcode{is_convertible_v} is \tcode{false} or -\tcode{is_convertible_v} is \tcode{false}. +\returns \tcode{y < x}. \end{itemdescr} -\indexlibrary{\idxcode{pair}!constructor}% +\indexlibrarymember{operator>=}{pair}% \begin{itemdecl} -template - pair(piecewise_construct_t, tuple first_args, tuple second_args); +template + constexpr bool operator>=(const pair& x, const pair& y); \end{itemdecl} \begin{itemdescr} \pnum -\requires \tcode{is_constructible_v} is \tcode{true} -and \tcode{is_constructible_v} is \tcode{true}. - -\pnum -\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 -an element \tcode{x} of type \tcode{U} within a \tcode{tuple} object means calling -\tcode{std::forward(x)}.) This form of construction, whereby constructor -arguments for \tcode{first} and \tcode{second} are each provided in a separate -\tcode{tuple} object, is called \defn{piecewise construction}. +\returns \tcode{!(x < y)}. \end{itemdescr} -\indexlibrarymember{operator=}{pair}% +\indexlibrarymember{operator<=}{pair}% \begin{itemdecl} -pair& operator=(const pair& p); +template + constexpr bool operator<=(const pair& x, const pair& y); \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 -\returns \tcode{*this}. +\returns \tcode{!(y < x)}. \end{itemdescr} -\indexlibrarymember{operator=}{pair}% + +\indexlibrary{\idxcode{swap}!\idxcode{pair}}% \begin{itemdecl} -template pair& operator=(const pair& p); +template void swap(pair& x, pair& y) + noexcept(noexcept(x.swap(y))); \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 not participate in overload resolution unless -\tcode{is_assignable_v} is \tcode{true} -and \tcode{is_assignable_v} is \tcode{true}. +\effects As if by \tcode{x.swap(y)}. \pnum -\returns \tcode{*this}. +\remarks +This function shall not participate in overload resolution unless +\tcode{is_swappable_v} is \tcode{true} and +\tcode{is_swappable_v} is \tcode{true}. \end{itemdescr} -\indexlibrarymember{operator=}{pair}% +\indexlibrary{\idxcode{make_pair}}% \begin{itemdecl} -pair& operator=(pair&& p) noexcept(@\seebelow@); +template + constexpr pair make_pair(T1&& x, T2&& y); \end{itemdecl} \begin{itemdescr} \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 be defined as deleted unless -\tcode{is_move_assignable_v} is \tcode{true} -and \tcode{is_move_assignable_v} is \tcode{true}. +\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}. 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 -\remarks The expression inside \tcode{noexcept} is equivalent to: +\begin{example} +In place of: \begin{codeblock} -is_nothrow_move_assignable_v && is_nothrow_move_assignable_v + 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} +\end{example} -\pnum -\returns \tcode{*this}. -\end{itemdescr} +\rSec2[pair.astuple]{Tuple-like access to pair} -\indexlibrarymember{operator=}{pair}% +\indexlibrary{\idxcode{tuple_size}}% \begin{itemdecl} -template pair& operator=(pair&& p); +template + struct tuple_size> : integral_constant { }; \end{itemdecl} +\indexlibrary{\idxcode{tuple_element}}% +\begin{itemdecl} +tuple_element>::type +\end{itemdecl} \begin{itemdescr} \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}. +\requires \tcode{I < 2}. The program is ill-formed if \tcode{I} is out of bounds. \pnum -\returns \tcode{*this}. +\textit{Value:} The type \tcode{T1} if \tcode{I == 0}, otherwise the type \tcode{T2}. \end{itemdescr} -\indexlibrarymember{swap}{pair}% -\begin{itemdecl} -void swap(pair& p) noexcept(@\seebelow@); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\requires -\tcode{first} shall be swappable with~(\ref{swappable.requirements}) -\tcode{p.first} and \tcode{second} shall be swappable with \tcode{p.second}. - -\pnum -\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} - -\indexlibrarymember{operator==}{pair}% -\begin{itemdecl} -template - constexpr bool operator==(const pair& x, const pair& y); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{x.first == y.first \&\& x.second == y.second}. -\end{itemdescr} - -\indexlibrarymember{operator<}{pair}% -\begin{itemdecl} -template - constexpr bool operator<(const pair& x, const pair& y); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns -\tcode{x.first < y.first || (!(y.first < x.first) \&\& x.second < y.second)}. -\end{itemdescr} - -\indexlibrarymember{operator"!=}{pair}% -\begin{itemdecl} -template - constexpr bool operator!=(const pair& x, const pair& y); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns \tcode{!(x == y)}. -\end{itemdescr} - -\indexlibrarymember{operator>}{pair}% -\begin{itemdecl} -template - constexpr bool operator>(const pair& x, const pair& y); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns \tcode{y < x}. -\end{itemdescr} - -\indexlibrarymember{operator>=}{pair}% -\begin{itemdecl} -template - constexpr bool operator>=(const pair& x, const pair& y); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns \tcode{!(x < y)}. -\end{itemdescr} - -\indexlibrarymember{operator<=}{pair}% -\begin{itemdecl} -template - constexpr bool operator<=(const pair& x, const pair& y); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\returns \tcode{!(y < x)}. -\end{itemdescr} - - -\indexlibrary{\idxcode{swap}!\idxcode{pair}}% -\begin{itemdecl} -template void swap(pair& x, pair& y) - noexcept(noexcept(x.swap(y))); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\effects As if by \tcode{x.swap(y)}. - -\pnum -\remarks -This function shall not participate in overload resolution unless -\tcode{is_swappable_v} is \tcode{true} and -\tcode{is_swappable_v} is \tcode{true}. -\end{itemdescr} - -\indexlibrary{\idxcode{make_pair}}% -\begin{itemdecl} -template - constexpr pair make_pair(T1&& x, T2&& y); -\end{itemdecl} - -\begin{itemdescr} -\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}. 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} -\end{example} - -\rSec2[pair.astuple]{Tuple-like access to pair} - -\indexlibrary{\idxcode{tuple_size}}% -\begin{itemdecl} -template - struct tuple_size> : integral_constant { }; -\end{itemdecl} - -\indexlibrary{\idxcode{tuple_element}}% -\begin{itemdecl} -tuple_element<0, pair>::type -\end{itemdecl} -\begin{itemdescr} -\pnum\textit{Value:} The type \tcode{T1}. -\end{itemdescr} - -\indexlibrary{\idxcode{tuple_element}}% -\begin{itemdecl} -tuple_element<1, pair>::type -\end{itemdecl} -\begin{itemdescr} -\pnum\textit{Value:} The type T2. -\end{itemdescr} - -\indexlibrarymember{get}{pair}% +\indexlibrarymember{get}{pair}% \begin{itemdecl} template constexpr tuple_element_t>& get(pair& p) noexcept; @@ -1374,7 +1047,7 @@ The \tcode{struct} \tcode{piecewise_construct_t} is an empty structure type used as a unique type to disambiguate constructor and function overloading. Specifically, \tcode{pair} has a constructor with \tcode{piecewise_construct_t} as the -first argument, immediately followed by two \tcode{tuple}~(\ref{tuple}) arguments used +first argument, immediately followed by two \tcode{tuple}\iref{tuple} arguments used for piecewise construction of the elements of the \tcode{pair} object. \rSec1[tuple]{Tuples} @@ -1808,11 +1481,11 @@ \begin{itemdescr} \pnum \requires \tcode{Alloc} shall meet the requirements for an -\tcode{Allocator}~(\ref{allocator.requirements}). +\tcode{Allocator}\iref{allocator.requirements}. \pnum \effects Equivalent to the preceding constructors except that each element is constructed with -uses-allocator construction~(\ref{allocator.uses.construction}). +uses-allocator construction\iref{allocator.uses.construction}. \end{itemdescr} \rSec3[tuple.assign]{Assignment} @@ -1964,7 +1637,7 @@ \begin{itemdescr} \pnum \requires -Each element in \tcode{*this} shall be swappable with~(\ref{swappable.requirements}) +Each element in \tcode{*this} shall be swappable with\iref{swappable.requirements} the corresponding element in \tcode{rhs}. \pnum @@ -2130,7 +1803,7 @@ template constexpr decltype(auto) apply_impl(F&& f, Tuple&& t, index_sequence) { // exposition only - return @\placeholdernc{INVOKE}@(std::forward(f), std::get(std::forward(t))...); + return @\placeholdernc{INVOKE}@(std::forward(f), std::get(std::forward(t))...); // see \ref{func.require} } \end{codeblock} Equivalent to: @@ -2176,7 +1849,7 @@ \begin{itemdescr} \pnum \remarks All specializations of \tcode{tuple_size} shall meet the -\tcode{UnaryTypeTrait} requirements~(\ref{meta.rqmts}) with a +\tcode{UnaryTypeTrait} requirements\iref{meta.rqmts} with a base characteristic of \tcode{integral_constant} for some \tcode{N}. \end{itemdescr} @@ -2219,7 +1892,7 @@ Let \tcode{\placeholder{TS}} denote \tcode{tuple_size} of the \cv-unqualified type \tcode{T}. 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}) +of the three templates shall meet the \tcode{UnaryTypeTrait} requirements\iref{meta.rqmts} with a base characteristic of \begin{codeblock} integral_constant @@ -2255,7 +1928,7 @@ \pnum Let \tcode{\placeholder{TE}} denote \tcode{tuple_element_t} of the \cv-unqualified type \tcode{T}. Then each of the three templates shall meet the \tcode{TransformationTrait} -requirements~(\ref{meta.rqmts}) with a member typedef \tcode{type} that names the following +requirements\iref{meta.rqmts} with a member typedef \tcode{type} that names the following type: \begin{itemize} @@ -2469,7 +2142,7 @@ \begin{itemdescr} \pnum -\requires \tcode{Alloc} shall be an \tcode{Allocator}~(\ref{allocator.requirements}). +\requires \tcode{Alloc} shall be an \tcode{Allocator}\iref{allocator.requirements}. \pnum \begin{note} Specialization of this trait informs other library components that @@ -2695,7 +2368,7 @@ \pnum \remarks No contained value is initialized. -For every object type \tcode{T} these constructors shall be constexpr constructors (\ref{dcl.constexpr}). +For every object type \tcode{T} these constructors shall be constexpr constructors\iref{dcl.constexpr}. \end{itemdescr} \indexlibrary{\idxcode{optional}!constructor}% @@ -4060,7 +3733,7 @@ \begin{itemdescr} \pnum -The specialization \tcode{hash>} is enabled~(\ref{unord.hash}) +The specialization \tcode{hash>} is enabled\iref{unord.hash} if and only if \tcode{hash>} is enabled. When enabled, for an object \tcode{o} of type \tcode{optional}, if \tcode{bool(o) == true}, then \tcode{hash>()(o)} @@ -4189,10 +3862,6 @@ template struct hash; template struct hash>; template <> struct hash; - - // \ref{variant.traits}, allocator-related traits - template struct uses_allocator; - template struct uses_allocator, Alloc>; } \end{codeblock} @@ -4222,26 +3891,6 @@ 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(); @@ -4406,8 +4055,9 @@ \pnum \remarks -This function shall not participate in overload resolution unless -\tcode{is_same_v, variant>} is \tcode{false}, +This function shall not participate in overload resolution +unless \tcode{sizeof...(Types)} is nonzero, +unless \tcode{is_same_v, variant>} is \tcode{false}, unless \tcode{decay_t} is neither a specialization of \tcode{in_place_type_t} nor a specialization of \tcode{in_place_index_t}, @@ -4553,40 +4203,6 @@ constructor shall be a constexpr constructor. \end{itemdescr} -\indexlibrary{\idxcode{variant}!constructor}% -\begin{itemdecl} -// allocator-extended constructors -template - variant(allocator_arg_t, const Alloc& a); -template - variant(allocator_arg_t, const Alloc& a, const variant& v); -template - variant(allocator_arg_t, const Alloc& a, variant&& v); -template - variant(allocator_arg_t, const Alloc& a, T&& t); -template - variant(allocator_arg_t, const Alloc& a, in_place_type_t, Args&&... args); -template - variant(allocator_arg_t, const Alloc& a, in_place_type_t, - initializer_list il, Args&&... args); -template - variant(allocator_arg_t, const Alloc& a, in_place_index_t, Args&&... args); -template - variant(allocator_arg_t, const Alloc& a, in_place_index_t, - initializer_list il, Args&&... args); -\end{itemdecl} - -\begin{itemdescr} -\pnum -\requires -\tcode{Alloc} shall meet the requirements for an Allocator~(\ref{allocator.requirements}). - -\pnum -\effects -Equivalent to the preceding constructors except that the contained value is -constructed with uses-allocator construction~(\ref{allocator.uses.construction}). -\end{itemdescr} - \rSec3[variant.dtor]{Destructor} \indexlibrary{\idxcode{variant}!destructor}% @@ -4929,7 +4545,7 @@ \begin{itemdescr} \pnum -\requires Lvalues of type $\tcode{T}_i$ shall be swappable~(\ref{swappable.requirements}) and +\requires Lvalues of type $\tcode{T}_i$ shall be swappable\iref{swappable.requirements} and \tcode{is_move_constructible_v<$\tcode{T}_i$>} shall be \tcode{true} for all $i$. \pnum @@ -4976,7 +4592,7 @@ \pnum \remarks All specializations of \tcode{variant_size} shall meet the -\tcode{UnaryTypeTrait} requirements~(\ref{meta.rqmts}) +\tcode{UnaryTypeTrait} requirements\iref{meta.rqmts} with a base characteristic of \tcode{integral_constant} for some \tcode{N}. \end{itemdescr} @@ -4991,7 +4607,7 @@ \pnum 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{UnaryTypeTrait} requirements\iref{meta.rqmts} with a base characteristic of \tcode{integral_constant}. \end{itemdescr} @@ -5013,7 +4629,7 @@ \pnum Let \tcode{VA} denote \tcode{variant_alternative} of the cv-unqualified type \tcode{T}. Then each of the three templates shall -meet the \tcode{TransformationTrait} requirements~(\ref{meta.rqmts}) with a +meet the \tcode{TransformationTrait} requirements\iref{meta.rqmts} with a member typedef \tcode{type} that names the following type: \begin{itemize} \item for the first specialization, \tcode{add_const_t}, @@ -5030,6 +4646,7 @@ \begin{itemdescr} \pnum \requires \tcode{I < sizeof...(Types)}. +The program is ill-formed if \tcode{I} is out of bounds. \pnum \textit{Value:} The type $\tcode{T}_I$. @@ -5288,7 +4905,7 @@ \pnum \effects Let \tcode{is...} be \tcode{vars.index()...}. Returns \tcode{\placeholdernc{INVOKE}(forward(vis), get(}\brk{} -\tcode{forward(vars))...);}. +\tcode{forward(vars))...);}\iref{func.require}. \pnum \remarks @@ -5407,7 +5024,7 @@ \begin{itemdescr} \pnum -The specialization \tcode{hash>} is enabled~(\ref{unord.hash}) +The specialization \tcode{hash>} is enabled\iref{unord.hash} if and only if every specialization in \tcode{hash>...} is enabled. The member functions are not guaranteed to be \tcode{noexcept}. \end{itemdescr} @@ -5419,28 +5036,7 @@ \begin{itemdescr} \pnum -The specialization is enabled~(\ref{unord.hash}). -\end{itemdescr} - - -\rSec2[variant.traits]{Allocator-related traits} - -\indexlibrary{\idxcode{uses_allocator}!\idxcode{variant}}% -\begin{itemdecl} -template - struct uses_allocator, Alloc> : true_type { }; -\end{itemdecl} - -\begin{itemdescr} -\pnum -\requires \tcode{Alloc} shall be an Allocator~(\ref{allocator.requirements}). - -\pnum -\begin{note} -Specialization of this trait informs other library components -that variant can be constructed with an allocator, -even though it does not have a nested \tcode{allocator_type}. -\end{note} +The specialization is enabled\iref{unord.hash}. \end{itemdescr} @@ -5502,20 +5098,20 @@ \end{codeblock} \pnum -Objects of type \tcode{bad_any_cast} are thrown by a failed \tcode{any_cast}~(\ref{any.nonmembers}). +Objects of type \tcode{bad_any_cast} are thrown by a failed \tcode{any_cast}\iref{any.nonmembers}. -\indexlibrarymember{what}{bad_any_access}% +\indexlibrarymember{what}{bad_any_cast}% \begin{itemdecl} const char* what() const noexcept override; \end{itemdecl} \begin{itemdescr} \pnum -\returns An \impldef{return value of \tcode{bad_any_access::what}} \ntbs. +\returns An \impldef{return value of \tcode{bad_any_cast::what}} \ntbs. \pnum \remarks -The message may be a null-terminated multibyte string~(\ref{multibyte.strings}), +The message may be a null-terminated multibyte string\iref{multibyte.strings}, suitable for conversion and display as a wstring~(\ref{string.classes}, \ref{locale.codecvt}). \end{itemdescr} @@ -5599,7 +5195,7 @@ \effects If \tcode{other.has_value()} is \tcode{false}, constructs an object that has no value. Otherwise, equivalent to \tcode{any(in_place, any_cast(other))} -where \tcode{T} is the type of the contained object. +where \tcode{T} is the type of the contained value. \pnum \throws @@ -5616,9 +5212,9 @@ \effects If \tcode{other.has_value()} is \tcode{false}, constructs an object that has no value. Otherwise, constructs an object of type \tcode{any} that -contains either the contained object of \tcode{other}, or +contains either the contained value of \tcode{other}, or contains an object of the same type constructed from -the contained object of \tcode{other} considering that contained object as an rvalue. +the contained value of \tcode{other} considering that contained value as an rvalue. \pnum \postconditions @@ -5986,19 +5582,19 @@ \begin{itemdescr} \pnum -Let \tcode{U} be the type \tcode{remove_cv_t>}. +Let \tcode{U} be the type \tcode{remove_cv_t>}. \pnum \requires -For the first overload, \tcode{is_constructible_v} is \tcode{true}. -For the second overload, \tcode{is_constructible_v} is \tcode{true}. -For the third overload, \tcode{is_constructible_v} is \tcode{true}. +For the first overload, \tcode{is_constructible_v} is \tcode{true}. +For the second overload, \tcode{is_constructible_v} is \tcode{true}. +For the third overload, \tcode{is_constructible_v} is \tcode{true}. Otherwise the program is ill-formed. \pnum \returns -For the first and second overload, \tcode{static_cast(*any_cast(\&operand))}. -For the third overload, \tcode{static_cast(std::move(*any_cast(\&operand)))}. +For the first and second overload, \tcode{static_cast(*any_cast(\&operand))}. +For the third overload, \tcode{static_cast(std::move(*any_cast(\&operand)))}. \pnum \throws @@ -6069,7 +5665,7 @@ \begin{codeblock} #include -#include // for \tcode{istream} (\ref{istream.syn}), \tcode{ostream} (\ref{ostream.syn}), see \ref{iosfwd.syn} +#include // for \tcode{istream}\iref{istream.syn}, \tcode{ostream}\iref{ostream.syn}, see \ref{iosfwd.syn} namespace std { template class bitset; @@ -6108,13 +5704,14 @@ class reference { friend class bitset; reference() noexcept; + public: ~reference() noexcept; - reference& operator=(bool x) noexcept; // for \tcode{b[i] = x;} - reference& operator=(const reference&) noexcept; // for \tcode{b[i] = b[j];} - bool operator~() const noexcept; // flips the bit - operator bool() const noexcept; // for \tcode{x = b[i];} - reference& flip() noexcept; // for \tcode{b[i].flip();} + reference& operator=(bool x) noexcept; // for \tcode{b[i] = x;} + reference& operator=(const reference&) noexcept; // for \tcode{b[i] = b[j];} + bool operator~() const noexcept; // flips the bit + operator bool() const noexcept; // for \tcode{x = b[i];} + reference& flip() noexcept; // for \tcode{b[i].flip();} }; // \ref{bitset.cons}, constructors @@ -6124,8 +5721,8 @@ explicit bitset( const basic_string& str, typename basic_string::size_type pos = 0, - typename basic_string::size_type n = - basic_string::npos, + typename basic_string::size_type n + = basic_string::npos, charT zero = charT('0'), charT one = charT('1')); template @@ -6150,8 +5747,8 @@ bitset& flip(size_t pos); // element access: - constexpr bool operator[](size_t pos) const; // for \tcode{b[i];} - reference operator[](size_t pos); // for \tcode{b[i];} + constexpr bool operator[](size_t pos) const; // for \tcode{b[i];} + reference operator[](size_t pos); // for \tcode{b[i];} unsigned long to_ulong() const; unsigned long long to_ullong() const; @@ -6181,7 +5778,7 @@ \pnum The class template -\tcode{bitset}% +\tcode{bitset} describes an object that can store a sequence consisting of a fixed number of bits, \tcode{N}. @@ -6211,19 +5808,19 @@ an \term{invalid-argument} error is associated with exceptions of type -\tcode{invalid_argument}~(\ref{invalid.argument}); +\tcode{invalid_argument}\iref{invalid.argument}; \indexlibrary{\idxcode{invalid_argument}}% \item an \term{out-of-range} error is associated with exceptions of type -\tcode{out_of_range}~(\ref{out.of.range}); +\tcode{out_of_range}\iref{out.of.range}; \indexlibrary{\idxcode{out_of_range}}% \item an \term{overflow} error is associated with exceptions of type -\tcode{overflow_error}~(\ref{overflow.error}). +\tcode{overflow_error}\iref{overflow.error}. \indexlibrary{\idxcode{overflow_error}}% \end{itemize} @@ -6255,19 +5852,20 @@ initializing the first \tcode{M} bit positions to the corresponding bit values in \tcode{val}. \tcode{M} is the smaller of \tcode{N} and the number of bits in the value -representation~(\ref{basic.types}) of \tcode{unsigned long long}. +representation\iref{basic.types} of \tcode{unsigned long long}. If \tcode{M < N}, the remaining bit positions are initialized to zero. \end{itemdescr} \indexlibrary{\idxcode{bitset}!constructor}% \begin{itemdecl} template -explicit -bitset(const basic_string& str, - typename basic_string::size_type pos = 0, - typename basic_string::size_type n = - basic_string::npos, - charT zero = charT('0'), charT one = charT('1')); + explicit bitset( + const basic_string& str, + typename basic_string::size_type pos = 0, + typename basic_string::size_type n + = basic_string::npos, + charT zero = charT('0'), + charT one = charT('1')); \end{itemdecl} \begin{itemdescr} @@ -6320,20 +5918,19 @@ 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')); \end{itemdecl} \begin{itemdescr} \pnum \effects Constructs an object of class \tcode{bitset} as if by: \begin{codeblock} -bitset( - n == basic_string::npos - ? basic_string(str) - : basic_string(str, n), - 0, n, zero, one) +bitset(n == basic_string::npos + ? basic_string(str) + : basic_string(str, n), + 0, n, zero, one) \end{codeblock} - \end{itemdescr} @@ -6474,7 +6071,7 @@ \effects Stores a new value in the bit at position \tcode{pos} in \tcode{*this}. -If \tcode{val} is nonzero, the stored value is one, otherwise it is zero. +If \tcode{val} is \tcode{true}, the stored value is one, otherwise it is zero. \pnum \returns @@ -6618,10 +6215,10 @@ \indexlibrarymember{to_string}{bitset}% \begin{itemdecl} 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; \end{itemdecl} \begin{itemdescr} @@ -6810,7 +6407,7 @@ \pnum \remarks For the purpose of determining the presence of a data -race~(\ref{intro.multithread}), any access or update through the resulting +race\iref{intro.multithread}, any access or update through the resulting reference potentially accesses or modifies, respectively, the entire underlying bitset. \end{itemdescr} @@ -6823,7 +6420,7 @@ \end{itemdecl} \begin{itemdescr} -\pnum The specialization is enabled~(\ref{unord.hash}). +\pnum The specialization is enabled\iref{unord.hash}. \end{itemdescr} @@ -6866,12 +6463,12 @@ \begin{itemdecl} template basic_istream& - operator>>(basic_istream& is, bitset& x); + operator>>(basic_istream& is, bitset& x); \end{itemdecl} \begin{itemdescr} \pnum -A formatted input function~(\ref{istream.formatted}). +A formatted input function\iref{istream.formatted}. \pnum \effects @@ -6900,7 +6497,7 @@ If no characters are stored in \tcode{str}, calls \tcode{is.setstate(ios_base::failbit)} (which may throw -\tcode{ios_base::failure}~(\ref{iostate.flags})). +\tcode{ios_base::failure}\iref{iostate.flags}). \pnum \returns @@ -6911,7 +6508,7 @@ \begin{itemdecl} template basic_ostream& - operator<<(basic_ostream& os, const bitset& x); + operator<<(basic_ostream& os, const bitset& x); \end{itemdecl} \begin{itemdescr} @@ -6931,8 +6528,8 @@ \pnum This subclause describes the contents of the header -\tcode{}~(\ref{memory.syn}) and some -of the contents of the header \tcode{}~(\ref{cstdlib.syn}). +\tcode{}\iref{memory.syn} and some +of the contents of the header \tcode{}\iref{cstdlib.syn}. \rSec2[memory.syn]{Header \tcode{} synopsis} @@ -6945,7 +6542,7 @@ buffers~(\ref{pointer.traits}--\ref{specialized.algorithms}). The header also defines the templates \tcode{unique_ptr}, \tcode{shared_ptr}, \tcode{weak_ptr}, and various function -templates that operate on objects of these types~(\ref{smartptr}). +templates that operate on objects of these types\iref{smartptr}. \indextext{\idxhdr{memory}}% \indexlibrary{\idxhdr{memory}}% @@ -7171,6 +6768,8 @@ shared_ptr dynamic_pointer_cast(const shared_ptr& r) noexcept; template shared_ptr const_pointer_cast(const shared_ptr& r) noexcept; + template + shared_ptr reinterpret_pointer_cast(const shared_ptr& r) noexcept; // \ref{util.smartptr.getdeleter}, \tcode{shared_ptr} \tcode{get_deleter} template @@ -7279,7 +6878,7 @@ \pnum \ctype \tcode{Ptr::element_type} if the \grammarterm{qualified-id} \tcode{Ptr::element_type} is valid and denotes a -type~(\ref{temp.deduct}); otherwise, \tcode{T} if +type\iref{temp.deduct}; otherwise, \tcode{T} if \tcode{Ptr} is a class template instantiation of the form \tcode{SomePointer}, where \tcode{Args} is zero or more type arguments; otherwise, the specialization is ill-formed. @@ -7294,7 +6893,7 @@ \pnum \ctype \tcode{Ptr::difference_type} if the \grammarterm{qualified-id} \tcode{Ptr::difference_type} is valid and denotes a -type~(\ref{temp.deduct}); otherwise, +type\iref{temp.deduct}; otherwise, \tcode{ptrdiff_t}. \end{itemdescr} @@ -7307,7 +6906,7 @@ \pnum \templalias \tcode{Ptr::rebind} if the \grammarterm{qualified-id} \tcode{Ptr::rebind} is valid and denotes a -type~(\ref{temp.deduct}); otherwise, +type\iref{temp.deduct}; otherwise, \tcode{SomePointer} if \tcode{Ptr} is a class template instantiation of the form \tcode{SomePointer}, where \tcode{Args} is zero or more type arguments; otherwise, the instantiation of @@ -7351,11 +6950,11 @@ \begin{itemdescr} \pnum \requires \tcode{p} shall be a safely-derived -pointer~(\ref{basic.stc.dynamic.safety}) or a null pointer value. +pointer\iref{basic.stc.dynamic.safety} or a null pointer value. \pnum \effects If \tcode{p} is not null, the complete object referenced by \tcode{p} -is subsequently declared reachable~(\ref{basic.stc.dynamic.safety}). +is subsequently declared reachable\iref{basic.stc.dynamic.safety}. \pnum \throws May throw \tcode{bad_alloc} if the system cannot allocate @@ -7371,7 +6970,7 @@ \pnum \requires If \tcode{p} is not null, the complete object referenced by \tcode{p} shall have been previously declared reachable, and shall be -live~(\ref{basic.life}) from the time of the call until the last +live\iref{basic.life} from the time of the call until the last \tcode{undeclare_reachable(p)} call on the object. \pnum @@ -7444,7 +7043,7 @@ \begin{itemdescr} \pnum \returns \tcode{pointer_safety::strict} if the implementation has strict pointer -safety~(\ref{basic.stc.dynamic.safety}). It is +safety\iref{basic.stc.dynamic.safety}. It is \impldef{whether \tcode{get_pointer_safety} returns \tcode{pointer_safety::relaxed} or \tcode{pointer_safety::\brk{}preferred} if the implementation has relaxed pointer safety} @@ -7511,7 +7110,7 @@ disambiguate constructor and function overloading. Specifically, several types (see \tcode{tuple}~\ref{tuple}) have constructors with \tcode{allocator_arg_t} as the first argument, immediately followed by an argument of a type that satisfies the -\tcode{Allocator} requirements~(\ref{allocator.requirements}). +\tcode{Allocator} requirements\iref{allocator.requirements}. \rSec2[allocator.uses]{\tcode{uses_allocator}} @@ -7526,9 +7125,9 @@ \pnum \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 +requirements\iref{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 +is valid and denotes a type\iref{temp.deduct} and \tcode{is_convertible_v != false}, otherwise it shall be derived from \tcode{false_type}. A program may specialize this template to derive from \tcode{true_type} for a user-defined type \tcode{T} that does not have a nested @@ -7633,7 +7232,7 @@ \pnum \ctype \tcode{Alloc::pointer} if the \grammarterm{qualified-id} \tcode{Alloc::pointer} is valid and denotes a -type~(\ref{temp.deduct}); otherwise, \tcode{value_type*}. +type\iref{temp.deduct}; otherwise, \tcode{value_type*}. \end{itemdescr} \indexlibrarymember{const_pointer}{allocator_traits}% @@ -7645,7 +7244,7 @@ \pnum \ctype \tcode{Alloc::const_pointer} if the \grammarterm{qualified-id} \tcode{Alloc::const_pointer} is valid and denotes a -type~(\ref{temp.deduct}); otherwise, +type\iref{temp.deduct}; otherwise, \tcode{pointer_traits::rebind<\brk{}const value_type>}. \end{itemdescr} @@ -7658,7 +7257,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\iref{temp.deduct}; otherwise, \tcode{pointer_traits::rebind<\brk{}void>}. \end{itemdescr} @@ -7671,7 +7270,7 @@ \pnum \ctype \tcode{Alloc::const_void_pointer} if the \grammarterm{qualified-id} \tcode{Alloc::const_void_pointer} is valid and denotes a -type~(\ref{temp.deduct}); otherwise, +type\iref{temp.deduct}; otherwise, \tcode{pointer_traits::\brk{}rebind}. \end{itemdescr} @@ -7684,7 +7283,7 @@ \pnum \ctype \tcode{Alloc::difference_type} if the \grammarterm{qualified-id} \tcode{Alloc::difference_type} is valid and denotes a -type~(\ref{temp.deduct}); otherwise, +type\iref{temp.deduct}; otherwise, \tcode{pointer_traits::dif\-ference_type}. \end{itemdescr} @@ -7697,7 +7296,7 @@ \pnum \ctype \tcode{Alloc::size_type} if the \grammarterm{qualified-id} \tcode{Alloc::size_type} is valid and denotes a -type~(\ref{temp.deduct}); otherwise, +type\iref{temp.deduct}; otherwise, \tcode{make_unsigned_t}. \end{itemdescr} @@ -7710,7 +7309,7 @@ \pnum \ctype \tcode{Alloc::propagate_on_container_copy_assignment} if the \grammarterm{qualified-id} \tcode{Alloc::propagate_on_container_copy_assignment} is valid and denotes a -type~(\ref{temp.deduct}); otherwise +type\iref{temp.deduct}; otherwise \tcode{false_type}. \end{itemdescr} @@ -7723,7 +7322,7 @@ \pnum \ctype \tcode{Alloc::propagate_on_container_move_assignment} if the \grammarterm{qualified-id} \tcode{Alloc::propagate_on_container_move_assignment} is valid and denotes a -type~(\ref{temp.deduct}); otherwise +type\iref{temp.deduct}; otherwise \tcode{false_type}. \end{itemdescr} @@ -7736,7 +7335,7 @@ \pnum \ctype \tcode{Alloc::propagate_on_container_swap} if the \grammarterm{qualified-id} \tcode{Alloc::propagate_on_container_swap} is valid and denotes a -type~(\ref{temp.deduct}); otherwise +type\iref{temp.deduct}; otherwise \tcode{false_type}. \end{itemdescr} @@ -7749,7 +7348,7 @@ \pnum \ctype \tcode{Alloc::is_always_equal} if the \grammarterm{qualified-id} \tcode{Alloc::is_always_equal} -is valid and denotes a type~(\ref{temp.deduct}); +is valid and denotes a type\iref{temp.deduct}; otherwise \tcode{is_empty::type}. \end{itemdescr} @@ -7762,7 +7361,7 @@ \pnum \templalias \tcode{Alloc::rebind::other} if the \grammarterm{qualified-id} \tcode{Alloc::rebind::other} is valid and denotes a -type~(\ref{temp.deduct}); otherwise, +type\iref{temp.deduct}; otherwise, \tcode{Alloc} if \tcode{Alloc} is a class template instantiation of the form \tcode{Alloc}, where \tcode{Args} is zero or more type arguments; otherwise, the instantiation of \tcode{rebind_alloc} is ill-formed. @@ -7854,7 +7453,7 @@ \pnum All specializations of the default allocator satisfy the -allocator completeness requirements~(\ref{allocator.requirements.completeness}). +allocator completeness requirements\iref{allocator.requirements.completeness}. \indexlibrary{\idxcode{allocator}}% \begin{codeblock} @@ -7880,7 +7479,7 @@ \pnum Except for the destructor, member functions of the default allocator shall not introduce -data races~(\ref{intro.multithread}) as a result of concurrent calls to those member +data races\iref{intro.multithread} as a result of concurrent calls to those member functions from different threads. Calls to these functions that allocate or deallocate a particular unit of storage shall occur in a single total order, and each such deallocation call shall happen before the next allocation (if any) in this order. @@ -7898,7 +7497,7 @@ \pnum \remarks -the storage is obtained by calling \tcode{::operator new}~(\ref{new.delete}), +the storage is obtained by calling \tcode{::operator new}\iref{new.delete}, but it is unspecified when or how often this function is called. @@ -7926,7 +7525,7 @@ \pnum \remarks Uses -\tcode{::operator delete}~(\ref{new.delete}), +\tcode{::operator delete}\iref{new.delete}, but it is unspecified when this function is called. \end{itemdescr} @@ -7966,11 +7565,11 @@ \item If an algorithm's template parameter is named \tcode{InputIterator}, the template argument shall satisfy the requirements -of an input iterator~(\ref{input.iterators}). +of an input iterator\iref{input.iterators}. \item If an algorithm's template parameter is named \tcode{ForwardIterator}, the template argument shall satisfy the requirements -of a forward iterator~(\ref{forward.iterators}), and +of a forward iterator\iref{forward.iterators}, and is required to have the property that no exceptions are thrown from increment, assignment, comparison, or indirection through valid iterators. \end{itemize} @@ -7991,7 +7590,7 @@ \pnum \remarks An expression \tcode{addressof(E)} -is a constant subexpression~(\ref{defns.const.subexpr}) +is a constant subexpression\iref{defns.const.subexpr} if \tcode{E} is an lvalue constant subexpression. \end{itemdescr} @@ -8258,7 +7857,7 @@ \pnum \indextext{\idxhdr{cstdlib}}% \begin{note} -The header \tcode{}~(\ref{cstdlib.syn}) +The header \tcode{}\iref{cstdlib.syn} declares the functions described in this subclause. \end{note} @@ -8281,7 +7880,7 @@ \pnum \remarks These functions do not attempt to allocate -storage by calling \tcode{::operator new()}~(\ref{support.dynamic}). +storage by calling \tcode{::operator new()}\iref{support.dynamic}. \indexlibrary{\idxcode{new}!\idxcode{operator}}% \pnum @@ -8318,7 +7917,7 @@ \tcode{::operator delete()}\indexlibrary{\idxcode{delete}!\idxcode{operator}}. \end{itemdescr} -\xref ISO C~7.22.3. +\xref ISO C 7.22.3 \rSec1[smartptr]{Smart pointers} @@ -8329,7 +7928,7 @@ manages that other object through a pointer. More precisely, a unique pointer is an object \textit{u} that stores a pointer to a second object \textit{p} and will dispose of \textit{p} when \textit{u} is itself destroyed (e.g., when -leaving block scope~(\ref{stmt.dcl})). In this context, \textit{u} is said +leaving block scope\iref{stmt.dcl}). In this context, \textit{u} is said to \defn{own} \tcode{p}. \pnum @@ -8503,7 +8102,7 @@ \begin{itemdescr} \pnum \effects -constructs a \tcode{default_delete} object from another \tcode{default_delete} object. +Constructs a \tcode{default_delete} object from another \tcode{default_delete} object. \pnum \remarks @@ -8580,7 +8179,7 @@ The default type for the template parameter \tcode{D} is \tcode{default_delete}. A client-supplied template argument \tcode{D} shall be a function -object type~(\ref{function.objects}), lvalue reference to function, or +object type\iref{function.objects}, lvalue reference to function, or lvalue reference to function object type for which, given a value \tcode{d} of type \tcode{D} and a value @@ -8594,14 +8193,14 @@ \pnum If the \grammarterm{qualified-id} \tcode{remove_reference_t::pointer} is valid and denotes a -type~(\ref{temp.deduct}), then \tcode{unique_ptr::pointer} shall be a synonym for \tcode{remove_reference_t::pointer}. Otherwise \tcode{unique_ptr::pointer} shall be a synonym for \tcode{element_type*}. The type \tcode{unique_ptr::pointer} shall -satisfy the requirements of \tcode{NullablePointer} (\ref{nullablepointer.requirements}). +satisfy the requirements of \tcode{NullablePointer}\iref{nullablepointer.requirements}. \pnum -\begin{example} Given an allocator type \tcode{X}~(\ref{allocator.requirements}) and +\begin{example} Given an allocator type \tcode{X}\iref{allocator.requirements} and letting \tcode{A} be a synonym for \tcode{allocator_traits}, the types \tcode{A::pointer}, \tcode{A::const_pointer}, \tcode{A::void_pointer}, and \tcode{A::const_void_pointer} may be used as \tcode{unique_ptr::pointer}. \end{example} @@ -8658,7 +8257,7 @@ \remarks If \tcode{is_pointer_v} is \tcode{true} or \tcode{is_default_constructible_v} is \tcode{false}, this constructor shall not participate in overload resolution. -If class template argument deduction~(\ref{over.match.class.deduct}) +If class template argument deduction\iref{over.match.class.deduct} would select the function template corresponding to this constructor, then the program is ill-formed. \end{itemdescr} @@ -8714,7 +8313,7 @@ returns a reference to the lvalue \tcode{d}. \pnum -\remarks If class template argument deduction~(\ref{over.match.class.deduct}) +\remarks If class template argument deduction\iref{over.match.class.deduct} would select a function template corresponding to either of these constructors, then the program is ill-formed. @@ -9003,7 +8602,7 @@ \begin{itemdescr} \pnum \requires \tcode{get_deleter()} shall be -swappable~(\ref{swappable.requirements}) and shall +swappable\iref{swappable.requirements} and shall not throw an exception under \tcode{swap}. @@ -9334,8 +8933,8 @@ typename unique_ptr::pointer> \end{codeblock} Then the specialization -\tcode{less<\placeholder{CT}>} shall be a function object type~(\ref{function.objects}) that -induces a strict weak ordering~(\ref{alg.sorting}) on the pointer values. +\tcode{less<\placeholder{CT}>} shall be a function object type\iref{function.objects} that +induces a strict weak ordering\iref{alg.sorting} on the pointer values. \pnum \returns \tcode{less<\placeholder{CT}>()(x.get(), y.get())}. @@ -9416,8 +9015,8 @@ \begin{itemdescr} \pnum \requires The specialization \tcode{less::pointer>} shall be -a function object type~(\ref{function.objects}) that induces a strict weak -ordering~(\ref{alg.sorting}) on the pointer values. +a function object type\iref{function.objects} that induces a strict weak +ordering\iref{alg.sorting} on the pointer values. \pnum \returns @@ -9568,9 +9167,29 @@ // \ref{util.smartptr.shared.create}, \tcode{shared_ptr} creation template - shared_ptr make_shared(Args&&... args); + shared_ptr make_shared(Args&&... args); // \tcode{T} is not array template - shared_ptr allocate_shared(const A& a, Args&&... args); + shared_ptr allocate_shared(const A& a, Args&&... args); // \tcode{T} is not array + + template shared_ptr make_shared(size_t N); // \tcode{T} is \tcode{U[]} + template + shared_ptr allocate_shared(const A& a, size_t N); // \tcode{T} is \tcode{U[]} + + template shared_ptr make_shared(); // \tcode{T} is \tcode{U[N]} + template + shared_ptr allocate_shared(const A& a); // \tcode{T} is \tcode{U[N]} + + template + shared_ptr make_shared(size_t N, const remove_extent_t& u); // \tcode{T} is \tcode{U[]} + template + shared_ptr allocate_shared(const A& a, size_t N, + const remove_extent_t& u); // \tcode{T} is \tcode{U[]} + + template shared_ptr + make_shared(const remove_extent_t& u); // \tcode{T} is \tcode{U[N]} + template + shared_ptr allocate_shared(const A& a, + const remove_extent_t& u); // \tcode{T} is \tcode{U[N]} // \ref{util.smartptr.shared.cmp}, \tcode{shared_ptr} comparisons template @@ -9673,7 +9292,7 @@ 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}), +that is a specialization of \tcode{enable_shared_from_this}\iref{util.smartptr.enab}, then \tcode{remove_cv_t*} shall be implicitly convertible to \tcode{T*} and the constructor evaluates the statement: \begin{codeblock} @@ -9681,7 +9300,7 @@ p->weak_this = shared_ptr>(*this, const_cast*>(p)); \end{codeblock} The assignment to the \tcode{weak_this} member is not atomic and -conflicts with any potentially concurrent access to the same object~(\ref{intro.multithread}). +conflicts with any potentially concurrent access to the same object\iref{intro.multithread}. \indexlibrary{\idxcode{shared_ptr}!constructor}% \begin{itemdecl} @@ -9746,7 +9365,7 @@ initialized with \tcode{std::move(d)} shall not throw exceptions. The expression \tcode{d(p)} shall have well-defined behavior and shall not throw exceptions. -\tcode{A} shall be an allocator~(\ref{allocator.requirements}). +\tcode{A} shall be an allocator\iref{allocator.requirements}. \pnum\effects Constructs a \tcode{shared_ptr} object that owns the object \tcode{p} and the deleter \tcode{d}. @@ -10133,87 +9752,303 @@ \rSec4[util.smartptr.shared.create]{\tcode{shared_ptr} creation} +\pnum +The common requirements that apply to +all \tcode{make_shared} and \tcode{allocate_shared} overloads, +unless specified otherwise, are described below. + \indexlibrary{\idxcode{make_shared}}% \indexlibrary{\idxcode{allocate_shared}}% \begin{itemdecl} -template - shared_ptr make_shared(Args&&... args); -template - shared_ptr allocate_shared(const A& a, Args&&... args); +template + shared_ptr make_shared(\placeholder{args}); +template + shared_ptr allocate_shared(const A& a, \placeholder{args}); \end{itemdecl} \begin{itemdescr} \pnum -\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 allocator~(\ref{allocator.requirements}). The copy constructor -and destructor of \tcode{A} shall not throw exceptions. - -\pnum -\effects Allocates memory suitable for an object of type \tcode{T} -and constructs an object in that memory via the placement -\grammarterm{new-expression} -\tcode{::new (pv) T(std::forward(args)...)}. -The template \tcode{allocate_shared} uses a copy of \tcode{a} to -allocate memory. If an exception is thrown, the functions have no effect. +\requires \tcode{A} shall be an allocator\iref{allocator.requirements}. \pnum -\returns A \tcode{shared_ptr} instance that stores and owns -the address of the newly constructed object of type \tcode{T}. +\effects Allocates memory for an object of type \tcode{T} +(or \tcode{U[N]} when \tcode{T} is \tcode{U[]}, +where \tcode{N} is determined from \placeholder{args} as specified by the concrete overload). +The object is initialized from \placeholder{args} as specified by the concrete overload. +The \tcode{allocate_shared} templates use a copy of \tcode{a} +(rebound for an unspecified \tcode{value_type}) to allocate memory. +If an exception is thrown, the functions have no effect. \pnum -\postconditions \tcode{get() != 0 \&\& use_count() == 1}. +\returns A \tcode{shared_ptr} instance that stores and owns the address of +the newly constructed object. \pnum -\throws \tcode{bad_alloc}, or an exception thrown from -\tcode{A::allocate} or from the constructor of \tcode{T}. +\postconditions \tcode{r.get() != 0 \&\& r.use_count() == 1}, +where \tcode{r} is the return value. \pnum -\remarks The \tcode{shared_ptr} constructor called by this function -enables \tcode{shared_from_this} with the address -of the newly constructed object of type \tcode{T}. -Implementations should -perform no more than one memory allocation. \begin{note} This provides -efficiency equivalent to an intrusive smart pointer. \end{note} +\throws \tcode{bad_alloc}, or +an exception thrown from \tcode{allocate} or from the initialization of the object. \pnum -\begin{note} These functions will typically allocate more memory -than \tcode{sizeof(T)} to allow for internal bookkeeping structures such -as the reference counts. \end{note} +\remarks +\begin{itemize} +\item + Implementations should perform no more than one memory allocation. + \begin{note} + This provides efficiency equivalent to an intrusive smart pointer. + \end{note} +\item + When an object of an array type \tcode{U} is specified to have + an initial value of \tcode{u} (of the same type), + this shall be interpreted to mean that + each array element of the object has as its initial value + the corresponding element from \tcode{u}. +\item + When an object of an array type is specified to have + a default initial value, + this shall be interpreted to mean that each array element of the object + has a default initial value. +\item + When a (sub)object of a non-array type \tcode{U} is specified to have + an initial value of \tcode{v}, or \tcode{U(l...)}, + where \tcode{l...} is a list of constructor arguments, + \tcode{make_shared} shall initialize this (sub)object + via the expression \tcode{::new(pv) U(v)} or \tcode{::new(pv) U(l...)} respectively, + where \tcode{pv} has type \tcode{void*} and points to storage + suitable to hold an object of type \tcode{U}. +\item + When a (sub)object of a non-array type \tcode{U} is specified to have + an initial value of \tcode{v}, or \tcode{U(l...)}, + where \tcode{l...} is a list of constructor arguments, + \tcode{allocate_shared} shall initialize this (sub)object + via the expression + \begin{itemize} + \item \tcode{allocator_traits::construct(a2, pv, v)} or + \item \tcode{allocator_traits::construct(a2, pv, l...)} + \end{itemize} + respectively, + where \tcode{pv} points to storage + suitable to hold an object of type \tcode{U} and + \tcode{a2} of type \tcode{A2} is a rebound copy of + the allocator \tcode{a} passed to \tcode{allocate_shared} + such that its \tcode{value_type} is \tcode{U}. +\item + When a (sub)object of non-array type \tcode{U} is specified to have + a default initial value, + \tcode{make_shared} shall initialize this (sub)object + via the expression \tcode{::new(pv) U()}, + where \tcode{pv} has type \tcode{void*} and points to storage + suitable to hold an object of type \tcode{U}. +\item + When a (sub)object of non-array type \tcode{U} is specified to have + a default initial value, + \tcode{allocate_shared} shall initialize this (sub)object + via the expression \tcode{allocator_traits::construct(a2, pv)}, + where \tcode{pv} points to storage + suitable to hold an object of type \tcode{U} and + \tcode{a2} of type \tcode{A2} is a rebound copy of + the allocator \tcode{a} passed to \tcode{allocate_shared} + such that its \tcode{value_type} is \tcode{U}. +\item + Array elements are initialized in ascending order of their addresses. +\item + When the lifetime of the object managed by the return value ends, or + when the initialization of an array element throws an exception, + the initialized elements should be destroyed in the reverse order of their construction. +\end{itemize} +\begin{note} +These functions will typically allocate more memory than \tcode{sizeof(T)} to +allow for internal bookkeeping structures such as reference counts. +\end{note} \end{itemdescr} -\rSec4[util.smartptr.shared.cmp]{\tcode{shared_ptr} comparison} - -\indexlibrarymember{operator==}{shared_ptr}% +\indexlibrary{\idxcode{make_shared}}% +\indexlibrary{\idxcode{allocate_shared}}% \begin{itemdecl} -template - bool operator==(const shared_ptr& a, const shared_ptr& b) noexcept; +template + shared_ptr make_shared(Args&&... args); // \tcode{T} is not array +template + shared_ptr allocate_shared(const A& a, Args&&... args); // \tcode{T} is not array \end{itemdecl} \begin{itemdescr} \pnum -\returns \tcode{a.get() == b.get()}. +\returns A \tcode{shared_ptr} to an object of type \tcode{T} +with an initial value \tcode{T(forward(args)...)}. + +\pnum +\remarks These overloads shall only participate in overload resolution +when \tcode{T} is not an array type. +The \tcode{shared_ptr} constructors called by these functions +enable \tcode{shared_from_this} +with the address of the newly constructed object of type \tcode{T}. + +\pnum +\begin{example} +\begin{codeblock} +shared_ptr p = make_shared(); // \tcode{shared_ptr} to \tcode{int()} +shared_ptr> q = make_shared>(16, 1); + // \tcode{shared_ptr} to vector of \tcode{16} elements with value \tcode{1} +\end{codeblock} +\end{example} \end{itemdescr} -\indexlibrarymember{operator<}{shared_ptr}% +\indexlibrary{\idxcode{make_shared}}% +\indexlibrary{\idxcode{allocate_shared}}% \begin{itemdecl} -template - bool operator<(const shared_ptr& a, const shared_ptr& b) noexcept; +template shared_ptr make_shared(size_t N); // \tcode{T} is \tcode{U[]} +template + shared_ptr allocate_shared(const A& a, size_t N); // \tcode{T} is \tcode{U[]} \end{itemdecl} \begin{itemdescr} \pnum -\returns \tcode{less<>()(a.get(), b.get())}. +\returns A \tcode{shared_ptr} to an object of type \tcode{U[N]} +with a default initial value, +where \tcode{U} is \tcode{remove_extent_t}. \pnum -\begin{note} -Defining a comparison function allows \tcode{shared_ptr} objects to be -used as keys in associative containers. -\end{note} -\end{itemdescr} +\remarks These overloads shall only participate in overload resolution +when \tcode{T} is of the form \tcode{U[]}. -\indexlibrarymember{operator==}{shared_ptr}% +\pnum +\begin{example} +\begin{codeblock} +shared_ptr p = make_shared(1024); + // \tcode{shared_ptr} to a value-initialized \tcode{double[1024]} +shared_ptr q = make_shared(6); + // \tcode{shared_ptr} to a value-initialized \tcode{double[6][2][2]} +\end{codeblock} +\end{example} +\end{itemdescr} + +\indexlibrary{\idxcode{make_shared}}% +\indexlibrary{\idxcode{allocate_shared}}% +\begin{itemdecl} +template shared_ptr make_shared(); // \tcode{T} is \tcode{U[N]} +template + shared_ptr allocate_shared(const A& a); // \tcode{T} is \tcode{U[N]} +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns A \tcode{shared_ptr} to an object of type \tcode{T} +with a default initial value. + +\pnum +\remarks These overloads shall only participate in overload resolution +when \tcode{T} is of the form \tcode{U[N]}. + +\pnum +\begin{example} +\begin{codeblock} +shared_ptr p = make_shared(); + // \tcode{shared_ptr} to a value-initialized \tcode{double[1024]} +shared_ptr q = make_shared(); + // \tcode{shared_ptr} to a value-initialized \tcode{double[6][2][2]} +\end{codeblock} +\end{example} +\end{itemdescr} + +\indexlibrary{\idxcode{make_shared}}% +\indexlibrary{\idxcode{allocate_shared}}% +\begin{itemdecl} +template + shared_ptr make_shared(size_t N, const remove_extent_t& u); // \tcode{T} is \tcode{U[]} +template + shared_ptr allocate_shared(const A& a, size_t N, + const remove_extent_t& u); // \tcode{T} is \tcode{U[]} +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns A \tcode{shared_ptr} to an object of type \tcode{U[N]}, +where \tcode{U} is \tcode{remove_extent_t} and +each array element has an initial value of \tcode{u}. + +\pnum +\remarks These overloads shall only participate in overload resolution +when \tcode{T} is of the form \tcode{U[]}. + +\pnum +\begin{example} +\begin{codeblock} +shared_ptr p = make_shared(1024, 1.0); + // \tcode{shared_ptr} to a \tcode{double[1024]}, where each element is \tcode{1.0} +shared_ptr q = make_shared(6, {1.0, 0.0}); + // \tcode{shared_ptr} to a \tcode{double[6][2]}, where each \tcode{double[2]} element is \tcode{\{1.0, 0.0\}} +shared_ptr[]> r = make_shared[]>(4, {1, 2}); + // \tcode{shared_ptr} to a \tcode{vector[4]}, where each vector has contents \tcode{\{1, 2\}} +\end{codeblock} +\end{example} +\end{itemdescr} + +\indexlibrary{\idxcode{make_shared}}% +\indexlibrary{\idxcode{allocate_shared}}% +\begin{itemdecl} +template + shared_ptr make_shared(const remove_extent_t& u); // \tcode{T} is \tcode{U[N]} +template + shared_ptr allocate_shared(const A& a, + const remove_extent_t& u); // \tcode{T} is \tcode{U[N]} +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns A \tcode{shared_ptr} to an object of type \tcode{T}, +where each array element of type \tcode{remove_extent_t} +has an initial value of \tcode{u}. + +\pnum +\remarks These overloads shall only participate in overload resolution +when \tcode{T} is of the form \tcode{U[N]}. + +\pnum +\begin{example} +\begin{codeblock} +shared_ptr p = make_shared(1.0); + // \tcode{shared_ptr} to a \tcode{double[1024]}, where each element is \tcode{1.0} +shared_ptr q = make_shared({1.0, 0.0}); + // \tcode{shared_ptr} to a \tcode{double[6][2]}, where each double[2] element is \tcode{\{1.0, 0.0\}} +shared_ptr[4]> r = make_shared[4]>({1, 2}); + // \tcode{shared_ptr} to a \tcode{vector[4]}, where each vector has contents \tcode{\{1, 2\}} +\end{codeblock} +\end{example} +\end{itemdescr} + +\rSec4[util.smartptr.shared.cmp]{\tcode{shared_ptr} comparison} + +\indexlibrarymember{operator==}{shared_ptr}% +\begin{itemdecl} +template + bool operator==(const shared_ptr& a, const shared_ptr& b) noexcept; +\end{itemdecl} + +\begin{itemdescr} +\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; +\end{itemdecl} + +\begin{itemdescr} +\pnum +\returns \tcode{less<>()(a.get(), b.get())}. + +\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}% \begin{itemdecl} template bool operator==(const shared_ptr& a, nullptr_t) noexcept; @@ -10323,7 +10158,7 @@ \begin{itemdescr} \pnum -\requires The expression \tcode{static_cast((U*)0)} shall +\requires The expression \tcode{static_cast((U*)nullptr)} shall be well formed. \pnum @@ -10349,14 +10184,14 @@ \begin{itemdescr} \pnum -\requires The expression \tcode{dynamic_cast((U*)0)} -shall be well formed and shall have well defined behavior. +\requires The expression \tcode{dynamic_cast((U*)nullptr)} +shall be well formed and shall have well-defined behavior. \pnum \returns \begin{itemize} \item When \tcode{dynamic_cast::element_type*>(r.get())} -returns a nonzero value \tcode{p}, \tcode{shared_ptr(r, p)}. +returns a non-null value \tcode{p}, \tcode{shared_ptr(r, p)}. \item Otherwise, \tcode{shared_ptr()}. \end{itemize} @@ -10376,7 +10211,7 @@ \begin{itemdescr} \pnum -\requires The expression \tcode{const_cast((U*)0)} shall +\requires The expression \tcode{const_cast((U*)nullptr)} shall be well formed. \pnum @@ -10401,7 +10236,7 @@ \begin{itemdescr} \pnum -\requires The expression \tcode{reinterpret_cast((U*)0)} +\requires The expression \tcode{reinterpret_cast((U*)nullptr)} shall be well formed. \pnum\returns @@ -10491,8 +10326,8 @@ long use_count() const noexcept; bool expired() const noexcept; shared_ptr lock() const noexcept; - template bool owner_before(const shared_ptr& b) const; - template bool owner_before(const weak_ptr& b) const; + template bool owner_before(const shared_ptr& b) const noexcept; + template bool owner_before(const weak_ptr& b) const noexcept; }; template weak_ptr(shared_ptr) -> weak_ptr; @@ -10582,7 +10417,7 @@ \pnum\effects Equivalent to \tcode{weak_ptr(r).swap(*this)}. \pnum\remarks The implementation may meet the effects (and the -implied guarantees) via different means, without creating a temporary. +implied guarantees) via different means, without creating a temporary object. \pnum\returns \tcode{*this}. \end{itemdescr} @@ -10651,8 +10486,8 @@ \indexlibrarymember{owner_before}{weak_ptr}% \begin{itemdecl} -template bool owner_before(const shared_ptr& b) const; -template bool owner_before(const weak_ptr& b) const; +template bool owner_before(const shared_ptr& b) const noexcept; +template bool owner_before(const weak_ptr& b) const noexcept; \end{itemdecl} \begin{itemdescr} @@ -11040,7 +10875,7 @@ \begin{itemdescr} \pnum Letting \tcode{UP} be \tcode{unique_ptr}, -the specialization \tcode{hash} is enabled~(\ref{unord.hash}) +the specialization \tcode{hash} is enabled\iref{unord.hash} if and only if \tcode{hash} is enabled. When enabled, for an object \tcode{p} of type \tcode{UP}, \tcode{hash()(p)} shall evaluate to @@ -11187,8 +11022,8 @@ \pnum \returns -A derived class shall implement this function to return a pointer to allocated storage (\ref{basic.stc.dynamic.deallocation}) with a size of at least \tcode{bytes}. -The returned storage is aligned to the specified alignment, if such alignment is supported (\ref{basic.align}); +A derived class shall implement this function to return a pointer to allocated storage\iref{basic.stc.dynamic.deallocation} with a size of at least \tcode{bytes}. +The returned storage is aligned to the specified alignment, if such alignment is supported\iref{basic.align}; otherwise it is aligned to \tcode{max_align}. \pnum @@ -11261,7 +11096,7 @@ \pnum A specialization of class template \tcode{pmr::polymorphic_allocator} -conforms to the \tcode{Allocator} requirements (\ref{allocator.requirements}). +conforms to the \tcode{Allocator} requirements\iref{allocator.requirements}. Constructed with different memory resources, different instances of the same specialization of \tcode{pmr::polymorphic_allocator} can exhibit entirely different allocation behavior. @@ -11444,8 +11279,8 @@ \begin{itemdescr} \pnum \begin{note} -This method and the \tcode{construct} methods that follow -are overloads for piecewise construction of pairs~(\ref{pairs.pair}). +This member function and the \tcode{construct} member functions that follow +are overloads for piecewise construction of pairs\iref{pairs.pair}. \end{note} \pnum @@ -11457,7 +11292,7 @@ constructing a \tcode{pair} object in the storage whose address is represented by \tcode{p}, as if by separate uses-allocator construction -with allocator \tcode{resource()}~(\ref{allocator.uses.construction}) +with allocator \tcode{resource()}\iref{allocator.uses.construction} of \tcode{p->first} using the elements of \tcode{x} and \tcode{p->second} using the elements of \tcode{y}. \end{note} @@ -11707,10 +11542,6 @@ sets the value of the default memory resource pointer to \tcode{r}, otherwise sets the default memory resource pointer to \tcode{new_delete_resource()}. -\pnum -\postconditions -\tcode{get_default_resource() == r}. - \pnum \returns The previous value of the default memory resource pointer. @@ -11867,7 +11698,7 @@ \begin{itemdescr} \pnum The maximum number of blocks that will be allocated at once -from the upstream memory resource~(\ref{mem.res.monotonic.buffer}) +from the upstream memory resource\iref{mem.res.monotonic.buffer} to replenish a pool. If the value of \tcode{max_blocks_per_chunk} is zero or is greater than an \impldef{largest supported value to configure the maximum number of blocks to replenish a pool} @@ -12000,10 +11831,10 @@ \begin{itemdescr} \pnum \returns -A pointer to allocated storage (\ref{basic.stc.dynamic.deallocation}) +A pointer to allocated storage\iref{basic.stc.dynamic.deallocation} with a size of at least \tcode{bytes}. The size and alignment of the allocated memory shall meet the requirements -for a class derived from \tcode{memory_resource}~(\ref{mem.res}). +for a class derived from \tcode{memory_resource}\iref{mem.res}. \pnum \effects @@ -12115,7 +11946,7 @@ virtual ~monotonic_buffer_resource(); - monotonic_buffer_resource + monotonic_buffer_resource& operator=(const monotonic_buffer_resource&) = delete; void release(); @@ -12224,10 +12055,10 @@ \begin{itemdescr} \pnum \returns -A pointer to allocated storage (\ref{basic.stc.dynamic.deallocation}) +A pointer to allocated storage\iref{basic.stc.dynamic.deallocation} with a size of at least \tcode{bytes}. The size and alignment of the allocated memory shall meet the requirements -for a class derived from \tcode{memory_resource}~(\ref{mem.res}). +for a class derived from \tcode{memory_resource}\iref{mem.res}. \pnum \effects @@ -12700,7 +12531,7 @@ \begin{itemdescr} \pnum -\requires all of the types in \tcode{Args1} and \tcode{Args2} shall be +\requires All of the types in \tcode{Args1} and \tcode{Args2} shall be \tcode{CopyConstructible} (Table~\ref{tab:copyconstructible}). \pnum @@ -12887,14 +12718,14 @@ \rSec1[function.objects]{Function objects} \pnum -A \indexdefn{function object!type}\term{function object type} is an object -type~(\ref{basic.types}) that can be the type of the +A \defnx{function object type}{function object!type} is an object +type\iref{basic.types} that can be the type of the \grammarterm{postfix-expression} in a function call -(\ref{expr.call},~\ref{over.match.call}).\footnote{Such a type is a function +(\ref{expr.call}, \ref{over.match.call}).\footnote{Such a type is a function pointer or a class type which has a member \tcode{operator()} or a class type which has a conversion to a pointer to function.} A \defn{function object} is an object of a function object type. In the places where one would expect to pass a -pointer to a function to an algorithmic template (Clause~\ref{algorithms}), the +pointer to a function to an algorithmic template\iref{algorithms}, the interface is specified to accept a function object. This not only makes algorithmic templates work with pointers to functions, but also enables them to work with arbitrary function objects. @@ -13065,87 +12896,79 @@ The following definitions apply to this Clause: \pnum -\indexdefn{call signature}% -A \term{call signature} is the name of a return type followed by a +A \defn{call signature} is the name of a return type followed by a parenthesized comma-separated list of zero or more argument types. \pnum -\indexdefn{callable type}% -A \term{callable type} is a function object type~(\ref{function.objects}) or a pointer to member. +A \defn{callable type} is a function object type\iref{function.objects} or a pointer to member. \pnum -\indexdefn{callable object}% -A \term{callable object} is an object of a callable type. +A \defn{callable object} is an object of a callable type. \pnum -\indexdefn{call wrapper!type}% -A \term{call wrapper type} is a type that holds a callable object +A \defnx{call wrapper type}{call wrapper!type} is a type that holds a callable object and supports a call operation that forwards to that object. \pnum -\indexdefn{call wrapper}% -A \term{call wrapper} is an object of a call wrapper type. +A \defn{call wrapper} is an object of a call wrapper type. \pnum -\indexdefn{target object}% -A \term{target object} is the callable object held by a call wrapper. +A \defn{target object} is the callable object held by a call wrapper. \rSec2[func.require]{Requirements} \pnum \indexlibrary{invoke@\tcode{\placeholder{INVOKE}}}% -Define \tcode{\placeholdernc{INVOKE}(f, t1, t2, ..., tN)} as follows: +Define \tcode{\placeholdernc{INVOKE}(f, t$_1$, t$_2$, $\dotsc$, t$_N$)} as follows: \begin{itemize} -\item \tcode{(t1.*f)(t2, ..., tN)} when \tcode{f} is a pointer to a +\item \tcode{(t$_1$.*f)(t$_2$, $\dotsc$, t$_N$)} when \tcode{f} is a pointer to a member function of a class \tcode{T} -and \tcode{is_base_of_v>} is \tcode{true}; +and \tcode{is_base_of_v>} is \tcode{true}; -\item \tcode{(t1.get().*f)(t2, ..., tN)} when \tcode{f} is a pointer to a +\item \tcode{(t$_1$.get().*f)(t$_2$, $\dotsc$, t$_N$)} when \tcode{f} is a pointer to a member function of a class \tcode{T} -and \tcode{decay_t} is a specialization of \tcode{reference_wrapper}; +and \tcode{decay_t} is a specialization of \tcode{reference_wrapper}; -\item \tcode{((*t1).*f)(t2, ..., tN)} when \tcode{f} is a pointer to a +\item \tcode{((*t$_1$).*f)(t$_2$, $\dotsc$, t$_N$)} when \tcode{f} is a pointer to a member function of a class \tcode{T} -and \tcode{t1} does not satisfy the previous two items; +and \tcode{t$_1$} does not satisfy the previous two items; -\item \tcode{t1.*f} when \tcode{N == 1} and \tcode{f} is a pointer to +\item \tcode{t$_1$.*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}; +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 +\item \tcode{t$_1$.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}; +and \tcode{decay_t} is a specialization of \tcode{reference_wrapper}; -\item \tcode{(*t1).*f} when \tcode{N == 1} and \tcode{f} is a pointer to +\item \tcode{(*t$_1$).*f} when \tcode{N == 1} and \tcode{f} is a pointer to data member of a class \tcode{T} -and \tcode{t1} does not satisfy the previous two items; +and \tcode{t$_1$} does not satisfy the previous two items; -\item \tcode{f(t1, t2, ..., tN)} in all other cases. +\item \tcode{f(t$_1$, t$_2$, $\dotsc$, t$_N$)} in all other cases. \end{itemize} \pnum \indexlibrary{invoke@\tcode{\placeholder{INVOKE}}}% -Define \tcode{\placeholdernc{INVOKE}(f, t1, t2, ..., tN)} as -\tcode{static_cast(\placeholdernc{INVOKE}(f, t1, t2, ..., tN))} +Define \tcode{\placeholdernc{INVOKE}(f, t$_1$, t$_2$, $\dotsc$, t$_N$)} as +\tcode{static_cast(\placeholdernc{INVOKE}(f, t$_1$, t$_2$, $\dotsc$, t$_N$))} if \tcode{R} is \cv{}~\tcode{void}, otherwise -\tcode{\placeholdernc{INVOKE}(f, t1, t2, ..., tN)} implicitly converted +\tcode{\placeholdernc{INVOKE}(f, t$_1$, t$_2$, $\dotsc$, t$_N$)} implicitly converted to \tcode{R}. \pnum \indextext{call wrapper}% \indextext{call wrapper!simple}% \indextext{call wrapper!forwarding}% -\indextext{simple call wrapper}% -\indextext{forwarding call wrapper}% -Every call wrapper~(\ref{func.def}) shall be +Every call wrapper\iref{func.def} shall be \tcode{MoveConstructible}. -A \term{forwarding call wrapper} is a +A \defn{forwarding call wrapper} is a call wrapper that can be called with an arbitrary argument list and delivers the arguments to the wrapped callable object as references. This forwarding step shall ensure that rvalue arguments are delivered as rvalue references and lvalue arguments are delivered as lvalue references. -A \term{simple call wrapper} is a forwarding call wrapper that is +A \defn{simple call wrapper} is a forwarding call wrapper that is \tcode{CopyConstructible} and \tcode{CopyAssignable} and whose copy constructor, move constructor, and assignment operator do not throw exceptions. @@ -13172,7 +12995,7 @@ \begin{itemdescr} \pnum \returns -\tcode{\placeholdernc{INVOKE}(std::forward(f), std::forward(args)...)}~(\ref{func.require}). +\tcode{\placeholdernc{INVOKE}(std::forward(f), std::forward(args)...)}\iref{func.require}. \end{itemdescr} \rSec2[refwrap]{Class template \tcode{reference_wrapper}} @@ -13182,13 +13005,13 @@ \begin{codeblock} namespace std { template class reference_wrapper { - public : + public: // types using type = T; // construct/copy/destroy reference_wrapper(T&) noexcept; - reference_wrapper(T&&) = delete; // do not bind to temporary objects + reference_wrapper(T&&) = delete; // do not bind to temporary objects reference_wrapper(const reference_wrapper& x) noexcept; // assignment @@ -13200,8 +13023,7 @@ // invocation template - invoke_result_t - operator() (ArgTypes&&...) const; + invoke_result_t operator()(ArgTypes&&...) const; }; template @@ -13214,7 +13036,7 @@ around a reference to an object or function of type \tcode{T}. \pnum -\tcode{reference_wrapper} shall be a trivially copyable type~(\ref{basic.types}). +\tcode{reference_wrapper} shall be a trivially copyable type\iref{basic.types}. \rSec3[refwrap.const]{\tcode{reference_wrapper} construct/copy/destroy} @@ -13281,7 +13103,7 @@ \end{itemdecl} \begin{itemdescr} -\pnum\returns \tcode{\placeholdernc{INVOKE}(get(), std::forward(args)...)}.~(\ref{func.require}) +\pnum\returns \tcode{\placeholdernc{INVOKE}(get(), std::forward(args)...)}.\iref{func.require} \end{itemdescr} @@ -14141,7 +13963,7 @@ \requires \tcode{FD} shall satisfy the requirements of \tcode{MoveConstructible}. \tcode{is_constructible_v} shall be \tcode{true}. -\tcode{fd} shall be a callable object~(\ref{func.def}). +\tcode{fd} shall be a callable object\iref{func.def}. \pnum \effects @@ -14211,7 +14033,7 @@ \pnum Instantiations of the \tcode{is_bind_expression} template shall meet -the \tcode{UnaryTypeTrait} requirements~(\ref{meta.rqmts}). The implementation +the \tcode{UnaryTypeTrait} requirements\iref{meta.rqmts}. The implementation shall provide a definition that has a base characteristic of \tcode{true_type} if \tcode{T} is a type returned from \tcode{bind}, otherwise it shall have a base characteristic of \tcode{false_type}. @@ -14235,7 +14057,7 @@ \pnum Instantiations of the \tcode{is_placeholder} template shall meet -the \tcode{UnaryTypeTrait} requirements~(\ref{meta.rqmts}). The implementation +the \tcode{UnaryTypeTrait} requirements\iref{meta.rqmts}. The implementation shall provide a definition that has the base characteristic of \tcode{integral_constant} if \tcode{T} is the type of \tcode{std::placeholders::_\placeholder{J}}, otherwise it shall have a @@ -14274,22 +14096,22 @@ \requires \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 +\tcode{\placeholdernc{INVOKE}(fd, $\tcode{w}_1$, $\tcode{w}_2$, $\dotsc$, +$\tcode{w}_N$)}\iref{func.require} shall be a valid expression for some +values $\tcode{w}_1$, $\tcode{w}_2$, $\dotsc{}$, $\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($\tcode{u}_1$, $\tcode{u}_2$, \ldots, $\tcode{u}_M$)} shall +A forwarding call wrapper \tcode{g}\iref{func.require}. +The effect of \tcode{g($\tcode{u}_1$, $\tcode{u}_2$, $\dotsc$, $\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$@)) +@\placeholdernc{INVOKE}@(fd, std::forward<@$\tcode{V}_1$@>(@$\tcode{v}_1$@), std::forward<@$\tcode{V}_2$@>(@$\tcode{v}_2$@), @$\dotsc$@, std::forward<@$\tcode{V}_N$@>(@$\tcode{v}_N$@)) \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. +arguments $\tcode{v}_1$, $\tcode{v}_2$, $\dotsc$, $\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{TD}_i$ throws an exception. @@ -14316,23 +14138,23 @@ \requires \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 +\tcode{\placeholdernc{INVOKE}(fd, $\tcode{w}_1$, $\tcode{w}_2$, $\dotsc$, $\tcode{w}_N$)} shall be a valid expression for some -values $\tcode{w}_1$, $\tcode{w}_2$, \ldots, $\tcode{w}_N$, where +values $\tcode{w}_1$, $\tcode{w}_2$, $\dotsc$, $\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}). +A forwarding call wrapper \tcode{g}\iref{func.require}. The effect of -\tcode{g($\tcode{u}_1$, $\tcode{u}_2$, \ldots, $\tcode{u}_M$)} shall be +\tcode{g($\tcode{u}_1$, $\tcode{u}_2$, $\dotsc$, $\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$@)) +@\placeholdernc{INVOKE}@(fd, std::forward<@$\tcode{V}_1$@>(@$\tcode{v}_1$@), std::forward<@$\tcode{V}_2$@>(@$\tcode{v}_2$@), @$\dotsc$@, std::forward<@$\tcode{V}_N$@>(@$\tcode{v}_N$@)) \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. +arguments $\tcode{v}_1$, $\tcode{v}_2$, $\dotsc$, $\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{TD}_i$ throws an exception. @@ -14350,8 +14172,8 @@ \pnum \indextext{bound arguments}% -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 +The values of the \techterm{bound arguments} $\tcode{v}_1$, $\tcode{v}_2$, $\dotsc$, $\tcode{v}_N$ and their +corresponding types $\tcode{V}_1$, $\tcode{V}_2$, $\dotsc$, $\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: @@ -14420,9 +14242,9 @@ \begin{itemdescr} \pnum -\returns A simple call wrapper~(\ref{func.def}) \tcode{fn} -such that the expression \tcode{fn(t, a2, ..., aN)} is equivalent -to \tcode{\placeholdernc{INVOKE}(pm, t, a2, ..., aN)}~(\ref{func.require}). +\returns A simple call wrapper\iref{func.def} \tcode{fn} +such that the expression \tcode{fn(t, a$_2$, $\dotsc$, a$_N$)} is equivalent +to \tcode{\placeholdernc{INVOKE}(pm, t, a$_2$, $\dotsc$, a$_N$)}\iref{func.require}. \end{itemdescr} \indextext{function object!\idxcode{mem_fn}|)} @@ -14438,7 +14260,7 @@ \pnum An exception of type \tcode{bad_function_call} is thrown by -\tcode{function::operator()}~(\ref{func.wrap.func.inv}) +\tcode{function::operator()}\iref{func.wrap.func.inv} when the function wrapper object has no target. \begin{codeblock} @@ -14537,23 +14359,23 @@ \pnum The \tcode{function} class template provides polymorphic wrappers that generalize the notion of a function pointer. Wrappers can store, copy, -and call arbitrary callable objects~(\ref{func.def}), given a call -signature~(\ref{func.def}), allowing functions to be first-class objects. +and call arbitrary callable objects\iref{func.def}, given a call +signature\iref{func.def}, allowing functions to be first-class objects. \pnum \indextext{callable type}% -A callable type~(\ref{func.def}) \tcode{F} +A callable type\iref{func.def} \tcode{F} is \defn{Lvalue-Callable} for argument types \tcode{ArgTypes} and return type \tcode{R} if the expression \tcode{\placeholdernc{INVOKE}(declval(), declval()...)}, -considered as an unevaluated operand (Clause~\ref{expr}), is -well formed~(\ref{func.require}). +considered as an unevaluated operand\iref{expr}, is +well formed\iref{func.require}. \pnum The \tcode{function} class template is a call -wrapper~(\ref{func.def}) whose call signature~(\ref{func.def}) +wrapper\iref{func.def} whose call signature\iref{func.def} is \tcode{R(ArgTypes...)}. \pnum @@ -14594,11 +14416,11 @@ \tcode{*this} targets a copy of \tcode{f.target()}. \pnum -\throws shall not throw exceptions if \tcode{f}'s target is +\throws Shall not throw exceptions if \tcode{f}'s target is a specialization of \tcode{reference_wrapper} or a function pointer. Otherwise, may throw \tcode{bad_alloc} or any exception thrown by the copy constructor of the stored callable object. -\begin{note} Implementations are encouraged to avoid the use of +\begin{note} Implementations should avoid the use of dynamically allocated memory for small callable objects, for example, where \tcode{f}'s target is an object holding only a pointer or reference to an object and a member function pointer. \end{note} @@ -14617,12 +14439,12 @@ \tcode{f} is in a valid state with an unspecified value. \pnum -\throws shall not throw exceptions if \tcode{f}'s target is +\throws Shall not throw exceptions if \tcode{f}'s target is a specialization of \tcode{reference_wrapper} or a function pointer. Otherwise, may throw \tcode{bad_alloc} or any exception thrown by the copy or move constructor of the stored callable object. -\begin{note} Implementations are encouraged to avoid the use of +\begin{note} Implementations should avoid the use of dynamically allocated memory for small callable objects, for example, where \tcode{f}'s target is an object holding only a pointer or reference to an object and a member function pointer. \end{note} @@ -14639,7 +14461,7 @@ \pnum \remarks This constructor template shall not participate in overload resolution unless -\tcode{F} is Lvalue-Callable~(\ref{func.wrap.func}) for argument types +\tcode{F} is Lvalue-Callable\iref{func.wrap.func} for argument types \tcode{ArgTypes...} and return type \tcode{R}. \pnum @@ -14654,13 +14476,13 @@ \pnum Otherwise, \tcode{*this} targets a copy of \tcode{f} initialized with \tcode{std::move(f)}. -\begin{note} Implementations are encouraged to avoid the use of +\begin{note} Implementations should avoid the use of dynamically allocated memory for small callable objects, for example, where \tcode{f} is an object holding only a pointer or reference to an object and a member function pointer. \end{note} \pnum -\throws shall not throw exceptions when \tcode{f} is a function pointer +\throws Shall not throw exceptions when \tcode{f} is a function pointer or a \tcode{reference_wrapper} for some \tcode{T}. Otherwise, may throw \tcode{bad_alloc} or any exception thrown by \tcode{F}'s copy or move constructor. @@ -14742,7 +14564,7 @@ \pnum\remarks This assignment operator shall not participate in overload resolution unless \tcode{decay_t} is -Lvalue-Callable~(\ref{func.wrap.func}) for argument types \tcode{ArgTypes...} and +Lvalue-Callable\iref{func.wrap.func} for argument types \tcode{ArgTypes...} and return type \tcode{R}. \end{itemdescr} @@ -14775,7 +14597,7 @@ \end{itemdecl} \begin{itemdescr} -\pnum\effects interchanges the targets of \tcode{*this} and \tcode{other}. +\pnum\effects Interchanges the targets of \tcode{*this} and \tcode{other}. \end{itemdescr} \rSec4[func.wrap.func.cap]{\tcode{function} capacity} @@ -14800,8 +14622,8 @@ \begin{itemdescr} \pnum -\returns \tcode{\placeholdernc{INVOKE}(f, std::forward(args)...)}~(\ref{func.require}), -where \tcode{f} is the target object~(\ref{func.def}) of \tcode{*this}. +\returns \tcode{\placeholdernc{INVOKE}(f, std::forward(args)...)}\iref{func.require}, +where \tcode{f} is the target object\iref{func.def} of \tcode{*this}. \pnum\throws \tcode{bad_function_call} if \tcode{!*this}; otherwise, any @@ -14873,7 +14695,7 @@ \rSec2[func.search]{Searchers} \pnum -This subclause provides function object types (\ref{function.objects}) for +This subclause provides function object types\iref{function.objects} for 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 @@ -15153,7 +14975,7 @@ \indexlibrary{\idxcode{hash}}% \indextext{\idxcode{hash}!instantiation restrictions}% The unordered associative containers defined in \ref{unord} use -specializations of the class template \tcode{hash} (\ref{functional.syn}) +specializations of the class template \tcode{hash}\iref{functional.syn} as the default hash function. \pnum @@ -15184,7 +15006,7 @@ \tcode{is_copy_assignable_v}, and \tcode{is_move_assignable_v}. Disabled specializations of \tcode{hash} -are not function object types~(\ref{function.objects}). +are not function object types\iref{function.objects}. \begin{note} This means that the specialization of \tcode{hash} exists, but any attempts to use it as a \tcode{Hash} will be ill-formed. @@ -15193,11 +15015,11 @@ \pnum An enabled specialization \tcode{hash} will: \begin{itemize} -\item satisfy the \tcode{Hash} requirements~(\ref{hash.requirements}), +\item satisfy the \tcode{Hash} requirements\iref{hash.requirements}, with \tcode{Key} as the function call argument type, the \tcode{Default\-Constructible} requirements (Table~\ref{tab:defaultconstructible}), the \tcode{CopyAssignable} requirements (Table~\ref{tab:copyassignable}), -\item be swappable~(\ref{swappable.requirements}) for lvalues, +\item be swappable\iref{swappable.requirements} for lvalues, \item satisfy the requirement that if \tcode{k1 == k2} is \tcode{true}, \tcode{h(k1) == h(k2)} is also \tcode{true}, where \tcode{h} is an object of type \tcode{hash} and \tcode{k1} and \tcode{k2} are objects of type \tcode{Key}; @@ -15223,7 +15045,7 @@ \pnum \indextext{signal-safe!type traits}% -All functions specified in this subclause are signal-safe~(\ref{csignal.syn}). +All functions specified in this subclause are signal-safe\iref{support.signal}. \rSec2[meta.rqmts]{Requirements} @@ -15236,7 +15058,7 @@ and publicly and unambiguously derived, directly or indirectly, from its \defn{base characteristic}, which is a specialization of the template -\tcode{integral_constant}~(\ref{meta.help}), with +\tcode{integral_constant}\iref{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 base characteristic shall not be hidden and shall be @@ -15252,7 +15074,7 @@ indirectly, from its \term{base characteristic}, which is a specialization of the template -\tcode{integral_constant}~(\ref{meta.help}), with +\tcode{integral_constant}\iref{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 base characteristic shall not be hidden and shall be @@ -15476,6 +15298,13 @@ template struct disjunction; template struct negation; + // \ref{meta.endian}, endian + enum class endian { + little = @\seebelow@, + big = @\seebelow@, + native = @\seebelow@ + }; + // \ref{meta.unary.cat}, primary type categories template inline constexpr bool is_void_v = is_void::value; @@ -15684,7 +15513,7 @@ \pnum Each of these templates shall be a -\tcode{UnaryTypeTrait}~(\ref{meta.rqmts}) +\tcode{UnaryTypeTrait}\iref{meta.rqmts} with a base characteristic of \tcode{true_type} if the corresponding condition is \tcode{true}, otherwise \tcode{false_type}. @@ -15720,35 +15549,35 @@ \indexlibrary{\idxcode{is_null_pointer}}% \tcode{template }\br \tcode{struct is_null_pointer;} & -\tcode{T} is \tcode{nullptr_t}~(\ref{basic.fundamental}) & \\ \rowsep +\tcode{T} is \tcode{nullptr_t}\iref{basic.fundamental} & \\ \rowsep \indexlibrary{\idxcode{is_integral}}% \tcode{template }\br \tcode{struct is_integral;} & -\tcode{T} is an integral type~(\ref{basic.fundamental}) & \\ \rowsep +\tcode{T} is an integral type\iref{basic.fundamental} & \\ \rowsep \indexlibrary{\idxcode{is_floating_point}}% \tcode{template }\br \tcode{struct is_floating_point;} & -\tcode{T} is a floating-point type~(\ref{basic.fundamental}) & \\ \rowsep +\tcode{T} is a floating-point type\iref{basic.fundamental} & \\ \rowsep \indexlibrary{\idxcode{is_array}}% \tcode{template }\br \tcode{struct is_array;} & -\tcode{T} is an array type~(\ref{basic.compound}) of known or unknown extent & -Class template \tcode{array}~(\ref{array}) +\tcode{T} is an array type\iref{basic.compound} of known or unknown extent & +Class template \tcode{array}\iref{array} is not an array type. \\ \rowsep \indexlibrary{\idxcode{is_pointer}}% \tcode{template }\br \tcode{struct is_pointer;} & -\tcode{T} is a pointer type~(\ref{basic.compound}) & +\tcode{T} is a pointer type\iref{basic.compound} & Includes pointers to functions but not pointers to non-static members. \\ \rowsep \indexlibrary{\idxcode{is_lvalue_reference}}% \tcode{template }\br \tcode{struct is_lvalue_reference;} & - \tcode{T} is an lvalue reference type~(\ref{dcl.ref}) & \\ \rowsep + \tcode{T} is an lvalue reference type\iref{dcl.ref} & \\ \rowsep \indexlibrary{\idxcode{is_rvalue_reference}}% \tcode{template }\br \tcode{struct is_rvalue_reference;} & - \tcode{T} is an rvalue reference type~(\ref{dcl.ref}) & \\ \rowsep + \tcode{T} is an rvalue reference type\iref{dcl.ref} & \\ \rowsep \indexlibrary{\idxcode{is_member_object_pointer}}% \tcode{template }\br \tcode{struct is_member_object_pointer;}& @@ -15760,19 +15589,19 @@ \indexlibrary{\idxcode{is_enum}}% \tcode{template }\br \tcode{struct is_enum;} & -\tcode{T} is an enumeration type~(\ref{basic.compound}) & \\ \rowsep +\tcode{T} is an enumeration type\iref{basic.compound} & \\ \rowsep \indexlibrary{\idxcode{is_union}}% \tcode{template }\br \tcode{struct is_union;} & -\tcode{T} is a union type~(\ref{basic.compound}) & \\ \rowsep +\tcode{T} is a union type\iref{basic.compound} & \\ \rowsep \indexlibrary{\idxcode{is_class}}% \tcode{template }\br \tcode{struct is_class;} & -\tcode{T} is a non-union class type~(\ref{basic.compound}) & \\ \rowsep +\tcode{T} is a non-union class type\iref{basic.compound} & \\ \rowsep \indexlibrary{\idxcode{is_function}}% \tcode{template }\br \tcode{struct is_function;} & -\tcode{T} is a function type~(\ref{basic.compound}) & \\ +\tcode{T} is a function type\iref{basic.compound} & \\ \end{libreqtab3e} \rSec3[meta.unary.comp]{Composite type traits} @@ -15800,23 +15629,23 @@ \indexlibrary{\idxcode{is_arithmetic}}% \tcode{template }\br \tcode{struct is_arithmetic;} & - \tcode{T} is an arithmetic type~(\ref{basic.fundamental}) & \\ \rowsep + \tcode{T} is an arithmetic type\iref{basic.fundamental} & \\ \rowsep \indexlibrary{\idxcode{is_fundamental}}% \tcode{template }\br \tcode{struct is_fundamental;} & - \tcode{T} is a fundamental type~(\ref{basic.fundamental}) & \\ \rowsep + \tcode{T} is a fundamental type\iref{basic.fundamental} & \\ \rowsep \indexlibrary{\idxcode{is_object}}% \tcode{template }\br \tcode{struct is_object;} & - \tcode{T} is an object type~(\ref{basic.types}) & \\ \rowsep + \tcode{T} is an object type\iref{basic.types} & \\ \rowsep \indexlibrary{\idxcode{is_scalar}}% \tcode{template }\br \tcode{struct is_scalar;} & - \tcode{T} is a scalar type~(\ref{basic.types}) & \\ \rowsep + \tcode{T} is a scalar type\iref{basic.types} & \\ \rowsep \indexlibrary{\idxcode{is_compound}}% \tcode{template }\br \tcode{struct is_compound;} & - \tcode{T} is a compound type~(\ref{basic.compound}) & \\ \rowsep + \tcode{T} is a compound type\iref{basic.compound} & \\ \rowsep \indexlibrary{\idxcode{is_member_pointer}}% \tcode{template }\br \tcode{struct is_member_pointer;} & @@ -15845,7 +15674,7 @@ For the purpose of defining the templates in this subclause, a function call expression \tcode{declval()} for any type \tcode{T} is considered to be a trivial~(\ref{basic.types}, \ref{special}) function call -that is not an odr-use~(\ref{basic.def.odr}) of \tcode{declval} +that is not an odr-use\iref{basic.def.odr} of \tcode{declval} in the context of the corresponding definition notwithstanding the restrictions of~\ref{declval}. @@ -15861,39 +15690,39 @@ \indexlibrary{\idxcode{is_const}}% \tcode{template }\br \tcode{struct is_const;} & - \tcode{T} is const-qualified~(\ref{basic.type.qualifier}) & \\ \rowsep + \tcode{T} is const-qualified\iref{basic.type.qualifier} & \\ \rowsep \indexlibrary{\idxcode{is_volatile}}% \tcode{template }\br \tcode{struct is_volatile;} & - \tcode{T} is volatile-qualified~(\ref{basic.type.qualifier}) & \\ \rowsep + \tcode{T} is volatile-qualified\iref{basic.type.qualifier} & \\ \rowsep \indexlibrary{\idxcode{is_trivial}}% \tcode{template }\br \tcode{struct is_trivial;} & - \tcode{T} is a trivial type~(\ref{basic.types}) & + \tcode{T} is a trivial type\iref{basic.types} & \tcode{remove_all_extents_t} shall be a complete 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{T} is a trivially copyable type\iref{basic.types} & \tcode{remove_all_extents_t} shall be a complete type or \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{T} is a standard-layout type\iref{basic.types} & \tcode{remove_all_extents_t} shall be a complete 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{T} is a POD type\iref{basic.types} & \tcode{remove_all_extents_t} shall be a complete type or \cv{}~\tcode{void}. \\ \rowsep @@ -15909,27 +15738,27 @@ \indexlibrary{\idxcode{is_polymorphic}}% \tcode{template }\br \tcode{struct is_polymorphic;} & - \tcode{T} is a polymorphic class~(\ref{class.virtual}) & + \tcode{T} is a polymorphic class\iref{class.virtual} & If \tcode{T} is a non-union class type, \tcode{T} shall be a complete type. \\ \rowsep \indexlibrary{\idxcode{is_abstract}}% \tcode{template }\br \tcode{struct is_abstract;} & - \tcode{T} is an abstract class~(\ref{class.abstract}) & + \tcode{T} is an abstract class\iref{class.abstract} & If \tcode{T} is a non-union class type, \tcode{T} shall be a complete type. \\ \rowsep \indexlibrary{\idxcode{is_final}}% \tcode{template }\br \tcode{struct is_final;} & \tcode{T} is a class type marked with the \grammarterm{class-virt-specifier} - \tcode{final} (Clause~\ref{class}). \begin{note} A union is a class type that + \tcode{final}\iref{class}. \begin{note} A union is a class type that can be marked with \tcode{final}. \end{note} & If \tcode{T} is a class type, \tcode{T} shall be a complete type. \\ \rowsep -\indexlibrary{\idxcode{is_aggregate_signed}!class}% +\indexlibrary{\idxcode{is_aggregate}}% \tcode{template }\br \tcode{struct is_aggregate;} & - \tcode{T} is an aggregate type~(\ref{dcl.init.aggr}) & + \tcode{T} is an aggregate type\iref{dcl.init.aggr} & \tcode{remove_all_extents_t} shall be a complete type or \cv~\tcode{void}. \\ \rowsep \indexlibrary{\idxcode{is_signed}!class}% @@ -15967,7 +15796,7 @@ \indexlibrary{\idxcode{is_copy_constructible}}% \tcode{template }\br \tcode{struct is_copy_constructible;} & - For a referenceable type \tcode{T} (\ref{defns.referenceable}), the same result as + For a referenceable type \tcode{T}\iref{defns.referenceable}, the same result as \tcode{is_constructible_v}, otherwise \tcode{false}. & \tcode{T} shall be a complete type, \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep @@ -15985,7 +15814,7 @@ \tcode{struct is_assignable;} & The expression \tcode{declval() =} \tcode{declval()} is well-formed when treated as an unevaluated - operand (Clause~\ref{expr}). Access checking is performed as if in a context + operand\iref{expr}. Access checking is performed as if in a context unrelated to \tcode{T} and \tcode{U}. Only the validity of the immediate context of the assignment expression is considered. \begin{note} The compilation of the expression can result in side effects such as the instantiation of class template @@ -16016,9 +15845,9 @@ \tcode{struct is_swappable_with;} & The expressions \tcode{swap(declval(), declval())} and \tcode{swap(declval(), declval())} are each well-formed - when treated as an unevaluated operand (Clause~\ref{expr}) + when treated as an unevaluated operand\iref{expr} in an overload-resolution context - for swappable values~(\ref{swappable.requirements}). + for swappable values\iref{swappable.requirements}. Access checking is performed as if in a context unrelated to \tcode{T} and \tcode{U}. Only the validity of the immediate context @@ -16053,9 +15882,9 @@ for which the expression \tcode{declval().\~U()} is well-formed - when treated as an unevaluated operand (Clause \ref{expr}), + when treated as an unevaluated operand\iref{expr}, where \tcode{U} is - \tcode{remove_all_extents}. & + \tcode{remove_all_extents_t}. & \tcode{T} shall be a complete type, \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep @@ -16066,7 +15895,7 @@ \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, \cv{}~\tcode{void}, or arrays of unknown bound. \\ \rowsep @@ -16101,7 +15930,7 @@ \tcode{struct is_trivially_assignable;} & \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}). & + ~(\ref{basic.types}, \ref{special}). & \tcode{T} and \tcode{U} shall be complete types, \cv{}~\tcode{void}, or arrays of unknown bound. \\ \rowsep @@ -16137,7 +15966,7 @@ \tcode{is_constructible_v} is \tcode{true} and the variable definition for \tcode{is_constructible}, as defined below, is known not to - throw any exceptions~(\ref{expr.unary.noexcept}). + throw any exceptions\iref{expr.unary.noexcept}. & \tcode{T} and all types in the parameter pack \tcode{Args} shall be complete types, \cv{}~\tcode{void}, @@ -16172,7 +16001,7 @@ \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}). & + throw any exceptions\iref{expr.unary.noexcept}. & \tcode{T} and \tcode{U} shall be complete types, \cv{}~\tcode{void}, or arrays of unknown bound. \\ \rowsep @@ -16200,7 +16029,7 @@ \tcode{is_swappable_with_v} is \tcode{true} and each \tcode{swap} expression of the definition of \tcode{is_swappable_with} is known not to throw - any exceptions~(\ref{expr.unary.noexcept}). & + any exceptions\iref{expr.unary.noexcept}. & \tcode{T} and \tcode{U} shall be complete types, \cv{}~\tcode{void}, or arrays of unknown bound. \\ \rowsep @@ -16219,7 +16048,7 @@ \tcode{template }\br \tcode{struct is_nothrow_destructible;} & \tcode{is_destructible_v} is \tcode{true} and the indicated destructor is known - not to throw any exceptions~(\ref{expr.unary.noexcept}). & + not to throw any exceptions\iref{expr.unary.noexcept}. & \tcode{T} shall be a complete type, \cv{}~\tcode{void}, or an array of unknown bound. \\ \rowsep @@ -16227,7 +16056,7 @@ \indexlibrary{\idxcode{has_virtual_destructor}}% \tcode{template }\br \tcode{struct has_virtual_destructor;} & - \tcode{T} has a virtual destructor~(\ref{class.dtor}) & + \tcode{T} has a virtual destructor\iref{class.dtor} & If \tcode{T} is a non-union class type, \tcode{T} shall be a complete type. \\ \rowsep \indexlibrary{\idxcode{has_unique_object_representations}}% @@ -16336,7 +16165,7 @@ struct alignment_of;} & \tcode{alignof(T)}.\br \requires{} - \tcode{alignof(T)} shall be a valid expression~(\ref{expr.alignof}) \\ \rowsep + \tcode{alignof(T)} shall be a valid expression\iref{expr.alignof} \\ \rowsep \indexlibrary{\idxcode{rank}}% \tcode{template \br @@ -16351,12 +16180,12 @@ If \tcode{T} is not an array type, or if it has rank less than or equal to \tcode{I}, or if \tcode{I} is 0 and \tcode{T} has type ``array of unknown bound of \tcode{U}'', then - 0; otherwise, the bound~(\ref{dcl.array}) of the \tcode{I}'th dimension of + 0; otherwise, the bound\iref{dcl.array} of the \tcode{I}'th dimension of \tcode{T}, where indexing of \tcode{I} is zero-based \\ \end{libreqtab2a} \pnum -Each of these templates shall be a \tcode{UnaryTypeTrait}~(\ref{meta.rqmts}) with a +Each of these templates shall be a \tcode{UnaryTypeTrait}\iref{meta.rqmts} with a base characteristic of \tcode{integral_constant}. \pnum @@ -16392,7 +16221,7 @@ \pnum Each of these templates shall be a -\tcode{BinaryTypeTrait}~(\ref{meta.rqmts}) +\tcode{BinaryTypeTrait}\iref{meta.rqmts} with a base characteristic of \tcode{true_type} if the corresponding condition is true, otherwise \tcode{false_type}. @@ -16412,7 +16241,7 @@ \indexlibrary{\idxcode{is_base_of}}% \tcode{template }\br \tcode{struct is_base_of;} & - \tcode{Base} is a base class of \tcode{Derived} (Clause~\ref{class.derived}) + \tcode{Base} is a base class of \tcode{Derived}\iref{class.derived} without regard to cv-qualifiers or \tcode{Base} and \tcode{Derived} are not unions and name the same class type @@ -16476,7 +16305,7 @@ For the purpose of defining the templates in this subclause, a function call expression \tcode{declval()} for any type \tcode{T} is considered to be a trivial~(\ref{basic.types}, \ref{special}) function call -that is not an odr-use~(\ref{basic.def.odr}) of \tcode{declval} +that is not an odr-use\iref{basic.def.odr} of \tcode{declval} in the context of the corresponding definition notwithstanding the restrictions of~\ref{declval}. @@ -16511,7 +16340,7 @@ } \end{codeblock} -\begin{note} This requirement gives well defined results for reference types, void +\begin{note} This requirement gives well-defined results for reference types, void 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 @@ -16529,7 +16358,7 @@ \pnum Each of the templates in this subclause shall be a -\tcode{TransformationTrait}~(\ref{meta.rqmts}). +\tcode{TransformationTrait}\iref{meta.rqmts}. \rSec3[meta.trans.cv]{Const-volatile modifications} @@ -16617,11 +16446,11 @@ \indexlibrary{\idxcode{add_lvalue_reference}}% \tcode{template \br struct add_lvalue_reference;} & - If \tcode{T} names a referenceable type (\ref{defns.referenceable}) then + If \tcode{T} names a referenceable type\iref{defns.referenceable} then the member typedef \tcode{type} names \tcode{T\&}; otherwise, \tcode{type} names \tcode{T}. \begin{note} - This rule reflects the semantics of reference collapsing~(\ref{dcl.ref}). + This rule reflects the semantics of reference collapsing\iref{dcl.ref}. \end{note}\\ \rowsep \indexlibrary{\idxcode{add_rvalue_reference}}% @@ -16630,7 +16459,7 @@ If \tcode{T} names a referenceable type then the member typedef \tcode{type} names \tcode{T\&\&}; otherwise, \tcode{type} names \tcode{T}. - \begin{note} This rule reflects the semantics of reference collapsing~(\ref{dcl.ref}). + \begin{note} This rule reflects the semantics of reference collapsing\iref{dcl.ref}. For example, when a type \tcode{T} names a type \tcode{T1\&}, the type \tcode{add_rvalue_reference_t} is not an rvalue reference. \end{note} \\ @@ -16650,13 +16479,13 @@ \tcode{template }\br \tcode{struct make_signed;} & If \tcode{T} names a (possibly cv-qualified) signed integer - type~(\ref{basic.fundamental}) then the member typedef + type\iref{basic.fundamental} then the member typedef \tcode{type} names the type \tcode{T}; otherwise, if \tcode{T} names a (possibly cv-qualified) unsigned integer type then \tcode{type} names the corresponding signed integer type, with the same cv-qualifiers as \tcode{T}; otherwise, \tcode{type} names the signed integer type with smallest - rank~(\ref{conv.rank}) for which + rank\iref{conv.rank} for which \tcode{sizeof(T) == sizeof(type)}, with the same cv-qualifiers as \tcode{T}.\br \requires{} \tcode{T} shall be a (possibly cv-qualified) @@ -16667,13 +16496,13 @@ \tcode{template }\br \tcode{struct make_unsigned;} & If \tcode{T} names a (possibly cv-qualified) unsigned integer - type~(\ref{basic.fundamental}) then the member typedef + type\iref{basic.fundamental} then the member typedef \tcode{type} names the type \tcode{T}; otherwise, if \tcode{T} names a (possibly cv-qualified) signed integer type then \tcode{type} names the corresponding unsigned integer type, with the same cv-qualifiers as \tcode{T}; otherwise, \tcode{type} names the unsigned integer type with smallest - rank~(\ref{conv.rank}) for which + rank\iref{conv.rank} for which \tcode{sizeof(T) == sizeof(type)}, with the same cv-qualifiers as \tcode{T}.\br \requires{} \tcode{T} shall be a (possibly cv-qualified) @@ -16751,7 +16580,7 @@ \indexlibrary{\idxcode{add_pointer}}% \tcode{template \br struct add_pointer;} & - If \tcode{T} names a referenceable type (\ref{defns.referenceable}) or a + If \tcode{T} names a referenceable type\iref{defns.referenceable} or a \cv{}~\tcode{void} type then the member typedef \tcode{type} names the same type as \tcode{remove_reference_t*}; @@ -16778,10 +16607,10 @@ & The value of \textit{default-alignment} shall be the most stringent alignment requirement for any \Cpp object type whose size - is no greater than \tcode{Len}~(\ref{basic.types}). + is no greater than \tcode{Len}\iref{basic.types}. The member typedef \tcode{type} shall be a POD type suitable for use as uninitialized storage for any object whose size - is at most \textit{Len} and whose alignment is a divisor of \textit{Align}.\br + is at most \tcode{Len} and whose alignment is a divisor of \tcode{Align}.\br \requires{} \tcode{Len} shall not be zero. \tcode{Align} shall be equal to \tcode{alignof(T)} for some type \tcode{T} or to \textit{default-alignment}.\\ \rowsep @@ -16806,8 +16635,8 @@ \tcode{remove_extent_t*}. If \tcode{is_function_v} is \tcode{true}, the member typedef \tcode{type} shall equal \tcode{add_pointer_t}. Otherwise the member typedef \tcode{type} equals \tcode{remove_cv_t}. - \begin{note} This behavior is similar to the lvalue-to-rvalue~(\ref{conv.lval}), - array-to-pointer~(\ref{conv.array}), and function-to-pointer~(\ref{conv.func}) + \begin{note} This behavior is similar to the lvalue-to-rvalue\iref{conv.lval}, + array-to-pointer\iref{conv.array}, and function-to-pointer\iref{conv.func} conversions applied when an lvalue expression is used as an rvalue, but also strips \cv-qualifiers from class types in order to more closely model by-value argument passing. \end{note} @@ -16841,14 +16670,14 @@ & The member typedef \tcode{type} names the underlying type of \tcode{T}.\br - \requires{} \tcode{T} shall be a complete enumeration type~(\ref{dcl.enum}) \\ \rowsep + \requires{} \tcode{T} shall be a complete enumeration type\iref{dcl.enum} \\ \rowsep \tcode{template }\br \tcode{struct invoke_result;} & If the expression \tcode{\placeholdernc{INVOKE}(declval(), declval()...)} - is well formed when treated as an unevaluated operand (Clause~\ref{expr}), + is well formed when treated as an unevaluated operand\iref{expr}, the member typedef \tcode{type} names the type \tcode{decltype(\placeholdernc{INVOKE}(declval(), declval()...))}; otherwise, there shall be no member \tcode{type}. Access checking is @@ -16883,7 +16712,7 @@ \pnum It is \impldef{support for extended alignment} whether any extended alignment is -supported~(\ref{basic.align}). +supported\iref{basic.align}. \indexlibrary{\idxcode{common_type}}% \pnum @@ -17094,6 +16923,42 @@ is a \tcode{UnaryTypeTrait} with a base characteristic of \tcode{bool_constant}. \end{itemdescr} +\rSec2[meta.endian]{Endian} + +\pnum +Two common methods of byte ordering in multibyte scalar types are big-endian +and little-endian in the execution environment. Big-endian is a format for +storage of binary data in which the most significant byte is placed first, +with the rest in descending order. Little-endian is a format for storage of +binary data in which the least significant byte is placed first, with the rest +in ascending order. This subclause describes the endianness of the scalar types +of the execution environment. + +\indexlibrary{\idxcode{endian}}% +\indexlibrarymember{little}{endian}% +\indexlibrarymember{big}{endian}% +\indexlibrarymember{native}{endian}% +\begin{itemdecl} +enum class endian { + little = @\seebelow@, + big = @\seebelow@, + native = @\seebelow@ +}; +\end{itemdecl} + +\begin{itemdescr} +\pnum +If all scalar types have size \tcode{1}, then all of \tcode{endian::little}, +\tcode{endian::big}, and \tcode{endian::native} have the same value. +Otherwise, \tcode{endian::little} is not equal to \tcode{endian::big}. +If all scalar types are big-endian, \tcode{endian::native} is +equal to \tcode{endian::big}. +If all scalar types are little-endian, \tcode{endian::native} is +equal to \tcode{endian::little}. +Otherwise, \tcode{endian::native} is not equal +to either \tcode{endian::big} or \tcode{endian::little}. +\end{itemdescr} + \rSec1[ratio]{Compile-time rational arithmetic} \rSec2[ratio.general]{In general} @@ -17336,8 +17201,8 @@ \pnum \indexlibrary{\idxcode{chrono}}% -This subclause describes the chrono library~(\ref{time.syn}) and various C -functions~(\ref{ctime.syn}) that provide generally useful time +This subclause describes the chrono library\iref{time.syn} and various C +functions\iref{ctime.syn} that provide generally useful time utilities. \rSec2[time.syn]{Header \tcode{} synopsis} @@ -17535,7 +17400,7 @@ \pnum In Table~\ref{tab:time.clock} \tcode{C1} and \tcode{C2} denote clock types. \tcode{t1} and \tcode{t2} are values returned by \tcode{C1::now()} where the call returning \tcode{t1} happens -before~(\ref{intro.multithread}) the call returning \tcode{t2} and both of these calls +before\iref{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 @@ -17588,7 +17453,7 @@ A type \tcode{TC} meets the \tcode{TrivialClock} requirements if: \begin{itemize} -\item \tcode{TC} satisfies the \tcode{Clock} requirements~(\ref{time.clock.req}), +\item \tcode{TC} satisfies the \tcode{Clock} requirements\iref{time.clock.req}, \item the types \tcode{TC::rep}, \tcode{TC::duration}, and \tcode{TC::time_point} satisfy the requirements of \tcode{EqualityCom\-parable} (Table~\ref{tab:equalitycomparable}), @@ -17597,11 +17462,11 @@ \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\iref{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 -\tcode{TC::time_point} are swappable~(\ref{swappable.requirements}), +\tcode{TC::time_point} are swappable\iref{swappable.requirements}, \item the function \tcode{TC::now()} does not throw exceptions, and @@ -18283,7 +18148,7 @@ \pnum \returns Let \tcode{CF} be \tcode{ratio_divide}, and \tcode{CR} be \tcode{common_type<} \tcode{typename +ToDuration::period>}, and \tcode{CR} be \tcode{common_type::type}. \begin{itemize} \item If \tcode{CF::num == 1} and \tcode{CF::den == 1}, returns @@ -18532,7 +18397,7 @@ \end{codeblock} \pnum -\tcode{Clock} shall meet the Clock requirements~(\ref{time.clock.req}). +\tcode{Clock} shall meet the Clock requirements\iref{time.clock.req}. \pnum If \tcode{Duration} is not an instance of \tcode{duration}, @@ -18846,7 +18711,7 @@ \pnum The types defined in this subclause shall satisfy the \tcode{TrivialClock} -requirements~(\ref{time.clock.req}). +requirements\iref{time.clock.req}. \rSec3[time.clock.system]{Class \tcode{system_clock}} \indexlibrary{\idxcode{system_clock}}% @@ -19018,9 +18883,9 @@ \pnum The functions \tcode{asctime}, \tcode{ctime}, \tcode{gmtime}, and \tcode{localtime} are not required to avoid data -races~(\ref{res.on.data.races}). +races\iref{res.on.data.races}. -\xref ISO C~7.27. +\xref ISO C 7.27 \rSec1[type.index]{Class \tcode{type_index}} @@ -19064,8 +18929,8 @@ \pnum The class \tcode{type_index} provides a simple wrapper for \tcode{type_info} which can be used as an index type in associative -containers~(\ref{associative}) and in unordered associative -containers~(\ref{unord}). +containers\iref{associative} and in unordered associative +containers\iref{unord}. \rSec2[type.index.members]{\tcode{type_index} members} @@ -19341,3 +19206,346 @@ \pnum The header \tcode{} declares global objects associated with each type of execution policy. \end{itemdescr} + +\rSec1[charconv]{Primitive numeric conversions} + +\rSec2[charconv.syn]{Header \tcode{} synopsis} + +\indextext{\idxhdr{charconv}}% +\indexlibrary{\idxhdr{charconv}}% +\begin{codeblock} +namespace std { +@ +\indexlibrary{\idxcode{chars_format}}% +\indexlibrarymember{scientific}{chars_format}% +\indexlibrarymember{fixed}{chars_format}% +\indexlibrarymember{hex}{chars_format}% +\indexlibrarymember{general}{chars_format}% +@ + // floating-point format for primitive numerical conversion + enum class chars_format { + scientific = @\unspec@, + fixed = @\unspec@, + hex = @\unspec@, + general = fixed | scientific + }; +@ +\indexlibrary{\idxcode{to_chars_result}}% +\indexlibrarymember{ptr}{to_chars_result}% +\indexlibrarymember{ec}{to_chars_result} +@ + // \ref{charconv.to.chars}, primitive numerical output conversion + struct to_chars_result { + char* ptr; + errc ec; + }; + + to_chars_result to_chars(char* first, char* last, @\seebelow@ value, int base = 10); + + to_chars_result to_chars(char* first, char* last, float value); + 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, int precision); + to_chars_result to_chars(char* first, char* last, double value, + chars_format fmt, int precision); + to_chars_result to_chars(char* first, char* last, long double value, + chars_format fmt, int precision); +@ +\indexlibrary{\idxcode{from_chars_result}}% +\indexlibrarymember{ptr}{from_chars_result}% +\indexlibrarymember{ec}{from_chars_result} +@ + // \ref{charconv.from.chars}, primitive numerical input conversion + struct from_chars_result { + const char* ptr; + errc ec; + }; + + from_chars_result from_chars(const char* first, const char* last, + @\seebelow@& value, int base = 10); + + from_chars_result from_chars(const char* first, const char* last, float& value, + chars_format fmt = chars_format::general); + from_chars_result from_chars(const char* first, const char* last, double& value, + chars_format fmt = chars_format::general); + from_chars_result from_chars(const char* first, const char* last, long double& value, + chars_format fmt = chars_format::general); +} +\end{codeblock} + +\rSec2[charconv.to.chars]{Primitive numeric output conversion} + +\pnum +All functions named \tcode{to_chars} +convert \tcode{value} into a character string +by successively filling the range +\range{first}{last}, +where \range{first}{last} is required to be a valid range. +If the member \tcode{ec} +of the return value +is such that the value +is equal to the value of a value-initialized \tcode{errc}, +the conversion was successful +and the member \tcode{ptr} +is the one-past-the-end pointer of the characters written. +Otherwise, +the member \tcode{ec} has the value \tcode{errc::value_too_large}, +the member \tcode{ptr} has the value \tcode{last}, +and the contents of the range \range{first}{last} are unspecified. + +\pnum +The functions that take a floating-point \tcode{value} +but not a \tcode{precision} parameter +ensure that the string representation +consists of the smallest number of characters +such that +there is at least one digit before the radix point (if present) and +parsing the representation using the corresponding \tcode{from_chars} function +recovers \tcode{value} exactly. +\begin{note} +This guarantee applies only if +\tcode{to_chars} and \tcode{from_chars} +are executed on the same implementation. +\end{note} +If there are several such representations, +the representation with the smallest difference from +the floating-point argument value is chosen, +resolving any remaining ties using rounding according to +\tcode{round_to_nearest}\iref{round.style}. + +\pnum +The functions taking a \tcode{chars_format} parameter +determine the conversion specifier for \tcode{printf} as follows: +The conversion specifier is +\tcode{f} if \tcode{fmt} is \tcode{chars_format::fixed}, +\tcode{e} if \tcode{fmt} is \tcode{chars_format::scientific}, +\tcode{a} (without leading \tcode{"0x"} in the result) +if \tcode{fmt} is \tcode{chars_format::hex}, +and +\tcode{g} if \tcode{fmt} is \tcode{chars_format::general}. + +\indexlibrary{\idxcode{to_chars}}% +\begin{itemdecl} +to_chars_result to_chars(char* first, char* last, @\seebelow@ value, int base = 10); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\requires \tcode{base} has a value between 2 and 36 (inclusive). + +\pnum +\effects The value of \tcode{value} is converted +to a string of digits in the given base +(with no redundant leading zeroes). +Digits in the range 10..35 (inclusive) +are represented as lowercase characters \tcode{a}..\tcode{z}. +If \tcode{value} is less than zero, +the representation starts with a minus sign. + +\pnum +\throws Nothing. + +\pnum +\remarks +The implementation shall provide overloads +for all signed and unsigned integer types +and \tcode{char} +as the type of the parameter \tcode{value}. +\end{itemdescr} + +\indexlibrary{\idxcode{to_chars}}% +\begin{itemdecl} +to_chars_result to_chars(char* first, char* last, float value); +to_chars_result to_chars(char* first, char* last, double value); +to_chars_result to_chars(char* first, char* last, long double value); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\effects \tcode{value} is converted to a string +in the style of \tcode{printf} +in the \tcode{"C"} locale. +The conversion specifier is \tcode{f} or \tcode{e}, +chosen according to the requirement for a shortest representation +(see above); +a tie is resolved in favor of \tcode{f}. + +\pnum +\throws Nothing. +\end{itemdescr} + +\indexlibrary{\idxcode{to_chars}}% +\begin{itemdecl} +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); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\requires \tcode{fmt} has the value of +one of the enumerators of \tcode{chars_format}. + +\pnum +\effects \tcode{value} is converted to a string +in the style of \tcode{printf} +in the \tcode{"C"} locale. + +\pnum +\throws Nothing. +\end{itemdescr} + +\indexlibrary{\idxcode{to_chars}}% +\begin{itemdecl} +to_chars_result to_chars(char* first, char* last, float value, + chars_format fmt, int precision); +to_chars_result to_chars(char* first, char* last, double value, + chars_format fmt, int precision); +to_chars_result to_chars(char* first, char* last, long double value, + chars_format fmt, int precision); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\requires \tcode{fmt} has the value of +one of the enumerators of \tcode{chars_format}. + +\pnum +\effects \tcode{value} is converted to a string +in the style of \tcode{printf} +in the \tcode{"C"} locale +with the given precision. + +\pnum +\throws Nothing. +\end{itemdescr} + +\xref ISO C 7.21.6.1 + +\rSec2[charconv.from.chars]{Primitive numeric input conversion} + +\pnum +All functions named \tcode{from_chars} +analyze the string \range{first}{last} +for a pattern, +where \range{first}{last} is required to be a valid range. +If no characters match the pattern, +\tcode{value} is unmodified, +the member \tcode{ptr} of the return value is \tcode{first} and +the member \tcode{ec} is equal to \tcode{errc::invalid_argument}. +\begin{note} If the pattern allows for an optional sign, +but the string has no digit characters following the sign, +no characters match the pattern. \end{note} +Otherwise, +the characters matching the pattern +are interpreted as a representation +of a value of the type of \tcode{value}. +The member \tcode{ptr} +of the return value +points to the first character +not matching the pattern, +or has the value \tcode{last} +if all characters match. +If the parsed value +is not in the range +representable by the type of \tcode{value}, +\tcode{value} is unmodified and +the member \tcode{ec} of the return value +is equal to \tcode{errc::result_out_of_range}. +Otherwise, +\tcode{value} is set to the parsed value, +after rounding according to \tcode{round_to_nearest}\iref{round.style}, and +the member \tcode{ec} is value-initialized. + +\indexlibrary{\idxcode{from_chars}}% +\begin{itemdecl} +from_chars_result from_chars(const char* first, const char* last, + @\seebelow@&@\itcorr[-1]@ value, int base = 10); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\requires \tcode{base} has a value between 2 and 36 (inclusive). + +\pnum +\effects The pattern is the expected form of the subject sequence +in the \tcode{"C"} locale +for the given nonzero base, +as described for \tcode{strtol}, +except that no \tcode{"0x"} or \tcode{"0X"} prefix shall appear +if the value of \tcode{base} is 16, +and except that a minus sign +is the only sign that may appear, +and only if \tcode{value} has a signed type. + +\pnum +\throws Nothing. + +\pnum +\remarks +The implementation shall provide overloads +for all signed and unsigned integer types +and \tcode{char} +as the referenced type of the parameter \tcode{value}. +\end{itemdescr} + +\indexlibrary{\idxcode{from_chars}}% +\begin{itemdecl} +from_chars_result from_chars(const char* first, const char* last, float& value, + chars_format fmt = chars_format::general); +from_chars_result from_chars(const char* first, const char* last, double& value, + chars_format fmt = chars_format::general); +from_chars_result from_chars(const char* first, const char* last, long double& value, + chars_format fmt = chars_format::general); +\end{itemdecl} + +\begin{itemdescr} +\pnum +\requires \tcode{fmt} has the value of +one of the enumerators of \tcode{chars_format}. + +\pnum +\effects The pattern is the expected form of the subject sequence +in the \tcode{"C"} locale, +as described for \tcode{strtod}, +except that +\begin{itemize} +\item +the only sign that may appear is a minus sign; +\item +if \tcode{fmt} has \tcode{chars_format::scientific} set +but not \tcode{chars_format::fixed}, +the otherwise optional exponent part shall appear; +\item +if \tcode{fmt} has \tcode{chars_format::fixed} set +but not \tcode{chars_format::scientific}, +the optional exponent part shall not appear; and +\item +if \tcode{fmt} is \tcode{chars_format::hex}, +the prefix \tcode{"0x"} or \tcode{"0X"} is assumed. +\begin{example} +The string \tcode{0x123} +is parsed to have the value +\tcode{0} +with remaining characters \tcode{x123}. +\end{example} +\end{itemize} +In any case, the resulting \tcode{value} is one of +at most two floating-point values +closest to the value of the string matching the pattern. + +\pnum +\throws Nothing. +\end{itemdescr} + +\xref ISO C 7.22.1.3, 7.22.1.4 + diff --git a/source/xrefdelta.tex b/source/xrefdelta.tex index a89058b8fd..977606eb95 100644 --- a/source/xrefdelta.tex +++ b/source/xrefdelta.tex @@ -15,101 +15,16 @@ \newcommand{\deprxref}[1]{\oldxref{#1}{\textit{see} \secref{depr.#1}}} % Removed features. -\removedxref{depr.auto.ptr} -\removedxref{auto.ptr} -\removedxref{auto.ptr.cons} -\removedxref{auto.ptr.conv} -\removedxref{auto.ptr.members} -\removedxref{depr.incr.bool} -\removedxref{exception.unexpected} -\removedxref{except.unexpected} -\removedxref{get.unexpected} -\removedxref{set.unexpected} -\removedxref{unexpected} -\removedxref{unexpected.handler} -\removedxref{depr.adaptors} -\removedxref{depr.base} -\removedxref{depr.function.objects} -\removedxref{depr.function.pointer.adaptors} -\removedxref{depr.lib.bind.1st} -\removedxref{depr.lib.bind.2nd} -\removedxref{depr.lib.binder.1st} -\removedxref{depr.lib.binder.2nd} -\removedxref{depr.lib.binders} -\removedxref{depr.member.pointer.adaptors} -\removedxref{depr.ios.members} -\removedxref{depr.alg.random.shuffle} -\removedxref{depr.register} -\removedxref{lex.trigraph} +%\removedxref{removed.label} +\removedxref{variant.traits} % Renamed sections. -\movedxref{atomics.types.operations.arith}{atomics.types.int} -\movedxref{atomics.types.operations.general}{atomics.types.operations} -\movedxref{atomics.types.operations.pointer}{atomics.types.pointer} -\movedxref{atomics.types.operations.req}{atomics.types.operations} -\movedxref{atomics.types.operations.templ}{atomics.types.operations} -\movedxrefii{basic.start.init}{basic.start.static}{basic.start.dynamic} -\movedxref{bind}{func.bind} -\movedxref{charname}{lex.name} -\movedxrefs{charname.allowed}{Table~\ref{tab:charname.allowed}} -\movedxrefs{charname.disallowed}{Table~\ref{tab:charname.disallowed}} -\movedxrefii{class.inhctor}{class.inhctor.init}{namespace.udecl} -\movedxref{c.limits}{climits.syn} -\movedxref{date.time}{ctime.syn} -\movedxref{defns.additional}{definitions} -\movedxref{expr.prim.general}{expr.prim} -\movedxref{fstreams}{fstream.syn} -\movedxref{global.names}{lex.name} -\movedxrefiii{iostream.format.overview}{istream.syn}{ostream.syn}{iomanip.syn} -\movedxref{iostreams.base.overview}{ios.syn} -\movedxref{limits}{support.limits} -\movedxrefii{limits.numeric}{support.limits.general}{limits.syn} -\movedxref{stream.buffers.overview}{streambuf.syn} -\movedxref{string.streams.overview}{sstream.syn} -\movedxref{uninitialized.fill.n}{uninitialized.fill} -\movedxref{util.smartptr.weakptr}{util.smartptr.weak.bad} +%\movedxref{old.label}{new.label} +%\movedxrefii{old.label}{new.label.1}{new.label.2} +%\movedxrefiii{old.label}{new.label.1}{new.label.2}{new.label.3} +%\movedxrefs{old.label}{new place (eg Table~\ref{tab:blah})} +\movedxref{utility.from.chars}{charconv.from.chars} +\movedxref{utility.to.chars}{charconv.to.chars} % Deprecated features. -\movedxref{ccmplx}{depr.ccomplex.syn} -\deprxref{conversions.buffer} -\deprxref{conversions.string} -\deprxref{iterator.basic} -\deprxref{locale.stdcvt} -\deprxref{negators} -\deprxref{storage.iterator} -\deprxref{temporary.buffer} -\deprxref{uncaught} - -% :: -> . -\movedxref{istream::extractors}{istream.extractors} -\movedxref{string::append}{string.append} -\movedxref{string::assign}{string.assign} -\movedxref{string::compare}{string.compare} -\movedxref{string::copy}{string.copy} -\movedxref{string::erase}{string.erase} -\movedxref{string::find}{string.find} -\movedxref{string::find.first.not.of}{string.find.first.not.of} -\movedxref{string::find.first.of}{string.find.first.of} -\movedxref{string::find.last.not.of}{string.find.last.not.of} -\movedxref{string::find.last.of}{string.find.last.of} -\movedxref{string::insert}{string.insert} -\movedxref{string::op<}{string.op<} -\movedxref{string::op<=}{string.op<=} -\movedxref{string::op>}{string.op>} -\movedxref{string::op>=}{string.op>=} -\movedxref{string::op!=}{string.op!=} -\movedxref{string::op+}{string.op+} -\movedxref{string::op+=}{string.op+=} -\movedxref{string::operator==}{string.operator==} -\movedxref{string::replace}{string.replace} -\movedxref{string::rfind}{string.rfind} -\movedxref{string::substr}{string.substr} -\movedxref{string::swap}{string.swap} - -% Merged sections. -\movedxref{istreambuf.iterator::proxy}{istreambuf.iterator.proxy} -\movedxref{istreambuf.iterator::op*}{istreambuf.iterator.ops} -\movedxref{istreambuf.iterator::op++}{istreambuf.iterator.ops} -\movedxref{istreambuf.iterator::equal}{istreambuf.iterator.ops} -\movedxref{istreambuf.iterator::op==}{istreambuf.iterator.ops} -\movedxref{istreambuf.iterator::op!=}{istreambuf.iterator.ops} +%\deprxref{old.label} (if moved to depr.old.label, otherwise use \movedxref)