samedi 14 mars 2015

Ultimate Function Template?


Vote count:

0




I just started the topic of function templates today and I'm excited about the prospects.


Suppose I have something like:



template <class T>

T findGreater(T t1, T t2) { return (t1 > t2) ? t1 : t2; }


I can either pass two ints or two doubles to the function, but is there anything ultimate like I can pass an int and a double and it just returns the greater one. I know we get some ambiguity error for the function and all but is there a nice and smooth way of achieving this ultimate template functionality?



asked 25 secs ago







Ultimate Function Template?

Aucun commentaire:

Enregistrer un commentaire