Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is std::has_virtual_destructor implemented?

How can std::has_virtual_destructor and similar checks be implemented? I've tried looking at type_traits header in Visual Studio, but there's too many macros and templates to even get an idea. Can this check be expressed in any reasonably simple form? I'd love to at least know the principle of its working, because right now I have no idea.

like image 953
Violet Giraffe Avatar asked Sep 28 '13 18:09

Violet Giraffe


1 Answers

Many of the type traits require compiler magic: the traits essentially give a library interface to some hooks provided by the different compilers. How the compilers implement these hooks is entirely up to them and there is no consistant interface.

At the current meeting there was discussion on adding reflection to a future revision which may eventually lead to a library implementation if traits like std::has_virtual_destructor<T>. However, it will be a while before something like reflection emerges.

like image 105
Dietmar Kühl Avatar answered Oct 12 '22 07:10

Dietmar Kühl