My question is about the following piece of code:
template <class...T>
class A
{
public:
template <class...S>
static void a() { }
};
template <class...T>
class B
{
public:
template <class...S>
void b()
{
A<T...>::a<S...>();
}
};
int main(int argc, char** argv)
{
return 0;
}
I have a class A
that has a variadic template and contains a static method a
that has another variadic template. From somewhere else (class B
in this case) I have two different sets of variadic templates I want to pass to A::a
.
The compiler (GCC 4.8.1) gives the following error message:
main.cpp: In static member function ‘static void B<T>::b()’:
main.cpp:16:22: error: expected primary-expression before ‘...’ token
A <T...>::a<S...>();
^
main.cpp:16:22: error: expected ‘;’ before ‘...’ token
Also notice that when I change the method b()
to this:
void b()
{
A<int, char, short>::a<S...>();
}
or some other specification of A's templates then the code compiles just fine.
What is wrong with the above code?
()...)`). So the expansions are independent.