These are chat archives for boostorg/hana

19th
Feb 2017
Scott Santucci
@ScottFreeCode
Feb 19 2017 21:30
Does the BOOST_HANA_DEFINE_STRUCT macro support giving the struct members default values? Or would I have to use regular structs and the BOOST_HANA_ADAPT_STRUCT macro?
Jason Rice
@ricejasonf
Feb 19 2017 21:55
I doubt the macro supports it. not at my comp to check tho
Scott Santucci
@ScottFreeCode
Feb 19 2017 21:58
Also, I'm sort of trying to reverse the serialization example -- read in data (at runtime) and use it to set the value of the field that matches the key if there is a matching key in the struct; is this sort of thing possible? I'm a little stuck on checking for or comparing against a runtime string instead of a hana::string; I eventually tried a comparison using find_if and a predicate that uses .c_str(), but that didn't work (gave an error that doesn't really say anything meaningful to me and I'm not sure which part of the infodump is relevant). Any pointers (pun not intended)?
[edits for clarity]
Jason Rice
@ricejasonf
Feb 19 2017 22:02
I did this in my project nbdl with jsoncpp. dont remember how i dis the equals check
*did
Scott Santucci
@ScottFreeCode
Feb 19 2017 22:07
Jason Rice
@ricejasonf
Feb 19 2017 22:11
yes it doesnt use hana::Struct but its the same concept
Scott Santucci
@ScottFreeCode
Feb 19 2017 22:12
Aaah.
Interesting; I will see if I can find what it's doing. Thanks.
Scott Santucci
@ScottFreeCode
Feb 19 2017 23:23
I think I might be able to do it with an ordinary runtime loop instead of a Hana algorithm (I suspect the root of my problem is that the Hana functions all act at compile-time) provided I can find a way to get the length of the accessors list... or have a way to convert the accessors list into a runtime list that would have a length available.
Aha -- hana::length(Foldable) ought to do it? Let me fiddle with the code and see.
Hmm, that won't quite work -- I can only get the accessor at a given index if the index is a compile-time variable.