How to get a pointer to a member function of a destructor?

Let's pretend that

struct X { ~X() {} }; 

What is the type and way to get the pointer of a member function X::~X() in C ++ 03?

I don't want to call it, just use in SFINAE to determine if a destructor exists for a given type.

+4
source share
1 answer

You cannot get a pointer to a destructor function or constructor. However, a destructor always exists for a type, and you cannot detect if it is private , since access specifiers are not considered by SFINAE.

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

[Note: the designation for explicitly calling the destructor can be used for any scalar type name (5.2.4). This allows you to write code without knowing if a destructor exists for this type. For instance,

typedef int I;

I * p;

p> I :: ~ I ();

-end note]

+5
source

Source: https://habr.com/ru/post/1415673/


All Articles