Alan Mackenzie <[EMAIL PROTECTED]> writes:

> I'm thinking of things like
>
>     foo (a < b, c > d);
>
> I think this is unambiguously a function call with 2 parameters, the
> expressions "a < b" and "c > d".  It cannot be be one with 1 parameter
> beginning with the template invocation "a < b , c >".  Or can it?

No, it can't be, because a<b, c> is a type.  The result would be
foo(TYPE d), which can not be a function call.  On the other hand, if
there were a type before foo then this would be a function
declaration.  For example, this is valid C++ code:

template <int a1, int a2> class a;

int fn(int d, int e)
{
  const int b = 1;
  const int c = 2;
  typedef int f;
  f foo (int, int);
  f foo (a < b, c > d);
  foo (e < b, c > d);
}

The line "f foo (a < b, c > d);" uses a template, the line "foo (e <
b, c > d);" does not.

I rather doubt that you can purely syntactically, fully reliably,
determine whether <> refers to a template, but I don't know for sure.


> Another related question: although there is no maximum bound on how far
> apart template/generic brackets can be, I believe that in practice, they
> are never that far apart (a few hundred bytes max, perhaps).  Is this, in
> fact, the case?

A few hundred characters is probably a little too small, but in
practice I think one thousand characters is probably usually
sufficient.

Ian

Reply via email to