I have a feeling that I can come up with a much better title for this thread once I know the answer to this question :).
Say I have a function template template <typename T> void MyFunction(). Now I want to specialize MyFunction for a templated type. That is, say I have template <typename C> class MyClass{}; Now I want to specialize MyFunction for any MyClass<C> that was passed as the template parameter to MyFunction. Is this possible?
The structure would be something like this:
#include <iostream>
#include <vector>
#include "Point.h"
template <typename C>
class MyClass
{
};
template <typename T>
void Output(const T& object)
{
std::cout << object << std::endl;
}
// I want this to handle MyClass<int>, MyClass<float>, MyClass<anything>
template <>
void Output<MyClass<C> >(const MyClass<C>& object)
{
std::cout << "unsigned int " << object << std::endl;
}
int main(int argc, char* argv[])
{
MyClass<double> myClass;
Output(myClass);
Output(2u);
return 0;
}
Any ideas?
Thanks,
David