# 21 Strings library [strings]

## 21.2 Character traits [char.traits]

### 21.2.2 Character traits requirements [char.traits.require]

Table 69: Character traits requirements [tab:char.traits.req]
 ðŸ”— Expression Return type Assertion/note Complexity ðŸ”— pre-/post-condition ðŸ”— X​::​char_­type C compile-time ðŸ”— X​::​int_­type (described in [char.traits.typedefs]) compile-time ðŸ”— X​::​off_­type (described in [iostreams.limits.pos] and [iostream.forward]) compile-time ðŸ”— X​::​pos_­type (described in [iostreams.limits.pos] and [iostream.forward]) compile-time ðŸ”— X​::​state_­type (described in [char.traits.typedefs]) compile-time ðŸ”— 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, zero 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: p not in [s, s+n). 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