I\'ve got a template class:
template
class TemplateClass
{
//irrelevant what this class does
}
And two classes, one base
Sadly, C++ does not support template covariance, so you cannot do that automatically. As a workaround, you could do something like this:
template
void DoSomething(const TemplateClass& tc) {
// in C++03, use BOOST_STATIC_ASSERT and boost::is_convertible
static_assert(
std::is_convertible::value,
"Template argument must be convertible to Base*"
);
// ...
}
Demo on ideone.