Skip to content
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

Is there a x3::position_tagged without inheritance? #698

Open
denzor200 opened this issue Aug 30, 2021 · 0 comments · May be fixed by #742
Open

Is there a x3::position_tagged without inheritance? #698

denzor200 opened this issue Aug 30, 2021 · 0 comments · May be fixed by #742

Comments

@denzor200
Copy link

denzor200 commented Aug 30, 2021

Hi everyone! Is it possible to add the x3::position_tagged attribute to a custom structure without applying inheritance? If it's not possible, it question should resolve, because in the future BOOST PFR library maybe will be used on the Spirit side (The corresponding PR has already been created in the neighboring Fusion repository)

Recall that the pfr library is not able to work with inherited structures, the presence of inheritance for this library is not acceptable.

If this issue has not been resolved yet, I suggest solving it using composition instead of inheritance:

struct employee
{
	int age;
	person who;
	double salary;
        x3::position_tagged __position_tagged;
};

/// The library is aware of all the fields as they are listed in the BOOST_FUSION_ADAPT_STRUCT macro.
/// Among these fields, a search is performed for the field whose type corresponds to x3::position_tagged, the name of the field is not important.
/// Now this construction looks strange, but in the future the fields will be automatically detected using the PFR. The BOOST_FUSION_ADAPT_STRUCT macro will not be required
BOOST_FUSION_ADAPT_STRUCT(client::ast::employee,
    age, who, salary, __position_tagged
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant