Trying to respond to another question, I've found that g++ and clang++ disagree about the following simple code
template <typename>
struct foo
{ void bar (); };
template <typename T>
using fooAlias = foo<T>;
template <typename T>
void fooAlias<T>::bar ()
{ }
int main ()
{
}
While clang++ compile, g++ gives the following error
tmp_003-14,gcc,clang.cpp:26:24: error: invalid use of incomplete type ‘struct foo<T>’
void fooAlias<T>::bar ()
^
tmp_003-14,gcc,clang.cpp:19:8: note: declaration of ‘struct foo<T>’
struct foo
^~~
The question, as usual, is: who's right? clang++ or g++?
I also observe that the disagreement is connected with the presence of template parameter.
Indeed both clang++ and g++ compile the following code
struct foo
{ void bar (); };
using fooAlias = foo;
void fooAlias::bar ()
{ }
int main ()
{
}
Aucun commentaire:
Enregistrer un commentaire