Which would use the same techniques that Abel Sinkovics metaparse to parse the struct and automatically expand to the boilerplate template code for Boost.Fusion.
I don't think metaparse can be used for this. It can't reference the members in the struct.
I'm naturally open for a first iteration in this direction to see how we could change the DEFINE_STRUCT to allow adding own code to the structs from your experience.
As a first iteration, it would be nice if the extension metafunctions(ie
`access::struct_member`, `struct_member_name`, `struct_assoc_key`) would
provide an enable parameter. This would allow the struct definitions to be
inline. Boost.Fusion already provides `INLINE_STRUCT` but it doesn't provide
the member name nor an associative key.
When we have the members inline, we can then inherit from the base operators
we would like for the class:
struct person : equality<person>, streamable<person>
{
BOOST_FUSION_INLINE(
(std::string, name)
(int, age)
);
};
And then we could have another `INLINE_CONSTRUCT` that will generate the
constructor:
struct person : equality<person>, streamable<person>
{
BOOST_FUSION_INLINE_CONSTRUCT(person,
(std::string, name)
(int, age)
);
};
Then for those that want a define all together, we could have a macro like
this:
BOOST_FUSION_DEFINE(person, equality<person>, streamable<person>)
(
(std::string, name)
(int, age)
)
So that way the user can add in the behaviours they want through
inheritance.
Additionally, we could also switch the type and field name order so we could
handle types with commas in it:
struct person : equality<person>, streamable<person>
{
BOOST_FUSION_INLINE(
(name, std::string)
(age, int)
(locations, std::map