我正在编写一个 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
什么可能导致此错误,我该如何解决?