与类型转换有关,等级是什么意思? [英] What does rank mean in relation to type conversion?
问题描述
根据C ++ 11标准(草案n3337)§5/9:
-如果两个操作数具有相同的类型,则不进行进一步的转换 需要.
— If both operands have the same type, no further conversion is needed.
-否则,如果两个操作数都具有符号整数类型,或者都具有 无符号整数类型,具有较小整数类型的操作数 转换 rank 应转换为具有以下内容的操作数类型 排名.
— Otherwise, if both operands have signed integer types or both have unsigned integer types, the operand with the type of lesser integer conversion rank shall be converted to the type of the operand with greater rank.
-否则,如果具有无符号整数类型的操作数具有 rank 大于或等于另一个操作数类型的 rank , 带符号整数类型的操作数应转换为 无符号整数类型的操作数.
— Otherwise, if the operand that has unsigned integer type has rank greater than or equal to the rank of the type of the other operand, the operand with signed integer type shall be converted to the type of the operand with unsigned integer type.
-否则,如果带符号整数类型的操作数的类型可以 用unsigned表示操作数类型的所有值 整数类型,无符号整数类型的操作数应为 转换为带符号整数类型的操作数的类型.
— Otherwise, if the type of the operand with signed integer type can represent all of the values of the type of the operand with unsigned integer type, the operand with unsigned integer type shall be converted to the type of the operand with signed integer type.
-否则,两个操作数均应转换为无符号整数 与带符号整数的操作数类型相对应的类型 类型.
— Otherwise, both operands shall be converted to the unsigned integer type corresponding to the type of the operand with signed integer type.
在这种情况下,排名是什么意思?
当然,它不是指 std :: rank ,
因为这与数组中的维数有关...
What does rank mean in this context?
Surely it's not referring to std::rank,
as that has to do with the number of dimensions in an array...
就整数类型和浮点类型而言,我认为它指的是它们的潜在大小.
In terms of integral types and floating point types, I think it refers to their potential sizes.
C ++标准保证:
1 == sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long) <= sizeof(long long)
我正确地假设当时的排名是:
am I right to assume then that the ranks are then:
Rank
Type
1
char
2
short
3
int
4
long
5
long long
...
Rank
Type
1
char
2
short
3
int
4
long
5
long long
...
我无法在描述该级别的任何地方找到列表每种类型的排名.
I haven't been able to find a list anywhere describing the level of rank for each type.