Topic: Defect report|editorial: Unwanted error in 14.8.2.5/12 example


Author: =?iso-8859-1?q?Daniel_Kr=FCgler?= <daniel.kruegler@googlemail.com>
Date: Wed, 18 Apr 2007 18:42:37 CST
Raw View
Hello,

both the current 14882-2003 standard as well as the draft N2134
provide the following example in 14.8.2.4/12 and 14.8.2.5/12, resp.

template<class T, T i> void f(double a[10][i]);
int v[10][20];
f(v); //error: argument for template-parameter T cannot be deduced

The problem is that additional to the error which is explained here
there exists another one, namely that f has a parameter that is an
array of double, but the invocation provides an array of int.

Proposed resolution:

Fix the mentioned example as follows:

template<class T, T i> void f(int a[10][i]);
int v[10][20];
f(v); //error: argument for template-parameter T cannot be deduced

P.S.: I could not decide whether this is only editorial or not.

Greetings from Bremen,

Daniel Kr   gler


---
[ 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.comeaucomputing.com/csc/faq.html                      ]





Author: pete@versatilecoding.com (Pete Becker)
Date: Thu, 19 Apr 2007 13:07:25 GMT
Raw View
Daniel Kr=FCgler wrote:
> Hello,
>=20
> both the current 14882-2003 standard as well as the draft N2134
> provide the following example in 14.8.2.4/12 and 14.8.2.5/12, resp.
>=20
> template<class T, T i> void f(double a[10][i]);
> int v[10][20];
> f(v); //error: argument for template-parameter T cannot be deduced
>=20
> The problem is that additional to the error which is explained here
> there exists another one, namely that f has a parameter that is an
> array of double, but the invocation provides an array of int.
>=20
> Proposed resolution:
>=20
> Fix the mentioned example as follows:
>=20
> template<class T, T i> void f(int a[10][i]);
> int v[10][20];
> f(v); //error: argument for template-parameter T cannot be deduced
>=20
> P.S.: I could not decide whether this is only editorial or not.
>=20

I can't decide either, which means that it's not editorial. <g>

--=20

 -- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and=20
Reference." (www.petebecker.com/tr1book)

---
[ 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.comeaucomputing.com/csc/faq.html                      ]