From c29f95866f43dbf66764a5559b495733a58f4b07 Mon Sep 17 00:00:00 2001 From: Philippe Liard Date: Wed, 23 Nov 2011 08:51:14 +0000 Subject: [PATCH] CPP: Fix compilation error in default_logger.h on Visual Studio 2010. Review URL: http://codereview.appspot.com/5436046 --- cpp/src/phonenumbers/default_logger.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cpp/src/phonenumbers/default_logger.h b/cpp/src/phonenumbers/default_logger.h index d229821c7..706ebf682 100644 --- a/cpp/src/phonenumbers/default_logger.h +++ b/cpp/src/phonenumbers/default_logger.h @@ -39,11 +39,13 @@ class StdoutLogger : public Logger { #else +#include #include #include "phonenumbers/logger.h" using std::string; +using std::stringstream; // Make the logging functions private (not declared in logger.h) as the client // should not have any reason to use them. @@ -65,10 +67,12 @@ struct ConvertToString { template <> struct ConvertToString { - static inline string DoWork(const int& n) { - char buffer[16]; - std::snprintf(buffer, sizeof(buffer), "%d", n); - return string(buffer); + static inline string DoWork(int n) { + stringstream stream; + stream << n; + string result; + stream >> result; + return result; } };