Re: argument deduction for function template
vectorizor wrote:
I have a slight problem with the usage of function templates. It shoud
be really easy for you guys to explain me what's wrong.
I have one base class and 2 derived classes:
/*code*/
template <typename T> struct Image {...};
template <typename T> struct GrayImage : public Image<T> {...};
template <typename T> struct ColorImage : public Image<T> {...};
/*code*/
I am now trying to write a funtion to process images. The definition
is:
/*code*/
template <typename T, typename U> void func1(ColourImage<U> &input,
GrayImage<T> &output) {...}
/*code*/
Now I am tring to call this function as follow
/*code*/
GrayImage<f32> gray, tmp;
ColourImage<u8> color;
// ....
func1(color, gray);
[ Allegedly, the compiler can't deduce T here. Alas, wrong code. ]
As it turns out, after getting to the bottom of it in comp.lang.c++,
there were two more arguments in that function, and one of them was
T, and a value of a different from 'f32' type was passed to it, so
the compiler was unable to deduce T. Of course!...
I am not sure why after the cause of the error had been shown, there
was a need to post it again, here. Maybe the server lag...
Those who have access to Google Groups, see
http://tinyurl.com/2uxqjt ( http://preview.tinyurl.com/2uxqjt )
/*code*/
[..]
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]