Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

variadic tempalte deduction fails when default arguments are involved

Raffael_C_
Beginner
369 Views

Hi,

While porting some c++ code from linux to windows (using Intel Composer XE 2014 Update 1 on Windows) I came across a piece of code which is similar to the following:

[cpp]

template<class T1 = int, class T2 = int>

class A {};

template<class... TYPES>

void foo(const A<TYPES...>& a) {

}

int main() {

  foo(A<double>());

}

[/cpp]

This compiles fine with gcc 4.8.2 and clang 3.4 (using std=c++11) on linux. But intel throws a compilation error, i.e. it seems that it cannot deduce the type of the variadic template parameters TYPES.

Unfortunately the trick with the default template arguments was heavily used by boost to emulate variadic templates prior to c++11. Therefore the above bug implies that many libraries of boost cannot made to work with variadic templates in a simple fashion (although this is no problem with gcc and clang 3.4).

I hope this can be fixed in a future update of the intel compiler,

Raffael

0 Kudos
2 Replies
Judith_W_Intel
Employee
369 Views

 

Raffael,

Thanks for the bug report, we'll track this internally as DPD200253247.

BTW, the problem seems more general than just default arguments, if you try this you'll notice that variadic template argument deduction fails with the call to foo2() also (and shouldn't):

template<class T1 = int, class T2 = int>  class A {};

template<class T1, class T2>  class A2 {};

template<class... TYPES>  void foo(const A<TYPES...>& a);

template<class... TYPES>  void foo2(const A2<TYPES...>& a);

 

int main() {

  foo(A<double>());

  foo2(A2<int,int>());

  return 0;

}

Judy

0 Kudos
Raffael_C_
Beginner
369 Views

thanks a lot :)

Raffael

0 Kudos
Reply