Re: argument deduction for function template
vectorizor wrote:
Hey all,
thanks for the comments. Please find attached a standalone version of
my code. Please forgive the mess, I just did a quick copy and paste of
many files.
I am compiling with VS 2005 and the latest Intel compiler.
This is what your code should look like, distilled:
[..]
typedef float f32;
typedef unsigned char u8;
template <typename T>
struct Image
{
};
template <typename T>
struct GrayImage : public Image<T>
{
};
template <typename T>
struct ColourImage : public Image<T>
{
};
template <typename T, typename U>
void RGB2Log(ColourImage<U> &input, GrayImage<T> &buffer,
bool linear, T snr)
{
}
int main(int argc, char* argv[])
{
GrayImage<f32> gray, tmp;
ColourImage<u8> color;
RGB2Log(color, gray, true, 1.0);
Here you pass 'GrayImage<f32>' as the second argument from which
'T' is deduced as 'f32' or 'float'. _And_ you pass 1.0 (a double
literal) as the fourth argument, from which 'T' is deduced as...
'double' ! Do you not see it in the error message?
Now , if you want '1.0' to be treated as 'f32', you need to cast
it to 'f32':
RGB2Log(color, gray, true, (f32) 1.0);
}
##### CUT #####
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask