I have the following scenario:
class my_base { ... }
class my_derived : public my_base { ... };
template
struct my_traits;
Well, you don't need to write your own isbaseof. You can use boost's or c++0x's.
#include
struct base {};
struct derived : base {};
template < typename T, typename Enable = void >
struct traits;
template < typename T >
struct traits< T, typename boost::enable_if>::type >
{
enum { value = 5 };
};
#include
int main()
{
std::cout << traits::value << std::endl;
std::cin.get();
}
There are scaling issues but I don't believe they're any better or worse than the alternative in the other question.