CPP: Fix compilation error in default_logger.h on Visual Studio 2010.
authorphilip.liard@gmail.com <philip.liard@gmail.com@ee073f10-1060-11df-b6a4-87a95322a99c>
Wed, 23 Nov 2011 08:51:14 +0000 (08:51 +0000)
committerphilip.liard@gmail.com <philip.liard@gmail.com@ee073f10-1060-11df-b6a4-87a95322a99c>
Wed, 23 Nov 2011 08:51:14 +0000 (08:51 +0000)
Review URL: http://codereview.appspot.com/5436046

git-svn-id: http://libphonenumber.googlecode.com/svn/trunk@392 ee073f10-1060-11df-b6a4-87a95322a99c

cpp/src/phonenumbers/default_logger.h

index d229821..706ebf6 100644 (file)
@@ -39,11 +39,13 @@ class StdoutLogger : public Logger {
 
 #else
 
+#include <sstream>
 #include <string>
 
 #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<int> {
-  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;
   }
 };