Address of the "empty" variational type specialization
I have a variable member function template defined as:
template<typename ... Params> VAlgorithm* CreateAlgorithm(const char *objectName, const char *className, Params ... par) and I would like to take the address of the specialized version, where Params does not contain a type (which I call the "empty" specialization), i.e. of:
VAlgorithm* CreateAlgorithm(const char *objectName, const char *className) I tried several ways. Naive way:
&AlgorithmFactory::CreateAlgorithm<> (since, for example, & AlgorithmFactory :: CreateAlgorithm <int> works) and in a more explicit way:
(VAlgorithm* (*)(const char*, const char*))AlgorithmFactory::CreateAlgorithm<> Explicitly, GCC 4.7.1 says:
error: insufficient contextual information to determine type It seems that the "empty" specialization is not understood by the compiler, which interprets the missing types of templates as a lack of information, and not as "no types" information. What is the right way to do this? (Sorry for the potentially naive question, but I'm pretty new to variable templates, and I haven't found any documentation on this topic). Thanks
Your code should work; see for example http://liveworkspace.org/code/6253cf45f416be60879b93aa74c24de8
The following syntaxes apply to me:
struct S { template<typename... Args> static int *foo(const char *, const char *, Args...); }; int main() { (int *(*)(const char *, const char *))S::foo<>; (int *(*)(const char *, const char *))S::foo; (int *(&)(const char *, const char *))S::foo<>; (int *(&)(const char *, const char *))S::foo; int *(&f)(const char *, const char *) = S::foo<>; int *(&g)(const char *, const char *) = S::foo; int *(*h)(const char *, const char *) = S::foo<>; int *(*i)(const char *, const char *) = S::foo; }