Skip to content

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

Open
@denzor200

Description

@denzor200

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
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions