1

How to detect if a derived class has its destructor declared private?

I'm trying to use a SFINAE trick to detect if the destructor is accessible but I keep being failing.

I took a look at boost type traits and I did not find any has_private_destructor().

Is it only possible?

Gb01
  • 1,173
  • 3
  • 9
  • 10
  • Out of curiosity, why you need this? – Kiril Kirov Nov 25 '13 at 14:08
  • I want to prevent users to call delete() on the object they have created, since my framework will call delete() on their object, and only my framework know when the object can be deleted. So users must inherit from one of my class, I'm able to call delete on this base class since I'm friend with it. But I want them to implement their derived destructor as private to prevent them at compile time to call delete on this derived object. – Gb01 Nov 25 '13 at 14:22
  • 2
    http://stackoverflow.com/a/10859012/168175 seems to suggest that this isn't possible – Flexo Nov 25 '13 at 14:32
  • 1
    Is the "cpp98" in your title meant to refer to C++98? Referring to the language as "cpp" is confusing, since (a) that's not its name, and (b) "cpp" often refers to the C preprocessor. – Keith Thompson Nov 25 '13 at 15:51

0 Answers0