jeudi 1 août 2019

Legal use of non-trailing function template parameter pack?

While debugging someone's nasty macro-generated code, I saw that MSVC++ alone was not happy with something akin to the following function template declaration:

template <typename ...Vs, typename>
void foo();

Fair enough. I was puzzled though as to why GCC and Clang would compile that. I added a definition of foo to the declaration above, and now GCC also produces a compilation error (Clang remains content). This code is below:

template <typename ...Vs, typename>
void foo();

template <typename ...Vs, typename = int>
void foo() {  }

int main(int argc, char *argv[])
{
  foo<char,float>();
  return 0;
}

Is Clang right or wrong?

Aucun commentaire:

Enregistrer un commentaire