Question

At the following code I am trying to use Boost Spirit Auto Parser for a sequence or two doubles, but it doesn't compile. What am I doing wrong here?

// file main.cpp

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

namespace qi = boost::spirit::qi;

int main()
{
    boost::tuple<double, double> p;
    char* i = 0;
    qi::phrase_parse( i, i, p, qi::space );
    // qi::phrase_parse( i, i, qi::double_ >> qi::double_, qi::space, qi::skip_flag::postskip, p );

    return 0;
}

The commented out line compiles, so it accepts boost::tuple<double, double> as the attribute type of qi::double_ >> qi::double_; but it fails to obtain the parser from the attribute type. Why?

Was it helpful?

Solution

It's the same answer as in your other question - use boost::fusion::vector instead.

OTHER TIPS

It compiles for me (g++ 4.6.1/boost 1.46.1) if I add the following include to your program:

#include <boost/fusion/adapted/boost_tuple.hpp>

I believe this adapts boost::tuple to be a conforming boost::fusion sequence, required by the Sequence compound attribute rule:

http://www.boost.org/doc/libs/1_48_0/libs/spirit/doc/html/spirit/qi/quick_reference/compound_attribute_rules.html

Graham

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top