In my project I want to do something like following:
static void test0(void)
{
printf("%s [%d]\n", __func__, __LINE__);
}
static void test0(int a)
{
printf("%s [%d] %d\n", __func__, __LINE__, a);
}
static std::map<std::string, void*> initializeAddressMap()
{
std::map<std::string, void*> addressmap;
addressmap["test0"] = (void*) &test0; // ERROR HERE <------
return addressmap;
}
Basically, the third function returns a mapping of string
to function address. However, at this point, I get an error address of overloaded function with no contextual type information
, which also makes sense, since I have overloaded the test0
function, and compiler at this point doesn't know the address of which function to take. Is there any way I could address this problem, other than calling my functions different names?