- tmp/tmp1doj7uqu/{from.md → to.md} +220 -122
tmp/tmp1doj7uqu/{from.md → to.md}
RENAMED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
-
## Method of description
|
| 2 |
|
| 3 |
-
This subclause describes the conventions used to specify the C++
|
| 4 |
-
library. [[structure]] describes the structure of the normative
|
| 5 |
-
[[
|
| 6 |
-
|
| 7 |
|
| 8 |
### Structure of each clause <a id="structure">[[structure]]</a>
|
| 9 |
|
| 10 |
#### Elements <a id="structure.elements">[[structure.elements]]</a>
|
| 11 |
|
|
@@ -21,59 +21,82 @@ Each library clause contains the following elements, as applicable:[^1]
|
|
| 21 |
The Summary provides a synopsis of the category, and introduces the
|
| 22 |
first-level subclauses. Each subclause also provides a summary, listing
|
| 23 |
the headers specified in the subclause and the library entities provided
|
| 24 |
in each header.
|
| 25 |
|
| 26 |
-
Paragraphs labeled “Note(s):” or “Example(s):” are informative, other
|
| 27 |
-
paragraphs are normative.
|
| 28 |
-
|
| 29 |
The contents of the summary and the detailed specifications include:
|
| 30 |
|
| 31 |
- macros
|
| 32 |
- values
|
| 33 |
-
- types
|
| 34 |
- classes and class templates
|
| 35 |
- functions and function templates
|
| 36 |
-
- objects
|
|
|
|
| 37 |
|
| 38 |
#### Requirements <a id="structure.requirements">[[structure.requirements]]</a>
|
| 39 |
|
| 40 |
-
Requirements describe constraints that shall be met by a C++
|
| 41 |
-
extends the standard library. Such extensions are generally one of
|
| 42 |
-
following:
|
| 43 |
|
| 44 |
- Template arguments
|
| 45 |
- Derived classes
|
| 46 |
- Containers, iterators, and algorithms that meet an interface
|
| 47 |
-
convention
|
| 48 |
|
| 49 |
The string and iostream components use an explicit representation of
|
| 50 |
operations required of template arguments. They use a class template
|
| 51 |
`char_traits` to define these constraints.
|
| 52 |
|
| 53 |
Interface convention requirements are stated as generally as possible.
|
| 54 |
-
Instead of stating “class X has to define a member function
|
| 55 |
`operator++()`”, the interface requires “for any object `x` of class
|
| 56 |
`X`, `++x` is defined”. That is, whether the operator is a member is
|
| 57 |
unspecified.
|
| 58 |
|
| 59 |
Requirements are stated in terms of well-defined expressions that define
|
| 60 |
-
valid terms of the types that
|
| 61 |
-
well-defined expression requirements there is a
|
| 62 |
-
initial set of the valid expressions and their
|
| 63 |
-
algorithm
|
| 64 |
-
requirements is described in terms of the valid
|
| 65 |
-
template type parameters.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
Template argument requirements are sometimes referenced by name. See
|
| 68 |
[[type.descriptions]].
|
| 69 |
|
| 70 |
In some cases the semantic requirements are presented as C++ code. Such
|
| 71 |
code is intended as a specification of equivalence of a construct to
|
| 72 |
another construct, not necessarily as the way the construct must be
|
| 73 |
implemented.[^2]
|
| 74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
#### Detailed specifications <a id="structure.specifications">[[structure.specifications]]</a>
|
| 76 |
|
| 77 |
The detailed specifications each contain the following elements:
|
| 78 |
|
| 79 |
- name and brief description
|
|
@@ -93,89 +116,138 @@ appropriate):[^3]
|
|
| 93 |
- operators and other non-member functions
|
| 94 |
|
| 95 |
Descriptions of function semantics contain the following elements (as
|
| 96 |
appropriate):[^4]
|
| 97 |
|
| 98 |
-
- *
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
- *Throws:* any exceptions thrown by the function, and the conditions
|
| 105 |
-
that would cause the exception
|
| 106 |
-
- *Complexity:* the time and/or space complexity of the function
|
| 107 |
-
- *Remarks:* additional semantic constraints on the function
|
| 108 |
- *Error conditions:* the error conditions for error codes reported by
|
| 109 |
-
the function
|
| 110 |
|
| 111 |
-
Whenever the *Effects
|
| 112 |
function `F` are *Equivalent to* some code sequence, then the various
|
| 113 |
-
elements are interpreted as follows. If `F`’s semantics specifies
|
| 114 |
-
*
|
| 115 |
-
the *equivalent-to* semantics. Next, the
|
| 116 |
-
are determined by the *
|
| 117 |
-
*
|
| 118 |
-
,
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
|
|
|
| 124 |
occurrences of that element in the code sequence.
|
| 125 |
|
| 126 |
-
For non-reserved replacement and handler functions,
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
described is the required behavior.
|
| 134 |
|
| 135 |
If the formulation of a complexity requirement calls for a negative
|
| 136 |
number of operations, the actual requirement is zero operations.[^5]
|
| 137 |
|
| 138 |
Complexity requirements specified in the library clauses are upper
|
| 139 |
bounds, and implementations that provide better complexity guarantees
|
| 140 |
-
|
| 141 |
|
| 142 |
Error conditions specify conditions where a function may fail. The
|
| 143 |
conditions are listed, together with a suitable explanation, as the
|
| 144 |
-
`enum class errc` constants
|
| 145 |
|
| 146 |
#### C library <a id="structure.see.also">[[structure.see.also]]</a>
|
| 147 |
|
| 148 |
-
Paragraphs labeled “
|
| 149 |
-
|
|
|
|
| 150 |
|
| 151 |
### Other conventions <a id="conventions">[[conventions]]</a>
|
| 152 |
|
| 153 |
This subclause describes several editorial conventions used to describe
|
| 154 |
the contents of the C++ standard library. These conventions are for
|
| 155 |
-
describing implementation-defined types
|
| 156 |
-
member functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
|
| 158 |
#### Type descriptions <a id="type.descriptions">[[type.descriptions]]</a>
|
| 159 |
|
| 160 |
##### General <a id="type.descriptions.general">[[type.descriptions.general]]</a>
|
| 161 |
|
| 162 |
The Requirements subclauses may describe names that are used to specify
|
| 163 |
constraints on template arguments.[^6] These names are used in library
|
| 164 |
-
Clauses to describe the types that may be supplied as arguments by a
|
| 165 |
-
|
| 166 |
|
| 167 |
-
Certain types defined in
|
| 168 |
implementation-defined types. They are based on other types, but with
|
| 169 |
added constraints.
|
| 170 |
|
| 171 |
##### Exposition-only types <a id="expos.only.types">[[expos.only.types]]</a>
|
| 172 |
|
| 173 |
-
Several types defined in
|
| 174 |
-
|
| 175 |
-
return types are defined for the purpose of exposition only in order to
|
| 176 |
-
capture their language linkage. The declarations of such types are
|
| 177 |
followed by a comment ending in *exposition only*.
|
| 178 |
|
| 179 |
[*Example 1*:
|
| 180 |
|
| 181 |
``` cpp
|
|
@@ -189,73 +261,73 @@ function that takes a callback parameter with C language linkage.
|
|
| 189 |
|
| 190 |
— *end example*]
|
| 191 |
|
| 192 |
##### Enumerated types <a id="enumerated.types">[[enumerated.types]]</a>
|
| 193 |
|
| 194 |
-
Several types defined in
|
| 195 |
-
|
| 196 |
-
|
| 197 |
|
| 198 |
The enumerated type `enumerated` can be written:
|
| 199 |
|
| 200 |
``` cpp
|
| 201 |
-
enum enumerated { V₀, V₁, V₂, V₃,
|
| 202 |
|
| 203 |
inline const enumerated C₀(V₀);
|
| 204 |
inline const enumerated C₁(V₁);
|
| 205 |
inline const enumerated C₂(V₂);
|
| 206 |
inline const enumerated C₃(V₃);
|
| 207 |
-
|
| 208 |
```
|
| 209 |
|
| 210 |
Here, the names `C₀`, `C₁`, etc. represent *enumerated elements* for
|
| 211 |
this particular enumerated type. All such elements have distinct values.
|
| 212 |
|
| 213 |
##### Bitmask types <a id="bitmask.types">[[bitmask.types]]</a>
|
| 214 |
|
| 215 |
-
Several types defined in
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
|
| 220 |
-
The bitmask type
|
| 221 |
|
| 222 |
``` cpp
|
| 223 |
// For exposition only.
|
| 224 |
// int_type is an integral type capable of representing all values of the bitmask type.
|
| 225 |
enum bitmask : int_type {
|
| 226 |
-
V₀ = 1 << 0, V₁ = 1 << 1, V₂ = 1 << 2, V₃ = 1 << 3,
|
| 227 |
};
|
| 228 |
|
| 229 |
inline constexpr bitmask C₀(V₀{});
|
| 230 |
inline constexpr bitmask C₁(V₁{});
|
| 231 |
inline constexpr bitmask C₂(V₂{});
|
| 232 |
inline constexpr bitmask C₃(V₃{});
|
| 233 |
-
|
| 234 |
|
| 235 |
-
constexpr bitmask
|
| 236 |
-
return static_cast<bitmask
|
| 237 |
static_cast<int_type>(X) & static_cast<int_type>(Y));
|
| 238 |
}
|
| 239 |
-
constexpr bitmask
|
| 240 |
-
return static_cast<bitmask
|
| 241 |
static_cast<int_type>(X) | static_cast<int_type>(Y));
|
| 242 |
}
|
| 243 |
-
constexpr bitmask
|
| 244 |
-
return static_cast<bitmask
|
| 245 |
static_cast<int_type>(X) ^ static_cast<int_type>(Y));
|
| 246 |
}
|
| 247 |
-
constexpr bitmask
|
| 248 |
-
return static_cast<bitmask
|
| 249 |
}
|
| 250 |
-
bitmask
|
| 251 |
X = X & Y; return X;
|
| 252 |
}
|
| 253 |
-
bitmask
|
| 254 |
X = X | Y; return X;
|
| 255 |
}
|
| 256 |
-
bitmask
|
| 257 |
X = X ^ Y; return X;
|
| 258 |
}
|
| 259 |
```
|
| 260 |
|
| 261 |
Here, the names `C₀`, `C₁`, etc. represent *bitmask elements* for this
|
|
@@ -282,73 +354,99 @@ sequences that follow a few uniform conventions:
|
|
| 282 |
basic execution character set.
|
| 283 |
- The *decimal-point character* is the (single-byte) character used by
|
| 284 |
functions that convert between a (single-byte) character sequence and
|
| 285 |
a value of one of the floating-point types. It is used in the
|
| 286 |
character sequence to denote the beginning of a fractional part. It is
|
| 287 |
-
represented in
|
| 288 |
-
|
| 289 |
-
|
| 290 |
`setlocale(int, const char*)`,[^8] or by a change to a `locale`
|
| 291 |
-
object, as described in
|
| 292 |
-
- A *character sequence* is an array object
|
| 293 |
-
|
| 294 |
-
`unsigned char`, or `signed char`
|
| 295 |
qualified by any combination of `const` or `volatile`. The initial
|
| 296 |
elements of the array have defined contents up to and including an
|
| 297 |
element determined by some predicate. A character sequence can be
|
| 298 |
designated by a pointer value `S` that points to its first element.
|
| 299 |
|
| 300 |
###### Byte strings <a id="byte.strings">[[byte.strings]]</a>
|
| 301 |
|
| 302 |
A *null-terminated byte string*, or NTBS, is a character sequence whose
|
| 303 |
highest-addressed element with defined content has the value zero (the
|
| 304 |
-
*terminating null
|
| 305 |
value zero. [^9]
|
| 306 |
|
| 307 |
-
The *length
|
| 308 |
-
terminating null character. An *empty
|
| 309 |
|
| 310 |
-
The *value
|
| 311 |
and including the terminating null character.
|
| 312 |
|
| 313 |
-
A *static
|
| 314 |
|
| 315 |
###### Multibyte strings <a id="multibyte.strings">[[multibyte.strings]]</a>
|
| 316 |
|
| 317 |
A *null-terminated multibyte string*, or NTMBS, is an NTBS that
|
| 318 |
constitutes a sequence of valid multibyte characters, beginning and
|
| 319 |
ending in the initial shift state.[^11]
|
| 320 |
|
| 321 |
-
A *static
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 322 |
|
| 323 |
#### Functions within classes <a id="functions.within.classes">[[functions.within.classes]]</a>
|
| 324 |
|
| 325 |
-
For the sake of exposition,
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
[[class.
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
default.
|
| 333 |
-
|
| 334 |
-
For the sake of exposition, the library clauses sometimes annotate
|
| 335 |
-
constructors with \EXPLICIT. Such a constructor is conditionally
|
| 336 |
-
declared as either explicit or non-explicit ([[class.conv.ctor]]).
|
| 337 |
-
|
| 338 |
-
[*Note 1*: This is typically implemented by declaring two such
|
| 339 |
-
constructors, of which at most one participates in overload
|
| 340 |
-
resolution. — *end note*]
|
| 341 |
|
| 342 |
#### Private members <a id="objects.within.classes">[[objects.within.classes]]</a>
|
| 343 |
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
[[
|
| 350 |
|
| 351 |
For the sake of exposition, some subclauses provide representative
|
| 352 |
declarations, and semantic requirements, for private members of classes
|
| 353 |
that meet the external specifications of the classes. The declarations
|
| 354 |
for such members are followed by a comment that ends with *exposition
|
|
|
|
| 1 |
+
## Method of description <a id="description">[[description]]</a>
|
| 2 |
|
| 3 |
+
This subclause describes the conventions used to specify the C++
|
| 4 |
+
standard library. [[structure]] describes the structure of the normative
|
| 5 |
+
[[support]] through [[thread]] and [[depr]]. [[conventions]] describes
|
| 6 |
+
other editorial conventions.
|
| 7 |
|
| 8 |
### Structure of each clause <a id="structure">[[structure]]</a>
|
| 9 |
|
| 10 |
#### Elements <a id="structure.elements">[[structure.elements]]</a>
|
| 11 |
|
|
|
|
| 21 |
The Summary provides a synopsis of the category, and introduces the
|
| 22 |
first-level subclauses. Each subclause also provides a summary, listing
|
| 23 |
the headers specified in the subclause and the library entities provided
|
| 24 |
in each header.
|
| 25 |
|
|
|
|
|
|
|
|
|
|
| 26 |
The contents of the summary and the detailed specifications include:
|
| 27 |
|
| 28 |
- macros
|
| 29 |
- values
|
| 30 |
+
- types and alias templates
|
| 31 |
- classes and class templates
|
| 32 |
- functions and function templates
|
| 33 |
+
- objects and variable templates
|
| 34 |
+
- concepts
|
| 35 |
|
| 36 |
#### Requirements <a id="structure.requirements">[[structure.requirements]]</a>
|
| 37 |
|
| 38 |
+
Requirements describe constraints that shall be met by a C++ program
|
| 39 |
+
that extends the standard library. Such extensions are generally one of
|
| 40 |
+
the following:
|
| 41 |
|
| 42 |
- Template arguments
|
| 43 |
- Derived classes
|
| 44 |
- Containers, iterators, and algorithms that meet an interface
|
| 45 |
+
convention or model a concept
|
| 46 |
|
| 47 |
The string and iostream components use an explicit representation of
|
| 48 |
operations required of template arguments. They use a class template
|
| 49 |
`char_traits` to define these constraints.
|
| 50 |
|
| 51 |
Interface convention requirements are stated as generally as possible.
|
| 52 |
+
Instead of stating “class `X` has to define a member function
|
| 53 |
`operator++()`”, the interface requires “for any object `x` of class
|
| 54 |
`X`, `++x` is defined”. That is, whether the operator is a member is
|
| 55 |
unspecified.
|
| 56 |
|
| 57 |
Requirements are stated in terms of well-defined expressions that define
|
| 58 |
+
valid terms of the types that meet the requirements. For every set of
|
| 59 |
+
well-defined expression requirements there is either a named concept or
|
| 60 |
+
a table that specifies an initial set of the valid expressions and their
|
| 61 |
+
semantics. Any generic algorithm [[algorithms]] that uses the
|
| 62 |
+
well-defined expression requirements is described in terms of the valid
|
| 63 |
+
expressions for its template type parameters.
|
| 64 |
+
|
| 65 |
+
The library specification uses a typographical convention for naming
|
| 66 |
+
requirements. Names in *italic* type that begin with the prefix *Cpp17*
|
| 67 |
+
refer to sets of well-defined expression requirements typically
|
| 68 |
+
presented in tabular form, possibly with additional prose semantic
|
| 69 |
+
requirements. For example, *Cpp17Destructible* ([[cpp17.destructible]])
|
| 70 |
+
is such a named requirement. Names in `constant width` type refer to
|
| 71 |
+
library concepts which are presented as a concept definition [[temp]],
|
| 72 |
+
possibly with additional prose semantic requirements. For example,
|
| 73 |
+
`destructible` [[concept.destructible]] is such a named requirement.
|
| 74 |
|
| 75 |
Template argument requirements are sometimes referenced by name. See
|
| 76 |
[[type.descriptions]].
|
| 77 |
|
| 78 |
In some cases the semantic requirements are presented as C++ code. Such
|
| 79 |
code is intended as a specification of equivalence of a construct to
|
| 80 |
another construct, not necessarily as the way the construct must be
|
| 81 |
implemented.[^2]
|
| 82 |
|
| 83 |
+
Required operations of any concept defined in this document need not be
|
| 84 |
+
total functions; that is, some arguments to a required operation may
|
| 85 |
+
result in the required semantics failing to be met.
|
| 86 |
+
|
| 87 |
+
[*Example 1*: The required `<` operator of the `totally_ordered`
|
| 88 |
+
concept [[concept.totallyordered]] does not meet the semantic
|
| 89 |
+
requirements of that concept when operating on NaNs. — *end example*]
|
| 90 |
+
|
| 91 |
+
This does not affect whether a type models the concept.
|
| 92 |
+
|
| 93 |
+
A declaration may explicitly impose requirements through its associated
|
| 94 |
+
constraints [[temp.constr.decl]]. When the associated constraints refer
|
| 95 |
+
to a concept [[temp.concept]], the semantic constraints specified for
|
| 96 |
+
that concept are additionally imposed on the use of the declaration.
|
| 97 |
+
|
| 98 |
#### Detailed specifications <a id="structure.specifications">[[structure.specifications]]</a>
|
| 99 |
|
| 100 |
The detailed specifications each contain the following elements:
|
| 101 |
|
| 102 |
- name and brief description
|
|
|
|
| 116 |
- operators and other non-member functions
|
| 117 |
|
| 118 |
Descriptions of function semantics contain the following elements (as
|
| 119 |
appropriate):[^4]
|
| 120 |
|
| 121 |
+
- *Constraints:* the conditions for the function’s participation in
|
| 122 |
+
overload resolution [[over.match]]. \[*Note 1*: Failure to meet such a
|
| 123 |
+
condition results in the function’s silent
|
| 124 |
+
non-viability. — *end note*] \[*Example 1*: An implementation might
|
| 125 |
+
express such a condition via a *constraint-expression*
|
| 126 |
+
[[temp.constr.decl]]. — *end example*]
|
| 127 |
+
- *Mandates:* the conditions that, if not met, render the program
|
| 128 |
+
ill-formed. \[*Example 2*: An implementation might express such a
|
| 129 |
+
condition via the *constant-expression* in a
|
| 130 |
+
*static_assert-declaration* [[dcl.pre]]. If the diagnostic is to be
|
| 131 |
+
emitted only after the function has been selected by overload
|
| 132 |
+
resolution, an implementation might express such a condition via a
|
| 133 |
+
*constraint-expression* [[temp.constr.decl]] and also define the
|
| 134 |
+
function as deleted. — *end example*]
|
| 135 |
+
- *Preconditions:* the conditions that the function assumes to hold
|
| 136 |
+
whenever it is called.
|
| 137 |
+
- *Effects:* the actions performed by the function.
|
| 138 |
+
- *Synchronization:* the synchronization operations
|
| 139 |
+
[[intro.multithread]] applicable to the function.
|
| 140 |
+
- *Ensures:* the conditions (sometimes termed observable results)
|
| 141 |
+
established by the function.
|
| 142 |
+
- *Returns:* a description of the value(s) returned by the function.
|
| 143 |
- *Throws:* any exceptions thrown by the function, and the conditions
|
| 144 |
+
that would cause the exception.
|
| 145 |
+
- *Complexity:* the time and/or space complexity of the function.
|
| 146 |
+
- *Remarks:* additional semantic constraints on the function.
|
| 147 |
- *Error conditions:* the error conditions for error codes reported by
|
| 148 |
+
the function.
|
| 149 |
|
| 150 |
+
Whenever the *Effects* element specifies that the semantics of some
|
| 151 |
function `F` are *Equivalent to* some code sequence, then the various
|
| 152 |
+
elements are interpreted as follows. If `F`’s semantics specifies any
|
| 153 |
+
*Constraints* or *Mandates* elements, then those requirements are
|
| 154 |
+
logically imposed prior to the *equivalent-to* semantics. Next, the
|
| 155 |
+
semantics of the code sequence are determined by the *Constraints*,
|
| 156 |
+
*Mandates*, *Preconditions*, *Effects*, *Synchronization*,
|
| 157 |
+
*Postconditions*, *Returns*, *Throws*, *Complexity*, *Remarks*, and
|
| 158 |
+
*Error conditions* specified for the function invocations contained in
|
| 159 |
+
the code sequence. The value returned from `F` is specified by `F`’s
|
| 160 |
+
*Returns* element, or if `F` has no *Returns* element, a non-`void`
|
| 161 |
+
return from `F` is specified by the `return` statements [[stmt.return]]
|
| 162 |
+
in the code sequence. If `F`’s semantics contains a *Throws*,
|
| 163 |
+
*Postconditions*, or *Complexity* element, then that supersedes any
|
| 164 |
occurrences of that element in the code sequence.
|
| 165 |
|
| 166 |
+
For non-reserved replacement and handler functions, [[support]]
|
| 167 |
+
specifies two behaviors for the functions in question: their required
|
| 168 |
+
and default behavior. The *default behavior* describes a function
|
| 169 |
+
definition provided by the implementation. The *required behavior*
|
| 170 |
+
describes the semantics of a function definition provided by either the
|
| 171 |
+
implementation or a C++ program. Where no distinction is explicitly made
|
| 172 |
+
in the description, the behavior described is the required behavior.
|
|
|
|
| 173 |
|
| 174 |
If the formulation of a complexity requirement calls for a negative
|
| 175 |
number of operations, the actual requirement is zero operations.[^5]
|
| 176 |
|
| 177 |
Complexity requirements specified in the library clauses are upper
|
| 178 |
bounds, and implementations that provide better complexity guarantees
|
| 179 |
+
meet the requirements.
|
| 180 |
|
| 181 |
Error conditions specify conditions where a function may fail. The
|
| 182 |
conditions are listed, together with a suitable explanation, as the
|
| 183 |
+
`enum class errc` constants [[syserr]].
|
| 184 |
|
| 185 |
#### C library <a id="structure.see.also">[[structure.see.also]]</a>
|
| 186 |
|
| 187 |
+
Paragraphs labeled “<span class="smallcaps">See also</span>” contain
|
| 188 |
+
cross-references to the relevant portions of other standards
|
| 189 |
+
[[intro.refs]].
|
| 190 |
|
| 191 |
### Other conventions <a id="conventions">[[conventions]]</a>
|
| 192 |
|
| 193 |
This subclause describes several editorial conventions used to describe
|
| 194 |
the contents of the C++ standard library. These conventions are for
|
| 195 |
+
describing implementation-defined types [[type.descriptions]], and
|
| 196 |
+
member functions [[functions.within.classes]].
|
| 197 |
+
|
| 198 |
+
#### Exposition-only functions <a id="expos.only.func">[[expos.only.func]]</a>
|
| 199 |
+
|
| 200 |
+
Several function templates defined in [[support]] through [[thread]] and
|
| 201 |
+
[[depr]] are only defined for the purpose of exposition. The declaration
|
| 202 |
+
of such a function is followed by a comment ending in *exposition only*.
|
| 203 |
+
|
| 204 |
+
The following are defined for exposition only to aid in the
|
| 205 |
+
specification of the library:
|
| 206 |
+
|
| 207 |
+
``` cpp
|
| 208 |
+
template<class T> constexpr decay_t<T> decay-copy(T&& v)
|
| 209 |
+
noexcept(is_nothrow_convertible_v<T, decay_t<T>>) // exposition only
|
| 210 |
+
{ return std::forward<T>(v); }
|
| 211 |
+
|
| 212 |
+
constexpr auto synth-three-way =
|
| 213 |
+
[]<class T, class U>(const T& t, const U& u)
|
| 214 |
+
requires requires {
|
| 215 |
+
{ t < u } -> boolean-testable;
|
| 216 |
+
{ u < t } -> boolean-testable;
|
| 217 |
+
}
|
| 218 |
+
{
|
| 219 |
+
if constexpr (three_way_comparable_with<T, U>) {
|
| 220 |
+
return t <=> u;
|
| 221 |
+
} else {
|
| 222 |
+
if (t < u) return weak_ordering::less;
|
| 223 |
+
if (u < t) return weak_ordering::greater;
|
| 224 |
+
return weak_ordering::equivalent;
|
| 225 |
+
}
|
| 226 |
+
};
|
| 227 |
+
|
| 228 |
+
template<class T, class U=T>
|
| 229 |
+
using synth-three-way-result = decltype(synth-three-way(declval<T&>(), declval<U&>()));
|
| 230 |
+
```
|
| 231 |
|
| 232 |
#### Type descriptions <a id="type.descriptions">[[type.descriptions]]</a>
|
| 233 |
|
| 234 |
##### General <a id="type.descriptions.general">[[type.descriptions.general]]</a>
|
| 235 |
|
| 236 |
The Requirements subclauses may describe names that are used to specify
|
| 237 |
constraints on template arguments.[^6] These names are used in library
|
| 238 |
+
Clauses to describe the types that may be supplied as arguments by a C++
|
| 239 |
+
program when instantiating template components from the library.
|
| 240 |
|
| 241 |
+
Certain types defined in [[input.output]] are used to describe
|
| 242 |
implementation-defined types. They are based on other types, but with
|
| 243 |
added constraints.
|
| 244 |
|
| 245 |
##### Exposition-only types <a id="expos.only.types">[[expos.only.types]]</a>
|
| 246 |
|
| 247 |
+
Several types defined in [[support]] through [[thread]] and [[depr]] are
|
| 248 |
+
defined for the purpose of exposition. The declaration of such a type is
|
|
|
|
|
|
|
| 249 |
followed by a comment ending in *exposition only*.
|
| 250 |
|
| 251 |
[*Example 1*:
|
| 252 |
|
| 253 |
``` cpp
|
|
|
|
| 261 |
|
| 262 |
— *end example*]
|
| 263 |
|
| 264 |
##### Enumerated types <a id="enumerated.types">[[enumerated.types]]</a>
|
| 265 |
|
| 266 |
+
Several types defined in [[input.output]] are *enumerated types*. Each
|
| 267 |
+
enumerated type may be implemented as an enumeration or as a synonym for
|
| 268 |
+
an enumeration.[^7]
|
| 269 |
|
| 270 |
The enumerated type `enumerated` can be written:
|
| 271 |
|
| 272 |
``` cpp
|
| 273 |
+
enum enumerated { V₀, V₁, V₂, V₃, … };
|
| 274 |
|
| 275 |
inline const enumerated C₀(V₀);
|
| 276 |
inline const enumerated C₁(V₁);
|
| 277 |
inline const enumerated C₂(V₂);
|
| 278 |
inline const enumerated C₃(V₃);
|
| 279 |
+
⋮
|
| 280 |
```
|
| 281 |
|
| 282 |
Here, the names `C₀`, `C₁`, etc. represent *enumerated elements* for
|
| 283 |
this particular enumerated type. All such elements have distinct values.
|
| 284 |
|
| 285 |
##### Bitmask types <a id="bitmask.types">[[bitmask.types]]</a>
|
| 286 |
|
| 287 |
+
Several types defined in [[support]] through [[thread]] and [[depr]] are
|
| 288 |
+
*bitmask types*. Each bitmask type can be implemented as an enumerated
|
| 289 |
+
type that overloads certain operators, as an integer type, or as a
|
| 290 |
+
`bitset` [[template.bitset]].
|
| 291 |
|
| 292 |
+
The bitmask type `bitmask` can be written:
|
| 293 |
|
| 294 |
``` cpp
|
| 295 |
// For exposition only.
|
| 296 |
// int_type is an integral type capable of representing all values of the bitmask type.
|
| 297 |
enum bitmask : int_type {
|
| 298 |
+
V₀ = 1 << 0, V₁ = 1 << 1, V₂ = 1 << 2, V₃ = 1 << 3, …
|
| 299 |
};
|
| 300 |
|
| 301 |
inline constexpr bitmask C₀(V₀{});
|
| 302 |
inline constexpr bitmask C₁(V₁{});
|
| 303 |
inline constexpr bitmask C₂(V₂{});
|
| 304 |
inline constexpr bitmask C₃(V₃{});
|
| 305 |
+
⋮
|
| 306 |
|
| 307 |
+
constexpr bitmask operator&(bitmask X, bitmask Y) {
|
| 308 |
+
return static_cast<bitmask>(
|
| 309 |
static_cast<int_type>(X) & static_cast<int_type>(Y));
|
| 310 |
}
|
| 311 |
+
constexpr bitmask operator|(bitmask X, bitmask Y) {
|
| 312 |
+
return static_cast<bitmask>(
|
| 313 |
static_cast<int_type>(X) | static_cast<int_type>(Y));
|
| 314 |
}
|
| 315 |
+
constexpr bitmask operator^(bitmask X, bitmask Y){
|
| 316 |
+
return static_cast<bitmask>(
|
| 317 |
static_cast<int_type>(X) ^ static_cast<int_type>(Y));
|
| 318 |
}
|
| 319 |
+
constexpr bitmask operator~(bitmask X){
|
| 320 |
+
return static_cast<bitmask>(~static_cast<int_type>(X));
|
| 321 |
}
|
| 322 |
+
bitmask& operator&=(bitmask& X, bitmask Y){
|
| 323 |
X = X & Y; return X;
|
| 324 |
}
|
| 325 |
+
bitmask& operator|=(bitmask& X, bitmask Y) {
|
| 326 |
X = X | Y; return X;
|
| 327 |
}
|
| 328 |
+
bitmask& operator^=(bitmask& X, bitmask Y) {
|
| 329 |
X = X ^ Y; return X;
|
| 330 |
}
|
| 331 |
```
|
| 332 |
|
| 333 |
Here, the names `C₀`, `C₁`, etc. represent *bitmask elements* for this
|
|
|
|
| 354 |
basic execution character set.
|
| 355 |
- The *decimal-point character* is the (single-byte) character used by
|
| 356 |
functions that convert between a (single-byte) character sequence and
|
| 357 |
a value of one of the floating-point types. It is used in the
|
| 358 |
character sequence to denote the beginning of a fractional part. It is
|
| 359 |
+
represented in [[support]] through [[thread]] and [[depr]] by a
|
| 360 |
+
period, `'.'`, which is also its value in the `"C"` locale, but may
|
| 361 |
+
change during program execution by a call to
|
| 362 |
`setlocale(int, const char*)`,[^8] or by a change to a `locale`
|
| 363 |
+
object, as described in [[locales]] and [[input.output]].
|
| 364 |
+
- A *character sequence* is an array object [[dcl.array]] `A` that can
|
| 365 |
+
be declared as `T A[N]`, where `T` is any of the types `char`,
|
| 366 |
+
`unsigned char`, or `signed char` [[basic.fundamental]], optionally
|
| 367 |
qualified by any combination of `const` or `volatile`. The initial
|
| 368 |
elements of the array have defined contents up to and including an
|
| 369 |
element determined by some predicate. A character sequence can be
|
| 370 |
designated by a pointer value `S` that points to its first element.
|
| 371 |
|
| 372 |
###### Byte strings <a id="byte.strings">[[byte.strings]]</a>
|
| 373 |
|
| 374 |
A *null-terminated byte string*, or NTBS, is a character sequence whose
|
| 375 |
highest-addressed element with defined content has the value zero (the
|
| 376 |
+
*terminating null character*); no other element in the sequence has the
|
| 377 |
value zero. [^9]
|
| 378 |
|
| 379 |
+
The *length of an NTBS* is the number of elements that precede the
|
| 380 |
+
terminating null character. An *empty NTBS* has a length of zero.
|
| 381 |
|
| 382 |
+
The *value of an NTBS* is the sequence of values of the elements up to
|
| 383 |
and including the terminating null character.
|
| 384 |
|
| 385 |
+
A *static NTBS* is an NTBS with static storage duration.[^10]
|
| 386 |
|
| 387 |
###### Multibyte strings <a id="multibyte.strings">[[multibyte.strings]]</a>
|
| 388 |
|
| 389 |
A *null-terminated multibyte string*, or NTMBS, is an NTBS that
|
| 390 |
constitutes a sequence of valid multibyte characters, beginning and
|
| 391 |
ending in the initial shift state.[^11]
|
| 392 |
|
| 393 |
+
A *static NTMBS* is an NTMBS with static storage duration.
|
| 394 |
+
|
| 395 |
+
##### Customization Point Object types <a id="customization.point.object">[[customization.point.object]]</a>
|
| 396 |
+
|
| 397 |
+
A *customization point object* is a function object [[function.objects]]
|
| 398 |
+
with a literal class type that interacts with program-defined types
|
| 399 |
+
while enforcing semantic requirements on that interaction.
|
| 400 |
+
|
| 401 |
+
The type of a customization point object, ignoring cv-qualifiers, shall
|
| 402 |
+
model `semiregular` [[concepts.object]].
|
| 403 |
+
|
| 404 |
+
All instances of a specific customization point object type shall be
|
| 405 |
+
equal [[concepts.equality]].
|
| 406 |
+
|
| 407 |
+
The type `T` of a customization point object shall model
|
| 408 |
+
`invocable<const T&, Args...>` [[concept.invocable]] when the types in
|
| 409 |
+
`Args...` meet the requirements specified in that customization point
|
| 410 |
+
object’s definition. When the types of `Args...` do not meet the
|
| 411 |
+
customization point object’s requirements, `T` shall not have a function
|
| 412 |
+
call operator that participates in overload resolution.
|
| 413 |
+
|
| 414 |
+
Each customization point object type constrains its return type to model
|
| 415 |
+
a particular concept.
|
| 416 |
+
|
| 417 |
+
[*Note 1*: Many of the customization point objects in the library
|
| 418 |
+
evaluate function call expressions with an unqualified name which
|
| 419 |
+
results in a call to a program-defined function found by argument
|
| 420 |
+
dependent name lookup [[basic.lookup.argdep]]. To preclude such an
|
| 421 |
+
expression resulting in a call to unconstrained functions with the same
|
| 422 |
+
name in namespace `std`, customization point objects specify that lookup
|
| 423 |
+
for these expressions is performed in a context that includes deleted
|
| 424 |
+
overloads matching the signatures of overloads defined in namespace
|
| 425 |
+
`std`. When the deleted overloads are viable, program-defined overloads
|
| 426 |
+
need be more specialized [[temp.func.order]] or more constrained
|
| 427 |
+
[[temp.constr.order]] to be used by a customization point
|
| 428 |
+
object. — *end note*]
|
| 429 |
|
| 430 |
#### Functions within classes <a id="functions.within.classes">[[functions.within.classes]]</a>
|
| 431 |
|
| 432 |
+
For the sake of exposition, [[support]] through [[thread]] and [[depr]]
|
| 433 |
+
do not describe copy/move constructors, assignment operators, or
|
| 434 |
+
(non-virtual) destructors with the same apparent semantics as those that
|
| 435 |
+
can be generated by default ([[class.copy.ctor]],
|
| 436 |
+
[[class.copy.assign]], [[class.dtor]]). It is unspecified whether the
|
| 437 |
+
implementation provides explicit definitions for such member function
|
| 438 |
+
signatures, or for virtual destructors that can be generated by default.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 439 |
|
| 440 |
#### Private members <a id="objects.within.classes">[[objects.within.classes]]</a>
|
| 441 |
|
| 442 |
+
[[support]] through [[thread]] and [[depr]] do not specify the
|
| 443 |
+
representation of classes, and intentionally omit specification of class
|
| 444 |
+
members [[class.mem]]. An implementation may define static or non-static
|
| 445 |
+
class members, or both, as needed to implement the semantics of the
|
| 446 |
+
member functions specified in [[support]] through [[thread]] and
|
| 447 |
+
[[depr]].
|
| 448 |
|
| 449 |
For the sake of exposition, some subclauses provide representative
|
| 450 |
declarations, and semantic requirements, for private members of classes
|
| 451 |
that meet the external specifications of the classes. The declarations
|
| 452 |
for such members are followed by a comment that ends with *exposition
|