I have a C ++ function that looks like this:
template<class T> bool function(QString *text, T number, T (*f)(QString, bool)){ bool ok = true; QString c = "hello"; T col = (*f)(c, &ok);
I call it from the outside as follows
double num = 0.45; double (*fn)(QString, bool) = &doubleFromString; function(&text, num, fn);
and (Edited)
unsigned int num = 5; int (*fn)(QString, bool) = &intFromString; function(&text, num, fn);
And I get an error
template parameter T is ambigious
I assume the problem is combining the template and passing the function as an argument, but I'm not sure how to figure it out. (I do not want to write a function twice with only different types). Any solution?
source share