diff Framework/Toolbox/LinearAlgebra.cpp @ 804:61ba4b504e9a

PolylineSceneLayer now has one color per chain
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 28 May 2019 15:58:21 +0200
parents 9f68155c75b0
children 32eaf4929b08
line wrap: on
line diff
--- a/Framework/Toolbox/LinearAlgebra.cpp	Tue May 28 14:18:46 2019 +0200
+++ b/Framework/Toolbox/LinearAlgebra.cpp	Tue May 28 15:58:21 2019 +0200
@@ -26,6 +26,7 @@
 #include <Core/Toolbox.h>
 
 #include <stdio.h>
+#include <boost/lexical_cast.hpp>
 #include <boost/numeric/ublas/lu.hpp>
 
 namespace OrthancStone
@@ -68,15 +69,16 @@
 
       for (size_t i = 0; i < items.size(); i++)
       {
+        /**
+         * We try and avoid the use of "boost::lexical_cast<>" here,
+         * as it is very slow. As we are parsing many doubles, we
+         * prefer to use the standard "std::stod" function if
+         * available: http://www.cplusplus.com/reference/string/stod/
+         **/
+          
+#if __cplusplus >= 201103L  // Is C++11 enabled?
         try
         {
-          /**
-           * We don't use "boost::lexical_cast<>" here, as it is very
-           * slow. As we are parsing many doubles, we prefer to use
-           * the standard "std::stod" function:
-           * http://www.cplusplus.com/reference/string/stod/
-           **/
-          
           target[i] = std::stod(items[i]);
         }
         catch (std::exception&)
@@ -84,6 +86,17 @@
           target.clear();
           return false;
         }
+#else  // Fallback implementation using Boost
+        try
+        {
+          target[i] = boost::lexical_cast<double>(items[i]);
+        }
+        catch (boost::bad_lexical_cast&)
+        {
+          target.clear();
+          return false;
+        }
+#endif
       }
 
       return true;