[英]Passing function template specializations to a variadic template function
I have no problem passing the address of a function template specialization to a regular template function: 我将函数模板特化的地址传递给常规模板函数没有问题:
template <typename T>
void f(T) {}
template <typename A, typename B>
void foo(A, B) {}
int main()
{
foo(&f<int>, &f<float>);
}
However, when I try to pass the same specializations to a variadic template: 但是,当我尝试将相同的特化传递给可变参数模板时:
template <typename T>
void f(T) {}
template <typename... A>
void bar(A...) {}
int main()
{
bar(&f<int>, &f<float>);
}
I get the following compiler errors with GCC (I tried 4.6.1 and 4.7.0): 我用GCC得到了以下编译器错误(我试过4.6.1和4.7.0):
test.cpp: In function 'int main()':
test.cpp:9:27: error: no matching function for call to 'bar(<unresolved overloaded function type>, <unresolved overloaded function type>)'
test.cpp:9:27: note: candidate is:
test.cpp:5:6: note: template<class ... A> void bar(A ...)
test.cpp:5:6: note: template argument deduction/substitution failed:
Why am I getting these errors? 为什么我会收到这些错误?
看起来它可能是GCC中的一个可能在GCC 4.6.2中修复的错误 (我说可能是因为它不完全相同,但确实涉及获取可变参数模板函数的地址)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.