From Jason Turner

[char.traits.specializations]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpdx2l93q9/{from.md → to.md} +76 -66
tmp/tmpdx2l93q9/{from.md → to.md} RENAMED
@@ -1,22 +1,21 @@
1
  ### `char_traits` specializations <a id="char.traits.specializations">[[char.traits.specializations]]</a>
2
 
3
  ``` cpp
4
  namespace std {
5
  template<> struct char_traits<char>;
 
6
  template<> struct char_traits<char16_t>;
7
  template<> struct char_traits<char32_t>;
8
  template<> struct char_traits<wchar_t>;
9
  }
10
  ```
11
 
12
- The header `<string>` shall define four specializations of the class
13
- template `char_traits`: `char_traits<{}char>`, `char_traits<char16_t>`,
14
- `char_traits<char32_t>`, and `char_traits<wchar_t>`.
15
-
16
- The requirements for the members of these specializations are given in
17
- Clause  [[char.traits.require]].
18
 
19
  #### `struct char_traits<char>` <a id="char.traits.specializations.char">[[char.traits.specializations.char]]</a>
20
 
21
  ``` cpp
22
  namespace std {
@@ -24,138 +23,159 @@ namespace std {
24
  using char_type = char;
25
  using int_type = int;
26
  using off_type = streamoff;
27
  using pos_type = streampos;
28
  using state_type = mbstate_t;
 
29
 
30
  static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
31
  static constexpr bool eq(char_type c1, char_type c2) noexcept;
32
  static constexpr bool lt(char_type c1, char_type c2) noexcept;
33
 
34
  static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
35
  static constexpr size_t length(const char_type* s);
36
  static constexpr const char_type* find(const char_type* s, size_t n,
37
  const char_type& a);
38
- static char_type* move(char_type* s1, const char_type* s2, size_t n);
39
- static char_type* copy(char_type* s1, const char_type* s2, size_t n);
40
- static char_type* assign(char_type* s, size_t n, char_type a);
41
 
42
  static constexpr int_type not_eof(int_type c) noexcept;
43
  static constexpr char_type to_char_type(int_type c) noexcept;
44
  static constexpr int_type to_int_type(char_type c) noexcept;
45
  static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
46
  static constexpr int_type eof() noexcept;
47
  };
48
  }
49
  ```
50
 
51
- The defined types for `int_type`, `pos_type`, `off_type`, and
52
- `state_type` shall be `int`, `streampos`, `streamoff`, and `mbstate_t`
53
- respectively.
54
-
55
- The type `streampos` shall be an *implementation-defined* type that
56
- satisfies the requirements for `pos_type` in  [[iostreams.limits.pos]]
57
- and [[iostream.forward]].
58
-
59
- The type `streamoff` shall be an *implementation-defined* type that
60
- satisfies the requirements for `off_type` in  [[iostreams.limits.pos]]
61
- and [[iostream.forward]].
62
-
63
  The type `mbstate_t` is defined in `<cwchar>` and can represent any of
64
  the conversion states that can occur in an *implementation-defined* set
65
  of supported multibyte character encoding rules.
66
 
67
- The two-argument member `assign` shall be defined identically to the
68
- built-in operator `=`. The two-argument members `eq` and `lt` shall be
69
- defined identically to the built-in operators `==` and `<` for type
70
  `unsigned char`.
71
 
72
- The member `eof()` shall return `EOF`.
73
 
74
- #### `struct char_traits<char16_t>` <a id="char.traits.specializations.char16_t">[[char.traits.specializations.char16_t]]</a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  ``` cpp
77
  namespace std {
78
  template<> struct char_traits<char16_t> {
79
  using char_type = char16_t;
80
  using int_type = uint_least16_t;
81
  using off_type = streamoff;
82
  using pos_type = u16streampos;
83
  using state_type = mbstate_t;
 
84
 
85
  static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
86
  static constexpr bool eq(char_type c1, char_type c2) noexcept;
87
  static constexpr bool lt(char_type c1, char_type c2) noexcept;
88
 
89
  static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
90
  static constexpr size_t length(const char_type* s);
91
  static constexpr const char_type* find(const char_type* s, size_t n,
92
  const char_type& a);
93
- static char_type* move(char_type* s1, const char_type* s2, size_t n);
94
- static char_type* copy(char_type* s1, const char_type* s2, size_t n);
95
- static char_type* assign(char_type* s, size_t n, char_type a);
96
 
97
  static constexpr int_type not_eof(int_type c) noexcept;
98
  static constexpr char_type to_char_type(int_type c) noexcept;
99
  static constexpr int_type to_int_type(char_type c) noexcept;
100
  static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
101
  static constexpr int_type eof() noexcept;
102
  };
103
  }
104
  ```
105
 
106
- The type `u16streampos` shall be an *implementation-defined* type that
107
- satisfies the requirements for `pos_type` in  [[iostreams.limits.pos]]
108
- and [[iostream.forward]].
109
 
110
- The two-argument members `assign`, `eq`, and `lt` shall be defined
111
- identically to the built-in operators `=`, `==`, and `<` respectively.
112
 
113
- The member `eof()` shall return an *implementation-defined* constant
114
- that cannot appear as a valid UTF-16 code unit.
115
-
116
- #### `struct char_traits<char32_t>` <a id="char.traits.specializations.char32_t">[[char.traits.specializations.char32_t]]</a>
117
 
118
  ``` cpp
119
  namespace std {
120
  template<> struct char_traits<char32_t> {
121
  using char_type = char32_t;
122
  using int_type = uint_least32_t;
123
  using off_type = streamoff;
124
  using pos_type = u32streampos;
125
  using state_type = mbstate_t;
 
126
 
127
  static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
128
  static constexpr bool eq(char_type c1, char_type c2) noexcept;
129
  static constexpr bool lt(char_type c1, char_type c2) noexcept;
130
 
131
  static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
132
  static constexpr size_t length(const char_type* s);
133
  static constexpr const char_type* find(const char_type* s, size_t n,
134
  const char_type& a);
135
- static char_type* move(char_type* s1, const char_type* s2, size_t n);
136
- static char_type* copy(char_type* s1, const char_type* s2, size_t n);
137
- static char_type* assign(char_type* s, size_t n, char_type a);
138
 
139
  static constexpr int_type not_eof(int_type c) noexcept;
140
  static constexpr char_type to_char_type(int_type c) noexcept;
141
  static constexpr int_type to_int_type(char_type c) noexcept;
142
  static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
143
  static constexpr int_type eof() noexcept;
144
  };
145
  }
146
  ```
147
 
148
- The type `u32streampos` shall be an *implementation-defined* type that
149
- satisfies the requirements for `pos_type` in  [[iostreams.limits.pos]]
150
- and [[iostream.forward]].
151
 
152
- The two-argument members `assign`, `eq`, and `lt` shall be defined
153
- identically to the built-in operators `=`, `==`, and `<` respectively.
154
-
155
- The member `eof()` shall return an *implementation-defined* constant
156
- that cannot appear as a Unicode code point.
157
 
158
  #### `struct char_traits<wchar_t>` <a id="char.traits.specializations.wchar.t">[[char.traits.specializations.wchar.t]]</a>
159
 
160
  ``` cpp
161
  namespace std {
@@ -163,43 +183,33 @@ namespace std {
163
  using char_type = wchar_t;
164
  using int_type = wint_t;
165
  using off_type = streamoff;
166
  using pos_type = wstreampos;
167
  using state_type = mbstate_t;
 
168
 
169
  static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
170
  static constexpr bool eq(char_type c1, char_type c2) noexcept;
171
  static constexpr bool lt(char_type c1, char_type c2) noexcept;
172
 
173
  static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
174
  static constexpr size_t length(const char_type* s);
175
  static constexpr const char_type* find(const char_type* s, size_t n,
176
  const char_type& a);
177
- static char_type* move(char_type* s1, const char_type* s2, size_t n);
178
- static char_type* copy(char_type* s1, const char_type* s2, size_t n);
179
- static char_type* assign(char_type* s, size_t n, char_type a);
180
 
181
  static constexpr int_type not_eof(int_type c) noexcept;
182
  static constexpr char_type to_char_type(int_type c) noexcept;
183
  static constexpr int_type to_int_type(char_type c) noexcept;
184
  static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
185
  static constexpr int_type eof() noexcept;
186
  };
187
  }
188
  ```
189
 
190
- The defined types for `int_type`, `pos_type`, and `state_type` shall be
191
- `wint_t`, `wstreampos`, and `mbstate_t` respectively.
192
 
193
- The type `wstreampos` shall be an *implementation-defined* type that
194
- satisfies the requirements for `pos_type` in  [[iostreams.limits.pos]]
195
- and [[iostream.forward]].
196
-
197
- The type `mbstate_t` is defined in `<cwchar>` and can represent any of
198
- the conversion states that can occur in an *implementation-defined* set
199
- of supported multibyte character encoding rules.
200
-
201
- The two-argument members `assign`, `eq`, and `lt` shall be defined
202
- identically to the built-in operators `=`, `==`, and `<` respectively.
203
-
204
- The member `eof()` shall return `WEOF`.
205
 
 
1
  ### `char_traits` specializations <a id="char.traits.specializations">[[char.traits.specializations]]</a>
2
 
3
  ``` cpp
4
  namespace std {
5
  template<> struct char_traits<char>;
6
+ template<> struct char_traits<char8_t>;
7
  template<> struct char_traits<char16_t>;
8
  template<> struct char_traits<char32_t>;
9
  template<> struct char_traits<wchar_t>;
10
  }
11
  ```
12
 
13
+ The header `<string>` defines five specializations of the class template
14
+ `char_traits`: `char_traits<{}char>`, `char_traits<char8_t>`,
15
+ `char_traits<char16_t>`, `char_traits<char32_t>`, and
16
+ `char_traits<wchar_t>`.
 
 
17
 
18
  #### `struct char_traits<char>` <a id="char.traits.specializations.char">[[char.traits.specializations.char]]</a>
19
 
20
  ``` cpp
21
  namespace std {
 
23
  using char_type = char;
24
  using int_type = int;
25
  using off_type = streamoff;
26
  using pos_type = streampos;
27
  using state_type = mbstate_t;
28
+ using comparison_category = strong_ordering;
29
 
30
  static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
31
  static constexpr bool eq(char_type c1, char_type c2) noexcept;
32
  static constexpr bool lt(char_type c1, char_type c2) noexcept;
33
 
34
  static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
35
  static constexpr size_t length(const char_type* s);
36
  static constexpr const char_type* find(const char_type* s, size_t n,
37
  const char_type& a);
38
+ static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n);
39
+ static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n);
40
+ static constexpr char_type* assign(char_type* s, size_t n, char_type a);
41
 
42
  static constexpr int_type not_eof(int_type c) noexcept;
43
  static constexpr char_type to_char_type(int_type c) noexcept;
44
  static constexpr int_type to_int_type(char_type c) noexcept;
45
  static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
46
  static constexpr int_type eof() noexcept;
47
  };
48
  }
49
  ```
50
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  The type `mbstate_t` is defined in `<cwchar>` and can represent any of
52
  the conversion states that can occur in an *implementation-defined* set
53
  of supported multibyte character encoding rules.
54
 
55
+ The two-argument member `assign` is defined identically to the built-in
56
+ operator `=`. The two-argument members `eq` and `lt` are defined
57
+ identically to the built-in operators `==` and `<` for type
58
  `unsigned char`.
59
 
60
+ The member `eof()` returns `EOF`.
61
 
62
+ #### `struct char_traits<char8_t>` <a id="char.traits.specializations.char8.t">[[char.traits.specializations.char8.t]]</a>
63
+
64
+ ``` cpp
65
+ namespace std {
66
+ template<> struct char_traits<char8_t> {
67
+ using char_type = char8_t;
68
+ using int_type = unsigned int;
69
+ using off_type = streamoff;
70
+ using pos_type = u8streampos;
71
+ using state_type = mbstate_t;
72
+ using comparison_category = strong_ordering;
73
+
74
+ static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
75
+ static constexpr bool eq(char_type c1, char_type c2) noexcept;
76
+ static constexpr bool lt(char_type c1, char_type c2) noexcept;
77
+
78
+ static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
79
+ static constexpr size_t length(const char_type* s);
80
+ static constexpr const char_type* find(const char_type* s, size_t n,
81
+ const char_type& a);
82
+ static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n);
83
+ static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n);
84
+ static constexpr char_type* assign(char_type* s, size_t n, char_type a);
85
+ static constexpr int_type not_eof(int_type c) noexcept;
86
+ static constexpr char_type to_char_type(int_type c) noexcept;
87
+ static constexpr int_type to_int_type(char_type c) noexcept;
88
+ static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
89
+ static constexpr int_type eof() noexcept;
90
+ };
91
+ }
92
+ ```
93
+
94
+ The two-argument members `assign`, `eq`, and `lt` are defined
95
+ identically to the built-in operators `=`, `==`, and `<` respectively.
96
+
97
+ The member `eof()` returns an implementation-defined constant that
98
+ cannot appear as a valid UTF-8 code unit.
99
+
100
+ #### `struct char_traits<char16_t>` <a id="char.traits.specializations.char16.t">[[char.traits.specializations.char16.t]]</a>
101
 
102
  ``` cpp
103
  namespace std {
104
  template<> struct char_traits<char16_t> {
105
  using char_type = char16_t;
106
  using int_type = uint_least16_t;
107
  using off_type = streamoff;
108
  using pos_type = u16streampos;
109
  using state_type = mbstate_t;
110
+ using comparison_category = strong_ordering;
111
 
112
  static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
113
  static constexpr bool eq(char_type c1, char_type c2) noexcept;
114
  static constexpr bool lt(char_type c1, char_type c2) noexcept;
115
 
116
  static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
117
  static constexpr size_t length(const char_type* s);
118
  static constexpr const char_type* find(const char_type* s, size_t n,
119
  const char_type& a);
120
+ static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n);
121
+ static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n);
122
+ static constexpr char_type* assign(char_type* s, size_t n, char_type a);
123
 
124
  static constexpr int_type not_eof(int_type c) noexcept;
125
  static constexpr char_type to_char_type(int_type c) noexcept;
126
  static constexpr int_type to_int_type(char_type c) noexcept;
127
  static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
128
  static constexpr int_type eof() noexcept;
129
  };
130
  }
131
  ```
132
 
133
+ The two-argument members `assign`, `eq`, and `lt` are defined
134
+ identically to the built-in operators `=`, `==`, and `<`, respectively.
 
135
 
136
+ The member `eof()` returns an *implementation-defined* constant that
137
+ cannot appear as a valid UTF-16 code unit.
138
 
139
+ #### `struct char_traits<char32_t>` <a id="char.traits.specializations.char32.t">[[char.traits.specializations.char32.t]]</a>
 
 
 
140
 
141
  ``` cpp
142
  namespace std {
143
  template<> struct char_traits<char32_t> {
144
  using char_type = char32_t;
145
  using int_type = uint_least32_t;
146
  using off_type = streamoff;
147
  using pos_type = u32streampos;
148
  using state_type = mbstate_t;
149
+ using comparison_category = strong_ordering;
150
 
151
  static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
152
  static constexpr bool eq(char_type c1, char_type c2) noexcept;
153
  static constexpr bool lt(char_type c1, char_type c2) noexcept;
154
 
155
  static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
156
  static constexpr size_t length(const char_type* s);
157
  static constexpr const char_type* find(const char_type* s, size_t n,
158
  const char_type& a);
159
+ static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n);
160
+ static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n);
161
+ static constexpr char_type* assign(char_type* s, size_t n, char_type a);
162
 
163
  static constexpr int_type not_eof(int_type c) noexcept;
164
  static constexpr char_type to_char_type(int_type c) noexcept;
165
  static constexpr int_type to_int_type(char_type c) noexcept;
166
  static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
167
  static constexpr int_type eof() noexcept;
168
  };
169
  }
170
  ```
171
 
172
+ The two-argument members `assign`, `eq`, and `lt` are defined
173
+ identically to the built-in operators `=`, `==`, and `<`, respectively.
 
174
 
175
+ The member `eof()` returns an *implementation-defined* constant that
176
+ cannot appear as a Unicode code point.
 
 
 
177
 
178
  #### `struct char_traits<wchar_t>` <a id="char.traits.specializations.wchar.t">[[char.traits.specializations.wchar.t]]</a>
179
 
180
  ``` cpp
181
  namespace std {
 
183
  using char_type = wchar_t;
184
  using int_type = wint_t;
185
  using off_type = streamoff;
186
  using pos_type = wstreampos;
187
  using state_type = mbstate_t;
188
+ using comparison_category = strong_ordering;
189
 
190
  static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
191
  static constexpr bool eq(char_type c1, char_type c2) noexcept;
192
  static constexpr bool lt(char_type c1, char_type c2) noexcept;
193
 
194
  static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
195
  static constexpr size_t length(const char_type* s);
196
  static constexpr const char_type* find(const char_type* s, size_t n,
197
  const char_type& a);
198
+ static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n);
199
+ static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n);
200
+ static constexpr char_type* assign(char_type* s, size_t n, char_type a);
201
 
202
  static constexpr int_type not_eof(int_type c) noexcept;
203
  static constexpr char_type to_char_type(int_type c) noexcept;
204
  static constexpr int_type to_int_type(char_type c) noexcept;
205
  static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
206
  static constexpr int_type eof() noexcept;
207
  };
208
  }
209
  ```
210
 
211
+ The two-argument members `assign`, `eq`, and `lt` are defined
212
+ identically to the built-in operators `=`, `==`, and `<`, respectively.
213
 
214
+ The member `eof()` returns `WEOF`.
 
 
 
 
 
 
 
 
 
 
 
215