Pattern argument output for array types

Microsoft VC ++ 2010 gives an error in this code:

template <int D, typename T>
void Foo(T x[D]) {
  // details omitted
}

int main() {
  float x[3];
  Foo(x);  // C2784: could not deduce template argument for 'T [D]' from 'float [3]'
  return 0;
}

The same code is passed with gcc and clang.

Is this a bug with VC ++ 2010?

If this is an error:

  • Does anyone know if this is fixed in a later version of VC ++?
  • Is there a workaround besides an explicit call Foo<3, float>?

If this is not an error:

Is there a gcc and clang extension that allows them to resolve template arguments?

I greatly simplified the actual code to this small example. I tried this on other compilers, but now I do not have access to newer Microsoft compilers. I found similar questions on SO, but none of them specifically address this case.

+4
source share
1

T x[D] T x[] aka T* x. D . void Foo(T (&x)[D]) - .

+6

Source: https://habr.com/ru/post/1526229/


All Articles