简体   繁体   English

使用boost :: property_tree :: xml_writer_settings编译错误

[英]Compilation error with boost::property_tree::xml_writer_settings

In order to pretty print my XML output with boost::property_tree , I wrote the following code: 为了使用boost :: property_tree打印我的XML输出,我编写了以下代码:

#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);
}

Unfortunately I have this error and I can't find any information about it: 不幸的是我有这个错误,我找不到任何有关它的信息:

/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;
                     ^

Any idea? 任何的想法?

I'd use the helper function 我会使用辅助函数

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));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM