Get base class for a type in class hierarchy

Classes in C++ can have more than one base class, so there’s no sense in having a “get me the base” trait.

However, the TR2 additions include new compiler-supported traits std::tr2::bases and std::tr2::direct_bases, which returns an opaque type list of base classes.

I’m not sure whether this will make it into C++14, or whether it’ll be released independently, but GCC already seems to support this.

Leave a Comment