One of the rules explaining how the decltype
keyword works states that:
If the argument is [...] an unparenthesized class member access expression, then decltype
yields the type of the entity named by this expression. (https://en.cppreference.com/w/cpp/language/decltype)
However, consider the following example (pseudo-code for brevity):
struct X {
int a;
};
X x;
int X::* ptr = &X::a;
std::is_lvalue_reference<decltype(x.*ptr)>::value; //Evaluates to 1. The type is int&
std::is_rvalue_reference<decltype(X().*ptr)>::value; //Evaluates to 1. The type is int&&
This implies that accessing a class member through a pointer to member is not a class member access expression. It's treated as if it was just a normal expression, for which the rule I quoted doesn't apply.
Therefore, my question is: how can I know what exactly counts as a class member access expression for the purpose of decltype
? What source should I look into to find a precise definition?