From 8765630846685196353
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,2bb87329d23dffd0
X-Google-Attributes: gidf78e5,public
From: Martin von Loewis <loewis@informatik.hu-berlin.de>
Subject: Re: why ::template in qualified id?
Date: 2000/05/13
Message-ID: <p6q7lczlfem.fsf@informatik.hu-berlin.de>#1/1
X-Deja-AN: 622683443
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
References: <3914163C.199321C8@earthlink.net>
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Trace: mail2news.demon.co.uk 958161315 mail2news:27311 mail2news mail2news.demon.co.uk
Organization: Humboldt University Berlin, Department of Computer Science
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
NNTP-Posting-Date: 12 May 2000 19:47:24 GMT
Newsgroups: comp.std.c++

Larry Evans <cppljevans@earthlink.net> writes:

> The ISO/IEC 14882 standard in 5.1 para 7 shows qualified-id may have
> ::template substring; however, para 7 doesn't say when this is
> useful.  Could someone please explain this to me?

It is needed on a lexical level to determine the meaning of
"<". Normally, given

  X::foo<a,b>::c

you look up X, then X::foo. If it is a template, the '<' starts the
template parameters, so this is an access to member c of X::foo<a,b>.
Otherwise, this is equivalent to (X::foo < a), (b > ::c).

Now, if X is a template parameter, foo is a dependent name, and you
can't tell whether X::foo is a template or not until instantiation
time. Unfortunately, that means you could not parse that expression.
So the rule is: If X is a template parameter, the '<' parses as
an operator. If you mean it as a template argument list, you write

  X::template foo<a,b>::c

This is similar to the typename escape.

Regards,
Martin

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]




