From Jason Turner

[support.types]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpwyxu3hhi/{from.md → to.md} +305 -39
tmp/tmpwyxu3hhi/{from.md → to.md} RENAMED
@@ -1,54 +1,320 @@
1
- ## Types <a id="support.types">[[support.types]]</a>
2
-
3
- Table  [[tab:support.hdr.cstddef]] describes the header `<cstddef>`.
4
-
5
- The contents are the same as the Standard C library header `<stddef.h>`,
6
- with the following changes:
7
-
8
- The macro `NULL` is an implementation-defined C++null pointer constant
9
- in this International Standard ([[conv.ptr]]).[^1]
10
-
11
- The macro `offsetof`(*type*, *member-designator*) accepts a restricted
12
- set of *type* arguments in this International Standard. If *type* is not
13
- a standard-layout class (Clause  [[class]]), the results are
14
- undefined.[^2] The expression `offsetof`(*type*, *member-designator*) is
15
- never type-dependent ([[temp.dep.expr]]) and it is value-dependent (
16
- [[temp.dep.constexpr]]) if and only if *type* is dependent. The result
17
- of applying the `offsetof` macro to a field that is a static data member
18
- or a function member is undefined. No operation invoked by the
19
- `offsetof` macro shall throw an exception and
20
- `noexcept(offsetof(type, member-designator))` shall be `true`.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  The type `ptrdiff_t` is an *implementation-defined* signed integer type
23
  that can hold the difference of two subscripts in an array object, as
24
  described in  [[expr.add]].
25
 
26
  The type `size_t` is an *implementation-defined* unsigned integer type
27
  that is large enough to contain the size in bytes of any object.
28
 
29
- It is recommended that implementations choose types for `ptrdiff_t` and
30
- `size_t` whose integer conversion ranks ([[conv.rank]]) are no greater
31
- than that of `signed long int` unless a larger size is necessary to
32
- contain all the possible values.
33
 
34
  The type `max_align_t` is a POD type whose alignment requirement is at
35
  least as great as that of every scalar type, and whose alignment
36
  requirement is supported in every context.
37
 
38
- `nullptr_t` is defined as follows:
39
-
40
- ``` cpp
41
- namespace std {
42
- typedef decltype(nullptr) nullptr_t;
43
- }
44
- ```
45
-
46
- The type for which `nullptr_t` is a synonym has the characteristics
47
- described in  [[basic.fundamental]] and  [[conv.ptr]]. Although
48
- `nullptr`’s address cannot be taken, the address of another `nullptr_t`
49
- object that is an lvalue can be taken.
50
-
51
  Alignment ([[basic.align]]), Sizeof ([[expr.sizeof]]), Additive
52
- operators ([[expr.add]]), Free store ([[class.free]]), and ISO
53
- C 7.1.6.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
 
1
+ ## Common definitions <a id="support.types">[[support.types]]</a>
2
+
3
+ ### Header `<cstddef>` synopsis <a id="cstddef.syn">[[cstddef.syn]]</a>
4
+
5
+ ``` cpp
6
+ namespace std {
7
+ using ptrdiff_t = see below;
8
+ using size_t = see below;
9
+ using max_align_t = see below;
10
+ using nullptr_t = decltype(nullptr);
11
+
12
+ enum class byte : unsigned char {};
13
+
14
+ // [support.types.byteops], byte type operations
15
+ template <class IntType>
16
+ constexpr byte& operator<<=(byte& b, IntType shift) noexcept;
17
+ template <class IntType>
18
+ constexpr byte operator<<(byte b, IntType shift) noexcept;
19
+ template <class IntType>
20
+ constexpr byte& operator>>=(byte& b, IntType shift) noexcept;
21
+ template <class IntType>
22
+ constexpr byte operator>>(byte b, IntType shift) noexcept;
23
+ constexpr byte& operator|=(byte& l, byte r) noexcept;
24
+ constexpr byte operator|(byte l, byte r) noexcept;
25
+ constexpr byte& operator&=(byte& l, byte r) noexcept;
26
+ constexpr byte operator&(byte l, byte r) noexcept;
27
+ constexpr byte& operator^=(byte& l, byte r) noexcept;
28
+ constexpr byte operator^(byte l, byte r) noexcept;
29
+ constexpr byte operator~(byte b) noexcept;
30
+ template <class IntType>
31
+ constexpr IntType to_integer(byte b) noexcept;
32
+ }
33
+
34
+ #define NULL see below
35
+ #define offsetof(P, D) see below
36
+ ```
37
+
38
+ The contents and meaning of the header `<cstddef>` are the same as the C
39
+ standard library header `<stddef.h>`, except that it does not declare
40
+ the type `wchar_t`, that it also declares the type `byte` and its
41
+ associated operations ([[support.types.byteops]]), and as noted in
42
+ [[support.types.nullptr]] and [[support.types.layout]].
43
+
44
+ ISO C 7.19
45
+
46
+ ### Header `<cstdlib>` synopsis <a id="cstdlib.syn">[[cstdlib.syn]]</a>
47
+
48
+ ``` cpp
49
+ namespace std {
50
+ using size_t = see below;
51
+ using div_t = see below;
52
+ using ldiv_t = see below;
53
+ using lldiv_t = see below;
54
+ }
55
+
56
+ #define NULL see below
57
+ #define EXIT_FAILURE see below
58
+ #define EXIT_SUCCESS see below
59
+ #define RAND_MAX see below
60
+ #define MB_CUR_MAX see below
61
+
62
+ namespace std {
63
+ // Exposition-only function type aliases
64
+ extern "C" using c-atexit-handler = void(); // exposition only
65
+ extern "C++" using atexit-handler = void(); // exposition only
66
+ extern "C" using c-compare-pred = int(const void*, const void*); // exposition only
67
+ extern "C++" using compare-pred = int(const void*, const void*); // exposition only
68
+
69
+ // [support.start.term], start and termination
70
+ [[noreturn]] void abort() noexcept;
71
+ int atexit(c-atexit-handler* func) noexcept;
72
+ int atexit(atexit-handler* func) noexcept;
73
+ int at_quick_exit(c-atexit-handler* func) noexcept;
74
+ int at_quick_exit(atexit-handler* func) noexcept;
75
+ [[noreturn]] void exit(int status);
76
+ [[noreturn]] void _Exit(int status) noexcept;
77
+ [[noreturn]] void quick_exit(int status) noexcept;
78
+
79
+ char* getenv(const char* name);
80
+ int system(const char* string);
81
+
82
+ // [c.malloc], C library memory allocation
83
+ void* aligned_alloc(size_t alignment, size_t size);
84
+ void* calloc(size_t nmemb, size_t size);
85
+ void free(void* ptr);
86
+ void* malloc(size_t size);
87
+ void* realloc(void* ptr, size_t size);
88
+
89
+ double atof(const char* nptr);
90
+ int atoi(const char* nptr);
91
+ long int atol(const char* nptr);
92
+ long long int atoll(const char* nptr);
93
+ double strtod(const char* nptr, char** endptr);
94
+ float strtof(const char* nptr, char** endptr);
95
+ long double strtold(const char* nptr, char** endptr);
96
+ long int strtol(const char* nptr, char** endptr, int base);
97
+ long long int strtoll(const char* nptr, char** endptr, int base);
98
+ unsigned long int strtoul(const char* nptr, char** endptr, int base);
99
+ unsigned long long int strtoull(const char* nptr, char** endptr, int base);
100
+
101
+ // [c.mb.wcs], multibyte / wide string and character conversion functions
102
+ int mblen(const char* s, size_t n);
103
+ int mbtowc(wchar_t* pwc, const char* s, size_t n);
104
+ int wctomb(char* s, wchar_t wchar);
105
+ size_t mbstowcs(wchar_t* pwcs, const char* s, size_t n);
106
+ size_t wcstombs(char* s, const wchar_t* pwcs, size_t n);
107
+
108
+ // [alg.c.library], C standard library algorithms
109
+ void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
110
+ c-compare-pred* compar);
111
+ void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
112
+ compare-pred* compar);
113
+ void qsort(void* base, size_t nmemb, size_t size, c-compare-pred* compar);
114
+ void qsort(void* base, size_t nmemb, size_t size, compare-pred* compar);
115
+
116
+ // [c.math.rand], low-quality random number generation
117
+ int rand();
118
+ void srand(unsigned int seed);
119
+
120
+ // [c.math.abs], absolute values
121
+ int abs(int j);
122
+ long int abs(long int j);
123
+ long long int abs(long long int j);
124
+ float abs(float j);
125
+ double abs(double j);
126
+ long double abs(long double j);
127
+
128
+ long int labs(long int j);
129
+ long long int llabs(long long int j);
130
+
131
+ div_t div(int numer, int denom);
132
+ ldiv_t div(long int numer, long int denom); // see [library.c]
133
+ lldiv_t div(long long int numer, long long int denom); // see [library.c]
134
+ ldiv_t ldiv(long int numer, long int denom);
135
+ lldiv_t lldiv(long long int numer, long long int denom);
136
+ }
137
+ ```
138
+
139
+ The contents and meaning of the header `<cstdlib>` are the same as the C
140
+ standard library header `<stdlib.h>`, except that it does not declare
141
+ the type `wchar_t`, and except as noted in [[support.types.nullptr]],
142
+ [[support.types.layout]], [[support.start.term]], [[c.malloc]],
143
+ [[c.mb.wcs]], [[alg.c.library]], [[c.math.rand]], and [[c.math.abs]].
144
+
145
+ [*Note 1*: Several functions have additional overloads in this
146
+ International Standard, but they have the same behavior as in the C
147
+ standard library ([[library.c]]). — *end note*]
148
+
149
+ ISO C 7.22
150
+
151
+ ### Null pointers <a id="support.types.nullptr">[[support.types.nullptr]]</a>
152
+
153
+ The type `nullptr_t` is a synonym for the type of a `nullptr`
154
+ expression, and it has the characteristics described in 
155
+ [[basic.fundamental]] and  [[conv.ptr]].
156
+
157
+ [*Note 1*: Although `nullptr`’s address cannot be taken, the address of
158
+ another `nullptr_t` object that is an lvalue can be
159
+ taken. — *end note*]
160
+
161
+ The macro `NULL` is an *implementation-defined* null pointer constant.
162
+ [^1]
163
+
164
+ ### Sizes, alignments, and offsets <a id="support.types.layout">[[support.types.layout]]</a>
165
+
166
+ The macro `offsetof(type, member-designator)` has the same semantics as
167
+ the corresponding macro in the C standard library header `<stddef.h>`,
168
+ but accepts a restricted set of `type` arguments in this International
169
+ Standard. Use of the `offsetof` macro with a `type` other than a
170
+ standard-layout class (Clause  [[class]]) is
171
+ conditionally-supported.[^2] The expression
172
+ `offsetof(type, member-designator)` is never type-dependent (
173
+ [[temp.dep.expr]]) and it is value-dependent ([[temp.dep.constexpr]])
174
+ if and only if `type` is dependent. The result of applying the
175
+ `offsetof` macro to a static data member or a function member is
176
+ undefined. No operation invoked by the `offsetof` macro shall throw an
177
+ exception and `noexcept(offsetof(type, member-designator))` shall be
178
+ `true`.
179
 
180
  The type `ptrdiff_t` is an *implementation-defined* signed integer type
181
  that can hold the difference of two subscripts in an array object, as
182
  described in  [[expr.add]].
183
 
184
  The type `size_t` is an *implementation-defined* unsigned integer type
185
  that is large enough to contain the size in bytes of any object.
186
 
187
+ [*Note 1*: It is recommended that implementations choose types for
188
+ `ptrdiff_t` and `size_t` whose integer conversion ranks ([[conv.rank]])
189
+ are no greater than that of `signed long int` unless a larger size is
190
+ necessary to contain all the possible values. — *end note*]
191
 
192
  The type `max_align_t` is a POD type whose alignment requirement is at
193
  least as great as that of every scalar type, and whose alignment
194
  requirement is supported in every context.
195
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
  Alignment ([[basic.align]]), Sizeof ([[expr.sizeof]]), Additive
197
+ operators ([[expr.add]]), Free store ([[class.free]]), and ISO C 7.19.
198
+
199
+ ### `byte` type operations <a id="support.types.byteops">[[support.types.byteops]]</a>
200
+
201
+ ``` cpp
202
+ template <class IntType>
203
+ constexpr byte& operator<<=(byte& b, IntType shift) noexcept;
204
+ ```
205
+
206
+ *Remarks:* This function shall not participate in overload resolution
207
+ unless `is_integral_v<IntType>` is `true`.
208
+
209
+ *Effects:* Equivalent to:
210
+ `return b = byte(static_cast<unsigned char>(b) << shift);`
211
+
212
+ ``` cpp
213
+ template <class IntType>
214
+ constexpr byte operator<<(byte b, IntType shift) noexcept;
215
+ ```
216
+
217
+ *Remarks:* This function shall not participate in overload resolution
218
+ unless `is_integral_v<IntType>` is `true`.
219
+
220
+ *Effects:* Equivalent to:
221
+ `return byte(static_cast<unsigned char>(b) << shift);`
222
+
223
+ ``` cpp
224
+ template <class IntType>
225
+ constexpr byte& operator>>=(byte& b, IntType shift) noexcept;
226
+ ```
227
+
228
+ *Remarks:* This function shall not participate in overload resolution
229
+ unless `is_integral_v<IntType>` is `true`.
230
+
231
+ *Effects:* Equivalent to:
232
+ `return b = byte(static_cast<unsigned char>(b) >> shift);`
233
+
234
+ ``` cpp
235
+ template <class IntType>
236
+ constexpr byte operator>>(byte b, IntType shift) noexcept;
237
+ ```
238
+
239
+ *Remarks:* This function shall not participate in overload resolution
240
+ unless `is_integral_v<IntType>` is `true`.
241
+
242
+ *Effects:* Equivalent to:
243
+ `return byte(static_cast<unsigned char>(b) >> shift);`
244
+
245
+ ``` cpp
246
+ constexpr byte& operator|=(byte& l, byte r) noexcept;
247
+ ```
248
+
249
+ *Effects:* Equivalent to:
250
+
251
+ ``` cpp
252
+ return l = byte(static_cast<unsigned char>(l) | static_cast<unsigned char>(r));
253
+ ```
254
+
255
+ ``` cpp
256
+ constexpr byte operator|(byte l, byte r) noexcept;
257
+ ```
258
+
259
+ *Effects:* Equivalent to:
260
+
261
+ ``` cpp
262
+ return byte(static_cast<unsigned char>(l) | static_cast<unsigned char>(r));
263
+ ```
264
+
265
+ ``` cpp
266
+ constexpr byte& operator&=(byte& l, byte r) noexcept;
267
+ ```
268
+
269
+ *Effects:* Equivalent to:
270
+
271
+ ``` cpp
272
+ return l = byte(static_cast<unsigned char>(l) & static_cast<unsigned char>(r));
273
+ ```
274
+
275
+ ``` cpp
276
+ constexpr byte operator&(byte l, byte r) noexcept;
277
+ ```
278
+
279
+ *Effects:* Equivalent to:
280
+
281
+ ``` cpp
282
+ return byte(static_cast<unsigned char>(l) & static_cast<unsigned char>(r));
283
+ ```
284
+
285
+ ``` cpp
286
+ constexpr byte& operator^=(byte& l, byte r) noexcept;
287
+ ```
288
+
289
+ *Effects:* Equivalent to:
290
+
291
+ ``` cpp
292
+ return l = byte(static_cast<unsigned char>(l) ^ static_cast<unsigned char>(r));
293
+ ```
294
+
295
+ ``` cpp
296
+ constexpr byte operator^(byte l, byte r) noexcept;
297
+ ```
298
+
299
+ *Effects:* Equivalent to:
300
+
301
+ ``` cpp
302
+ return byte(static_cast<unsigned char>(l) ^ static_cast<unsigned char>(r));
303
+ ```
304
+
305
+ ``` cpp
306
+ constexpr byte operator~(byte b) noexcept;
307
+ ```
308
+
309
+ *Effects:* Equivalent to: `return byte(s̃tatic_cast<unsigned char>(b));`
310
+
311
+ ``` cpp
312
+ template <class IntType>
313
+ constexpr IntType to_integer(byte b) noexcept;
314
+ ```
315
+
316
+ *Remarks:* This function shall not participate in overload resolution
317
+ unless `is_integral_v<IntType>` is `true`.
318
+
319
+ *Effects:* Equivalent to: `return IntType(b);`
320