相关疑难解决方法(0)

Boost Spirit规则和语法中的模板参数中的括号

看看这个用于实现Spirit解析器的示例,当我尝试编写类似的东西时,有些事情让我感到困惑.

语法(std::map<std::string, std::string>())的属性模板参数和规则的签名模板参数(例如qi::rule<Iterator, std::string()> key, value)包含括号.

namespace qi = boost::spirit::qi;

template <typename Iterator>
struct keys_and_values
  : qi::grammar<Iterator, std::map<std::string, std::string>()> // <- parentheses here
{
    keys_and_values()
      : keys_and_values::base_type(query)
    {
        query =  pair >> *((qi::lit(';') | '&') >> pair);
        pair  =  key >> -('=' >> value);
        key   =  qi::char_("a-zA-Z_") >> *qi::char_("a-zA-Z_0-9");
        value = +qi::char_("a-zA-Z_0-9");
    }
    qi::rule<Iterator, std::map<std::string, std::string>()> query; // <- parentheses here
    qi::rule<Iterator, std::pair<std::string, std::string>()> pair; // <- parentheses here
    qi::rule<Iterator, std::string()> key, …
Run Code Online (Sandbox Code Playgroud)

c++ templates boost boost-spirit boost-spirit-qi

4
推荐指数
1
解决办法
825
查看次数

标签 统计

boost ×1

boost-spirit ×1

boost-spirit-qi ×1

c++ ×1

templates ×1