【发布时间】:2012-11-30 20:46:50
【问题描述】:
我正在编写一个 ptree,有时我需要将 DBL_MAX 放入(作为默认值)。 当我打开生成的 xml 文件时,我看到了正确的数字。
但是当我使用 ptree.get 获取号码时,会抛出异常:conversion of data to type "d" failed
这是我的代码:
using boost::property_tree::ptree;
ptree pt;
double d=-DBL_MAX;
double d2=-1.797693134862316e+308;
double d3=-1.79769e+308;
cout<<d<<endl;
cout<<d2<<endl;
cout<<d3<<endl;
pt.put<double>("double", d);
write_xml("test.xml", pt);
cout << "totalEndTimeLowerBound: " << pt.get<double>("double")<<endl;
//doesn't work with d and d2, but works with d3
什么会导致此错误,我该如何解决?
【问题讨论】:
标签: c++ boost boost-propertytree