【发布时间】:2019-07-03 14:50:02
【问题描述】:
下面的代码是将“key=val;..”字符串解析为std::map,编译失败,报错:
错误 C2146:语法错误:在标识符“value_type”之前缺少“>”
错误 C2039 : 'value_type': 不是 'std::pair,std::allocator,std::basic_string,std::allocator>>' c:\git\risk-engine-core_tcp\stage\boost- 的成员1.66.0-barclays-1\include\boost\spirit\home\support\container.hpp
它不喜欢作为容器传递的最后一个参数“contents”(std::map)。
Boost 版本是 1.66
namespace qi = boost::spirit::qi;
std::map<std::string,std::string> contents;
std::string::iterator first = str.begin();
std::string::iterator last = str.end();
const bool result = qi::phrase_parse(first,last,
*( *(qi::char_-"=") >> qi::lit("=") >> *(qi::char_-";") >> -qi::lit(";") ),
ascii::space, contents);
查看 boost 文档和堆栈溢出,我没有发现上述代码有任何问题。
【问题讨论】:
标签: c++ boost-spirit-qi