Article View: comp.std.c++
Article #3325Re: Observations on templates
From: Eugene Radchenko
Date: Thu, 08 Feb 1996 17:00
Date: Thu, 08 Feb 1996 17:00
60 lines
3667 bytes
3667 bytes
jason@cygnus.com (Jason Merrill) writes
>>>>>> Eugene Radchenko <eugene@qsar.chem.msu.su> writes:
>
>> 1) Clause [temp.res] verse 1 requires that all types dependent on the
>> template parameter must be qualified by 'typename' keyword - supposedly to
>> allow checking the template syntax. But it does not help anything as _each_
>> instance will have to be checked anyway:
>
>Requiring 'typename' allows syntactic analysis and some name binding
>to be done at the point of definition of the template. Older
>implementations do all name binding at the point of instantiation,
>which was thought to be confusing.
>
>Each instance will indeed have to be checked, but only for semantic
>correctness, not syntactic.
And does such a simplification (which does not simplify anything as
complete recheck is still needed) warrant the introduction of a new keyword
(why could not at least the 'class' keyword be used like in template
prefix?). Interestingly, WRT member functions (and especially operator->)
the decision was roughly inverse (i.e. to perform checking only on the
per-instance basis and only if given instance is required).
>> 2) Clause [temp.dep] verse 5 states that base class scope names hide the
>> template parameter:
>
>This is for orthogonality. Think of the template header as creating a
>special scope around the class; name lookups in class scope look in the
>current class, then in base classes, then in the surrounding scope.
That much I do understand. I only think that such an order is
counter-intuitive. The template parameters is something related to this
particular class and hence must be in the scope that is inner WRT its base
classes. Also, we have qualified names to access base class members while
current specs make template parameters completely inaccessible.
>> 3) Clause [temp.arg.explicit] verses 2-3 requires that for explicit arg in
>> member template to be present it must be qualified by 'template' keyword,
>> e.g.
>> X *p; p->template alloc<200>();
>> But to use operator -> we need X class definition anyway - so we know that
>> alloc() is a template.
>
>It is needed in some situations where we do not have the X class definition
>-- in template definitions, like with typename.
And what are we supposed to do with function alloc() if we do not have the
class definition and hence do not know anything about this function?
Cheers Genie
--
--------------------------------------------------------------------
Eugene V. Radchenko Research associate, Computer Chemistry
E-mail: eugene@qsar.chem.msu.su Fax: +7-(095)939-0290
Ordinary mail: Chair of Organic Chemistry, Department of Chemistry,
Moscow State University, 119899 Moscow, Russia
***************** Disappearances are deceptive *******************
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is
summarized in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
]
Technical Details
Message-ID:
<ADqNY6n4sN@qsar.chem.msu.su>Path:
arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamageReferences:
<u9vilu8zvz.fsf@yorick.cygnus.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage From: "Eugene Radchenko" <eugene@qsar.chem.msu.su> Newsgroups: comp.std.c++ Subject: Re: Observations on templates Date: 8 Feb 1996 17:00:57 GMT Organization: Lab. of Org.Synth., MSU Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <ADqNY6n4sN@qsar.chem.msu.su> References: <u9vilu8zvz.fsf@yorick.cygnus.com> NNTP-Posting-Host: taumet.eng.sun.com Content-Type: text X-Mailer: dMail [Demos Mail for DOS v1.23] Content-Length: 2838 X-Lines: 55 Originator: clamage@taumet