The code below compiles fine under Comeau and VC++7.1. gcc 3.3.2 gives the following diagnostic: t2x.cpp:14: error: parse error before `<' token t2x.cpp:14: error: syntax error before `<' token t2x.cpp:19: error: parse error before `}' token t2x.cpp: In function `int main()': t2x.cpp:33: error: conversion from `X' to non-scalar type `D<char, char>' requested make: *** [t2x] Error 1 The "struct C" commented allows this to compile and function as expected which indicates that there most likely is a parsing error (expecting a typename but have a template instead). Using the "typename" keyword does not correct the problem. struct X { // struct C; //uncomment to make this work. template<typename T, typename A, template<typename,typename> class C> C<T, A> Func() { return C<T, A>(); } template<typename T, typename A, template<typename,typename> class C > operator C<T, A> () { return C<T, A>(); } }; template<typename dpt, typename dpa> class D { }; int main() { X x; x.Func<char, char, D>(); D<char,char> d = x; } Credit for finding this problem goes to: Leor Zolman http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=58nt00110jirtteaml6p5o45j6l19le1cl%404ax.com&rnum=9
Fixed for 3.4 by the new parser.