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

C++ Boost Spirit规则和语法中模板参数中的括号,c++,templates,boost,boost-spirit,boost-spirit-qi,C++,Templates,Boost,Boost Spirit,Boost Spirit Qi,考虑到如何实现一个Spirit解析器,当我试图编写类似的东西时,我发现了一些问题 语法的属性模板参数(std::map())和规则的签名模板参数(例如qi::rule key,value)包含括号 namespace qi = boost::spirit::qi; template <typename Iterator> struct keys_and_values : qi::grammar<Iterator, std::map<std::string, std:

考虑到如何实现一个Spirit解析器,当我试图编写类似的东西时,我发现了一些问题

语法的属性模板参数(
std::map()
)和规则的签名模板参数(例如
qi::rule 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, value; // <- parentheses here
};
namespace qi=boost::spirit::qi;
模板
结构键\u和\u值
:qi::grammar//>*((qi::lit(“;”)|“&”)>>pair);
配对=键>>-('='>>值);
key=qi::char_(“a-zA-Z”)>*qi::char_(“a-zA-Z_0-9”);
value=+qi::char_uu(“a-zA-Z_u0-9”);
}
qi::规则查询;//<代码>标准::映射()
这是一个函数类型

()
表示“一个返回
std::map
且没有参数的函数。”


没有
()
,类型只是“
std::map
,”这是不正确的。

Ha!那么,就没有什么特别与提升/精神相关的了!
std::map<std::string, std::string>()