2

This code, taken verbatim from the 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 it fails with:

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

I'm missing something obvious?

dvd
  • 1,014
  • 6
  • 12
  • Including a link to the offending documentation would make a bit of sense... – sehe Mar 21 '17 at 23:44
  • Honestly I haven't found a link to the x3 documentation (except for these [docs](http://ciere.com/cppnow15/x3_docs/), but they are now quite old). There is also a ticket opened on the boost [trac](https://svn.boost.org/trac/boost/ticket/12322) that reports the lack of official documentation. Actually I'm building the doc of x3 from the boost sources – dvd Mar 22 '17 at 08:09

1 Answers1

3

The include

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

is missing to allow the pair to be attribute compatible

sehe
  • 374,641
  • 47
  • 450
  • 633
  • You are right as usual :) I have completely forgotten the fusion adaptors, and the compiler error does not ring a bell. – dvd Mar 22 '17 at 08:01
  • @dvd As always, the compiler rings a whole choir of bells :) Cheers – sehe Mar 22 '17 at 08:06