If I have a class Base, with at least one virtual function, and a class Derived which inherits singly from this then (uintptr_t)derived - (uintptr_t)static_cast
This will be part of the next standard This was part of the aborted TR2 via the std::bases
and std::direct_bases
traits. If you happen to be working with a compiler that includes the draft-TR2, you might have support for this. For example in GCC 4.7.2:
#include
#include
#include
struct T1 { };
struct T2 { };
struct Foo : T1, T2 { };
int main()
{
std::cout << demangle::type>() << std::endl;
}
This prints:
std::tr2::__reflection_typelist
(The demangler is my own; you may have seen it elsewhere.)
I trust you can build a suitable "is polymorphic and has precisely zero or one bases" trait yourself.