From Jason Turner

[constraints]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmphiwwgh95/{from.md → to.md} +125 -73
tmp/tmphiwwgh95/{from.md → to.md} RENAMED
@@ -19,20 +19,21 @@ The behavior of a C++program is undefined if it adds declarations or
19
  definitions to namespace `std` or to a namespace within namespace `std`
20
  unless otherwise specified. A program may add a template specialization
21
  for any standard library template to namespace `std` only if the
22
  declaration depends on a user-defined type and the specialization meets
23
  the standard library requirements for the original template and is not
24
- explicitly prohibited.[^22]
25
 
26
  The behavior of a C++program is undefined if it declares
27
 
28
  - an explicit specialization of any member function of a standard
29
  library class template, or
30
  - an explicit specialization of any member function template of a
31
  standard library class or class template, or
32
  - an explicit or partial specialization of any member class template of
33
- a standard library class or class template.
 
34
 
35
  A program may explicitly instantiate a template defined in the standard
36
  library only if the declaration depends on the name of a user-defined
37
  type and the instantiation meets the standard library requirements for
38
  the original template.
@@ -45,10 +46,20 @@ namespace ([[namespace.def]]).
45
  The behavior of a C++program is undefined if it adds declarations or
46
  definitions to namespace `posix` or to a namespace within namespace
47
  `posix` unless otherwise specified. The namespace `posix` is reserved
48
  for use by ISO/IEC 9945 and other POSIX standards.
49
 
 
 
 
 
 
 
 
 
 
 
50
  #### Reserved names <a id="reserved.names">[[reserved.names]]</a>
51
 
52
  The C++standard library reserves the following kinds of names:
53
 
54
  - macros
@@ -57,61 +68,81 @@ The C++standard library reserves the following kinds of names:
57
 
58
  If a program declares or defines a name in a context where it is
59
  reserved, other than as explicitly allowed by this Clause, its behavior
60
  is undefined.
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  ##### Macro names <a id="macro.names">[[macro.names]]</a>
63
 
64
  A translation unit that includes a standard library header shall not
65
  `#define` or `#undef` names declared in any standard library header.
66
 
67
  A translation unit shall not `#define` or `#undef` names lexically
68
  identical to keywords, to the identifiers listed in Table 
69
  [[tab:identifiers.special]], or to the *attribute-token*s described in 
70
  [[dcl.attr]].
71
 
72
- ##### Global names <a id="global.names">[[global.names]]</a>
73
-
74
- Certain sets of names and function signatures are always reserved to the
75
- implementation:
76
-
77
- - Each name that contains a double underscore `__` or begins with an
78
- underscore followed by an uppercase letter ([[lex.key]]) is reserved
79
- to the implementation for any use.
80
- - Each name that begins with an underscore is reserved to the
81
- implementation for use as a name in the global namespace.
82
-
83
  ##### External linkage <a id="extern.names">[[extern.names]]</a>
84
 
85
  Each name declared as an object with external linkage in a header is
86
  reserved to the implementation to designate that library object with
87
- external linkage, [^23] both in namespace `std` and in the global
88
  namespace.
89
 
90
  Each global function signature declared with external linkage in a
91
  header is reserved to the implementation to designate that function
92
- signature with external linkage. [^24]
93
 
94
- Each name from the Standard C library declared with external linkage is
95
  reserved to the implementation for use as a name with `extern "C"`
96
- linkage, both in namespace std and in the global namespace.
97
 
98
- Each function signature from the Standard C library declared with
99
  external linkage is reserved to the implementation for use as a function
100
- signature with both `extern "C"` and `extern "C++"` linkage, [^25] or as
101
  a name of namespace scope in the global namespace.
102
 
103
  ##### Types <a id="extern.types">[[extern.types]]</a>
104
 
105
- For each type T from the Standard C library,[^26] the types `::T` and
106
  `std::T` are reserved to the implementation and, when defined, `::T`
107
  shall be identical to `std::T`.
108
 
109
  ##### User-defined literal suffixes <a id="usrlit.suffix">[[usrlit.suffix]]</a>
110
 
111
- Literal suffix identifiers that do not start with an underscore are
112
- reserved for future standardization.
113
 
114
  #### Headers <a id="alt.headers">[[alt.headers]]</a>
115
 
116
  If a file with a name equivalent to the derived file name for one of the
117
  C++standard library headers is not provided as part of the
@@ -131,55 +162,73 @@ Clauses  [[language.support]] through  [[thread]] and Annex  [[depr]]
131
  describe the behavior of numerous functions defined by the C++standard
132
  library. Under some circumstances, however, certain of these function
133
  descriptions also apply to replacement functions defined in the
134
  program ([[definitions]]).
135
 
136
- A C++program may provide the definition for any of twelve dynamic memory
137
- allocation function signatures declared in header `<new>` (
138
  [[basic.stc.dynamic]], [[support.dynamic]]):
139
 
140
- - `operator new(std::size_t)`
141
- - `operator new(std::size_t, const std::nothrow_t&)`
142
- - `operator new[](std::size_t)`
143
- - `operator new[](std::size_t, const std::nothrow_t&)`
144
- - `operator delete(void*)`
145
- - `operator delete(void*, const std::nothrow_t&)`
146
- - `operator delete[](void*)`
147
- - `operator delete[](void*, const std::nothrow_t&)`
148
- - `operator delete(void*, std::size_t)`
149
- - `operator delete(void*, std::size_t, const std::nothrow_t&)`
150
- - `operator delete[](void*, std::size_t)`
151
- - `operator delete[](void*, std::size_t, const std::nothrow_t&)`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
 
153
  The program’s definitions are used instead of the default versions
154
  supplied by the implementation ([[support.dynamic]]). Such replacement
155
  occurs prior to program startup ([[basic.def.odr]], [[basic.start]]).
156
- The program’s definitions shall not be specified as `inline`. No
157
  diagnostic is required.
158
 
159
  #### Handler functions <a id="handler.functions">[[handler.functions]]</a>
160
 
161
- The C++standard library provides default versions of the following
162
- handler functions (Clause  [[language.support]]):
163
 
164
- - `unexpected_handler`
165
  - `terminate_handler`
166
 
167
  A C++program may install different handler functions during execution,
168
  by supplying a pointer to a function defined in the program or the
169
  library as an argument to (respectively):
170
 
171
  - `set_new_handler`
172
- - `set_unexpected`
173
- - `set_terminate` subclauses  [[alloc.errors]], Storage allocation
174
- errors, and  [[support.exception]], Exception handling.
 
175
 
176
  A C++program can get a pointer to the current handler function by
177
  calling the following functions:
178
 
179
  - `get_new_handler`
180
- - `get_unexpected`
181
  - `get_terminate`
182
 
183
  Calling the `set_*` and `get_*` functions shall not incur a data race. A
184
  call to any of the `set_*` functions shall synchronize with subsequent
185
  calls to the same `set_*` function and to the corresponding `get_*`
@@ -188,26 +237,26 @@ function.
188
  #### Other functions <a id="res.on.functions">[[res.on.functions]]</a>
189
 
190
  In certain cases (replacement functions, handler functions, operations
191
  on types used to instantiate standard library template components), the
192
  C++standard library depends on components supplied by a C++program. If
193
- these components do not meet their requirements, the Standard places no
194
- requirements on the implementation.
195
 
196
  In particular, the effects are undefined in the following cases:
197
 
198
  - for replacement functions ([[new.delete]]), if the installed
199
  replacement function does not implement the semantics of the
200
  applicable *Required behavior:* paragraph.
201
- - for handler functions ([[new.handler]], [[terminate.handler]],
202
- [[unexpected.handler]]), if the installed handler function does not
203
- implement the semantics of the applicable *Required behavior:*
204
- paragraph
205
  - for types used as template arguments when instantiating a template
206
  component, if the operations on the type do not implement the
207
- semantics of the applicable subclause ([[allocator.requirements]],
208
- [[container.requirements]], [[iterator.requirements]],
 
209
  [[numeric.requirements]]). Operations on such types can report a
210
  failure by throwing an exception unless otherwise specified.
211
  - if any replacement function or handler function or destructor
212
  operation exits via an exception, unless specifically allowed in the
213
  applicable *Required behavior:* paragraph.
@@ -228,37 +277,40 @@ the C++standard library, unless explicitly stated otherwise.
228
  address computations and accesses to objects (that would be valid if
229
  the pointer did point to the first element of such an array) are in
230
  fact valid.
231
  - If a function argument binds to an rvalue reference parameter, the
232
  implementation may assume that this parameter is a unique reference to
233
- this argument. If the parameter is a generic parameter of the form
234
- `T&&` and an lvalue of type `A` is bound, the argument binds to an
235
- lvalue reference ([[temp.deduct.call]]) and thus is not covered by
236
- the previous sentence. If a program casts an lvalue to an xvalue while
237
- passing that lvalue to a library function (e.g. by calling the
238
- function with the argument `move(x)`), the program is effectively
239
- asking that function to treat that lvalue as a temporary. The
240
- implementation is free to optimize away aliasing checks which might be
241
- needed if the argument was an lvalue.
 
242
 
243
- #### Shared objects and the library <a id="res.on.objects">[[res.on.objects]]</a>
244
 
245
  The behavior of a program is undefined if calls to standard library
246
  functions from different threads may introduce a data race. The
247
  conditions under which this may occur are specified in 
248
- [[res.on.data.races]]. Modifying an object of a standard library type
249
- that is shared between threads risks undefined behavior unless objects
250
- of that type are explicitly specified as being sharable without data
251
- races or the user supplies a locking mechanism.
252
 
253
- In particular, the program is required to ensure that completion of the
254
- constructor of any object of a class type defined in the standard
255
- library happens before any other member function invocation on that
256
- object and, unless otherwise specified, to ensure that completion of any
257
- member function invocation other than destruction on such an object
258
- happens before destruction of that object. This applies even to objects
259
- such as mutexes intended for thread synchronization.
 
 
 
 
 
260
 
261
  #### Requires paragraph <a id="res.on.required">[[res.on.required]]</a>
262
 
263
  Violation of the preconditions specified in a function’s *Requires:*
264
  paragraph results in undefined behavior unless the function’s *Throws:*
 
19
  definitions to namespace `std` or to a namespace within namespace `std`
20
  unless otherwise specified. A program may add a template specialization
21
  for any standard library template to namespace `std` only if the
22
  declaration depends on a user-defined type and the specialization meets
23
  the standard library requirements for the original template and is not
24
+ explicitly prohibited.[^21]
25
 
26
  The behavior of a C++program is undefined if it declares
27
 
28
  - an explicit specialization of any member function of a standard
29
  library class template, or
30
  - an explicit specialization of any member function template of a
31
  standard library class or class template, or
32
  - an explicit or partial specialization of any member class template of
33
+ a standard library class or class template, or
34
+ - a deduction guide for any standard library class template.
35
 
36
  A program may explicitly instantiate a template defined in the standard
37
  library only if the declaration depends on the name of a user-defined
38
  type and the instantiation meets the standard library requirements for
39
  the original template.
 
46
  The behavior of a C++program is undefined if it adds declarations or
47
  definitions to namespace `posix` or to a namespace within namespace
48
  `posix` unless otherwise specified. The namespace `posix` is reserved
49
  for use by ISO/IEC 9945 and other POSIX standards.
50
 
51
+ ##### Namespaces for future standardization <a id="namespace.future">[[namespace.future]]</a>
52
+
53
+ Top level namespaces with a name starting with `std` and followed by a
54
+ non-empty sequence of digits are reserved for future standardization.
55
+ The behavior of a C++program is undefined if it adds declarations or
56
+ definitions to such a namespace.
57
+
58
+ [*Example 1*: The top level namespace `std2` is reserved for use by
59
+ future revisions of this International Standard. — *end example*]
60
+
61
  #### Reserved names <a id="reserved.names">[[reserved.names]]</a>
62
 
63
  The C++standard library reserves the following kinds of names:
64
 
65
  - macros
 
68
 
69
  If a program declares or defines a name in a context where it is
70
  reserved, other than as explicitly allowed by this Clause, its behavior
71
  is undefined.
72
 
73
+ ##### Zombie names <a id="zombie.names">[[zombie.names]]</a>
74
+
75
+ In namespace `std`, the following names are reserved for previous
76
+ standardization:
77
+
78
+ - `auto_ptr`,
79
+ - `binary_function`,
80
+ - `bind1st`,
81
+ - `bind2nd`,
82
+ - `binder1st`,
83
+ - `binder2nd`,
84
+ - `const_mem_fun1_ref_t`,
85
+ - `const_mem_fun1_t`,
86
+ - `const_mem_fun_ref_t`,
87
+ - `const_mem_fun_t`,
88
+ - `get_unexpected`,
89
+ - `mem_fun1_ref_t`,
90
+ - `mem_fun1_t`,
91
+ - `mem_fun_ref_t`,
92
+ - `mem_fun_ref`,
93
+ - `mem_fun_t`,
94
+ - `mem_fun`,
95
+ - `pointer_to_binary_function`,
96
+ - `pointer_to_unary_function`,
97
+ - `ptr_fun`,
98
+ - `random_shuffle`,
99
+ - `set_unexpected`,
100
+ - `unary_function`,
101
+ - `unexpected`, and
102
+ - `unexpected_handler`.
103
+
104
  ##### Macro names <a id="macro.names">[[macro.names]]</a>
105
 
106
  A translation unit that includes a standard library header shall not
107
  `#define` or `#undef` names declared in any standard library header.
108
 
109
  A translation unit shall not `#define` or `#undef` names lexically
110
  identical to keywords, to the identifiers listed in Table 
111
  [[tab:identifiers.special]], or to the *attribute-token*s described in 
112
  [[dcl.attr]].
113
 
 
 
 
 
 
 
 
 
 
 
 
114
  ##### External linkage <a id="extern.names">[[extern.names]]</a>
115
 
116
  Each name declared as an object with external linkage in a header is
117
  reserved to the implementation to designate that library object with
118
+ external linkage, [^22] both in namespace `std` and in the global
119
  namespace.
120
 
121
  Each global function signature declared with external linkage in a
122
  header is reserved to the implementation to designate that function
123
+ signature with external linkage.[^23]
124
 
125
+ Each name from the C standard library declared with external linkage is
126
  reserved to the implementation for use as a name with `extern "C"`
127
+ linkage, both in namespace `std` and in the global namespace.
128
 
129
+ Each function signature from the C standard library declared with
130
  external linkage is reserved to the implementation for use as a function
131
+ signature with both `extern "C"` and `extern "C++"` linkage,[^24] or as
132
  a name of namespace scope in the global namespace.
133
 
134
  ##### Types <a id="extern.types">[[extern.types]]</a>
135
 
136
+ For each type T from the C standard library,[^25] the types `::T` and
137
  `std::T` are reserved to the implementation and, when defined, `::T`
138
  shall be identical to `std::T`.
139
 
140
  ##### User-defined literal suffixes <a id="usrlit.suffix">[[usrlit.suffix]]</a>
141
 
142
+ Literal suffix identifiers ([[over.literal]]) that do not start with an
143
+ underscore are reserved for future standardization.
144
 
145
  #### Headers <a id="alt.headers">[[alt.headers]]</a>
146
 
147
  If a file with a name equivalent to the derived file name for one of the
148
  C++standard library headers is not provided as part of the
 
162
  describe the behavior of numerous functions defined by the C++standard
163
  library. Under some circumstances, however, certain of these function
164
  descriptions also apply to replacement functions defined in the
165
  program ([[definitions]]).
166
 
167
+ A C++program may provide the definition for any of the following dynamic
168
+ memory allocation function signatures declared in header `<new>` (
169
  [[basic.stc.dynamic]], [[support.dynamic]]):
170
 
171
+ ``` cpp
172
+ operator new(std::size_t)
173
+ operator new(std::size_t, std::align_val_t)
174
+ operator new(std::size_t, const std::nothrow_t&)
175
+ operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
176
+ ```
177
+
178
+ ``` cpp
179
+ operator delete(void*)
180
+ operator delete(void*, std::size_t)
181
+ operator delete(void*, std::align_val_t)
182
+ operator delete(void*, std::size_t, std::align_val_t)
183
+ operator delete(void*, const std::nothrow_t&)
184
+ operator delete(void*, std::align_val_t, const std::nothrow_t&)
185
+ ```
186
+
187
+ ``` cpp
188
+ operator new[](std::size_t)
189
+ operator new[](std::size_t, std::align_val_t)
190
+ operator new[](std::size_t, const std::nothrow_t&)
191
+ operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
192
+ ```
193
+
194
+ ``` cpp
195
+ operator delete[](void*)
196
+ operator delete[](void*, std::size_t)
197
+ operator delete[](void*, std::align_val_t)
198
+ operator delete[](void*, std::size_t, std::align_val_t)
199
+ operator delete[](void*, const std::nothrow_t&)
200
+ operator delete[](void*, std::align_val_t, const std::nothrow_t&)
201
+ ```
202
 
203
  The program’s definitions are used instead of the default versions
204
  supplied by the implementation ([[support.dynamic]]). Such replacement
205
  occurs prior to program startup ([[basic.def.odr]], [[basic.start]]).
206
+ The program’s declarations shall not be specified as `inline`. No
207
  diagnostic is required.
208
 
209
  #### Handler functions <a id="handler.functions">[[handler.functions]]</a>
210
 
211
+ The C++standard library provides a default version of the following
212
+ handler function (Clause  [[language.support]]):
213
 
 
214
  - `terminate_handler`
215
 
216
  A C++program may install different handler functions during execution,
217
  by supplying a pointer to a function defined in the program or the
218
  library as an argument to (respectively):
219
 
220
  - `set_new_handler`
221
+ - `set_terminate`
222
+
223
+ See also subclauses  [[alloc.errors]], Storage allocation errors, and 
224
+ [[support.exception]], Exception handling.
225
 
226
  A C++program can get a pointer to the current handler function by
227
  calling the following functions:
228
 
229
  - `get_new_handler`
 
230
  - `get_terminate`
231
 
232
  Calling the `set_*` and `get_*` functions shall not incur a data race. A
233
  call to any of the `set_*` functions shall synchronize with subsequent
234
  calls to the same `set_*` function and to the corresponding `get_*`
 
237
  #### Other functions <a id="res.on.functions">[[res.on.functions]]</a>
238
 
239
  In certain cases (replacement functions, handler functions, operations
240
  on types used to instantiate standard library template components), the
241
  C++standard library depends on components supplied by a C++program. If
242
+ these components do not meet their requirements, this International
243
+ Standard places no requirements on the implementation.
244
 
245
  In particular, the effects are undefined in the following cases:
246
 
247
  - for replacement functions ([[new.delete]]), if the installed
248
  replacement function does not implement the semantics of the
249
  applicable *Required behavior:* paragraph.
250
+ - for handler functions ([[new.handler]], [[terminate.handler]]), if
251
+ the installed handler function does not implement the semantics of the
252
+ applicable *Required behavior:* paragraph
 
253
  - for types used as template arguments when instantiating a template
254
  component, if the operations on the type do not implement the
255
+ semantics of the applicable *Requirements* subclause (
256
+ [[allocator.requirements]], [[container.requirements]],
257
+ [[iterator.requirements]], [[algorithms.requirements]],
258
  [[numeric.requirements]]). Operations on such types can report a
259
  failure by throwing an exception unless otherwise specified.
260
  - if any replacement function or handler function or destructor
261
  operation exits via an exception, unless specifically allowed in the
262
  applicable *Required behavior:* paragraph.
 
277
  address computations and accesses to objects (that would be valid if
278
  the pointer did point to the first element of such an array) are in
279
  fact valid.
280
  - If a function argument binds to an rvalue reference parameter, the
281
  implementation may assume that this parameter is a unique reference to
282
+ this argument. \[*Note 1*: If the parameter is a generic parameter of
283
+ the form `T&&` and an lvalue of type `A` is bound, the argument binds
284
+ to an lvalue reference ([[temp.deduct.call]]) and thus is not covered
285
+ by the previous sentence. *end note*] \[*Note 2*: If a program
286
+ casts an lvalue to an xvalue while passing that lvalue to a library
287
+ function (e.g. by calling the function with the argument
288
+ `std::move(x)`), the program is effectively asking that function to
289
+ treat that lvalue as a temporary. The implementation is free to
290
+ optimize away aliasing checks which might be needed if the argument
291
+ was an lvalue. — *end note*]
292
 
293
+ #### Library object access <a id="res.on.objects">[[res.on.objects]]</a>
294
 
295
  The behavior of a program is undefined if calls to standard library
296
  functions from different threads may introduce a data race. The
297
  conditions under which this may occur are specified in 
298
+ [[res.on.data.races]].
 
 
 
299
 
300
+ [*Note 1*: Modifying an object of a standard library type that is
301
+ shared between threads risks undefined behavior unless objects of that
302
+ type are explicitly specified as being sharable without data races or
303
+ the user supplies a locking mechanism. *end note*]
304
+
305
+ If an object of a standard library type is accessed, and the beginning
306
+ of the object’s lifetime ([[basic.life]]) does not happen before the
307
+ access, or the access does not happen before the end of the object’s
308
+ lifetime, the behavior is undefined unless otherwise specified.
309
+
310
+ [*Note 2*: This applies even to objects such as mutexes intended for
311
+ thread synchronization. — *end note*]
312
 
313
  #### Requires paragraph <a id="res.on.required">[[res.on.required]]</a>
314
 
315
  Violation of the preconditions specified in a function’s *Requires:*
316
  paragraph results in undefined behavior unless the function’s *Throws:*