由于Boost Spirit占位符限制而导致的编译错误不超过10 [英] Compile error due boost spirit placeholder limit not more than 10

查看:72
本文介绍了由于Boost Spirit占位符限制而导致的编译错误不超过10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到

"qi :: _ 10不是qi的成员"

"qi::_10 is not a member of qi "

为qi编译语法时出错.

error when compiling grammar for qi.

有没有办法增加允许的最大值?

Is there a way to increase the maximum allowed?

推荐答案

副手:避免大量函数参数的代码味道.

那是

之前:

在Coliru上直播

#define SPIRIT_ARGUMENTS_LIMIT 10
#include <boost/spirit/include/qi.hpp>

int main() {
    auto& _10 = boost::spirit::labels::_10;
}

之后:

在Coliru上直播

#define SPIRIT_ARGUMENTS_LIMIT 11
#include <boost/spirit/include/qi.hpp>

int main() {
    auto& _10 = boost::spirit::labels::_10;
}

奖金

您可以欺骗和硬编码自己的占位符:

BONUS

You can cheat and hard-code your own placeholders:

boost::phoenix::actor<boost::spirit::argument<998> > const _999;

请注意998_999之间的差异;这是一个未记录的实现细节,因此最好不要依赖它,或者至少要进行测试.

Note the discrepancy between 998 and _999; this is an implementation detail that is not documented, so it's probably better not rely on it, or at least have tests.

这篇关于由于Boost Spirit占位符限制而导致的编译错误不超过10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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