I have a template class with a variadic template member function that I am not able to call from outside the class. This a simplified example of what I am trying to do:
template<typename T>
struct foo{
foo(){}
template<int... I>
int run(){
return sizeof...(I); // or whatever
}
};
template<int... I>
int run_int(){
return foo<int>().run<I...>(); // OK
}
template<typename T, int... I>
int run_T(){
return foo<T>().run<I...>(); // error
}
When foo is specialized, I can call its template member function run() with no problems. But if I try to call it from a function or structure that does not specialize foo, gcc(4.7) issues an error saying "parameter packs not expanded with ‘...’ ". I tried the same thing with clang (3.1) but got a similar error ( " error: expression contains unexpanded parameter pack 'I' " ).
Can anyone help me understand why the last function fails to compile? For now I can get around it by making "int...I" a non-type parameter of foo itself, and then call it like this from outside:
foo<T, I...>().run()
but I am still puzzled as to why it does not compile the other way.