From Jason Turner

[locale.convenience]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpyvzuki92/{from.md → to.md} +3 -298
tmp/tmpyvzuki92/{from.md → to.md} RENAMED
@@ -15,19 +15,18 @@ template <class charT> bool isxdigit(charT c, const locale& loc);
15
  template <class charT> bool isalnum (charT c, const locale& loc);
16
  template <class charT> bool isgraph (charT c, const locale& loc);
17
  template <class charT> bool isblank (charT c, const locale& loc);
18
  ```
19
 
20
- Each of these functions `is\textbf{F}` returns the result of the
21
- expression:
22
 
23
  ``` cpp
24
  use_facet<ctype<charT>>(loc).is(ctype_base::F, c)
25
  ```
26
 
27
- where ***F*** is the `ctype_base::mask` value corresponding to that
28
- function ([[category.ctype]]).[^3]
29
 
30
  #### Conversions <a id="conversions">[[conversions]]</a>
31
 
32
  ##### Character conversions <a id="conversions.character">[[conversions.character]]</a>
33
 
@@ -41,299 +40,5 @@ template <class charT> charT toupper(charT c, const locale& loc);
41
  template <class charT> charT tolower(charT c, const locale& loc);
42
  ```
43
 
44
  *Returns:* `use_facet<ctype<charT>>(loc).tolower(c)`.
45
 
46
- ##### `string` conversions <a id="conversions.string">[[conversions.string]]</a>
47
-
48
- Class template `wstring_convert` performs conversions between a wide
49
- string and a byte string. It lets you specify a code conversion facet
50
- (like class template `codecvt`) to perform the conversions, without
51
- affecting any streams or locales. If you want to use the code conversion
52
- facet `codecvt_utf8` to output to `cout` a UTF-8 multibyte sequence
53
- corresponding to a wide string, but you don’t want to alter the locale
54
- for `cout`, you can write something like:
55
-
56
- ``` cpp
57
- wstring_convert<std::codecvt_utf8<wchar_t>> myconv;
58
- std::string mbstring = myconv.to_bytes(L"Hello\n");
59
- std::cout << mbstring;
60
- ```
61
-
62
- ``` cpp
63
- namespace std {
64
- template<class Codecvt, class Elem = wchar_t,
65
- class Wide_alloc = std::allocator<Elem>,
66
- class Byte_alloc = std::allocator<char> > class wstring_convert {
67
- public:
68
- typedef std::basic_string<char, char_traits<char>, Byte_alloc> byte_string;
69
- typedef std::basic_string<Elem, char_traits<Elem>, Wide_alloc> wide_string;
70
- typedef typename Codecvt::state_type state_type;
71
- typedef typename wide_string::traits_type::int_type int_type;
72
-
73
- explicit wstring_convert(Codecvt* pcvt = new Codecvt);
74
- wstring_convert(Codecvt* pcvt, state_type state);
75
- explicit wstring_convert(const byte_string& byte_err,
76
- const wide_string& wide_err = wide_string());
77
- ~wstring_convert();
78
-
79
- wstring_convert(const wstring_convert&) = delete;
80
- wstring_convert& operator=(const wstring_convert&) = delete;
81
-
82
- wide_string from_bytes(char byte);
83
- wide_string from_bytes(const char* ptr);
84
- wide_string from_bytes(const byte_string& str);
85
- wide_string from_bytes(const char* first, const char* last);
86
-
87
- byte_string to_bytes(Elem wchar);
88
- byte_string to_bytes(const Elem* wptr);
89
- byte_string to_bytes(const wide_string& wstr);
90
- byte_string to_bytes(const Elem* first, const Elem* last);
91
-
92
- size_t converted() const noexcept;
93
- state_type state() const;
94
- private:
95
- byte_string byte_err_string; // exposition only
96
- wide_string wide_err_string; // exposition only
97
- Codecvt* cvtptr; // exposition only
98
- state_type cvtstate; // exposition only
99
- size_t cvtcount; // exposition only
100
- };
101
- }
102
- ```
103
-
104
- The class template describes an object that controls conversions between
105
- wide string objects of class `std::basic_string<Elem, char_traits<Elem>,
106
- Wide_alloc>` and byte string objects of class `std::\\basic_string<char,
107
- char_traits<char>, Byte_alloc>`. The class template defines the types
108
- `wide_string` and `byte_string` as synonyms for these two types.
109
- Conversion between a sequence of `Elem` values (stored in a
110
- `wide_string` object) and multibyte sequences (stored in a `byte_string`
111
- object) is performed by an object of class `Codecvt`, which meets the
112
- requirements of the standard code-conversion facet `std::codecvt<Elem,
113
- char, std::mbstate_t>`.
114
-
115
- An object of this class template stores:
116
-
117
- - `byte_err_string` — a byte string to display on errors
118
- - `wide_err_string` — a wide string to display on errors
119
- - `cvtptr` — a pointer to the allocated conversion object (which is
120
- freed when the `wstring_convert` object is destroyed)
121
- - `cvtstate` — a conversion state object
122
- - `cvtcount` — a conversion count
123
-
124
- ``` cpp
125
- typedef std::basic_string<char, char_traits<char>, Byte_alloc> byte_string;
126
- ```
127
-
128
- The type shall be a synonym for
129
- `std::basic_string<char, char_traits<char>, Byte_alloc>`
130
-
131
- ``` cpp
132
- size_t converted() const noexcept;
133
- ```
134
-
135
- *Returns:* `cvtcount`.
136
-
137
- ``` cpp
138
- wide_string from_bytes(char byte);
139
- wide_string from_bytes(const char* ptr);
140
- wide_string from_bytes(const byte_string& str);
141
- wide_string from_bytes(const char* first, const char* last);
142
- ```
143
-
144
- *Effects:* The first member function shall convert the single-element
145
- sequence `byte` to a wide string. The second member function shall
146
- convert the null-terminated sequence beginning at `ptr` to a wide
147
- string. The third member function shall convert the sequence stored in
148
- `str` to a wide string. The fourth member function shall convert the
149
- sequence defined by the range \[`first`, `last`) to a wide string.
150
-
151
- In all cases:
152
-
153
- - If the `cvtstate` object was not constructed with an explicit value,
154
- it shall be set to its default value (the initial conversion state)
155
- before the conversion begins. Otherwise it shall be left unchanged.
156
- - The number of input elements successfully converted shall be stored in
157
- `cvtcount`.
158
-
159
- *Returns:* If no conversion error occurs, the member function shall
160
- return the converted wide string. Otherwise, if the object was
161
- constructed with a wide-error string, the member function shall return
162
- the wide-error string. Otherwise, the member function throws an object
163
- of class `std::range_error`.
164
-
165
- ``` cpp
166
- typedef typename wide_string::traits_type::int_type int_type;
167
- ```
168
-
169
- The type shall be a synonym for `wide_string::traits_type::int_type`.
170
-
171
- ``` cpp
172
- state_type state() const;
173
- ```
174
-
175
- returns `cvtstate`.
176
-
177
- ``` cpp
178
- typedef typename Codecvt::state_type state_type;
179
- ```
180
-
181
- The type shall be a synonym for `Codecvt::state_type`.
182
-
183
- ``` cpp
184
- byte_string to_bytes(Elem wchar);
185
- byte_string to_bytes(const Elem* wptr);
186
- byte_string to_bytes(const wide_string& wstr);
187
- byte_string to_bytes(const Elem* first, const Elem* last);
188
- ```
189
-
190
- *Effects:* The first member function shall convert the single-element
191
- sequence `wchar` to a byte string. The second member function shall
192
- convert the null-terminated sequence beginning at `wptr` to a byte
193
- string. The third member function shall convert the sequence stored in
194
- `wstr` to a byte string. The fourth member function shall convert the
195
- sequence defined by the range \[`first`, `last`) to a byte string.
196
-
197
- In all cases:
198
-
199
- - If the `cvtstate` object was not constructed with an explicit value,
200
- it shall be set to its default value (the initial conversion state)
201
- before the conversion begins. Otherwise it shall be left unchanged.
202
- - The number of input elements successfully converted shall be stored in
203
- `cvtcount`.
204
-
205
- *Returns:* If no conversion error occurs, the member function shall
206
- return the converted byte string. Otherwise, if the object was
207
- constructed with a byte-error string, the member function shall return
208
- the byte-error string. Otherwise, the member function shall throw an
209
- object of class `std::range_error`.
210
-
211
- ``` cpp
212
- typedef std::basic_string<Elem, char_traits<Elem>, Wide_alloc> wide_string;
213
- ```
214
-
215
- The type shall be a synonym for
216
- `std::basic_string<Elem, char_traits<Elem>, Wide_alloc>`.
217
-
218
- ``` cpp
219
- explicit wstring_convert(Codecvt* pcvt = new Codecvt);
220
- wstring_convert(Codecvt* pcvt, state_type state);
221
- explicit wstring_convert(const byte_string& byte_err,
222
- const wide_string& wide_err = wide_string());
223
- ```
224
-
225
- *Requires:* For the first and second constructors, `pcvt != nullptr`.
226
-
227
- *Effects:* The first constructor shall store `pcvt` in `cvtptr` and
228
- default values in `cvtstate`, `byte_err_string`, and `wide_err_string`.
229
- The second constructor shall store `pcvt` in `cvtptr`, `state` in
230
- `cvtstate`, and default values in `byte_err_string` and
231
- `wide_err_string`; moreover the stored state shall be retained between
232
- calls to `from_bytes` and `to_bytes`. The third constructor shall store
233
- `new Codecvt` in `cvtptr`, `state_type()` in `cvtstate`, `byte_err` in
234
- `byte_err_string`, and `wide_err` in `wide_err_string`.
235
-
236
- ``` cpp
237
- ~wstring_convert();
238
- ```
239
-
240
- *Effects:* The destructor shall delete `cvtptr`.
241
-
242
- ##### Buffer conversions <a id="conversions.buffer">[[conversions.buffer]]</a>
243
-
244
- Class template `wbuffer_convert` looks like a wide stream buffer, but
245
- performs all its I/O through an underlying byte stream buffer that you
246
- specify when you construct it. Like class template `wstring_convert`, it
247
- lets you specify a code conversion facet to perform the conversions,
248
- without affecting any streams or locales.
249
-
250
- ``` cpp
251
- namespace std {
252
- template<class Codecvt,
253
- class Elem = wchar_t,
254
- class Tr = std::char_traits<Elem> >
255
- class wbuffer_convert
256
- : public std::basic_streambuf<Elem, Tr> {
257
- public:
258
- typedef typename Codecvt::state_type state_type;
259
-
260
- explicit wbuffer_convert(std::streambuf* bytebuf = 0,
261
- Codecvt* pcvt = new Codecvt,
262
- state_type state = state_type());
263
-
264
- ~wbuffer_convert();
265
-
266
- wbuffer_convert(const wbuffer_convert&) = delete;
267
- wbuffer_convert& operator=(const wbuffer_convert&) = delete;
268
-
269
- std::streambuf* rdbuf() const;
270
- std::streambuf* rdbuf(std::streambuf* bytebuf);
271
-
272
- state_type state() const;
273
-
274
- private:
275
- std::streambuf* bufptr; // exposition only
276
- Codecvt* cvtptr; // exposition only
277
- state_type cvtstate; // exposition only
278
- };
279
- }
280
- ```
281
-
282
- The class template describes a stream buffer that controls the
283
- transmission of elements of type `Elem`, whose character traits are
284
- described by the class `Tr`, to and from a byte stream buffer of type
285
- `std::streambuf`. Conversion between a sequence of `Elem` values and
286
- multibyte sequences is performed by an object of class `Codecvt`, which
287
- shall meet the requirements of the standard code-conversion facet
288
- `std::codecvt<Elem, char, std::mbstate_t>`.
289
-
290
- An object of this class template stores:
291
-
292
- - `bufptr` — a pointer to its underlying byte stream buffer
293
- - `cvtptr` — a pointer to the allocated conversion object (which is
294
- freed when the `wbuffer_convert` object is destroyed)
295
- - `cvtstate` — a conversion state object
296
-
297
- ``` cpp
298
- state_type state() const;
299
- ```
300
-
301
- *Returns:* `cvtstate`.
302
-
303
- ``` cpp
304
- std::streambuf* rdbuf() const;
305
- ```
306
-
307
- *Returns:* `bufptr`.
308
-
309
- ``` cpp
310
- std::streambuf* rdbuf(std::streambuf* bytebuf);
311
- ```
312
-
313
- *Effects:* stores `bytebuf` in `bufptr`.
314
-
315
- *Returns:* The previous value of `bufptr`.
316
-
317
- ``` cpp
318
- typedef typename Codecvt::state_type state_type;
319
- ```
320
-
321
- The type shall be a synonym for `Codecvt::state_type`.
322
-
323
- ``` cpp
324
- explicit wbuffer_convert(std::streambuf* bytebuf = 0,
325
- Codecvt* pcvt = new Codecvt, state_type state = state_type());
326
- ```
327
-
328
- *Requires:* `pcvt != nullptr`.
329
-
330
- *Effects:* The constructor constructs a stream buffer object,
331
- initializes `bufptr` to `bytebuf`, initializes `cvtptr` to `pcvt`, and
332
- initializes `cvtstate` to `state`.
333
-
334
- ``` cpp
335
- ~wbuffer_convert();
336
- ```
337
-
338
- *Effects:* The destructor shall delete `cvtptr`.
339
-
 
15
  template <class charT> bool isalnum (charT c, const locale& loc);
16
  template <class charT> bool isgraph (charT c, const locale& loc);
17
  template <class charT> bool isblank (charT c, const locale& loc);
18
  ```
19
 
20
+ Each of these functions `isF` returns the result of the expression:
 
21
 
22
  ``` cpp
23
  use_facet<ctype<charT>>(loc).is(ctype_base::F, c)
24
  ```
25
 
26
+ where `F` is the `ctype_base::mask` value corresponding to that
27
+ function ([[category.ctype]]).[^4]
28
 
29
  #### Conversions <a id="conversions">[[conversions]]</a>
30
 
31
  ##### Character conversions <a id="conversions.character">[[conversions.character]]</a>
32
 
 
40
  template <class charT> charT tolower(charT c, const locale& loc);
41
  ```
42
 
43
  *Returns:* `use_facet<ctype<charT>>(loc).tolower(c)`.
44