Class to determine if two types are base and derived. More...
|static const bool||True = ( sizeof(X::f((D*)0)) == sizeof(X::f((B*)0)) )|
Class to determine if two types are base and derived.
This class tests whether a pointer for type B is useable as pointer to type D. Typically, this implies that B is a base for D. It may also imply that B is void, or B and D are the same type.
How this works? Overloaded definition of function X::f(). The first of which takes a const B* pointer as an argument and returns are char. The second of which takes a ... and returns a double. sizeof is used to determine the size of the return type that would used if the code were executed. Thus, if B and D are compatible pointer types then sizeof(X::f()) for both of them is sizeof(char).