是非静态成员函数的指示。不被视为指针
我遇到 this
成员函数指针不是指针。指示非会员功能,包括静态成员函数,是指针。
上面的报价似乎表明指向非静态成员功能不是指针。
同样,我阅读在这里:
成员指针是与普通指针不同类型的类别。
我的问题是在技术上是上述引号(按标准形式上)正确吗?我的意思是我们将术语“指针”用于非静态成员函数。但是,如果它们实际上不是指针,那么为什么首先使用“指针”一词呢?我的理解是因为尽管“指向成员函数的指针”在许多方面与普通指针有所不同,但它们在一个方面仍然与普通指针相似,即它们指向某种东西(意思是持有地址)。
我还尝试了:
std::cout<<std::is_pointer_v<void(A::*)()><<std::endl;
它给出0
确认指向非静态成员函数的指针不被视为指针。
I came across this which states:
Member function pointers are not pointers. Pointers to non-member functions, including static member functions, are pointers.
The above quote seems to suggest that pointers to non-static member function are not pointers.
Similarly, i read here:
A member pointer is a different type category from a ordinary pointer.
My question is that are the above quotes technically(formally according to the standard) correct? I mean we use the term, "pointer" to non-static member function. But if they are not actually pointers then why use the term "pointers" in the first place? My understanding is that it is because although "pointer to member functions" differ in many respect with ordinary pointers they still are similar to ordinary pointers in one respect which is that they point to something(meaning hold addresses).
I also tried:
std::cout<<std::is_pointer_v<void(A::*)()><<std::endl;
which gives 0
confirming that a pointer to non-static member function is not considered a pointer.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所讨论的报价似乎通过标准的以下语句验证。
来自 dcl.mptr#3的注释:
和 basic.compound#3 :
The quoted statements in question seems to be validated by the following statements from the standard.
From dcl.mptr#3's note:
And from basic.compound#3: