Boost Spirit char parser

血红的双手。 提交于 2019-12-23 02:44:43

问题


Here is a code sample:

// file main.cpp

#include <iostream>
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_io.hpp>
#include <boost/spirit/include/qi.hpp>

int main()
{
    std::string s( "1 A" );
    boost::tuple<double, char> p;
    complex_matrix_parser::iterator b = s.begin();
    complex_matrix_parser::iterator e = s.end();
    qi::phrase_parse( b, e,
            ( qi::double_ >> qi::char_('A') ),
            qi::space, qi::skip_flag::postskip, p );

    std::cerr << "==== " << p << std::endl;

    return 0;
}

This should print ==== (1 A) right? But it prints ==== (1 ), so it skips the 'A' character.

What am I doing wrong here?


回答1:


Use boost::fusion::vector instead of the boost::tuple and everything will work.



来源:https://stackoverflow.com/questions/9448120/boost-spirit-char-parser

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