L
ld
Hereafter is a small code which reports my problem. gcc says
problem.cpp:43: error: invalid use of incomplete type ‘struct E<B<T>,
D>’
problem.cpp:3: error: declaration of ‘struct E<B<T>, D>’
Any hint? Thanks.
ld.
// type declaration
template <typename T, typename I>
struct E; // line 3
// abstract class
struct D {
virtual void doit() const = 0;
};
// partial specialization
template <typename T>
struct E<T, D> {
virtual void doit() const;
explicit E(T = T());
T& e;
};
// simple class
struct A {
void doit() const;
int a;
};
// template class
template <typename T>
struct B {
void doit() const;
T b;
};
// specialization with class, ok
template <>
void
E<A, D>::doit() const
{
e.doit();
}
// specialization with template class, error
template <> template <typename T>
void
E<B<T>, D>::doit() const // line 43
{
e.doit();
}
int main() {
E<A, D> a;
E<B<int>, D> b;
}
problem.cpp:43: error: invalid use of incomplete type ‘struct E<B<T>,
D>’
problem.cpp:3: error: declaration of ‘struct E<B<T>, D>’
Any hint? Thanks.
ld.
// type declaration
template <typename T, typename I>
struct E; // line 3
// abstract class
struct D {
virtual void doit() const = 0;
};
// partial specialization
template <typename T>
struct E<T, D> {
virtual void doit() const;
explicit E(T = T());
T& e;
};
// simple class
struct A {
void doit() const;
int a;
};
// template class
template <typename T>
struct B {
void doit() const;
T b;
};
// specialization with class, ok
template <>
void
E<A, D>::doit() const
{
e.doit();
}
// specialization with template class, error
template <> template <typename T>
void
E<B<T>, D>::doit() const // line 43
{
e.doit();
}
int main() {
E<A, D> a;
E<B<int>, D> b;
}