1

Does Visual C++ 2010 support variadic templates or does it not?

Here is stated:

Visual C++ 2010 does not support variadic templates.

But this forum entry says:

Yes, VS2010 TR1 support variable length template arguments.

And there is also an example on MSDN that is listed as for Visual C++ 2010 explicitly. However, when I try to build it with Visual C++ 2010, I get syntax error C2059 on the "...":

template<class T1, class T2, ..., class TN>
class tuple { /* ... */ };

What am I missing? Do I need to turn on some compiler option besides the C++11 support?

Community
  • 1
  • 1
theV0ID
  • 4,172
  • 9
  • 35
  • 56
  • The MSDN example code above _isn't_ a variadic template. The `...` there is meant to represent "arbitrary many, but predetermined" sequence of `typename`. A C++11 variadic template declaration would look like `template `, where the variadic type parameter can only appear _once_ as the _last_ template argument. I can't comment specifically on VS2010 support though since I don't used it. – Saran Tunyasuvunakool Mar 09 '15 at 11:37
  • *Do I need to turn on some compiler option?* Well, variadic templates are available since c++11 , so you must compile with it enable – hlscalon Mar 09 '15 at 11:41
  • @Saran I see. Thanks for the clarification. This means the forum entry is wrong. Is there any way of 'bypassing' the restriction of not being allowed to use variable length templates? – theV0ID Mar 09 '15 at 11:41
  • @1nflktd Yes, sure, I forgot to mention that I'm already doing this of course. – theV0ID Mar 09 '15 at 11:42
  • @theV0ID Here's a quick example of a valid C++11 variadic template code. See if VS2010 likes it: http://coliru.stacked-crooked.com/a/44dd192a0b8a9516 – Saran Tunyasuvunakool Mar 09 '15 at 11:50

1 Answers1

0

According to these two tables listing the features of c++11 implemented on Visual Studio compilers, variadic templates are not supported in VC10:

msdn blog

C++11 Core Language Features

Variadic templates v0.9, v1.0 on VC10 ? No

Variadic templates v0.9, v1.0 on VC11 ? No

Wiki apache

Variadic Templates only on 11.0 nov'12

Community
  • 1
  • 1
hlscalon
  • 7,304
  • 4
  • 33
  • 40