How do I get the member function pointer of a destructor?

后端 未结 1 824
时光说笑
时光说笑 2021-01-06 01:28

Assume I have

struct X {
  ~X() {}
};

What\'s the type of and how do I get the member function pointer of X::~X() in C++03?

相关标签:
1条回答
  • 2021-01-06 01:57

    You can't get the function pointer of a destructor nor a constructor. Nevertheless a destructor always exist for a type, and you can't detect if its private with as access specifiers are not considered by SFINAE.

    On the subject of invoking what would be the destructor of a scalar type, the standard says [class.dtor]/16:

    [Note:the notation for explicit call of a destructor can be used for any scalar type name (5.2.4). Allowing this makes it possible to write code without having to know if a destructor exists for a given type. For example,

    typedef int I;

    I* p;

    p->I::~I();

    —end note]

    0 讨论(0)
提交回复
热议问题