comparison Framework/Toolbox/LinearAlgebra.cpp @ 1164:6c159b8362ff broker

removing std::stod()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 19 Nov 2019 21:18:46 +0100
parents 341e68752354
children ad4e21df4e40
comparison
equal deleted inserted replaced
1163:ba9db2ad317c 1164:6c159b8362ff
72 target.resize(items.size()); 72 target.resize(items.size());
73 73
74 for (size_t i = 0; i < items.size(); i++) 74 for (size_t i = 0; i < items.size(); i++)
75 { 75 {
76 /** 76 /**
77 * SJO - 2019-11-19 - WARNING: I reverted from "std::stod()"
78 * to "boost::lexical_cast", as "std::stod()" is sensitive to
79 * locale settings, making this code non portable and very
80 * dangerous as it fails silently. A string such as
81 * "1.3671875\1.3671875" is interpreted as "1\1", because
82 * "std::stod()" expects a comma (",") instead of a point
83 * (".").
84 **/
85
86 #if 0 // __cplusplus >= 201103L // Is C++11 enabled?
87 /**
77 * We try and avoid the use of "boost::lexical_cast<>" here, 88 * We try and avoid the use of "boost::lexical_cast<>" here,
78 * as it is very slow. As we are parsing many doubles, we 89 * as it is very slow. As we are parsing many doubles, we
79 * prefer to use the standard "std::stod" function if 90 * prefer to use the standard "std::stod" function if
80 * available: http://www.cplusplus.com/reference/string/stod/ 91 * available: http://www.cplusplus.com/reference/string/stod/
81 **/ 92 **/
82 93
83 #if __cplusplus >= 201103L // Is C++11 enabled?
84 try 94 try
85 { 95 {
86 target[i] = std::stod(items[i]); 96 target[i] = std::stod(items[i]);
87 } 97 }
88 catch (std::exception&) 98 catch (std::exception&)