的boost ::精神::气 [英] boost::spirit::qi

查看:142
本文介绍了的boost ::精神::气的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑以下code:(::提振精神2.5.1)

Consider the following code: (boost::spirit 2.5.1)

qi::parse(str.begin(), str.end(), (+qi::alpha)[[](const string& s){cout << s<< '\n';}]
                                    >> (*(qi::char_(',') | qi::char_('\'')))
                                    >> qi::uint_[[](int integer){cout << integer << '\n';}]);

在[[](INT整数){COUT&LT;&LT;整数LT;&LT;'\\ n';}]的作品,但类似的code为+气::阿尔法没有按'吨。

The "[[](int integer){cout << integer << '\n';}]" works, but the analogous code for "+qi::alpha" doesn't.

我怎样才能纠正code?

How can I correct the code?

推荐答案

您code给我下面的编译器错误,跳过某些位

Your code gives me the following compiler error, skipping some bits

/usr/include/boost/spirit/home/support/action_dispatch.hpp:142:13:
error: no matching function for call to
‘action_dispatch<>::do_call(
    const main()::<lambda(const string&)>&,
    action_dispatch<>::fwd_tag<std::vector<char>>,
...

这归结为传递给你的拉姆达参数为矢量&lt;字符&GT; ,而不是字符串

所以,替换字符串矢量&lt;&字符GT;

(+qi::alpha)[[](const std::vector<char>& s) {
      cout << std::string(s.begin(), s.end()) << '\n';
}]

这篇关于的boost ::精神::气的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆