Spirit X3:复合组件的基本示例无法编译

时间:2017-03-21 23:01:48

标签: c++ boost-spirit boost-spirit-x3

此代码,从x3文档中逐字逐句,不编译

#include <string>
#include <utility>
#include <boost/spirit/home/x3.hpp>

namespace x3 = boost::spirit::x3;

int main(int argc, char* argv[]) {
    std::string input("(1.0, 2.0)");
    std::string::iterator strbegin = input.begin();
    std::pair<double, double> p;
    x3::parse(strbegin, input.end(),
        '(' >> x3::double_ >> ", " >> x3::double_ >> ')',
        p);
    return 0;
}

使用Boost 1.63,1.61和Gcc 7,6.2测试时,它失败了:

/home/dvd/Projects/personal/iforeader/main.cpp:27:4:   required from here
/home/dvd/Projects/personal/iforeader/3rdparty/boost/spirit/home/x3/support/traits/move_to.hpp:62:18: error: no match for ‘operator=’ (operand types are ‘std::pair<double, double>’ and ‘std::remove_reference<double&>::type {aka double}’)
         dest = std::move(src);

我错过了一些明显的东西?

1 个答案:

答案 0 :(得分:4)

包含

#include <boost/fusion/adapted/std_pair.hpp>
缺少

以允许该对属性兼容