Hey guys. I have this project where I need to use a structure without knowing what its name is nor how its members are named. I decided to force the user to add a static const char* Format variable which holds information on the type of the members only (i = int, d = double..) and this way I can somewhat get around this problem. However, it seems that some of my calculations are wrong even though when I tried it with a dummy class and a few pointers in the main() function it worked, now that I integrated all of this into my class, there's a problem. I stepped through with the debugger and all the values are correct; however, the debugger also revealed that only the first variable is modified (i.e. the pointer is not shifted properly to the next variable). How is this possible according to the following code ? I have checked back my algorithm and it seems correct to me.
template <typename ArgT>
void ProcessVar(void* ptr, ArgT* var, std::string tmp)
*((ArgT*)ptr) = *var; // This sets the variable pointed to to *var
ptr = ((ArgT*)ptr + 1); // This is the line shifting the pointer