Boost logo

Boost Users :

From: Patrick Mézard (pmezard_at_[hidden])
Date: 2005-03-29 04:37:45


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net