Boost logo

Boost Users :

From: Markus Werle (numerical.simulation_at_[hidden])
Date: 2007-01-30 12:05:33


Hi!

The following code snippet prints "failure!" during execution:

#include <boost/lexical_cast.hpp>

#include <iostream>

int main()
{
        try
        {
                bool test = boost::lexical_cast<bool>("true");
        }
        catch (boost::bad_lexical_cast const &)
        {
                std::cerr << "failure!\n";
        }
}

IIRC there was some way to achieve a conversion using
the correct locale and stringstreams. Is there a way to obtain a
successful conversion with lexical_cast, too?

Markus


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