[英]Passing function template specializations to a variadic template function
我將函數模板特化的地址傳遞給常規模板函數沒有問題:
template <typename T>
void f(T) {}
template <typename A, typename B>
void foo(A, B) {}
int main()
{
foo(&f<int>, &f<float>);
}
但是,當我嘗試將相同的特化傳遞給可變參數模板時:
template <typename T>
void f(T) {}
template <typename... A>
void bar(A...) {}
int main()
{
bar(&f<int>, &f<float>);
}
我用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:
為什么我會收到這些錯誤?
看起來它可能是GCC中的一個可能在GCC 4.6.2中修復的錯誤 (我說可能是因為它不完全相同,但確實涉及獲取可變參數模板函數的地址)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.