xorp

BaseAndDerived< B, D > Class Template Reference

Class to determine if two types are base and derived. More...

#include <minitraits.hh>

List of all members.

Classes

struct  X

Static Public Attributes

static const bool True = ( sizeof(X::f((D*)0)) == sizeof(X::f((B*)0)) )

Detailed Description

template<typename B, typename D>
class BaseAndDerived< B, D >

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).


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations