In your real code, did you do something to make f public so test can use
it? But that isn't the main problem. Arturs Zoldners gave the solution
to the main problem:
If I understand correctly, while processing the definition of test, the
compiler doesn't look at the definition of C, so it doesn't know f is a
templated function, so it doesn't know how to parse the "<" in "c.f<int>".
When it instantiates test<T> it will, of course, look inside C<T> (for
at least the constructor of C and the declaration of f). But if it
can't process test at definition time, it never gets to instantiation.
@ wrote:
> why the following code cannot be compiled?
>
> template <typename TC>
> class C
> {
> template <typename TF>
> void f() {}
> };
>
> template <typename T>
> void test()
> {
> C<T> c;
> c.f<int>();
> }
>
> gcc-4.3.2 on "c.f<int>();" reports error: expected primary-expression before
> ‘int’
>