I need to convert an integer to a Glib::ustring, but I don't want to use stringstream. Not that there's anything inherently WRONG with stringstream, but I don't want yet another library just to accomplish such a simple task.
My first instinct is to write a function with a big 'ol if-statement, or use an array of characters for each digit, but there has to be something cleaner. Is there any alternative?
Glib::ustring
provides aformat
static function that simply forwards whatever you throw at it (up to 8 arguments, no variadic template yet it seems) to a stringstream and returns the formatted string:Since c++11 the standard library also has an overloaded
to_string
method for converting integers and floats