-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
X3: Sequence operator doesn't collapse when attribute is a single element tuple #408
Comments
You want too much guessing from Spirit. It will not do collapsing because you want to parse sequence into tuple attribute (and size of the parser sequences do not match the size of the tuple attribute). To fix your code you need to add an intermediate rule which will do collapsing (and which result should be of
That extends your tuple type from It is not a bug in Spirit but a missing feature, and I do not think it is worth the complexity (refs #178 (comment) and #463). |
Okay, so the root problem lies in that I use single element structures? |
Yes, quickfix is to replace struct ints_ {
std::vector<int> m_vector;
};
BOOST_FUSION_ADAPT_STRUCT(ints_, m_vector) with struct ints_ : std::vector<int> {}; or even typedef std::vector<int> ints_; |
Okay, thank you. |
Hello, I'm trying to make a rule, that parses integers separated by a slash, and the last one is separated by an asterisk:
Unfortunately, the code doesn't compile with this error:
According to the Compound Attribute Rules section in the documentation, the attribute of the
ints
rule should bevector<int>
:If I add another
int
field to the struct, it successfully compiles, but I would like to have all the integers in the same vector. Is there a solution to this? Am I not doing something right?The text was updated successfully, but these errors were encountered: