I have a simple ptree with some values and want to output it in a file for debug reasons. But whenever I want to write double values it throws a bad any cast exception. Am I missing something?
property_tree::ptree obj;
obj.put<std::string>("abc1", "t1");
obj.put<std::string>("abc2", "t2");
obj.put<std::string>("abc3", "t3");
obj.put<std::string>("abc4", "t4");
obj.put<std::string>("abc5", "t5");
obj.put<double>("lksd", 12.393); // this courses
const auto settings = boost::property_tree::xml_writer_make_settings< std::string >(' ', 4);
boost::property_tree::xml_parser::write_xml("obj.xml", obj, std::locale(), settings);
The output looks like this
<?xml version="1.0" encoding="utf-8"?>
<abc1>t1</abc1>
<abc2>t2</abc2>
<abc3>t3</abc3>
<abc4>t4</abc4>
<abc5>t5</abc5>
<abc6>