Let's say I have the following code:
class Example
{
#ifndef PRIVATE_DESTRUCTOR
public:
#endif
~Example() { }
public:
friend class Friend;
};
class Friend
{
public:
void Member();
};
void Friend::Member()
{
std::printf("Example's destructor is %s.\n",
IsDestructorPrivate<Example>::value ? "private" : "public");
}
Is it possible to implement the IsDestructorPrivate
template above to determine whether a class's destructor is private
or protected
?
In the cases I'm working with, the only times I need to use this IsDestructorPrivate
are within places that have access to such a private destructor, if it exists. It doesn't necessarily exist. It is permissible for IsDestructorPrivate to be a macro rather than a template (or be a macro that resolves to a template). C++11 is fine.