undefined behaviour somewhere in boost::spirit::qi::phrase_parse

后端 未结 1 490
一整个雨季
一整个雨季 2020-11-29 14:10

I am learning to use boost::spirit library. I took this example http://www.boost.org/doc/libs/1_56_0/libs/spirit/example/qi/num_list1.cpp and compiled it on my computer - it

相关标签:
1条回答
  • 2020-11-29 14:47

    You cannot use auto to store parser expressions¹

    Either you need to evaluate from the temporary expression directly, or you need to assign to a rule/grammar:

    const qi::rule<std::string::const_iterator, qi::space_type> doubles_parser_local = qi::double_ >> *(',' >> qi::double_);
    

    You can have your cake and eat it too on most recent BOost versions (possibly the dev branch) there should be a BOOST_SPIRIT_AUTO macro

    This is becoming a bit of a FAQ item:

    • Assigning parsers to auto variables
    • boost spirit V2 qi bug associated with optimization level

    ¹ I believe this is actually a limitation of the underlying Proto library. There's a Proto-0x lib version on github (by Eric Niebler) that promises to solve these issues by being completely redesigned to be aware of references. I think this required some c++11 features that Boost Proto currently cannot use.

    0 讨论(0)
提交回复
热议问题