【发布时间】:2019-06-11 10:43:18
【问题描述】:
非常简单的问题,我无法搜索到答案。
例如:
int a = 0;
int& b = x;
int&& c = 1;
decltype((a)) x; // what is the type of x?
decltype((b)) y; // what is the type of y?
decltype((c)) z; // what is the type of z?
也许我应该将 x、y 和 z 分配给某个值以获得不同的结果,我不确定。
编辑:
根据下面的双括号将示例int 转换为参考:
https://github.com/AnthonyCalandra/modern-cpp-features#decltype
int a = 1; // `a` is declared as type `int`
int&& f = 1; // `f` is declared as type `int&&`
decltype(f) g = 1; // `decltype(f) is `int&&`
decltype((a)) h = g; // `decltype((a))` is int&
【问题讨论】:
-
(a),(b),(c) 是左值表达式。和 decltype(a = 1) 一样
标签: c++ c++11 reference rvalue-reference decltype