cpp/named req/CharTraits
From cppreference.com
Template:cpp/concept/title Template:cpp/concept/navbar
Template:concept is a traits class that abstracts basic character and string operations for a given character type. Most standard library string and input/output classes require a Template:concept template type parameter alongside a corresponding character template type parameter
Requirements
No operation on Template:concept may throw an exception.
Given
- CharT, a character type
- X, a Template:concept type for type CharT
- c, d, objects of type CharT
- p, q, objects of type const CharT*
- s, an object of type CharT*
- n, i, j, objects of type std::size_t
- e, f, objects of type X::int_type
- pos, an object of type X::pos_type
- state, an object of type X::state_type
- r, an lvalue of type CharT
expression | return type | semantics | complexity |
---|---|---|---|
X::char_type | CharT | Used to refer to the character type | Compile-time |
X::int_type | An type that can hold all valid values of X::char_type plus X::eof() | Compile-time | |
X::off_type | Invokes implementation-defined behaviour if not std::streamoff when X is used as the traits template parameter in input/output classes | Compile-time | |
X::pos_type | Invokes implementation-defined behaviour if not std::streampos when X is used as the traits template parameter in input/output classes | Compile-time | |
X::state_type | Template:concept, Template:concept, Template:concept | 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:
|
Linear |
X::length(p) | std::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:
|
Linear |
X::move(s,p,n) | X::char_type* |
|
Linear |
X::copy(s,p,n) | X::char_type* |
|
Linear |
X::assign(r,d) | (Not used) | Assigns r = d | Constant |
X::assign(s,n,c) | X::char_type* |
|
Linear |
X::not_eof(e) | X::int_type | Returns:
|
Constant |
X::to_char_type(e) | X::char_type | Returns:
|
Constant |
X::to_int_type(c) | X::int_type | Returns: some value e, constrained by the definitions of X::to_char_type and X::eq_int_type | Constant |
X::eq_int_type(e,f) | bool |
|
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 |