命名右值引用的类型是什么?
What is the type of a named rvalue reference?
考虑以下代码:
int&& x = 42;
static_assert(std::is_same<decltype( x ), int&&>::value, "&&");
static_assert(std::is_same<decltype((x)), int& >::value, "&" );
那么,x
的类型是什么?是int&&
还是int&
?
(看完这个答案后我问了自己这个问题)
x
(变量的)类型为int&&
。所以decltype(x)
生成int&&
。表达式x
的类型为int
。如果表达式是左值,decltype((x))
产生对表达式类型的左值引用。所以decltype((x))
生成int&
。
相关文章:
- 标准 N3337 5.2.10 第 7 条中的C++"类型"是什么意思?
- 如何声明一个标准::提升直方图的向量?提升直方图的类型是什么?
- 类名后跟括号的类型是什么
- std::chrono::duration::count函数的实际结果类型是什么
- c++运算符重载-我实际返回的操作数类型是什么
- 运算符和返回类型是什么意思?
- 指向 2D 数组的指针的类型是什么?
- RSA_verify中预期的数据类型是什么,无法验证从 Java 生成的签名
- 共享_ptr中多功能数组的类型是什么
- 构造函数的类型是什么?
- 字符串中单个字符作为数组的数据类型是什么
- 该结构继承的类型是什么
- 如果我获得Integer和Double的产品,输出的数据类型是什么
- C 中被视为可可的类型是什么
- 当函数采用右值引用时,函数中该变量的类型是什么?
- STD :: SETW,STD :: SETFILL等的真实返回类型是什么?
- 模板类中引用的引用的类型是什么
- const自动参考绑定到(NULL)指针 - 实际类型是什么
- 包含通过引用捕获的 lambda 函数的"variable"的类型是什么?
- 通过插座发送的内容的数据类型是什么