From 8983827349307636486
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,9da47553ab59d368
X-Google-Attributes: gidf78e5,public
From: stephen.clamage@sun.com (Steve Clamage)
Subject: Re: template member function syntax
Date: 1999/02/02
Message-ID: <797cj1$rpk$1@engnews2.Eng.Sun.COM>#1/1
X-Deja-AN: 439828519
X-NNTP-Posting-Host: taumet.eng.sun.com
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <m107X1E-000Q9bC@psalm> <slrn7bcvr8.39c.sbnaran@localhost.localdomain>
X-UID: 0000000001
X-Status: $$$T
Organization: Sun Microsystems Inc., Mountain View, CA
Newsgroups: comp.std.c++
Originator: clamage@taumet


sbnaran@localhost.localdomain (Siemel Naran) writes:

>On 02 Feb 99 04:09:35 GMT, hursh <hursh@sparc.isl.net> wrote:

>>     myType mytmp = MyObj.template myFunc<myType>();
>>                          ^^^^^^^^?
>>  I understand the the syntax error of myType being after the
>>less-than operator, but putting the template keyword in the invocation
>>just seems plain ugly.

>The 'template' is required to make life easier for the compiler
>writer, I think.

No, it is required to allow parsing of general expressions like
	A . B < C > ( D )

If A has a static member B, A.B is its address. The address
could be compared with C, and the result compared with D
(the parens are redundant).

But if B is a template function member of A, we have a
function call as in the original code.

You can't tell in general whether the '<' is a template
bracket or a less-than. To make the determination, you need
to know whether myFunc is the name of a template. To know
that you need to know what scopes to look in.  To know that,
you need to know whether the < is a template bracket.

The 'template' keyword breaks the circular dependency.

The name lookup rules are complex and context-dependent. The
template keyword is necessary in this case to be able to
parse the code.

--
Steve Clamage, stephen.clamage@sun.com


[ 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              ]




