- tmp/tmp04bs6yms/{from.md → to.md} +104 -119
tmp/tmp04bs6yms/{from.md → to.md}
RENAMED
|
@@ -1,108 +1,82 @@
|
|
| 1 |
## Character traits <a id="char.traits">[[char.traits]]</a>
|
| 2 |
|
| 3 |
This subclause defines requirements on classes representing *character
|
| 4 |
traits*, and defines a class template `char_traits<charT>`, along with
|
| 5 |
-
|
| 6 |
-
`char_traits<
|
| 7 |
-
requirements.
|
| 8 |
|
| 9 |
-
Most classes specified in
|
| 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. This subclause
|
| 14 |
defines the semantics of these members.
|
| 15 |
|
| 16 |
-
To specialize those templates to generate a string
|
| 17 |
-
handle a particular character container type
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
This subclause specifies a class template, `char_traits<charT>`, and
|
| 23 |
-
four explicit specializations of it, `char_traits<{}char>`,
|
| 24 |
-
`char_traits<char16_t>`, `char_traits<char32_t>`, and
|
| 25 |
-
`char_traits<wchar_t>`, all of which appear in the header `<string>` and
|
| 26 |
-
satisfy the requirements below.
|
| 27 |
|
| 28 |
### Character traits requirements <a id="char.traits.require">[[char.traits.require]]</a>
|
| 29 |
|
| 30 |
-
In
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
`
|
| 35 |
-
`X::
|
| 36 |
-
|
| 37 |
-
type `CharT`. Operations on Traits shall not throw exceptions.
|
| 38 |
|
| 39 |
The class template
|
| 40 |
|
| 41 |
``` cpp
|
| 42 |
template<class charT> struct char_traits;
|
| 43 |
```
|
| 44 |
|
| 45 |
-
|
| 46 |
specializations.
|
| 47 |
|
| 48 |
### Traits typedefs <a id="char.traits.typedefs">[[char.traits.typedefs]]</a>
|
| 49 |
|
| 50 |
``` cpp
|
| 51 |
-
using
|
| 52 |
```
|
| 53 |
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
|
| 58 |
``` cpp
|
| 59 |
-
using
|
| 60 |
```
|
| 61 |
|
| 62 |
-
*
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
end-of-file to be used as a return type of the iostream class member
|
| 68 |
-
functions.[^1]
|
| 69 |
-
|
| 70 |
-
``` cpp
|
| 71 |
-
using off_type = implementation-defined;
|
| 72 |
-
using pos_type = implementation-defined;
|
| 73 |
-
```
|
| 74 |
-
|
| 75 |
-
*Requires:* Requirements for `off_type` and `pos_type` are described
|
| 76 |
-
in [[iostreams.limits.pos]] and [[iostream.forward]].
|
| 77 |
-
|
| 78 |
-
``` cpp
|
| 79 |
-
using state_type = STATE_T;
|
| 80 |
-
```
|
| 81 |
-
|
| 82 |
-
*Requires:* `state_type` shall meet the requirements of `CopyAssignable`
|
| 83 |
-
(Table [[tab:copyassignable]]), `CopyConstructible`
|
| 84 |
-
(Table [[tab:copyconstructible]]), and `DefaultConstructible`
|
| 85 |
-
(Table [[tab:defaultconstructible]]) types.
|
| 86 |
|
| 87 |
### `char_traits` specializations <a id="char.traits.specializations">[[char.traits.specializations]]</a>
|
| 88 |
|
| 89 |
``` cpp
|
| 90 |
namespace std {
|
| 91 |
template<> struct char_traits<char>;
|
|
|
|
| 92 |
template<> struct char_traits<char16_t>;
|
| 93 |
template<> struct char_traits<char32_t>;
|
| 94 |
template<> struct char_traits<wchar_t>;
|
| 95 |
}
|
| 96 |
```
|
| 97 |
|
| 98 |
-
The header `<string>`
|
| 99 |
-
|
| 100 |
-
`char_traits<
|
| 101 |
-
|
| 102 |
-
The requirements for the members of these specializations are given in
|
| 103 |
-
Clause [[char.traits.require]].
|
| 104 |
|
| 105 |
#### `struct char_traits<char>` <a id="char.traits.specializations.char">[[char.traits.specializations.char]]</a>
|
| 106 |
|
| 107 |
``` cpp
|
| 108 |
namespace std {
|
|
@@ -110,138 +84,159 @@ namespace std {
|
|
| 110 |
using char_type = char;
|
| 111 |
using int_type = int;
|
| 112 |
using off_type = streamoff;
|
| 113 |
using pos_type = streampos;
|
| 114 |
using state_type = mbstate_t;
|
|
|
|
| 115 |
|
| 116 |
static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
|
| 117 |
static constexpr bool eq(char_type c1, char_type c2) noexcept;
|
| 118 |
static constexpr bool lt(char_type c1, char_type c2) noexcept;
|
| 119 |
|
| 120 |
static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
|
| 121 |
static constexpr size_t length(const char_type* s);
|
| 122 |
static constexpr const char_type* find(const char_type* s, size_t n,
|
| 123 |
const char_type& a);
|
| 124 |
-
static char_type* move(char_type* s1, const char_type* s2, size_t n);
|
| 125 |
-
static char_type* copy(char_type* s1, const char_type* s2, size_t n);
|
| 126 |
-
static char_type* assign(char_type* s, size_t n, char_type a);
|
| 127 |
|
| 128 |
static constexpr int_type not_eof(int_type c) noexcept;
|
| 129 |
static constexpr char_type to_char_type(int_type c) noexcept;
|
| 130 |
static constexpr int_type to_int_type(char_type c) noexcept;
|
| 131 |
static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
|
| 132 |
static constexpr int_type eof() noexcept;
|
| 133 |
};
|
| 134 |
}
|
| 135 |
```
|
| 136 |
|
| 137 |
-
The defined types for `int_type`, `pos_type`, `off_type`, and
|
| 138 |
-
`state_type` shall be `int`, `streampos`, `streamoff`, and `mbstate_t`
|
| 139 |
-
respectively.
|
| 140 |
-
|
| 141 |
-
The type `streampos` shall be an *implementation-defined* type that
|
| 142 |
-
satisfies the requirements for `pos_type` in [[iostreams.limits.pos]]
|
| 143 |
-
and [[iostream.forward]].
|
| 144 |
-
|
| 145 |
-
The type `streamoff` shall be an *implementation-defined* type that
|
| 146 |
-
satisfies the requirements for `off_type` in [[iostreams.limits.pos]]
|
| 147 |
-
and [[iostream.forward]].
|
| 148 |
-
|
| 149 |
The type `mbstate_t` is defined in `<cwchar>` and can represent any of
|
| 150 |
the conversion states that can occur in an *implementation-defined* set
|
| 151 |
of supported multibyte character encoding rules.
|
| 152 |
|
| 153 |
-
The two-argument member `assign`
|
| 154 |
-
|
| 155 |
-
|
| 156 |
`unsigned char`.
|
| 157 |
|
| 158 |
-
The member `eof()`
|
| 159 |
|
| 160 |
-
#### `struct char_traits<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
``` cpp
|
| 163 |
namespace std {
|
| 164 |
template<> struct char_traits<char16_t> {
|
| 165 |
using char_type = char16_t;
|
| 166 |
using int_type = uint_least16_t;
|
| 167 |
using off_type = streamoff;
|
| 168 |
using pos_type = u16streampos;
|
| 169 |
using state_type = mbstate_t;
|
|
|
|
| 170 |
|
| 171 |
static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
|
| 172 |
static constexpr bool eq(char_type c1, char_type c2) noexcept;
|
| 173 |
static constexpr bool lt(char_type c1, char_type c2) noexcept;
|
| 174 |
|
| 175 |
static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
|
| 176 |
static constexpr size_t length(const char_type* s);
|
| 177 |
static constexpr const char_type* find(const char_type* s, size_t n,
|
| 178 |
const char_type& a);
|
| 179 |
-
static char_type* move(char_type* s1, const char_type* s2, size_t n);
|
| 180 |
-
static char_type* copy(char_type* s1, const char_type* s2, size_t n);
|
| 181 |
-
static char_type* assign(char_type* s, size_t n, char_type a);
|
| 182 |
|
| 183 |
static constexpr int_type not_eof(int_type c) noexcept;
|
| 184 |
static constexpr char_type to_char_type(int_type c) noexcept;
|
| 185 |
static constexpr int_type to_int_type(char_type c) noexcept;
|
| 186 |
static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
|
| 187 |
static constexpr int_type eof() noexcept;
|
| 188 |
};
|
| 189 |
}
|
| 190 |
```
|
| 191 |
|
| 192 |
-
The
|
| 193 |
-
|
| 194 |
-
and [[iostream.forward]].
|
| 195 |
|
| 196 |
-
The
|
| 197 |
-
|
| 198 |
|
| 199 |
-
|
| 200 |
-
that cannot appear as a valid UTF-16 code unit.
|
| 201 |
-
|
| 202 |
-
#### `struct char_traits<char32_t>` <a id="char.traits.specializations.char32_t">[[char.traits.specializations.char32_t]]</a>
|
| 203 |
|
| 204 |
``` cpp
|
| 205 |
namespace std {
|
| 206 |
template<> struct char_traits<char32_t> {
|
| 207 |
using char_type = char32_t;
|
| 208 |
using int_type = uint_least32_t;
|
| 209 |
using off_type = streamoff;
|
| 210 |
using pos_type = u32streampos;
|
| 211 |
using state_type = mbstate_t;
|
|
|
|
| 212 |
|
| 213 |
static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
|
| 214 |
static constexpr bool eq(char_type c1, char_type c2) noexcept;
|
| 215 |
static constexpr bool lt(char_type c1, char_type c2) noexcept;
|
| 216 |
|
| 217 |
static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
|
| 218 |
static constexpr size_t length(const char_type* s);
|
| 219 |
static constexpr const char_type* find(const char_type* s, size_t n,
|
| 220 |
const char_type& a);
|
| 221 |
-
static char_type* move(char_type* s1, const char_type* s2, size_t n);
|
| 222 |
-
static char_type* copy(char_type* s1, const char_type* s2, size_t n);
|
| 223 |
-
static char_type* assign(char_type* s, size_t n, char_type a);
|
| 224 |
|
| 225 |
static constexpr int_type not_eof(int_type c) noexcept;
|
| 226 |
static constexpr char_type to_char_type(int_type c) noexcept;
|
| 227 |
static constexpr int_type to_int_type(char_type c) noexcept;
|
| 228 |
static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
|
| 229 |
static constexpr int_type eof() noexcept;
|
| 230 |
};
|
| 231 |
}
|
| 232 |
```
|
| 233 |
|
| 234 |
-
The
|
| 235 |
-
|
| 236 |
-
and [[iostream.forward]].
|
| 237 |
|
| 238 |
-
The
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
The member `eof()` shall return an *implementation-defined* constant
|
| 242 |
-
that cannot appear as a Unicode code point.
|
| 243 |
|
| 244 |
#### `struct char_traits<wchar_t>` <a id="char.traits.specializations.wchar.t">[[char.traits.specializations.wchar.t]]</a>
|
| 245 |
|
| 246 |
``` cpp
|
| 247 |
namespace std {
|
|
@@ -249,43 +244,33 @@ namespace std {
|
|
| 249 |
using char_type = wchar_t;
|
| 250 |
using int_type = wint_t;
|
| 251 |
using off_type = streamoff;
|
| 252 |
using pos_type = wstreampos;
|
| 253 |
using state_type = mbstate_t;
|
|
|
|
| 254 |
|
| 255 |
static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
|
| 256 |
static constexpr bool eq(char_type c1, char_type c2) noexcept;
|
| 257 |
static constexpr bool lt(char_type c1, char_type c2) noexcept;
|
| 258 |
|
| 259 |
static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
|
| 260 |
static constexpr size_t length(const char_type* s);
|
| 261 |
static constexpr const char_type* find(const char_type* s, size_t n,
|
| 262 |
const char_type& a);
|
| 263 |
-
static char_type* move(char_type* s1, const char_type* s2, size_t n);
|
| 264 |
-
static char_type* copy(char_type* s1, const char_type* s2, size_t n);
|
| 265 |
-
static char_type* assign(char_type* s, size_t n, char_type a);
|
| 266 |
|
| 267 |
static constexpr int_type not_eof(int_type c) noexcept;
|
| 268 |
static constexpr char_type to_char_type(int_type c) noexcept;
|
| 269 |
static constexpr int_type to_int_type(char_type c) noexcept;
|
| 270 |
static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
|
| 271 |
static constexpr int_type eof() noexcept;
|
| 272 |
};
|
| 273 |
}
|
| 274 |
```
|
| 275 |
|
| 276 |
-
The
|
| 277 |
-
`
|
| 278 |
|
| 279 |
-
The
|
| 280 |
-
satisfies the requirements for `pos_type` in [[iostreams.limits.pos]]
|
| 281 |
-
and [[iostream.forward]].
|
| 282 |
-
|
| 283 |
-
The type `mbstate_t` is defined in `<cwchar>` and can represent any of
|
| 284 |
-
the conversion states that can occur in an *implementation-defined* set
|
| 285 |
-
of supported multibyte character encoding rules.
|
| 286 |
-
|
| 287 |
-
The two-argument members `assign`, `eq`, and `lt` shall be defined
|
| 288 |
-
identically to the built-in operators `=`, `==`, and `<` respectively.
|
| 289 |
-
|
| 290 |
-
The member `eof()` shall return `WEOF`.
|
| 291 |
|
|
|
|
| 1 |
## Character traits <a id="char.traits">[[char.traits]]</a>
|
| 2 |
|
| 3 |
This subclause defines requirements on classes representing *character
|
| 4 |
traits*, and defines a class template `char_traits<charT>`, along with
|
| 5 |
+
five specializations, `char_traits<char>`, `char_traits<char8_t>`,
|
| 6 |
+
`char_traits<char16_t>`, `char_traits<char32_t>`, and
|
| 7 |
+
`char_traits<wchar_t>`, that meet those requirements.
|
| 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. This subclause
|
| 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,
|
| 20 |
+
or iostream template as parameters `charT` and `traits`. If
|
| 21 |
+
`X::char_type` is not the same type as `C`, the program is ill-formed.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
### Character traits requirements <a id="char.traits.require">[[char.traits.require]]</a>
|
| 24 |
|
| 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 |
+
Operations on `X` shall not throw exceptions.
|
|
|
|
| 32 |
|
| 33 |
The class template
|
| 34 |
|
| 35 |
``` cpp
|
| 36 |
template<class charT> struct char_traits;
|
| 37 |
```
|
| 38 |
|
| 39 |
+
is provided in the header `<string>` as a basis for explicit
|
| 40 |
specializations.
|
| 41 |
|
| 42 |
### Traits typedefs <a id="char.traits.typedefs">[[char.traits.typedefs]]</a>
|
| 43 |
|
| 44 |
``` cpp
|
| 45 |
+
using int_type = see below;
|
| 46 |
```
|
| 47 |
|
| 48 |
+
*Preconditions:* `int_type` shall be able to represent all of the valid
|
| 49 |
+
characters converted from the corresponding `char_type` values, as well
|
| 50 |
+
as an end-of-file value, `eof()`. [^1]
|
| 51 |
|
| 52 |
``` cpp
|
| 53 |
+
using state_type = see below;
|
| 54 |
```
|
| 55 |
|
| 56 |
+
*Preconditions:* `state_type` meets the *Cpp17Destructible*
|
| 57 |
+
([[cpp17.destructible]]), *Cpp17CopyAssignable*
|
| 58 |
+
([[cpp17.copyassignable]]), *Cpp17CopyConstructible*
|
| 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>;
|
| 69 |
template<> struct char_traits<char32_t>;
|
| 70 |
template<> struct char_traits<wchar_t>;
|
| 71 |
}
|
| 72 |
```
|
| 73 |
|
| 74 |
+
The header `<string>` defines five specializations of the class template
|
| 75 |
+
`char_traits`: `char_traits<{}char>`, `char_traits<char8_t>`,
|
| 76 |
+
`char_traits<char16_t>`, `char_traits<char32_t>`, and
|
| 77 |
+
`char_traits<wchar_t>`.
|
|
|
|
|
|
|
| 78 |
|
| 79 |
#### `struct char_traits<char>` <a id="char.traits.specializations.char">[[char.traits.specializations.char]]</a>
|
| 80 |
|
| 81 |
``` cpp
|
| 82 |
namespace std {
|
|
|
|
| 84 |
using char_type = char;
|
| 85 |
using int_type = int;
|
| 86 |
using off_type = streamoff;
|
| 87 |
using pos_type = streampos;
|
| 88 |
using state_type = mbstate_t;
|
| 89 |
+
using comparison_category = strong_ordering;
|
| 90 |
|
| 91 |
static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
|
| 92 |
static constexpr bool eq(char_type c1, char_type c2) noexcept;
|
| 93 |
static constexpr bool lt(char_type c1, char_type c2) noexcept;
|
| 94 |
|
| 95 |
static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
|
| 96 |
static constexpr size_t length(const char_type* s);
|
| 97 |
static constexpr const char_type* find(const char_type* s, size_t n,
|
| 98 |
const char_type& a);
|
| 99 |
+
static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n);
|
| 100 |
+
static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n);
|
| 101 |
+
static constexpr char_type* assign(char_type* s, size_t n, char_type a);
|
| 102 |
|
| 103 |
static constexpr int_type not_eof(int_type c) noexcept;
|
| 104 |
static constexpr char_type to_char_type(int_type c) noexcept;
|
| 105 |
static constexpr int_type to_int_type(char_type c) noexcept;
|
| 106 |
static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
|
| 107 |
static constexpr int_type eof() noexcept;
|
| 108 |
};
|
| 109 |
}
|
| 110 |
```
|
| 111 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
The type `mbstate_t` is defined in `<cwchar>` and can represent any of
|
| 113 |
the conversion states that can occur in an *implementation-defined* set
|
| 114 |
of supported multibyte character encoding rules.
|
| 115 |
|
| 116 |
+
The two-argument member `assign` is defined identically to the built-in
|
| 117 |
+
operator `=`. The two-argument members `eq` and `lt` are defined
|
| 118 |
+
identically to the built-in operators `==` and `<` for type
|
| 119 |
`unsigned char`.
|
| 120 |
|
| 121 |
+
The member `eof()` returns `EOF`.
|
| 122 |
|
| 123 |
+
#### `struct char_traits<char8_t>` <a id="char.traits.specializations.char8.t">[[char.traits.specializations.char8.t]]</a>
|
| 124 |
+
|
| 125 |
+
``` cpp
|
| 126 |
+
namespace std {
|
| 127 |
+
template<> struct char_traits<char8_t> {
|
| 128 |
+
using char_type = char8_t;
|
| 129 |
+
using int_type = unsigned int;
|
| 130 |
+
using off_type = streamoff;
|
| 131 |
+
using pos_type = u8streampos;
|
| 132 |
+
using state_type = mbstate_t;
|
| 133 |
+
using comparison_category = strong_ordering;
|
| 134 |
+
|
| 135 |
+
static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
|
| 136 |
+
static constexpr bool eq(char_type c1, char_type c2) noexcept;
|
| 137 |
+
static constexpr bool lt(char_type c1, char_type c2) noexcept;
|
| 138 |
+
|
| 139 |
+
static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
|
| 140 |
+
static constexpr size_t length(const char_type* s);
|
| 141 |
+
static constexpr const char_type* find(const char_type* s, size_t n,
|
| 142 |
+
const char_type& a);
|
| 143 |
+
static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n);
|
| 144 |
+
static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n);
|
| 145 |
+
static constexpr char_type* assign(char_type* s, size_t n, char_type a);
|
| 146 |
+
static constexpr int_type not_eof(int_type c) noexcept;
|
| 147 |
+
static constexpr char_type to_char_type(int_type c) noexcept;
|
| 148 |
+
static constexpr int_type to_int_type(char_type c) noexcept;
|
| 149 |
+
static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
|
| 150 |
+
static constexpr int_type eof() noexcept;
|
| 151 |
+
};
|
| 152 |
+
}
|
| 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
|
| 164 |
namespace std {
|
| 165 |
template<> struct char_traits<char16_t> {
|
| 166 |
using char_type = char16_t;
|
| 167 |
using int_type = uint_least16_t;
|
| 168 |
using off_type = streamoff;
|
| 169 |
using pos_type = u16streampos;
|
| 170 |
using state_type = mbstate_t;
|
| 171 |
+
using comparison_category = strong_ordering;
|
| 172 |
|
| 173 |
static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
|
| 174 |
static constexpr bool eq(char_type c1, char_type c2) noexcept;
|
| 175 |
static constexpr bool lt(char_type c1, char_type c2) noexcept;
|
| 176 |
|
| 177 |
static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
|
| 178 |
static constexpr size_t length(const char_type* s);
|
| 179 |
static constexpr const char_type* find(const char_type* s, size_t n,
|
| 180 |
const char_type& a);
|
| 181 |
+
static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n);
|
| 182 |
+
static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n);
|
| 183 |
+
static constexpr char_type* assign(char_type* s, size_t n, char_type a);
|
| 184 |
|
| 185 |
static constexpr int_type not_eof(int_type c) noexcept;
|
| 186 |
static constexpr char_type to_char_type(int_type c) noexcept;
|
| 187 |
static constexpr int_type to_int_type(char_type c) noexcept;
|
| 188 |
static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
|
| 189 |
static constexpr int_type eof() noexcept;
|
| 190 |
};
|
| 191 |
}
|
| 192 |
```
|
| 193 |
|
| 194 |
+
The two-argument members `assign`, `eq`, and `lt` are defined
|
| 195 |
+
identically to the built-in operators `=`, `==`, and `<`, respectively.
|
|
|
|
| 196 |
|
| 197 |
+
The member `eof()` returns an *implementation-defined* constant that
|
| 198 |
+
cannot appear as a valid UTF-16 code unit.
|
| 199 |
|
| 200 |
+
#### `struct char_traits<char32_t>` <a id="char.traits.specializations.char32.t">[[char.traits.specializations.char32.t]]</a>
|
|
|
|
|
|
|
|
|
|
| 201 |
|
| 202 |
``` cpp
|
| 203 |
namespace std {
|
| 204 |
template<> struct char_traits<char32_t> {
|
| 205 |
using char_type = char32_t;
|
| 206 |
using int_type = uint_least32_t;
|
| 207 |
using off_type = streamoff;
|
| 208 |
using pos_type = u32streampos;
|
| 209 |
using state_type = mbstate_t;
|
| 210 |
+
using comparison_category = strong_ordering;
|
| 211 |
|
| 212 |
static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
|
| 213 |
static constexpr bool eq(char_type c1, char_type c2) noexcept;
|
| 214 |
static constexpr bool lt(char_type c1, char_type c2) noexcept;
|
| 215 |
|
| 216 |
static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
|
| 217 |
static constexpr size_t length(const char_type* s);
|
| 218 |
static constexpr const char_type* find(const char_type* s, size_t n,
|
| 219 |
const char_type& a);
|
| 220 |
+
static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n);
|
| 221 |
+
static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n);
|
| 222 |
+
static constexpr char_type* assign(char_type* s, size_t n, char_type a);
|
| 223 |
|
| 224 |
static constexpr int_type not_eof(int_type c) noexcept;
|
| 225 |
static constexpr char_type to_char_type(int_type c) noexcept;
|
| 226 |
static constexpr int_type to_int_type(char_type c) noexcept;
|
| 227 |
static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
|
| 228 |
static constexpr int_type eof() noexcept;
|
| 229 |
};
|
| 230 |
}
|
| 231 |
```
|
| 232 |
|
| 233 |
+
The two-argument members `assign`, `eq`, and `lt` are defined
|
| 234 |
+
identically to the built-in operators `=`, `==`, and `<`, respectively.
|
|
|
|
| 235 |
|
| 236 |
+
The member `eof()` returns an *implementation-defined* constant that
|
| 237 |
+
cannot appear as a Unicode code point.
|
|
|
|
|
|
|
|
|
|
| 238 |
|
| 239 |
#### `struct char_traits<wchar_t>` <a id="char.traits.specializations.wchar.t">[[char.traits.specializations.wchar.t]]</a>
|
| 240 |
|
| 241 |
``` cpp
|
| 242 |
namespace std {
|
|
|
|
| 244 |
using char_type = wchar_t;
|
| 245 |
using int_type = wint_t;
|
| 246 |
using off_type = streamoff;
|
| 247 |
using pos_type = wstreampos;
|
| 248 |
using state_type = mbstate_t;
|
| 249 |
+
using comparison_category = strong_ordering;
|
| 250 |
|
| 251 |
static constexpr void assign(char_type& c1, const char_type& c2) noexcept;
|
| 252 |
static constexpr bool eq(char_type c1, char_type c2) noexcept;
|
| 253 |
static constexpr bool lt(char_type c1, char_type c2) noexcept;
|
| 254 |
|
| 255 |
static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);
|
| 256 |
static constexpr size_t length(const char_type* s);
|
| 257 |
static constexpr const char_type* find(const char_type* s, size_t n,
|
| 258 |
const char_type& a);
|
| 259 |
+
static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n);
|
| 260 |
+
static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n);
|
| 261 |
+
static constexpr char_type* assign(char_type* s, size_t n, char_type a);
|
| 262 |
|
| 263 |
static constexpr int_type not_eof(int_type c) noexcept;
|
| 264 |
static constexpr char_type to_char_type(int_type c) noexcept;
|
| 265 |
static constexpr int_type to_int_type(char_type c) noexcept;
|
| 266 |
static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;
|
| 267 |
static constexpr int_type eof() noexcept;
|
| 268 |
};
|
| 269 |
}
|
| 270 |
```
|
| 271 |
|
| 272 |
+
The two-argument members `assign`, `eq`, and `lt` are defined
|
| 273 |
+
identically to the built-in operators `=`, `==`, and `<`, respectively.
|
| 274 |
|
| 275 |
+
The member `eof()` returns `WEOF`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 276 |
|