The decltype
specifier rules are here: link
Your case falls into any expression (third item), because *p
is not a id-expression , nor a class member access , but rather any 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
.
The value category of the expression *p
( indirection expression ) is defined as a lvalue :
The following expressions are lvalue expressions:
- ...
-
*p
, the built-in indirection expression;
So, the type where decltype(*p)
results comes from rule 3.b .: if the value category of expression is lvalue, then decltype yields T&
, where T
is the type of expression *p
, which in this case is int
. Substituting, we have int&
as the resulting type.