You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi developers, I have used BOOST_HANA_DEFINE_STRUCT in my project and find it very useful. Thanks for the great work.
When I was using the library, I came up with an idea that makes a similar BOOST_HANA_DEFINE_STRUCT, with much shorter compile time. I made a proof-of-concept and it shows 5x time saving and 4x memory saving (will show later).
Since Hana is a library that features fast compile time, I think my proposal can help makes Hana a better library, and I want to make contribution.
The proposal is a macro like BOOST_HANA_ADAPT_STRUCT.
The benchmark is accessible here.
How do you think about this proposal? If you consider this is suitable, can you instruct me some ways to glue this namedtuple into Hana?
The text was updated successfully, but these errors were encountered:
Hi developers, I have used
BOOST_HANA_DEFINE_STRUCT
in my project and find it very useful. Thanks for the great work.When I was using the library, I came up with an idea that makes a similar
BOOST_HANA_DEFINE_STRUCT
, with much shorter compile time. I made a proof-of-concept and it shows 5x time saving and 4x memory saving (will show later).Since Hana is a library that features fast compile time, I think my proposal can help makes Hana a better library, and I want to make contribution.
The proposal is a macro like
BOOST_HANA_ADAPT_STRUCT
.Using this macro,
MyStruct
almost becomes a tuple, bound with member name.my.get<0>()
isa
my.get<1>()
isb
my.get<2>()
isc
my.get<3>()
isd
MyStruct::get_name(0)
is"a"
MyStruct::get_name(1)
is"b"
MyStruct::get_name(2)
is"c"
MyStruct::get_name(3)
is"d"
MyStruct::num_members
is4
This acts like python
namedtuple
, which allows iterating all members/names using fold expression (c++17) or recursion (pre c++17).For example, this
namedtuple
allowed me to create a generic argument parser works as below:Or I can implement a generic JSON print function like the example in
Hana::Struct
.The implemention of
namedtuple
is simple. Withboost.preprocessor
I only need 10 lines of macro, which is expanded to:The benchmark is accessible here.
How do you think about this proposal? If you consider this is suitable, can you instruct me some ways to glue this
namedtuple
into Hana?The text was updated successfully, but these errors were encountered: