I have the following snippet.
template< typename T > struct f { template< typename V > struct a : f {}; }; int main () { f<int>::a<int>::a<double> x; }
It compiles without warning about GCC 4.4.5, as well as MSVC 2010, but not in GCC 4.5.2 - on which I get the following errors:
test.cc: In function 'int main()': test.cc:11:21: error: expected primary-expression before 'double' test.cc:11:21: error: expected ';' before 'double'
So, although I do not see anything non-standard in this question, the question is mandatory - is this legal in C ++? Also, if so, how do I submit a bug report to GCC? (
to change . A small background for the curious:
This is supposed to be a metaprogramming pattern. f basically has a template metaclass class structure with apply replaced by a (of course, the nested type of apply omitted, so we can focus on the structure itself).
Inheritance in this case is the standard device for binding metafile return values. What this piece is trying to achieve is a class of metaphors that recursively gives itself when evaluating.
edit2 : let me put the same fragment in a different way:
template< typename T > struct f { template< typename V > struct a; }; template< typename T > template< typename V > struct f<T>::a : f<T> {}; int main () { f<int>::a<int>::a<double> x; }
This leads to the same error. I think this refutes the argument of an incomplete type.
xcvii source share