【问题标题】:Parsing a pair of ints with boost spirit用增强精神解析一对整数
【发布时间】:2011-06-19 22:23:10
【问题描述】:

我有以下代码:

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
        );

所以我试图解析字符串测试并将结果放在 std::pair d 中。但是它不起作用,我怀疑它与Compound Attribute Rules有关。

关于如何使它工作的任何提示?

编译错误如下:

错误:没有匹配的调用函数 到 'std::pair::pair(const int&)'

【问题讨论】:

    标签: c++ parsing boost boost-spirit


    【解决方案1】:

    它应该工作。人们经常忘记的是添加一个

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

    到他们的包含列表。这是使std::pair 成为成熟的 Fusion 公民所必需的。

    【讨论】:

    • 完美的工作.. 它写在文档的某个地方吗?我找不到它,但也许我只是忽略了它。
    • 同样的问题,幸运的是在这里找到了解决方案:-)
    • 这也解决了我的问题。非常感谢海报。
    猜你喜欢
    • 1970-01-01
    • 2011-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多