X3 problem
Mikael Asplund <[email protected]>
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <[email protected]> |
Hi!
I really can't figure out what's wrong with this... Can anyone figure out what's wrong? Using boost 1.60.
It seem to be exactly as prescribed, and the error messages that X3 produce are less then helpful:
http://coliru.stacked-crooked.com/a/5c128d4f02379eb8
#include <iostream>
#include <string>
#include <vector>
#include <boost/spirit/home/x3.hpp>
#include <boost/optional.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
using std::string;
using std::vector;
using std::pair;
namespace x3 = boost::spirit::x3;
int parse_input(vector<string> v);
int main(int argc, const char* argv[]) {
if (argc > 1) {
return parse_input(vector<string>(&argv[1], &argv[argc + !argc]));
}
return 1;
}
struct XXX {
int a;
boost::optional<pair<int, int>> b;
};
BOOST_FUSION_ADAPT_STRUCT(XXX, a, b)
int parse_input(vector<string> v) {
std::stringstream ss;
std::copy(v.begin(), v.end(), std::ostream_iterator<string>(ss, " "));
string s = ss.str();
auto iter = s.begin();
auto end = s.end();
XXX x;
bool success = x3::phrase_parse(iter, end, x3::int_ >> -(x3::int_ >> x3::int_), x3::space, x);
return !success;
}
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://makebettercode.com/inteldaal-eval
_______________________________________________
Spirit-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/spirit-general