6.3 KiB
6.3 KiB
[char.traits.require]
27 Strings library [strings]
27.2 Character traits [char.traits]
27.2.2 Character traits requirements [char.traits.require]
In Table 87,X denotes a traits class defining types and functions for the character container typeC;c andd denote values of typeC;p andq denote values of typeconst C*;s denotes a value of typeC*;n,i andj denote values of typesize_t;e andf denote values of typeX::int_type;pos denotes a value of typeX::pos_type; andr denotes an lvalue of typeC.
No expression which is part of the character traits requirements specified in [char.traits.require] shall exit via an exception.
Table 87 — Character traits requirements [tab:char.traits.req]
| ð Expression |
Return type | Assertion/note | Complexity |
|---|---|---|---|
| ð | pre-/post-condition | ||
| ð X::char_type |
C | ||
| ð X::int_type |
(described in [char.traits.typedefs]) | ||
| ð X::off_type |
(described in [iostreams.limits.pos] and [iostream.forward]) | ||
| ð X::pos_type |
(described in [iostreams.limits.pos] and [iostream.forward]) | ||
| ð X::state_type |
(described in [char.traits.typedefs]) | ||
| ð X::eq(c,d) |
bool | Returns: whether c is to be treated as equal to d. | constant |
| ð X::lt(c,d) |
bool | Returns: whether c is to be treated as less than d. | constant |
| ð X::compare(p,q,n) |
int | Returns: 0 if for each i in [0, n), X::eq(p[i],q[i]) is true; else, a negative value if, for some j in [0, n), X::lt(p[j],q[j]) is true and for each i in [0, j) X::eq(p[i],q[i]) is true; else a positive value. | linear |
| ð X::length(p) |
size_t | Returns: the smallest i such that X::eq(p[i],charT()) is true. | linear |
| ð X::find(p,n,c) |
const X::char_type* | Returns: the smallest q in [p, p+n) such that X::eq(*q,c) is true, nullptr otherwise. | linear |
| ð X::move(s,p,n) |
X::char_type* | for each i in [0, n), performs X::assign(s[i],p[i]). Copies correctly even where the ranges [p, p+n) and [s, s+n) overlap. Returns: s. |
linear |
| ð X::copy(s,p,n) |
X::char_type* | Preconditions: The ranges [p, p+n) and [s, s+n) do not overlap. Returns: s. for each i in [0, n), performs X::assign(s[i],p[i]). |
linear |
| ð X::assign(r,d) |
(not used) | assigns r=d. | constant |
| ð X::assign(s,n,c) |
X::char_type* | for each i in [0, n), performs X::assign(s[i],c). Returns: s. |
linear |
| ð X::not_eof(e) |
int_type | Returns: e if X::eq_int_type(e,X::eof()) is false, otherwise a value f such that X::eq_int_type(f,X::eof()) is false. | constant |
| ð X::to_char_type(e) |
X::char_type | Returns: if for some c, X::eq_int_type(e,X::to_int_type(c)) is true, c; else some unspecified value. | constant |
| ð X::to_int_type(c) |
X::int_type | Returns: some value e, constrained by the definitions of to_char_type and eq_int_type. | constant |
| ð X::eq_int_type(e,f) |
bool | Returns: for all c and d, X::eq(c,d) is equal to X::eq_int_type(X::to_int_type(c), X::to_int_type(d)); otherwise, yields true if e and f are both copies of X::eof(); otherwise, yields false if one of e and f is a copy of X::eof() and the other is not; otherwise the value is unspecified. | constant |
| ð X::eof() |
X::int_type | Returns: a value e such that X::eq_int_type(e,X::to_int_type(c)) is false for all values c. | constant |
The class template
template struct char_traits; is provided in the header as a basis for explicit specializations.