Is it possible?
example:
template<class T>
class A {};
class B : public A<B::C>
{
public:
struct C {};
};
Problem is that B::C is undeclared identifier (which is obvious why) and I don't know how to make it work. In summary: Can B derive from A with template parameter set to C?
There is no requirement that your base class be a template. It is quite possible to have a template class inherit from a 'normal' class.
Nested class templates are declared as class templates inside the scope of the outer class. They can be defined inside or outside of the enclosing class.
A template argument for a template template parameter is the name of a class template. When the compiler tries to find a template to match the template template argument, it only considers primary class templates. (A primary template is the template that is being specialized.)
A non-type template argument provided within a template argument list is an expression whose value can be determined at compile time. Such arguments must be constant expressions, addresses of functions or objects with external linkage, or addresses of static class members.
No. B
is incomplete at this point, because you have not yet defined the class it should inherit from. Thus it is not possible to reference B::C
here (nested classes/structs depend on the complete definition of their enclosing class/struct, since the nested type could and often does depend on the definition of the enclosing one).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With