the question can sound a bit unusual. Let's take a POD struct:
struct MyStruct
{
int myInt;
double myDouble;
AnotherPOD* myPointer;
};
The compiler knows the list of available data members. Do you know any way to get list of data member name (and type) either at compile time (better) or at run time?
I have a huge amount of POD structs and I would like to automate the creation of operator<<.
I know I could create a parser for the header files, create some files and compile those. However, I am sure the compiler has already had this information and I would like to exploit it.
Any ideas?
Thanks
BOOST_FUSION_ADAPT_STRUCT introduces compile-time reflection (which is awesome).
It is up to you to map this to run-time reflection of course, and it won't be too easy, but it is possible in this direction, while it would not be in the reverse :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With