我有以下代码:
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
);
所以我试图解析字符串 test 并将结果放在 std::pair d 中。但是它不起作用,我怀疑它与 Compound Attribute Rules 有关.
关于如何让它工作的任何提示?
编译错误如下:
error: no matching function for call to 'std::pair::pair(const int&)'
最佳答案
它应该可以工作。人们经常忘记的是添加一个
#include <boost/fusion/include/std_pair.hpp>
到他们的包含列表。这是使 std::pair
成为成熟的 Fusion 公民所必需的。
关于c++ - 用 boost spirit 解析一对整数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4874075/