2

此代码逐字取自 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);

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

4

1 回答 1

3

包括

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

缺少以允许该对属性兼容

于 2017-03-21T23:43:42.020 回答