I have the following functions in class “C”
class C
{
template<typename T> void Func1(int x);
template<typename T> void Func2(int x);
};
template<typename T> void C::Func1(int x)
{
T a(x);
}
template<typename T> void C::Func2(int x)
{
T a(x);
}
The functions uses templates only in the implementation. The signature does not contain template parameters.
Is it possible to define pointers to such template functions?
I tried the following definition but it results compilation error.
typedef template<typename T> void (СSomeClass::*TFuncPtr)(int);
Once instantiated, a member function template is just a normal member function, so you can use a normal member function pointer (best
typedef‘d like below):The underlined part is the important part. You can’t make a pointer to a function template, but you can make a pointer to an instantiated function template.