- tmp/tmpc9hzp6jm/{from.md → to.md} +180 -57
tmp/tmpc9hzp6jm/{from.md → to.md}
RENAMED
|
@@ -2,11 +2,11 @@
|
|
| 2 |
|
| 3 |
### General <a id="description.general">[[description.general]]</a>
|
| 4 |
|
| 5 |
Subclause [[description]] describes the conventions used to specify the
|
| 6 |
C++ standard library. [[structure]] describes the structure of
|
| 7 |
-
[[support]] through [[
|
| 8 |
other editorial conventions.
|
| 9 |
|
| 10 |
### Structure of each clause <a id="structure">[[structure]]</a>
|
| 11 |
|
| 12 |
#### Elements <a id="structure.elements">[[structure.elements]]</a>
|
|
@@ -124,54 +124,85 @@ appropriate):[^5]
|
|
| 124 |
overload resolution [[over.match]]. \[*Note 1*: Failure to meet such a
|
| 125 |
condition results in the function’s silent
|
| 126 |
non-viability. — *end note*] \[*Example 1*: An implementation can
|
| 127 |
express such a condition via a *constraint-expression*
|
| 128 |
[[temp.constr.decl]]. — *end example*]
|
|
|
|
| 129 |
- *Mandates:* the conditions that, if not met, render the program
|
| 130 |
ill-formed. \[*Example 2*: An implementation can express such a
|
| 131 |
condition via the *constant-expression* in a
|
| 132 |
*static_assert-declaration* [[dcl.pre]]. If the diagnostic is to be
|
| 133 |
emitted only after the function has been selected by overload
|
| 134 |
resolution, an implementation can express such a condition via a
|
| 135 |
*constraint-expression* [[temp.constr.decl]] and also define the
|
| 136 |
function as deleted. — *end example*]
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
- *Effects:* the actions performed by the function.
|
|
|
|
| 141 |
- *Synchronization:* the synchronization operations
|
| 142 |
[[intro.multithread]] applicable to the function.
|
|
|
|
| 143 |
- *Ensures:* the conditions (sometimes termed observable results)
|
| 144 |
-
established by the function.
|
|
|
|
|
|
|
|
|
|
| 145 |
- *Result:* for a *typename-specifier*, a description of the named type;
|
| 146 |
-
for an *expression*, a description of the type
|
| 147 |
-
expression is an lvalue if the type is an lvalue
|
| 148 |
-
xvalue if the type is an rvalue reference type, and
|
| 149 |
-
otherwise.
|
|
|
|
| 150 |
- *Returns:* a description of the value(s) returned by the function.
|
|
|
|
| 151 |
- *Throws:* any exceptions thrown by the function, and the conditions
|
| 152 |
that would cause the exception.
|
|
|
|
| 153 |
- *Complexity:* the time and/or space complexity of the function.
|
|
|
|
| 154 |
- *Remarks:* additional semantic constraints on the function.
|
|
|
|
| 155 |
- *Error conditions:* the error conditions for error codes reported by
|
| 156 |
the function.
|
| 157 |
|
| 158 |
Whenever the *Effects* element specifies that the semantics of some
|
| 159 |
function `F` are *Equivalent to* some code sequence, then the various
|
| 160 |
elements are interpreted as follows. If `F`’s semantics specifies any
|
| 161 |
*Constraints* or *Mandates* elements, then those requirements are
|
| 162 |
logically imposed prior to the *equivalent-to* semantics. Next, the
|
| 163 |
semantics of the code sequence are determined by the *Constraints*,
|
| 164 |
-
*Mandates*, *
|
| 165 |
-
*
|
| 166 |
-
*Error conditions* specified for the
|
| 167 |
-
the code sequence. The value returned
|
| 168 |
-
|
| 169 |
-
return from `F` is specified by the
|
| 170 |
-
in the code sequence. If `F`’s
|
| 171 |
-
*Postconditions*, or *Complexity*
|
| 172 |
-
occurrences of that element in the
|
|
|
|
| 173 |
|
| 174 |
For non-reserved replacement and handler functions, [[support]]
|
| 175 |
specifies two behaviors for the functions in question: their required
|
| 176 |
and default behavior. The *default behavior* describes a function
|
| 177 |
definition provided by the implementation. The *required behavior*
|
|
@@ -205,27 +236,26 @@ to describe the contents of the C++ standard library. These conventions
|
|
| 205 |
are for describing implementation-defined types [[type.descriptions]],
|
| 206 |
and member functions [[functions.within.classes]].
|
| 207 |
|
| 208 |
#### Exposition-only entities, etc. <a id="expos.only.entity">[[expos.only.entity]]</a>
|
| 209 |
|
| 210 |
-
Several entities
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
comment ending in *exposition only*.
|
| 214 |
|
| 215 |
The following are defined for exposition only to aid in the
|
| 216 |
specification of the library:
|
| 217 |
|
| 218 |
``` cpp
|
| 219 |
namespace std {
|
| 220 |
template<class T>
|
| 221 |
requires convertible_to<T, decay_t<T>>
|
| 222 |
-
constexpr decay_t<T> decay-copy(T&& v)
|
| 223 |
-
noexcept(is_nothrow_convertible_v<T, decay_t<T>>)
|
| 224 |
{ return std::forward<T>(v); }
|
| 225 |
|
| 226 |
-
constexpr auto synth-three-way =
|
| 227 |
[]<class T, class U>(const T& t, const U& u)
|
| 228 |
requires requires {
|
| 229 |
{ t < u } -> boolean-testable;
|
| 230 |
{ u < t } -> boolean-testable;
|
| 231 |
}
|
|
@@ -238,14 +268,24 @@ namespace std {
|
|
| 238 |
return weak_ordering::equivalent;
|
| 239 |
}
|
| 240 |
};
|
| 241 |
|
| 242 |
template<class T, class U = T>
|
| 243 |
-
using synth-three-way-result =
|
|
|
|
| 244 |
}
|
| 245 |
```
|
| 246 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 247 |
#### Type descriptions <a id="type.descriptions">[[type.descriptions]]</a>
|
| 248 |
|
| 249 |
##### General <a id="type.descriptions.general">[[type.descriptions.general]]</a>
|
| 250 |
|
| 251 |
The Requirements subclauses may describe names that are used to specify
|
|
@@ -280,11 +320,11 @@ inline const enumerated C₃(V₃);
|
|
| 280 |
Here, the names `C₀`, `C₁`, etc. represent *enumerated elements* for
|
| 281 |
this particular enumerated type. All such elements have distinct values.
|
| 282 |
|
| 283 |
##### Bitmask types <a id="bitmask.types">[[bitmask.types]]</a>
|
| 284 |
|
| 285 |
-
Several types defined in [[support]] through [[
|
| 286 |
*bitmask types*. Each bitmask type can be implemented as an enumerated
|
| 287 |
type that overloads certain operators, as an integer type, or as a
|
| 288 |
`bitset` [[template.bitset]].
|
| 289 |
|
| 290 |
The bitmask type `bitmask` can be written:
|
|
@@ -366,20 +406,22 @@ sequences that follow a few uniform conventions:
|
|
| 366 |
basic character set.
|
| 367 |
- The *decimal-point character* is the locale-specific (single-byte)
|
| 368 |
character used by functions that convert between a (single-byte)
|
| 369 |
character sequence and a value of one of the floating-point types. It
|
| 370 |
is used in the character sequence to denote the beginning of a
|
| 371 |
-
fractional part. It is represented in [[support]] through [[
|
| 372 |
-
|
| 373 |
locale.
|
| 374 |
- A *character sequence* is an array object [[dcl.array]] `A` that can
|
| 375 |
be declared as `T A[N]`, where `T` is any of the types `char`,
|
| 376 |
`unsigned char`, or `signed char` [[basic.fundamental]], optionally
|
| 377 |
qualified by any combination of `const` or `volatile`. The initial
|
| 378 |
elements of the array have defined contents up to and including an
|
| 379 |
element determined by some predicate. A character sequence can be
|
| 380 |
designated by a pointer value `S` that points to its first element.
|
|
|
|
|
|
|
| 381 |
|
| 382 |
###### Byte strings <a id="byte.strings">[[byte.strings]]</a>
|
| 383 |
|
| 384 |
A *null-terminated byte string*, or NTBS, is a character sequence whose
|
| 385 |
highest-addressed element with defined content has the value zero (the
|
|
@@ -437,32 +479,64 @@ initialized as if by `auto p = o;`. Then for any sequence of arguments
|
|
| 437 |
- `p(args...)`
|
| 438 |
- `as_const(p)(args...)`
|
| 439 |
- `std::move(p)(args...)`
|
| 440 |
- `std::move(as_const(p))(args...)`
|
| 441 |
|
| 442 |
-
|
| 443 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 444 |
|
| 445 |
#### Functions within classes <a id="functions.within.classes">[[functions.within.classes]]</a>
|
| 446 |
|
| 447 |
-
For the sake of exposition, [[support]] through [[
|
| 448 |
-
|
| 449 |
(non-virtual) destructors with the same apparent semantics as those that
|
| 450 |
can be generated by default
|
| 451 |
[[class.copy.ctor]], [[class.copy.assign]], [[class.dtor]]. It is
|
| 452 |
unspecified whether the implementation provides explicit definitions for
|
| 453 |
such member function signatures, or for virtual destructors that can be
|
| 454 |
generated by default.
|
| 455 |
|
| 456 |
#### Private members <a id="objects.within.classes">[[objects.within.classes]]</a>
|
| 457 |
|
| 458 |
-
[[support]] through [[
|
| 459 |
representation of classes, and intentionally omit specification of class
|
| 460 |
members [[class.mem]]. An implementation may define static or non-static
|
| 461 |
class members, or both, as needed to implement the semantics of the
|
| 462 |
-
member functions specified in [[support]] through [[
|
| 463 |
-
[[depr]].
|
| 464 |
|
| 465 |
For the sake of exposition, some subclauses provide representative
|
| 466 |
declarations, and semantic requirements, for private members of classes
|
| 467 |
that meet the external specifications of the classes. The declarations
|
| 468 |
for such members are followed by a comment that ends with *exposition
|
|
@@ -475,58 +549,107 @@ streambuf* sb; // exposition only
|
|
| 475 |
An implementation may use any technique that provides equivalent
|
| 476 |
observable behavior.
|
| 477 |
|
| 478 |
#### Freestanding items <a id="freestanding.item">[[freestanding.item]]</a>
|
| 479 |
|
| 480 |
-
A *freestanding item* is a declaration, entity,
|
| 481 |
-
|
| 482 |
-
|
| 483 |
|
| 484 |
Unless otherwise specified, the requirements on freestanding items for a
|
| 485 |
freestanding implementation are the same as the corresponding
|
| 486 |
requirements for a hosted implementation, except that not all of the
|
| 487 |
-
members of
|
| 488 |
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
| 492 |
-
|
| 493 |
-
|
|
|
|
|
|
|
| 494 |
|
| 495 |
-
|
|
|
|
|
|
|
| 496 |
|
| 497 |
-
|
| 498 |
-
- the header synopsis begins with a comment that includes *all
|
| 499 |
-
freestanding*.
|
| 500 |
|
| 501 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 502 |
|
| 503 |
- introduced by a declaration that is a freestanding item,
|
|
|
|
|
|
|
|
|
|
| 504 |
- an enclosing namespace of a freestanding item,
|
| 505 |
- a friend of a freestanding item,
|
| 506 |
-
- denoted by a
|
| 507 |
- denoted by an alias template that is a freestanding item.
|
| 508 |
|
| 509 |
A macro is a freestanding item if it is defined in a header synopsis and
|
| 510 |
|
| 511 |
- the definition is followed by a comment that includes *freestanding*,
|
| 512 |
or
|
| 513 |
-
- the header synopsis begins with a comment that includes *
|
| 514 |
-
|
|
|
|
| 515 |
|
| 516 |
-
[*Example
|
| 517 |
|
| 518 |
``` cpp
|
| 519 |
#define NULL see below // freestanding
|
| 520 |
```
|
| 521 |
|
| 522 |
— *end example*]
|
| 523 |
|
| 524 |
-
[*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 525 |
|
| 526 |
``` cpp
|
| 527 |
-
//
|
| 528 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 529 |
```
|
| 530 |
|
| 531 |
— *end example*]
|
| 532 |
|
|
|
|
| 2 |
|
| 3 |
### General <a id="description.general">[[description.general]]</a>
|
| 4 |
|
| 5 |
Subclause [[description]] describes the conventions used to specify the
|
| 6 |
C++ standard library. [[structure]] describes the structure of
|
| 7 |
+
[[support]] through [[exec]] and [[depr]]. [[conventions]] describes
|
| 8 |
other editorial conventions.
|
| 9 |
|
| 10 |
### Structure of each clause <a id="structure">[[structure]]</a>
|
| 11 |
|
| 12 |
#### Elements <a id="structure.elements">[[structure.elements]]</a>
|
|
|
|
| 124 |
overload resolution [[over.match]]. \[*Note 1*: Failure to meet such a
|
| 125 |
condition results in the function’s silent
|
| 126 |
non-viability. — *end note*] \[*Example 1*: An implementation can
|
| 127 |
express such a condition via a *constraint-expression*
|
| 128 |
[[temp.constr.decl]]. — *end example*]
|
| 129 |
+
|
| 130 |
- *Mandates:* the conditions that, if not met, render the program
|
| 131 |
ill-formed. \[*Example 2*: An implementation can express such a
|
| 132 |
condition via the *constant-expression* in a
|
| 133 |
*static_assert-declaration* [[dcl.pre]]. If the diagnostic is to be
|
| 134 |
emitted only after the function has been selected by overload
|
| 135 |
resolution, an implementation can express such a condition via a
|
| 136 |
*constraint-expression* [[temp.constr.decl]] and also define the
|
| 137 |
function as deleted. — *end example*]
|
| 138 |
+
|
| 139 |
+
- the conditions that are required for a call to the function to be a
|
| 140 |
+
constant subexpression [[defns.const.subexpr]].
|
| 141 |
+
|
| 142 |
+
- *Preconditions:* conditions that the function assumes to hold whenever
|
| 143 |
+
it is called; violation of any preconditions results in undefined
|
| 144 |
+
behavior. \[*Example 3*: An implementation can express some such
|
| 145 |
+
conditions via the use of a contract assertion, such as a precondition
|
| 146 |
+
assertion [[dcl.contract.func]]. — *end example*]
|
| 147 |
+
|
| 148 |
+
- conditions that the function assumes to hold whenever it is called.
|
| 149 |
+
- When invoking the function in a hardened implementation, prior to
|
| 150 |
+
any other observable side effects of the function, one or more
|
| 151 |
+
contract assertions whose predicates are as described in the
|
| 152 |
+
hardened precondition are evaluated with a checking semantic
|
| 153 |
+
[[basic.contract.eval]]. If any of these assertions is evaluated
|
| 154 |
+
with a non-terminating semantic and the contract-violation handler
|
| 155 |
+
returns, the program has undefined behavior.
|
| 156 |
+
- When invoking the function in a non-hardened implementation, if any
|
| 157 |
+
hardened precondition is violated, the program has undefined
|
| 158 |
+
behavior.
|
| 159 |
+
|
| 160 |
- *Effects:* the actions performed by the function.
|
| 161 |
+
|
| 162 |
- *Synchronization:* the synchronization operations
|
| 163 |
[[intro.multithread]] applicable to the function.
|
| 164 |
+
|
| 165 |
- *Ensures:* the conditions (sometimes termed observable results)
|
| 166 |
+
established by the function. \[*Example 4*: An implementation can
|
| 167 |
+
express some such conditions via the use of a contract assertion, such
|
| 168 |
+
as a postcondition assertion [[dcl.contract.func]]. — *end example*]
|
| 169 |
+
|
| 170 |
- *Result:* for a *typename-specifier*, a description of the named type;
|
| 171 |
+
for an *expression*, a description of the type and value category of
|
| 172 |
+
the expression; the expression is an lvalue if the type is an lvalue
|
| 173 |
+
reference type, an xvalue if the type is an rvalue reference type, and
|
| 174 |
+
a prvalue otherwise.
|
| 175 |
+
|
| 176 |
- *Returns:* a description of the value(s) returned by the function.
|
| 177 |
+
|
| 178 |
- *Throws:* any exceptions thrown by the function, and the conditions
|
| 179 |
that would cause the exception.
|
| 180 |
+
|
| 181 |
- *Complexity:* the time and/or space complexity of the function.
|
| 182 |
+
|
| 183 |
- *Remarks:* additional semantic constraints on the function.
|
| 184 |
+
|
| 185 |
- *Error conditions:* the error conditions for error codes reported by
|
| 186 |
the function.
|
| 187 |
|
| 188 |
Whenever the *Effects* element specifies that the semantics of some
|
| 189 |
function `F` are *Equivalent to* some code sequence, then the various
|
| 190 |
elements are interpreted as follows. If `F`’s semantics specifies any
|
| 191 |
*Constraints* or *Mandates* elements, then those requirements are
|
| 192 |
logically imposed prior to the *equivalent-to* semantics. Next, the
|
| 193 |
semantics of the code sequence are determined by the *Constraints*,
|
| 194 |
+
*Mandates*, *Constant When*, *Preconditions*, *Hardened preconditions*,
|
| 195 |
+
*Effects*, *Synchronization*, *Postconditions*, *Returns*, *Throws*,
|
| 196 |
+
*Complexity*, *Remarks*, and *Error conditions* specified for the
|
| 197 |
+
function invocations contained in the code sequence. The value returned
|
| 198 |
+
from `F` is specified by `F`’s *Returns* element, or if `F` has no
|
| 199 |
+
*Returns* element, a non-`void` return from `F` is specified by the
|
| 200 |
+
`return` statements [[stmt.return]] in the code sequence. If `F`’s
|
| 201 |
+
semantics contains a *Throws*, *Postconditions*, or *Complexity*
|
| 202 |
+
element, then that supersedes any occurrences of that element in the
|
| 203 |
+
code sequence.
|
| 204 |
|
| 205 |
For non-reserved replacement and handler functions, [[support]]
|
| 206 |
specifies two behaviors for the functions in question: their required
|
| 207 |
and default behavior. The *default behavior* describes a function
|
| 208 |
definition provided by the implementation. The *required behavior*
|
|
|
|
| 236 |
are for describing implementation-defined types [[type.descriptions]],
|
| 237 |
and member functions [[functions.within.classes]].
|
| 238 |
|
| 239 |
#### Exposition-only entities, etc. <a id="expos.only.entity">[[expos.only.entity]]</a>
|
| 240 |
|
| 241 |
+
Several entities defined in [[support]] through [[exec]] and [[depr]]
|
| 242 |
+
are only defined for the purpose of exposition. The declaration of such
|
| 243 |
+
an entity is followed by a comment ending in *exposition only*.
|
|
|
|
| 244 |
|
| 245 |
The following are defined for exposition only to aid in the
|
| 246 |
specification of the library:
|
| 247 |
|
| 248 |
``` cpp
|
| 249 |
namespace std {
|
| 250 |
template<class T>
|
| 251 |
requires convertible_to<T, decay_t<T>>
|
| 252 |
+
constexpr decay_t<T> decay-copy(T&& v) // exposition only
|
| 253 |
+
noexcept(is_nothrow_convertible_v<T, decay_t<T>>)
|
| 254 |
{ return std::forward<T>(v); }
|
| 255 |
|
| 256 |
+
constexpr auto synth-three-way = // exposition only
|
| 257 |
[]<class T, class U>(const T& t, const U& u)
|
| 258 |
requires requires {
|
| 259 |
{ t < u } -> boolean-testable;
|
| 260 |
{ u < t } -> boolean-testable;
|
| 261 |
}
|
|
|
|
| 268 |
return weak_ordering::equivalent;
|
| 269 |
}
|
| 270 |
};
|
| 271 |
|
| 272 |
template<class T, class U = T>
|
| 273 |
+
using synth-three-way-result = // exposition only
|
| 274 |
+
decltype(synth-three-way(declval<T&>(), declval<U&>()));
|
| 275 |
}
|
| 276 |
```
|
| 277 |
|
| 278 |
+
An object `dst` is said to be *decay-copied from* a subexpression `src`
|
| 279 |
+
if the type of `dst` is
|
| 280 |
+
|
| 281 |
+
``` cpp
|
| 282 |
+
decay_t<decltype((src))>
|
| 283 |
+
```
|
| 284 |
+
|
| 285 |
+
and `dst` is copy-initialized from `src`.
|
| 286 |
+
|
| 287 |
#### Type descriptions <a id="type.descriptions">[[type.descriptions]]</a>
|
| 288 |
|
| 289 |
##### General <a id="type.descriptions.general">[[type.descriptions.general]]</a>
|
| 290 |
|
| 291 |
The Requirements subclauses may describe names that are used to specify
|
|
|
|
| 320 |
Here, the names `C₀`, `C₁`, etc. represent *enumerated elements* for
|
| 321 |
this particular enumerated type. All such elements have distinct values.
|
| 322 |
|
| 323 |
##### Bitmask types <a id="bitmask.types">[[bitmask.types]]</a>
|
| 324 |
|
| 325 |
+
Several types defined in [[support]] through [[exec]] and [[depr]] are
|
| 326 |
*bitmask types*. Each bitmask type can be implemented as an enumerated
|
| 327 |
type that overloads certain operators, as an integer type, or as a
|
| 328 |
`bitset` [[template.bitset]].
|
| 329 |
|
| 330 |
The bitmask type `bitmask` can be written:
|
|
|
|
| 406 |
basic character set.
|
| 407 |
- The *decimal-point character* is the locale-specific (single-byte)
|
| 408 |
character used by functions that convert between a (single-byte)
|
| 409 |
character sequence and a value of one of the floating-point types. It
|
| 410 |
is used in the character sequence to denote the beginning of a
|
| 411 |
+
fractional part. It is represented in [[support]] through [[exec]] and
|
| 412 |
+
[[depr]] by a period, `'.'`, which is also its value in the `"C"`
|
| 413 |
locale.
|
| 414 |
- A *character sequence* is an array object [[dcl.array]] `A` that can
|
| 415 |
be declared as `T A[N]`, where `T` is any of the types `char`,
|
| 416 |
`unsigned char`, or `signed char` [[basic.fundamental]], optionally
|
| 417 |
qualified by any combination of `const` or `volatile`. The initial
|
| 418 |
elements of the array have defined contents up to and including an
|
| 419 |
element determined by some predicate. A character sequence can be
|
| 420 |
designated by a pointer value `S` that points to its first element.
|
| 421 |
+
- Let *`STATICALLY-WIDEN`*`<charT>("...")` be `"..."` if `charT` is
|
| 422 |
+
`char` and `L"..."` if `charT` is `wchar_t`.
|
| 423 |
|
| 424 |
###### Byte strings <a id="byte.strings">[[byte.strings]]</a>
|
| 425 |
|
| 426 |
A *null-terminated byte string*, or NTBS, is a character sequence whose
|
| 427 |
highest-addressed element with defined content has the value zero (the
|
|
|
|
| 479 |
- `p(args...)`
|
| 480 |
- `as_const(p)(args...)`
|
| 481 |
- `std::move(p)(args...)`
|
| 482 |
- `std::move(as_const(p))(args...)`
|
| 483 |
|
| 484 |
+
#### Algorithm function objects <a id="alg.func.obj">[[alg.func.obj]]</a>
|
| 485 |
+
|
| 486 |
+
An *algorithm function object* is a customization point object
|
| 487 |
+
[[customization.point.object]] that is specified as one or more
|
| 488 |
+
overloaded function templates. The name of these function templates
|
| 489 |
+
designates the corresponding algorithm function object.
|
| 490 |
+
|
| 491 |
+
For an algorithm function object `o`, let S be the corresponding set of
|
| 492 |
+
function templates. Then for any sequence of arguments `args` …,
|
| 493 |
+
`o(args` … `)` is expression-equivalent to `s(args` … `)`, where the
|
| 494 |
+
result of name lookup for `s` is the overload set S.
|
| 495 |
+
|
| 496 |
+
[*Note 1*:
|
| 497 |
+
|
| 498 |
+
Algorithm function objects are not found by argument-dependent name
|
| 499 |
+
lookup [[basic.lookup.argdep]]. When found by unqualified name lookup
|
| 500 |
+
[[basic.lookup.unqual]] for the *postfix-expression* in a function call
|
| 501 |
+
[[expr.call]], they inhibit argument-dependent name lookup.
|
| 502 |
+
|
| 503 |
+
[*Example 1*:
|
| 504 |
+
|
| 505 |
+
``` cpp
|
| 506 |
+
void foo() {
|
| 507 |
+
using namespace std::ranges;
|
| 508 |
+
std::vector<int> vec{1,2,3};
|
| 509 |
+
find(begin(vec), end(vec), 2); // #1
|
| 510 |
+
}
|
| 511 |
+
```
|
| 512 |
+
|
| 513 |
+
The function call expression at \#1 invokes `std::ranges::find`, not
|
| 514 |
+
`std::find`.
|
| 515 |
+
|
| 516 |
+
— *end example*]
|
| 517 |
+
|
| 518 |
+
— *end note*]
|
| 519 |
|
| 520 |
#### Functions within classes <a id="functions.within.classes">[[functions.within.classes]]</a>
|
| 521 |
|
| 522 |
+
For the sake of exposition, [[support]] through [[exec]] and [[depr]] do
|
| 523 |
+
not describe copy/move constructors, assignment operators, or
|
| 524 |
(non-virtual) destructors with the same apparent semantics as those that
|
| 525 |
can be generated by default
|
| 526 |
[[class.copy.ctor]], [[class.copy.assign]], [[class.dtor]]. It is
|
| 527 |
unspecified whether the implementation provides explicit definitions for
|
| 528 |
such member function signatures, or for virtual destructors that can be
|
| 529 |
generated by default.
|
| 530 |
|
| 531 |
#### Private members <a id="objects.within.classes">[[objects.within.classes]]</a>
|
| 532 |
|
| 533 |
+
[[support]] through [[exec]] and [[depr]] do not specify the
|
| 534 |
representation of classes, and intentionally omit specification of class
|
| 535 |
members [[class.mem]]. An implementation may define static or non-static
|
| 536 |
class members, or both, as needed to implement the semantics of the
|
| 537 |
+
member functions specified in [[support]] through [[exec]] and [[depr]].
|
|
|
|
| 538 |
|
| 539 |
For the sake of exposition, some subclauses provide representative
|
| 540 |
declarations, and semantic requirements, for private members of classes
|
| 541 |
that meet the external specifications of the classes. The declarations
|
| 542 |
for such members are followed by a comment that ends with *exposition
|
|
|
|
| 549 |
An implementation may use any technique that provides equivalent
|
| 550 |
observable behavior.
|
| 551 |
|
| 552 |
#### Freestanding items <a id="freestanding.item">[[freestanding.item]]</a>
|
| 553 |
|
| 554 |
+
A *freestanding item* is a declaration, entity, or macro that is
|
| 555 |
+
required to be present in a freestanding implementation and a hosted
|
| 556 |
+
implementation.
|
| 557 |
|
| 558 |
Unless otherwise specified, the requirements on freestanding items for a
|
| 559 |
freestanding implementation are the same as the corresponding
|
| 560 |
requirements for a hosted implementation, except that not all of the
|
| 561 |
+
members of those items are required to be present.
|
| 562 |
|
| 563 |
+
Function declarations and function template declarations followed by a
|
| 564 |
+
comment that include *freestanding-deleted* are *freestanding deleted
|
| 565 |
+
functions*. On freestanding implementations, it is
|
| 566 |
+
*implementation-defined* whether each entity introduced by a
|
| 567 |
+
freestanding deleted function is a deleted function
|
| 568 |
+
[[dcl.fct.def.delete]] or whether the requirements are the same as the
|
| 569 |
+
corresponding requirements for a hosted implementation.
|
| 570 |
|
| 571 |
+
[*Note 1*: Deleted definitions reduce the chance of overload resolution
|
| 572 |
+
silently changing when migrating from a freestanding implementation to a
|
| 573 |
+
hosted implementation. — *end note*]
|
| 574 |
|
| 575 |
+
[*Example 1*:
|
|
|
|
|
|
|
| 576 |
|
| 577 |
+
``` cpp
|
| 578 |
+
double abs(double j); // freestanding-deleted
|
| 579 |
+
```
|
| 580 |
+
|
| 581 |
+
— *end example*]
|
| 582 |
+
|
| 583 |
+
A declaration in a synopsis is a freestanding item if
|
| 584 |
+
|
| 585 |
+
- it is followed by a comment that includes *freestanding*,
|
| 586 |
+
- it is followed by a comment that includes *freestanding-deleted*, or
|
| 587 |
+
- the header synopsis begins with a comment that includes *freestanding*
|
| 588 |
+
and the declaration is not followed by a comment that includes
|
| 589 |
+
*hosted*. \[*Note 2*: Declarations followed by *hosted* in
|
| 590 |
+
freestanding headers are not freestanding items. As a result, looking
|
| 591 |
+
up the name of such functions can vary between hosted and freestanding
|
| 592 |
+
implementations. — *end note*]
|
| 593 |
+
|
| 594 |
+
[*Example 2*:
|
| 595 |
+
|
| 596 |
+
``` cpp
|
| 597 |
+
// all freestanding
|
| 598 |
+
namespace std {
|
| 599 |
+
```
|
| 600 |
+
|
| 601 |
+
— *end example*]
|
| 602 |
+
|
| 603 |
+
An entity or deduction guide is a freestanding item if its introducing
|
| 604 |
+
declaration is not followed by a comment that includes *hosted*, and is:
|
| 605 |
|
| 606 |
- introduced by a declaration that is a freestanding item,
|
| 607 |
+
- a member of a freestanding item other than a namespace,
|
| 608 |
+
- an enumerator of a freestanding item,
|
| 609 |
+
- a deduction guide of a freestanding item,
|
| 610 |
- an enclosing namespace of a freestanding item,
|
| 611 |
- a friend of a freestanding item,
|
| 612 |
+
- denoted by a type alias that is a freestanding item, or
|
| 613 |
- denoted by an alias template that is a freestanding item.
|
| 614 |
|
| 615 |
A macro is a freestanding item if it is defined in a header synopsis and
|
| 616 |
|
| 617 |
- the definition is followed by a comment that includes *freestanding*,
|
| 618 |
or
|
| 619 |
+
- the header synopsis begins with a comment that includes *freestanding*
|
| 620 |
+
and the definition is not followed by a comment that includes
|
| 621 |
+
*hosted*.
|
| 622 |
|
| 623 |
+
[*Example 3*:
|
| 624 |
|
| 625 |
``` cpp
|
| 626 |
#define NULL see below // freestanding
|
| 627 |
```
|
| 628 |
|
| 629 |
— *end example*]
|
| 630 |
|
| 631 |
+
[*Note 3*: Freestanding annotations follow some additional exposition
|
| 632 |
+
conventions that do not impose any additional normative requirements.
|
| 633 |
+
Header synopses that begin with a comment containing "all freestanding"
|
| 634 |
+
contain no hosted items and no freestanding deleted functions. Header
|
| 635 |
+
synopses that begin with a comment containing "mostly freestanding"
|
| 636 |
+
contain at least one hosted item or freestanding deleted function.
|
| 637 |
+
Classes and class templates followed by a comment containing "partially
|
| 638 |
+
freestanding" contain at least one hosted item or freestanding deleted
|
| 639 |
+
function. — *end note*]
|
| 640 |
+
|
| 641 |
+
[*Example 4*:
|
| 642 |
|
| 643 |
``` cpp
|
| 644 |
+
template<class T, size_t N> struct array; // partially freestanding
|
| 645 |
+
template<class T, size_t N>
|
| 646 |
+
struct array {
|
| 647 |
+
constexpr reference operator[](size_type n);
|
| 648 |
+
constexpr const_reference operator[](size_type n) const;
|
| 649 |
+
constexpr reference at(size_type n); // freestanding-deleted
|
| 650 |
+
constexpr const_reference at(size_type n) const; // freestanding-deleted
|
| 651 |
+
};
|
| 652 |
```
|
| 653 |
|
| 654 |
— *end example*]
|
| 655 |
|