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.contract.general">[[basic.contract.general]]</a>
|
| 4 |
+
|
| 5 |
+
*Contract assertions* allow the programmer to specify properties of the
|
| 6 |
+
state of the program that are expected to hold at certain points during
|
| 7 |
+
execution. Contract assertions are introduced by
|
| 8 |
+
*precondition-specifier*s, *postcondition-specifier*s
|
| 9 |
+
[[dcl.contract.func]], and *assertion-statement*s
|
| 10 |
+
[[stmt.contract.assert]].
|
| 11 |
+
|
| 12 |
+
Each contract assertion has a *contract-assertion predicate*, which is
|
| 13 |
+
an expression of type `bool`.
|
| 14 |
+
|
| 15 |
+
[*Note 1*: The value of the predicate is used to identify program
|
| 16 |
+
states that are expected. — *end note*]
|
| 17 |
+
|
| 18 |
+
An invocation of the macro `va_start` [[cstdarg.syn]] shall not be a
|
| 19 |
+
subexpression of the predicate of a contract assertion, no diagnostic
|
| 20 |
+
required.
|
| 21 |
+
|
| 22 |
+
[*Note 2*: Within the predicate of a contract assertion,
|
| 23 |
+
*id-expression*s referring to variables declared outside the contract
|
| 24 |
+
assertion are `const` [[expr.prim.id.unqual]], `this` is a pointer to
|
| 25 |
+
`const` [[expr.prim.this]], and the result object can be named if a
|
| 26 |
+
*result-name-introducer* [[dcl.contract.res]] has been
|
| 27 |
+
specified. — *end note*]
|
| 28 |
+
|
| 29 |
+
### Evaluation <a id="basic.contract.eval">[[basic.contract.eval]]</a>
|
| 30 |
+
|
| 31 |
+
An evaluation of a contract assertion uses one of the following four
|
| 32 |
+
*evaluation semantics*: *ignore*, *observe*, *enforce*, or
|
| 33 |
+
*quick-enforce*. Observe, enforce, and quick-enforce are *checking
|
| 34 |
+
semantics*; enforce and quick-enforce are *terminating semantics*.
|
| 35 |
+
|
| 36 |
+
It is *implementation-defined* which evaluation semantic is used for any
|
| 37 |
+
given evaluation of a contract assertion.
|
| 38 |
+
|
| 39 |
+
[*Note 1*: The range and flexibility of available choices of evaluation
|
| 40 |
+
semantics depends on the implementation and need not allow all four
|
| 41 |
+
evaluation semantics as possibilities. The evaluation semantics can
|
| 42 |
+
differ for different evaluations of the same contract assertion,
|
| 43 |
+
including evaluations during constant evaluation. — *end note*]
|
| 44 |
+
|
| 45 |
+
*Recommended practice:* An implementation should provide the option to
|
| 46 |
+
translate a program such that all evaluations of contract assertions use
|
| 47 |
+
the ignore semantic as well as the option to translate a program such
|
| 48 |
+
that all evaluations of contract assertions use the enforce semantic. By
|
| 49 |
+
default, evaluations of contract assertions should use the enforce
|
| 50 |
+
semantic.
|
| 51 |
+
|
| 52 |
+
The evaluation of a contract assertion using the ignore semantic has no
|
| 53 |
+
effect.
|
| 54 |
+
|
| 55 |
+
[*Note 2*: The predicate is potentially evaluated [[basic.def.odr]],
|
| 56 |
+
but not evaluated. — *end note*]
|
| 57 |
+
|
| 58 |
+
The evaluation A of a contract assertion using a checking semantic
|
| 59 |
+
determines the value of the predicate. It is unspecified whether the
|
| 60 |
+
predicate is evaluated. Let B be the value that would result from
|
| 61 |
+
evaluating the predicate.
|
| 62 |
+
|
| 63 |
+
[*Note 3*:
|
| 64 |
+
|
| 65 |
+
To determine whether a predicate would evaluate to `true` or `false`, an
|
| 66 |
+
alternative evaluation that produces the same value as the predicate but
|
| 67 |
+
has no side effects can occur.
|
| 68 |
+
|
| 69 |
+
[*Example 1*:
|
| 70 |
+
|
| 71 |
+
``` cpp
|
| 72 |
+
struct S {
|
| 73 |
+
mutable int g = 5;
|
| 74 |
+
} s;
|
| 75 |
+
void f()
|
| 76 |
+
pre(( s.g++, false )); // #1
|
| 77 |
+
void g()
|
| 78 |
+
{
|
| 79 |
+
f(); // Increment of s.g might not occur, even if #1 uses a checking semantic.
|
| 80 |
+
}
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
— *end example*]
|
| 84 |
+
|
| 85 |
+
— *end note*]
|
| 86 |
+
|
| 87 |
+
There is an observable checkpoint [[intro.abstract]] C that happens
|
| 88 |
+
before A such that any other operation O that happens before A also
|
| 89 |
+
happens before C.
|
| 90 |
+
|
| 91 |
+
A *contract violation* occurs when
|
| 92 |
+
|
| 93 |
+
- B is `false`,
|
| 94 |
+
- the evaluation of the predicate exits via an exception, or
|
| 95 |
+
- the evaluation of the predicate is performed in a context that is
|
| 96 |
+
manifestly constant-evaluated [[expr.const]] and the predicate is not
|
| 97 |
+
a core constant expression.
|
| 98 |
+
|
| 99 |
+
[*Note 4*: If B is `true`, no contract violation occurs and control
|
| 100 |
+
flow continues normally after the point of evaluation of the contract
|
| 101 |
+
assertion. The evaluation of the predicate can fail to produce a value
|
| 102 |
+
without causing a contract violation, for example, by calling `longjmp`
|
| 103 |
+
[[csetjmp.syn]] or terminating the program. — *end note*]
|
| 104 |
+
|
| 105 |
+
If a contract violation occurs in a context that is manifestly
|
| 106 |
+
constant-evaluated [[expr.const]], and the evaluation semantic is a
|
| 107 |
+
terminating semantic, the program is ill-formed.
|
| 108 |
+
|
| 109 |
+
[*Note 5*: A diagnostic is produced if the evaluation semantic is
|
| 110 |
+
observe [[intro.compliance]]. — *end note*]
|
| 111 |
+
|
| 112 |
+
[*Note 6*:
|
| 113 |
+
|
| 114 |
+
Different evaluation semantics chosen for the same contract assertion in
|
| 115 |
+
different translation units can result in violations of the
|
| 116 |
+
one-definition rule [[basic.def.odr]] when a contract assertion has side
|
| 117 |
+
effects that alter the value produced by a constant expression.
|
| 118 |
+
|
| 119 |
+
[*Example 2*:
|
| 120 |
+
|
| 121 |
+
``` cpp
|
| 122 |
+
constexpr int f(int i)
|
| 123 |
+
{
|
| 124 |
+
contract_assert((++const_cast<int&>(i), true));
|
| 125 |
+
return i;
|
| 126 |
+
}
|
| 127 |
+
inline void g()
|
| 128 |
+
{
|
| 129 |
+
int a[f(1)]; // size dependent on the evaluation semantic of contract_assert above
|
| 130 |
+
}
|
| 131 |
+
```
|
| 132 |
+
|
| 133 |
+
— *end example*]
|
| 134 |
+
|
| 135 |
+
— *end note*]
|
| 136 |
+
|
| 137 |
+
When the program is *contract-terminated*, it is
|
| 138 |
+
*implementation-defined* (depending on context) whether
|
| 139 |
+
|
| 140 |
+
- `std::terminate` is called,
|
| 141 |
+
- `std::abort` is called, or
|
| 142 |
+
- execution is terminated. \[*Note 7*: No further execution steps occur
|
| 143 |
+
[[intro.progress]]. — *end note*]
|
| 144 |
+
|
| 145 |
+
[*Note 8*: Performing the actions of `std::terminate` or `std::abort`
|
| 146 |
+
without actually making a library call is a conforming implementation of
|
| 147 |
+
contract-termination [[intro.abstract]]. — *end note*]
|
| 148 |
+
|
| 149 |
+
If a contract violation occurs in a context that is not manifestly
|
| 150 |
+
constant-evaluated and the evaluation semantic is quick-enforce, the
|
| 151 |
+
program is contract-terminated.
|
| 152 |
+
|
| 153 |
+
If a contract violation occurs in a context that is not manifestly
|
| 154 |
+
constant-evaluated and the evaluation semantic is enforce or observe,
|
| 155 |
+
the contract-violation handler [[basic.contract.handler]] is invoked
|
| 156 |
+
with an lvalue referring to an object `v` of type
|
| 157 |
+
`const std::contracts::contract_violation`
|
| 158 |
+
[[support.contract.violation]] containing information about the contract
|
| 159 |
+
violation. Storage for `v` is allocated in an unspecified manner except
|
| 160 |
+
as noted in [[basic.stc.dynamic.allocation]]. The lifetime of `v`
|
| 161 |
+
persists for the duration of the invocation of the contract-violation
|
| 162 |
+
handler.
|
| 163 |
+
|
| 164 |
+
If the contract violation occurred because the evaluation of the
|
| 165 |
+
predicate exited via an exception, the contract-violation handler is
|
| 166 |
+
invoked from within an active implicit handler for that exception
|
| 167 |
+
[[except.handle]]. If the contract-violation handler returns normally
|
| 168 |
+
and the evaluation semantic is observe, that implicit handler is no
|
| 169 |
+
longer considered active.
|
| 170 |
+
|
| 171 |
+
[*Note 9*: The exception can be inspected or rethrown within the
|
| 172 |
+
contract-violation handler. — *end note*]
|
| 173 |
+
|
| 174 |
+
If the contract-violation handler returns normally and the evaluation
|
| 175 |
+
semantic is enforce, the program is contract-terminated; if violation
|
| 176 |
+
occurred as the result of an uncaught exception from the evaluation of
|
| 177 |
+
the predicate, the implicit handler remains active when contract
|
| 178 |
+
termination occurs.
|
| 179 |
+
|
| 180 |
+
[*Note 10*: If the contract-violation handler returns normally and the
|
| 181 |
+
evaluation semantic is observe, control flow continues normally after
|
| 182 |
+
the point of evaluation of the contract assertion. — *end note*]
|
| 183 |
+
|
| 184 |
+
There is an observable checkpoint [[intro.abstract]] C that happens
|
| 185 |
+
after the contract-violation handler returns normally such that any
|
| 186 |
+
other operation O that happens after the contract-violation handler
|
| 187 |
+
returns also happens after C.
|
| 188 |
+
|
| 189 |
+
[*Note 11*: The terminating semantics terminate the program if
|
| 190 |
+
execution would otherwise continue normally past a contract violation:
|
| 191 |
+
the enforce semantic provides the opportunity to log information about
|
| 192 |
+
the contract violation before terminating the program or to throw an
|
| 193 |
+
exception to avoid termination, and the quick-enforce semantic is
|
| 194 |
+
intended to terminate the program as soon as possible as well as to
|
| 195 |
+
minimize the impact of contract checks on the generated code size.
|
| 196 |
+
Conversely, the observe semantic provides the opportunity to log
|
| 197 |
+
information about the contract violation without having to terminate the
|
| 198 |
+
program. — *end note*]
|
| 199 |
+
|
| 200 |
+
If a contract-violation handler invoked from the evaluation of a
|
| 201 |
+
function contract assertion [[dcl.contract.func]] exits via an
|
| 202 |
+
exception, the behavior is as if the function body exits via that same
|
| 203 |
+
exception.
|
| 204 |
+
|
| 205 |
+
[*Note 12*: A *function-try-block* [[except.pre]] is the function body
|
| 206 |
+
when present and thus does not have an opportunity to catch the
|
| 207 |
+
exception. If the function has a non-throwing exception specification,
|
| 208 |
+
the function `std::terminate` is invoked
|
| 209 |
+
[[except.terminate]]. — *end note*]
|
| 210 |
+
|
| 211 |
+
[*Note 13*: If a contract-violation handler invoked from an
|
| 212 |
+
*assertion-statement* [[stmt.contract.assert]] exits via an exception,
|
| 213 |
+
the search for a handler continues from the execution of that
|
| 214 |
+
statement. — *end note*]
|
| 215 |
+
|
| 216 |
+
To *evaluate in sequence* a list R of contract assertions:
|
| 217 |
+
|
| 218 |
+
- Construct a list of contract assertions S such that
|
| 219 |
+
- all elements of R are in S,
|
| 220 |
+
- each element of R may be repeated an *implementation-defined* number
|
| 221 |
+
of times within S, and
|
| 222 |
+
- if a contract assertion A precedes another contract assertion B in
|
| 223 |
+
R, then the first occurrence of A precedes the first occurrence of B
|
| 224 |
+
in S.
|
| 225 |
+
- Evaluate each element of S such that, if a contract assertion A
|
| 226 |
+
precedes a contract assertion B in S, then the evaluation of A is
|
| 227 |
+
sequenced before the evaluation of B.
|
| 228 |
+
|
| 229 |
+
[*Example 3*:
|
| 230 |
+
|
| 231 |
+
``` cpp
|
| 232 |
+
void f(int i)
|
| 233 |
+
{
|
| 234 |
+
contract_assert(i > 0); // #1
|
| 235 |
+
contract_assert(i < 10); // #2
|
| 236 |
+
// valid sequence of evaluations: #1 #2
|
| 237 |
+
// valid sequence of evaluations: #1 #1 #2 #2
|
| 238 |
+
// valid sequence of evaluations: #1 #2 #1 #2
|
| 239 |
+
// valid sequence of evaluations: #1 #2 #2 #1
|
| 240 |
+
// invalid sequence of evaluations: #2 #1
|
| 241 |
+
}
|
| 242 |
+
```
|
| 243 |
+
|
| 244 |
+
— *end example*]
|
| 245 |
+
|
| 246 |
+
*Recommended practice:* An implementation should provide an option to
|
| 247 |
+
perform a specified number of repeated evaluations for contract
|
| 248 |
+
assertions. By default, no repeated evaluations should be performed.
|
| 249 |
+
|
| 250 |
+
### Contract-violation handler <a id="basic.contract.handler">[[basic.contract.handler]]</a>
|
| 251 |
+
|
| 252 |
+
The *contract-violation handler* of a program is a function named
|
| 253 |
+
`::handle_contract_violation`. The contract-violation handler shall have
|
| 254 |
+
a single parameter of type “lvalue reference to `const`
|
| 255 |
+
`std::contracts::contract_violation`” and shall return `void`. The
|
| 256 |
+
contract-violation handler may have a non-throwing exception
|
| 257 |
+
specification. The implementation shall provide a definition of the
|
| 258 |
+
contract-violation handler, called the
|
| 259 |
+
*default contract-violation handler*.
|
| 260 |
+
|
| 261 |
+
[*Note 1*: No declaration for the default contract-violation handler is
|
| 262 |
+
provided by any standard library header. — *end note*]
|
| 263 |
+
|
| 264 |
+
*Recommended practice:* The default contract-violation handler should
|
| 265 |
+
produce diagnostic output that suitably formats the most relevant
|
| 266 |
+
contents of the `std::contracts::contract_violation` object,
|
| 267 |
+
rate-limited for potentially repeated violations of observed contract
|
| 268 |
+
assertions, and then return normally.
|
| 269 |
+
|
| 270 |
+
It is *implementation-defined* whether the contract-violation handler is
|
| 271 |
+
replaceable [[term.replaceable.function]]. If the contract-violation
|
| 272 |
+
handler is not replaceable, a declaration of a replacement function for
|
| 273 |
+
the contract-violation handler is ill-formed, no diagnostic required.
|
| 274 |
+
|
| 275 |
+
<!-- Link reference definitions -->
|
| 276 |
+
[allocator.members]: mem.md#allocator.members
|
| 277 |
+
[atomics]: thread.md#atomics
|
| 278 |
+
[atomics.flag]: thread.md#atomics.flag
|
| 279 |
+
[atomics.lockfree]: thread.md#atomics.lockfree
|
| 280 |
+
[atomics.order]: thread.md#atomics.order
|
| 281 |
+
[bad.alloc]: support.md#bad.alloc
|
| 282 |
+
[basic]: #basic
|
| 283 |
+
[basic.align]: #basic.align
|
| 284 |
+
[basic.compound]: #basic.compound
|
| 285 |
+
[basic.contract]: #basic.contract
|
| 286 |
+
[basic.contract.eval]: #basic.contract.eval
|
| 287 |
+
[basic.contract.general]: #basic.contract.general
|
| 288 |
+
[basic.contract.handler]: #basic.contract.handler
|
| 289 |
+
[basic.def]: #basic.def
|
| 290 |
+
[basic.def.odr]: #basic.def.odr
|
| 291 |
+
[basic.exec]: #basic.exec
|
| 292 |
+
[basic.extended.fp]: #basic.extended.fp
|
| 293 |
+
[basic.fundamental]: #basic.fundamental
|
| 294 |
+
[basic.fundamental.width]: #basic.fundamental.width
|
| 295 |
+
[basic.indet]: #basic.indet
|
| 296 |
+
[basic.life]: #basic.life
|
| 297 |
+
[basic.link]: #basic.link
|
| 298 |
+
[basic.lookup]: #basic.lookup
|
| 299 |
+
[basic.lookup.argdep]: #basic.lookup.argdep
|
| 300 |
+
[basic.lookup.elab]: #basic.lookup.elab
|
| 301 |
+
[basic.lookup.general]: #basic.lookup.general
|
| 302 |
+
[basic.lookup.qual]: #basic.lookup.qual
|
| 303 |
+
[basic.lookup.qual.general]: #basic.lookup.qual.general
|
| 304 |
+
[basic.lookup.udir]: #basic.lookup.udir
|
| 305 |
+
[basic.lookup.unqual]: #basic.lookup.unqual
|
| 306 |
+
[basic.lval]: expr.md#basic.lval
|
| 307 |
+
[basic.memobj]: #basic.memobj
|
| 308 |
+
[basic.namespace]: dcl.md#basic.namespace
|
| 309 |
+
[basic.namespace.general]: dcl.md#basic.namespace.general
|
| 310 |
+
[basic.pre]: #basic.pre
|
| 311 |
+
[basic.scope]: #basic.scope
|
| 312 |
+
[basic.scope.block]: #basic.scope.block
|
| 313 |
+
[basic.scope.class]: #basic.scope.class
|
| 314 |
+
[basic.scope.contract]: #basic.scope.contract
|
| 315 |
+
[basic.scope.enum]: #basic.scope.enum
|
| 316 |
+
[basic.scope.lambda]: #basic.scope.lambda
|
| 317 |
+
[basic.scope.namespace]: #basic.scope.namespace
|
| 318 |
+
[basic.scope.param]: #basic.scope.param
|
| 319 |
+
[basic.scope.pdecl]: #basic.scope.pdecl
|
| 320 |
+
[basic.scope.scope]: #basic.scope.scope
|
| 321 |
+
[basic.scope.temp]: #basic.scope.temp
|
| 322 |
+
[basic.splice]: #basic.splice
|
| 323 |
+
[basic.start]: #basic.start
|
| 324 |
+
[basic.start.dynamic]: #basic.start.dynamic
|
| 325 |
+
[basic.start.main]: #basic.start.main
|
| 326 |
+
[basic.start.static]: #basic.start.static
|
| 327 |
+
[basic.start.term]: #basic.start.term
|
| 328 |
+
[basic.stc]: #basic.stc
|
| 329 |
+
[basic.stc.auto]: #basic.stc.auto
|
| 330 |
+
[basic.stc.dynamic]: #basic.stc.dynamic
|
| 331 |
+
[basic.stc.dynamic.allocation]: #basic.stc.dynamic.allocation
|
| 332 |
+
[basic.stc.dynamic.deallocation]: #basic.stc.dynamic.deallocation
|
| 333 |
+
[basic.stc.dynamic.general]: #basic.stc.dynamic.general
|
| 334 |
+
[basic.stc.general]: #basic.stc.general
|
| 335 |
+
[basic.stc.static]: #basic.stc.static
|
| 336 |
+
[basic.stc.thread]: #basic.stc.thread
|
| 337 |
+
[basic.type.qualifier]: #basic.type.qualifier
|
| 338 |
+
[basic.type.qualifier.rel]: #basic.type.qualifier.rel
|
| 339 |
+
[basic.types]: #basic.types
|
| 340 |
+
[basic.types.general]: #basic.types.general
|
| 341 |
+
[bit.cast]: utilities.md#bit.cast
|
| 342 |
+
[c.malloc]: mem.md#c.malloc
|
| 343 |
+
[class]: class.md#class
|
| 344 |
+
[class.abstract]: class.md#class.abstract
|
| 345 |
+
[class.access]: class.md#class.access
|
| 346 |
+
[class.access.base]: class.md#class.access.base
|
| 347 |
+
[class.base.init]: class.md#class.base.init
|
| 348 |
+
[class.bit]: class.md#class.bit
|
| 349 |
+
[class.cdtor]: class.md#class.cdtor
|
| 350 |
+
[class.conv.fct]: class.md#class.conv.fct
|
| 351 |
+
[class.copy.assign]: class.md#class.copy.assign
|
| 352 |
+
[class.copy.ctor]: class.md#class.copy.ctor
|
| 353 |
+
[class.copy.elision]: class.md#class.copy.elision
|
| 354 |
+
[class.default.ctor]: class.md#class.default.ctor
|
| 355 |
+
[class.derived]: class.md#class.derived
|
| 356 |
+
[class.derived.general]: class.md#class.derived.general
|
| 357 |
+
[class.dtor]: class.md#class.dtor
|
| 358 |
+
[class.free]: class.md#class.free
|
| 359 |
+
[class.friend]: class.md#class.friend
|
| 360 |
+
[class.mem]: class.md#class.mem
|
| 361 |
+
[class.mem.general]: class.md#class.mem.general
|
| 362 |
+
[class.member.lookup]: #class.member.lookup
|
| 363 |
+
[class.name]: class.md#class.name
|
| 364 |
+
[class.pre]: class.md#class.pre
|
| 365 |
+
[class.prop]: class.md#class.prop
|
| 366 |
+
[class.qual]: #class.qual
|
| 367 |
+
[class.spaceship]: class.md#class.spaceship
|
| 368 |
+
[class.static]: class.md#class.static
|
| 369 |
+
[class.static.data]: class.md#class.static.data
|
| 370 |
+
[class.temporary]: #class.temporary
|
| 371 |
+
[class.union]: class.md#class.union
|
| 372 |
+
[class.union.anon]: class.md#class.union.anon
|
| 373 |
+
[class.virtual]: class.md#class.virtual
|
| 374 |
+
[conv]: expr.md#conv
|
| 375 |
+
[conv.array]: expr.md#conv.array
|
| 376 |
+
[conv.func]: expr.md#conv.func
|
| 377 |
+
[conv.integral]: expr.md#conv.integral
|
| 378 |
+
[conv.lval]: expr.md#conv.lval
|
| 379 |
+
[conv.mem]: expr.md#conv.mem
|
| 380 |
+
[conv.prom]: expr.md#conv.prom
|
| 381 |
+
[conv.ptr]: expr.md#conv.ptr
|
| 382 |
+
[conv.qual]: expr.md#conv.qual
|
| 383 |
+
[conv.rank]: #conv.rank
|
| 384 |
+
[conv.rval]: expr.md#conv.rval
|
| 385 |
+
[cpp.predefined]: cpp.md#cpp.predefined
|
| 386 |
+
[csetjmp.syn]: support.md#csetjmp.syn
|
| 387 |
+
[cstdarg.syn]: support.md#cstdarg.syn
|
| 388 |
+
[cstddef.syn]: support.md#cstddef.syn
|
| 389 |
+
[cstring.syn]: strings.md#cstring.syn
|
| 390 |
+
[dcl.align]: dcl.md#dcl.align
|
| 391 |
+
[dcl.array]: dcl.md#dcl.array
|
| 392 |
+
[dcl.attr]: dcl.md#dcl.attr
|
| 393 |
+
[dcl.attr.grammar]: dcl.md#dcl.attr.grammar
|
| 394 |
+
[dcl.attr.indet]: dcl.md#dcl.attr.indet
|
| 395 |
+
[dcl.attr.nouniqueaddr]: dcl.md#dcl.attr.nouniqueaddr
|
| 396 |
+
[dcl.constexpr]: dcl.md#dcl.constexpr
|
| 397 |
+
[dcl.contract.func]: dcl.md#dcl.contract.func
|
| 398 |
+
[dcl.contract.res]: dcl.md#dcl.contract.res
|
| 399 |
+
[dcl.decl]: dcl.md#dcl.decl
|
| 400 |
+
[dcl.enum]: dcl.md#dcl.enum
|
| 401 |
+
[dcl.fct]: dcl.md#dcl.fct
|
| 402 |
+
[dcl.fct.def]: dcl.md#dcl.fct.def
|
| 403 |
+
[dcl.fct.def.coroutine]: dcl.md#dcl.fct.def.coroutine
|
| 404 |
+
[dcl.fct.def.general]: dcl.md#dcl.fct.def.general
|
| 405 |
+
[dcl.fct.default]: dcl.md#dcl.fct.default
|
| 406 |
+
[dcl.init]: dcl.md#dcl.init
|
| 407 |
+
[dcl.init.aggr]: dcl.md#dcl.init.aggr
|
| 408 |
+
[dcl.init.general]: dcl.md#dcl.init.general
|
| 409 |
+
[dcl.init.list]: dcl.md#dcl.init.list
|
| 410 |
+
[dcl.init.ref]: dcl.md#dcl.init.ref
|
| 411 |
+
[dcl.link]: dcl.md#dcl.link
|
| 412 |
+
[dcl.meaning]: dcl.md#dcl.meaning
|
| 413 |
+
[dcl.meaning.general]: dcl.md#dcl.meaning.general
|
| 414 |
+
[dcl.mptr]: dcl.md#dcl.mptr
|
| 415 |
+
[dcl.name]: dcl.md#dcl.name
|
| 416 |
+
[dcl.pre]: dcl.md#dcl.pre
|
| 417 |
+
[dcl.ptr]: dcl.md#dcl.ptr
|
| 418 |
+
[dcl.ref]: dcl.md#dcl.ref
|
| 419 |
+
[dcl.spec]: dcl.md#dcl.spec
|
| 420 |
+
[dcl.spec.auto]: dcl.md#dcl.spec.auto
|
| 421 |
+
[dcl.stc]: dcl.md#dcl.stc
|
| 422 |
+
[dcl.struct.bind]: dcl.md#dcl.struct.bind
|
| 423 |
+
[dcl.type.decltype]: dcl.md#dcl.type.decltype
|
| 424 |
+
[dcl.type.elab]: dcl.md#dcl.type.elab
|
| 425 |
+
[dcl.typedef]: dcl.md#dcl.typedef
|
| 426 |
+
[defns.access]: intro.md#defns.access
|
| 427 |
+
[defns.block]: intro.md#defns.block
|
| 428 |
+
[depr.local]: future.md#depr.local
|
| 429 |
+
[depr.static.constexpr]: future.md#depr.static.constexpr
|
| 430 |
+
[diff.cpp11.basic]: compatibility.md#diff.cpp11.basic
|
| 431 |
+
[enum.udecl]: dcl.md#enum.udecl
|
| 432 |
+
[except.handle]: except.md#except.handle
|
| 433 |
+
[except.pre]: except.md#except.pre
|
| 434 |
+
[except.spec]: except.md#except.spec
|
| 435 |
+
[except.terminate]: except.md#except.terminate
|
| 436 |
+
[except.throw]: except.md#except.throw
|
| 437 |
+
[expr.add]: expr.md#expr.add
|
| 438 |
+
[expr.alignof]: expr.md#expr.alignof
|
| 439 |
+
[expr.arith.conv]: expr.md#expr.arith.conv
|
| 440 |
+
[expr.assign]: expr.md#expr.assign
|
| 441 |
+
[expr.await]: expr.md#expr.await
|
| 442 |
+
[expr.call]: expr.md#expr.call
|
| 443 |
+
[expr.cast]: expr.md#expr.cast
|
| 444 |
+
[expr.comma]: expr.md#expr.comma
|
| 445 |
+
[expr.cond]: expr.md#expr.cond
|
| 446 |
+
[expr.const]: expr.md#expr.const
|
| 447 |
+
[expr.const.cast]: expr.md#expr.const.cast
|
| 448 |
+
[expr.context]: expr.md#expr.context
|
| 449 |
+
[expr.delete]: expr.md#expr.delete
|
| 450 |
+
[expr.dynamic.cast]: expr.md#expr.dynamic.cast
|
| 451 |
+
[expr.eq]: expr.md#expr.eq
|
| 452 |
+
[expr.mptr.oper]: expr.md#expr.mptr.oper
|
| 453 |
+
[expr.new]: expr.md#expr.new
|
| 454 |
+
[expr.pre]: expr.md#expr.pre
|
| 455 |
+
[expr.prim.id]: expr.md#expr.prim.id
|
| 456 |
+
[expr.prim.id.general]: expr.md#expr.prim.id.general
|
| 457 |
+
[expr.prim.id.qual]: expr.md#expr.prim.id.qual
|
| 458 |
+
[expr.prim.id.unqual]: expr.md#expr.prim.id.unqual
|
| 459 |
+
[expr.prim.lambda]: expr.md#expr.prim.lambda
|
| 460 |
+
[expr.prim.lambda.capture]: expr.md#expr.prim.lambda.capture
|
| 461 |
+
[expr.prim.lambda.closure]: expr.md#expr.prim.lambda.closure
|
| 462 |
+
[expr.prim.splice]: expr.md#expr.prim.splice
|
| 463 |
+
[expr.prim.this]: expr.md#expr.prim.this
|
| 464 |
+
[expr.prop]: expr.md#expr.prop
|
| 465 |
+
[expr.ref]: expr.md#expr.ref
|
| 466 |
+
[expr.reflect]: expr.md#expr.reflect
|
| 467 |
+
[expr.reinterpret.cast]: expr.md#expr.reinterpret.cast
|
| 468 |
+
[expr.rel]: expr.md#expr.rel
|
| 469 |
+
[expr.sizeof]: expr.md#expr.sizeof
|
| 470 |
+
[expr.static.cast]: expr.md#expr.static.cast
|
| 471 |
+
[expr.sub]: expr.md#expr.sub
|
| 472 |
+
[expr.throw]: expr.md#expr.throw
|
| 473 |
+
[expr.type.conv]: expr.md#expr.type.conv
|
| 474 |
+
[expr.typeid]: expr.md#expr.typeid
|
| 475 |
+
[expr.unary.noexcept]: expr.md#expr.unary.noexcept
|
| 476 |
+
[expr.unary.op]: expr.md#expr.unary.op
|
| 477 |
+
[get.new.handler]: support.md#get.new.handler
|
| 478 |
+
[headers]: library.md#headers
|
| 479 |
+
[intro.abstract]: intro.md#intro.abstract
|
| 480 |
+
[intro.compliance]: intro.md#intro.compliance
|
| 481 |
+
[intro.execution]: #intro.execution
|
| 482 |
+
[intro.memory]: #intro.memory
|
| 483 |
+
[intro.multithread]: #intro.multithread
|
| 484 |
+
[intro.multithread.general]: #intro.multithread.general
|
| 485 |
+
[intro.object]: #intro.object
|
| 486 |
+
[intro.progress]: #intro.progress
|
| 487 |
+
[intro.races]: #intro.races
|
| 488 |
+
[lex.charset]: lex.md#lex.charset
|
| 489 |
+
[lex.fcon]: lex.md#lex.fcon
|
| 490 |
+
[lex.name]: lex.md#lex.name
|
| 491 |
+
[lex.phases]: lex.md#lex.phases
|
| 492 |
+
[lex.string]: lex.md#lex.string
|
| 493 |
+
[mem.res.public]: mem.md#mem.res.public
|
| 494 |
+
[meta.define.static]: meta.md#meta.define.static
|
| 495 |
+
[meta.reflection.operators]: meta.md#meta.reflection.operators
|
| 496 |
+
[meta.syn]: meta.md#meta.syn
|
| 497 |
+
[module.context]: module.md#module.context
|
| 498 |
+
[module.global.frag]: module.md#module.global.frag
|
| 499 |
+
[module.interface]: module.md#module.interface
|
| 500 |
+
[module.reach]: module.md#module.reach
|
| 501 |
+
[module.unit]: module.md#module.unit
|
| 502 |
+
[multibyte.strings]: library.md#multibyte.strings
|
| 503 |
+
[namespace.alias]: dcl.md#namespace.alias
|
| 504 |
+
[namespace.def]: dcl.md#namespace.def
|
| 505 |
+
[namespace.qual]: #namespace.qual
|
| 506 |
+
[namespace.udecl]: dcl.md#namespace.udecl
|
| 507 |
+
[namespace.udir]: dcl.md#namespace.udir
|
| 508 |
+
[namespace.unnamed]: dcl.md#namespace.unnamed
|
| 509 |
+
[new.delete.array]: support.md#new.delete.array
|
| 510 |
+
[new.delete.placement]: support.md#new.delete.placement
|
| 511 |
+
[new.delete.single]: support.md#new.delete.single
|
| 512 |
+
[new.handler]: support.md#new.handler
|
| 513 |
+
[new.syn]: support.md#new.syn
|
| 514 |
+
[obj.lifetime]: mem.md#obj.lifetime
|
| 515 |
+
[over]: over.md#over
|
| 516 |
+
[over.literal]: over.md#over.literal
|
| 517 |
+
[over.match]: over.md#over.match
|
| 518 |
+
[over.match.funcs]: over.md#over.match.funcs
|
| 519 |
+
[over.oper]: over.md#over.oper
|
| 520 |
+
[over.over]: over.md#over.over
|
| 521 |
+
[ptr.align]: mem.md#ptr.align
|
| 522 |
+
[ptr.launder]: support.md#ptr.launder
|
| 523 |
+
[special]: class.md#special
|
| 524 |
+
[std.modules]: library.md#std.modules
|
| 525 |
+
[stdfloat.syn]: support.md#stdfloat.syn
|
| 526 |
+
[stmt.block]: stmt.md#stmt.block
|
| 527 |
+
[stmt.contract.assert]: stmt.md#stmt.contract.assert
|
| 528 |
+
[stmt.dcl]: stmt.md#stmt.dcl
|
| 529 |
+
[stmt.expand]: stmt.md#stmt.expand
|
| 530 |
+
[stmt.expr]: stmt.md#stmt.expr
|
| 531 |
+
[stmt.if]: stmt.md#stmt.if
|
| 532 |
+
[stmt.iter]: stmt.md#stmt.iter
|
| 533 |
+
[stmt.iter.general]: stmt.md#stmt.iter.general
|
| 534 |
+
[stmt.pre]: stmt.md#stmt.pre
|
| 535 |
+
[stmt.ranged]: stmt.md#stmt.ranged
|
| 536 |
+
[stmt.return]: stmt.md#stmt.return
|
| 537 |
+
[stmt.select]: stmt.md#stmt.select
|
| 538 |
+
[support.contract.violation]: support.md#support.contract.violation
|
| 539 |
+
[support.dynamic]: support.md#support.dynamic
|
| 540 |
+
[support.runtime]: support.md#support.runtime
|
| 541 |
+
[support.start.term]: support.md#support.start.term
|
| 542 |
+
[support.types]: support.md#support.types
|
| 543 |
+
[temp.alias]: temp.md#temp.alias
|
| 544 |
+
[temp.concept]: temp.md#temp.concept
|
| 545 |
+
[temp.deduct.guide]: temp.md#temp.deduct.guide
|
| 546 |
+
[temp.dep]: temp.md#temp.dep
|
| 547 |
+
[temp.dep.candidate]: temp.md#temp.dep.candidate
|
| 548 |
+
[temp.dep.constexpr]: temp.md#temp.dep.constexpr
|
| 549 |
+
[temp.dep.splice]: temp.md#temp.dep.splice
|
| 550 |
+
[temp.dep.type]: temp.md#temp.dep.type
|
| 551 |
+
[temp.expl.spec]: temp.md#temp.expl.spec
|
| 552 |
+
[temp.explicit]: temp.md#temp.explicit
|
| 553 |
+
[temp.friend]: temp.md#temp.friend
|
| 554 |
+
[temp.local]: temp.md#temp.local
|
| 555 |
+
[temp.names]: temp.md#temp.names
|
| 556 |
+
[temp.over]: temp.md#temp.over
|
| 557 |
+
[temp.over.link]: temp.md#temp.over.link
|
| 558 |
+
[temp.param]: temp.md#temp.param
|
| 559 |
+
[temp.point]: temp.md#temp.point
|
| 560 |
+
[temp.pre]: temp.md#temp.pre
|
| 561 |
+
[temp.res]: temp.md#temp.res
|
| 562 |
+
[temp.spec]: temp.md#temp.spec
|
| 563 |
+
[temp.spec.partial]: temp.md#temp.spec.partial
|
| 564 |
+
[temp.spec.partial.match]: temp.md#temp.spec.partial.match
|
| 565 |
+
[temp.type]: temp.md#temp.type
|
| 566 |
+
[term.implicit.lifetime.type]: #term.implicit.lifetime.type
|
| 567 |
+
[term.incomplete.type]: #term.incomplete.type
|
| 568 |
+
[term.odr.use]: #term.odr.use
|
| 569 |
+
[term.replaceable.function]: dcl.md#term.replaceable.function
|
| 570 |
+
[term.unevaluated.operand]: expr.md#term.unevaluated.operand
|
| 571 |
+
[thread]: thread.md#thread
|
| 572 |
+
[thread.jthread.class]: thread.md#thread.jthread.class
|
| 573 |
+
[thread.thread.class]: thread.md#thread.thread.class
|
| 574 |
+
[thread.thread.this]: thread.md#thread.thread.this
|
| 575 |
+
[thread.threads]: thread.md#thread.threads
|
| 576 |
+
|
| 577 |
+
[^1]: Appearing inside the brace-enclosed *declaration-seq* in a
|
| 578 |
+
*linkage-specification* does not affect whether a declaration is a
|
| 579 |
+
definition.
|
| 580 |
+
|
| 581 |
+
[^2]: An implementation is not required to call allocation and
|
| 582 |
+
deallocation functions from constructors or destructors; however,
|
| 583 |
+
this is a permissible implementation technique.
|
| 584 |
+
|
| 585 |
+
[^3]: An implicit object parameter [[over.match.funcs]] is not part of
|
| 586 |
+
the parameter-type-list.
|
| 587 |
+
|
| 588 |
+
[^4]: Lookups in which function names are ignored include names
|
| 589 |
+
appearing in a *nested-name-specifier*, an
|
| 590 |
+
*elaborated-type-specifier*, or a *base-specifier*.
|
| 591 |
+
|
| 592 |
+
[^5]: The number of bits in a byte is reported by the macro `CHAR_BIT`
|
| 593 |
+
in the header `<climits>`.
|
| 594 |
+
|
| 595 |
+
[^6]: Under the “as-if” rule an implementation is allowed to store two
|
| 596 |
+
objects at the same machine address or not store an object at all if
|
| 597 |
+
the program cannot observe the difference [[intro.execution]].
|
| 598 |
+
|
| 599 |
+
[^7]: For example, before the dynamic initialization of an object with
|
| 600 |
+
static storage duration [[basic.start.dynamic]].
|
| 601 |
+
|
| 602 |
+
[^8]: That is, an object for which a destructor will be called
|
| 603 |
+
implicitly—upon exit from the block for an object with automatic
|
| 604 |
+
storage duration, upon exit from the thread for an object with
|
| 605 |
+
thread storage duration, or upon exit from the program for an object
|
| 606 |
+
with static storage duration.
|
| 607 |
+
|
| 608 |
+
[^9]: The intent is to have `operator new()` implementable by calling
|
| 609 |
+
`std::malloc()` or `std::calloc()`, so the rules are substantially
|
| 610 |
+
the same. C++ differs from C in requiring a zero request to return a
|
| 611 |
+
non-null pointer.
|
| 612 |
+
|
| 613 |
+
[^10]: The global `operator delete(void*, std::size_t)` precludes use of
|
| 614 |
+
an allocation function `void operator new(std::size_t, std::size_t)`
|
| 615 |
+
as a placement allocation function [[diff.cpp11.basic]].
|
| 616 |
+
|
| 617 |
+
[^11]: The same rules apply to initialization of an `initializer_list`
|
| 618 |
+
object [[dcl.init.list]] with its underlying temporary array.
|
| 619 |
+
|
| 620 |
+
[^12]: By using, for example, the library functions [[headers]]
|
| 621 |
+
`std::memcpy` or `std::memmove`.
|
| 622 |
+
|
| 623 |
+
[^13]: By using, for example, the library functions [[headers]]
|
| 624 |
+
`std::memcpy` or `std::memmove`.
|
| 625 |
+
|
| 626 |
+
[^14]: The intent is that the memory model of C++ is compatible with
|
| 627 |
+
that of the C programming language.
|
| 628 |
+
|
| 629 |
+
[^15]: The size and layout of an instance of an incompletely-defined
|
| 630 |
+
object type is unknown.
|
| 631 |
+
|
| 632 |
+
[^16]: This is also known as two’s complement representation.
|
| 633 |
+
|
| 634 |
+
[^17]: Static class members are objects or functions, and pointers to
|
| 635 |
+
them are ordinary pointers to objects or functions.
|
| 636 |
+
|
| 637 |
+
[^18]: For an object that is not within its lifetime, this is the first
|
| 638 |
+
byte in memory that it will occupy or used to occupy.
|
| 639 |
+
|
| 640 |
+
[^19]: Some implementations might define that copying such a pointer
|
| 641 |
+
value causes a system-generated runtime fault.
|
| 642 |
+
|
| 643 |
+
[^20]: The same representation and alignment requirements are meant to
|
| 644 |
+
imply interchangeability as arguments to functions, return values
|
| 645 |
+
from functions, and non-static data members of unions.
|
| 646 |
+
|
| 647 |
+
[^21]: As specified in [[class.temporary]], after a full-expression is
|
| 648 |
+
evaluated, a sequence of zero or more invocations of destructor
|
| 649 |
+
functions for temporary objects takes place, usually in reverse
|
| 650 |
+
order of the construction of each temporary object.
|
| 651 |
+
|
| 652 |
+
[^22]: In other words, function executions do not interleave with each
|
| 653 |
+
other.
|
| 654 |
+
|
| 655 |
+
[^23]: An object with automatic or thread storage duration [[basic.stc]]
|
| 656 |
+
is associated with one specific thread, and can be accessed by a
|
| 657 |
+
different thread only indirectly through a pointer or reference
|
| 658 |
+
[[basic.compound]].
|
| 659 |
+
|
| 660 |
+
[^24]: A non-block variable with static storage duration having
|
| 661 |
+
initialization with side effects is initialized in this case, even
|
| 662 |
+
if it is not itself odr-used [[term.odr.use]], [[basic.stc.static]].
|