Is it possible to determine the type of function of the candidate who will choose the resolution of the overload, taking into account the set of overload and the list of arguments? For example, given:
char* f(int); int f(char*);
I would like to write something like:
overload<f, short>::type x;
to declare a variable x type char* (*)(int) .
Is it possible? My first instinct was to write something like this:
template<typename... Args> struct overload { template<typename Ret> static auto deduce(Ret (*fptr)(Args...)) -> decltype(fptr); };
... but this cannot handle inaccurate matches (i.e. decltype(overload<int>::deduce(f)) works, but decltype(overload<short>::deduce(f)) doesn't).
c ++ c ++ 11 templates template-meta-programming overload-resolution
0x5f3759df
source share