Compile error due boost spirit placeholder limit not more than 10

孤街醉人 提交于 2019-12-11 06:59:24

问题


I'm getting a

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

error when compiling grammar for qi.

Is there a way to increase the maximum allowed?


回答1:


Off-hand: Avoid the code smell of large numbers of function arguments.

That said,

Before:

Live On Coliru

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

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

After:

Live On 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;

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.



来源:https://stackoverflow.com/questions/54034181/compile-error-due-boost-spirit-placeholder-limit-not-more-than-10

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!