From C++11 standard (draft 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.
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.
The C++ Standard guarantees that:
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
...
I haven't been able to find a list anywhere describing the level of rank for each type.