I am trying to use static instance of the struct in the same struct but g++ compiler tells me that:
C:\Temp\cs2cpp_tries\test\test.cpp: In instantiation of 'struct Static<Test<int> >':
C:\Temp\cs2cpp_tries\test\test.cpp:16:19: required from 'struct Test<int>'
C:\Temp\cs2cpp_tries\test\test.cpp:20:12: required from here
C:\Temp\cs2cpp_tries\test\test.cpp:6:4: error: 'Static<T>::t' has incomplete type
T t;
^
C:\Temp\cs2cpp_tries\test\test.cpp:10:8: note: declaration of 'struct Test<int>'
struct Test
^~~~
Here is the code example. You can see that types are defined but g++ still does not like it.
#include <iostream>
template < typename T >
struct Static
{
T t;
};
template < typename T >
struct Test
{
static Static<Test<T>> t;
};
template < typename T >
Static< Test<T> > Test<T>::t;
int main (int argc, char **argv)
{
Test<int> t;
return 0;
}
Aucun commentaire:
Enregistrer un commentaire