Reputation: 39774
Recently, I looked into GCC's basic_string.h
and noticed that all std::to_string
overloads are implemented using std::vsnprintf
like for example:
inline string
to_string(int __val)
{
return __gnu_cxx::__to_xstring<string>(&std::vsnprintf, 4 * sizeof(int), "%d", __val);
}
Wouldn't this introduce a lot of overhead? Stringifying an integer base 10 is possible in just a few lines of code, so why would this be implemented using vsnprintf
?
Upvotes: 0
Views: 351