At this point, it appears that the hammer almost works, so if you can bear with me for a few iterations, I would appreciate it.
I have solved the std::map problem by adding a #include <map>.
So I try the code:
Code:
//define a function pointer
typedef double (*fnc_ptr)(double x);
//this will be your function registry
std::map<std::string, fnc_ptr> fncRegistry;
//maybe this is not actually needed [I try with and without this line, of course]
double MYROUTINE_A(double x);
double MYROUTINE_A(double x)
{
fncRegistry("MYROUTINE_A", MYROUTINE_A); // < this line now has the error
//define the function
}
double MYBOSSESROUTINE(const char* z)
{
....
fncRegistry(z)(10.2); //call z
....
}
Defining the function pointer survives the compiler.
Establishing the map, aka function registry survives the compiler.
When I add the line above the comment indicating that further code defines the function, the compiler complains with:
error C2064: term does not evaluate to a function taking 2 arguments.
I must admit, putting the line "fncRegistry("MYROUTINE_A", MYROUTINE_A)" *inside* the definition of the function itself puzzles me. If the purpose is to add the information to the registry, one would think you would do it once, not every time the function is called.
In any event, that is where I'm stuck right now. I will continue to massage what I can and ask that if anybody spots the specific issue to please let me know.
brewbuck, I appreciate your point of view, but there are very good reasons (well beyond this one project) where the name of the function [or a portion of the name of the function] will be defined in such a way as to make it subject to input from higher up the food chain (including all the way to the user), so consider this a prototype. Many text based languages have this construct built in. I'm not complaining about the fact that it isn't built-in here, just trying to re-create the capability.