Topic: Const and array argument for a template


Author: joe_hesse@actcx.com ("Joseph Hesse")
Date: Tue, 17 Sep 2002 23:09:11 +0000 (UTC)
Raw View
Hi,
Is there some simple explanation for the fact that

int a[2] = {1, 2};
const int (&b)[2] = a;

works just fine and that

template <typename T, int s>
void f(const T (&array)[size]) {}

will not work for

void foo()
{
  int a[2] = {1, 2};
  f(a);  // no matching template function
}

except for the fact that the standard does not allow it?

Thank you,
Joe Hesse


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]