#include <iostream>
#include <boost/lexical_cast.hpp>
#include <string>
using namespace std;
int main() {
string str = "12345";
try{
int num = boost::lexical_cast<int>(str);
cout<< "Srting to num: " << num << endl;
double dbl = boost::lexical_cast<double>("12.34");
cout<< "String to double: " << dbl << endl;
string strFromInt = boost::lexical_cast<string>(4567);
cout<< "Integer to String: " << strFromInt<<endl;
}
catch(const boost::bad_lexical_cast &e)
{
cerr<<"Error"<<e.what()<<endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Ym9vc3QvbGV4aWNhbF9jYXN0LmhwcD4KI2luY2x1ZGUgPHN0cmluZz4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBtYWluKCkgewogICAgc3RyaW5nIHN0ciA9ICIxMjM0NSI7CiAgICAKICAgIHRyeXsKICAgICAgICBpbnQgbnVtID0gYm9vc3Q6OmxleGljYWxfY2FzdDxpbnQ+KHN0cik7CiAgICAgICAgY291dDw8ICJTcnRpbmcgdG8gbnVtOiAiIDw8IG51bSA8PCBlbmRsOwogICAgICAgIAogICAgICAgIGRvdWJsZSBkYmwgPSBib29zdDo6bGV4aWNhbF9jYXN0PGRvdWJsZT4oIjEyLjM0Iik7CiAgICAgICAgY291dDw8ICJTdHJpbmcgdG8gZG91YmxlOiAiIDw8IGRibCA8PCBlbmRsOwogICAgICAgIAogICAgICAgIHN0cmluZyBzdHJGcm9tSW50ID0gYm9vc3Q6OmxleGljYWxfY2FzdDxzdHJpbmc+KDQ1NjcpOwogICAgICAgIGNvdXQ8PCAiSW50ZWdlciB0byBTdHJpbmc6ICIgPDwgc3RyRnJvbUludDw8ZW5kbDsKICAgIH0KICAgIAogICAgY2F0Y2goY29uc3QgYm9vc3Q6OmJhZF9sZXhpY2FsX2Nhc3QgJmUpCiAgICB7CiAgICAgICAgY2Vycjw8IkVycm9yIjw8ZS53aGF0KCk8PGVuZGw7CiAgICB9CgogICAgcmV0dXJuIDA7Cn0=