From Jason Turner

[char.traits.specializations]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpn92948ie/{from.md → to.md} +45 -45
tmp/tmpn92948ie/{from.md → to.md} RENAMED
@@ -7,35 +7,35 @@ namespace std {
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 template
13
- struct `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 {
23
  template<> struct char_traits<char> {
24
- typedef char char_type;
25
- typedef int int_type;
26
- typedef streamoff off_type;
27
- typedef streampos pos_type;
28
- typedef mbstate_t state_type;
29
 
30
- static 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 int compare(const char_type* s1, const char_type* s2, size_t n);
35
- static size_t length(const char_type* s);
36
- static 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
 
@@ -65,32 +65,32 @@ 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
- typedef char16_t char_type;
80
- typedef uint_least16_t int_type;
81
- typedef streamoff off_type;
82
- typedef u16streampos pos_type;
83
- typedef mbstate_t state_type;
84
 
85
- static 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 int compare(const char_type* s1, const char_type* s2, size_t n);
90
- static size_t length(const char_type* s);
91
- static 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
 
@@ -102,12 +102,12 @@ namespace std {
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]] and
108
- [[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
@@ -116,23 +116,23 @@ that cannot appear as a valid UTF-16 code unit.
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
- typedef char32_t char_type;
122
- typedef uint_least32_t int_type;
123
- typedef streamoff off_type;
124
- typedef u32streampos pos_type;
125
- typedef mbstate_t state_type;
126
 
127
- static 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 int compare(const char_type* s1, const char_type* s2, size_t n);
132
- static size_t length(const char_type* s);
133
- static 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
 
@@ -144,12 +144,12 @@ namespace std {
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]] and
150
- [[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
@@ -158,23 +158,23 @@ that cannot appear as a Unicode code point.
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 {
162
  template<> struct char_traits<wchar_t> {
163
- typedef wchar_t char_type;
164
- typedef wint_t int_type;
165
- typedef streamoff off_type;
166
- typedef wstreampos pos_type;
167
- typedef mbstate_t state_type;
168
 
169
- static 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 int compare(const char_type* s1, const char_type* s2, size_t n);
174
- static size_t length(const char_type* s);
175
- static 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
 
@@ -189,12 +189,12 @@ namespace std {
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]] and
195
- [[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
 
 
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 {
23
  template<> struct char_traits<char> {
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
 
 
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
 
 
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
 
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
 
 
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
 
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 {
162
  template<> struct char_traits<wchar_t> {
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
 
 
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