#include <boost/lexical_cast.hpp>
#include <iostream>
#include <string>
#define ERROR_LEXICAL_CAST 1
int main()
{
using boost::lexical_cast;
int a = 0;
double b = 0.0;
std::string s = "";
int e = 0;
try
{
a = lexical_cast<int>("123");
b = lexical_cast<double>("123.12");
s = lexical_cast<std::string>("123456.7");
e = lexical_cast<int>("abc");
}
catch(boost::bad_lexical_cast& e)
{
std::cout << e.what() << std::endl;
return ERROR_LEXICAL_CAST;
}
std::cout << a << std::endl;
std::cout << b << std::endl;
std::cout << s << std::endl;
return 0;
}