diff Core/Logging.h @ 2504:78862372ea88

fix msvc build
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 26 Mar 2018 10:13:50 +0200
parents 911e62dbb4ac
children a4f885670da7
line wrap: on
line diff
--- a/Core/Logging.h	Sat Mar 24 12:02:52 2018 +0100
+++ b/Core/Logging.h	Mon Mar 26 10:13:50 2018 +0200
@@ -59,6 +59,8 @@
 #  include <orthanc/OrthancCPlugin.h>
 #endif
 
+#include <boost/lexical_cast.hpp>
+
 namespace Orthanc
 {
   namespace Logging
@@ -91,13 +93,8 @@
       {
       }
       
-      std::ostream& operator<< (const std::string& message)
-      {
-        return *this;
-      }
-
-      // This overload fixes build problems with Visual Studio 2015
-      std::ostream& operator<< (const char* message)
+      template <typename T>
+      std::ostream& operator<< (const T& message)
       {
         return *this;
       }
@@ -116,7 +113,6 @@
        ORTHANC_ENABLE_LOGGING_STDIO == 1)
 
 #  include <boost/noncopyable.hpp>
-#  include <boost/lexical_cast.hpp>
 #  define LOG(level)  ::Orthanc::Logging::InternalLogger \
   (::Orthanc::Logging::level, __FILE__, __LINE__)
 #  define VLOG(level) ::Orthanc::Logging::InternalLogger \
@@ -148,7 +144,7 @@
       ~InternalLogger();
       
       template <typename T>
-      InternalLogger& operator<< (T message)
+      InternalLogger& operator<< (const T& message)
       {
         message_ += boost::lexical_cast<std::string>(message);
         return *this;
@@ -186,15 +182,10 @@
 
       ~InternalLogger();
       
-      std::ostream& operator<< (const std::string& message)
+      template <typename T>
+      std::ostream& operator<< (const T& message)
       {
-        return (*stream_) << message;
-      }
-
-      // This overload fixes build problems with Visual Studio 2015
-      std::ostream& operator<< (const char* message)
-      {
-        return (*stream_) << message;
+        return (*stream_) << boost::lexical_cast<std::string>(message);
       }
     };
   }