From -9072612651196595729
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 109fba,1441794ed9819078
X-Google-Attributes: gid109fba,public
X-Google-Thread: f78e5,a9e0bc9c2025eeb2
X-Google-Attributes: gidf78e5,public
From: kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763)
Subject: Re: Template member function
Date: 1996/08/06
Message-ID: <KANZE.96Aug6153234@slsvgqt.lts.sel.alcatel.de>#1/1
X-Deja-AN: 172479676
references: <1996Aug6.061314.5177@iiasa.ac.at>
x-original-date: 06 Aug 1996 13:32:34 GMT
followup-to: comp.std.c++
apparently-to: std-c++@ncar.UCAR.EDU
organization: GABI Software, Sarl.
x-auth: PGPMoose V1.1 PGP comp.std.c++
newsgroups: comp.lang.c++,comp.std.c++
originator: austern@isolde.mti.sgi.com


[Moderator's note: this article is crossposted to comp.std.c++ and 
comp.lang.c++.  Followups have been directed by default to comp.std.c++.
mha]

In article <1996Aug6.061314.5177@iiasa.ac.at> marek@iiasa.ac.at (Marek
MAKOWSKI) writes:

|> Is it possible to have a template member function in a non-template class ?

According to the latest drafts, yes.  This is a recent extension,
though, and not supported by most compilers.

Also, there are limits on the types of things that can be member
templates.  I've not studied the list in detail, but I do remember that
non-virtual functions are OK, virtual functions no.

|> Something like:

|> class A {
|> public:
|> 	A();
|> 	// ....
|> private:
|> 	template <class T> process();
|> 	// ....
|> };

|> Both SunPro and Watcom give errors for such a code.
|> I can't define A<T> because T is decided upon after A is constructed.

I know for a fact that the Sun compilers do not support this.  (I rather
suspect that they are waiting some stability in order to introduce all
of the changes at once, so we only have to change our code once, and not
with each release.)

I'm also pretty sure that the syntax is false.  I'm not even sure what
you are trying to do.  I presume that you want process to be a set of
functions that in some way depends on the type T.  In this case, the T
must appear somewhere in the parameter list of the function, in order
that the compiler can know which version to generate.  (I think that the
syntax here would be exactly the same as that of a non-member template
function.)
-- 
James Kanze         Tel.: (+33) 88 14 49 00        email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
Conseils, �tudes et r�alisations en logiciel orient� objet --
                -- A la recherche d'une activit� dans une region francophone
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu 
]



