A possible way of doing this is to make the return type of the overloaded functions store the information of the specific function:
template<class _ret_t, class _func_t>
struct tpinf
{
using ret_t = _ret_t;
using func_t = _func_t;
ret_t value;
};
tpinf<int, int(*)(double)> func(int n) { ... }
tpinf<int, int(*)(char)> func(char c) { ... }
int main()
{
int n = 56;
using resolved_function_type = decltype(func(n))::func_t;
auto v = func(n).value; // access returned object
return 0;
}
The problem is, I might want to know which overload is resolved of some predefined or standard functions, for that I have to rewrite those functions, which is not a good idea. So is there a more efficient way to achieve this?
You can take the address of an overloaded function in a context where which overload you want is unambiguous.