Nested type as a template parameter of a base class

Is it possible?

Example:

template<class T> class A {}; class B : public A<B::C> { public: struct C {}; }; 

The problem is that B :: C is an undeclared identifier (which is obvious why), and I don't know how to make it work. Bottom line: Can B is obtained from A with the template parameter set to C?

+6
source share
1 answer

No. B is incomplete at this point because you have not yet defined the class to which it should inherit. Thus, it is impossible to refer to B::C (nested classes / structures depend on the full definition of their encompassing class / structure, since the nested type can and often depends on the definition of the adjective).

+5
source

Source: https://habr.com/ru/post/976419/


All Articles