tmp/tmpwny7gxrs/{from.md → to.md}
RENAMED
|
@@ -1,19 +1,22 @@
|
|
| 1 |
## Character traits <a id="char.traits">[[char.traits]]</a>
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
`char_traits<
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
Most classes specified in [[string.classes]], [[string.view]], and
|
| 10 |
[[input.output]] need a set of related types and functions to complete
|
| 11 |
the definition of their semantics. These types and functions are
|
| 12 |
provided as a set of member *typedef-name*s and functions in the
|
| 13 |
-
template parameter `traits` used by each such template.
|
| 14 |
-
defines the semantics of these members.
|
| 15 |
|
| 16 |
To specialize those templates to generate a string, string view, or
|
| 17 |
iostream class to handle a particular character container type
|
| 18 |
[[defns.character.container]] `C`, that and its related character traits
|
| 19 |
class `X` are passed as a pair of parameters to the string, string view,
|
|
@@ -25,12 +28,13 @@ or iostream template as parameters `charT` and `traits`. If
|
|
| 25 |
In [[char.traits.req]], `X` denotes a traits class defining types and
|
| 26 |
functions for the character container type `C`; `c` and `d` denote
|
| 27 |
values of type `C`; `p` and `q` denote values of type `const C*`; `s`
|
| 28 |
denotes a value of type `C*`; `n`, `i` and `j` denote values of type
|
| 29 |
`size_t`; `e` and `f` denote values of type `X::int_type`; `pos` denotes
|
| 30 |
-
a value of type `X::pos_type`; and `r` denotes an lvalue of type `C`.
|
| 31 |
-
|
|
|
|
| 32 |
|
| 33 |
The class template
|
| 34 |
|
| 35 |
``` cpp
|
| 36 |
template<class charT> struct char_traits;
|
|
@@ -59,10 +63,12 @@ using state_type = see below;
|
|
| 59 |
([[cpp17.copyconstructible]]), and *Cpp17DefaultConstructible*
|
| 60 |
([[cpp17.defaultconstructible]]) requirements.
|
| 61 |
|
| 62 |
### `char_traits` specializations <a id="char.traits.specializations">[[char.traits.specializations]]</a>
|
| 63 |
|
|
|
|
|
|
|
| 64 |
``` cpp
|
| 65 |
namespace std {
|
| 66 |
template<> struct char_traits<char>;
|
| 67 |
template<> struct char_traits<char8_t>;
|
| 68 |
template<> struct char_traits<char16_t>;
|
|
@@ -153,11 +159,11 @@ namespace std {
|
|
| 153 |
```
|
| 154 |
|
| 155 |
The two-argument members `assign`, `eq`, and `lt` are defined
|
| 156 |
identically to the built-in operators `=`, `==`, and `<` respectively.
|
| 157 |
|
| 158 |
-
The member `eof()` returns an implementation-defined constant that
|
| 159 |
cannot appear as a valid UTF-8 code unit.
|
| 160 |
|
| 161 |
#### `struct char_traits<char16_t>` <a id="char.traits.specializations.char16.t">[[char.traits.specializations.char16.t]]</a>
|
| 162 |
|
| 163 |
``` cpp
|
|
|
|
| 1 |
## Character traits <a id="char.traits">[[char.traits]]</a>
|
| 2 |
|
| 3 |
+
### General <a id="char.traits.general">[[char.traits.general]]</a>
|
| 4 |
+
|
| 5 |
+
Subclause [[char.traits]] defines requirements on classes representing
|
| 6 |
+
*character traits*, and defines a class template `char_traits<charT>`,
|
| 7 |
+
along with five specializations, `char_traits<char>`,
|
| 8 |
+
`char_traits<char8_t>`, `char_traits<char16_t>`,
|
| 9 |
+
`char_traits<char32_t>`, and `char_traits<wchar_t>`, that meet those
|
| 10 |
+
requirements.
|
| 11 |
|
| 12 |
Most classes specified in [[string.classes]], [[string.view]], and
|
| 13 |
[[input.output]] need a set of related types and functions to complete
|
| 14 |
the definition of their semantics. These types and functions are
|
| 15 |
provided as a set of member *typedef-name*s and functions in the
|
| 16 |
+
template parameter `traits` used by each such template. Subclause
|
| 17 |
+
[[char.traits]] defines the semantics of these members.
|
| 18 |
|
| 19 |
To specialize those templates to generate a string, string view, or
|
| 20 |
iostream class to handle a particular character container type
|
| 21 |
[[defns.character.container]] `C`, that and its related character traits
|
| 22 |
class `X` are passed as a pair of parameters to the string, string view,
|
|
|
|
| 28 |
In [[char.traits.req]], `X` denotes a traits class defining types and
|
| 29 |
functions for the character container type `C`; `c` and `d` denote
|
| 30 |
values of type `C`; `p` and `q` denote values of type `const C*`; `s`
|
| 31 |
denotes a value of type `C*`; `n`, `i` and `j` denote values of type
|
| 32 |
`size_t`; `e` and `f` denote values of type `X::int_type`; `pos` denotes
|
| 33 |
+
a value of type `X::pos_type`; and `r` denotes an lvalue of type `C`. No
|
| 34 |
+
expression which is part of the character traits requirements specified
|
| 35 |
+
in this subclause [[char.traits.require]] shall exit via an exception.
|
| 36 |
|
| 37 |
The class template
|
| 38 |
|
| 39 |
``` cpp
|
| 40 |
template<class charT> struct char_traits;
|
|
|
|
| 63 |
([[cpp17.copyconstructible]]), and *Cpp17DefaultConstructible*
|
| 64 |
([[cpp17.defaultconstructible]]) requirements.
|
| 65 |
|
| 66 |
### `char_traits` specializations <a id="char.traits.specializations">[[char.traits.specializations]]</a>
|
| 67 |
|
| 68 |
+
#### General <a id="char.traits.specializations.general">[[char.traits.specializations.general]]</a>
|
| 69 |
+
|
| 70 |
``` cpp
|
| 71 |
namespace std {
|
| 72 |
template<> struct char_traits<char>;
|
| 73 |
template<> struct char_traits<char8_t>;
|
| 74 |
template<> struct char_traits<char16_t>;
|
|
|
|
| 159 |
```
|
| 160 |
|
| 161 |
The two-argument members `assign`, `eq`, and `lt` are defined
|
| 162 |
identically to the built-in operators `=`, `==`, and `<` respectively.
|
| 163 |
|
| 164 |
+
The member `eof()` returns an *implementation-defined* constant that
|
| 165 |
cannot appear as a valid UTF-8 code unit.
|
| 166 |
|
| 167 |
#### `struct char_traits<char16_t>` <a id="char.traits.specializations.char16.t">[[char.traits.specializations.char16.t]]</a>
|
| 168 |
|
| 169 |
``` cpp
|