int i=0,*p = &i;
decltype(p) c;
为什么p返回的数据类型是int &,不是很能理解,是可以把解引用理解为等价于引用吗?
decltype(*p)
中*p
是表达式,其结果是左值,故decltype(*p)
返回的类型是int&
参考
https://en.cppreference.com/w/cpp/language/decltype
decltype ( expression )
If the argument is any other expression of type T, and
a) if the value category of expression is xvalue, then decltype yields T&&;
b) if the value category of expression is lvalue, then decltype yields T&;
c) if the value category of expression is prvalue, then decltype yields T.
你是什么编译器?还是你自己瞎猜
*p是左值