I was studying about the differences between auto
and decltype
type specifier and I saw in another question that when I use decltype
with a reference, like this:
const int ci = 0, &cj = ci;
decltype(ci) x = 0;
decltype(cj) y = x;
decltype(cj)
will not give me the type of the object that cj
refers to (that is, const int
) but will give me the type of cj
itself. So y
will be const int&
.
Why does this happen? And it could affect my code in someway? Is it related to the difference between decltype()
and decltype(())
?