-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathP3154R1.bs
644 lines (504 loc) · 27.1 KB
/
P3154R1.bs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
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
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
<pre class='metadata'>
Title: Deprecating signed character types in iostreams
Shortname: P3154
Revision: 1
Audience: LEWG
Status: P
Group: WG21
URL: http://wg21.link/P3154R1.html
Editor: Elias Kosunen, [email protected]
Abstract:
This paper proposes deprecating overloads under iostreams,
that take some variant of `signed char` or `unsigned char`,
and treat these as characters, rather than integers.
The behavior of these overloads is unexpected, especially
when using the aliases `int8_t` or `uint8_t`.
Date: 2024-05-20
Markup Shorthands: markdown yes
Max ToC Depth: 2
</pre>
Changelog {#changelog}
=========
Changes since R0 {#changelog-since-r0}
----------------
* Add a study on possible impact
* Update the code example in Motivation
* Add note about `char8_t` in C
* Add note about [[P0487R1]]
Motivation {#motivation}
==========
```cpp
#include <iostream>
#include <format>
int main() {
// Prints:
std::cout
<< static_cast< char>(48) << '\n' // 0
<< static_cast< signed char>(48) << '\n' // 0 (Proposing deprecation)
<< static_cast<unsigned char>(48) << '\n' // 0 (Proposing deprecation)
<< static_cast< int8_t>(48) << '\n' // 0 (Proposing deprecation)
<< static_cast< uint8_t>(48) << '\n' // 0 (Proposing deprecation)
<< static_cast< short>(48) << '\n' // 48
<< std::format("{}\n", static_cast< char>(48)) // 0
<< std::format("{}\n", static_cast< signed char>(48)) // 48
<< std::format("{}\n", static_cast<unsigned char>(48)) // 48
<< std::format("{}\n", static_cast< int8_t>(48)) // 48
<< std::format("{}\n", static_cast< uint8_t>(48)) // 48
<< std::format("{}\n", static_cast< short>(48)); // 48
}
```
There are overloads for `operator<<` for `basic_ostream`,
that take an `(un)signed char`, and a `const (un)signed char*`.
In addition, there are overloads for `operator>>` for `basic_istream`,
that take an `(un)signed char&` and an `(un)signed char (&)[N]`.
These overloads are specified to have equivalent behavior to
the non-signedness qualified overloads:
[[istream.extractors](https://eel.is/c++draft/istream.extractors)]
[[ostream.inserters.character](https://eel.is/c++draft/ostream.inserters.character)].
This is surprising. Per [[basic.fundamental](https://eel.is/c++draft/basic.fundamental#1)] p1 and p2:
> There are five <i>standard signed integer types</i>:
> "`signed char`", "`short int`", "`int`", "`long int`", and "`long long int`"...
> There may also be implementation-defined <i>extended signed integer types</i>.
> The standard and extended signed integer types are collectively called <i>signed integer types</i>.
>
> For each of the standard signed integer types,
> there exists a corresponding (but different) <i>standard unsigned integer type</i>:
> "`unsigned char`", "`unsigned short int`", "`unsigned int`", "`unsigned long int`", and "`unsigned long long int`"...
> Likewise, for each of the extended signed integer types, there exists a corresponding <i>extended unsigned integer types</i>.
> The standard and extended unsigned integer types are collectively called <i>unsigned integer types</i>.
Thus, `signed char` and `unsigned char` should be treated as integers, not as characters.
This is highlighted by the fact, that `int8_t` and `uint8_t`
are specified to be aliases to (un)signed integer types,
which are in practice going to be `signed char` and `unsigned char`.
Note:
The Solaris implementation is different, and defines `int8_t` to be `char` by default.
This is not conformant.
`signed char` and `unsigned char` are not character types.
Per [[basic.fundamental](https://eel.is/c++draft/basic.fundamental#11)] p11, since [[P2314R4]]:
> The types `char`, `wchar_t`, `char8_t`, `char16_t`, and `char32_t` are collectively called <i>character types</i>.
`signed char` and `unsigned char` are included in the set of <i>ordinary character types</i>
and <i>narrow character types</i> ([[basic.fundamental](https://eel.is/c++draft/basic.fundamental#7)] p7),
but these definitions are used for specifying alignment, padding, and <i>indeterminate values</i>
([[basic.indet](https://eel.is/c++draft/basic.indet)]),
and are arguably not related to characters in the sense of pieces of text.
`std::format` has already taken a step in the right direction here,
by treating `signed char` and `unsigned char` as integers.
It's specified to not give special treatment to these types,
but to use the standard definitions of (un)signed integer type
to determine whether a type is to be treated as an integer when formatting.
This paper proposes that these overloads in iostreams should be deprecated.
Impact {#impact}
======
It's difficult to find examples where this is the sought-after behavior, and would become deprecated with this change.
These snippets aren't easily greppable.
It's easy to find counter-examples, however, where workarounds have to be employed to insert or extract `signed char`s or `unsigned char`s
as integers. Some of them can be found with [isocpp.org codesearch](https://codesearch.isocpp.org/cgi-bin/cgi_ppsearch?q=%3C%3C+static_cast%3Cint%3E&search=Search)
by searching for `<< static_cast<int>` or `<< (int)`, although false positives there are very prevalent.
```cpp
/* ... */ << static_cast<int>(my_schar);
```
These overloads have existed since C++98.
The signature of `operator>>` for `basic_istream` was updated for C++20 in [[P0487R1]],
where these functions were changed to take `T (&)[N]` instead of `T*`, for safety reasons.
No other changes to these overloads have been made in standard C++.
<pre highlight=cpp>
// Changes in P0487, applied to C++20
template<class charT, class traits<ins>, size_t N</ins>>
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>&, <del>charT*</del><ins>charT(&)[N]</ins>);
template<class traits<ins>, size_t N</ins>>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, <del>unsigned char*</del><ins>unsigned char(&)[N]</ins>);
template<class traits<ins>, size_t N</ins>>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, <del>signed char*</del><ins>signed char(&)[N]</ins>);
</pre>
It should be noted, that the C standard has defined `char8_t` to be an alias (typedef) to `unsigned char`.
In C++, `char8_t` is a distinct type with an underlying type of `unsigned char`.
Impact study {#study}
------------
To gauge the potential impact of this deprecation,
the author tried building open source C++ code bases,
using a patched version of libc++.
Below are the instances where the overloads proposed for deprecation were used in these builds.
For reference, the author built
[tensorflow-lite](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite) and
[Tenzir](https://github.com/tenzir/tenzir) using a custom version of libc++ where these overloads
were marked as `= delete`d. These code bases number ~1½ MLoC in total, with a large number of dependencies,
are reasonably modern, and use iostreams.
<h4 id="study-abseil">Abseil</h4>
The [Abseil logging library](https://github.com/abseil/abseil-cpp/tree/master/absl/log) seems to
treat `signed char` and `unsigned char` as character types.
This is likely because the syntax used by the library is very similar to that
used by iostreams:
```cpp
signed char my_schar = 65;
LOG(ERROR) << my_schar;
// Will output:
// E0520 13:49:47.968463 123694 absl_log.cpp:8] A
// where the message itself is the 'A' here -----^
```
Internally in the library, this is achieved with this overload set:
```cpp
// Abseil, version 20230802.1:
// absl/log/internal/check_op.cc
void MakeCheckOpValueString(std::ostream& os, const char v) {
if (v >= 32 && v <= 128) {
os << "'" << v << "'";
} else {
os << "char value " << int{v};
}
}
void MakeCheckOpValueString(std::ostream& os, const signed char v) {
if (v >= 32 && v <= 128) {
os << "'" << v << "'";
} else {
os << "signed char value " << int{v};
}
}
void MakeCheckOpValueString(std::ostream& os, const unsigned char v) {
if (v >= 32 && v <= 128) {
os << "'" << v << "'";
} else {
os << "unsigned char value " << int{v};
}
}
```
where `signed char` and `unsigned char` are explicitly and intentionally
treated similarly to `char`, and are passed to an underlying `std::ostream`.
Notably, the values between `32` and `128` are really treated as character values,
as they are printed with `'single quotes around them'`, and are cast to integers otherwise.
<h4 id="study-flatbuffers">FlatBuffers</h4>
In the implementation of `flatc` (the FlatBuffers schema compiler), there's the following
function template:
```cpp
// Flatbuffers, version 23.5.26:
// src/annotated_binary_text_gen.cpp
template<typename T> std::string ToString(T value) {
if (std::is_floating_point<T>::value) {
std::stringstream ss;
ss << value;
return ss.value();
} else {
return std::to_string(value);
}
}
```
where the proposed-for-deprecation overload of `operator<<` is instantiated,
if `T` is `signed char` or `unsigned char`. The overloads are never actually called,
but because the above code is using `if` instead of `if constexpr`, the compiler
warns about usage, anyway.
The current behavior when using `signed char` or `unsigned char` is to use `std::to_string`,
which formats the value as an integer, as the overload `std::to_string(int)` is picked
in overload resolution.
<h4 id="study-simdjson">simdjson</h4>
The following piece of code is present in the implementation of
[simdjson](https://github.com/simdjson/simdjson/):
```cpp
// simdjson, version 3.9.1:
// include/simdjson/dom/document-inl.h
inline bool document::dump_raw_tape(std::ostream &os) const noexcept {
uint32_t string_length;
size_t tape_idx = 0;
uint64_t tape_val = tape[tape_idx];
uint8_t type = uint8_t(tape_val >> 56);
os << tape_idx << " : " << type;
// ...
os << tape_idx << " : " << type << "\t// pointing to " <<
// ...
if (type == 'r')
// ...
switch (type) {
case '"':
// ...
case 'l':
// ...
}
}
```
This member function is apparently intended to be used for debugging.
The `tape` referenced is a library-internal representation of a parsed JSON document.
Above, `type` has the type of `uint8_t`, but is clearly treated as a character type.
Its value is compared to character literals, and thus, when written to a `std::ostream`,
is intended to be formatted as a character. The proposed deprecation would break this.
<h4 id="study-yaml">yaml-cpp</h4>
In [yaml-cpp](https://github.com/jbeder/yaml-cpp), the following piece of code can be found,
where the `operator<<` overload is called with `signed char` and `unsigned char`:
```cpp
// yaml-cpp, version 0.8.0:
// include/yaml-cpp/node/convert.h
// Used with T=signed char and T=unsigned char
template <typename T>
typename std::enable_if<!std::is_floating_point<T>::value, void>::type
inner_encode(const T& rhs, std::stringstream& stream){
stream << rhs;
}
```
This function template is instantiated and called when writing to an existing YAML document:
```cpp
signed char my_schar = 65;
unsigned char my_uchar = 65;
auto node = YAML::Load("{schar: 0, uchar: 0}");
node["schar"] = my_schar;
node["uchar"] = my_uchar;
std::cout << node;
// Outputs: {schar: A, uchar: A}
```
It's unclear whether treating `signed char` as a character type here is the desired behavior,
or simply an oversight caused by the usage of `std::stringstream`.
Elsewhere in the library, `signed char` is treated unambiguously as an integer,
whereas `unsigned char` is treated as a character:
```cpp
signed char my_schar = 65;
unsigned char my_uchar = 65;
YAML::Emitter out;
out << YAML::BeginMap
<< YAML::Key << "schar"
<< YAML::Value << my_schar
<< YAML::Key << "uchar"
<< YAML::Value << my_uchar
<< YAML::EndMap;
std::cout << out.c_str();
// Outputs:
// schar: 65
// uchar: A
```
There are two
[long-standing](https://github.com/jbeder/yaml-cpp/issues/1245)
[issues](https://github.com/jbeder/yaml-cpp/issues/1081)
against yaml-cpp to inquire about this inconsistency,
without a resolution before the mailing deadline.
<h4 id="study-conclusion">Conclusion</h4>
Only four instances of use were found during this study, which is not a lot.
Notably, only uses of `operator<<` taking a `signed char` or `unsigned char` were found.
No uses of the array-version of `operator<<` or any of the `operator>>` overloads were identified.
In these four cases:
* One (probably) contained a bug, which could have been identified with the deprecation proposed here [[#study-yaml]]
* One was essentially a false-positive, where the deprecated overloads were never called, only instantiated [[#study-flatbuffers]]
* Two were cases were the deprecated behavior was the desired one [[#study-abseil]] [[#study-simdjson]]
So, the use in the wild for these overloads seems to be quite limited.
In some cases, the current behavior is asked for, but it's difficult to ascertain whether the developers writing that code
initially got tripped up by this behavior.
With this deprecation, at least a single possible bug was identified, and it's possible even more could be found,
once developers are forced to check their usages as their compilers start warning them.
If anything, forcing users to cast to `char`/`int`/`unsigned` could be argued to be an increase in readability,
in favor of relying on the current behavior with `signed char` and `unsigned char`.
Wording {#wording}
=======
This wording is relative to [[N4971]].
Modify [[istream.general](https://eel.is/c++draft/istream.general#1)] p1
------------------------------------------------------------------------
<pre highlight=cpp>
// ...
// [istream.extractors], character extraction templates
template<class charT, class traits>
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>&, charT&);
<del>template<class traits>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, unsigned char&);
template<class traits>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, signed char&);</del>
template<class charT, class traits, size_t N>
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>&, charT(&)[N]);
<del>template<class traits, size_t N>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, unsigned char(&)[N]);
template<class traits, size_t N>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, signed char(&)[N]);</del>
</pre>
Modify [[istream.extractors](https://eel.is/c++draft/istream.extractors)], around p7 to p12
------------------------------------------------------------------------
<pre highlight=cpp>
template<class charT, class traits, size_t N>
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>&, charT(&)[N]);
<del>template<class traits, size_t N>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, unsigned char(&)[N]);
template<class traits, size_t N>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, signed char(&)[N]);</del>
</pre>
<i>Effects:</i> Behaves like a formatted input member (as described in [istream.formatted.reqmts]) of `in`.
After a sentry object is constructed, `operator>>` extracts characters and stores them into `s`.
If `width()` is greater than zero, `n` is `min(size_t(width()), N)`.
Otherwise `n` is `N`.
`n` is the maximum number of characters stored.
Characters are extracted and stored until any of the following occurs:
- `n-1` characters are stored;
- end of file occurs on the input sequence;
- letting `ct` be `use_facet<ctype<charT>>(in.getloc())`, `ct.is(ct.space, c)` is `true`.
`operator>>` then stores a null byte (`charT()`) in the next position, which may be the first position if no characters were extracted.
`operator>>` then calls `width(0)`.
If the function extracted no characters, `ios_base::failbit` is set in the input function's local error state before `setstate` is called.
<i>Returns:</i> `in`.
<pre highlight=cpp>
template<class charT, class traits>
basic_istream<charT, traits>& operator>>(basic_istream<charT, traits>&, charT&);
<del>template<class traits>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, unsigned char&);
template<class traits>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>&, signed char&);</del>
</pre>
<i>Effects:</i> Behaves like a formatted input member (as described in [istream.formatted.reqmts]) of `in`.
A character is extracted from `in`, if one is available, and stored in `c`.
Otherwise, `ios_base::failbit` is set in the input function's local error state before `setstate` is called.
<i>Returns:</i> `in`.
Modify [[ostream.general](https://eel.is/c++draft/ostream.general)] p1
----------------------------------------------------------------------
<pre highlight=cpp>
// ...
// [ostream.inserters.character], character inserters
template<class charT, class traits>
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, charT);
template<class charT, class traits>
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, char);
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char);
<del>template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, signed char);
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, unsigned char);</del>
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, wchar_t) = delete;
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char8_t) = delete;
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char16_t) = delete;
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char32_t) = delete;
template<class traits>
basic_ostream<wchar_t, traits>&
operator<<(basic_ostream<wchar_t, traits>&, char8_t) = delete;
template<class traits>
basic_ostream<wchar_t, traits>&
operator<<(basic_ostream<wchar_t, traits>&, char16_t) = delete;
template<class traits>
basic_ostream<wchar_t, traits>&
operator<<(basic_ostream<wchar_t, traits>&, char32_t) = delete;
template<class charT, class traits>
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, const charT*);
template<class charT, class traits>
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, const char*);
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char*);
<del>template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const signed char*);
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const unsigned char*);</del>
template<class traits>
basic_ostream<char, traits>&
operator<<(basic_ostream<char, traits>&, const wchar_t*) = delete;
template<class traits>
basic_ostream<char, traits>&
operator<<(basic_ostream<char, traits>&, const char8_t*) = delete;
template<class traits>
basic_ostream<char, traits>&
operator<<(basic_ostream<char, traits>&, const char16_t*) = delete;
template<class traits>
basic_ostream<char, traits>&
operator<<(basic_ostream<char, traits>&, const char32_t*) = delete;
template<class traits>
basic_ostream<wchar_t, traits>&
operator<<(basic_ostream<wchar_t, traits>&, const char8_t*) = delete;
template<class traits>
basic_ostream<wchar_t, traits>&
operator<<(basic_ostream<wchar_t, traits>&, const char16_t*) = delete;
template<class traits>
basic_ostream<wchar_t, traits>&
operator<<(basic_ostream<wchar_t, traits>&, const char32_t*) = delete;
// ...
</pre>
Modify [[ostream.inserters.character](https://eel.is/c++draft/ostream.inserters.character)]
-------------------------------------------------------------------------------------------
<pre highlight=cpp>
template<class charT, class traits>
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, charT);
template<class charT, class traits>
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, char);
// specialization
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, char);
// signed and unsigned
<del>template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, signed char);
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, unsigned char);</del>
</pre>
<i>Effects:</i> Behaves as a formatted output function of `out`.
Constructs a character sequence `seq`.
If `c` has type `char` and the character container type of the stream is not `char`,
then `seq` consists of `out.widen(c)`; otherwise `seq` consists of `c`.
Determines padding for `seq` as described in [ostream.formatted.reqmts].
Inserts `seq` into `out`.
Calls `os.width(0)`.
<i>Returns:</i> `out`.
<pre highlight=cpp>
template<class charT, class traits>
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, const charT*);
template<class charT, class traits>
basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>&, const char*);
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const char*);
<del>template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const signed char*);
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>&, const unsigned char*);</del>
</pre>
<i>Preconditions:</i> `s` is not a null pointer.
<i>Effects:</i> Behaves like a formatted inserter (as described in [ostream.formatted.reqmts]) of `out`.
Creates a character sequence `seq` of `n` characters starting at `s`, each widened using `out.widen()` ([basic.ios.members]),
where `n` is the number that would be computed as if by:
- `traits::length(s)` for the overload where the first argument is of type `basic_ostream<charT, traits>&` and
the second is of type `const charT*`, and also for the overload where the first argument is of type `basic_ostream<char, traits>&`
and the second is of type `const char*`,
- `char_traits<char>::length(s)` for the overload where the first argument is of type `basic_ostream<charT, traits>&` and
the second is of type `const char*`<ins>.</ins><del>,</del>
- <del>`traits::length(reinterpret_cast<const char*>(s))` for the other two overloads.</del>
Determines padding for `seq` as described in [ostream.formatted.reqmts].
Inserts `seq` into `out`.
Calls `width(0)`.
<i>Returns:</i> `out`.
Add a new subclause in Annex D after [[depr.atomics](https://eel.is/c++draft/depr.atomics)]
-------------------------------------------------------------------------------------------
<b>Deprecated `signed char` and `unsigned char` extraction [depr.istream.extractors]</b>
The following function overloads are declared in addition to those specified in [[istream.extractors](https://eel.is/c++draft/istream.extractors)]:
<pre highlight=cpp>
template<class traits>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, unsigned char& c);
template<class traits>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, signed char& c);
</pre>
<i>Effects:</i> Behaves like a formatted input member (as described in [istream.formatted.reqmts]) of `in`.
A character is extracted from `in`, if one is available, and stored in `c`.
Otherwise, `ios_base::failbit` is set in the input function's local error state before `setstate` is called.
<i>Returns:</i> `in`.
<pre highlight=cpp>
template<class traits, size_t N>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, unsigned char(&)[N] s);
template<class traits, size_t N>
basic_istream<char, traits>& operator>>(basic_istream<char, traits>& in, signed char(&)[N] s);
</pre>
<i>Effects:</i> Behaves like a formatted input member (as described in [istream.formatted.reqmts]) of `in`.
After a sentry object is constructed, `operator>>` extracts characters and stores them into `s`.
If `width()` is greater than zero, `n` is `min(size_t(width()), N)`.
Otherwise `n` is `N`.
`n` is the maximum number of characters stored.
Characters are extracted and stored until any of the following occurs:
- `n-1` characters are stored;
- end of file occurs on the input sequence;
- letting `ct` be `use_facet<ctype<charT>>(in.getloc())`, `ct.is(ct.space, c)` is `true`.
`operator>>` then stores a null byte (`charT()`) in the next position, which may be the first position if no characters were extracted.
`operator>>` then calls `width(0)`.
If the function extracted no characters, `ios_base::failbit` is set in the input function's local error state before `setstate` is called.
<i>Returns:</i> `in`.
Add a new subclause in Annex D after the above ([depr.istream.extractors])
--------------------------------------------------------------------------
<b>Deprecated `signed char` and `unsigned char` insertion [depr.ostream.inserters]</b>
The following function overloads are declared in addition to those specified in [[ostream.inserters](https://eel.is/c++draft/ostream.inserters.character)]:
<pre highlight=cpp>
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, signed char c);
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, unsigned char c);
</pre>
<i>Effects:</i> Equivalent to: `return out << static_cast<char>(c);`.
<pre highlight=cpp>
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, const signed char* s);
template<class traits>
basic_ostream<char, traits>& operator<<(basic_ostream<char, traits>& out, const unsigned char* s);
</pre>
<i>Effects:</i> Equivalent to: `return out << reinterpret_cast<const char*>(s);`.