Topic: Templates : parameterising


Author: madhavi@india.ti.com (Madhavi)
Date: 1995/04/10
Raw View
In article <3m3ntf$ao@proxim.franken.de>, guus@proxim.franken.de (Guus C. Bloemsma) says:
>
>In article <3ljjuv$t4q@tilde.csc.ti.com> madhavi@india.ti.com (Madhavi
>Bhamidipati) writes:
>>       In other words, the user would want to do the following:
>>       template <class T1, int >
>>       void X :: process (void ) { //define his own body }
>>
>If I'm not mistaken, you actually can. Just the syntax is slightly
>different:
>
>        template <class T1 >
>        void X <T1, int> :: process (void ) { //define his own body }
>
>Now it's up to your development environment to pick the right template
>definition when instantiating the template.
>
>Good luck, Guus Bloemsma.

 No that is not true. You cannot perform template specialization
for a class member function, on selected template parameters.

 -Madhavi Bhamidipati
 Texas Instruments (India) Limited.





























Author: guus@proxim.franken.de (Guus C. Bloemsma)
Date: 1995/04/07
Raw View
In article <3ljjuv$t4q@tilde.csc.ti.com> madhavi@india.ti.com (Madhavi
Bhamidipati) writes:
>  In other words, the user would want to do the following:
>  template <class T1, int >
>  void X :: process (void ) { //define his own body }
>
If I'm not mistaken, you actually can. Just the syntax is slightly
different:

 template <class T1 >
 void X <T1, int> :: process (void ) { //define his own body }

Now it's up to your development environment to pick the right template
definition when instantiating the template.

Good luck, Guus Bloemsma.





Author: madhavi@india.ti.com (Madhavi Bhamidipati)
Date: 1995/04/01
Raw View
 Suppose somebody designed a template class ex.,
template <class T1, class T2>
class X
{


 T1 t1 ;
 T2 t2 ;

 public :
 void process(void) ;
} ;
 Someone else decides to use the above template class. For his
application, when T2 assumes the type int, the body of process() is
to be changed from what is defined in the template class definition.
Similarly when T2 assumes the type float, the body is again different.
 In other words, the user would want to do the following:
 template <class T1, int >
 void X :: process (void ) { //define his own body }

 Note that I want to substitute 'int' for parameter T2 keeping T1
as is, that too only for one method.

 Through inheritance we can probably get the functionality done.

But does anybody feel that the language should be able to support this
through some (perhaps special) syntax ?

 -Madhavi Bhamidipati
 Texas Instruments (India) Limited.