gpt4 book ai didi

C++11 条件包含控制表达式 "types act as if same representation as"?

转载 作者:行者123 更新时间:2023-11-30 04:20:34 24 4
gpt4 key购买 nike

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

For the purposes of this token conversion and evaluation all signed and unsigned integer types act as if they have the same representation as, respectively, intmax_t or uintmax_t.

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

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

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

最佳答案

这基本上意味着预处理器不必处理带有类型信息;它可以完成所有的积分运算在单一类型中。大多数时候,它不会有所不同,但这确实意味着像 UINT_MAX + 1U 这样的结果在一个非常大的数字中,在预处理器之外,它将导致 0

关于C++11 条件包含控制表达式 "types act as if same representation as"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15208332/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com