Monday, November 06, 2006

a neat ToString for c++




template <class T>
string to_string(T toBeConverted){

// create an out string stream
ostringstream buffer;
// write the value to be converted to the output stream
buffer << toBeConverted;
// get the string value
return buffer.str();
}

1 comment:

Robert Gould said...

Thanks! You just saved me a few hours of my life.
So I figured I could spare a few moments to thank you ;)