From -6681941990977885614
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109fba,1441794ed9819078
X-Google-Attributes: gid109fba,public
X-Google-Thread: f78e5,a9e0bc9c2025eeb2,start
X-Google-Attributes: gidf78e5,public
From: Carsten Arnholm <ca@sesam.dnv.no>
Subject: Re: Template member function
Date: 1996/08/06
Message-ID: <4u7253$pg4@o.online.no>#1/1
X-Deja-AN: 172479675
references: <1996Aug6.061314.5177@iiasa.ac.at>
x-original-date: 6 Aug 1996 09:09:55 GMT
followup-to: comp.std.c++
organization: DNV
x-auth: PGPMoose V1.1 PGP comp.std.c++
newsgroups: comp.lang.c++,comp.std.c++
originator: austern@isolde.mti.sgi.com
x-mailer: Mozilla 1.1 (Windows; I; 32bit)


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

marek@iiasa.ac.at (Marek  MAKOWSKI) wrote:
>Is it possible to have a template member function in a non-template class ?
>Something like:
>
>class A {
>public:
>	A();
>	// ....
>private:
>	template <class T> process();
>	// ....
>};


Sorry, this is not allowed (yet). 
Refer to the book "The Design and Evolution of C++", by Bjarne Stroustrup.
In section 15.9.1 "Inheritance Relationships", (page 361) he talks about 
smart pointers and how he would like them to have similar inheritance 
behaviour as ordinary pointers. On the bottom of te page he says:

"Member templates - which are not currently part of C++ - provide a solution:

template<class T1> class Ptr { // pointer to T1
   // ...
   template<class T2> operator Ptr<T2>();
};"

This is basically the same as what you are asking for. I guess it will
become legal C++ at some stage, but currently we will have to do 
without it.

BTW, your example will perhaps NEVER be legal, because your process()
member function template has no arguments. How do you think the compiler
is supposed to figure out which template function you want ?

Carsten Arnholm
ca@dnv.no
---
[ 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 
]



