How can I get a function pointer to the overloaded function that the compiler would choose after inspecting the arguments? In this example:
#include <iostream>
void MyFunction(float a){}
void MyFunction(int a){}
int main()
{
float a;
MyFunction(a);
void (*manualFunctionPointer)(float);
manualFunctionPointer(a);
// automaticFunctionPointer = ?
}
I have specified that I want a function pointer to the function that accepts a float and returns void. The compiler can certainly figure that out by itself, because the MyFunction(a) call calls the right function. Is there a way to get a function pointer to the function that the compiler chooses?
Replace the float in
With
Then whatever a changes too, manualFunctionPointer will follow