2

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);
}
VINOTH ENERGETIC
  • 1,591
  • 4
  • 18
  • 36

1 Answers1

4

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).

Kerrek SB
  • 428,875
  • 83
  • 813
  • 1,025