0
template <typename Foo>
class A{

};

class B : A<B::Bar>{
    struct Bar{

    };
};

I wonder how could I do something like this, or it's the only way to move struct Bar outside the class B.

Emc Java
  • 21
  • 3

1 Answers1

3

You simply can't do it!

You can not use an unknown type as template parameter and you can't forward a nested class type. Both together makes it impossible to do what you like to do.

About forwarding a nested class declaration see here: forward declaration of nested class

There was already a proposal to add such thing to C++, but I think it is not part of the standard even not in C++20. Forward declarations of nested classes

Klaus
  • 24,205
  • 7
  • 58
  • 113