U
utab
Dear all,
I have a simple template to convert its argument to a string:
template<typename T>
string AtoStr(T t){
ostringstream sstrm;
sstrm << t;
return sstrm.str();
}
This is simple with stringstream. But lets say if the argument is a
double 1.0 or an int 1
The returned value is the same "1" without decimal point. I guess the
library is optimizing the output on this one. But I need to do sth to
cope with this:
+ if the type of the argument is an int, then it should convert it to
"1"
+ if the type of the argument is a double like 1.0 then it should
convert it to "1.0".
I am not so sure if output manipulators can help me.
Best regards,
I have a simple template to convert its argument to a string:
template<typename T>
string AtoStr(T t){
ostringstream sstrm;
sstrm << t;
return sstrm.str();
}
This is simple with stringstream. But lets say if the argument is a
double 1.0 or an int 1
The returned value is the same "1" without decimal point. I guess the
library is optimizing the output on this one. But I need to do sth to
cope with this:
+ if the type of the argument is an int, then it should convert it to
"1"
+ if the type of the argument is a double like 1.0 then it should
convert it to "1.0".
I am not so sure if output manipulators can help me.
Best regards,