variadic tempalte deduction fails when default arguments are involved

variadic tempalte deduction fails when default arguments are involved

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:

template<class T1 = int, class T2 = int>
class A {};
template<class... TYPES>
void foo(const A<TYPES...>& a) {
}
int main() {
  foo(A<double>());
}

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

3 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.

 

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

thanks a lot :)

Raffael

Deixar um comentário

Faça login para adicionar um comentário. Não é membro? Inscreva-se hoje mesmo!