与类型转换相关的排名意味着什么?
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.
— 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.
— 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.
— 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,
因为这与数组中的维数有关...
关于整数类型和浮点类型,我认为是指它们的潜在大小。
C++ 标准保证:
1 == sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long) <= sizeof(long long)
我认为当时的排名是正确的吗:
<strong>排名</strong>
<strong>类型</strong>
1
char
2
short
3
int
4
long
5
long long
...
我没能在任何地方找到 list 来描述每种类型的级别。
Every integer type has an integer conversion rank defined as follows:
— No two signed integer types other than char and signed char (if char
is signed) shall have the same rank, even if they have the same
representation.
— The rank of a signed integer type shall be greater than the rank of
any signed integer type with a smaller size.
— The rank of long long int shall be greater than the rank of long
int, which shall be greater than the rank of int, which shall be
greater than the rank of short int, which shall be greater than the
rank of signed char.
— The rank of any unsigned integer type shall equal the rank of the
corresponding signed integer type
— The rank of any standard integer type shall be greater than the rank
of any extended integer type with the same size.
— The rank of char shall equal the rank of signed char and unsigned
char.
— The rank of bool shall be less than the rank of all other standard
integer types.
— The ranks of char16_t, char32_t, and wchar_t shall equal the ranks
of their underlying types (3.9.1).
— The rank of any extended signed integer type relative to another
extended signed integer type with the same size is
implementation-defined, but still subject to the other rules for
determining the integer conversion rank.
— For all integer types T1, T2, and T3, if T1 has greater rank than T2
and T2 has greater rank than T3, then T1 shall have greater rank than
T3.
来自 C++11 标准(草案 n3337)§5/9:
— If both operands have the same type, no further conversion is needed.
— 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.
— 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.
— 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,
因为这与数组中的维数有关...
关于整数类型和浮点类型,我认为是指它们的潜在大小。
C++ 标准保证:
1 == sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long) <= sizeof(long long)
我认为当时的排名是正确的吗:
<strong>排名</strong>
<strong>类型</strong>
1
char
2
short
3
int
4
long
5
long long
...
我没能在任何地方找到 list 来描述每种类型的级别。
Every integer type has an integer conversion rank defined as follows:
— No two signed integer types other than char and signed char (if char is signed) shall have the same rank, even if they have the same representation.
— The rank of a signed integer type shall be greater than the rank of any signed integer type with a smaller size.
— The rank of long long int shall be greater than the rank of long int, which shall be greater than the rank of int, which shall be greater than the rank of short int, which shall be greater than the rank of signed char.
— The rank of any unsigned integer type shall equal the rank of the corresponding signed integer type
— The rank of any standard integer type shall be greater than the rank of any extended integer type with the same size.
— The rank of char shall equal the rank of signed char and unsigned char.
— The rank of bool shall be less than the rank of all other standard integer types.
— The ranks of char16_t, char32_t, and wchar_t shall equal the ranks of their underlying types (3.9.1).
— The rank of any extended signed integer type relative to another extended signed integer type with the same size is implementation-defined, but still subject to the other rules for determining the integer conversion rank.
— For all integer types T1, T2, and T3, if T1 has greater rank than T2 and T2 has greater rank than T3, then T1 shall have greater rank than T3.