Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top