To state the obvious, there is no reflection in C or C ++. Therefore, there is no reliable way to list member variables (by default).
If you have control over the data structure, you can try std::vector<boost::any> or std::map<std::string, boost::any> , and then add all the member variables to the vector / map .
Of course, this means that all of your variables are likely to be on the heap, so defeat will be achieved with this approach. Using the std :: map approach, this means that you will have a peculiar reflection of the "poor."
source share