I have the following problem:
class Base
{
};
class Derived : public Base
{
};
class Different
{
};
class X
{
public:
template
stat
I found a VERY easy solution!
class Base
{
};
class Derived : public Base
{
};
class Different
{
};
class X
{
private:
template
static const char *intFunc(const void *, T *data)
{
// Do something generic...
return "Generic";
}
template
static const char *intFunc(const Base *, T *data)
{
// Do something specific...
return "Specific";
}
public:
template
static const char *func(T *data)
{
return intFunc(data, data);
}
};
This works great and is very slim! The trick is to let the compiler select the correct method by the (otherwise useless) first parameter.