What types will be expected to be the type of operands of prefix++ is defined as the following:
The type of the operand shall be an arithmetic type other than cv bool, or a pointer to a completely-defined object type.
The formal definition for wording object type is defined as:
basic.types#general-8
An object type is a (possibly cv-qualified) type that is not a function type, not a reference type, and not cv void.
However, consider the below code:
#include <iostream>
struct Test{
int a;
};
int main(){
int Test::* member_ptr = &Test::a;
++member_ptr; // Permite this operation?
}
According to the definition of object type, member type is not be excluded by it. Does it mean we could consider member type to be an object type? you will say, members are not objects, so the pointer to member cannot be used as the operand of prefix++. But, I will argue here, Is a function an object? That's absolutely not, why function type is excluded by the definition for object type, also reference type. So, Is it a defect that didn't place a member type to the exclusive set?
UPDATE
The answers from M.M quotes the rule:
Except for pointers to static members, text referring to “pointers” does not apply to pointers to members.
I know that rule. However, I thought the pointers just refers to literal pointers. After all, the text pointers has appeared in the standard. Such as: expr.eq#2 Comparing pointers is defined as follows. (The rule can absolutely be applied here, that is, does not apply to pointers to members). However, I don't think the text pointers also denotes the form pointer to X(where X is anything other than member,e.g object, function). Is it necessary to clarify that rule?
Except describes anywhere,
pointer to X(where X may be object, function, or type) orpointersdoes not apply topointer to member.