Bug#216234: g++-3.3: template function triggers syntax error
Hi,
Am 19.10.2003 um 23:52 schrieb Falk Hueffner:
> The Compaq compiler also rejects it. I'm pretty sure it's the expected
> behaviour, but somebody else should check.
In my copy of Stroustrups book (german version, 4th edition) there's a
short passage in Appendix A.9 talking about parsing of
templates. There's a short example
void h()
{
f<1>(0);
}
which can be interpreted as (f < 1) > 0 or as (f<1>)(0). The following
passage talks about the resolution of this conflict: if f is the name
of a template, then f< has to be interpreted as the start of a
template specification. There are some more funny cases in this
section.
Thus, I believe my test program to be correct :) The expression
"e.test<1>()" is ok, the function foo1() shows that the compiler
correctly identifies "e.test" as a template-name; otherwise there
would be a syntax error in foo1. The calls inside the both
foo-functions should be equivalent because none of them has anything
to do with the template-parameter "dim" of foo2()... if the
surrounding function would change the interpretation of method-calls
it would at least be confusing (well, that wouldn't totally surprise
me in the C/C++ world, but I hope for the best :)
But maybe I've missed another special passage in the Stroustrup...
Cheers
Thimo
Reply to: