gpt4 book ai didi

c++ - 哪些右值有名字?

转载 作者:IT老高 更新时间:2023-10-28 22:59:01 26 4
gpt4 key购买 nike

@FredOverflow mentioned in the C++ chatroom this 是具有名称的右值的罕见情况。 C++0x FDIS 在 5.1.1 [expr.prim.general] p4 下提到:

Otherwise, if a member-declarator declares a non-static data member (9.2) of a class X, the expression this is a prvalue of type “pointer to X” within the optional brace-or-equal-initializer. It shall not appear elsewhere in the member-declarator. (emphasis mine)

如果有的话,还有什么其他的?

最佳答案

一个突出的例子是枚举数

enum arity { one, two };

表达式 onetwo 是右值(更具体地说,是 C++0x 中的右值)。另一个是模板非类型参数

template<int *P> struct A { };

表达式 P 也是一个右值(更具体地说,C++0x 中的右值)。

关于c++ - 哪些右值有名字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6162226/

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