gpt4 book ai didi

c++ - boost::property_tree::xml_writer_settings 编译错误

转载 作者:可可西里 更新时间:2023-11-01 15:56:58 26 4
gpt4 key购买 nike

为了漂亮地打印我的 XML 输出 boost::property_tree ,我写了下面的代码:

#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>

int main()
{
std::string filename = "test.xml";
boost::property_tree::ptree pt;
pt.put("some.path.value", "hello");

boost::property_tree::xml_writer_settings<char> settings('\t', 1);
write_xml(filename, pt, settings);
}

不幸的是我有这个错误,我找不到任何相关信息:

/usr/local/include/boost/property_tree/detail/xml_parser_writer_settings.hpp:38:19: error: type 'char' cannot be used prior to '::' because it has no members
typedef typename Str::value_type Ch;
^

有什么想法吗?

最佳答案

我会使用辅助函数

std::ofstream file("test.xml");

boost::property_tree::ptree pt;
pt.put("some.value", "test");

boost::property_tree::write_xml(
file, pt,
boost::property_tree::xml_writer_make_settings<std::string>('\t', 1));

关于c++ - boost::property_tree::xml_writer_settings 编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29370713/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com