本文介绍了什么是decltype(0 + 0)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! (由提供答案) 给定N3290,§7.1.6.2p4,其中列表项未编号,但为了方便起见编号: 项目1不适用,2可能,但如果不是,则3不适用,将是结果。那么,什么是xvalue,是0 + 0是xvalue? §3.10p1: 8.3.2这将是有帮助的,但我知道0 + 0不涉及任何右值引用。文字0是一个prvalue,它是不是xvalue的右值(§3.10p1)。我相信0 + 0也是贬值。如果是这样,decltype(0 + 0)将是int(不是&&)。 我在我的解释中错过了什么吗?这个代码是否格式良好? decltype(0 + 0)x; //未初始化。 代码在GCC 4.7.0 20110427和Clang 2.9(trunk 126116)上编译。如果decltype指定了一个int&&& c> ,每个常量表达式是一个prvalue。因此,规则4适用于以下情况: 到所有字面常量表达式。 (Prompted by an answer.)Given N3290, §7.1.6.2p4, where the list items are unnumbered, but numbered here for our convenience:What is the type specified by decltype(0 + 0)?Item 1 doesn't apply, 2 might, but if not, then 3 doesn't apply and 4 would be the result. So, what is an xvalue, and is 0 + 0 an xvalue?§3.10p1:I don't see anything in §8.3.2 that would be helpful here, but I do know "0 + 0" doesn't involve any rvalue-references. The literal 0 is a prvalue, which is "an rvalue that is not an xvalue" (§3.10p1). I believe "0 + 0" is also a prvalue. If that's true, "decltype(0 + 0)" would be int (not int&&).Have I missed something in my interpretation? Is this code well-formed?decltype(0 + 0) x; // Not initialized.The code compiles on GCC 4.7.0 20110427 and Clang 2.9 (trunk 126116). It would not be well-formed if the decltype specified an int&& type, for example. 解决方案 From 5.19 [expr.const], every literal constant expression is a prvalue.Therefore rule 4 applies to all literal constant expressions. 这篇关于什么是decltype(0 + 0)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-24 09:02