C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Defect report|editorial: Unwanted error in 14.8.2.5/12 examp

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
Daniel Krügler
Guest





PostPosted: Thu Apr 19, 2007 12:42 am    Post subject: Defect report|editorial: Unwanted error in 14.8.2.5/12 examp Reply with quote



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 ]
Back to top
Pete Becker
Guest





PostPosted: Thu Apr 19, 2007 6:07 pm    Post subject: Re: Defect report|editorial: Unwanted error in 14.8.2.5/12 e Reply with quote



Daniel Krügler wrote:
Quote:
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.


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

--

-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
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 ]
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.