指向非静态成员函数的指针 "formally" 不被视为指针
Are pointers to non-static member function "formally" not considered pointers
我看到 this 上面写着:
Member function pointers are not pointers. Pointers to non-member functions, including static member functions, are pointers.
以上引用似乎暗示指向非静态成员函数的指针不是指针。
同样,我阅读了here:
A member pointer is a different type category from a ordinary pointer.
我的问题是以上引述在技术上(正式根据标准)是否正确?我的意思是我们使用术语 指向非静态成员函数的“指针”。但如果它们实际上不是指针,那么为什么首先使用术语“指针”呢?我的理解是,这是因为尽管“指向成员函数的指针”在许多方面与普通指针不同,但它们在一个方面仍然与普通指针相似,即它们指向某物(意思是保存地址)。
我也试过:
std::cout<<std::is_pointer_v<void(A::*)()><<std::endl;
0
确认指向非静态成员函数的指针不被视为指针。
所引用的相关陈述似乎已通过标准中的以下陈述得到验证。
[ Note: See also [expr.unary] and [expr.mptr.oper]. The type “pointer to member” is distinct from the type “pointer”, that is, a pointer to member is declared only by the pointer to member declarator syntax, and never by the pointer declarator syntax. There is no “reference-to-member” type in C++. — end note ]
...Except for pointers to static members, text referring to “pointers” does not apply to pointers to members...
我看到 this 上面写着:
Member function pointers are not pointers. Pointers to non-member functions, including static member functions, are pointers.
以上引用似乎暗示指向非静态成员函数的指针不是指针。
同样,我阅读了here:
A member pointer is a different type category from a ordinary pointer.
我的问题是以上引述在技术上(正式根据标准)是否正确?我的意思是我们使用术语 指向非静态成员函数的“指针”。但如果它们实际上不是指针,那么为什么首先使用术语“指针”呢?我的理解是,这是因为尽管“指向成员函数的指针”在许多方面与普通指针不同,但它们在一个方面仍然与普通指针相似,即它们指向某物(意思是保存地址)。
我也试过:
std::cout<<std::is_pointer_v<void(A::*)()><<std::endl;
0
确认指向非静态成员函数的指针不被视为指针。
所引用的相关陈述似乎已通过标准中的以下陈述得到验证。
[ Note: See also [expr.unary] and [expr.mptr.oper]. The type “pointer to member” is distinct from the type “pointer”, that is, a pointer to member is declared only by the pointer to member declarator syntax, and never by the pointer declarator syntax. There is no “reference-to-member” type in C++. — end note ]
...Except for pointers to static members, text referring to “pointers” does not apply to pointers to members...