Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing a pair of ints with boost spirit

I have the following code:

std::string test("1.1");
std::pair<int, int> d;

bool r = qi::phrase_parse(
        test.begin(),
        test.end(),
        qi::int_ >> '.' >> qi::int_,
        space,
        d
        );

So I'm trying to parse the string test and place the result in the std::pair d. However it is not working, I suspect it has to do with the Compound Attribute Rules.

Any hints to how to get this working?

The compiler error is the following:

error: no matching function for call to 'std::pair::pair(const int&)'

like image 481
mortenvp Avatar asked Feb 02 '11 11:02

mortenvp


1 Answers

It should work. What people forget very often is to add a

#include <boost/fusion/include/std_pair.hpp>

to their list of includes. This is necessary to make std::pair a full blown Fusion citizen.

like image 158
hkaiser Avatar answered Oct 27 '22 18:10

hkaiser