when using either the '.', '->' or '->*' operators is there any way of getting the name of the function invoked (or the name of the variable in the case of '->*' and everything goes.
EDIT: Just to clarify I'm not talking about reflection but more something in the line of 'function' basically I want to create an overload of an operator (preferrably one of the three mentioned) which is aware of the right side of the operator
What I'm trying to accomplish is basically a compile time transformation of
obj->Function(a,b);
to
obj->Map("Function")(a,b); //Where Map(string) returns a function pointer
EDIT: Just to further clarify, The requirement is that the code will have to look like one of these three
obj.SomeMethod(args);
obj->SomeMethod(args);
obj->*SomeMethod(args);
any solution that fits that is acceptable as long as SomeMethod can be any valid identifier (I.e. any thing that can be used as a function name) and the solution will have to use SomeMethod as a lookup in a Map. The Map part is already implemented it's only the reinterpretation of what looks like a method call I seeking a solution to.
if that (as I'm affraid) can't be done then any solution with a new "operator" syntax will be accepted. Such as obj __ SomeMethod(args); as long as the lookup is based on the RHS of the "operator"
As far as I know, no. C++ does not support any form of reflection, so in order to get this kind of information you have to design your own tools and tricks.
C++ doesn't have any kind of reflection. The names of the functions are gone by the time that your executable is running. The only way to do it is to pass them in.
If you were planning to do something based on the method name, perhaps you just need virtual methods or overloading so that the right code is called.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With