From: Ian Lance Taylor <iant@google.com>
To: Alan Mackenzie <acm@muc.de>
Cc: gcc@gcc.gnu.org
Subject: Re: Help requested on C++ template syntax (for Emacs development).
Date: Tue, 10 Jun 2008 18:56:00 -0000 [thread overview]
Message-ID: <m3zlptglv9.fsf@google.com> (raw)
In-Reply-To: <20080610183707.GB4844@muc.de> (Alan Mackenzie's message of "Tue\, 10 Jun 2008 18\:37\:07 +0000")
Alan Mackenzie <acm@muc.de> 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
next prev parent reply other threads:[~2008-06-10 18:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-10 18:15 Alan Mackenzie
2008-06-10 18:56 ` Ian Lance Taylor [this message]
2008-06-10 19:05 ` Ian Lance Taylor
2008-06-15 14:12 ` Alan Mackenzie
2008-06-11 18:15 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3zlptglv9.fsf@google.com \
--to=iant@google.com \
--cc=acm@muc.de \
--cc=gcc@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).