I have a struct like this one:
struct Player {
POINT3D headPosition;
POINT3D position;
POINT2D view;
INT32 health;
// etc...
};
And I would like to iterate through the members of this struct to do some actions, a bit like we could do with foreach in some other languages.
Is there any way I could do something like that in C++? My research indicate that it is not possible natively, I found that it could be possible with some library like Boost.Hana, but I would like to be sure first that there is absolutely no other ways without a third party library. Even something with macros or generated at compilation time would do. Since we know exactly the struct it has to be automatable somehow. You can ignore the problems related to different data types for my issue, in the "foreach" loop I will give the member variable to a template function that accepts all types of variables found in that struct.
Thank you for your help on this matter.