samedi 14 mars 2015

Recognising template typename in runtime


Vote count:

0




I am in need for your expert help with this little code bellow:



template<typename T> void print_element(T t)
{
int width;
if(pre_def_const+2 < 8) width=8;
else width = pre_def_const+2;

cout << left << setw(width) << setfill(' ') << t;
}


This function will receive only doubles and string parameters and I want to be able to diferentiate between each case.


In short I want to add something like this to that code above:



if(T==double) ...
if(T==string) ...


I need this to test for doubles being smaller than zero. Thank you!



asked 45 secs ago







Recognising template typename in runtime

Aucun commentaire:

Enregistrer un commentaire