I have two template classes as outer and inner. I am type casting to inner class from other inner class object. I am getting compilation error. How to resolve this?
template<typename O>
struct outer
{
template<typename I>
struct inner
{
};
inner<int> *ptr;
outer();
};
template<typename O,typename I>
void callme()
{
reinterpret_cast< outer<O>::inner<I> *>(NULL);
}
You want:
reinterpret_cast<typename outer<O>::template inner<I> *>(nullptr);
// ^^^^^^^^ ^^^^^^^^ ^^^^^^^
The names outer
and inner
are dependent names (they depend on template arguments), and therefore you need to explicitly specify their "kind" (value, type, template).