[OpenWalnut-Dev] Boost lexical_cast is evil
Sebastian Eichelbaum
eichelbaum at informatik.uni-leipzig.de
Wed Feb 8 15:46:37 CET 2012
Hi list
The current boost::lexical_cast (tested with boost 1.48) uses the currently set global locale for converting numbers to strings. This causes "boost::lexical_cast< std::string >( 0.1f )" to be "0,1" on german systems. This causes severe problems in many parts of our code, where we converted numbers to strings and vice versa (loaders, project files, shader preprocessors , .........). I have removed ALL occurrences of boost's lexical cast in our code. I added two simple functions to replace it:
template< typename T >
T string_utils::fromString( const std::string& str );
and
template< typename T >
std::string string_utils::toString( const T& value );
They do the same job in the C locale. Avoid any further use of boost::lexical_cast!
Bye
Sebastian
--
Dipl.-Inf. Sebastian Eichelbaum
Universität Leipzig
Institut für Informatik
Abteilung Bild- und Signalverarbeitung
PF 100920
D-04009 Leipzig
More information about the OpenWalnut-Dev
mailing list