Parsing a pair of ints with boost spirit

孤人 提交于 2019-11-29 13:41:02

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/4874075/parsing-a-pair-of-ints-with-boost-spirit

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