Search code examples
c++parsingtuplescharacterboost-spirit-qi

Boost Spirit char parser


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?


Solution

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