I am new to boost::spirit
and trying to write a simple parser using x3.
I got an error that I can't explain.
For some reason I get an error about boost::spirit::x3::unused_type
.
The error disappears when I remove the kleene star in the line I marked below.
The other kleene stars seem to be ok (for some reason).
This is my code:
#include <string>
#include <iostream>
#include <boost/spirit/home/x3.hpp>
namespace x3 = boost::spirit::x3;
int main()
{
std::string str = "qqq::qqq::qqq";
auto begin = str.begin(), end = str.end();
bool r = x3::parse(begin, end,
( (x3::alpha | '_') >> *(x3::alnum | '_')) >>
* //this line is the problem
("::" >> (x3::alpha | '_') >> *(x3::alnum | '_'))
); // is supposed to match str
if (r && std::distance(begin,end) < 1)
{
std::cout << "Parsing succeeded\n";
}
else
{
std::cout << "Parsing FAILED\n";
std::cout << "r " << r << " d " << std::distance(begin,end) << "\n";
}
return 0;
}
This is the error:
/usr/include/boost/spirit/home/x3/core/detail/parse_into_container.hpp:254:22: error: ‘const struct boost::spirit::x3::unused_type’ has no member named ‘empty’
254 | if (attr.empty())
| ~~~~~^~~~~
/usr/include/boost/spirit/home/x3/core/detail/parse_into_container.hpp:259:22: error: ‘const struct boost::spirit::x3::unused_type’ has no member named ‘insert’
259 | attr.insert(attr.end(), rest.begin(), rest.end());
| ~~~~~^~~~~~
/usr/include/boost/spirit/home/x3/core/detail/parse_into_container.hpp:259:34: error: ‘const struct boost::spirit::x3::unused_type’ has no member named ‘end’
259 | attr.insert(attr.end(), rest.begin(), rest.end());
| ~~~~~^~~
/usr/include/boost/spirit/home/x3/core/detail/parse_into_container.hpp:259:46: error: ‘const struct boost::spirit::x3::unused_type’ has no member named ‘begin’
259 | attr.insert(attr.end(), rest.begin(), rest.end());
| ~~~~~^~~~~
/usr/include/boost/spirit/home/x3/core/detail/parse_into_container.hpp:259:60: error: ‘const struct boost::spirit::x3::unused_type’ has no member named ‘end’
259 | attr.insert(attr.end(), rest.begin(), rest.end());
| ~~~~~^~~
I am on Ubuntu 18.04 using boost 1.65.1. I read this (https://stackoverflow.com/a/49121776/2359966) post where a similar problem was described.
Is there a way to fix or circumvent this problem without changing system packages?