I have a simple RAII class to ensure some handle is properly disposed of. Now I would like to assert that no one is going to add by accident any virtual methods to it. The way I see it, I need to assert that the class does not have the vtbl pointer.
How can I do it? Is it possible to assert at the compile time?
EDIT
I will settle for desktop compilers. As far as I know there are no desktop c++ compilers that are not using vtbl for implementing polymorphism.
If you have a C++11 library, you can use std::is_polymorphic<T>
:
If T is a polymorphic class (that is, a class that declares or inherits at least one virtual function), provides the member constant value equal true. For any other type, value is false.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With