C ++十进制类型和括号-为什么?

问题描述 投票:7回答:2

主题为discussed before,但这不是重复的。

[当有人询问decltype(a)decltype((a))之间的差异时,通常的答案是-a是变量,(a)是表达式。我觉得这个答案不令人满意。

首先,a也是一个表达式。 primary expression的选项包括->

For an expression e, the type denoted by decltype(e) is defined as follows:
(1.1)  if e is an unparenthesized id-expression naming a structured binding, ...
(1.2)  otherwise, if e is an unparenthesized id-expression naming a non-type template-parameter, ...
(1.3)  otherwise, if e is an unparenthesized id-expression or an unparenthesized class member access, ...
(1.4)  otherwise, ...

所以问题仍然存在。 为什么

括号的区别?是否有人熟悉其背后的技术论文或委员会讨论?括号的明确考虑导致认为这不是疏忽,所以一定有我所缺少的技术原因。

之前已经讨论过该主题,但这不是重复的。当有人问decltype(a)和decltype((a))之间的区别时,通常的回答是-a是变量,(a)是...

c++ c++11 language-lawyer
2个回答
4
投票

为什么括号要区别对待?


0
投票
这不是疏忽。有趣的是,在

Decltype and auto(revision 4)(N1705 = 04-0145)

© www.soinside.com 2019 - 2024. All rights reserved.