Topic: Defect report: Invalid template argument deduction in example of 14.8.1 p. 3
Author: "=?iso-8859-1?q?Daniel_Kr=FCgler?=" <daniel.kruegler@googlemail.com>
Date: Tue, 30 Jan 2007 15:00:13 CST Raw View
The example, given as
template<class X, class Y, class Z> X f(Y,Z);
void g()
{
f<int,char*,double>("aa",3.0);
f<int,char*>("aa",3.0); // Z is deduced to be double
f<int>("aa",3.0); // Y is deduced to be char*, and
// Z is deduced to be double
f("aa",3.0); //error: X cannot be deduced
}
concludes:
f<int>("aa",3.0); // Y is deduced to be char*, [..]
but according to 4.2 p. 2 this deduction is not const-correct
and should be changed to:
f<int>("aa",3.0); // Y is deduced to be const char*, [..]
Thanks to Hyman Rosen for his confirmation.
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 ]