Spirit X3: Basic Composite Component Example Does Not Compile

This code, taken verbatim from x3 documentation, does not compile

#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;
}

      

Tested with Boost 1.63,1.61 and Gcc 7,6.2 with error:

/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 foroperator=’ (operand types are ‘std::pair<double, double>’ andstd::remove_reference<double&>::type {aka double}’)
         dest = std::move(src);

      

Am I missing something obvious?

+3


source to share


1 answer


Enable

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

      



missing to ensure pair compatibility

+4


source







All Articles