本文介绍了与类型转换有关,等级是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据C ++ 11标准(草案n3337)§5/9:

-否则,如果两个操作数都具有符号整数类型,或者都具有 无符号整数类型,具有较小整数类型的操作数 转换 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:







...







...

我无法在描述该级别的任何地方找到列表每种类型的排名.

I haven't been able to find a list anywhere describing the level of rank for each type.

推荐答案

-除char和signed char外,没有两个带符号整数类型(如果为char 已签名),即使他们具有相同的等级,也应具有相同的等级 表示形式.

— 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.

— long long int的等级应大于long long的等级 int,该值应大于int的等级,该值应为 大于short int的等级,该等级应大于 签名字符的等级.

— 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.

-char16_t,char32_t和wchar_t的等级应等于等级 它们的基础类型(3.9.1).

— 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.

-对于所有整数类型T1,T2和T3,如果T1的排名大于T2 并且T2的等级高于T3,则T1的等级高于 T3.

— 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.

这篇关于与类型转换有关,等级是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-09 22:16