MetaClassInstance c=reflection::MakeClassInstance(instance_ptr); MetaFunction f=c->GetFunction("GetSize"); float size=f();In this case, a MetaClassInstance contains a pointer to an instance, and automatic meta-data saying what kind of class it points to. A MetaFunction contains the instance pointer, and a reference to the function we asked for - if it exists. Then we call the overloaded () operator of MetaFunction, and this invokes the function, which obviously knows what class instance it refers to. So we could just say:
float f=MakeClassInstance(instance_ptr).GetFunction("GetSize")();- although, obviously we want exceptions or some kind of error output if the class has no function GetSize(), or it takes one or more arguments, or doesn't return something that converts to float. Would this kind of system be worthwhile to the community? Would you use it, or roll your own? Have you already rolled your own, and if so, how did you get on? And for this kind of system what would be a good syntax for the meta functions?