How to specialize a function of a variational template that has a const reference for an argument?
Example:
template<typename T, typename... Args> T foo(Args... args) = delete; template<> int foo(int a, const char* str, const Test& t) { .... } // Fails to compile //template<> int foo(int a, const char* str, Test ) { .... } // Ok int main() { auto i = foo<int>(10, "test string!", t); return 0; }
When calling the foo function with the declared argument const Test& compiler does not see the specialized function and backups for the remote function:
error: use of deleted function 'T foo(Args ...) [with T = int; Args = {int, const char*, Test}]' auto i = foo<int>(10, "test string!", t);
The above code compiles if I remove the const link from the argument. What am I doing wrong?
The code can be found here.
c ++ template-specialization variadic-templates
Bected
source share