I've used to_string a few times on gcc and clang, but
have turned away from it after seeing a jump in object
size compared to other alternatives. That's been over
three months ago so haven't tried it with the versions
of those compilers I'm using now. This has been one of
few disappointments for me with new stuff.
That "object size" generally matters only when it is embedded
software. Otherwise it is down in my wishlist somewhere among
"good to have". The authors of libstdc++ do it for free so if
you know a way how to make some thing in it more efficient then
help them. ;-)
Can you suggest some portable alternatives to time_t?
Most readable and portable at the moment are ISO 8601 compatible text
representations.
One can still use time_t and struct tm internally with those. For example
strftime seems to be available in most implementations. (Untested code):
time_t now;
time(&now);
// time_t to struct tm
struct tm now2 = gmtime(&now);
// struct tm to ISO 8601 string
std::string now3(sizeof "2013-07-24T19:59:09Z", '\0');
strftime(&t[0], t.size(), "%FT%TZ", gmtime(&now));
Parsing ISO 8601 back to struct tm is bit trickier, because POSIX
strptime is not available everywhere. OTOH one can always find an
implementation for it if it is missing.
I myself would use things in <chrono> or std::get_time/std:
ut_time
if available. History has shown that standard things will be most portable
sooner or later. There is also Boost.Date_Time with lot of things done
well but it has some shortcomings too.