Reputation: 507215
I was surprised when the following worked
template<typename T>
void f(T &...);
I thought that I have to declare "T" as "typename ...T" then, and that it only works in C++0x. But the above compiled in strict C++03 mode. What's going on?
Upvotes: 12
Views: 246
Reputation: 131837
Did you call the function? Template functions don't get compiled until you call them. And in Visual Studio 2010, IntelliSense shows the real syntax of that function would be
template <class T> void f(T&, ...)
Smells like old variable argument syntax.
Upvotes: 3
Reputation: 14461
It's just the bad old C varargs syntax; the grammar allows omitting the comma. The following are equivalent:
int printf(const char* fmt, ...);
int printf(const char* fmt...);
Upvotes: 20