Code:

#include <iostream>
#include <complex>
template <class T>
class A
{
public:
template <class R>
void a(R);
};
template <class T>
template <class R>
void A<T>::a(R param)
{
std::cout << param << " Default" << std::endl;
}
template <>
template <class R>
void A<int>::a(R param)
{
std::cout << param << " Specialized" << std::endl;
}
int main(int argc, char *argv[])
{
A<double> a;
A<int> b;
a.a("a: This call is the");
b.a("b: This call is the");
return 0;
}

The output of this code is...

Code:

a: This call is the Default
b: This call is the Specialized

Okay, so this code works, and the function a(R param) is specialized for the A<int> so that it prints the item and then " Specialized". What I want is the a(R param) function specialized for another templated type. For example if I wanted...

Code:

...
void A<std::complex<type> >::a(R param)
{
...
}

I can't seem to get it to work. I've tried

Code:

template <class T>
template <class R>
void A<std::complex<T> >::a(R param)
{
...
}

as well as

Code:

template <>
template <class R, class T>
void A<std::complex<T> >::a(R param)
{
...
}

I can't seem to get this to work. If possible I need this to work for single functions, rather than specializing the entire class. The program I'm working on needs to use complex values, but it has about one hundered functions and only about 8 need to be specialized. Any help is greatly appreciated!