
29 Mar
2005
29 Mar
'05
9:37 a.m.
The last line of the following program throws a bad_lexical_cast exception. The code is compiled with VC7.1. //********************************************************** #include <limits> #include <iostream> #include <boost/lexical_cast.hpp> int main(int argc, char* argv[]) { double d = std::numeric_limits<double>::infinity(); std::string s = boost::lexical_cast<std::string>(d); std::cout<<d<<", "<<s<<std::endl; //Throws bad_lexical_cast boost::lexical_cast<double>(s); } //********************************************************** The output is: "1.#INF, 1.#INF" Am I doing something wrong ? Patrick Mézard