mortenvp
mortenvp

Reputation: 1115

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&)'

Upvotes: 13

Views: 1655

Answers (1)

hkaiser
hkaiser

Reputation: 11521

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.

Upvotes: 23

Related Questions