Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to add a member function Y that takes S as a template parameter in template class B.

template<typename t="">
class B {
public:
   template<typename s="">
   static void X(S & x);
}
</typename></typename>


If I try to define
template<>
template<typename s="">
void B<_variant_t>::X(S & x) {
}
</typename>


or

XML
<pre>
template<typename t="">
template<typename S>
void B<t>::X(S & x) {
}
</pre></t></typename>



I get an error
Posted
Updated 22-Jun-11 9:50am
v5

1 solution

What you are looking for is template function, not template class. More exactly, this is irrelevant if the declaring class template or not. You function can stay along or be a member of the class; and this class can be a template class or not, does not matter.

Review some samples on how to write a template function:
http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Ffunction_templates.htm[^].

It should be enough, but you can find tons of info if you Google for it.

—SA
 
Share this answer
 
v2
Comments
Espen Harlinn 22-Jun-11 12:35pm    
fair enough :)
Sergey Alexandrovich Kryukov 22-Jun-11 12:51pm    
Thank you, Espen.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900