From Jason Turner

[locales]

Diff to HTML by rtfpessoa

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