From Jason Turner

[category.ctype]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpeam004yy/{from.md → to.md} +48 -51
tmp/tmpeam004yy/{from.md → to.md} RENAMED
@@ -1,37 +1,37 @@
1
- ### The `ctype` category <a id="category.ctype">[[category.ctype]]</a>
2
 
3
- #### General <a id="category.ctype.general">[[category.ctype.general]]</a>
4
 
5
  ``` cpp
6
  namespace std {
7
  class ctype_base {
8
  public:
9
  using mask = see below;
10
 
11
  // numeric values are for exposition only.
12
- static const mask space = 1 << 0;
13
- static const mask print = 1 << 1;
14
- static const mask cntrl = 1 << 2;
15
- static const mask upper = 1 << 3;
16
- static const mask lower = 1 << 4;
17
- static const mask alpha = 1 << 5;
18
- static const mask digit = 1 << 6;
19
- static const mask punct = 1 << 7;
20
- static const mask xdigit = 1 << 8;
21
- static const mask blank = 1 << 9;
22
- static const mask alnum = alpha | digit;
23
- static const mask graph = alnum | punct;
24
  };
25
  }
26
  ```
27
 
28
  The type `mask` is a bitmask type [[bitmask.types]].
29
 
30
- #### Class template `ctype` <a id="locale.ctype">[[locale.ctype]]</a>
31
 
32
- ##### General <a id="locale.ctype.general">[[locale.ctype.general]]</a>
33
 
34
  ``` cpp
35
  namespace std {
36
  template<class charT>
37
  class ctype : public locale::facet, public ctype_base {
@@ -82,11 +82,11 @@ input parsing.
82
  The specializations required in [[locale.category.facets]]
83
  [[locale.category]], namely `ctype<char>` and `ctype<wchar_t>`,
84
  implement character classing appropriate to the implementation’s native
85
  character set.
86
 
87
- ##### `ctype` members <a id="locale.ctype.members">[[locale.ctype.members]]</a>
88
 
89
  ``` cpp
90
  bool is(mask m, charT c) const;
91
  const charT* is(const charT* low, const charT* high, mask* vec) const;
92
  ```
@@ -104,11 +104,11 @@ const charT* scan_not(mask m, const charT* low, const charT* high) const;
104
  ```
105
 
106
  *Returns:* `do_scan_not(m, low, high)`.
107
 
108
  ``` cpp
109
- charT toupper(charT) const;
110
  const charT* toupper(charT* low, const charT* high) const;
111
  ```
112
 
113
  *Returns:* `do_toupper(c)` or `do_toupper(low, high)`.
114
 
@@ -131,11 +131,11 @@ char narrow(charT c, char dfault) const;
131
  const charT* narrow(const charT* low, const charT* high, char dfault, 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, mask* vec) const;
141
  ```
@@ -207,11 +207,11 @@ value or sequence of `char` values to the corresponding `charT` value or
207
  values.[^5]
208
 
209
  The only characters for which unique transformations are required are
210
  those in the basic 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
 
216
  The second form transforms each character `*p` in the range \[`low`,
217
  `high`), placing the result in `dest[p - low]`.
@@ -250,30 +250,30 @@ the result (or `dfault` if no simple transformation is readily
250
  available) in `dest[p - low]`.
251
 
252
  *Returns:* The first form returns the transformed value; or `dfault` if
253
  no mapping is readily available. The second form returns `high`.
254
 
255
- #### Class template `ctype_byname` <a id="locale.ctype.byname">[[locale.ctype.byname]]</a>
256
 
257
  ``` cpp
258
  namespace std {
259
  template<class charT>
260
  class ctype_byname : public ctype<charT> {
261
  public:
262
- using mask = typename ctype<charT>::mask;
263
  explicit ctype_byname(const char*, size_t refs = 0);
264
  explicit ctype_byname(const string&, size_t refs = 0);
265
 
266
  protected:
267
  ~ctype_byname();
268
  };
269
  }
270
  ```
271
 
272
- #### `ctype<char>` specialization <a id="facet.ctype.special">[[facet.ctype.special]]</a>
273
 
274
- ##### General <a id="facet.ctype.special.general">[[facet.ctype.special.general]]</a>
275
 
276
  ``` cpp
277
  namespace std {
278
  template<>
279
  class ctype<char> : public locale::facet, public ctype_base {
@@ -323,20 +323,20 @@ A specialization `ctype<char>` is provided so that the member functions
323
  on type `char` can be implemented inline.[^7]
324
 
325
  The *implementation-defined* value of member `table_size` is at least
326
  256.
327
 
328
- ##### Destructor <a id="facet.ctype.char.dtor">[[facet.ctype.char.dtor]]</a>
329
 
330
  ``` cpp
331
  ~ctype();
332
  ```
333
 
334
  *Effects:* If the constructor’s first argument was nonzero, and its
335
  second argument was `true`, does `delete [] table()`.
336
 
337
- ##### Members <a id="facet.ctype.char.members">[[facet.ctype.char.members]]</a>
338
 
339
  In the following member descriptions, for `unsigned char` values `v`
340
  where `v >= table_size`, `table()[v]` is assumed to have an
341
  implementation-specific value (possibly different for each such value
342
  `v`) without performing the array lookup.
@@ -419,21 +419,21 @@ const mask* table() const noexcept;
419
  ```
420
 
421
  *Returns:* The first constructor argument, if it was nonzero, otherwise
422
  `classic_table()`.
423
 
424
- ##### Static members <a id="facet.ctype.char.statics">[[facet.ctype.char.statics]]</a>
425
 
426
  ``` cpp
427
  static const mask* classic_table() noexcept;
428
  ```
429
 
430
  *Returns:* A pointer to the initial element of an array of size
431
  `table_size` which represents the classifications of characters in the
432
  `"C"` locale.
433
 
434
- ##### Virtual functions <a id="facet.ctype.char.virtuals">[[facet.ctype.char.virtuals]]</a>
435
 
436
  ``` cpp
437
  char do_toupper(char) const;
438
  const char* do_toupper(char* low, const char* high) const;
439
  char do_tolower(char) const;
@@ -447,13 +447,13 @@ virtual const char* do_narrow(const char* low, const char* high,
447
  ```
448
 
449
  These functions are described identically as those members of the same
450
  name in the `ctype` class template [[locale.ctype.members]].
451
 
452
- #### Class template `codecvt` <a id="locale.codecvt">[[locale.codecvt]]</a>
453
 
454
- ##### General <a id="locale.codecvt.general">[[locale.codecvt.general]]</a>
455
 
456
  ``` cpp
457
  namespace std {
458
  class codecvt_base {
459
  public:
@@ -521,23 +521,20 @@ The `stateT` argument selects the pair of character encodings being
521
  mapped between.
522
 
523
  The specializations required in [[locale.category.facets]]
524
  [[locale.category]] convert the implementation-defined native character
525
  set. `codecvt<char, char, mbstate_t>` implements a degenerate
526
- conversion; it does not convert at all. The specialization
527
- `codecvt<char16_t, char8_t, mbstate_t>` converts between the UTF-16 and
528
- UTF-8 encoding forms, and the specialization
529
- `codecvt<char32_t, char8_t, mbstate_t>` converts between the UTF-32 and
530
- UTF-8 encoding forms. `codecvt<wchar_t, char, mbstate_t>` converts
531
- between the native character sets for ordinary and wide characters.
532
- Specializations on `mbstate_t` perform conversion between encodings
533
- known to the library implementer. Other encodings can be converted by
534
- specializing on a program-defined `stateT` type. Objects of type
535
- `stateT` can contain any state that is useful to communicate to or from
536
- the specialized `do_in` or `do_out` members.
537
 
538
- ##### Members <a id="locale.codecvt.members">[[locale.codecvt.members]]</a>
539
 
540
  ``` cpp
541
  result out(
542
  stateT& state,
543
  const internT* from, const internT* from_end, const internT*& from_next,
@@ -585,11 +582,11 @@ int length(stateT& state, const externT* from, const externT* from_end, size_t m
585
  int max_length() const noexcept;
586
  ```
587
 
588
  *Returns:* `do_max_length()`.
589
 
590
- ##### Virtual functions <a id="locale.codecvt.virtuals">[[locale.codecvt.virtuals]]</a>
591
 
592
  ``` cpp
593
  result do_out(
594
  stateT& state,
595
  const internT* from, const internT* from_end, const internT*& from_next,
@@ -611,13 +608,13 @@ the sequence.
611
  destination `to`. Converts no more than `(from_end - from)` source
612
  elements, and stores no more than `(to_end - to)` destination elements.
613
 
614
  Stops if it encounters a character it cannot convert. It always leaves
615
  the `from_next` and `to_next` pointers pointing one beyond the last
616
- element successfully converted. If returns `noconv`, `internT` and
617
- `externT` are the same type and the converted sequence is identical to
618
- the input sequence \[`from`, `from``next`). `to_next` is set equal to
619
  `to`, the value of `state` is unchanged, and there are no changes to the
620
  values in \[`to`, `to_end`).
621
 
622
  A `codecvt` facet that is used by `basic_filebuf` [[file.streams]] shall
623
  have the property that if
@@ -728,14 +725,14 @@ sequence.
728
 
729
  *Effects:* The effect on the `state` argument is as if it called
730
  `do_in(state, from, from_end, from, to, to + max, to)` for `to` pointing
731
  to a buffer of at least `max` elements.
732
 
733
- *Returns:* `(from_next-from)` where `from_next` is the largest value in
734
- the range \[`from`, `from_end`\] such that the sequence of values in the
735
- range \[`from`, `from_next`) represents `max` or fewer valid complete
736
- characters of type `internT`. The specialization
737
  `codecvt<char, char, mbstate_t>`, returns the lesser of `max` and
738
  `(from_end - from)`.
739
 
740
  ``` cpp
741
  int do_max_length() const noexcept;
@@ -744,11 +741,11 @@ int do_max_length() const noexcept;
744
  *Returns:* The maximum value that `do_length(state, from, from_end, 1)`
745
  can return for any valid range \[`from`, `from_end`) and `stateT` value
746
  `state`. The specialization
747
  `codecvt<char, char, mbstate_t>::do_max_length()` returns 1.
748
 
749
- #### Class template `codecvt_byname` <a id="locale.codecvt.byname">[[locale.codecvt.byname]]</a>
750
 
751
  ``` cpp
752
  namespace std {
753
  template<class internT, class externT, class stateT>
754
  class codecvt_byname : public codecvt<internT, externT, stateT> {
 
1
+ #### The `ctype` category <a id="category.ctype">[[category.ctype]]</a>
2
 
3
+ ##### General <a id="category.ctype.general">[[category.ctype.general]]</a>
4
 
5
  ``` cpp
6
  namespace std {
7
  class ctype_base {
8
  public:
9
  using mask = see below;
10
 
11
  // numeric values are for exposition only.
12
+ static constexpr mask space = 1 << 0;
13
+ static constexpr mask print = 1 << 1;
14
+ static constexpr mask cntrl = 1 << 2;
15
+ static constexpr mask upper = 1 << 3;
16
+ static constexpr mask lower = 1 << 4;
17
+ static constexpr mask alpha = 1 << 5;
18
+ static constexpr mask digit = 1 << 6;
19
+ static constexpr mask punct = 1 << 7;
20
+ static constexpr mask xdigit = 1 << 8;
21
+ static constexpr mask blank = 1 << 9;
22
+ static constexpr mask alnum = alpha | digit;
23
+ static constexpr mask graph = alnum | punct;
24
  };
25
  }
26
  ```
27
 
28
  The type `mask` is a bitmask type [[bitmask.types]].
29
 
30
+ ##### Class template `ctype` <a id="locale.ctype">[[locale.ctype]]</a>
31
 
32
+ ###### General <a id="locale.ctype.general">[[locale.ctype.general]]</a>
33
 
34
  ``` cpp
35
  namespace std {
36
  template<class charT>
37
  class ctype : public locale::facet, public ctype_base {
 
82
  The specializations required in [[locale.category.facets]]
83
  [[locale.category]], namely `ctype<char>` and `ctype<wchar_t>`,
84
  implement character classing appropriate to the implementation’s native
85
  character set.
86
 
87
+ ###### `ctype` members <a id="locale.ctype.members">[[locale.ctype.members]]</a>
88
 
89
  ``` cpp
90
  bool is(mask m, charT c) const;
91
  const charT* is(const charT* low, const charT* high, mask* vec) const;
92
  ```
 
104
  ```
105
 
106
  *Returns:* `do_scan_not(m, low, high)`.
107
 
108
  ``` cpp
109
+ charT toupper(charT c) const;
110
  const charT* toupper(charT* low, const charT* high) const;
111
  ```
112
 
113
  *Returns:* `do_toupper(c)` or `do_toupper(low, high)`.
114
 
 
131
  const charT* narrow(const charT* low, const charT* high, char dfault, 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, mask* vec) const;
141
  ```
 
207
  values.[^5]
208
 
209
  The only characters for which unique transformations are required are
210
  those in the basic character set [[lex.charset]].
211
 
212
+ For any named `ctype` category with a `ctype<char>` facet `ctc` and
213
  valid `ctype_base::mask` value `M`,
214
  `(ctc.is(M, c) || !is(M, do_widen(c)) )` is `true`.[^6]
215
 
216
  The second form transforms each character `*p` in the range \[`low`,
217
  `high`), placing the result in `dest[p - low]`.
 
250
  available) in `dest[p - low]`.
251
 
252
  *Returns:* The first form returns the transformed value; or `dfault` if
253
  no mapping is readily available. The second form returns `high`.
254
 
255
+ ##### Class template `ctype_byname` <a id="locale.ctype.byname">[[locale.ctype.byname]]</a>
256
 
257
  ``` cpp
258
  namespace std {
259
  template<class charT>
260
  class ctype_byname : public ctype<charT> {
261
  public:
262
+ using mask = ctype<charT>::mask;
263
  explicit ctype_byname(const char*, size_t refs = 0);
264
  explicit ctype_byname(const string&, size_t refs = 0);
265
 
266
  protected:
267
  ~ctype_byname();
268
  };
269
  }
270
  ```
271
 
272
+ ##### `ctype<char>` specialization <a id="facet.ctype.special">[[facet.ctype.special]]</a>
273
 
274
+ ###### General <a id="facet.ctype.special.general">[[facet.ctype.special.general]]</a>
275
 
276
  ``` cpp
277
  namespace std {
278
  template<>
279
  class ctype<char> : public locale::facet, public ctype_base {
 
323
  on type `char` can be implemented inline.[^7]
324
 
325
  The *implementation-defined* value of member `table_size` is at least
326
  256.
327
 
328
+ ###### Destructor <a id="facet.ctype.char.dtor">[[facet.ctype.char.dtor]]</a>
329
 
330
  ``` cpp
331
  ~ctype();
332
  ```
333
 
334
  *Effects:* If the constructor’s first argument was nonzero, and its
335
  second argument was `true`, does `delete [] table()`.
336
 
337
+ ###### Members <a id="facet.ctype.char.members">[[facet.ctype.char.members]]</a>
338
 
339
  In the following member descriptions, for `unsigned char` values `v`
340
  where `v >= table_size`, `table()[v]` is assumed to have an
341
  implementation-specific value (possibly different for each such value
342
  `v`) without performing the array lookup.
 
419
  ```
420
 
421
  *Returns:* The first constructor argument, if it was nonzero, otherwise
422
  `classic_table()`.
423
 
424
+ ###### Static members <a id="facet.ctype.char.statics">[[facet.ctype.char.statics]]</a>
425
 
426
  ``` cpp
427
  static const mask* classic_table() noexcept;
428
  ```
429
 
430
  *Returns:* A pointer to the initial element of an array of size
431
  `table_size` which represents the classifications of characters in the
432
  `"C"` locale.
433
 
434
+ ###### Virtual functions <a id="facet.ctype.char.virtuals">[[facet.ctype.char.virtuals]]</a>
435
 
436
  ``` cpp
437
  char do_toupper(char) const;
438
  const char* do_toupper(char* low, const char* high) const;
439
  char do_tolower(char) const;
 
447
  ```
448
 
449
  These functions are described identically as those members of the same
450
  name in the `ctype` class template [[locale.ctype.members]].
451
 
452
+ ##### Class template `codecvt` <a id="locale.codecvt">[[locale.codecvt]]</a>
453
 
454
+ ###### General <a id="locale.codecvt.general">[[locale.codecvt.general]]</a>
455
 
456
  ``` cpp
457
  namespace std {
458
  class codecvt_base {
459
  public:
 
521
  mapped between.
522
 
523
  The specializations required in [[locale.category.facets]]
524
  [[locale.category]] convert the implementation-defined native character
525
  set. `codecvt<char, char, mbstate_t>` implements a degenerate
526
+ conversion; it does not convert at all.
527
+ `codecvt<wchar_t, char, mbstate_t>` converts between the native
528
+ character sets for ordinary and wide characters. Specializations on
529
+ `mbstate_t` perform conversion between encodings known to the library
530
+ implementer. Other encodings can be converted by specializing on a
531
+ program-defined `stateT` type. Objects of type `stateT` can contain any
532
+ state that is useful to communicate to or from the specialized `do_in`
533
+ or `do_out` members.
 
 
 
534
 
535
+ ###### Members <a id="locale.codecvt.members">[[locale.codecvt.members]]</a>
536
 
537
  ``` cpp
538
  result out(
539
  stateT& state,
540
  const internT* from, const internT* from_end, const internT*& from_next,
 
582
  int max_length() const noexcept;
583
  ```
584
 
585
  *Returns:* `do_max_length()`.
586
 
587
+ ###### Virtual functions <a id="locale.codecvt.virtuals">[[locale.codecvt.virtuals]]</a>
588
 
589
  ``` cpp
590
  result do_out(
591
  stateT& state,
592
  const internT* from, const internT* from_end, const internT*& from_next,
 
608
  destination `to`. Converts no more than `(from_end - from)` source
609
  elements, and stores no more than `(to_end - to)` destination elements.
610
 
611
  Stops if it encounters a character it cannot convert. It always leaves
612
  the `from_next` and `to_next` pointers pointing one beyond the last
613
+ element successfully converted. If it returns `noconv`, `internT` and
614
+ `externT` are the same type, and the converted sequence is identical to
615
+ the input sequence \[`from`, `from``next`), `to_next` is set equal to
616
  `to`, the value of `state` is unchanged, and there are no changes to the
617
  values in \[`to`, `to_end`).
618
 
619
  A `codecvt` facet that is used by `basic_filebuf` [[file.streams]] shall
620
  have the property that if
 
725
 
726
  *Effects:* The effect on the `state` argument is as if it called
727
  `do_in(state, from, from_end, from, to, to + max, to)` for `to` pointing
728
  to a buffer of at least `max` elements.
729
 
730
+ *Returns:* `(from_next - from)` where `from_next` is the largest value
731
+ in the range \[`from`, `from_end`\] such that the sequence of values in
732
+ the range \[`from`, `from_next`) represents `max` or fewer valid
733
+ complete characters of type `internT`. The specialization
734
  `codecvt<char, char, mbstate_t>`, returns the lesser of `max` and
735
  `(from_end - from)`.
736
 
737
  ``` cpp
738
  int do_max_length() const noexcept;
 
741
  *Returns:* The maximum value that `do_length(state, from, from_end, 1)`
742
  can return for any valid range \[`from`, `from_end`) and `stateT` value
743
  `state`. The specialization
744
  `codecvt<char, char, mbstate_t>::do_max_length()` returns 1.
745
 
746
+ ##### Class template `codecvt_byname` <a id="locale.codecvt.byname">[[locale.codecvt.byname]]</a>
747
 
748
  ``` cpp
749
  namespace std {
750
  template<class internT, class externT, class stateT>
751
  class codecvt_byname : public codecvt<internT, externT, stateT> {