B
Belebele
The code below does not compile under g++.
There is an outer class template that contains and inner class
template. The outer class template is fully specialized for int. Then
a separate Foo class template inherits from the inner.
The compiler indicates that the inner class is incomplete when used as
the base class of the inner class template. Why?
-------------------------------------------------------------------
template <typename X> struct Outer {
template <typename Y> struct Inner {};
};
template <> struct Outer<int> { // If this full specialization is
removed, the compilation succeeds.
template <typename Y> struct Inner {};
};
template <typename T>
struct Foo: Outer<T>::Inner<T> {};
int main()
{
Foo<int> o;
return 0;
}
-------------------------------------------------------------------
Interestingly, if I remove the full specialization, the compilation
succeeds, to add to my confusion.
Thanks
There is an outer class template that contains and inner class
template. The outer class template is fully specialized for int. Then
a separate Foo class template inherits from the inner.
The compiler indicates that the inner class is incomplete when used as
the base class of the inner class template. Why?
-------------------------------------------------------------------
template <typename X> struct Outer {
template <typename Y> struct Inner {};
};
template <> struct Outer<int> { // If this full specialization is
removed, the compilation succeeds.
template <typename Y> struct Inner {};
};
template <typename T>
struct Foo: Outer<T>::Inner<T> {};
int main()
{
Foo<int> o;
return 0;
}
-------------------------------------------------------------------
Interestingly, if I remove the full specialization, the compilation
succeeds, to add to my confusion.
Thanks