From Jason Turner

[category.ctype]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpvcjsyp9b/{from.md → to.md} +71 -92
tmp/tmpvcjsyp9b/{from.md → to.md} RENAMED
@@ -2,11 +2,11 @@
2
 
3
  ``` cpp
4
  namespace std {
5
  class ctype_base {
6
  public:
7
- using mask = T;
8
 
9
  // numeric values are for exposition only.
10
  static const mask space = 1 << 0;
11
  static const mask print = 1 << 1;
12
  static const mask cntrl = 1 << 2;
@@ -21,11 +21,11 @@ namespace std {
21
  static const mask graph = alnum | punct;
22
  };
23
  }
24
  ```
25
 
26
- The type `mask` is a bitmask type ([[bitmask.types]]).
27
 
28
  #### Class template `ctype` <a id="locale.ctype">[[locale.ctype]]</a>
29
 
30
  ``` cpp
31
  namespace std {
@@ -73,35 +73,32 @@ namespace std {
73
 
74
  Class `ctype` encapsulates the C library `<cctype>` features. `istream`
75
  members are required to use `ctype<>` for character classing during
76
  input parsing.
77
 
78
- The specializations required in Table 
79
- [[tab:localization.category.facets]] ([[locale.category]]), namely
80
- `ctype<char>` and `ctype<wchar_t>`, implement character classing
81
- appropriate to the implementation’s native character set.
82
 
83
  ##### `ctype` members <a id="locale.ctype.members">[[locale.ctype.members]]</a>
84
 
85
  ``` cpp
86
  bool is(mask m, charT c) const;
87
- const charT* is(const charT* low, const charT* high,
88
- mask* vec) const;
89
  ```
90
 
91
  *Returns:* `do_is(m, c)` or `do_is(low, high, vec)`.
92
 
93
  ``` cpp
94
- const charT* scan_is(mask m,
95
- const charT* low, const charT* high) const;
96
  ```
97
 
98
  *Returns:* `do_scan_is(m, low, high)`.
99
 
100
  ``` cpp
101
- const charT* scan_not(mask m,
102
- const charT* low, const charT* high) const;
103
  ```
104
 
105
  *Returns:* `do_scan_not(m, low, high)`.
106
 
107
  ``` cpp
@@ -125,22 +122,20 @@ const char* widen(const char* low, const char* high, charT* to) const;
125
 
126
  *Returns:* `do_widen(c)` or `do_widen(low, high, to)`.
127
 
128
  ``` cpp
129
  char narrow(charT c, char dfault) const;
130
- const charT* narrow(const charT* low, const charT* high, char dfault,
131
- char* to) const;
132
  ```
133
 
134
  *Returns:* `do_narrow(c, dfault)` or `do_narrow(low, high, dfault, to)`.
135
 
136
  ##### `ctype` virtual functions <a id="locale.ctype.virtuals">[[locale.ctype.virtuals]]</a>
137
 
138
  ``` cpp
139
  bool do_is(mask m, charT c) const;
140
- const charT* do_is(const charT* low, const charT* high,
141
- mask* vec) const;
142
  ```
143
 
144
  *Effects:* Classifies a character or sequence of characters. For each
145
  argument character, identifies a value `M` of type `ctype_base::mask`.
146
  The second form identifies a value `M` of type `ctype_base::mask` for
@@ -198,18 +193,17 @@ which a corresponding lower-case character exists, with that character.
198
  if it is known to exist, or its argument if not. The second form returns
199
  `high`.
200
 
201
  ``` cpp
202
  charT do_widen(char c) const;
203
- const char* do_widen(const char* low, const char* high,
204
- charT* dest) const;
205
  ```
206
 
207
  *Effects:* Applies the simplest reasonable transformation from a `char`
208
  value or sequence of `char` values to the corresponding `charT` value or
209
  values.[^5] The only characters for which unique transformations are
210
- required are those in the basic source character set ([[lex.charset]]).
211
 
212
  For any named `ctype` category with a `ctype <charT>` facet `ctc` and
213
  valid `ctype_base::mask` value `M`,
214
  `(ctc.is(M, c) || !is(M, do_widen(c)) )` is `true`.[^6]
215
 
@@ -219,20 +213,19 @@ The second form transforms each character `*p` in the range \[`low`,
219
  *Returns:* The first form returns the transformed value. The second form
220
  returns `high`.
221
 
222
  ``` cpp
223
  char do_narrow(charT c, char dfault) const;
224
- const charT* do_narrow(const charT* low, const charT* high,
225
- char dfault, char* dest) const;
226
  ```
227
 
228
  *Effects:* Applies the simplest reasonable transformation from a `charT`
229
  value or sequence of `charT` values to the corresponding `char` value or
230
  values.
231
 
232
- For any character `c` in the basic source character
233
- set ([[lex.charset]]) the transformation is such that
234
 
235
  ``` cpp
236
  do_widen(do_narrow(c, 0)) == c
237
  ```
238
 
@@ -261,45 +254,42 @@ namespace std {
261
  class ctype_byname : public ctype<charT> {
262
  public:
263
  using mask = typename ctype<charT>::mask;
264
  explicit ctype_byname(const char*, size_t refs = 0);
265
  explicit ctype_byname(const string&, size_t refs = 0);
 
266
  protected:
267
  ~ctype_byname();
268
  };
269
  }
270
  ```
271
 
272
- #### `ctype` specializations <a id="facet.ctype.special">[[facet.ctype.special]]</a>
273
 
274
  ``` cpp
275
  namespace std {
276
  template<>
277
  class ctype<char> : public locale::facet, public ctype_base {
278
  public:
279
  using char_type = char;
280
 
281
- explicit ctype(const mask* tab = 0, bool del = false,
282
- size_t refs = 0);
283
 
284
  bool is(mask m, char c) const;
285
  const char* is(const char* low, const char* high, mask* vec) const;
286
- const char* scan_is (mask m,
287
- const char* low, const char* high) const;
288
- const char* scan_not(mask m,
289
- const char* low, const char* high) const;
290
 
291
  char toupper(char c) const;
292
  const char* toupper(char* low, const char* high) const;
293
  char tolower(char c) const;
294
  const char* tolower(char* low, const char* high) const;
295
 
296
  char widen(char c) const;
297
  const char* widen(const char* low, const char* high, char* to) const;
298
  char narrow(char c, char dfault) const;
299
- const char* narrow(const char* low, const char* high, char dfault,
300
- char* to) const;
301
 
302
  static locale::id id;
303
  static const size_t table_size = implementation-defined;
304
 
305
  const mask* table() const noexcept;
@@ -311,66 +301,60 @@ namespace std {
311
  virtual const char* do_toupper(char* low, const char* high) const;
312
  virtual char do_tolower(char c) const;
313
  virtual const char* do_tolower(char* low, const char* high) const;
314
 
315
  virtual char do_widen(char c) const;
316
- virtual const char* do_widen(const char* low,
317
- const char* high,
318
- char* to) const;
319
  virtual char do_narrow(char c, char dfault) const;
320
- virtual const char* do_narrow(const char* low,
321
- const char* high,
322
  char dfault, char* to) const;
323
  };
324
  }
325
  ```
326
 
327
  A specialization `ctype<char>` is provided so that the member functions
328
- on type `char` can be implemented `inline`.[^7] The
329
  *implementation-defined* value of member `table_size` is at least 256.
330
 
331
- ##### `ctype<char>` destructor <a id="facet.ctype.char.dtor">[[facet.ctype.char.dtor]]</a>
332
 
333
  ``` cpp
334
  ~ctype();
335
  ```
336
 
337
  *Effects:* If the constructor’s first argument was nonzero, and its
338
  second argument was `true`, does `delete [] table()`.
339
 
340
- ##### `ctype<char>` members <a id="facet.ctype.char.members">[[facet.ctype.char.members]]</a>
341
 
342
  In the following member descriptions, for `unsigned char` values `v`
343
  where `v >= table_size`, `table()[v]` is assumed to have an
344
  implementation-specific value (possibly different for each such value
345
  `v`) without performing the array lookup.
346
 
347
  ``` cpp
348
- explicit ctype(const mask* tbl = 0, bool del = false,
349
- size_t refs = 0);
350
  ```
351
 
352
- *Requires:* `tbl` either 0 or an array of at least `table_size`
353
- elements.
354
 
355
  *Effects:* Passes its `refs` argument to its base class constructor.
356
 
357
  ``` cpp
358
  bool is(mask m, char c) const;
359
- const char* is(const char* low, const char* high,
360
- mask* vec) const;
361
  ```
362
 
363
  *Effects:* The second form, for all `*p` in the range \[`low`, `high`),
364
  assigns into `vec[p - low]` the value `table()[(unsigned char)*p]`.
365
 
366
  *Returns:* The first form returns `table()[(unsigned char)c] & m`; the
367
  second form returns `high`.
368
 
369
  ``` cpp
370
- const char* scan_is(mask m,
371
- const char* low, const char* high) const;
372
  ```
373
 
374
  *Returns:* The smallest `p` in the range \[`low`, `high`) such that
375
 
376
  ``` cpp
@@ -378,12 +362,11 @@ table()[(unsigned char) *p] & m
378
  ```
379
 
380
  is `true`.
381
 
382
  ``` cpp
383
- const char* scan_not(mask m,
384
- const char* low, const char* high) const;
385
  ```
386
 
387
  *Returns:* The smallest `p` in the range \[`low`, `high`) such that
388
 
389
  ``` cpp
@@ -406,20 +389,18 @@ const char* tolower(char* low, const char* high) const;
406
 
407
  *Returns:* `do_tolower(c)` or `do_tolower(low, high)`, respectively.
408
 
409
  ``` cpp
410
  char widen(char c) const;
411
- const char* widen(const char* low, const char* high,
412
- char* to) const;
413
  ```
414
 
415
  *Returns:* `do_widen(c)` or `do_widen(low, high, to)`, respectively.
416
 
417
  ``` cpp
418
  char narrow(char c, char dfault) const;
419
- const char* narrow(const char* low, const char* high,
420
- char dfault, char* to) const;
421
  ```
422
 
423
  *Returns:* `do_narrow(c, dfault)` or `do_narrow(low, high, dfault, to)`,
424
  respectively.
425
 
@@ -428,40 +409,37 @@ const mask* table() const noexcept;
428
  ```
429
 
430
  *Returns:* The first constructor argument, if it was nonzero, otherwise
431
  `classic_table()`.
432
 
433
- ##### `ctype<char>` static members <a id="facet.ctype.char.statics">[[facet.ctype.char.statics]]</a>
434
 
435
  ``` cpp
436
  static const mask* classic_table() noexcept;
437
  ```
438
 
439
  *Returns:* A pointer to the initial element of an array of size
440
  `table_size` which represents the classifications of characters in the
441
  `"C"` locale.
442
 
443
- ##### `ctype<char>` virtual functions <a id="facet.ctype.char.virtuals">[[facet.ctype.char.virtuals]]</a>
444
 
445
  ``` cpp
446
  char do_toupper(char) const;
447
  const char* do_toupper(char* low, const char* high) const;
448
  char do_tolower(char) const;
449
  const char* do_tolower(char* low, const char* high) const;
450
 
451
  virtual char do_widen(char c) const;
452
- virtual const char* do_widen(const char* low,
453
- const char* high,
454
- char* to) const;
455
  virtual char do_narrow(char c, char dfault) const;
456
- virtual const char* do_narrow(const char* low,
457
- const char* high,
458
  char dfault, char* to) const;
459
  ```
460
 
461
  These functions are described identically as those members of the same
462
- name in the `ctype` class template ([[locale.ctype.members]]).
463
 
464
  #### Class template `codecvt` <a id="locale.codecvt">[[locale.codecvt]]</a>
465
 
466
  ``` cpp
467
  namespace std {
@@ -522,33 +500,32 @@ namespace std {
522
  }
523
  ```
524
 
525
  The class `codecvt<internT, externT, stateT>` is for use when converting
526
  from one character encoding to another, such as from wide characters to
527
- multibyte characters or between wide character encodings such as Unicode
528
  and EUC.
529
 
530
  The `stateT` argument selects the pair of character encodings being
531
  mapped between.
532
 
533
- The specializations required in Table 
534
- [[tab:localization.category.facets]] ([[locale.category]]) convert the
535
- implementation-defined native character set.
536
- `codecvt<char, char, mbstate_t>` implements a degenerate conversion; it
537
- does not convert at all. The specialization
538
- `codecvt<char16_t, char, mbstate_t>` converts between the UTF-16 and
539
  UTF-8 encoding forms, and the specialization `codecvt`
540
- `<char32_t, char, mbstate_t>` converts between the UTF-32 and UTF-8
541
  encoding forms. `codecvt<wchar_t, char, mbstate_t>` converts between the
542
- native character sets for narrow and wide characters. Specializations on
543
- `mbstate_t` perform conversion between encodings known to the library
544
  implementer. Other encodings can be converted by specializing on a
545
- user-defined `stateT` type. Objects of type `stateT` can contain any
546
  state that is useful to communicate to or from the specialized `do_in`
547
  or `do_out` members.
548
 
549
- ##### `codecvt` members <a id="locale.codecvt.members">[[locale.codecvt.members]]</a>
550
 
551
  ``` cpp
552
  result out(
553
  stateT& state,
554
  const internT* from, const internT* from_end, const internT*& from_next,
@@ -596,11 +573,11 @@ int length(stateT& state, const externT* from, const externT* from_end, size_t m
596
  int max_length() const noexcept;
597
  ```
598
 
599
  *Returns:* `do_max_length()`.
600
 
601
- ##### `codecvt` virtual functions <a id="locale.codecvt.virtuals">[[locale.codecvt.virtuals]]</a>
602
 
603
  ``` cpp
604
  result do_out(
605
  stateT& state,
606
  const internT* from, const internT* from_end, const internT*& from_next,
@@ -610,14 +587,14 @@ result do_in(
610
  stateT& state,
611
  const externT* from, const externT* from_end, const externT*& from_next,
612
  internT* to, internT* to_end, internT*& to_next) const;
613
  ```
614
 
615
- *Requires:* `(from <= from_end && to <= to_end)` well-defined and
616
- `true`; `state` initialized, if at the beginning of a sequence, or else
617
- equal to the result of converting the preceding characters in the
618
- sequence.
619
 
620
  *Effects:* Translates characters in the source range \[`from`,
621
  `from_end`), placing the results in sequential positions starting at
622
  destination `to`. Converts no more than `(from_end - from)` source
623
  elements, and stores no more than `(to_end - to)` destination elements.
@@ -628,12 +605,12 @@ element successfully converted. If returns `noconv`, `internT` and
628
  `externT` are the same type and the converted sequence is identical to
629
  the input sequence \[`from`, `from``next`). `to_next` is set equal to
630
  `to`, the value of `state` is unchanged, and there are no changes to the
631
  values in \[`to`, `to_end`).
632
 
633
- A `codecvt` facet that is used by `basic_filebuf` ([[file.streams]])
634
- shall have the property that if
635
 
636
  ``` cpp
637
  do_out(state, from, from_end, from_next, to, to_end, to_next)
638
  ```
639
 
@@ -666,13 +643,13 @@ shall also return `ok`.[^8]
666
  [*Note 2*: This argument can be used, for example, to maintain shift
667
  state, to specify conversion options (such as count only), or to
668
  identify a cache of seek offsets. — *end note*]
669
 
670
  *Returns:* An enumeration value, as summarized in
671
- Table  [[tab:localization.convert.result.values.out.in]].
672
 
673
- **Table: `do_in/do_out` result values** <a id="tab:localization.convert.result.values.out.in">[tab:localization.convert.result.values.out.in]</a>
674
 
675
  | Value | Meaning |
676
  | --------- | ------------------------------------------------------------------------------------------------ |
677
  | `ok` | completed the conversion |
678
  | `partial` | not all source characters converted |
@@ -687,24 +664,24 @@ before another destination element can be produced.
687
 
688
  ``` cpp
689
  result do_unshift(stateT& state, externT* to, externT* to_end, externT*& to_next) const;
690
  ```
691
 
692
- *Requires:* `(to <= to_end)` well defined and `true`; state initialized,
693
- if at the beginning of a sequence, or else equal to the result of
694
- converting the preceding characters in the sequence.
695
 
696
  *Effects:* Places characters starting at `to` that should be appended to
697
  terminate a sequence when the current `stateT` is given by `state`.[^9]
698
  Stores no more than `(to_end - to)` destination elements, and leaves the
699
  `to_next` pointer pointing one beyond the last element successfully
700
  stored.
701
 
702
  *Returns:* An enumeration value, as summarized in
703
- Table  [[tab:localization.convert.result.values.unshift]].
704
 
705
- **Table: `do_unshift` result values** <a id="tab:localization.convert.result.values.unshift">[tab:localization.convert.result.values.unshift]</a>
706
 
707
  | Value | Meaning |
708
  | --------- | -------------------------------------------------------------------------------------------------------------------- |
709
  | `ok` | completed the sequence |
710
  | `partial` | space for more than `to_end - to` destination elements was needed to terminate a sequence given the value of `state` |
@@ -729,15 +706,16 @@ valid argument values. `codecvt<char, char, mbstate_t>` returns `true`.
729
 
730
  ``` cpp
731
  int do_length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
732
  ```
733
 
734
- *Requires:* `(from <= from_end)` well-defined and `true`; `state`
735
- initialized, if at the beginning of a sequence, or else equal to the
736
- result of converting the preceding characters in the sequence.
 
737
 
738
- *Effects:* The effect on the `state` argument is as if it called
739
  `do_in(state, from, from_end, from, to, to+max, to)` for `to` pointing
740
  to a buffer of at least `max` elements.
741
 
742
  *Returns:* `(from_next-from)` where `from_next` is the largest value in
743
  the range \[`from`, `from_end`\] such that the sequence of values in the
@@ -762,10 +740,11 @@ namespace std {
762
  template<class internT, class externT, class stateT>
763
  class codecvt_byname : public codecvt<internT, externT, stateT> {
764
  public:
765
  explicit codecvt_byname(const char*, size_t refs = 0);
766
  explicit codecvt_byname(const string&, size_t refs = 0);
 
767
  protected:
768
  ~codecvt_byname();
769
  };
770
  }
771
  ```
 
2
 
3
  ``` cpp
4
  namespace std {
5
  class ctype_base {
6
  public:
7
+ using mask = see below;
8
 
9
  // numeric values are for exposition only.
10
  static const mask space = 1 << 0;
11
  static const mask print = 1 << 1;
12
  static const mask cntrl = 1 << 2;
 
21
  static const mask graph = alnum | punct;
22
  };
23
  }
24
  ```
25
 
26
+ The type `mask` is a bitmask type [[bitmask.types]].
27
 
28
  #### Class template `ctype` <a id="locale.ctype">[[locale.ctype]]</a>
29
 
30
  ``` cpp
31
  namespace std {
 
73
 
74
  Class `ctype` encapsulates the C library `<cctype>` features. `istream`
75
  members are required to use `ctype<>` for character classing during
76
  input parsing.
77
 
78
+ The specializations required in [[locale.category.facets]]
79
+ [[locale.category]], namely `ctype<char>` and `ctype<wchar_t>`,
80
+ implement character classing appropriate to the implementation’s native
81
+ character set.
82
 
83
  ##### `ctype` members <a id="locale.ctype.members">[[locale.ctype.members]]</a>
84
 
85
  ``` cpp
86
  bool is(mask m, charT c) const;
87
+ const charT* is(const charT* low, const charT* high, mask* vec) const;
 
88
  ```
89
 
90
  *Returns:* `do_is(m, c)` or `do_is(low, high, vec)`.
91
 
92
  ``` cpp
93
+ const charT* scan_is(mask m, const charT* low, const charT* high) const;
 
94
  ```
95
 
96
  *Returns:* `do_scan_is(m, low, high)`.
97
 
98
  ``` cpp
99
+ const charT* scan_not(mask m, const charT* low, const charT* high) const;
 
100
  ```
101
 
102
  *Returns:* `do_scan_not(m, low, high)`.
103
 
104
  ``` cpp
 
122
 
123
  *Returns:* `do_widen(c)` or `do_widen(low, high, to)`.
124
 
125
  ``` cpp
126
  char narrow(charT c, char dfault) const;
127
+ const charT* narrow(const charT* low, const charT* high, char dfault, char* to) const;
 
128
  ```
129
 
130
  *Returns:* `do_narrow(c, dfault)` or `do_narrow(low, high, dfault, to)`.
131
 
132
  ##### `ctype` virtual functions <a id="locale.ctype.virtuals">[[locale.ctype.virtuals]]</a>
133
 
134
  ``` cpp
135
  bool do_is(mask m, charT c) const;
136
+ const charT* do_is(const charT* low, const charT* high, mask* vec) const;
 
137
  ```
138
 
139
  *Effects:* Classifies a character or sequence of characters. For each
140
  argument character, identifies a value `M` of type `ctype_base::mask`.
141
  The second form identifies a value `M` of type `ctype_base::mask` for
 
193
  if it is known to exist, or its argument if not. The second form returns
194
  `high`.
195
 
196
  ``` cpp
197
  charT do_widen(char c) const;
198
+ const char* do_widen(const char* low, const char* high, charT* dest) const;
 
199
  ```
200
 
201
  *Effects:* Applies the simplest reasonable transformation from a `char`
202
  value or sequence of `char` values to the corresponding `charT` value or
203
  values.[^5] The only characters for which unique transformations are
204
+ required are those in the basic source character set [[lex.charset]].
205
 
206
  For any named `ctype` category with a `ctype <charT>` facet `ctc` and
207
  valid `ctype_base::mask` value `M`,
208
  `(ctc.is(M, c) || !is(M, do_widen(c)) )` is `true`.[^6]
209
 
 
213
  *Returns:* The first form returns the transformed value. The second form
214
  returns `high`.
215
 
216
  ``` cpp
217
  char do_narrow(charT c, char dfault) const;
218
+ const charT* do_narrow(const charT* low, const charT* high, char dfault, char* dest) const;
 
219
  ```
220
 
221
  *Effects:* Applies the simplest reasonable transformation from a `charT`
222
  value or sequence of `charT` values to the corresponding `char` value or
223
  values.
224
 
225
+ For any character `c` in the basic source character set [[lex.charset]]
226
+ the transformation is such that
227
 
228
  ``` cpp
229
  do_widen(do_narrow(c, 0)) == c
230
  ```
231
 
 
254
  class ctype_byname : public ctype<charT> {
255
  public:
256
  using mask = typename ctype<charT>::mask;
257
  explicit ctype_byname(const char*, size_t refs = 0);
258
  explicit ctype_byname(const string&, size_t refs = 0);
259
+
260
  protected:
261
  ~ctype_byname();
262
  };
263
  }
264
  ```
265
 
266
+ #### `ctype<char>` specialization <a id="facet.ctype.special">[[facet.ctype.special]]</a>
267
 
268
  ``` cpp
269
  namespace std {
270
  template<>
271
  class ctype<char> : public locale::facet, public ctype_base {
272
  public:
273
  using char_type = char;
274
 
275
+ explicit ctype(const mask* tab = nullptr, bool del = false, size_t refs = 0);
 
276
 
277
  bool is(mask m, char c) const;
278
  const char* is(const char* low, const char* high, mask* vec) const;
279
+ const char* scan_is (mask m, const char* low, const char* high) const;
280
+ const char* scan_not(mask m, const char* low, const char* high) const;
 
 
281
 
282
  char toupper(char c) const;
283
  const char* toupper(char* low, const char* high) const;
284
  char tolower(char c) const;
285
  const char* tolower(char* low, const char* high) const;
286
 
287
  char widen(char c) const;
288
  const char* widen(const char* low, const char* high, char* to) const;
289
  char narrow(char c, char dfault) const;
290
+ const char* narrow(const char* low, const char* high, char dfault, char* to) const;
 
291
 
292
  static locale::id id;
293
  static const size_t table_size = implementation-defined;
294
 
295
  const mask* table() const noexcept;
 
301
  virtual const char* do_toupper(char* low, const char* high) const;
302
  virtual char do_tolower(char c) const;
303
  virtual const char* do_tolower(char* low, const char* high) const;
304
 
305
  virtual char do_widen(char c) const;
306
+ virtual const char* do_widen(const char* low, const char* high, char* to) const;
 
 
307
  virtual char do_narrow(char c, char dfault) const;
308
+ virtual const char* do_narrow(const char* low, const char* high,
 
309
  char dfault, char* to) const;
310
  };
311
  }
312
  ```
313
 
314
  A specialization `ctype<char>` is provided so that the member functions
315
+ on type `char` can be implemented inline.[^7] The
316
  *implementation-defined* value of member `table_size` is at least 256.
317
 
318
+ ##### Destructor <a id="facet.ctype.char.dtor">[[facet.ctype.char.dtor]]</a>
319
 
320
  ``` cpp
321
  ~ctype();
322
  ```
323
 
324
  *Effects:* If the constructor’s first argument was nonzero, and its
325
  second argument was `true`, does `delete [] table()`.
326
 
327
+ ##### Members <a id="facet.ctype.char.members">[[facet.ctype.char.members]]</a>
328
 
329
  In the following member descriptions, for `unsigned char` values `v`
330
  where `v >= table_size`, `table()[v]` is assumed to have an
331
  implementation-specific value (possibly different for each such value
332
  `v`) without performing the array lookup.
333
 
334
  ``` cpp
335
+ explicit ctype(const mask* tbl = nullptr, bool del = false, size_t refs = 0);
 
336
  ```
337
 
338
+ *Preconditions:* Either `tbl == nullptr` is `true` or \[`tbl`,
339
+ `tbl+table_size`) is a valid range.
340
 
341
  *Effects:* Passes its `refs` argument to its base class constructor.
342
 
343
  ``` cpp
344
  bool is(mask m, char c) const;
345
+ const char* is(const char* low, const char* high, mask* vec) const;
 
346
  ```
347
 
348
  *Effects:* The second form, for all `*p` in the range \[`low`, `high`),
349
  assigns into `vec[p - low]` the value `table()[(unsigned char)*p]`.
350
 
351
  *Returns:* The first form returns `table()[(unsigned char)c] & m`; the
352
  second form returns `high`.
353
 
354
  ``` cpp
355
+ const char* scan_is(mask m, const char* low, const char* high) const;
 
356
  ```
357
 
358
  *Returns:* The smallest `p` in the range \[`low`, `high`) such that
359
 
360
  ``` cpp
 
362
  ```
363
 
364
  is `true`.
365
 
366
  ``` cpp
367
+ const char* scan_not(mask m, const char* low, const char* high) const;
 
368
  ```
369
 
370
  *Returns:* The smallest `p` in the range \[`low`, `high`) such that
371
 
372
  ``` cpp
 
389
 
390
  *Returns:* `do_tolower(c)` or `do_tolower(low, high)`, respectively.
391
 
392
  ``` cpp
393
  char widen(char c) const;
394
+ const char* widen(const char* low, const char* high, char* to) const;
 
395
  ```
396
 
397
  *Returns:* `do_widen(c)` or `do_widen(low, high, to)`, respectively.
398
 
399
  ``` cpp
400
  char narrow(char c, char dfault) const;
401
+ const char* narrow(const char* low, const char* high, char dfault, char* to) const;
 
402
  ```
403
 
404
  *Returns:* `do_narrow(c, dfault)` or `do_narrow(low, high, dfault, to)`,
405
  respectively.
406
 
 
409
  ```
410
 
411
  *Returns:* The first constructor argument, if it was nonzero, otherwise
412
  `classic_table()`.
413
 
414
+ ##### Static members <a id="facet.ctype.char.statics">[[facet.ctype.char.statics]]</a>
415
 
416
  ``` cpp
417
  static const mask* classic_table() noexcept;
418
  ```
419
 
420
  *Returns:* A pointer to the initial element of an array of size
421
  `table_size` which represents the classifications of characters in the
422
  `"C"` locale.
423
 
424
+ ##### Virtual functions <a id="facet.ctype.char.virtuals">[[facet.ctype.char.virtuals]]</a>
425
 
426
  ``` cpp
427
  char do_toupper(char) const;
428
  const char* do_toupper(char* low, const char* high) const;
429
  char do_tolower(char) const;
430
  const char* do_tolower(char* low, const char* high) const;
431
 
432
  virtual char do_widen(char c) const;
433
+ virtual const char* do_widen(const char* low, const char* high, char* to) const;
 
 
434
  virtual char do_narrow(char c, char dfault) const;
435
+ virtual const char* do_narrow(const char* low, const char* high,
 
436
  char dfault, char* to) const;
437
  ```
438
 
439
  These functions are described identically as those members of the same
440
+ name in the `ctype` class template [[locale.ctype.members]].
441
 
442
  #### Class template `codecvt` <a id="locale.codecvt">[[locale.codecvt]]</a>
443
 
444
  ``` cpp
445
  namespace std {
 
500
  }
501
  ```
502
 
503
  The class `codecvt<internT, externT, stateT>` is for use when converting
504
  from one character encoding to another, such as from wide characters to
505
+ multibyte characters or between wide character encodings such as UTF-32
506
  and EUC.
507
 
508
  The `stateT` argument selects the pair of character encodings being
509
  mapped between.
510
 
511
+ The specializations required in [[locale.category.facets]]
512
+ [[locale.category]] convert the implementation-defined native character
513
+ set. `codecvt<char, char, mbstate_t>` implements a degenerate
514
+ conversion; it does not convert at all. The specialization
515
+ `codecvt<char16_t, char8_t, mbstate_t>` converts between the UTF-16 and
 
516
  UTF-8 encoding forms, and the specialization `codecvt`
517
+ `<char32_t, char8_t, mbstate_t>` converts between the UTF-32 and UTF-8
518
  encoding forms. `codecvt<wchar_t, char, mbstate_t>` converts between the
519
+ native character sets for ordinary and wide characters. Specializations
520
+ on `mbstate_t` perform conversion between encodings known to the library
521
  implementer. Other encodings can be converted by specializing on a
522
+ program-defined `stateT` type. Objects of type `stateT` can contain any
523
  state that is useful to communicate to or from the specialized `do_in`
524
  or `do_out` members.
525
 
526
+ ##### Members <a id="locale.codecvt.members">[[locale.codecvt.members]]</a>
527
 
528
  ``` cpp
529
  result out(
530
  stateT& state,
531
  const internT* from, const internT* from_end, const internT*& from_next,
 
573
  int max_length() const noexcept;
574
  ```
575
 
576
  *Returns:* `do_max_length()`.
577
 
578
+ ##### Virtual functions <a id="locale.codecvt.virtuals">[[locale.codecvt.virtuals]]</a>
579
 
580
  ``` cpp
581
  result do_out(
582
  stateT& state,
583
  const internT* from, const internT* from_end, const internT*& from_next,
 
587
  stateT& state,
588
  const externT* from, const externT* from_end, const externT*& from_next,
589
  internT* to, internT* to_end, internT*& to_next) const;
590
  ```
591
 
592
+ *Preconditions:* `(from <= from_end && to <= to_end)` is well-defined
593
+ and `true`; `state` is initialized, if at the beginning of a sequence,
594
+ or else is equal to the result of converting the preceding characters in
595
+ the sequence.
596
 
597
  *Effects:* Translates characters in the source range \[`from`,
598
  `from_end`), placing the results in sequential positions starting at
599
  destination `to`. Converts no more than `(from_end - from)` source
600
  elements, and stores no more than `(to_end - to)` destination elements.
 
605
  `externT` are the same type and the converted sequence is identical to
606
  the input sequence \[`from`, `from``next`). `to_next` is set equal to
607
  `to`, the value of `state` is unchanged, and there are no changes to the
608
  values in \[`to`, `to_end`).
609
 
610
+ A `codecvt` facet that is used by `basic_filebuf` [[file.streams]] shall
611
+ have the property that if
612
 
613
  ``` cpp
614
  do_out(state, from, from_end, from_next, to, to_end, to_next)
615
  ```
616
 
 
643
  [*Note 2*: This argument can be used, for example, to maintain shift
644
  state, to specify conversion options (such as count only), or to
645
  identify a cache of seek offsets. — *end note*]
646
 
647
  *Returns:* An enumeration value, as summarized in
648
+ [[locale.codecvt.inout]].
649
 
650
+ **Table: `do_in/do_out` result values** <a id="locale.codecvt.inout">[locale.codecvt.inout]</a>
651
 
652
  | Value | Meaning |
653
  | --------- | ------------------------------------------------------------------------------------------------ |
654
  | `ok` | completed the conversion |
655
  | `partial` | not all source characters converted |
 
664
 
665
  ``` cpp
666
  result do_unshift(stateT& state, externT* to, externT* to_end, externT*& to_next) const;
667
  ```
668
 
669
+ *Preconditions:* `(to <= to_end)` is well-defined and `true`; `state` is
670
+ initialized, if at the beginning of a sequence, or else is equal to the
671
+ result of converting the preceding characters in the sequence.
672
 
673
  *Effects:* Places characters starting at `to` that should be appended to
674
  terminate a sequence when the current `stateT` is given by `state`.[^9]
675
  Stores no more than `(to_end - to)` destination elements, and leaves the
676
  `to_next` pointer pointing one beyond the last element successfully
677
  stored.
678
 
679
  *Returns:* An enumeration value, as summarized in
680
+ [[locale.codecvt.unshift]].
681
 
682
+ **Table: `do_unshift` result values** <a id="locale.codecvt.unshift">[locale.codecvt.unshift]</a>
683
 
684
  | Value | Meaning |
685
  | --------- | -------------------------------------------------------------------------------------------------------------------- |
686
  | `ok` | completed the sequence |
687
  | `partial` | space for more than `to_end - to` destination elements was needed to terminate a sequence given the value of `state` |
 
706
 
707
  ``` cpp
708
  int do_length(stateT& state, const externT* from, const externT* from_end, size_t max) const;
709
  ```
710
 
711
+ *Preconditions:* `(from <= from_end)` is well-defined and `true`;
712
+ `state` is initialized, if at the beginning of a sequence, or else is
713
+ equal to the result of converting the preceding characters in the
714
+ sequence.
715
 
716
+ *Effects:* The effect on the `state` argument is as if it called
717
  `do_in(state, from, from_end, from, to, to+max, to)` for `to` pointing
718
  to a buffer of at least `max` elements.
719
 
720
  *Returns:* `(from_next-from)` where `from_next` is the largest value in
721
  the range \[`from`, `from_end`\] such that the sequence of values in the
 
740
  template<class internT, class externT, class stateT>
741
  class codecvt_byname : public codecvt<internT, externT, stateT> {
742
  public:
743
  explicit codecvt_byname(const char*, size_t refs = 0);
744
  explicit codecvt_byname(const string&, size_t refs = 0);
745
+
746
  protected:
747
  ~codecvt_byname();
748
  };
749
  }
750
  ```