1

在 C++ 标准的 16.1.4(条件包含)中,它说:

出于此令牌转换和评估的目的,所有有符号和无符号整数类型的行为就好像它们分别具有与 intmax_t 或 uintmax_t 相同的表示。

我不明白这一点。“表现得好像它们具有相同的表示形式”是什么意思?

integer-literals根据 2.14.2.2 中解释的值和后缀,将其标记为特定的基本类型。

16.1.4 引用是否说他们的类型被intmax_tand以某种方式“替换”了uintmax_t?(这是否完全等同于将整数文字静态转换为intmax_tor uintmax_t?)

4

1 回答 1

2

It basically means that the preprocessor doesn't have to deal with type information; it can do all of its integral arithmetic in a single type. Most of the time, it won't make a different, but it does mean that something like UINT_MAX + 1U will result in a very big number, where as outside of the preprocessor, it will result in 0.

于 2013-03-04T18:40:33.827 回答