- tmp/tmplmh2jwky/{from.md → to.md} +732 -289
tmp/tmplmh2jwky/{from.md → to.md}
RENAMED
|
@@ -1,23 +1,27 @@
|
|
| 1 |
## Library-wide requirements <a id="requirements">[[requirements]]</a>
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
|
| 7 |
Requirements specified in terms of interactions between threads do not
|
| 8 |
apply to programs having only a single thread of execution.
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
|
| 17 |
### Library contents and organization <a id="organization">[[organization]]</a>
|
| 18 |
|
|
|
|
|
|
|
| 19 |
[[contents]] describes the entities and macros defined in the C++
|
| 20 |
standard library. [[headers]] lists the standard library headers and
|
| 21 |
some constraints on those headers. [[compliance]] lists requirements for
|
| 22 |
a freestanding implementation of the C++ standard library.
|
| 23 |
|
|
@@ -27,19 +31,40 @@ The C++ standard library provides definitions for the entities and
|
|
| 27 |
macros described in the synopses of the C++ standard library headers
|
| 28 |
[[headers]], unless otherwise specified.
|
| 29 |
|
| 30 |
All library entities except `operator new` and `operator delete` are
|
| 31 |
defined within the namespace `std` or namespaces nested within namespace
|
| 32 |
-
`std`.[^12]
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
#### Headers <a id="headers">[[headers]]</a>
|
| 43 |
|
| 44 |
Each element of the C++ standard library is declared or defined (as
|
| 45 |
appropriate) in a *header*.[^14]
|
|
@@ -53,12 +78,12 @@ headers shown in [[headers.cpp.c]]. [^15]
|
|
| 53 |
The headers listed in [[headers.cpp]], or, for a freestanding
|
| 54 |
implementation, the subset of such headers that are provided by the
|
| 55 |
implementation, are collectively known as the
|
| 56 |
*importable C++ library headers*.
|
| 57 |
|
| 58 |
-
[*Note 1*: Importable C++ library headers can be imported
|
| 59 |
-
|
| 60 |
|
| 61 |
[*Example 1*:
|
| 62 |
|
| 63 |
``` cpp
|
| 64 |
import <vector>; // imports the <vector> header unit
|
|
@@ -90,12 +115,12 @@ Names that are defined as functions in C shall be defined as functions
|
|
| 90 |
in the C++ standard library.[^16]
|
| 91 |
|
| 92 |
Identifiers that are keywords or operators in C++ shall not be defined
|
| 93 |
as macros in C++ standard library headers.[^17]
|
| 94 |
|
| 95 |
-
[[
|
| 96 |
-
using the `name.h` (C header) form in a C++ program.[^18]
|
| 97 |
|
| 98 |
Annex K of the C standard describes a large number of functions, with
|
| 99 |
associated types and macros, which “promote safer, more secure
|
| 100 |
programming” than many of the traditional C library functions. The names
|
| 101 |
of the functions have a suffix of `_s`; most of them provide the same
|
|
@@ -107,13 +132,54 @@ global namespace. (None of them is declared in namespace `std`.)
|
|
| 107 |
|
| 108 |
[[c.annex.k.names]] lists the Annex K names that may be declared in some
|
| 109 |
header. These names are also subject to the restrictions of
|
| 110 |
[[macro.names]].
|
| 111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
#### Freestanding implementations <a id="compliance">[[compliance]]</a>
|
| 113 |
|
| 114 |
-
Two kinds of implementations are defined:
|
| 115 |
[[intro.compliance]]; the kind of the implementation is
|
| 116 |
*implementation-defined*. For a hosted implementation, this document
|
| 117 |
describes the set of available headers.
|
| 118 |
|
| 119 |
A freestanding implementation has an *implementation-defined* set of
|
|
@@ -121,39 +187,39 @@ headers. This set shall include at least the headers shown in
|
|
| 121 |
[[headers.cpp.fs]].
|
| 122 |
|
| 123 |
**Table: C++ headers for freestanding implementations** <a id="headers.cpp.fs">[headers.cpp.fs]</a>
|
| 124 |
|
| 125 |
| Subclause | | Header |
|
| 126 |
-
| ---------------------- | ------------------------- | ------------------------------------------------ |
|
| 127 |
-
| [[support.types]] |
|
| 128 |
| [[support.limits]] | Implementation properties | `<cfloat>`, `<climits>`, `<limits>`, `<version>` |
|
| 129 |
-
| [[cstdint]]
|
| 130 |
| [[support.start.term]] | Start and termination | `<cstdlib>` |
|
| 131 |
| [[support.dynamic]] | Dynamic memory management | `<new>` |
|
| 132 |
| [[support.rtti]] | Type identification | `<typeinfo>` |
|
| 133 |
| [[support.srcloc]] | Source location | `<source_location>` |
|
| 134 |
| [[support.exception]] | Exception handling | `<exception>` |
|
| 135 |
| [[support.initlist]] | Initializer lists | `<initializer_list>` |
|
| 136 |
| [[cmp]] | Comparisons | `<compare>` |
|
| 137 |
| [[support.coroutine]] | Coroutines support | `<coroutine>` |
|
| 138 |
| [[support.runtime]] | Other runtime support | `<cstdarg>` |
|
| 139 |
| [[concepts]] | Concepts library | `<concepts>` |
|
| 140 |
-
| [[
|
| 141 |
| [[bit]] | Bit manipulation | `<bit>` |
|
| 142 |
| [[atomics]] | Atomics | `<atomic>` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
|
| 144 |
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
`<atomic>` shall meet the same requirements as for a hosted
|
| 149 |
-
implementation except that support for always lock-free integral atomic
|
| 150 |
-
types [[atomics.lockfree]] is *implementation-defined*, and whether or
|
| 151 |
-
not the type aliases `atomic_signed_lock_free` and
|
| 152 |
-
`atomic_unsigned_lock_free` are defined [[atomics.alias]] is
|
| 153 |
-
*implementation-defined*. The other headers listed in this table shall
|
| 154 |
-
meet the same requirements as for a hosted implementation.
|
| 155 |
|
| 156 |
### Using the library <a id="using">[[using]]</a>
|
| 157 |
|
| 158 |
#### Overview <a id="using.overview">[[using.overview]]</a>
|
| 159 |
|
|
@@ -199,10 +265,12 @@ program are included in the program prior to program startup.
|
|
| 199 |
See also replacement functions [[replacement.functions]], runtime
|
| 200 |
changes [[handler.functions]].
|
| 201 |
|
| 202 |
### Requirements on types and expressions <a id="utility.requirements">[[utility.requirements]]</a>
|
| 203 |
|
|
|
|
|
|
|
| 204 |
[[utility.arg.requirements]] describes requirements on types and
|
| 205 |
expressions used to instantiate templates defined in the C++ standard
|
| 206 |
library. [[swappable.requirements]] describes the requirements on
|
| 207 |
swappable types and swappable expressions.
|
| 208 |
[[nullablepointer.requirements]] describes the requirements on
|
|
@@ -214,33 +282,38 @@ allocators.
|
|
| 214 |
#### Template argument requirements <a id="utility.arg.requirements">[[utility.arg.requirements]]</a>
|
| 215 |
|
| 216 |
The template definitions in the C++ standard library refer to various
|
| 217 |
named requirements whose details are set out in Tables
|
| 218 |
[[tab:cpp17.equalitycomparable]]– [[tab:cpp17.destructible]]. In these
|
| 219 |
-
tables,
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
|
| 225 |
In general, a default constructor is not required. Certain container
|
| 226 |
class member function signatures specify `T()` as a default argument.
|
| 227 |
`T()` shall be a well-defined expression [[dcl.init]] if one of those
|
| 228 |
signatures is called using the default argument [[dcl.fct.default]].
|
| 229 |
|
| 230 |
**Table: Cpp17EqualityComparable requirements** <a id="cpp17.equalitycomparable">[cpp17.equalitycomparable]</a>
|
| 231 |
|
| 232 |
| Expression | Return type |
|
| 233 |
| ---------- | ----------- |
|
| 234 |
-
| `a == b` |
|
| 235 |
|
| 236 |
|
| 237 |
**Table: Cpp17LessThanComparable requirements** <a id="cpp17.lessthancomparable">[cpp17.lessthancomparable]</a>
|
| 238 |
|
| 239 |
| Expression | Return type | Requirement |
|
| 240 |
-
| ---------- | --------------------- | ------------------------------------------------------ |
|
| 241 |
-
| `a < b` |
|
| 242 |
|
| 243 |
|
| 244 |
**Table: Cpp17DefaultConstructible requirements** <a id="cpp17.defaultconstructible">[cpp17.defaultconstructible]</a>
|
| 245 |
|
| 246 |
| Expression | Post-condition |
|
|
@@ -248,37 +321,49 @@ signatures is called using the default argument [[dcl.fct.default]].
|
|
| 248 |
| `T t;` | object `t` is default-initialized |
|
| 249 |
| `T u{};` | object `u` is value-initialized or aggregate-initialized |
|
| 250 |
| `T()`<br>`T{}` | an object of type `T` is value-initialized or aggregate-initialized |
|
| 251 |
|
| 252 |
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
|
| 258 |
**Table: Cpp17CopyConstructible requirements (in addition to Cpp17MoveConstructible)** <a id="cpp17.copyconstructible">[cpp17.copyconstructible]</a>
|
| 259 |
|
| 260 |
| Expression | Post-condition |
|
| 261 |
| ---------- | --------------------------------------------------------- |
|
| 262 |
| `T u = v;` | the value of `v` is unchanged and is equivalent to ` u` |
|
| 263 |
| `T(v)` | the value of `v` is unchanged and is equivalent to `T(v)` |
|
| 264 |
|
| 265 |
|
| 266 |
-
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
|
|
|
|
|
|
|
|
|
|
| 270 |
|
| 271 |
**Table: Cpp17CopyAssignable requirements (in addition to Cpp17MoveAssignable)** <a id="cpp17.copyassignable">[cpp17.copyassignable]</a>
|
| 272 |
|
| 273 |
| Expression | Return type | Return value | Post-condition |
|
| 274 |
| ---------- | ----------- | ------------ | ------------------------------------------------------- |
|
| 275 |
| `t = v` | `T&` | `t` | `t` is equivalent to `v`, the value of `v` is unchanged |
|
| 276 |
|
| 277 |
|
| 278 |
-
|
| 279 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 280 |
|
| 281 |
#### Swappable requirements <a id="swappable.requirements">[[swappable.requirements]]</a>
|
| 282 |
|
| 283 |
This subclause provides definitions for swappable types and expressions.
|
| 284 |
In these definitions, let `t` denote an expression of type `T`, and let
|
|
@@ -312,44 +397,48 @@ swappable requirement includes the header `<utility>` to ensure an
|
|
| 312 |
appropriate evaluation context. — *end note*]
|
| 313 |
|
| 314 |
An rvalue or lvalue `t` is *swappable* if and only if `t` is swappable
|
| 315 |
with any rvalue or lvalue, respectively, of type `T`.
|
| 316 |
|
|
|
|
|
|
|
|
|
|
| 317 |
A type `X` meeting any of the iterator requirements
|
| 318 |
[[iterator.requirements]] meets the *Cpp17ValueSwappable* requirements
|
| 319 |
if, for any dereferenceable object `x` of type `X`, `*x` is swappable.
|
| 320 |
|
| 321 |
[*Example 1*:
|
| 322 |
|
| 323 |
User code can ensure that the evaluation of `swap` calls is performed in
|
| 324 |
an appropriate context under the various conditions as follows:
|
| 325 |
|
| 326 |
``` cpp
|
|
|
|
| 327 |
#include <utility>
|
| 328 |
|
| 329 |
-
//
|
| 330 |
template<class T, class U>
|
| 331 |
void value_swap(T&& t, U&& u) {
|
| 332 |
using std::swap;
|
| 333 |
-
swap(std::forward<T>(t), std::forward<U>(u)); // OK
|
| 334 |
// for rvalues and lvalues
|
| 335 |
}
|
| 336 |
|
| 337 |
-
//
|
| 338 |
template<class T>
|
| 339 |
void lv_swap(T& t1, T& t2) {
|
| 340 |
using std::swap;
|
| 341 |
-
swap(t1, t2); // OK
|
| 342 |
}
|
| 343 |
|
| 344 |
namespace N {
|
| 345 |
struct A { int m; };
|
| 346 |
struct Proxy { A* a; };
|
| 347 |
Proxy proxy(A& a) { return Proxy{ &a }; }
|
| 348 |
|
| 349 |
void swap(A& x, Proxy p) {
|
| 350 |
-
std::swap(x.m, p.a->m); // OK
|
| 351 |
// conditions for fundamental types
|
| 352 |
}
|
| 353 |
void swap(Proxy p, A& x) { swap(x, p); } // satisfy symmetry constraint
|
| 354 |
}
|
| 355 |
|
|
@@ -370,22 +459,21 @@ int main() {
|
|
| 370 |
|
| 371 |
A *Cpp17NullablePointer* type is a pointer-like type that supports null
|
| 372 |
values. A type `P` meets the *Cpp17NullablePointer* requirements if:
|
| 373 |
|
| 374 |
- `P` meets the *Cpp17EqualityComparable*, *Cpp17DefaultConstructible*,
|
| 375 |
-
*Cpp17CopyConstructible*, *Cpp17CopyAssignable*, and
|
| 376 |
*Cpp17Destructible* requirements,
|
| 377 |
-
- lvalues of type `P` are swappable [[swappable.requirements]],
|
| 378 |
- the expressions shown in [[cpp17.nullablepointer]] are valid and have
|
| 379 |
the indicated semantics, and
|
| 380 |
- `P` meets all the other requirements of this subclause.
|
| 381 |
|
| 382 |
A value-initialized object of type `P` produces the null value of the
|
| 383 |
type. The null value shall be equivalent only to itself. A
|
| 384 |
default-initialized object of type `P` may have an indeterminate value.
|
| 385 |
|
| 386 |
-
[*Note 1*: Operations involving indeterminate values
|
| 387 |
undefined behavior. — *end note*]
|
| 388 |
|
| 389 |
An object `p` of type `P` can be contextually converted to `bool`
|
| 390 |
[[conv]]. The effect shall be as if `p != nullptr` had been evaluated in
|
| 391 |
place of `p`.
|
|
@@ -393,25 +481,25 @@ place of `p`.
|
|
| 393 |
No operation which is part of the *Cpp17NullablePointer* requirements
|
| 394 |
shall exit via an exception.
|
| 395 |
|
| 396 |
In [[cpp17.nullablepointer]], `u` denotes an identifier, `t` denotes a
|
| 397 |
non-`const` lvalue of type `P`, `a` and `b` denote values of type
|
| 398 |
-
(possibly
|
| 399 |
-
`
|
| 400 |
|
| 401 |
**Table: Cpp17NullablePointer requirements** <a id="cpp17.nullablepointer">[cpp17.nullablepointer]</a>
|
| 402 |
|
| 403 |
| Expression | Return type | Operational semantics |
|
| 404 |
-
| -------------- | ---------------------------------- | --------------------------- |
|
| 405 |
| `P u(np);`<br> | | Ensures: `u == nullptr` |
|
| 406 |
| `P u = np;` | | |
|
| 407 |
| `P(np)` | | Ensures: `P(np) == nullptr` |
|
| 408 |
| `t = np` | `P&` | Ensures: `t == nullptr` |
|
| 409 |
-
| `a != b` |
|
| 410 |
-
| `a == np` |
|
| 411 |
| `np == a` | | |
|
| 412 |
-
| `a != np` |
|
| 413 |
| `np != a` | | |
|
| 414 |
|
| 415 |
|
| 416 |
#### *Cpp17Hash* requirements <a id="hash.requirements">[[hash.requirements]]</a>
|
| 417 |
|
|
@@ -422,110 +510,480 @@ A type `H` meets the requirements if:
|
|
| 422 |
and *Cpp17Destructible* ([[cpp17.destructible]]) requirements, and
|
| 423 |
- the expressions shown in [[cpp17.hash]] are valid and have the
|
| 424 |
indicated semantics.
|
| 425 |
|
| 426 |
Given `Key` is an argument type for function objects of type `H`, in
|
| 427 |
-
[[cpp17.hash]] `h` is a value of type (possibly
|
| 428 |
lvalue of type `Key`, and `k` is a value of a type convertible to
|
| 429 |
-
(possibly
|
| 430 |
|
| 431 |
[*Note 1*: Thus all evaluations of the expression `h(k)` with the same
|
| 432 |
value for `k` yield the same result for a given execution of the
|
| 433 |
program. — *end note*]
|
| 434 |
|
| 435 |
#### *Cpp17Allocator* requirements <a id="allocator.requirements">[[allocator.requirements]]</a>
|
| 436 |
|
|
|
|
|
|
|
| 437 |
The library describes a standard set of requirements for *allocators*,
|
| 438 |
which are class-type objects that encapsulate the information about an
|
| 439 |
allocation model. This information includes the knowledge of pointer
|
| 440 |
types, the type of their difference, the type of the size of objects in
|
| 441 |
this allocation model, as well as the memory allocation and deallocation
|
| 442 |
primitives for it. All of the string types [[strings]], containers
|
| 443 |
[[containers]] (except `array`), string buffers and string streams
|
| 444 |
[[input.output]], and `match_results` [[re]] are parameterized in terms
|
| 445 |
of allocators.
|
| 446 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 447 |
The class template `allocator_traits` [[allocator.traits]] supplies a
|
| 448 |
-
uniform interface to all allocator types.
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
|
| 470 |
-
|
| 471 |
-
|
| 472 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 473 |
`SomeAllocator<T, Args>`, where `Args` is zero or more type arguments,
|
| 474 |
and `Allocator` does not supply a `rebind` member template, the standard
|
| 475 |
`allocator_traits` template uses `SomeAllocator<U, Args>` in place of
|
| 476 |
-
`Allocator::
|
| 477 |
not template instantiations of the above form, no default is provided.
|
| 478 |
|
| 479 |
-
Note
|
| 480 |
-
|
| 481 |
-
|
| 482 |
-
|
| 483 |
-
`
|
| 484 |
-
|
| 485 |
-
|
| 486 |
-
|
| 487 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 488 |
|
| 489 |
An allocator type `X` shall meet the *Cpp17CopyConstructible*
|
| 490 |
-
requirements ([[cpp17.copyconstructible]]). The `
|
| 491 |
-
`
|
| 492 |
-
shall meet the *Cpp17NullablePointer* requirements (
|
| 493 |
-
[[cpp17.nullablepointer]]). No constructor, comparison
|
| 494 |
-
operation, move operation, or swap operation on these
|
| 495 |
-
shall exit via an exception. `
|
| 496 |
-
also meet the requirements for a
|
| 497 |
-
[[random.access.iterators]] and the
|
| 498 |
-
`
|
| 499 |
-
value `n`,
|
| 500 |
|
| 501 |
``` cpp
|
| 502 |
-
addressof(*(
|
| 503 |
```
|
| 504 |
|
| 505 |
is `true`.
|
| 506 |
|
| 507 |
Let `x1` and `x2` denote objects of (possibly different) types
|
| 508 |
-
`
|
| 509 |
-
`
|
| 510 |
pointer values, if and only if both `x1` and `x2` can be explicitly
|
| 511 |
converted to the two corresponding objects `px1` and `px2` of type
|
| 512 |
-
`
|
| 513 |
four types, and the expression `px1 == px2` evaluates to `true`.
|
| 514 |
|
| 515 |
-
Let `w1` and `w2` denote objects of type `
|
| 516 |
-
expressions
|
| 517 |
|
| 518 |
``` cpp
|
| 519 |
w1 == w2
|
| 520 |
w1 != w2
|
| 521 |
```
|
| 522 |
|
| 523 |
either or both objects may be replaced by an equivalently-valued object
|
| 524 |
-
of type `
|
| 525 |
|
| 526 |
-
Let `p1` and `p2` denote objects of type `
|
| 527 |
expressions
|
| 528 |
|
| 529 |
``` cpp
|
| 530 |
p1 == p2
|
| 531 |
p1 != p2
|
|
@@ -535,11 +993,11 @@ p1 >= p2
|
|
| 535 |
p1 > p2
|
| 536 |
p1 - p2
|
| 537 |
```
|
| 538 |
|
| 539 |
either or both objects may be replaced by an equivalently-valued object
|
| 540 |
-
of type `
|
| 541 |
|
| 542 |
An allocator may constrain the types on which it can be instantiated and
|
| 543 |
the arguments for which its `construct` or `destroy` members may be
|
| 544 |
called. If a type cannot be used with a particular allocator, the
|
| 545 |
allocator class or the call to `construct` or `destroy` may fail to
|
|
@@ -548,34 +1006,32 @@ instantiate.
|
|
| 548 |
If the alignment associated with a specific over-aligned type is not
|
| 549 |
supported by an allocator, instantiation of the allocator for that type
|
| 550 |
may fail. The allocator also may silently ignore the requested
|
| 551 |
alignment.
|
| 552 |
|
| 553 |
-
[*Note
|
| 554 |
-
|
| 555 |
|
| 556 |
[*Example 1*:
|
| 557 |
|
| 558 |
The following is an allocator class template supporting the minimal
|
| 559 |
-
interface that meets the requirements of
|
|
|
|
| 560 |
|
| 561 |
``` cpp
|
| 562 |
-
template<class
|
| 563 |
struct SimpleAllocator {
|
| 564 |
-
|
| 565 |
SimpleAllocator(ctor args);
|
| 566 |
|
| 567 |
-
template<class
|
| 568 |
|
| 569 |
-
|
| 570 |
-
void deallocate(
|
|
|
|
|
|
|
| 571 |
};
|
| 572 |
-
|
| 573 |
-
template<class T, class U>
|
| 574 |
-
bool operator==(const SimpleAllocator<T>&, const SimpleAllocator<U>&);
|
| 575 |
-
template<class T, class U>
|
| 576 |
-
bool operator!=(const SimpleAllocator<T>&, const SimpleAllocator<U>&);
|
| 577 |
```
|
| 578 |
|
| 579 |
— *end example*]
|
| 580 |
|
| 581 |
##### Allocator completeness requirements <a id="allocator.requirements.completeness">[[allocator.requirements.completeness]]</a>
|
|
@@ -618,10 +1074,14 @@ library requirements for the original template.[^21]
|
|
| 618 |
The behavior of a C++ program is undefined if it declares an explicit or
|
| 619 |
partial specialization of any standard library variable template, except
|
| 620 |
where explicitly permitted by the specification of that variable
|
| 621 |
template.
|
| 622 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 623 |
The behavior of a C++ program is undefined if it declares
|
| 624 |
|
| 625 |
- an explicit specialization of any member function of a standard
|
| 626 |
library class template, or
|
| 627 |
- an explicit specialization of any member function template of a
|
|
@@ -640,41 +1100,30 @@ standard library static member function, or an instantiation of a
|
|
| 640 |
standard library function template. Unless `F` is designated an
|
| 641 |
*addressable function*, the behavior of a C++ program is unspecified
|
| 642 |
(possibly ill-formed) if it explicitly or implicitly attempts to form a
|
| 643 |
pointer to `F`.
|
| 644 |
|
| 645 |
-
[*Note
|
| 646 |
of the unary `&` operator [[expr.unary.op]], `addressof`
|
| 647 |
[[specialized.addressof]], or a function-to-pointer standard conversion
|
| 648 |
[[conv.func]]. — *end note*]
|
| 649 |
|
| 650 |
Moreover, the behavior of a C++ program is unspecified (possibly
|
| 651 |
ill-formed) if it attempts to form a reference to `F` or if it attempts
|
| 652 |
to form a pointer-to-member designating either a standard library
|
| 653 |
non-static member function [[member.functions]] or an instantiation of a
|
| 654 |
standard library member function template.
|
| 655 |
|
| 656 |
-
Other than in namespace `std` or in a namespace within namespace `std`,
|
| 657 |
-
a program may provide an overload for any library function template
|
| 658 |
-
designated as a *customization point*, provided that (a) the overload’s
|
| 659 |
-
declaration depends on at least one user-defined type and (b) the
|
| 660 |
-
overload meets the standard library requirements for the customization
|
| 661 |
-
point. [^22]
|
| 662 |
-
|
| 663 |
-
[*Note 2*: This permits a (qualified or unqualified) call to the
|
| 664 |
-
customization point to invoke the most appropriate overload for the
|
| 665 |
-
given arguments. — *end note*]
|
| 666 |
-
|
| 667 |
A translation unit shall not declare namespace `std` to be an inline
|
| 668 |
namespace [[namespace.def]].
|
| 669 |
|
| 670 |
##### Namespace `posix` <a id="namespace.posix">[[namespace.posix]]</a>
|
| 671 |
|
| 672 |
The behavior of a C++ program is undefined if it adds declarations or
|
| 673 |
definitions to namespace `posix` or to a namespace within namespace
|
| 674 |
`posix` unless otherwise specified. The namespace `posix` is reserved
|
| 675 |
-
for use by ISO/IEC 9945 and other POSIX standards.
|
| 676 |
|
| 677 |
##### Namespaces for future standardization <a id="namespace.future">[[namespace.future]]</a>
|
| 678 |
|
| 679 |
Top-level namespaces whose *namespace-name* consists of `std` followed
|
| 680 |
by one or more *digit*s [[lex.name]] are reserved for future
|
|
@@ -684,18 +1133,20 @@ declarations or definitions to such a namespace.
|
|
| 684 |
[*Example 1*: The top-level namespace `std2` is reserved for use by
|
| 685 |
future revisions of this International Standard. — *end example*]
|
| 686 |
|
| 687 |
#### Reserved names <a id="reserved.names">[[reserved.names]]</a>
|
| 688 |
|
|
|
|
|
|
|
| 689 |
The C++ standard library reserves the following kinds of names:
|
| 690 |
|
| 691 |
- macros
|
| 692 |
- global names
|
| 693 |
- names with external linkage
|
| 694 |
|
| 695 |
If a program declares or defines a name in a context where it is
|
| 696 |
-
reserved, other than as explicitly allowed by
|
| 697 |
is undefined.
|
| 698 |
|
| 699 |
##### Zombie names <a id="zombie.names">[[zombie.names]]</a>
|
| 700 |
|
| 701 |
In namespace `std`, the following names are reserved for previous
|
|
@@ -711,10 +1162,13 @@ standardization:
|
|
| 711 |
- `binder2nd`,
|
| 712 |
- `const_mem_fun1_ref_t`,
|
| 713 |
- `const_mem_fun1_t`,
|
| 714 |
- `const_mem_fun_ref_t`,
|
| 715 |
- `const_mem_fun_t`,
|
|
|
|
|
|
|
|
|
|
| 716 |
- `get_temporary_buffer`,
|
| 717 |
- `get_unexpected`,
|
| 718 |
- `gets`,
|
| 719 |
- `is_literal_type`,
|
| 720 |
- `is_literal_type_v`,
|
|
@@ -724,10 +1178,11 @@ standardization:
|
|
| 724 |
- `mem_fun_ref`,
|
| 725 |
- `mem_fun_t`,
|
| 726 |
- `mem_fun`,
|
| 727 |
- `not1`,
|
| 728 |
- `not2`,
|
|
|
|
| 729 |
- `pointer_to_binary_function`,
|
| 730 |
- `pointer_to_unary_function`,
|
| 731 |
- `ptr_fun`,
|
| 732 |
- `random_shuffle`,
|
| 733 |
- `raw_storage_iterator`,
|
|
@@ -736,23 +1191,26 @@ standardization:
|
|
| 736 |
- `return_temporary_buffer`,
|
| 737 |
- `set_unexpected`,
|
| 738 |
- `unary_function`,
|
| 739 |
- `unary_negate`,
|
| 740 |
- `uncaught_exception`,
|
| 741 |
-
- `
|
|
|
|
| 742 |
- `unexpected_handler`.
|
| 743 |
|
| 744 |
-
The following names are reserved as
|
| 745 |
standardization, and may not be used as a name for object-like macros in
|
| 746 |
portable code:
|
| 747 |
|
| 748 |
- `argument_type`,
|
| 749 |
- `first_argument_type`,
|
| 750 |
- `io_state`,
|
| 751 |
- `open_mode`,
|
| 752 |
-
- `
|
| 753 |
-
- `
|
|
|
|
|
|
|
| 754 |
|
| 755 |
The name `stossc` is reserved as a member function for previous
|
| 756 |
standardization, and may not be used as a name for function-like macros
|
| 757 |
in portable code.
|
| 758 |
|
|
@@ -772,36 +1230,40 @@ defined as function-like macros [[cpp.replace]].
|
|
| 772 |
|
| 773 |
##### External linkage <a id="extern.names">[[extern.names]]</a>
|
| 774 |
|
| 775 |
Each name declared as an object with external linkage in a header is
|
| 776 |
reserved to the implementation to designate that library object with
|
| 777 |
-
external linkage, [^
|
| 778 |
-
|
|
|
|
| 779 |
|
| 780 |
Each global function signature declared with external linkage in a
|
| 781 |
header is reserved to the implementation to designate that function
|
| 782 |
-
signature with external linkage.[^
|
| 783 |
|
| 784 |
Each name from the C standard library declared with external linkage is
|
| 785 |
reserved to the implementation for use as a name with `extern "C"`
|
| 786 |
linkage, both in namespace `std` and in the global namespace.
|
| 787 |
|
| 788 |
Each function signature from the C standard library declared with
|
| 789 |
external linkage is reserved to the implementation for use as a function
|
| 790 |
-
signature with both `extern "C"` and `extern "C++"` linkage,[^
|
| 791 |
-
|
|
|
|
| 792 |
|
| 793 |
##### Types <a id="extern.types">[[extern.types]]</a>
|
| 794 |
|
| 795 |
For each type `T` from the C standard library, the types `::T` and
|
| 796 |
`std::T` are reserved to the implementation and, when defined, `::T`
|
| 797 |
shall be identical to `std::T`.
|
| 798 |
|
| 799 |
##### User-defined literal suffixes <a id="usrlit.suffix">[[usrlit.suffix]]</a>
|
| 800 |
|
| 801 |
Literal suffix identifiers [[over.literal]] that do not start with an
|
| 802 |
-
underscore are reserved for future standardization.
|
|
|
|
|
|
|
| 803 |
|
| 804 |
#### Headers <a id="alt.headers">[[alt.headers]]</a>
|
| 805 |
|
| 806 |
If a file with a name equivalent to the derived file name for one of the
|
| 807 |
C++ standard library headers is not provided as part of the
|
|
@@ -818,15 +1280,15 @@ program [[class.virtual]].
|
|
| 818 |
#### Replacement functions <a id="replacement.functions">[[replacement.functions]]</a>
|
| 819 |
|
| 820 |
[[support]] through [[thread]] and [[depr]] describe the behavior of
|
| 821 |
numerous functions defined by the C++ standard library. Under some
|
| 822 |
circumstances, however, certain of these function descriptions also
|
| 823 |
-
apply to replacement functions defined in the program
|
| 824 |
|
| 825 |
A C++ program may provide the definition for any of the following
|
| 826 |
-
dynamic memory allocation function signatures declared in header
|
| 827 |
-
|
| 828 |
|
| 829 |
``` cpp
|
| 830 |
operator new(std::size_t)
|
| 831 |
operator new(std::size_t, std::align_val_t)
|
| 832 |
operator new(std::size_t, const std::nothrow_t&)
|
|
@@ -858,11 +1320,11 @@ operator delete[](void*, const std::nothrow_t&)
|
|
| 858 |
operator delete[](void*, std::align_val_t, const std::nothrow_t&)
|
| 859 |
```
|
| 860 |
|
| 861 |
The program’s definitions are used instead of the default versions
|
| 862 |
supplied by the implementation [[new.delete]]. Such replacement occurs
|
| 863 |
-
prior to program startup
|
| 864 |
program’s declarations shall not be specified as `inline`. No diagnostic
|
| 865 |
is required.
|
| 866 |
|
| 867 |
#### Handler functions <a id="handler.functions">[[handler.functions]]</a>
|
| 868 |
|
|
@@ -898,31 +1360,30 @@ In certain cases (replacement functions, handler functions, operations
|
|
| 898 |
on types used to instantiate standard library template components), the
|
| 899 |
C++ standard library depends on components supplied by a C++ program. If
|
| 900 |
these components do not meet their requirements, this document places no
|
| 901 |
requirements on the implementation.
|
| 902 |
|
| 903 |
-
In particular, the
|
| 904 |
|
| 905 |
- For replacement functions [[new.delete]], if the installed replacement
|
| 906 |
function does not implement the semantics of the applicable *Required
|
| 907 |
behavior:* paragraph.
|
| 908 |
-
- For handler functions
|
| 909 |
-
|
| 910 |
applicable *Required behavior:* paragraph.
|
| 911 |
- For types used as template arguments when instantiating a template
|
| 912 |
component, if the operations on the type do not implement the
|
| 913 |
-
semantics of the applicable *Requirements* subclause
|
| 914 |
-
[[allocator.requirements]], [[container.requirements]],
|
| 915 |
-
|
| 916 |
-
|
| 917 |
-
failure by throwing an exception unless otherwise specified.
|
| 918 |
- If any replacement function or handler function or destructor
|
| 919 |
operation exits via an exception, unless specifically allowed in the
|
| 920 |
applicable *Required behavior:* paragraph.
|
| 921 |
-
- If an incomplete type [[
|
| 922 |
-
when instantiating a template component or evaluating a
|
| 923 |
-
unless specifically allowed for that component.
|
| 924 |
|
| 925 |
#### Function arguments <a id="res.on.arguments">[[res.on.arguments]]</a>
|
| 926 |
|
| 927 |
Each of the following applies to all arguments to functions defined in
|
| 928 |
the C++ standard library, unless explicitly stated otherwise.
|
|
@@ -933,22 +1394,23 @@ the C++ standard library, unless explicitly stated otherwise.
|
|
| 933 |
- If a function argument is described as being an array, the pointer
|
| 934 |
actually passed to the function shall have a value such that all
|
| 935 |
address computations and accesses to objects (that would be valid if
|
| 936 |
the pointer did point to the first element of such an array) are in
|
| 937 |
fact valid.
|
| 938 |
-
- If a function argument
|
| 939 |
implementation may assume that this parameter is a unique reference to
|
| 940 |
-
this argument
|
| 941 |
-
|
| 942 |
-
|
| 943 |
-
|
| 944 |
-
|
| 945 |
-
|
| 946 |
-
|
| 947 |
-
|
| 948 |
-
|
| 949 |
-
|
|
|
|
| 950 |
|
| 951 |
#### Library object access <a id="res.on.objects">[[res.on.objects]]</a>
|
| 952 |
|
| 953 |
The behavior of a program is undefined if calls to standard library
|
| 954 |
functions from different threads may introduce a data race. The
|
|
@@ -966,15 +1428,10 @@ access, or the access does not happen before the end of the object’s
|
|
| 966 |
lifetime, the behavior is undefined unless otherwise specified.
|
| 967 |
|
| 968 |
[*Note 2*: This applies even to objects such as mutexes intended for
|
| 969 |
thread synchronization. — *end note*]
|
| 970 |
|
| 971 |
-
#### Expects paragraph <a id="res.on.expects">[[res.on.expects]]</a>
|
| 972 |
-
|
| 973 |
-
Violation of any preconditions specified in a function’s
|
| 974 |
-
*Preconditions:* element results in undefined behavior.
|
| 975 |
-
|
| 976 |
#### Semantic requirements <a id="res.on.requirements">[[res.on.requirements]]</a>
|
| 977 |
|
| 978 |
A sequence `Args` of template arguments is said to *model* a concept `C`
|
| 979 |
if `Args` satisfies `C` [[temp.constr.decl]] and meets all semantic
|
| 980 |
requirements (if any) given in the specification of `C`.
|
|
@@ -1011,11 +1468,11 @@ those other headers.
|
|
| 1011 |
|
| 1012 |
Certain types and macros are defined in more than one header. Every such
|
| 1013 |
entity shall be defined such that any header that defines it may be
|
| 1014 |
included after any other header that also defines it [[basic.def.odr]].
|
| 1015 |
|
| 1016 |
-
The C standard library headers [[
|
| 1017 |
their corresponding C++ standard library header, as described in
|
| 1018 |
[[headers]].
|
| 1019 |
|
| 1020 |
#### Restrictions on macro definitions <a id="res.on.macro.definitions">[[res.on.macro.definitions]]</a>
|
| 1021 |
|
|
@@ -1032,11 +1489,11 @@ stated otherwise.
|
|
| 1032 |
It is unspecified whether any non-member functions in the C++ standard
|
| 1033 |
library are defined as inline [[dcl.inline]].
|
| 1034 |
|
| 1035 |
A call to a non-member function signature described in [[support]]
|
| 1036 |
through [[thread]] and [[depr]] shall behave as if the implementation
|
| 1037 |
-
declared no additional non-member function signatures.[^
|
| 1038 |
|
| 1039 |
An implementation shall not declare a non-member function signature with
|
| 1040 |
additional default arguments.
|
| 1041 |
|
| 1042 |
Unless otherwise specified, calls made by functions in the standard
|
|
@@ -1071,11 +1528,11 @@ For a non-virtual member function described in the C++ standard library,
|
|
| 1071 |
an implementation may declare a different set of member function
|
| 1072 |
signatures, provided that any call to the member function that would
|
| 1073 |
select an overload from the set of declarations described in this
|
| 1074 |
document behaves as if that overload were selected.
|
| 1075 |
|
| 1076 |
-
[*Note 1*: For instance, an implementation
|
| 1077 |
default values, or replace a member function with default arguments with
|
| 1078 |
two or more member functions with equivalent behavior, or add additional
|
| 1079 |
signatures for a member function name. — *end note*]
|
| 1080 |
|
| 1081 |
#### Friend functions <a id="hidden.friends">[[hidden.friends]]</a>
|
|
@@ -1141,12 +1598,12 @@ objects [[intro.multithread]] accessible by threads other than the
|
|
| 1141 |
current thread unless the objects are accessed directly or indirectly
|
| 1142 |
via the function’s non-const arguments, including `this`.
|
| 1143 |
|
| 1144 |
[*Note 1*: This means, for example, that implementations can’t use an
|
| 1145 |
object with static storage duration for internal purposes without
|
| 1146 |
-
synchronization because
|
| 1147 |
-
do not explicitly share objects between threads. — *end note*]
|
| 1148 |
|
| 1149 |
A C++ standard library function shall not access objects indirectly
|
| 1150 |
accessible via its arguments or via elements of its container arguments
|
| 1151 |
except by invoking functions required by its specification on those
|
| 1152 |
container elements.
|
|
@@ -1190,11 +1647,14 @@ the implementation.
|
|
| 1190 |
In any case:
|
| 1191 |
|
| 1192 |
- Every base class described as `virtual` shall be virtual;
|
| 1193 |
- Every base class not specified as `virtual` shall not be virtual;
|
| 1194 |
- Unless explicitly stated otherwise, types with distinct names shall be
|
| 1195 |
-
distinct types.[
|
|
|
|
|
|
|
|
|
|
| 1196 |
|
| 1197 |
All types specified in the C++ standard library shall be non-`final`
|
| 1198 |
types unless otherwise specified.
|
| 1199 |
|
| 1200 |
#### Restrictions on exception handling <a id="res.on.exception.handling">[[res.on.exception.handling]]</a>
|
|
@@ -1203,41 +1663,30 @@ Any of the functions defined in the C++ standard library can report a
|
|
| 1203 |
failure by throwing an exception of a type described in its *Throws:*
|
| 1204 |
paragraph, or of a type derived from a type named in the *Throws:*
|
| 1205 |
paragraph that would be caught by an exception handler for the base
|
| 1206 |
type.
|
| 1207 |
|
| 1208 |
-
Functions from the C standard library shall not throw exceptions [^
|
|
|
|
| 1209 |
except when such a function calls a program-supplied function that
|
| 1210 |
-
throws an exception.[^
|
| 1211 |
|
| 1212 |
Destructor operations defined in the C++ standard library shall not
|
| 1213 |
throw exceptions. Every destructor in the C++ standard library shall
|
| 1214 |
behave as if it had a non-throwing exception specification.
|
| 1215 |
|
| 1216 |
Functions defined in the C++ standard library that do not have a
|
| 1217 |
*Throws:* paragraph but do have a potentially-throwing exception
|
| 1218 |
-
specification may throw *implementation-defined* exceptions.
|
|
|
|
| 1219 |
Implementations should report errors by throwing exceptions of or
|
| 1220 |
-
derived from the standard exception classes
|
| 1221 |
-
[[support.exception]], [[std.exceptions]]
|
| 1222 |
|
| 1223 |
An implementation may strengthen the exception specification for a
|
| 1224 |
non-virtual function by adding a non-throwing exception specification.
|
| 1225 |
|
| 1226 |
-
#### Restrictions on storage of pointers <a id="res.on.pointer.storage">[[res.on.pointer.storage]]</a>
|
| 1227 |
-
|
| 1228 |
-
Objects constructed by the standard library that may hold a
|
| 1229 |
-
user-supplied pointer value or an integer of type `std::intptr_t` shall
|
| 1230 |
-
store such values in a traceable pointer location
|
| 1231 |
-
[[basic.stc.dynamic.safety]].
|
| 1232 |
-
|
| 1233 |
-
[*Note 1*: Other libraries are strongly encouraged to do the same,
|
| 1234 |
-
since not doing so may result in accidental use of pointers that are not
|
| 1235 |
-
safely derived. Libraries that store pointers outside the user’s address
|
| 1236 |
-
space should make it appear that they are stored and retrieved from a
|
| 1237 |
-
traceable pointer location. — *end note*]
|
| 1238 |
-
|
| 1239 |
#### Value of error codes <a id="value.error.codes">[[value.error.codes]]</a>
|
| 1240 |
|
| 1241 |
Certain functions in the C++ standard library report errors via a
|
| 1242 |
`std::error_code` [[syserr.errcode.overview]] object. That object’s
|
| 1243 |
`category()` member shall return `std::system_category()` for errors
|
|
@@ -1260,25 +1709,29 @@ associated values. — *end example*]
|
|
| 1260 |
Objects of types defined in the C++ standard library may be moved from
|
| 1261 |
[[class.copy.ctor]]. Move operations may be explicitly specified or
|
| 1262 |
implicitly generated. Unless otherwise specified, such moved-from
|
| 1263 |
objects shall be placed in a valid but unspecified state.
|
| 1264 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1265 |
<!-- Link reference definitions -->
|
| 1266 |
[alg.c.library]: algorithms.md#alg.c.library
|
| 1267 |
[alg.sorting]: algorithms.md#alg.sorting
|
| 1268 |
[algorithm.stable]: #algorithm.stable
|
| 1269 |
[algorithms]: algorithms.md#algorithms
|
| 1270 |
[algorithms.requirements]: algorithms.md#algorithms.requirements
|
| 1271 |
[alloc.errors]: support.md#alloc.errors
|
| 1272 |
-
[allocator.req.var]: #allocator.req.var
|
| 1273 |
[allocator.requirements]: #allocator.requirements
|
| 1274 |
[allocator.requirements.completeness]: #allocator.requirements.completeness
|
| 1275 |
-
[allocator.
|
|
|
|
| 1276 |
[alt.headers]: #alt.headers
|
| 1277 |
-
[
|
| 1278 |
-
[atomics
|
| 1279 |
-
[atomics.lockfree]: atomics.md#atomics.lockfree
|
| 1280 |
[bad.alloc]: support.md#bad.alloc
|
| 1281 |
[basic.def.odr]: basic.md#basic.def.odr
|
| 1282 |
[basic.fundamental]: basic.md#basic.fundamental
|
| 1283 |
[basic.life]: basic.md#basic.life
|
| 1284 |
[basic.link]: basic.md#basic.link
|
|
@@ -1286,24 +1739,24 @@ objects shall be placed in a valid but unspecified state.
|
|
| 1286 |
[basic.lookup.qual]: basic.md#basic.lookup.qual
|
| 1287 |
[basic.lookup.unqual]: basic.md#basic.lookup.unqual
|
| 1288 |
[basic.scope.namespace]: basic.md#basic.scope.namespace
|
| 1289 |
[basic.start]: basic.md#basic.start
|
| 1290 |
[basic.stc.dynamic]: basic.md#basic.stc.dynamic
|
| 1291 |
-
[
|
| 1292 |
-
[basic.types]: basic.md#basic.types
|
| 1293 |
-
[bit]: numerics.md#bit
|
| 1294 |
[bitmask.types]: #bitmask.types
|
| 1295 |
[byte.strings]: #byte.strings
|
| 1296 |
[c.annex.k.names]: #c.annex.k.names
|
|
|
|
|
|
|
| 1297 |
[character.seq]: #character.seq
|
|
|
|
| 1298 |
[class.copy.assign]: class.md#class.copy.assign
|
| 1299 |
[class.copy.ctor]: class.md#class.copy.ctor
|
| 1300 |
[class.dtor]: class.md#class.dtor
|
| 1301 |
[class.mem]: class.md#class.mem
|
| 1302 |
-
[class.mfct]: class.md#class.mfct
|
| 1303 |
-
[class.this]: class.md#class.this
|
| 1304 |
[class.virtual]: class.md#class.virtual
|
|
|
|
| 1305 |
[cmp]: support.md#cmp
|
| 1306 |
[compliance]: #compliance
|
| 1307 |
[concept.destructible]: concepts.md#concept.destructible
|
| 1308 |
[concept.invocable]: concepts.md#concept.invocable
|
| 1309 |
[concept.totallyordered]: concepts.md#concept.totallyordered
|
|
@@ -1319,52 +1772,48 @@ objects shall be placed in a valid but unspecified state.
|
|
| 1319 |
[containers]: containers.md#containers
|
| 1320 |
[contents]: #contents
|
| 1321 |
[conv]: expr.md#conv
|
| 1322 |
[conv.func]: expr.md#conv.func
|
| 1323 |
[conventions]: #conventions
|
|
|
|
| 1324 |
[cpp.include]: cpp.md#cpp.include
|
| 1325 |
[cpp.replace]: cpp.md#cpp.replace
|
| 1326 |
-
[cpp17.allocator]: #cpp17.allocator
|
| 1327 |
[cpp17.copyassignable]: #cpp17.copyassignable
|
| 1328 |
[cpp17.copyconstructible]: #cpp17.copyconstructible
|
| 1329 |
[cpp17.destructible]: #cpp17.destructible
|
| 1330 |
[cpp17.hash]: #cpp17.hash
|
| 1331 |
[cpp17.moveassignable]: #cpp17.moveassignable
|
| 1332 |
[cpp17.nullablepointer]: #cpp17.nullablepointer
|
| 1333 |
-
[
|
|
|
|
|
|
|
| 1334 |
[customization.point.object]: #customization.point.object
|
| 1335 |
[dcl.array]: dcl.md#dcl.array
|
| 1336 |
[dcl.attr]: dcl.md#dcl.attr
|
| 1337 |
[dcl.constexpr]: dcl.md#dcl.constexpr
|
| 1338 |
[dcl.fct.default]: dcl.md#dcl.fct.default
|
| 1339 |
[dcl.init]: dcl.md#dcl.init
|
| 1340 |
-
[dcl.init.list]: dcl.md#dcl.init.list
|
| 1341 |
[dcl.inline]: dcl.md#dcl.inline
|
| 1342 |
[dcl.link]: dcl.md#dcl.link
|
| 1343 |
[dcl.pre]: dcl.md#dcl.pre
|
| 1344 |
-
[
|
|
|
|
| 1345 |
[depr]: future.md#depr
|
| 1346 |
-
[depr.c.headers]: future.md#depr.c.headers
|
| 1347 |
[derivation]: #derivation
|
| 1348 |
[derived.classes]: #derived.classes
|
| 1349 |
[description]: #description
|
|
|
|
| 1350 |
[diagnostics]: diagnostics.md#diagnostics
|
| 1351 |
[enumerated.types]: #enumerated.types
|
| 1352 |
[except]: except.md#except
|
| 1353 |
-
[
|
| 1354 |
-
[expos.only.func]: #expos.only.func
|
| 1355 |
-
[expos.only.types]: #expos.only.types
|
| 1356 |
-
[expr.cond]: expr.md#expr.cond
|
| 1357 |
-
[expr.const]: expr.md#expr.const
|
| 1358 |
[expr.delete]: expr.md#expr.delete
|
| 1359 |
-
[expr.eq]: expr.md#expr.eq
|
| 1360 |
[expr.new]: expr.md#expr.new
|
| 1361 |
-
[expr.rel]: expr.md#expr.rel
|
| 1362 |
-
[expr.spaceship]: expr.md#expr.spaceship
|
| 1363 |
[expr.unary.op]: expr.md#expr.unary.op
|
| 1364 |
[extern.names]: #extern.names
|
| 1365 |
[extern.types]: #extern.types
|
|
|
|
| 1366 |
[function.objects]: utilities.md#function.objects
|
| 1367 |
[functions.within.classes]: #functions.within.classes
|
| 1368 |
[global.functions]: #global.functions
|
| 1369 |
[handler.functions]: #handler.functions
|
| 1370 |
[hash.requirements]: #hash.requirements
|
|
@@ -1373,16 +1822,15 @@ objects shall be placed in a valid but unspecified state.
|
|
| 1373 |
[headers.cpp.c]: #headers.cpp.c
|
| 1374 |
[headers.cpp.fs]: #headers.cpp.fs
|
| 1375 |
[hidden.friends]: #hidden.friends
|
| 1376 |
[input.output]: input.md#input.output
|
| 1377 |
[intro.compliance]: intro.md#intro.compliance
|
| 1378 |
-
[intro.defs]: intro.md#intro.defs
|
| 1379 |
-
[intro.execution]: basic.md#intro.execution
|
| 1380 |
[intro.multithread]: basic.md#intro.multithread
|
| 1381 |
[intro.refs]: intro.md#intro.refs
|
| 1382 |
[iterator.requirements]: iterators.md#iterator.requirements
|
| 1383 |
[iterators]: iterators.md#iterators
|
|
|
|
| 1384 |
[lex.name]: lex.md#lex.name
|
| 1385 |
[lex.name.special]: #lex.name.special
|
| 1386 |
[lex.phases]: lex.md#lex.phases
|
| 1387 |
[lex.separate]: lex.md#lex.separate
|
| 1388 |
[lib.types.movedfrom]: #lib.types.movedfrom
|
|
@@ -1391,12 +1839,14 @@ objects shall be placed in a valid but unspecified state.
|
|
| 1391 |
[library.categories]: #library.categories
|
| 1392 |
[library.general]: #library.general
|
| 1393 |
[locales]: localization.md#locales
|
| 1394 |
[localization]: localization.md#localization
|
| 1395 |
[macro.names]: #macro.names
|
|
|
|
| 1396 |
[member.functions]: #member.functions
|
| 1397 |
-
[
|
|
|
|
| 1398 |
[module.import]: module.md#module.import
|
| 1399 |
[multibyte.strings]: #multibyte.strings
|
| 1400 |
[namespace.constraints]: #namespace.constraints
|
| 1401 |
[namespace.def]: dcl.md#namespace.def
|
| 1402 |
[namespace.future]: #namespace.future
|
|
@@ -1409,44 +1859,49 @@ objects shall be placed in a valid but unspecified state.
|
|
| 1409 |
[nullablepointer.requirements]: #nullablepointer.requirements
|
| 1410 |
[numeric.requirements]: numerics.md#numeric.requirements
|
| 1411 |
[numerics]: numerics.md#numerics
|
| 1412 |
[objects.within.classes]: #objects.within.classes
|
| 1413 |
[organization]: #organization
|
|
|
|
| 1414 |
[ostream.iterator.ops]: iterators.md#ostream.iterator.ops
|
| 1415 |
[over.literal]: over.md#over.literal
|
| 1416 |
[over.match]: over.md#over.match
|
| 1417 |
-
[over.oper]: over.md#over.oper
|
| 1418 |
[protection.within.classes]: #protection.within.classes
|
| 1419 |
[random.access.iterators]: iterators.md#random.access.iterators
|
| 1420 |
[ranges]: ranges.md#ranges
|
|
|
|
| 1421 |
[re]: re.md#re
|
| 1422 |
[reentrancy]: #reentrancy
|
| 1423 |
[replacement.functions]: #replacement.functions
|
| 1424 |
[requirements]: #requirements
|
|
|
|
| 1425 |
[res.on.arguments]: #res.on.arguments
|
| 1426 |
[res.on.data.races]: #res.on.data.races
|
| 1427 |
[res.on.exception.handling]: #res.on.exception.handling
|
| 1428 |
-
[res.on.expects]: #res.on.expects
|
| 1429 |
[res.on.functions]: #res.on.functions
|
| 1430 |
[res.on.headers]: #res.on.headers
|
| 1431 |
[res.on.macro.definitions]: #res.on.macro.definitions
|
| 1432 |
[res.on.objects]: #res.on.objects
|
| 1433 |
-
[res.on.pointer.storage]: #res.on.pointer.storage
|
| 1434 |
[res.on.requirements]: #res.on.requirements
|
| 1435 |
[reserved.names]: #reserved.names
|
| 1436 |
-
[
|
|
|
|
| 1437 |
[std.exceptions]: diagnostics.md#std.exceptions
|
|
|
|
| 1438 |
[stmt.return]: stmt.md#stmt.return
|
| 1439 |
[stream.types]: input.md#stream.types
|
| 1440 |
[strings]: strings.md#strings
|
| 1441 |
[structure]: #structure
|
| 1442 |
[structure.elements]: #structure.elements
|
| 1443 |
[structure.requirements]: #structure.requirements
|
| 1444 |
[structure.see.also]: #structure.see.also
|
| 1445 |
[structure.specifications]: #structure.specifications
|
| 1446 |
[structure.summary]: #structure.summary
|
| 1447 |
[support]: support.md#support
|
|
|
|
|
|
|
| 1448 |
[support.coroutine]: support.md#support.coroutine
|
| 1449 |
[support.dynamic]: support.md#support.dynamic
|
| 1450 |
[support.exception]: support.md#support.exception
|
| 1451 |
[support.initlist]: support.md#support.initlist
|
| 1452 |
[support.limits]: support.md#support.limits
|
|
@@ -1456,90 +1911,93 @@ objects shall be placed in a valid but unspecified state.
|
|
| 1456 |
[support.start.term]: support.md#support.start.term
|
| 1457 |
[support.types]: support.md#support.types
|
| 1458 |
[swappable.requirements]: #swappable.requirements
|
| 1459 |
[syserr]: diagnostics.md#syserr
|
| 1460 |
[syserr.errcode.overview]: diagnostics.md#syserr.errcode.overview
|
| 1461 |
-
[tab:allocator.req.var]: #tab:allocator.req.var
|
| 1462 |
-
[tab:cpp17.allocator]: #tab:cpp17.allocator
|
| 1463 |
[tab:cpp17.destructible]: #tab:cpp17.destructible
|
| 1464 |
[tab:cpp17.equalitycomparable]: #tab:cpp17.equalitycomparable
|
| 1465 |
[temp]: temp.md#temp
|
| 1466 |
[temp.concept]: temp.md#temp.concept
|
| 1467 |
[temp.constr.decl]: temp.md#temp.constr.decl
|
| 1468 |
-
[temp.constr.order]: temp.md#temp.constr.order
|
| 1469 |
[temp.deduct.call]: temp.md#temp.deduct.call
|
| 1470 |
-
[temp.func.order]: temp.md#temp.func.order
|
| 1471 |
[template.bitset]: utilities.md#template.bitset
|
|
|
|
|
|
|
| 1472 |
[terminate.handler]: support.md#terminate.handler
|
| 1473 |
[thread]: thread.md#thread
|
| 1474 |
[time]: time.md#time
|
|
|
|
| 1475 |
[type.descriptions]: #type.descriptions
|
| 1476 |
[type.descriptions.general]: #type.descriptions.general
|
|
|
|
| 1477 |
[using]: #using
|
| 1478 |
[using.headers]: #using.headers
|
| 1479 |
[using.linkage]: #using.linkage
|
| 1480 |
[using.overview]: #using.overview
|
| 1481 |
[usrlit.suffix]: #usrlit.suffix
|
| 1482 |
[utilities]: utilities.md#utilities
|
|
|
|
| 1483 |
[utility.arg.requirements]: #utility.arg.requirements
|
| 1484 |
[utility.requirements]: #utility.requirements
|
|
|
|
| 1485 |
[value.error.codes]: #value.error.codes
|
| 1486 |
[zombie.names]: #zombie.names
|
| 1487 |
|
| 1488 |
-
[^1]:
|
|
|
|
|
|
|
| 1489 |
For example, if a Clause does not specify any requirements, there
|
| 1490 |
will be no “Requirements” subclause.
|
| 1491 |
|
| 1492 |
-
[^
|
| 1493 |
implementation.
|
| 1494 |
|
| 1495 |
-
[^
|
| 1496 |
-
example, if a class does not specify any comparison
|
| 1497 |
-
will be no “Comparison functions”
|
|
|
|
| 1498 |
|
| 1499 |
-
[^
|
| 1500 |
omitted. For example, if a function specifies no preconditions,
|
| 1501 |
there will be no *Preconditions:* element.
|
| 1502 |
|
| 1503 |
-
[^
|
| 1504 |
some cases.
|
| 1505 |
|
| 1506 |
-
[^
|
| 1507 |
*Cpp17EqualityComparable*, *Cpp17LessThanComparable*,
|
| 1508 |
*Cpp17CopyConstructible*. Examples from [[iterator.requirements]]
|
| 1509 |
include: *Cpp17InputIterator*, *Cpp17ForwardIterator*.
|
| 1510 |
|
| 1511 |
-
[^
|
| 1512 |
[[basic.fundamental]].
|
| 1513 |
|
| 1514 |
-
[^8]: declared in `<clocale>`.
|
| 1515 |
-
|
| 1516 |
[^9]: Many of the objects manipulated by function signatures declared in
|
| 1517 |
`<cstring>` are character sequences or NTBSs. The size of some of
|
| 1518 |
these character sequences is limited by a length value, maintained
|
| 1519 |
separately from the character sequence.
|
| 1520 |
|
| 1521 |
[^10]: A *string-literal*, such as `"abc"`, is a static NTBS.
|
| 1522 |
|
| 1523 |
-
[^11]: An NTBS that contains characters only from the basic
|
| 1524 |
character set is also an NTMBS. Each multibyte character then
|
| 1525 |
consists of a single byte.
|
| 1526 |
|
| 1527 |
-
[^12]: The C standard library headers [[
|
| 1528 |
names within the global namespace, while the C++ headers for C
|
| 1529 |
-
library facilities [[headers]]
|
| 1530 |
global namespace.
|
| 1531 |
|
| 1532 |
[^13]: This gives implementers freedom to use inline namespaces to
|
| 1533 |
support multiple configurations of the library.
|
| 1534 |
|
| 1535 |
[^14]: A header is not necessarily a source file, nor are the sequences
|
| 1536 |
delimited by `<` and `>` in header names necessarily valid source
|
| 1537 |
file names [[cpp.include]].
|
| 1538 |
|
| 1539 |
[^15]: It is intentional that there is no C++ header for any of these C
|
| 1540 |
-
headers: `<
|
| 1541 |
|
| 1542 |
[^16]: This disallows the practice, allowed in C, of providing a masking
|
| 1543 |
macro in addition to the function prototype. The only way to achieve
|
| 1544 |
equivalent inline behavior in C++ is to provide a definition as an
|
| 1545 |
extern inline function.
|
|
@@ -1561,48 +2019,33 @@ objects shall be placed in a valid but unspecified state.
|
|
| 1561 |
|
| 1562 |
[^21]: Any library code that instantiates other library templates must
|
| 1563 |
be prepared to work adequately with any user-supplied specialization
|
| 1564 |
that meets the minimum requirements of this document.
|
| 1565 |
|
| 1566 |
-
[^22]:
|
| 1567 |
-
adequately with any user-defined overload that meets the minimum
|
| 1568 |
-
requirements of this document. Therefore an implementation may
|
| 1569 |
-
elect, under the as-if rule [[intro.execution]], to provide any
|
| 1570 |
-
customization point in the form of an instantiated function object
|
| 1571 |
-
[[function.objects]] even though the customization point’s
|
| 1572 |
-
specification is in the form of a function template. The template
|
| 1573 |
-
parameters of each such function object and the function parameters
|
| 1574 |
-
and return type of the object’s `operator()` must match those of the
|
| 1575 |
-
corresponding customization point’s specification.
|
| 1576 |
-
|
| 1577 |
-
[^23]: The list of such reserved names includes `errno`, declared or
|
| 1578 |
defined in `<cerrno>`.
|
| 1579 |
|
| 1580 |
-
[^
|
| 1581 |
linkage includes `setjmp(jmp_buf)`, declared or defined in
|
| 1582 |
`<csetjmp>`, and `va_end(va_list)`, declared or defined in
|
| 1583 |
`<cstdarg>`.
|
| 1584 |
|
| 1585 |
-
[^
|
| 1586 |
`<cwctype>` are always reserved, notwithstanding the restrictions
|
| 1587 |
imposed in subclause 4.5.1 of Amendment 1 to the C Standard for
|
| 1588 |
these headers.
|
| 1589 |
|
| 1590 |
-
[^
|
| 1591 |
-
function. An implementation
|
| 1592 |
functions that would otherwise not be called by a valid C++ program.
|
| 1593 |
|
| 1594 |
-
[^
|
| 1595 |
-
described as synonyms for basic integral types, such as `size_t`
|
| 1596 |
-
[[support.types]] and `streamoff` [[stream.types]].
|
| 1597 |
-
|
| 1598 |
-
[^28]: That is, the C library functions can all be treated as if they
|
| 1599 |
are marked `noexcept`. This allows implementations to make
|
| 1600 |
performance optimizations based on the absence of exceptions at
|
| 1601 |
runtime.
|
| 1602 |
|
| 1603 |
-
[^
|
| 1604 |
this condition.
|
| 1605 |
|
| 1606 |
-
[^
|
| 1607 |
throwing an exception of type `bad_alloc`, or a class derived from
|
| 1608 |
`bad_alloc` [[bad.alloc]].
|
|
|
|
| 1 |
## Library-wide requirements <a id="requirements">[[requirements]]</a>
|
| 2 |
|
| 3 |
+
### General <a id="requirements.general">[[requirements.general]]</a>
|
| 4 |
+
|
| 5 |
+
Subclause [[requirements]] specifies requirements that apply to the
|
| 6 |
+
entire C++ standard library. [[support]] through [[thread]] and [[depr]]
|
| 7 |
+
specify the requirements of individual entities within the library.
|
| 8 |
|
| 9 |
Requirements specified in terms of interactions between threads do not
|
| 10 |
apply to programs having only a single thread of execution.
|
| 11 |
|
| 12 |
+
[[organization]] describes the library’s contents and organization,
|
| 13 |
+
[[using]] describes how well-formed C++ programs gain access to library
|
| 14 |
+
entities, [[utility.requirements]] describes constraints on types and
|
| 15 |
+
functions used with the C++ standard library, [[constraints]] describes
|
| 16 |
+
constraints on well-formed C++ programs, and [[conforming]] describes
|
| 17 |
+
constraints on conforming implementations.
|
| 18 |
|
| 19 |
### Library contents and organization <a id="organization">[[organization]]</a>
|
| 20 |
|
| 21 |
+
#### General <a id="organization.general">[[organization.general]]</a>
|
| 22 |
+
|
| 23 |
[[contents]] describes the entities and macros defined in the C++
|
| 24 |
standard library. [[headers]] lists the standard library headers and
|
| 25 |
some constraints on those headers. [[compliance]] lists requirements for
|
| 26 |
a freestanding implementation of the C++ standard library.
|
| 27 |
|
|
|
|
| 31 |
macros described in the synopses of the C++ standard library headers
|
| 32 |
[[headers]], unless otherwise specified.
|
| 33 |
|
| 34 |
All library entities except `operator new` and `operator delete` are
|
| 35 |
defined within the namespace `std` or namespaces nested within namespace
|
| 36 |
+
`std`.[^12]
|
| 37 |
+
|
| 38 |
+
It is unspecified whether names declared in a specific namespace are
|
| 39 |
+
declared directly in that namespace or in an inline namespace inside
|
| 40 |
+
that namespace.[^13]
|
| 41 |
+
|
| 42 |
+
Whenever an unqualified name other than `swap`, `make_error_code`, or
|
| 43 |
+
`make_error_condition` is used in the specification of a declaration `D`
|
| 44 |
+
in [[support]] through [[thread]] or [[depr]], its meaning is
|
| 45 |
+
established as-if by performing unqualified name lookup
|
| 46 |
+
[[basic.lookup.unqual]] in the context of `D`.
|
| 47 |
+
|
| 48 |
+
[*Note 1*: Argument-dependent lookup is not performed. — *end note*]
|
| 49 |
+
|
| 50 |
+
Similarly, the meaning of a *qualified-id* is established as-if by
|
| 51 |
+
performing qualified name lookup [[basic.lookup.qual]] in the context of
|
| 52 |
+
`D`.
|
| 53 |
+
|
| 54 |
+
[*Example 1*: The reference to `is_array_v` in the specification of
|
| 55 |
+
`std::to_array` [[array.creation]] refers to
|
| 56 |
+
`::std::is_array_v`. — *end example*]
|
| 57 |
+
|
| 58 |
+
[*Note 2*: Operators in expressions [[over.match.oper]] are not so
|
| 59 |
+
constrained; see [[global.functions]]. — *end note*]
|
| 60 |
+
|
| 61 |
+
The meaning of the unqualified name `swap` is established in an overload
|
| 62 |
+
resolution context for swappable values [[swappable.requirements]]. The
|
| 63 |
+
meanings of the unqualified names `make_error_code` and
|
| 64 |
+
`make_error_condition` are established as-if by performing
|
| 65 |
+
argument-dependent lookup [[basic.lookup.argdep]].
|
| 66 |
|
| 67 |
#### Headers <a id="headers">[[headers]]</a>
|
| 68 |
|
| 69 |
Each element of the C++ standard library is declared or defined (as
|
| 70 |
appropriate) in a *header*.[^14]
|
|
|
|
| 78 |
The headers listed in [[headers.cpp]], or, for a freestanding
|
| 79 |
implementation, the subset of such headers that are provided by the
|
| 80 |
implementation, are collectively known as the
|
| 81 |
*importable C++ library headers*.
|
| 82 |
|
| 83 |
+
[*Note 1*: Importable C++ library headers can be imported
|
| 84 |
+
[[module.import]]. — *end note*]
|
| 85 |
|
| 86 |
[*Example 1*:
|
| 87 |
|
| 88 |
``` cpp
|
| 89 |
import <vector>; // imports the <vector> header unit
|
|
|
|
| 115 |
in the C++ standard library.[^16]
|
| 116 |
|
| 117 |
Identifiers that are keywords or operators in C++ shall not be defined
|
| 118 |
as macros in C++ standard library headers.[^17]
|
| 119 |
|
| 120 |
+
[[support.c.headers]], C standard library headers, describes the effects
|
| 121 |
+
of using the `name.h` (C header) form in a C++ program.[^18]
|
| 122 |
|
| 123 |
Annex K of the C standard describes a large number of functions, with
|
| 124 |
associated types and macros, which “promote safer, more secure
|
| 125 |
programming” than many of the traditional C library functions. The names
|
| 126 |
of the functions have a suffix of `_s`; most of them provide the same
|
|
|
|
| 132 |
|
| 133 |
[[c.annex.k.names]] lists the Annex K names that may be declared in some
|
| 134 |
header. These names are also subject to the restrictions of
|
| 135 |
[[macro.names]].
|
| 136 |
|
| 137 |
+
#### Modules <a id="std.modules">[[std.modules]]</a>
|
| 138 |
+
|
| 139 |
+
The C++ standard library provides the following *C++ library modules*.
|
| 140 |
+
|
| 141 |
+
The named module `std` exports declarations in namespace `std` that are
|
| 142 |
+
provided by the importable C++ library headers ([[headers.cpp]] or the
|
| 143 |
+
subset provided by a freestanding implementation) and the C++ headers
|
| 144 |
+
for C library facilities ([[headers.cpp.c]]). It additionally exports
|
| 145 |
+
declarations in the global namespace for the storage allocation and
|
| 146 |
+
deallocation functions that are provided by `<new>`.
|
| 147 |
+
|
| 148 |
+
The named module `std.compat` exports the same declarations as the named
|
| 149 |
+
module `std`, and additionally exports declarations in the global
|
| 150 |
+
namespace corresponding to the declarations in namespace `std` that are
|
| 151 |
+
provided by the C++ headers for C library facilities (
|
| 152 |
+
[[headers.cpp.c]]), except the explicitly excluded declarations
|
| 153 |
+
described in [[support.c.headers.other]].
|
| 154 |
+
|
| 155 |
+
It is unspecified to which module a declaration in the standard library
|
| 156 |
+
is attached.
|
| 157 |
+
|
| 158 |
+
[*Note 1*: Implementations are required to ensure that mixing
|
| 159 |
+
`#include` and `import` does not result in conflicting attachments
|
| 160 |
+
[[basic.link]]. — *end note*]
|
| 161 |
+
|
| 162 |
+
*Recommended practice:* Implementations should ensure such attachments
|
| 163 |
+
do not preclude further evolution or decomposition of the standard
|
| 164 |
+
library modules.
|
| 165 |
+
|
| 166 |
+
A declaration in the standard library denotes the same entity regardless
|
| 167 |
+
of whether it was made reachable through including a header, importing a
|
| 168 |
+
header unit, or importing a C++ library module.
|
| 169 |
+
|
| 170 |
+
*Recommended practice:* Implementations should avoid exporting any other
|
| 171 |
+
declarations from the C++ library modules.
|
| 172 |
+
|
| 173 |
+
[*Note 2*: Like all named modules, the C++ library modules do not make
|
| 174 |
+
macros visible [[module.import]], such as `assert` [[cassert.syn]],
|
| 175 |
+
`errno` [[cerrno.syn]], `offsetof` [[cstddef.syn]], and `va_arg`
|
| 176 |
+
[[cstdarg.syn]]. — *end note*]
|
| 177 |
+
|
| 178 |
#### Freestanding implementations <a id="compliance">[[compliance]]</a>
|
| 179 |
|
| 180 |
+
Two kinds of implementations are defined: hosted and freestanding
|
| 181 |
[[intro.compliance]]; the kind of the implementation is
|
| 182 |
*implementation-defined*. For a hosted implementation, this document
|
| 183 |
describes the set of available headers.
|
| 184 |
|
| 185 |
A freestanding implementation has an *implementation-defined* set of
|
|
|
|
| 187 |
[[headers.cpp.fs]].
|
| 188 |
|
| 189 |
**Table: C++ headers for freestanding implementations** <a id="headers.cpp.fs">[headers.cpp.fs]</a>
|
| 190 |
|
| 191 |
| Subclause | | Header |
|
| 192 |
+
| ---------------------- | -------------------------------- | ------------------------------------------------ |
|
| 193 |
+
| [[support.types]] | Common definitions | `<cstddef>` |
|
| 194 |
| [[support.limits]] | Implementation properties | `<cfloat>`, `<climits>`, `<limits>`, `<version>` |
|
| 195 |
+
| [[cstdint.syn]] | Integer types | `<cstdint>` |
|
| 196 |
| [[support.start.term]] | Start and termination | `<cstdlib>` |
|
| 197 |
| [[support.dynamic]] | Dynamic memory management | `<new>` |
|
| 198 |
| [[support.rtti]] | Type identification | `<typeinfo>` |
|
| 199 |
| [[support.srcloc]] | Source location | `<source_location>` |
|
| 200 |
| [[support.exception]] | Exception handling | `<exception>` |
|
| 201 |
| [[support.initlist]] | Initializer lists | `<initializer_list>` |
|
| 202 |
| [[cmp]] | Comparisons | `<compare>` |
|
| 203 |
| [[support.coroutine]] | Coroutines support | `<coroutine>` |
|
| 204 |
| [[support.runtime]] | Other runtime support | `<cstdarg>` |
|
| 205 |
| [[concepts]] | Concepts library | `<concepts>` |
|
| 206 |
+
| [[type.traits]] | Type traits | `<type_traits>` |
|
| 207 |
| [[bit]] | Bit manipulation | `<bit>` |
|
| 208 |
| [[atomics]] | Atomics | `<atomic>` |
|
| 209 |
+
| [[utility]] | Utility components | `<utility>` |
|
| 210 |
+
| [[tuple]] | Tuples | `<tuple>` |
|
| 211 |
+
| [[memory]] | Memory | `<memory>` |
|
| 212 |
+
| [[function.objects]] | Function objects | `<functional>` |
|
| 213 |
+
| [[ratio]] | Compile-time rational arithmetic | `<ratio>` |
|
| 214 |
+
| [[iterators]] | Iterators library | `<iterator>` |
|
| 215 |
+
| [[ranges]] | Ranges library | `<ranges>` |
|
| 216 |
|
| 217 |
|
| 218 |
+
For each of the headers listed in [[headers.cpp.fs]], a freestanding
|
| 219 |
+
implementation provides at least the freestanding items
|
| 220 |
+
[[freestanding.item]] declared in the header.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 221 |
|
| 222 |
### Using the library <a id="using">[[using]]</a>
|
| 223 |
|
| 224 |
#### Overview <a id="using.overview">[[using.overview]]</a>
|
| 225 |
|
|
|
|
| 265 |
See also replacement functions [[replacement.functions]], runtime
|
| 266 |
changes [[handler.functions]].
|
| 267 |
|
| 268 |
### Requirements on types and expressions <a id="utility.requirements">[[utility.requirements]]</a>
|
| 269 |
|
| 270 |
+
#### General <a id="utility.requirements.general">[[utility.requirements.general]]</a>
|
| 271 |
+
|
| 272 |
[[utility.arg.requirements]] describes requirements on types and
|
| 273 |
expressions used to instantiate templates defined in the C++ standard
|
| 274 |
library. [[swappable.requirements]] describes the requirements on
|
| 275 |
swappable types and swappable expressions.
|
| 276 |
[[nullablepointer.requirements]] describes the requirements on
|
|
|
|
| 282 |
#### Template argument requirements <a id="utility.arg.requirements">[[utility.arg.requirements]]</a>
|
| 283 |
|
| 284 |
The template definitions in the C++ standard library refer to various
|
| 285 |
named requirements whose details are set out in Tables
|
| 286 |
[[tab:cpp17.equalitycomparable]]– [[tab:cpp17.destructible]]. In these
|
| 287 |
+
tables,
|
| 288 |
+
|
| 289 |
+
- `T` denotes an object or reference type to be supplied by a C++
|
| 290 |
+
program instantiating a template,
|
| 291 |
+
- `a`, `b`, and `c` denote values of type (possibly const) `T`,
|
| 292 |
+
- `s` and `t` denote modifiable lvalues of type `T`,
|
| 293 |
+
- `u` denotes an identifier,
|
| 294 |
+
- `rv` denotes an rvalue of type `T`, and
|
| 295 |
+
- `v` denotes an lvalue of type (possibly const) `T` or an rvalue of
|
| 296 |
+
type `const T`.
|
| 297 |
|
| 298 |
In general, a default constructor is not required. Certain container
|
| 299 |
class member function signatures specify `T()` as a default argument.
|
| 300 |
`T()` shall be a well-defined expression [[dcl.init]] if one of those
|
| 301 |
signatures is called using the default argument [[dcl.fct.default]].
|
| 302 |
|
| 303 |
**Table: Cpp17EqualityComparable requirements** <a id="cpp17.equalitycomparable">[cpp17.equalitycomparable]</a>
|
| 304 |
|
| 305 |
| Expression | Return type |
|
| 306 |
| ---------- | ----------- |
|
| 307 |
+
| `a == b` | `decltype(a == b)` models `boolean-testable` | `==` is an equivalence relation, that is, it has the following properties: For all `a`, `a == a`.; If `a == b`, then `b == a`.; If `a == b` and `b == c`, then `a == c`. |
|
| 308 |
|
| 309 |
|
| 310 |
**Table: Cpp17LessThanComparable requirements** <a id="cpp17.lessthancomparable">[cpp17.lessthancomparable]</a>
|
| 311 |
|
| 312 |
| Expression | Return type | Requirement |
|
| 313 |
+
| ---------- | ------------------------------------------- | ------------------------------------------------------ |
|
| 314 |
+
| `a < b` | `decltype(a < b)` models `boolean-testable` | `<` is a strict weak ordering relation [[alg.sorting]] |
|
| 315 |
|
| 316 |
|
| 317 |
**Table: Cpp17DefaultConstructible requirements** <a id="cpp17.defaultconstructible">[cpp17.defaultconstructible]</a>
|
| 318 |
|
| 319 |
| Expression | Post-condition |
|
|
|
|
| 321 |
| `T t;` | object `t` is default-initialized |
|
| 322 |
| `T u{};` | object `u` is value-initialized or aggregate-initialized |
|
| 323 |
| `T()`<br>`T{}` | an object of type `T` is value-initialized or aggregate-initialized |
|
| 324 |
|
| 325 |
|
| 326 |
+
**Table: Cpp17MoveConstructible requirements** <a id="cpp17.moveconstructible">[cpp17.moveconstructible]</a>
|
| 327 |
+
|
| 328 |
+
| Expression | Post-condition |
|
| 329 |
+
| ----------- | ------------------------------------------------------------------ |
|
| 330 |
+
| `T u = rv;` | `u` is equivalent to the value of `rv` before the construction |
|
| 331 |
+
| `T(rv)` | `T(rv)` is equivalent to the value of `rv` before the construction |
|
| 332 |
+
| *[spans 2 columns]* `rv`'s state is unspecified *`rv` must still meet the requirements of the library component that is using it. The operations listed in those requirements must work as specified whether `rv` has been moved from or not.* |
|
| 333 |
+
|
| 334 |
|
| 335 |
**Table: Cpp17CopyConstructible requirements (in addition to Cpp17MoveConstructible)** <a id="cpp17.copyconstructible">[cpp17.copyconstructible]</a>
|
| 336 |
|
| 337 |
| Expression | Post-condition |
|
| 338 |
| ---------- | --------------------------------------------------------- |
|
| 339 |
| `T u = v;` | the value of `v` is unchanged and is equivalent to ` u` |
|
| 340 |
| `T(v)` | the value of `v` is unchanged and is equivalent to `T(v)` |
|
| 341 |
|
| 342 |
|
| 343 |
+
**Table: Cpp17MoveAssignable requirements** <a id="cpp17.moveassignable">[cpp17.moveassignable]</a>
|
| 344 |
+
|
| 345 |
+
| Expression | Return type | Return value | Post-condition |
|
| 346 |
+
| ---------- | ----------- | ------------ | ------------------------------------------------------------------------------------------------------------- |
|
| 347 |
+
| `t = rv` | `T&` | `t` | If `t` and `rv` do not refer to the same object, `t` is equivalent to the value of `rv` before the assignment |
|
| 348 |
+
| *[spans 4 columns]* `rv`'s state is unspecified. *`rv` must still meet the requirements of the library component that is using it, whether or not `t` and `rv` refer to the same object. The operations listed in those requirements must work as specified whether `rv` has been moved from or not.* |
|
| 349 |
+
|
| 350 |
|
| 351 |
**Table: Cpp17CopyAssignable requirements (in addition to Cpp17MoveAssignable)** <a id="cpp17.copyassignable">[cpp17.copyassignable]</a>
|
| 352 |
|
| 353 |
| Expression | Return type | Return value | Post-condition |
|
| 354 |
| ---------- | ----------- | ------------ | ------------------------------------------------------- |
|
| 355 |
| `t = v` | `T&` | `t` | `t` is equivalent to `v`, the value of `v` is unchanged |
|
| 356 |
|
| 357 |
|
| 358 |
+
**Table: Cpp17Destructible requirements** <a id="cpp17.destructible">[cpp17.destructible]</a>
|
| 359 |
+
|
| 360 |
+
| Expression | Post-condition |
|
| 361 |
+
| ---------- | --------------------------------------------------------------------- |
|
| 362 |
+
| `u.~T()` | All resources owned by `u` are reclaimed, no exception is propagated. |
|
| 363 |
+
| *[spans 2 columns]* *Array types and non-object types are not Cpp17Destructible.* |
|
| 364 |
+
|
| 365 |
|
| 366 |
#### Swappable requirements <a id="swappable.requirements">[[swappable.requirements]]</a>
|
| 367 |
|
| 368 |
This subclause provides definitions for swappable types and expressions.
|
| 369 |
In these definitions, let `t` denote an expression of type `T`, and let
|
|
|
|
| 397 |
appropriate evaluation context. — *end note*]
|
| 398 |
|
| 399 |
An rvalue or lvalue `t` is *swappable* if and only if `t` is swappable
|
| 400 |
with any rvalue or lvalue, respectively, of type `T`.
|
| 401 |
|
| 402 |
+
A type `X` meets the *Cpp17Swappable* requirements if lvalues of type
|
| 403 |
+
`X` are swappable.
|
| 404 |
+
|
| 405 |
A type `X` meeting any of the iterator requirements
|
| 406 |
[[iterator.requirements]] meets the *Cpp17ValueSwappable* requirements
|
| 407 |
if, for any dereferenceable object `x` of type `X`, `*x` is swappable.
|
| 408 |
|
| 409 |
[*Example 1*:
|
| 410 |
|
| 411 |
User code can ensure that the evaluation of `swap` calls is performed in
|
| 412 |
an appropriate context under the various conditions as follows:
|
| 413 |
|
| 414 |
``` cpp
|
| 415 |
+
#include <cassert>
|
| 416 |
#include <utility>
|
| 417 |
|
| 418 |
+
// Preconditions: std::forward<T>(t) is swappable with std::forward<U>(u).
|
| 419 |
template<class T, class U>
|
| 420 |
void value_swap(T&& t, U&& u) {
|
| 421 |
using std::swap;
|
| 422 |
+
swap(std::forward<T>(t), std::forward<U>(u)); // OK, uses ``swappable with'' conditions
|
| 423 |
// for rvalues and lvalues
|
| 424 |
}
|
| 425 |
|
| 426 |
+
// Preconditions: T meets the Cpp17Swappable requirements.
|
| 427 |
template<class T>
|
| 428 |
void lv_swap(T& t1, T& t2) {
|
| 429 |
using std::swap;
|
| 430 |
+
swap(t1, t2); // OK, uses swappable conditions for lvalues of type T
|
| 431 |
}
|
| 432 |
|
| 433 |
namespace N {
|
| 434 |
struct A { int m; };
|
| 435 |
struct Proxy { A* a; };
|
| 436 |
Proxy proxy(A& a) { return Proxy{ &a }; }
|
| 437 |
|
| 438 |
void swap(A& x, Proxy p) {
|
| 439 |
+
std::swap(x.m, p.a->m); // OK, uses context equivalent to swappable
|
| 440 |
// conditions for fundamental types
|
| 441 |
}
|
| 442 |
void swap(Proxy p, A& x) { swap(x, p); } // satisfy symmetry constraint
|
| 443 |
}
|
| 444 |
|
|
|
|
| 459 |
|
| 460 |
A *Cpp17NullablePointer* type is a pointer-like type that supports null
|
| 461 |
values. A type `P` meets the *Cpp17NullablePointer* requirements if:
|
| 462 |
|
| 463 |
- `P` meets the *Cpp17EqualityComparable*, *Cpp17DefaultConstructible*,
|
| 464 |
+
*Cpp17CopyConstructible*, *Cpp17CopyAssignable*, *Cpp17Swappable*, and
|
| 465 |
*Cpp17Destructible* requirements,
|
|
|
|
| 466 |
- the expressions shown in [[cpp17.nullablepointer]] are valid and have
|
| 467 |
the indicated semantics, and
|
| 468 |
- `P` meets all the other requirements of this subclause.
|
| 469 |
|
| 470 |
A value-initialized object of type `P` produces the null value of the
|
| 471 |
type. The null value shall be equivalent only to itself. A
|
| 472 |
default-initialized object of type `P` may have an indeterminate value.
|
| 473 |
|
| 474 |
+
[*Note 1*: Operations involving indeterminate values can cause
|
| 475 |
undefined behavior. — *end note*]
|
| 476 |
|
| 477 |
An object `p` of type `P` can be contextually converted to `bool`
|
| 478 |
[[conv]]. The effect shall be as if `p != nullptr` had been evaluated in
|
| 479 |
place of `p`.
|
|
|
|
| 481 |
No operation which is part of the *Cpp17NullablePointer* requirements
|
| 482 |
shall exit via an exception.
|
| 483 |
|
| 484 |
In [[cpp17.nullablepointer]], `u` denotes an identifier, `t` denotes a
|
| 485 |
non-`const` lvalue of type `P`, `a` and `b` denote values of type
|
| 486 |
+
(possibly const) `P`, and `np` denotes a value of type (possibly const)
|
| 487 |
+
`std::nullptr_t`.
|
| 488 |
|
| 489 |
**Table: Cpp17NullablePointer requirements** <a id="cpp17.nullablepointer">[cpp17.nullablepointer]</a>
|
| 490 |
|
| 491 |
| Expression | Return type | Operational semantics |
|
| 492 |
+
| -------------- | ------------------------------------------------------------------------- | --------------------------- |
|
| 493 |
| `P u(np);`<br> | | Ensures: `u == nullptr` |
|
| 494 |
| `P u = np;` | | |
|
| 495 |
| `P(np)` | | Ensures: `P(np) == nullptr` |
|
| 496 |
| `t = np` | `P&` | Ensures: `t == nullptr` |
|
| 497 |
+
| `a != b` | `decltype(a != b)` models `boolean-testable` | `!(a == b)` |
|
| 498 |
+
| `a == np` | `decltype(a == np)` and `decltype(np == a)` each model `boolean-testable` | `a == P()` |
|
| 499 |
| `np == a` | | |
|
| 500 |
+
| `a != np` | `decltype(a != np)` and `decltype(np != a)` each model `boolean-testable` | `!(a == np)` |
|
| 501 |
| `np != a` | | |
|
| 502 |
|
| 503 |
|
| 504 |
#### *Cpp17Hash* requirements <a id="hash.requirements">[[hash.requirements]]</a>
|
| 505 |
|
|
|
|
| 510 |
and *Cpp17Destructible* ([[cpp17.destructible]]) requirements, and
|
| 511 |
- the expressions shown in [[cpp17.hash]] are valid and have the
|
| 512 |
indicated semantics.
|
| 513 |
|
| 514 |
Given `Key` is an argument type for function objects of type `H`, in
|
| 515 |
+
[[cpp17.hash]] `h` is a value of type (possibly const) `H`, `u` is an
|
| 516 |
lvalue of type `Key`, and `k` is a value of a type convertible to
|
| 517 |
+
(possibly const) `Key`.
|
| 518 |
|
| 519 |
[*Note 1*: Thus all evaluations of the expression `h(k)` with the same
|
| 520 |
value for `k` yield the same result for a given execution of the
|
| 521 |
program. — *end note*]
|
| 522 |
|
| 523 |
#### *Cpp17Allocator* requirements <a id="allocator.requirements">[[allocator.requirements]]</a>
|
| 524 |
|
| 525 |
+
##### General <a id="allocator.requirements.general">[[allocator.requirements.general]]</a>
|
| 526 |
+
|
| 527 |
The library describes a standard set of requirements for *allocators*,
|
| 528 |
which are class-type objects that encapsulate the information about an
|
| 529 |
allocation model. This information includes the knowledge of pointer
|
| 530 |
types, the type of their difference, the type of the size of objects in
|
| 531 |
this allocation model, as well as the memory allocation and deallocation
|
| 532 |
primitives for it. All of the string types [[strings]], containers
|
| 533 |
[[containers]] (except `array`), string buffers and string streams
|
| 534 |
[[input.output]], and `match_results` [[re]] are parameterized in terms
|
| 535 |
of allocators.
|
| 536 |
|
| 537 |
+
In subclause [[allocator.requirements]],
|
| 538 |
+
|
| 539 |
+
- `T`, `U`, `C` denote any cv-unqualified object type
|
| 540 |
+
[[term.object.type]],
|
| 541 |
+
- `X` denotes an allocator class for type `T`,
|
| 542 |
+
- `Y` denotes the corresponding allocator class for type `U`,
|
| 543 |
+
- `XX` denotes the type `allocator_traits<X>`,
|
| 544 |
+
- `YY` denotes the type `allocator_traits<Y>`,
|
| 545 |
+
- `a`, `a1`, `a2` denote lvalues of type `X`,
|
| 546 |
+
- `u` denotes the name of a variable being declared,
|
| 547 |
+
- `b` denotes a value of type `Y`,
|
| 548 |
+
- `c` denotes a pointer of type `C*` through which indirection is valid,
|
| 549 |
+
- `p` denotes a value of type `XX::pointer` obtained by calling
|
| 550 |
+
`a1.allocate`, where `a1 == a`,
|
| 551 |
+
- `q` denotes a value of type `XX::const_pointer` obtained by conversion
|
| 552 |
+
from a value `p`,
|
| 553 |
+
- `r` denotes a value of type `T&` obtained by the expression `*p`,
|
| 554 |
+
- `w` denotes a value of type `XX::void_pointer` obtained by conversion
|
| 555 |
+
from a value `p`,
|
| 556 |
+
- `x` denotes a value of type `XX::const_void_pointer` obtained by
|
| 557 |
+
conversion from a value `q` or a value `w`,
|
| 558 |
+
- `y` denotes a value of type `XX::const_void_pointer` obtained by
|
| 559 |
+
conversion from a result value of `YY::allocate`, or else a value of
|
| 560 |
+
type (possibly const) `std::nullptr_t`,
|
| 561 |
+
- `n` denotes a value of type `XX::size_type`,
|
| 562 |
+
- `Args` denotes a template parameter pack, and
|
| 563 |
+
- `args` denotes a function parameter pack with the pattern `Args&&`.
|
| 564 |
+
|
| 565 |
The class template `allocator_traits` [[allocator.traits]] supplies a
|
| 566 |
+
uniform interface to all allocator types. This subclause describes the
|
| 567 |
+
requirements on allocator types and thus on types used to instantiate
|
| 568 |
+
`allocator_traits`. A requirement is optional if a default for a given
|
| 569 |
+
type or expression is specified. Within the standard library
|
| 570 |
+
`allocator_traits` template, an optional requirement that is not
|
| 571 |
+
supplied by an allocator is replaced by the specified default type or
|
| 572 |
+
expression.
|
| 573 |
+
|
| 574 |
+
[*Note 1*: There are no program-defined specializations of
|
| 575 |
+
`allocator_traits`. — *end note*]
|
| 576 |
+
|
| 577 |
+
``` cpp
|
| 578 |
+
typename X::pointer
|
| 579 |
+
```
|
| 580 |
+
|
| 581 |
+
*Remarks:* Default: `T*`
|
| 582 |
+
|
| 583 |
+
``` cpp
|
| 584 |
+
typename X::const_pointer
|
| 585 |
+
```
|
| 586 |
+
|
| 587 |
+
*Mandates:* `XX::pointer` is convertible to `XX::const_pointer`.
|
| 588 |
+
|
| 589 |
+
*Remarks:* Default: `pointer_traits<XX::pointer>::rebind<const T>`
|
| 590 |
+
|
| 591 |
+
``` cpp
|
| 592 |
+
typename X::void_pointer
|
| 593 |
+
typename Y::void_pointer
|
| 594 |
+
```
|
| 595 |
+
|
| 596 |
+
*Mandates:* `XX::pointer` is convertible to `XX::void_pointer`.
|
| 597 |
+
`XX::void_pointer` and `YY::void_pointer` are the same type.
|
| 598 |
+
|
| 599 |
+
*Remarks:* Default: `pointer_traits<XX::pointer>::rebind<void>`
|
| 600 |
+
|
| 601 |
+
``` cpp
|
| 602 |
+
typename X::const_void_pointer
|
| 603 |
+
typename Y::const_void_pointer
|
| 604 |
+
```
|
| 605 |
+
|
| 606 |
+
*Mandates:* `XX::pointer`, `XX::const_pointer`, and `XX::void_pointer`
|
| 607 |
+
are convertible to `XX::const_void_pointer`. `XX::const_void_pointer`
|
| 608 |
+
and `YY::const_void_pointer` are the same type.
|
| 609 |
+
|
| 610 |
+
*Remarks:* Default: `pointer_traits<XX::pointer>::rebind<const void>`
|
| 611 |
+
|
| 612 |
+
``` cpp
|
| 613 |
+
typename X::value_type
|
| 614 |
+
```
|
| 615 |
+
|
| 616 |
+
*Result:* Identical to `T`.
|
| 617 |
+
|
| 618 |
+
``` cpp
|
| 619 |
+
typename X::size_type
|
| 620 |
+
```
|
| 621 |
+
|
| 622 |
+
*Result:* An unsigned integer type that can represent the size of the
|
| 623 |
+
largest object in the allocation model.
|
| 624 |
+
|
| 625 |
+
*Remarks:* Default: `make_unsigned_t<XX::difference_type>`
|
| 626 |
+
|
| 627 |
+
``` cpp
|
| 628 |
+
typename X::difference_type
|
| 629 |
+
```
|
| 630 |
+
|
| 631 |
+
*Result:* A signed integer type that can represent the difference
|
| 632 |
+
between any two pointers in the allocation model.
|
| 633 |
+
|
| 634 |
+
*Remarks:* Default: `pointer_traits<XX::pointer>::difference_type`
|
| 635 |
+
|
| 636 |
+
``` cpp
|
| 637 |
+
typename X::template rebind<U>::other
|
| 638 |
+
```
|
| 639 |
+
|
| 640 |
+
*Result:* `Y`
|
| 641 |
+
|
| 642 |
+
*Ensures:* For all `U` (including `T`), `YY::rebind_alloc<T>` is `X`.
|
| 643 |
+
|
| 644 |
+
*Remarks:* If `Allocator` is a class template instantiation of the form
|
| 645 |
`SomeAllocator<T, Args>`, where `Args` is zero or more type arguments,
|
| 646 |
and `Allocator` does not supply a `rebind` member template, the standard
|
| 647 |
`allocator_traits` template uses `SomeAllocator<U, Args>` in place of
|
| 648 |
+
`Allocator::rebind<U>::other` by default. For allocator types that are
|
| 649 |
not template instantiations of the above form, no default is provided.
|
| 650 |
|
| 651 |
+
[*Note 1*: The member class template `rebind` of `X` is effectively a
|
| 652 |
+
typedef template. In general, if the name `Allocator` is bound to
|
| 653 |
+
`SomeAllocator<T>`, then `Allocator::rebind<U>::other` is the same type
|
| 654 |
+
as `SomeAllocator<U>`, where `SomeAllocator<T>::value_type` is `T` and
|
| 655 |
+
`SomeAllocator<U>::value_type` is `U`. — *end note*]
|
| 656 |
+
|
| 657 |
+
``` cpp
|
| 658 |
+
*p
|
| 659 |
+
```
|
| 660 |
+
|
| 661 |
+
*Result:* `T&`
|
| 662 |
+
|
| 663 |
+
``` cpp
|
| 664 |
+
*q
|
| 665 |
+
```
|
| 666 |
+
|
| 667 |
+
*Result:* `const T&`
|
| 668 |
+
|
| 669 |
+
*Ensures:* `*q` refers to the same object as `*p`.
|
| 670 |
+
|
| 671 |
+
``` cpp
|
| 672 |
+
p->m
|
| 673 |
+
```
|
| 674 |
+
|
| 675 |
+
*Result:* Type of `T::m`.
|
| 676 |
+
|
| 677 |
+
*Preconditions:* `(*p).m` is well-defined.
|
| 678 |
+
|
| 679 |
+
*Effects:* Equivalent to `(*p).m`.
|
| 680 |
+
|
| 681 |
+
``` cpp
|
| 682 |
+
q->m
|
| 683 |
+
```
|
| 684 |
+
|
| 685 |
+
*Result:* Type of `T::m`.
|
| 686 |
+
|
| 687 |
+
*Preconditions:* `(*q).m` is well-defined.
|
| 688 |
+
|
| 689 |
+
*Effects:* Equivalent to `(*q).m`.
|
| 690 |
+
|
| 691 |
+
``` cpp
|
| 692 |
+
static_cast<XX::pointer>(w)
|
| 693 |
+
```
|
| 694 |
+
|
| 695 |
+
*Result:* `XX::pointer`
|
| 696 |
+
|
| 697 |
+
*Ensures:* `static_cast<XX::pointer>(w) == p`.
|
| 698 |
+
|
| 699 |
+
``` cpp
|
| 700 |
+
static_cast<XX::const_pointer>(x)
|
| 701 |
+
```
|
| 702 |
+
|
| 703 |
+
*Result:* `XX::const_pointer`
|
| 704 |
+
|
| 705 |
+
*Ensures:* `static_cast<XX::const_pointer>(x) == q`.
|
| 706 |
+
|
| 707 |
+
``` cpp
|
| 708 |
+
pointer_traits<XX::pointer>::pointer_to(r)
|
| 709 |
+
```
|
| 710 |
+
|
| 711 |
+
*Result:* `XX::pointer`
|
| 712 |
+
|
| 713 |
+
*Ensures:* Same as `p`.
|
| 714 |
+
|
| 715 |
+
``` cpp
|
| 716 |
+
a.allocate(n)
|
| 717 |
+
```
|
| 718 |
+
|
| 719 |
+
*Result:* `XX::pointer`
|
| 720 |
+
|
| 721 |
+
*Effects:* Memory is allocated for an array of `n` `T` and such an
|
| 722 |
+
object is created but array elements are not constructed.
|
| 723 |
+
|
| 724 |
+
[*Example 1*: When reusing storage denoted by some pointer value `p`,
|
| 725 |
+
`launder(reinterpret_cast<T*>(new (p) byte[n * sizeof(T)]))` can be used
|
| 726 |
+
to implicitly create a suitable array object and obtain a pointer to
|
| 727 |
+
it. — *end example*]
|
| 728 |
+
|
| 729 |
+
*Throws:* `allocate` may throw an appropriate exception.
|
| 730 |
+
|
| 731 |
+
[*Note 2*: It is intended that `a.allocate` be an efficient means of
|
| 732 |
+
allocating a single object of type `T`, even when `sizeof(T)` is small.
|
| 733 |
+
That is, there is no need for a container to maintain its own free
|
| 734 |
+
list. — *end note*]
|
| 735 |
+
|
| 736 |
+
*Remarks:* If `n == 0`, the return value is unspecified.
|
| 737 |
+
|
| 738 |
+
``` cpp
|
| 739 |
+
a.allocate(n, y)
|
| 740 |
+
```
|
| 741 |
+
|
| 742 |
+
*Result:* `XX::pointer`
|
| 743 |
+
|
| 744 |
+
*Effects:* Same as `a.allocate(n)`. The use of `y` is unspecified, but
|
| 745 |
+
it is intended as an aid to locality.
|
| 746 |
+
|
| 747 |
+
*Remarks:* Default: `a.allocate(n)`
|
| 748 |
+
|
| 749 |
+
``` cpp
|
| 750 |
+
a.allocate_at_least(n)
|
| 751 |
+
```
|
| 752 |
+
|
| 753 |
+
*Result:* `allocation_result<XX::pointer, XX::size_type>`
|
| 754 |
+
|
| 755 |
+
*Returns:* `allocation_result<XX::pointer, XX::size_type>{ptr, count}`
|
| 756 |
+
where `ptr` is memory allocated for an array of `count` `T` and such an
|
| 757 |
+
object is created but array elements are not constructed, such that
|
| 758 |
+
`count` ≥ `n`. If `n == 0`, the return value is unspecified.
|
| 759 |
+
|
| 760 |
+
*Throws:* `allocate_at_least` may throw an appropriate exception.
|
| 761 |
+
|
| 762 |
+
*Remarks:* Default: `{a.allocate(n), n}`.
|
| 763 |
+
|
| 764 |
+
``` cpp
|
| 765 |
+
a.deallocate(p, n)
|
| 766 |
+
```
|
| 767 |
+
|
| 768 |
+
*Result:* (not used)
|
| 769 |
+
|
| 770 |
+
*Preconditions:*
|
| 771 |
+
|
| 772 |
+
- If `p` is memory that was obtained by a call to `a.allocate_at_least`,
|
| 773 |
+
let `ret` be the value returned and `req` be the value passed as the
|
| 774 |
+
first argument of that call. `p` is equal to `ret.ptr` and `n` is a
|
| 775 |
+
value such that `req` ≤ `n` ≤ `ret.count`.
|
| 776 |
+
- Otherwise, `p` is a pointer value obtained from `allocate`. `n` equals
|
| 777 |
+
the value passed as the first argument to the invocation of `allocate`
|
| 778 |
+
which returned `p`.
|
| 779 |
+
|
| 780 |
+
`p` has not been invalidated by an intervening call to `deallocate`.
|
| 781 |
+
|
| 782 |
+
*Throws:* Nothing.
|
| 783 |
+
|
| 784 |
+
``` cpp
|
| 785 |
+
a.max_size()
|
| 786 |
+
```
|
| 787 |
+
|
| 788 |
+
*Result:* `XX::size_type`
|
| 789 |
+
|
| 790 |
+
*Returns:* The largest value `n` that can meaningfully be passed to
|
| 791 |
+
`a.allocate(n)`.
|
| 792 |
+
|
| 793 |
+
*Remarks:* Default:
|
| 794 |
+
`numeric_limits<size_type>::max() / sizeof(value_type)`
|
| 795 |
+
|
| 796 |
+
``` cpp
|
| 797 |
+
a1 == a2
|
| 798 |
+
```
|
| 799 |
+
|
| 800 |
+
*Result:* `bool`
|
| 801 |
+
|
| 802 |
+
*Returns:* `true` only if storage allocated from each can be deallocated
|
| 803 |
+
via the other.
|
| 804 |
+
|
| 805 |
+
*Throws:* Nothing.
|
| 806 |
+
|
| 807 |
+
*Remarks:* `operator==` shall be reflexive, symmetric, and transitive.
|
| 808 |
+
|
| 809 |
+
``` cpp
|
| 810 |
+
a1 != a2
|
| 811 |
+
```
|
| 812 |
+
|
| 813 |
+
*Result:* `bool`
|
| 814 |
+
|
| 815 |
+
*Returns:* `!(a1 == a2)`.
|
| 816 |
+
|
| 817 |
+
``` cpp
|
| 818 |
+
a == b
|
| 819 |
+
```
|
| 820 |
+
|
| 821 |
+
*Result:* `bool`
|
| 822 |
+
|
| 823 |
+
*Returns:* `a == YY::rebind_alloc<T>(b)`.
|
| 824 |
+
|
| 825 |
+
``` cpp
|
| 826 |
+
a != b
|
| 827 |
+
```
|
| 828 |
+
|
| 829 |
+
*Result:* `bool`
|
| 830 |
+
|
| 831 |
+
*Returns:* `!(a == b)`.
|
| 832 |
+
|
| 833 |
+
``` cpp
|
| 834 |
+
X u(a);
|
| 835 |
+
X u = a;
|
| 836 |
+
```
|
| 837 |
+
|
| 838 |
+
*Ensures:* `u == a`
|
| 839 |
+
|
| 840 |
+
*Throws:* Nothing.
|
| 841 |
+
|
| 842 |
+
``` cpp
|
| 843 |
+
X u(b);
|
| 844 |
+
```
|
| 845 |
+
|
| 846 |
+
*Ensures:* `Y(u) == b` and `u == X(b)`.
|
| 847 |
+
|
| 848 |
+
*Throws:* Nothing.
|
| 849 |
+
|
| 850 |
+
``` cpp
|
| 851 |
+
X u(std::move(a));
|
| 852 |
+
X u = std::move(a);
|
| 853 |
+
```
|
| 854 |
+
|
| 855 |
+
*Ensures:* The value of `a` is unchanged and is equal to `u`.
|
| 856 |
+
|
| 857 |
+
*Throws:* Nothing.
|
| 858 |
+
|
| 859 |
+
``` cpp
|
| 860 |
+
X u(std::move(b));
|
| 861 |
+
```
|
| 862 |
+
|
| 863 |
+
*Ensures:* `u` is equal to the prior value of `X(b)`.
|
| 864 |
+
|
| 865 |
+
*Throws:* Nothing.
|
| 866 |
+
|
| 867 |
+
``` cpp
|
| 868 |
+
a.construct(c, args)
|
| 869 |
+
```
|
| 870 |
+
|
| 871 |
+
*Result:* (not used)
|
| 872 |
+
|
| 873 |
+
*Effects:* Constructs an object of type `C` at `c`.
|
| 874 |
+
|
| 875 |
+
*Remarks:* Default: `construct_at(c, std::forward<Args>(args)...)`
|
| 876 |
+
|
| 877 |
+
``` cpp
|
| 878 |
+
a.destroy(c)
|
| 879 |
+
```
|
| 880 |
+
|
| 881 |
+
*Result:* (not used)
|
| 882 |
+
|
| 883 |
+
*Effects:* Destroys the object at `c`.
|
| 884 |
+
|
| 885 |
+
*Remarks:* Default: `destroy_at(c)`
|
| 886 |
+
|
| 887 |
+
``` cpp
|
| 888 |
+
a.select_on_container_copy_construction()
|
| 889 |
+
```
|
| 890 |
+
|
| 891 |
+
*Result:* `X`
|
| 892 |
+
|
| 893 |
+
*Returns:* Typically returns either `a` or `X()`.
|
| 894 |
+
|
| 895 |
+
*Remarks:* Default: `return a;`
|
| 896 |
+
|
| 897 |
+
``` cpp
|
| 898 |
+
typename X::propagate_on_container_copy_assignment
|
| 899 |
+
```
|
| 900 |
+
|
| 901 |
+
*Result:* Identical to or derived from `true_type` or `false_type`.
|
| 902 |
+
|
| 903 |
+
*Returns:* `true_type` only if an allocator of type `X` should be copied
|
| 904 |
+
when the client container is copy-assigned; if so, `X` shall meet the
|
| 905 |
+
*Cpp17CopyAssignable* requirements ([[cpp17.copyassignable]]) and the
|
| 906 |
+
copy operation shall not throw exceptions.
|
| 907 |
+
|
| 908 |
+
*Remarks:* Default: `false_type`
|
| 909 |
+
|
| 910 |
+
``` cpp
|
| 911 |
+
typename X::propagate_on_container_move_assignment
|
| 912 |
+
```
|
| 913 |
+
|
| 914 |
+
*Result:* Identical to or derived from `true_type` or `false_type`.
|
| 915 |
+
|
| 916 |
+
*Returns:* `true_type` only if an allocator of type `X` should be moved
|
| 917 |
+
when the client container is move-assigned; if so, `X` shall meet the
|
| 918 |
+
*Cpp17MoveAssignable* requirements ([[cpp17.moveassignable]]) and the
|
| 919 |
+
move operation shall not throw exceptions.
|
| 920 |
+
|
| 921 |
+
*Remarks:* Default: `false_type`
|
| 922 |
+
|
| 923 |
+
``` cpp
|
| 924 |
+
typename X::propagate_on_container_swap
|
| 925 |
+
```
|
| 926 |
+
|
| 927 |
+
*Result:* Identical to or derived from `true_type` or `false_type`.
|
| 928 |
+
|
| 929 |
+
*Returns:* `true_type` only if an allocator of type `X` should be
|
| 930 |
+
swapped when the client container is swapped; if so, `X` shall meet the
|
| 931 |
+
*Cpp17Swappable* requirements [[swappable.requirements]] and the `swap`
|
| 932 |
+
operation shall not throw exceptions.
|
| 933 |
+
|
| 934 |
+
*Remarks:* Default: `false_type`
|
| 935 |
+
|
| 936 |
+
``` cpp
|
| 937 |
+
typename X::is_always_equal
|
| 938 |
+
```
|
| 939 |
+
|
| 940 |
+
*Result:* Identical to or derived from `true_type` or `false_type`.
|
| 941 |
+
|
| 942 |
+
*Returns:* `true_type` only if the expression `a1 == a2` is guaranteed
|
| 943 |
+
to be `true` for any two (possibly const) values `a1`, `a2` of type `X`.
|
| 944 |
+
|
| 945 |
+
*Remarks:* Default: `is_empty<X>::type`
|
| 946 |
|
| 947 |
An allocator type `X` shall meet the *Cpp17CopyConstructible*
|
| 948 |
+
requirements ([[cpp17.copyconstructible]]). The `XX::pointer`,
|
| 949 |
+
`XX::const_pointer`, `XX::void_pointer`, and `XX::const_void_pointer`
|
| 950 |
+
types shall meet the *Cpp17NullablePointer* requirements (
|
| 951 |
+
[[cpp17.nullablepointer]]). No constructor, comparison operator
|
| 952 |
+
function, copy operation, move operation, or swap operation on these
|
| 953 |
+
pointer types shall exit via an exception. `XX::pointer` and
|
| 954 |
+
`XX::const_pointer` shall also meet the requirements for a
|
| 955 |
+
*Cpp17RandomAccessIterator* [[random.access.iterators]] and the
|
| 956 |
+
additional requirement that, when `p` and `(p + n)` are dereferenceable
|
| 957 |
+
pointer values for some integral value `n`,
|
| 958 |
|
| 959 |
``` cpp
|
| 960 |
+
addressof(*(p + n)) == addressof(*p) + n
|
| 961 |
```
|
| 962 |
|
| 963 |
is `true`.
|
| 964 |
|
| 965 |
Let `x1` and `x2` denote objects of (possibly different) types
|
| 966 |
+
`XX::void_pointer`, `XX::const_void_pointer`, `XX::pointer`, or
|
| 967 |
+
`XX::const_pointer`. Then, `x1` and `x2` are *equivalently-valued*
|
| 968 |
pointer values, if and only if both `x1` and `x2` can be explicitly
|
| 969 |
converted to the two corresponding objects `px1` and `px2` of type
|
| 970 |
+
`XX::const_pointer`, using a sequence of `static_cast`s using only these
|
| 971 |
four types, and the expression `px1 == px2` evaluates to `true`.
|
| 972 |
|
| 973 |
+
Let `w1` and `w2` denote objects of type `XX::void_pointer`. Then for
|
| 974 |
+
the expressions
|
| 975 |
|
| 976 |
``` cpp
|
| 977 |
w1 == w2
|
| 978 |
w1 != w2
|
| 979 |
```
|
| 980 |
|
| 981 |
either or both objects may be replaced by an equivalently-valued object
|
| 982 |
+
of type `XX::const_void_pointer` with no change in semantics.
|
| 983 |
|
| 984 |
+
Let `p1` and `p2` denote objects of type `XX::pointer`. Then for the
|
| 985 |
expressions
|
| 986 |
|
| 987 |
``` cpp
|
| 988 |
p1 == p2
|
| 989 |
p1 != p2
|
|
|
|
| 993 |
p1 > p2
|
| 994 |
p1 - p2
|
| 995 |
```
|
| 996 |
|
| 997 |
either or both objects may be replaced by an equivalently-valued object
|
| 998 |
+
of type `XX::const_pointer` with no change in semantics.
|
| 999 |
|
| 1000 |
An allocator may constrain the types on which it can be instantiated and
|
| 1001 |
the arguments for which its `construct` or `destroy` members may be
|
| 1002 |
called. If a type cannot be used with a particular allocator, the
|
| 1003 |
allocator class or the call to `construct` or `destroy` may fail to
|
|
|
|
| 1006 |
If the alignment associated with a specific over-aligned type is not
|
| 1007 |
supported by an allocator, instantiation of the allocator for that type
|
| 1008 |
may fail. The allocator also may silently ignore the requested
|
| 1009 |
alignment.
|
| 1010 |
|
| 1011 |
+
[*Note 2*: Additionally, the member function `allocate` for that type
|
| 1012 |
+
can fail by throwing an object of type `bad_alloc`. — *end note*]
|
| 1013 |
|
| 1014 |
[*Example 1*:
|
| 1015 |
|
| 1016 |
The following is an allocator class template supporting the minimal
|
| 1017 |
+
interface that meets the requirements of
|
| 1018 |
+
[[allocator.requirements.general]]:
|
| 1019 |
|
| 1020 |
``` cpp
|
| 1021 |
+
template<class T>
|
| 1022 |
struct SimpleAllocator {
|
| 1023 |
+
using value_type = T;
|
| 1024 |
SimpleAllocator(ctor args);
|
| 1025 |
|
| 1026 |
+
template<class U> SimpleAllocator(const SimpleAllocator<U>& other);
|
| 1027 |
|
| 1028 |
+
T* allocate(std::size_t n);
|
| 1029 |
+
void deallocate(T* p, std::size_t n);
|
| 1030 |
+
|
| 1031 |
+
template<class U> bool operator==(const SimpleAllocator<U>& rhs) const;
|
| 1032 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1033 |
```
|
| 1034 |
|
| 1035 |
— *end example*]
|
| 1036 |
|
| 1037 |
##### Allocator completeness requirements <a id="allocator.requirements.completeness">[[allocator.requirements.completeness]]</a>
|
|
|
|
| 1074 |
The behavior of a C++ program is undefined if it declares an explicit or
|
| 1075 |
partial specialization of any standard library variable template, except
|
| 1076 |
where explicitly permitted by the specification of that variable
|
| 1077 |
template.
|
| 1078 |
|
| 1079 |
+
[*Note 1*: The requirements on an explicit or partial specialization
|
| 1080 |
+
are stated by each variable template that grants such
|
| 1081 |
+
permission. — *end note*]
|
| 1082 |
+
|
| 1083 |
The behavior of a C++ program is undefined if it declares
|
| 1084 |
|
| 1085 |
- an explicit specialization of any member function of a standard
|
| 1086 |
library class template, or
|
| 1087 |
- an explicit specialization of any member function template of a
|
|
|
|
| 1100 |
standard library function template. Unless `F` is designated an
|
| 1101 |
*addressable function*, the behavior of a C++ program is unspecified
|
| 1102 |
(possibly ill-formed) if it explicitly or implicitly attempts to form a
|
| 1103 |
pointer to `F`.
|
| 1104 |
|
| 1105 |
+
[*Note 2*: Possible means of forming such pointers include application
|
| 1106 |
of the unary `&` operator [[expr.unary.op]], `addressof`
|
| 1107 |
[[specialized.addressof]], or a function-to-pointer standard conversion
|
| 1108 |
[[conv.func]]. — *end note*]
|
| 1109 |
|
| 1110 |
Moreover, the behavior of a C++ program is unspecified (possibly
|
| 1111 |
ill-formed) if it attempts to form a reference to `F` or if it attempts
|
| 1112 |
to form a pointer-to-member designating either a standard library
|
| 1113 |
non-static member function [[member.functions]] or an instantiation of a
|
| 1114 |
standard library member function template.
|
| 1115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1116 |
A translation unit shall not declare namespace `std` to be an inline
|
| 1117 |
namespace [[namespace.def]].
|
| 1118 |
|
| 1119 |
##### Namespace `posix` <a id="namespace.posix">[[namespace.posix]]</a>
|
| 1120 |
|
| 1121 |
The behavior of a C++ program is undefined if it adds declarations or
|
| 1122 |
definitions to namespace `posix` or to a namespace within namespace
|
| 1123 |
`posix` unless otherwise specified. The namespace `posix` is reserved
|
| 1124 |
+
for use by ISO/IEC/IEEE 9945 and other POSIX standards.
|
| 1125 |
|
| 1126 |
##### Namespaces for future standardization <a id="namespace.future">[[namespace.future]]</a>
|
| 1127 |
|
| 1128 |
Top-level namespaces whose *namespace-name* consists of `std` followed
|
| 1129 |
by one or more *digit*s [[lex.name]] are reserved for future
|
|
|
|
| 1133 |
[*Example 1*: The top-level namespace `std2` is reserved for use by
|
| 1134 |
future revisions of this International Standard. — *end example*]
|
| 1135 |
|
| 1136 |
#### Reserved names <a id="reserved.names">[[reserved.names]]</a>
|
| 1137 |
|
| 1138 |
+
##### General <a id="reserved.names.general">[[reserved.names.general]]</a>
|
| 1139 |
+
|
| 1140 |
The C++ standard library reserves the following kinds of names:
|
| 1141 |
|
| 1142 |
- macros
|
| 1143 |
- global names
|
| 1144 |
- names with external linkage
|
| 1145 |
|
| 1146 |
If a program declares or defines a name in a context where it is
|
| 1147 |
+
reserved, other than as explicitly allowed by [[library]], its behavior
|
| 1148 |
is undefined.
|
| 1149 |
|
| 1150 |
##### Zombie names <a id="zombie.names">[[zombie.names]]</a>
|
| 1151 |
|
| 1152 |
In namespace `std`, the following names are reserved for previous
|
|
|
|
| 1162 |
- `binder2nd`,
|
| 1163 |
- `const_mem_fun1_ref_t`,
|
| 1164 |
- `const_mem_fun1_t`,
|
| 1165 |
- `const_mem_fun_ref_t`,
|
| 1166 |
- `const_mem_fun_t`,
|
| 1167 |
+
- `declare_no_pointers`,
|
| 1168 |
+
- `declare_reachable`,
|
| 1169 |
+
- `get_pointer_safety`,
|
| 1170 |
- `get_temporary_buffer`,
|
| 1171 |
- `get_unexpected`,
|
| 1172 |
- `gets`,
|
| 1173 |
- `is_literal_type`,
|
| 1174 |
- `is_literal_type_v`,
|
|
|
|
| 1178 |
- `mem_fun_ref`,
|
| 1179 |
- `mem_fun_t`,
|
| 1180 |
- `mem_fun`,
|
| 1181 |
- `not1`,
|
| 1182 |
- `not2`,
|
| 1183 |
+
- `pointer_safety`,
|
| 1184 |
- `pointer_to_binary_function`,
|
| 1185 |
- `pointer_to_unary_function`,
|
| 1186 |
- `ptr_fun`,
|
| 1187 |
- `random_shuffle`,
|
| 1188 |
- `raw_storage_iterator`,
|
|
|
|
| 1191 |
- `return_temporary_buffer`,
|
| 1192 |
- `set_unexpected`,
|
| 1193 |
- `unary_function`,
|
| 1194 |
- `unary_negate`,
|
| 1195 |
- `uncaught_exception`,
|
| 1196 |
+
- `undeclare_no_pointers`,
|
| 1197 |
+
- `undeclare_reachable`, and
|
| 1198 |
- `unexpected_handler`.
|
| 1199 |
|
| 1200 |
+
The following names are reserved as members for previous
|
| 1201 |
standardization, and may not be used as a name for object-like macros in
|
| 1202 |
portable code:
|
| 1203 |
|
| 1204 |
- `argument_type`,
|
| 1205 |
- `first_argument_type`,
|
| 1206 |
- `io_state`,
|
| 1207 |
- `open_mode`,
|
| 1208 |
+
- `preferred`,
|
| 1209 |
+
- `second_argument_type`,
|
| 1210 |
+
- `seek_dir`, and.
|
| 1211 |
+
- `strict`.
|
| 1212 |
|
| 1213 |
The name `stossc` is reserved as a member function for previous
|
| 1214 |
standardization, and may not be used as a name for function-like macros
|
| 1215 |
in portable code.
|
| 1216 |
|
|
|
|
| 1230 |
|
| 1231 |
##### External linkage <a id="extern.names">[[extern.names]]</a>
|
| 1232 |
|
| 1233 |
Each name declared as an object with external linkage in a header is
|
| 1234 |
reserved to the implementation to designate that library object with
|
| 1235 |
+
external linkage, [^22]
|
| 1236 |
+
|
| 1237 |
+
both in namespace `std` and in the global namespace.
|
| 1238 |
|
| 1239 |
Each global function signature declared with external linkage in a
|
| 1240 |
header is reserved to the implementation to designate that function
|
| 1241 |
+
signature with external linkage.[^23]
|
| 1242 |
|
| 1243 |
Each name from the C standard library declared with external linkage is
|
| 1244 |
reserved to the implementation for use as a name with `extern "C"`
|
| 1245 |
linkage, both in namespace `std` and in the global namespace.
|
| 1246 |
|
| 1247 |
Each function signature from the C standard library declared with
|
| 1248 |
external linkage is reserved to the implementation for use as a function
|
| 1249 |
+
signature with both `extern "C"` and `extern "C++"` linkage,[^24]
|
| 1250 |
+
|
| 1251 |
+
or as a name of namespace scope in the global namespace.
|
| 1252 |
|
| 1253 |
##### Types <a id="extern.types">[[extern.types]]</a>
|
| 1254 |
|
| 1255 |
For each type `T` from the C standard library, the types `::T` and
|
| 1256 |
`std::T` are reserved to the implementation and, when defined, `::T`
|
| 1257 |
shall be identical to `std::T`.
|
| 1258 |
|
| 1259 |
##### User-defined literal suffixes <a id="usrlit.suffix">[[usrlit.suffix]]</a>
|
| 1260 |
|
| 1261 |
Literal suffix identifiers [[over.literal]] that do not start with an
|
| 1262 |
+
underscore are reserved for future standardization. Literal suffix
|
| 1263 |
+
identifiers that contain a double underscore `__` are reserved for use
|
| 1264 |
+
by C++ implementations.
|
| 1265 |
|
| 1266 |
#### Headers <a id="alt.headers">[[alt.headers]]</a>
|
| 1267 |
|
| 1268 |
If a file with a name equivalent to the derived file name for one of the
|
| 1269 |
C++ standard library headers is not provided as part of the
|
|
|
|
| 1280 |
#### Replacement functions <a id="replacement.functions">[[replacement.functions]]</a>
|
| 1281 |
|
| 1282 |
[[support]] through [[thread]] and [[depr]] describe the behavior of
|
| 1283 |
numerous functions defined by the C++ standard library. Under some
|
| 1284 |
circumstances, however, certain of these function descriptions also
|
| 1285 |
+
apply to replacement functions defined in the program.
|
| 1286 |
|
| 1287 |
A C++ program may provide the definition for any of the following
|
| 1288 |
+
dynamic memory allocation function signatures declared in header `<new>`
|
| 1289 |
+
[[basic.stc.dynamic]], [[new.syn]]:
|
| 1290 |
|
| 1291 |
``` cpp
|
| 1292 |
operator new(std::size_t)
|
| 1293 |
operator new(std::size_t, std::align_val_t)
|
| 1294 |
operator new(std::size_t, const std::nothrow_t&)
|
|
|
|
| 1320 |
operator delete[](void*, std::align_val_t, const std::nothrow_t&)
|
| 1321 |
```
|
| 1322 |
|
| 1323 |
The program’s definitions are used instead of the default versions
|
| 1324 |
supplied by the implementation [[new.delete]]. Such replacement occurs
|
| 1325 |
+
prior to program startup [[basic.def.odr]], [[basic.start]]. The
|
| 1326 |
program’s declarations shall not be specified as `inline`. No diagnostic
|
| 1327 |
is required.
|
| 1328 |
|
| 1329 |
#### Handler functions <a id="handler.functions">[[handler.functions]]</a>
|
| 1330 |
|
|
|
|
| 1360 |
on types used to instantiate standard library template components), the
|
| 1361 |
C++ standard library depends on components supplied by a C++ program. If
|
| 1362 |
these components do not meet their requirements, this document places no
|
| 1363 |
requirements on the implementation.
|
| 1364 |
|
| 1365 |
+
In particular, the behavior is undefined in the following cases:
|
| 1366 |
|
| 1367 |
- For replacement functions [[new.delete]], if the installed replacement
|
| 1368 |
function does not implement the semantics of the applicable *Required
|
| 1369 |
behavior:* paragraph.
|
| 1370 |
+
- For handler functions [[new.handler]], [[terminate.handler]], if the
|
| 1371 |
+
installed handler function does not implement the semantics of the
|
| 1372 |
applicable *Required behavior:* paragraph.
|
| 1373 |
- For types used as template arguments when instantiating a template
|
| 1374 |
component, if the operations on the type do not implement the
|
| 1375 |
+
semantics of the applicable *Requirements* subclause
|
| 1376 |
+
[[allocator.requirements]], [[container.requirements]], [[iterator.requirements]], [[algorithms.requirements]], [[numeric.requirements]].
|
| 1377 |
+
Operations on such types can report a failure by throwing an exception
|
| 1378 |
+
unless otherwise specified.
|
|
|
|
| 1379 |
- If any replacement function or handler function or destructor
|
| 1380 |
operation exits via an exception, unless specifically allowed in the
|
| 1381 |
applicable *Required behavior:* paragraph.
|
| 1382 |
+
- If an incomplete type [[term.incomplete.type]] is used as a template
|
| 1383 |
+
argument when instantiating a template component or evaluating a
|
| 1384 |
+
concept, unless specifically allowed for that component.
|
| 1385 |
|
| 1386 |
#### Function arguments <a id="res.on.arguments">[[res.on.arguments]]</a>
|
| 1387 |
|
| 1388 |
Each of the following applies to all arguments to functions defined in
|
| 1389 |
the C++ standard library, unless explicitly stated otherwise.
|
|
|
|
| 1394 |
- If a function argument is described as being an array, the pointer
|
| 1395 |
actually passed to the function shall have a value such that all
|
| 1396 |
address computations and accesses to objects (that would be valid if
|
| 1397 |
the pointer did point to the first element of such an array) are in
|
| 1398 |
fact valid.
|
| 1399 |
+
- If a function argument is bound to an rvalue reference parameter, the
|
| 1400 |
implementation may assume that this parameter is a unique reference to
|
| 1401 |
+
this argument, except that the argument passed to a move-assignment
|
| 1402 |
+
operator may be a reference to `*this` [[lib.types.movedfrom]].
|
| 1403 |
+
\[*Note 1*: If the type of a parameter is a forwarding reference
|
| 1404 |
+
[[temp.deduct.call]] that is deduced to an lvalue reference type, then
|
| 1405 |
+
the argument is not bound to an rvalue reference. — *end note*]
|
| 1406 |
+
\[*Note 2*: If a program casts an lvalue to an xvalue while passing
|
| 1407 |
+
that lvalue to a library function (e.g., by calling the function with
|
| 1408 |
+
the argument `std::move(x)`), the program is effectively asking that
|
| 1409 |
+
function to treat that lvalue as a temporary object. The
|
| 1410 |
+
implementation is free to optimize away aliasing checks which would
|
| 1411 |
+
possibly be needed if the argument was an lvalue. — *end note*]
|
| 1412 |
|
| 1413 |
#### Library object access <a id="res.on.objects">[[res.on.objects]]</a>
|
| 1414 |
|
| 1415 |
The behavior of a program is undefined if calls to standard library
|
| 1416 |
functions from different threads may introduce a data race. The
|
|
|
|
| 1428 |
lifetime, the behavior is undefined unless otherwise specified.
|
| 1429 |
|
| 1430 |
[*Note 2*: This applies even to objects such as mutexes intended for
|
| 1431 |
thread synchronization. — *end note*]
|
| 1432 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1433 |
#### Semantic requirements <a id="res.on.requirements">[[res.on.requirements]]</a>
|
| 1434 |
|
| 1435 |
A sequence `Args` of template arguments is said to *model* a concept `C`
|
| 1436 |
if `Args` satisfies `C` [[temp.constr.decl]] and meets all semantic
|
| 1437 |
requirements (if any) given in the specification of `C`.
|
|
|
|
| 1468 |
|
| 1469 |
Certain types and macros are defined in more than one header. Every such
|
| 1470 |
entity shall be defined such that any header that defines it may be
|
| 1471 |
included after any other header that also defines it [[basic.def.odr]].
|
| 1472 |
|
| 1473 |
+
The C standard library headers [[support.c.headers]] shall include only
|
| 1474 |
their corresponding C++ standard library header, as described in
|
| 1475 |
[[headers]].
|
| 1476 |
|
| 1477 |
#### Restrictions on macro definitions <a id="res.on.macro.definitions">[[res.on.macro.definitions]]</a>
|
| 1478 |
|
|
|
|
| 1489 |
It is unspecified whether any non-member functions in the C++ standard
|
| 1490 |
library are defined as inline [[dcl.inline]].
|
| 1491 |
|
| 1492 |
A call to a non-member function signature described in [[support]]
|
| 1493 |
through [[thread]] and [[depr]] shall behave as if the implementation
|
| 1494 |
+
declared no additional non-member function signatures.[^25]
|
| 1495 |
|
| 1496 |
An implementation shall not declare a non-member function signature with
|
| 1497 |
additional default arguments.
|
| 1498 |
|
| 1499 |
Unless otherwise specified, calls made by functions in the standard
|
|
|
|
| 1528 |
an implementation may declare a different set of member function
|
| 1529 |
signatures, provided that any call to the member function that would
|
| 1530 |
select an overload from the set of declarations described in this
|
| 1531 |
document behaves as if that overload were selected.
|
| 1532 |
|
| 1533 |
+
[*Note 1*: For instance, an implementation can add parameters with
|
| 1534 |
default values, or replace a member function with default arguments with
|
| 1535 |
two or more member functions with equivalent behavior, or add additional
|
| 1536 |
signatures for a member function name. — *end note*]
|
| 1537 |
|
| 1538 |
#### Friend functions <a id="hidden.friends">[[hidden.friends]]</a>
|
|
|
|
| 1598 |
current thread unless the objects are accessed directly or indirectly
|
| 1599 |
via the function’s non-const arguments, including `this`.
|
| 1600 |
|
| 1601 |
[*Note 1*: This means, for example, that implementations can’t use an
|
| 1602 |
object with static storage duration for internal purposes without
|
| 1603 |
+
synchronization because doing so can cause a data race even in programs
|
| 1604 |
+
that do not explicitly share objects between threads. — *end note*]
|
| 1605 |
|
| 1606 |
A C++ standard library function shall not access objects indirectly
|
| 1607 |
accessible via its arguments or via elements of its container arguments
|
| 1608 |
except by invoking functions required by its specification on those
|
| 1609 |
container elements.
|
|
|
|
| 1647 |
In any case:
|
| 1648 |
|
| 1649 |
- Every base class described as `virtual` shall be virtual;
|
| 1650 |
- Every base class not specified as `virtual` shall not be virtual;
|
| 1651 |
- Unless explicitly stated otherwise, types with distinct names shall be
|
| 1652 |
+
distinct types. \[*Note 1*: There is an implicit exception to this
|
| 1653 |
+
rule for types that are described as synonyms
|
| 1654 |
+
[[dcl.typedef]], [[namespace.udecl]], such as `size_t`
|
| 1655 |
+
[[support.types]] and `streamoff` [[stream.types]]. — *end note*]
|
| 1656 |
|
| 1657 |
All types specified in the C++ standard library shall be non-`final`
|
| 1658 |
types unless otherwise specified.
|
| 1659 |
|
| 1660 |
#### Restrictions on exception handling <a id="res.on.exception.handling">[[res.on.exception.handling]]</a>
|
|
|
|
| 1663 |
failure by throwing an exception of a type described in its *Throws:*
|
| 1664 |
paragraph, or of a type derived from a type named in the *Throws:*
|
| 1665 |
paragraph that would be caught by an exception handler for the base
|
| 1666 |
type.
|
| 1667 |
|
| 1668 |
+
Functions from the C standard library shall not throw exceptions [^26]
|
| 1669 |
+
|
| 1670 |
except when such a function calls a program-supplied function that
|
| 1671 |
+
throws an exception.[^27]
|
| 1672 |
|
| 1673 |
Destructor operations defined in the C++ standard library shall not
|
| 1674 |
throw exceptions. Every destructor in the C++ standard library shall
|
| 1675 |
behave as if it had a non-throwing exception specification.
|
| 1676 |
|
| 1677 |
Functions defined in the C++ standard library that do not have a
|
| 1678 |
*Throws:* paragraph but do have a potentially-throwing exception
|
| 1679 |
+
specification may throw *implementation-defined* exceptions.[^28]
|
| 1680 |
+
|
| 1681 |
Implementations should report errors by throwing exceptions of or
|
| 1682 |
+
derived from the standard exception classes
|
| 1683 |
+
[[bad.alloc]], [[support.exception]], [[std.exceptions]].
|
| 1684 |
|
| 1685 |
An implementation may strengthen the exception specification for a
|
| 1686 |
non-virtual function by adding a non-throwing exception specification.
|
| 1687 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1688 |
#### Value of error codes <a id="value.error.codes">[[value.error.codes]]</a>
|
| 1689 |
|
| 1690 |
Certain functions in the C++ standard library report errors via a
|
| 1691 |
`std::error_code` [[syserr.errcode.overview]] object. That object’s
|
| 1692 |
`category()` member shall return `std::system_category()` for errors
|
|
|
|
| 1709 |
Objects of types defined in the C++ standard library may be moved from
|
| 1710 |
[[class.copy.ctor]]. Move operations may be explicitly specified or
|
| 1711 |
implicitly generated. Unless otherwise specified, such moved-from
|
| 1712 |
objects shall be placed in a valid but unspecified state.
|
| 1713 |
|
| 1714 |
+
An object of a type defined in the C++ standard library may be
|
| 1715 |
+
move-assigned [[class.copy.assign]] to itself. Unless otherwise
|
| 1716 |
+
specified, such an assignment places the object in a valid but
|
| 1717 |
+
unspecified state.
|
| 1718 |
+
|
| 1719 |
<!-- Link reference definitions -->
|
| 1720 |
[alg.c.library]: algorithms.md#alg.c.library
|
| 1721 |
[alg.sorting]: algorithms.md#alg.sorting
|
| 1722 |
[algorithm.stable]: #algorithm.stable
|
| 1723 |
[algorithms]: algorithms.md#algorithms
|
| 1724 |
[algorithms.requirements]: algorithms.md#algorithms.requirements
|
| 1725 |
[alloc.errors]: support.md#alloc.errors
|
|
|
|
| 1726 |
[allocator.requirements]: #allocator.requirements
|
| 1727 |
[allocator.requirements.completeness]: #allocator.requirements.completeness
|
| 1728 |
+
[allocator.requirements.general]: #allocator.requirements.general
|
| 1729 |
+
[allocator.traits]: mem.md#allocator.traits
|
| 1730 |
[alt.headers]: #alt.headers
|
| 1731 |
+
[array.creation]: containers.md#array.creation
|
| 1732 |
+
[atomics]: thread.md#atomics
|
|
|
|
| 1733 |
[bad.alloc]: support.md#bad.alloc
|
| 1734 |
[basic.def.odr]: basic.md#basic.def.odr
|
| 1735 |
[basic.fundamental]: basic.md#basic.fundamental
|
| 1736 |
[basic.life]: basic.md#basic.life
|
| 1737 |
[basic.link]: basic.md#basic.link
|
|
|
|
| 1739 |
[basic.lookup.qual]: basic.md#basic.lookup.qual
|
| 1740 |
[basic.lookup.unqual]: basic.md#basic.lookup.unqual
|
| 1741 |
[basic.scope.namespace]: basic.md#basic.scope.namespace
|
| 1742 |
[basic.start]: basic.md#basic.start
|
| 1743 |
[basic.stc.dynamic]: basic.md#basic.stc.dynamic
|
| 1744 |
+
[bit]: utilities.md#bit
|
|
|
|
|
|
|
| 1745 |
[bitmask.types]: #bitmask.types
|
| 1746 |
[byte.strings]: #byte.strings
|
| 1747 |
[c.annex.k.names]: #c.annex.k.names
|
| 1748 |
+
[cassert.syn]: diagnostics.md#cassert.syn
|
| 1749 |
+
[cerrno.syn]: diagnostics.md#cerrno.syn
|
| 1750 |
[character.seq]: #character.seq
|
| 1751 |
+
[character.seq.general]: #character.seq.general
|
| 1752 |
[class.copy.assign]: class.md#class.copy.assign
|
| 1753 |
[class.copy.ctor]: class.md#class.copy.ctor
|
| 1754 |
[class.dtor]: class.md#class.dtor
|
| 1755 |
[class.mem]: class.md#class.mem
|
|
|
|
|
|
|
| 1756 |
[class.virtual]: class.md#class.virtual
|
| 1757 |
+
[clocale.syn]: localization.md#clocale.syn
|
| 1758 |
[cmp]: support.md#cmp
|
| 1759 |
[compliance]: #compliance
|
| 1760 |
[concept.destructible]: concepts.md#concept.destructible
|
| 1761 |
[concept.invocable]: concepts.md#concept.invocable
|
| 1762 |
[concept.totallyordered]: concepts.md#concept.totallyordered
|
|
|
|
| 1772 |
[containers]: containers.md#containers
|
| 1773 |
[contents]: #contents
|
| 1774 |
[conv]: expr.md#conv
|
| 1775 |
[conv.func]: expr.md#conv.func
|
| 1776 |
[conventions]: #conventions
|
| 1777 |
+
[conventions.general]: #conventions.general
|
| 1778 |
[cpp.include]: cpp.md#cpp.include
|
| 1779 |
[cpp.replace]: cpp.md#cpp.replace
|
|
|
|
| 1780 |
[cpp17.copyassignable]: #cpp17.copyassignable
|
| 1781 |
[cpp17.copyconstructible]: #cpp17.copyconstructible
|
| 1782 |
[cpp17.destructible]: #cpp17.destructible
|
| 1783 |
[cpp17.hash]: #cpp17.hash
|
| 1784 |
[cpp17.moveassignable]: #cpp17.moveassignable
|
| 1785 |
[cpp17.nullablepointer]: #cpp17.nullablepointer
|
| 1786 |
+
[cstdarg.syn]: support.md#cstdarg.syn
|
| 1787 |
+
[cstddef.syn]: support.md#cstddef.syn
|
| 1788 |
+
[cstdint.syn]: support.md#cstdint.syn
|
| 1789 |
[customization.point.object]: #customization.point.object
|
| 1790 |
[dcl.array]: dcl.md#dcl.array
|
| 1791 |
[dcl.attr]: dcl.md#dcl.attr
|
| 1792 |
[dcl.constexpr]: dcl.md#dcl.constexpr
|
| 1793 |
[dcl.fct.default]: dcl.md#dcl.fct.default
|
| 1794 |
[dcl.init]: dcl.md#dcl.init
|
|
|
|
| 1795 |
[dcl.inline]: dcl.md#dcl.inline
|
| 1796 |
[dcl.link]: dcl.md#dcl.link
|
| 1797 |
[dcl.pre]: dcl.md#dcl.pre
|
| 1798 |
+
[dcl.typedef]: dcl.md#dcl.typedef
|
| 1799 |
+
[defns.nonconst.libcall]: intro.md#defns.nonconst.libcall
|
| 1800 |
[depr]: future.md#depr
|
|
|
|
| 1801 |
[derivation]: #derivation
|
| 1802 |
[derived.classes]: #derived.classes
|
| 1803 |
[description]: #description
|
| 1804 |
+
[description.general]: #description.general
|
| 1805 |
[diagnostics]: diagnostics.md#diagnostics
|
| 1806 |
[enumerated.types]: #enumerated.types
|
| 1807 |
[except]: except.md#except
|
| 1808 |
+
[expos.only.entity]: #expos.only.entity
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1809 |
[expr.delete]: expr.md#expr.delete
|
|
|
|
| 1810 |
[expr.new]: expr.md#expr.new
|
|
|
|
|
|
|
| 1811 |
[expr.unary.op]: expr.md#expr.unary.op
|
| 1812 |
[extern.names]: #extern.names
|
| 1813 |
[extern.types]: #extern.types
|
| 1814 |
+
[freestanding.item]: #freestanding.item
|
| 1815 |
[function.objects]: utilities.md#function.objects
|
| 1816 |
[functions.within.classes]: #functions.within.classes
|
| 1817 |
[global.functions]: #global.functions
|
| 1818 |
[handler.functions]: #handler.functions
|
| 1819 |
[hash.requirements]: #hash.requirements
|
|
|
|
| 1822 |
[headers.cpp.c]: #headers.cpp.c
|
| 1823 |
[headers.cpp.fs]: #headers.cpp.fs
|
| 1824 |
[hidden.friends]: #hidden.friends
|
| 1825 |
[input.output]: input.md#input.output
|
| 1826 |
[intro.compliance]: intro.md#intro.compliance
|
|
|
|
|
|
|
| 1827 |
[intro.multithread]: basic.md#intro.multithread
|
| 1828 |
[intro.refs]: intro.md#intro.refs
|
| 1829 |
[iterator.requirements]: iterators.md#iterator.requirements
|
| 1830 |
[iterators]: iterators.md#iterators
|
| 1831 |
+
[lex.charset]: lex.md#lex.charset
|
| 1832 |
[lex.name]: lex.md#lex.name
|
| 1833 |
[lex.name.special]: #lex.name.special
|
| 1834 |
[lex.phases]: lex.md#lex.phases
|
| 1835 |
[lex.separate]: lex.md#lex.separate
|
| 1836 |
[lib.types.movedfrom]: #lib.types.movedfrom
|
|
|
|
| 1839 |
[library.categories]: #library.categories
|
| 1840 |
[library.general]: #library.general
|
| 1841 |
[locales]: localization.md#locales
|
| 1842 |
[localization]: localization.md#localization
|
| 1843 |
[macro.names]: #macro.names
|
| 1844 |
+
[mem]: mem.md#mem
|
| 1845 |
[member.functions]: #member.functions
|
| 1846 |
+
[memory]: mem.md#memory
|
| 1847 |
+
[meta]: meta.md#meta
|
| 1848 |
[module.import]: module.md#module.import
|
| 1849 |
[multibyte.strings]: #multibyte.strings
|
| 1850 |
[namespace.constraints]: #namespace.constraints
|
| 1851 |
[namespace.def]: dcl.md#namespace.def
|
| 1852 |
[namespace.future]: #namespace.future
|
|
|
|
| 1859 |
[nullablepointer.requirements]: #nullablepointer.requirements
|
| 1860 |
[numeric.requirements]: numerics.md#numeric.requirements
|
| 1861 |
[numerics]: numerics.md#numerics
|
| 1862 |
[objects.within.classes]: #objects.within.classes
|
| 1863 |
[organization]: #organization
|
| 1864 |
+
[organization.general]: #organization.general
|
| 1865 |
[ostream.iterator.ops]: iterators.md#ostream.iterator.ops
|
| 1866 |
[over.literal]: over.md#over.literal
|
| 1867 |
[over.match]: over.md#over.match
|
| 1868 |
+
[over.match.oper]: over.md#over.match.oper
|
| 1869 |
[protection.within.classes]: #protection.within.classes
|
| 1870 |
[random.access.iterators]: iterators.md#random.access.iterators
|
| 1871 |
[ranges]: ranges.md#ranges
|
| 1872 |
+
[ratio]: meta.md#ratio
|
| 1873 |
[re]: re.md#re
|
| 1874 |
[reentrancy]: #reentrancy
|
| 1875 |
[replacement.functions]: #replacement.functions
|
| 1876 |
[requirements]: #requirements
|
| 1877 |
+
[requirements.general]: #requirements.general
|
| 1878 |
[res.on.arguments]: #res.on.arguments
|
| 1879 |
[res.on.data.races]: #res.on.data.races
|
| 1880 |
[res.on.exception.handling]: #res.on.exception.handling
|
|
|
|
| 1881 |
[res.on.functions]: #res.on.functions
|
| 1882 |
[res.on.headers]: #res.on.headers
|
| 1883 |
[res.on.macro.definitions]: #res.on.macro.definitions
|
| 1884 |
[res.on.objects]: #res.on.objects
|
|
|
|
| 1885 |
[res.on.requirements]: #res.on.requirements
|
| 1886 |
[reserved.names]: #reserved.names
|
| 1887 |
+
[reserved.names.general]: #reserved.names.general
|
| 1888 |
+
[specialized.addressof]: mem.md#specialized.addressof
|
| 1889 |
[std.exceptions]: diagnostics.md#std.exceptions
|
| 1890 |
+
[std.modules]: #std.modules
|
| 1891 |
[stmt.return]: stmt.md#stmt.return
|
| 1892 |
[stream.types]: input.md#stream.types
|
| 1893 |
[strings]: strings.md#strings
|
| 1894 |
[structure]: #structure
|
| 1895 |
[structure.elements]: #structure.elements
|
| 1896 |
[structure.requirements]: #structure.requirements
|
| 1897 |
[structure.see.also]: #structure.see.also
|
| 1898 |
[structure.specifications]: #structure.specifications
|
| 1899 |
[structure.summary]: #structure.summary
|
| 1900 |
[support]: support.md#support
|
| 1901 |
+
[support.c.headers]: support.md#support.c.headers
|
| 1902 |
+
[support.c.headers.other]: support.md#support.c.headers.other
|
| 1903 |
[support.coroutine]: support.md#support.coroutine
|
| 1904 |
[support.dynamic]: support.md#support.dynamic
|
| 1905 |
[support.exception]: support.md#support.exception
|
| 1906 |
[support.initlist]: support.md#support.initlist
|
| 1907 |
[support.limits]: support.md#support.limits
|
|
|
|
| 1911 |
[support.start.term]: support.md#support.start.term
|
| 1912 |
[support.types]: support.md#support.types
|
| 1913 |
[swappable.requirements]: #swappable.requirements
|
| 1914 |
[syserr]: diagnostics.md#syserr
|
| 1915 |
[syserr.errcode.overview]: diagnostics.md#syserr.errcode.overview
|
|
|
|
|
|
|
| 1916 |
[tab:cpp17.destructible]: #tab:cpp17.destructible
|
| 1917 |
[tab:cpp17.equalitycomparable]: #tab:cpp17.equalitycomparable
|
| 1918 |
[temp]: temp.md#temp
|
| 1919 |
[temp.concept]: temp.md#temp.concept
|
| 1920 |
[temp.constr.decl]: temp.md#temp.constr.decl
|
|
|
|
| 1921 |
[temp.deduct.call]: temp.md#temp.deduct.call
|
|
|
|
| 1922 |
[template.bitset]: utilities.md#template.bitset
|
| 1923 |
+
[term.incomplete.type]: basic.md#term.incomplete.type
|
| 1924 |
+
[term.object.type]: basic.md#term.object.type
|
| 1925 |
[terminate.handler]: support.md#terminate.handler
|
| 1926 |
[thread]: thread.md#thread
|
| 1927 |
[time]: time.md#time
|
| 1928 |
+
[tuple]: utilities.md#tuple
|
| 1929 |
[type.descriptions]: #type.descriptions
|
| 1930 |
[type.descriptions.general]: #type.descriptions.general
|
| 1931 |
+
[type.traits]: meta.md#type.traits
|
| 1932 |
[using]: #using
|
| 1933 |
[using.headers]: #using.headers
|
| 1934 |
[using.linkage]: #using.linkage
|
| 1935 |
[using.overview]: #using.overview
|
| 1936 |
[usrlit.suffix]: #usrlit.suffix
|
| 1937 |
[utilities]: utilities.md#utilities
|
| 1938 |
+
[utility]: utilities.md#utility
|
| 1939 |
[utility.arg.requirements]: #utility.arg.requirements
|
| 1940 |
[utility.requirements]: #utility.requirements
|
| 1941 |
+
[utility.requirements.general]: #utility.requirements.general
|
| 1942 |
[value.error.codes]: #value.error.codes
|
| 1943 |
[zombie.names]: #zombie.names
|
| 1944 |
|
| 1945 |
+
[^1]: See also ISO/IEC 9899:2018 section 7.6.
|
| 1946 |
+
|
| 1947 |
+
[^2]: To save space, items that do not apply to a Clause are omitted.
|
| 1948 |
For example, if a Clause does not specify any requirements, there
|
| 1949 |
will be no “Requirements” subclause.
|
| 1950 |
|
| 1951 |
+
[^3]: Although in some cases the code given is unambiguously the optimum
|
| 1952 |
implementation.
|
| 1953 |
|
| 1954 |
+
[^4]: To save space, items that do not apply to a class are omitted. For
|
| 1955 |
+
example, if a class does not specify any comparison operator
|
| 1956 |
+
functions, there will be no “Comparison operator functions”
|
| 1957 |
+
subclause.
|
| 1958 |
|
| 1959 |
+
[^5]: To save space, elements that do not apply to a function are
|
| 1960 |
omitted. For example, if a function specifies no preconditions,
|
| 1961 |
there will be no *Preconditions:* element.
|
| 1962 |
|
| 1963 |
+
[^6]: This simplifies the presentation of complexity requirements in
|
| 1964 |
some cases.
|
| 1965 |
|
| 1966 |
+
[^7]: Examples from [[utility.requirements]] include:
|
| 1967 |
*Cpp17EqualityComparable*, *Cpp17LessThanComparable*,
|
| 1968 |
*Cpp17CopyConstructible*. Examples from [[iterator.requirements]]
|
| 1969 |
include: *Cpp17InputIterator*, *Cpp17ForwardIterator*.
|
| 1970 |
|
| 1971 |
+
[^8]: Such as an integer type, with constant integer values
|
| 1972 |
[[basic.fundamental]].
|
| 1973 |
|
|
|
|
|
|
|
| 1974 |
[^9]: Many of the objects manipulated by function signatures declared in
|
| 1975 |
`<cstring>` are character sequences or NTBSs. The size of some of
|
| 1976 |
these character sequences is limited by a length value, maintained
|
| 1977 |
separately from the character sequence.
|
| 1978 |
|
| 1979 |
[^10]: A *string-literal*, such as `"abc"`, is a static NTBS.
|
| 1980 |
|
| 1981 |
+
[^11]: An NTBS that contains characters only from the basic literal
|
| 1982 |
character set is also an NTMBS. Each multibyte character then
|
| 1983 |
consists of a single byte.
|
| 1984 |
|
| 1985 |
+
[^12]: The C standard library headers [[support.c.headers]] also define
|
| 1986 |
names within the global namespace, while the C++ headers for C
|
| 1987 |
+
library facilities [[headers]] can also define names within the
|
| 1988 |
global namespace.
|
| 1989 |
|
| 1990 |
[^13]: This gives implementers freedom to use inline namespaces to
|
| 1991 |
support multiple configurations of the library.
|
| 1992 |
|
| 1993 |
[^14]: A header is not necessarily a source file, nor are the sequences
|
| 1994 |
delimited by `<` and `>` in header names necessarily valid source
|
| 1995 |
file names [[cpp.include]].
|
| 1996 |
|
| 1997 |
[^15]: It is intentional that there is no C++ header for any of these C
|
| 1998 |
+
headers: `<stdnoreturn.h>`, `<threads.h>`.
|
| 1999 |
|
| 2000 |
[^16]: This disallows the practice, allowed in C, of providing a masking
|
| 2001 |
macro in addition to the function prototype. The only way to achieve
|
| 2002 |
equivalent inline behavior in C++ is to provide a definition as an
|
| 2003 |
extern inline function.
|
|
|
|
| 2019 |
|
| 2020 |
[^21]: Any library code that instantiates other library templates must
|
| 2021 |
be prepared to work adequately with any user-supplied specialization
|
| 2022 |
that meets the minimum requirements of this document.
|
| 2023 |
|
| 2024 |
+
[^22]: The list of such reserved names includes `errno`, declared or
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2025 |
defined in `<cerrno>`.
|
| 2026 |
|
| 2027 |
+
[^23]: The list of such reserved function signatures with external
|
| 2028 |
linkage includes `setjmp(jmp_buf)`, declared or defined in
|
| 2029 |
`<csetjmp>`, and `va_end(va_list)`, declared or defined in
|
| 2030 |
`<cstdarg>`.
|
| 2031 |
|
| 2032 |
+
[^24]: The function signatures declared in `<cuchar>`, `<cwchar>`, and
|
| 2033 |
`<cwctype>` are always reserved, notwithstanding the restrictions
|
| 2034 |
imposed in subclause 4.5.1 of Amendment 1 to the C Standard for
|
| 2035 |
these headers.
|
| 2036 |
|
| 2037 |
+
[^25]: A valid C++ program always calls the expected library non-member
|
| 2038 |
+
function. An implementation can also define additional non-member
|
| 2039 |
functions that would otherwise not be called by a valid C++ program.
|
| 2040 |
|
| 2041 |
+
[^26]: That is, the C library functions can all be treated as if they
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2042 |
are marked `noexcept`. This allows implementations to make
|
| 2043 |
performance optimizations based on the absence of exceptions at
|
| 2044 |
runtime.
|
| 2045 |
|
| 2046 |
+
[^27]: The functions `qsort()` and `bsearch()` [[alg.c.library]] meet
|
| 2047 |
this condition.
|
| 2048 |
|
| 2049 |
+
[^28]: In particular, they can report a failure to allocate storage by
|
| 2050 |
throwing an exception of type `bad_alloc`, or a class derived from
|
| 2051 |
`bad_alloc` [[bad.alloc]].
|