I've got a template class with a template method within it, giving two template parameters T and U. The operation is quite expensive and is showing up in profiling to be a major use of CPU time. I could optimise it somewhat, but only for the case where T == U (which is fairly common), however I'm not sure on the syntax for doing this...
The class and method in question look like this:
template<typename T>class Foo
{
public:
...
template<typename U>U bar()const;
};
Foo::bar is generally called from some other template code, so even if I created a separate method (e.g. "T fastBar()const") I don't know how id go about making the other template code call that version where possible...
I tried to create an explicit specialisation for T == U, but VC9 gave me errors
template<typename T>template<>T Foo<T>::bar<T>()const
error C2768: 'Foo::bar' : illegal use of explicit template arguments