How do I write this template specification when I'm outside the 'class' definition

This is something that I never ran into before. Say I have a class that looks like this:

template <class T1>
class A
{
   void normal_function();

   template <class T2>
   void templated_function(T2);
}

Because of coding standards, I'm not allowed to put the body of templated_function inside of the class definitions, i have to have it below (but still in the .h file).

So I have something like this

template <class T1>
void A<T1>::normal_function()
{
  ...
}

But how do I write the template specification for templated_function when it's outside of the class definition? I tried this, but it didn't seem right to me, and I wasn't surprised when it didn't compile.

template <class T1, class T2>
void A<T1>::templated_function<T2>(T2 t)
{
  ...
}

Answers


This works with g++:

template<class T1> template<class T2>
void A<T1>::templated_function(T2 t)
{
   ...
}

Need Your Help

Cant' make nav display next to h1 element

css html5 css3 floating

solved - it was a group effort. thank you all so much, my first posting experience on here was wonderful and you all have given me things to learn :)

Create Up and Down arrow icons or buttons using pure CSS

html css css3 arrow arrow-keys

I am trying to create below shown "up and down" control buttons using pure CSS and no Background image.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.