C ++ does not support this. To sort through the elements of a structure, you need to somehow find out what the members of the structure are. Compiled C ++ programs do not have this information. For them, a structure is just a collection of bytes.
Languages ββlike C # (actually .NET) and Java can do this because they store structure information (reflection information) with the program.
If you really desperately need this function, you can try to implement this by examining the symbol file created by the compiler. It is, however, extremely advanced, and it is unlikely that it is worth the effort.
source share