From Jason Turner

[locale]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp4svi6609/{from.md → to.md} +40 -28
tmp/tmp4svi6609/{from.md → to.md} RENAMED
@@ -1,47 +1,51 @@
1
- ### Class `locale` <a id="locale">[[locale]]</a>
2
 
3
- #### General <a id="locale.general">[[locale.general]]</a>
4
 
5
  ``` cpp
6
  namespace std {
7
  class locale {
8
  public:
9
- // types
 
10
  class facet;
 
11
  class id;
 
12
  using category = int;
13
  static const category // values assigned here are for exposition only
14
  none = 0,
15
  collate = 0x010, ctype = 0x020,
16
  monetary = 0x040, numeric = 0x080,
17
  time = 0x100, messages = 0x200,
18
  all = collate | ctype | monetary | numeric | time | messages;
19
 
20
- // construct/copy/destroy
21
  locale() noexcept;
22
  locale(const locale& other) noexcept;
23
  explicit locale(const char* std_name);
24
  explicit locale(const string& std_name);
25
  locale(const locale& other, const char* std_name, category);
26
  locale(const locale& other, const string& std_name, category);
27
  template<class Facet> locale(const locale& other, Facet* f);
28
  locale(const locale& other, const locale& one, category);
29
  ~locale(); // not virtual
30
  const locale& operator=(const locale& other) noexcept;
 
 
31
  template<class Facet> locale combine(const locale& other) const;
32
-
33
- // locale operations
34
  string name() const;
 
35
 
36
  bool operator==(const locale& other) const;
37
 
38
  template<class charT, class traits, class Allocator>
39
  bool operator()(const basic_string<charT, traits, Allocator>& s1,
40
  const basic_string<charT, traits, Allocator>& s2) const;
41
 
42
- // global locale objects
43
  static locale global(const locale&);
44
  static const locale& classic();
45
  };
46
  }
47
  ```
@@ -122,13 +126,13 @@ global locale object per thread is *implementation-defined*.
122
  Implementations should provide one global locale object per thread. If
123
  there is a single global locale object for the entire program,
124
  implementations are not required to avoid data races on it
125
  [[res.on.data.races]].
126
 
127
- #### Types <a id="locale.types">[[locale.types]]</a>
128
 
129
- ##### Type `locale::category` <a id="locale.category">[[locale.category]]</a>
130
 
131
  ``` cpp
132
  using category = int;
133
  ```
134
 
@@ -158,12 +162,10 @@ including at least those shown in [[locale.category.facets]].
158
  | Category | Includes facets |
159
  | -------- | ----------------------------------------------------- |
160
  | collate | `collate<char>`, `collate<wchar_t>` |
161
  | ctype | `ctype<char>`, `ctype<wchar_t>` |
162
  | | `codecvt<char, char, mbstate_t>` |
163
- | | `codecvt<char16_t, char8_t, mbstate_t>` |
164
- | | `codecvt<char32_t, char8_t, mbstate_t>` |
165
  | | `codecvt<wchar_t, char, mbstate_t>` |
166
  | monetary | `moneypunct<char>`, `moneypunct<wchar_t>` |
167
  | | `moneypunct<char, true>`, `moneypunct<wchar_t, true>` |
168
  | | `money_get<char>`, `money_get<wchar_t>` |
169
  | | `money_put<char>`, `money_put<wchar_t>` |
@@ -190,12 +192,10 @@ templates identified as members of a category, and for those shown in
190
  | Category | Includes facets |
191
  | -------- | --------------------------------------------------------- |
192
  | collate | `collate_byname<char>`, `collate_byname<wchar_t>` |
193
  | ctype | `ctype_byname<char>`, `ctype_byname<wchar_t>` |
194
  | | `codecvt_byname<char, char, mbstate_t>` |
195
- | | `codecvt_byname<char16_t, char8_t, mbstate_t>` |
196
- | | `codecvt_byname<char32_t, char8_t, mbstate_t>` |
197
  | | `codecvt_byname<wchar_t, char, mbstate_t>` |
198
  | monetary | `moneypunct_byname<char, International>` |
199
  | | `moneypunct_byname<wchar_t, International>` |
200
  | | `money_get<C, InputIterator>` |
201
  | | `money_put<C, OutputIterator>` |
@@ -222,16 +222,17 @@ In declarations of facets, a template parameter with name
222
  `InputIterator` or `OutputIterator` indicates the set of all possible
223
  specializations on parameters that meet the *Cpp17InputIterator*
224
  requirements or *Cpp17OutputIterator* requirements, respectively
225
  [[iterator.requirements]]. A template parameter with name `C` represents
226
  the set of types containing `char`, `wchar_t`, and any other
227
- *implementation-defined* character types that meet the requirements for
228
- a character on which any of the iostream components can be instantiated.
229
- A template parameter with name `International` represents the set of all
230
- possible specializations on a bool parameter.
 
231
 
232
- ##### Class `locale::facet` <a id="locale.facet">[[locale.facet]]</a>
233
 
234
  ``` cpp
235
  namespace std {
236
  class locale::facet {
237
  protected:
@@ -266,11 +267,11 @@ For `refs == 0`, the implementation performs
266
  facet) when the last `locale` object containing the facet is destroyed;
267
  for `refs == 1`, the implementation never destroys the facet.
268
 
269
  Constructors of all facets defined in this Clause take such an argument
270
  and pass it along to their `facet` base class constructor. All
271
- one-argument constructors defined in this Clause are *explicit*,
272
  preventing their participation in implicit conversions.
273
 
274
  For some standard facets a standard “…`_byname`” class, derived from it,
275
  implements the virtual function semantics equivalent to that facet of
276
  the locale constructed by `locale(const char*)` with the same name. Each
@@ -281,11 +282,11 @@ takes a `string` argument `str` and a `refs` argument, which has the
281
  same effect as calling the first constructor with the two arguments
282
  `str.c_str()` and `refs`. If there is no “…`_byname`” version of a
283
  facet, the base class implements named locale semantics itself by
284
  reference to other facets.
285
 
286
- ##### Class `locale::id` <a id="locale.id">[[locale.id]]</a>
287
 
288
  ``` cpp
289
  namespace std {
290
  class locale::id {
291
  public:
@@ -298,19 +299,19 @@ namespace std {
298
 
299
  The class `locale::id` provides identification of a locale facet
300
  interface, used as an index for lookup and to encapsulate
301
  initialization.
302
 
303
- [*Note 1*: Because facets are used by iostreams, potentially while
304
  static constructors are running, their initialization cannot depend on
305
  programmed static initialization. One initialization strategy is for
306
  `locale` to initialize each facet’s `id` member the first time an
307
  instance of the facet is installed into a locale. This depends only on
308
  static storage being zero before constructors run
309
  [[basic.start.static]]. — *end note*]
310
 
311
- #### Constructors and destructor <a id="locale.cons">[[locale.cons]]</a>
312
 
313
  ``` cpp
314
  locale() noexcept;
315
  ```
316
 
@@ -396,11 +397,11 @@ const locale& operator=(const locale& other) noexcept;
396
 
397
  *Effects:* Creates a copy of `other`, replacing the current value.
398
 
399
  *Returns:* `*this`.
400
 
401
- #### Members <a id="locale.members">[[locale.members]]</a>
402
 
403
  ``` cpp
404
  template<class Facet> locale combine(const locale& other) const;
405
  ```
406
 
@@ -418,11 +419,21 @@ string name() const;
418
  ```
419
 
420
  *Returns:* The name of `*this`, if it has one; otherwise, the string
421
  `"*"`.
422
 
423
- #### Operators <a id="locale.operators">[[locale.operators]]</a>
 
 
 
 
 
 
 
 
 
 
424
 
425
  ``` cpp
426
  bool operator==(const locale& other) const;
427
  ```
428
 
@@ -434,16 +445,17 @@ copy of the other, or each has a name and the names are identical;
434
  template<class charT, class traits, class Allocator>
435
  bool operator()(const basic_string<charT, traits, Allocator>& s1,
436
  const basic_string<charT, traits, Allocator>& s2) const;
437
  ```
438
 
439
- *Effects:* Compares two strings according to the `collate<charT>` facet.
 
440
 
441
  *Returns:*
442
 
443
  ``` cpp
444
- use_facet<collate<charT>>(*this).compare(s1.data(), s1.data() + s1.size(),
445
  s2.data(), s2.data() + s2.size()) < 0
446
  ```
447
 
448
  *Remarks:* This member operator template (and therefore `locale` itself)
449
  meets the requirements for a comparator predicate template
@@ -458,11 +470,11 @@ locale `loc` simply by [[alg.sort]], [[vector]]:
458
  std::sort(v.begin(), v.end(), loc);
459
  ```
460
 
461
  — *end example*]
462
 
463
- #### Static members <a id="locale.statics">[[locale.statics]]</a>
464
 
465
  ``` cpp
466
  static locale global(const locale& loc);
467
  ```
468
 
@@ -480,11 +492,11 @@ otherwise, the effect on the C locale, if any, is
480
  *Returns:* The previous value of `locale()`.
481
 
482
  *Remarks:* No library function other than `locale::global()` affects the
483
  value returned by `locale()`.
484
 
485
- [*Note 1*: See  [[c.locales]] for data race considerations when
486
  `setlocale` is invoked. — *end note*]
487
 
488
  ``` cpp
489
  static const locale& classic();
490
  ```
 
1
+ #### Class `locale` <a id="locale">[[locale]]</a>
2
 
3
+ ##### General <a id="locale.general">[[locale.general]]</a>
4
 
5
  ``` cpp
6
  namespace std {
7
  class locale {
8
  public:
9
+ // [locale.types], types
10
+ // [locale.facet], class locale::facet
11
  class facet;
12
+ // [locale.id], class locale::id
13
  class id;
14
+ // [locale.category], type locale::category
15
  using category = int;
16
  static const category // values assigned here are for exposition only
17
  none = 0,
18
  collate = 0x010, ctype = 0x020,
19
  monetary = 0x040, numeric = 0x080,
20
  time = 0x100, messages = 0x200,
21
  all = collate | ctype | monetary | numeric | time | messages;
22
 
23
+ // [locale.cons], construct/copy/destroy
24
  locale() noexcept;
25
  locale(const locale& other) noexcept;
26
  explicit locale(const char* std_name);
27
  explicit locale(const string& std_name);
28
  locale(const locale& other, const char* std_name, category);
29
  locale(const locale& other, const string& std_name, category);
30
  template<class Facet> locale(const locale& other, Facet* f);
31
  locale(const locale& other, const locale& one, category);
32
  ~locale(); // not virtual
33
  const locale& operator=(const locale& other) noexcept;
34
+
35
+ // [locale.members], locale operations
36
  template<class Facet> locale combine(const locale& other) const;
 
 
37
  string name() const;
38
+ text_encoding encoding() const;
39
 
40
  bool operator==(const locale& other) const;
41
 
42
  template<class charT, class traits, class Allocator>
43
  bool operator()(const basic_string<charT, traits, Allocator>& s1,
44
  const basic_string<charT, traits, Allocator>& s2) const;
45
 
46
+ // [locale.statics], global locale objects
47
  static locale global(const locale&);
48
  static const locale& classic();
49
  };
50
  }
51
  ```
 
126
  Implementations should provide one global locale object per thread. If
127
  there is a single global locale object for the entire program,
128
  implementations are not required to avoid data races on it
129
  [[res.on.data.races]].
130
 
131
+ ##### Types <a id="locale.types">[[locale.types]]</a>
132
 
133
+ ###### Type `locale::category` <a id="locale.category">[[locale.category]]</a>
134
 
135
  ``` cpp
136
  using category = int;
137
  ```
138
 
 
162
  | Category | Includes facets |
163
  | -------- | ----------------------------------------------------- |
164
  | collate | `collate<char>`, `collate<wchar_t>` |
165
  | ctype | `ctype<char>`, `ctype<wchar_t>` |
166
  | | `codecvt<char, char, mbstate_t>` |
 
 
167
  | | `codecvt<wchar_t, char, mbstate_t>` |
168
  | monetary | `moneypunct<char>`, `moneypunct<wchar_t>` |
169
  | | `moneypunct<char, true>`, `moneypunct<wchar_t, true>` |
170
  | | `money_get<char>`, `money_get<wchar_t>` |
171
  | | `money_put<char>`, `money_put<wchar_t>` |
 
192
  | Category | Includes facets |
193
  | -------- | --------------------------------------------------------- |
194
  | collate | `collate_byname<char>`, `collate_byname<wchar_t>` |
195
  | ctype | `ctype_byname<char>`, `ctype_byname<wchar_t>` |
196
  | | `codecvt_byname<char, char, mbstate_t>` |
 
 
197
  | | `codecvt_byname<wchar_t, char, mbstate_t>` |
198
  | monetary | `moneypunct_byname<char, International>` |
199
  | | `moneypunct_byname<wchar_t, International>` |
200
  | | `money_get<C, InputIterator>` |
201
  | | `money_put<C, OutputIterator>` |
 
222
  `InputIterator` or `OutputIterator` indicates the set of all possible
223
  specializations on parameters that meet the *Cpp17InputIterator*
224
  requirements or *Cpp17OutputIterator* requirements, respectively
225
  [[iterator.requirements]]. A template parameter with name `C` represents
226
  the set of types containing `char`, `wchar_t`, and any other
227
+ *implementation-defined* character container types
228
+ [[defns.character.container]] that meet the requirements for a character
229
+ on which any of the iostream components can be instantiated. A template
230
+ parameter with name `International` represents the set of all possible
231
+ specializations on a bool parameter.
232
 
233
+ ###### Class `locale::facet` <a id="locale.facet">[[locale.facet]]</a>
234
 
235
  ``` cpp
236
  namespace std {
237
  class locale::facet {
238
  protected:
 
267
  facet) when the last `locale` object containing the facet is destroyed;
268
  for `refs == 1`, the implementation never destroys the facet.
269
 
270
  Constructors of all facets defined in this Clause take such an argument
271
  and pass it along to their `facet` base class constructor. All
272
+ one-argument constructors defined in this Clause are explicit,
273
  preventing their participation in implicit conversions.
274
 
275
  For some standard facets a standard “…`_byname`” class, derived from it,
276
  implements the virtual function semantics equivalent to that facet of
277
  the locale constructed by `locale(const char*)` with the same name. Each
 
282
  same effect as calling the first constructor with the two arguments
283
  `str.c_str()` and `refs`. If there is no “…`_byname`” version of a
284
  facet, the base class implements named locale semantics itself by
285
  reference to other facets.
286
 
287
+ ###### Class `locale::id` <a id="locale.id">[[locale.id]]</a>
288
 
289
  ``` cpp
290
  namespace std {
291
  class locale::id {
292
  public:
 
299
 
300
  The class `locale::id` provides identification of a locale facet
301
  interface, used as an index for lookup and to encapsulate
302
  initialization.
303
 
304
+ [*Note 2*: Because facets are used by iostreams, potentially while
305
  static constructors are running, their initialization cannot depend on
306
  programmed static initialization. One initialization strategy is for
307
  `locale` to initialize each facet’s `id` member the first time an
308
  instance of the facet is installed into a locale. This depends only on
309
  static storage being zero before constructors run
310
  [[basic.start.static]]. — *end note*]
311
 
312
+ ##### Constructors and destructor <a id="locale.cons">[[locale.cons]]</a>
313
 
314
  ``` cpp
315
  locale() noexcept;
316
  ```
317
 
 
397
 
398
  *Effects:* Creates a copy of `other`, replacing the current value.
399
 
400
  *Returns:* `*this`.
401
 
402
+ ##### Members <a id="locale.members">[[locale.members]]</a>
403
 
404
  ``` cpp
405
  template<class Facet> locale combine(const locale& other) const;
406
  ```
407
 
 
419
  ```
420
 
421
  *Returns:* The name of `*this`, if it has one; otherwise, the string
422
  `"*"`.
423
 
424
+ ``` cpp
425
+ text_encoding encoding() const;
426
+ ```
427
+
428
+ *Mandates:* `CHAR_BIT == 8` is `true`.
429
+
430
+ *Returns:* A `text_encoding` object representing the
431
+ implementation-defined encoding scheme associated with the locale
432
+ `*this`.
433
+
434
+ ##### Operators <a id="locale.operators">[[locale.operators]]</a>
435
 
436
  ``` cpp
437
  bool operator==(const locale& other) const;
438
  ```
439
 
 
445
  template<class charT, class traits, class Allocator>
446
  bool operator()(const basic_string<charT, traits, Allocator>& s1,
447
  const basic_string<charT, traits, Allocator>& s2) const;
448
  ```
449
 
450
+ *Effects:* Compares two strings according to the `std::collate<charT>`
451
+ facet.
452
 
453
  *Returns:*
454
 
455
  ``` cpp
456
+ use_facet<std::collate<charT>>(*this).compare(s1.data(), s1.data() + s1.size(),
457
  s2.data(), s2.data() + s2.size()) < 0
458
  ```
459
 
460
  *Remarks:* This member operator template (and therefore `locale` itself)
461
  meets the requirements for a comparator predicate template
 
470
  std::sort(v.begin(), v.end(), loc);
471
  ```
472
 
473
  — *end example*]
474
 
475
+ ##### Static members <a id="locale.statics">[[locale.statics]]</a>
476
 
477
  ``` cpp
478
  static locale global(const locale& loc);
479
  ```
480
 
 
492
  *Returns:* The previous value of `locale()`.
493
 
494
  *Remarks:* No library function other than `locale::global()` affects the
495
  value returned by `locale()`.
496
 
497
+ [*Note 2*: See  [[c.locales]] for data race considerations when
498
  `setlocale` is invoked. — *end note*]
499
 
500
  ``` cpp
501
  static const locale& classic();
502
  ```