I was reading this article on Wikipedia regarding C++11 Type Inference feature.
There is an example and I quote:
#include
int main() {
I found a good description here. It describes the difference between:
struct A { double x; };
const A* a = new A();
...
decltype(a->x) x4; // type is double
decltype((a->x)) x5; // type is const double&
and I quote:
The reason for the difference between the latter two invocations of decltype is that the parenthesized expression
(a->x)is neither an id-expression nor a member access expression, and therefore does not denote a named object. [13]Because the expression is an lvalue, its deduced type is "reference to the type of the expression", or
const double&. [10]