int x;
decltype(x) 和 decltype((x)) 的类型是不一样的。
decltype(x) 和 decltype(*&x) 的类型是不一样的。
decltype(x)的类型是 int
decltype((x)) 和 decltype(*&x) 的类型是 int&
C++11标准:
The type denoted by decltype(e) is defined as follows:
— if e is an unparenthesized id-expression or an unparenthesized class member
access (5.2.5), decltype(e) is the type of the entity named by e. If there
is no such entity, or if e names a set of overloaded functions, the program
is ill-formed;
— otherwise, if e is an xvalue, decltype(e) is T&&, where T is the type of e;
— otherwise, if e is an lvalue, decltype(e) is T&, where T is the type of e;
— otherwise, decltype(e) is the type of e.